Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Joomla-Framework

License

Content on this site is copyright © 2005 - 2008 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5. Some parts of this website may be subject to other licenses.
Source code for file /joomla/database/table/content.php

Documentation is available at content.php

  1. <?php
  2. /**
  3. @version        $Id: content.php 9936 2008-01-13 22:44:03Z ircmaxell $
  4. @package        Joomla.Framework
  5. @subpackage    Table
  6. @copyright    Copyright (C) 2005 - 2008 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 $frontpage_up        = null;
  64.     /** @var datetime */
  65.     var $frontpage_down        = null;
  66.     /** @var datetime */
  67.     var $publish_up            = null;
  68.     /** @var datetime */
  69.     var $publish_down        = null;
  70.     /** @var string */
  71.     var $images                = null;
  72.     /** @var string */
  73.     var $urls                = null;
  74.     /** @var string */
  75.     var $attribs                = null;
  76.     /** @var int */
  77.     var $version                = null;
  78.     /** @var int */
  79.     var $parentid            = null;
  80.     /** @var int */
  81.     var $ordering            = null;
  82.     /** @var string */
  83.     var $metakey                = null;
  84.     /** @var string */
  85.     var $metadesc            = null;
  86.     /** @var string */
  87.     var $metadata            = null;
  88.     /** @var int */
  89.     var $access                = null;
  90.     /** @var int */
  91.     var $hits                = null;
  92.  
  93.     /**
  94.     * @param database A database connector object
  95.     */
  96.     function __construct&$db {
  97.         parent::__construct'#__content''id'$db );
  98.     }
  99.  
  100.     /**
  101.      * Overloaded check function
  102.      *
  103.      * @access public
  104.      * @return boolean 
  105.      * @see JTable::check
  106.      * @since 1.5
  107.      */
  108.     function check()
  109.     {
  110.         /*
  111.         TODO: This filter is too rigorous,need to implement more configurable solution
  112.         // specific filters
  113.         $filter = & JFilterInput::getInstance( null, null, 1, 1 );
  114.         $this->introtext = trim( $filter->clean( $this->introtext ) );
  115.         $this->fulltext =  trim( $filter->clean( $this->fulltext ) );
  116.         */
  117.  
  118.  
  119.         if(empty($this->title)) {
  120.             $this->setError(JText::_('Article must have a title'));
  121.             return false;
  122.         }
  123.  
  124.         if(empty($this->alias)) {
  125.             $this->alias = $this->title;
  126.         }
  127.         $this->alias = JFilterOutput::stringURLSafe($this->alias);
  128.  
  129.         if(trim(str_replace('-','',$this->alias)) == ''{
  130.             $datenow new JDate();
  131.             $this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S");
  132.         }
  133.  
  134.         if (trimstr_replace'&nbsp;'''$this->fulltext ) ) == ''{
  135.             $this->fulltext = '';
  136.         }
  137.  
  138.         if(empty($this->introtext&& empty($this->fulltext)) {
  139.             $this->setError(JText::_('Article must have some text'));
  140.             return false;
  141.         }
  142.  
  143.         return true;
  144.     }
  145.  
  146.     /**
  147.     * Converts record to XML
  148.     * @param boolean Map foreign keys to text values
  149.     */
  150.     function toXML$mapKeysToText=false )
  151.     {
  152.         $db =JFactory::getDBO();
  153.  
  154.         if ($mapKeysToText{
  155.             $query 'SELECT name'
  156.             . ' FROM #__sections'
  157.             . ' WHERE id = '. (int) $this->sectionid
  158.             ;
  159.             $db->setQuery$query );
  160.             $this->sectionid = $db->loadResult();
  161.  
  162.             $query 'SELECT name'
  163.             . ' FROM #__categories'
  164.             . ' WHERE id = '. (int) $this->catid
  165.             ;
  166.             $db->setQuery$query );
  167.             $this->catid = $db->loadResult();
  168.  
  169.             $query 'SELECT name'
  170.             . ' FROM #__users'
  171.             . ' WHERE id = ' . (int) $this->created_by
  172.             ;
  173.             $db->setQuery$query );
  174.             $this->created_by = $db->loadResult();
  175.         }
  176.  
  177.         return parent::toXML$mapKeysToText );
  178.     }
  179. }

Documentation generated on Tue, 29 Jan 2008 18:45:10 +0000 by phpDocumentor 1.3.1