| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: content.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla.Framework 5 * @subpackage Table 6 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 7 * @license GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant 9 * to the GNU General Public License, and as distributed it includes or 10 * is derivative of works licensed under the GNU General Public License or 11 * other free or open source software licenses. 12 * See COPYRIGHT.php for copyright notices and details. 13 */ 14 15 // Check to ensure this file is within the rest of the framework 16 defined('JPATH_BASE') or die(); 17 18 19 /** 20 * Content table 21 * 22 * @package Joomla.Framework 23 * @subpackage Table 24 * @since 1.0 25 */ 26 class JTableContent extends JTable 27 { 28 /** @var int Primary key */ 29 var $id = null; 30 /** @var string */ 31 var $title = null; 32 /** @var string */ 33 var $alias = null; 34 /** @var string */ 35 var $title_alias = null; 36 /** @var string */ 37 var $introtext = null; 38 /** @var string */ 39 var $fulltext = null; 40 /** @var int */ 41 var $state = null; 42 /** @var int The id of the category section*/ 43 var $sectionid = null; 44 /** @var int DEPRECATED */ 45 var $mask = null; 46 /** @var int */ 47 var $catid = null; 48 /** @var datetime */ 49 var $created = null; 50 /** @var int User id*/ 51 var $created_by = null; 52 /** @var string An alias for the author*/ 53 var $created_by_alias = null; 54 /** @var datetime */ 55 var $modified = null; 56 /** @var int User id*/ 57 var $modified_by = null; 58 /** @var boolean */ 59 var $checked_out = 0; 60 /** @var time */ 61 var $checked_out_time = 0; 62 /** @var datetime */ 63 var $publish_up = null; 64 /** @var datetime */ 65 var $publish_down = null; 66 /** @var string */ 67 var $images = null; 68 /** @var string */ 69 var $urls = null; 70 /** @var string */ 71 var $attribs = null; 72 /** @var int */ 73 var $version = null; 74 /** @var int */ 75 var $parentid = null; 76 /** @var int */ 77 var $ordering = null; 78 /** @var string */ 79 var $metakey = null; 80 /** @var string */ 81 var $metadesc = null; 82 /** @var string */ 83 var $metadata = null; 84 /** @var int */ 85 var $access = null; 86 /** @var int */ 87 var $hits = null; 88 89 /** 90 * @param database A database connector object 91 */ 92 function __construct( &$db ) { 93 parent::__construct( '#__content', 'id', $db ); 94 } 95 96 /** 97 * Overloaded check function 98 * 99 * @access public 100 * @return boolean 101 * @see JTable::check 102 * @since 1.5 103 */ 104 function check() 105 { 106 /* 107 TODO: This filter is too rigorous,need to implement more configurable solution 108 // specific filters 109 $filter = & JFilterInput::getInstance( null, null, 1, 1 ); 110 $this->introtext = trim( $filter->clean( $this->introtext ) ); 111 $this->fulltext = trim( $filter->clean( $this->fulltext ) ); 112 */ 113 114 115 if(empty($this->title)) { 116 $this->setError(JText::_('Article must have a title')); 117 return false; 118 } 119 120 if(empty($this->alias)) { 121 $this->alias = $this->title; 122 } 123 $this->alias = JFilterOutput::stringURLSafe($this->alias); 124 125 if(trim(str_replace('-','',$this->alias)) == '') { 126 $datenow =& JFactory::getDate(); 127 $this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); 128 } 129 130 if (trim( str_replace( ' ', '', $this->fulltext ) ) == '') { 131 $this->fulltext = ''; 132 } 133 134 if(empty($this->introtext) && empty($this->fulltext)) { 135 $this->setError(JText::_('Article must have some text')); 136 return false; 137 } 138 139 // clean up keywords -- eliminate extra spaces between phrases 140 // and cr (\r) and lf (\n) characters from string 141 if(!empty($this->metakey)) { // only process if not empty 142 $bad_characters = array("\n", "\r", "\"", "<", ">"); // array of characters to remove 143 $after_clean = JString::str_ireplace($bad_characters, "", $this->metakey); // remove bad characters 144 $keys = explode(',', $after_clean); // create array using commas as delimiter 145 $clean_keys = array(); 146 foreach($keys as $key) { 147 if(trim($key)) { // ignore blank keywords 148 $clean_keys[] = trim($key); 149 } 150 } 151 $this->metakey = implode(", ", $clean_keys); // put array back together delimited by ", " 152 } 153 154 // clean up description -- eliminate quotes and <> brackets 155 if(!empty($this->metadesc)) { // only process if not empty 156 $bad_characters = array("\"", "<", ">"); 157 $this->metadesc = JString::str_ireplace($bad_characters, "", $this->metadesc); 158 } 159 160 return true; 161 } 162 163 /** 164 * Converts record to XML 165 * @param boolean Map foreign keys to text values 166 */ 167 function toXML( $mapKeysToText=false ) 168 { 169 $db =& JFactory::getDBO(); 170 171 if ($mapKeysToText) { 172 $query = 'SELECT name' 173 . ' FROM #__sections' 174 . ' WHERE id = '. (int) $this->sectionid 175 ; 176 $db->setQuery( $query ); 177 $this->sectionid = $db->loadResult(); 178 179 $query = 'SELECT name' 180 . ' FROM #__categories' 181 . ' WHERE id = '. (int) $this->catid 182 ; 183 $db->setQuery( $query ); 184 $this->catid = $db->loadResult(); 185 186 $query = 'SELECT name' 187 . ' FROM #__users' 188 . ' WHERE id = ' . (int) $this->created_by 189 ; 190 $db->setQuery( $query ); 191 $this->created_by = $db->loadResult(); 192 } 193 194 return parent::toXML( $mapKeysToText ); 195 } 196 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |