Source for file contenttype.php

Documentation is available at contenttype.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  Table
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * Tags table
  14.  *
  15.  * @package     Joomla.Libraries
  16.  * @subpackage  Table
  17.  * @since       3.1
  18.  */
  19. class JTableContenttype extends JTable
  20. {
  21.     /**
  22.      * Constructor
  23.      *
  24.      * @param   JDatabaseDriver  $db  A database connector object
  25.      *
  26.      * @since   3.1
  27.      */
  28.     public function __construct($db)
  29.     {
  30.         parent::__construct('#__content_types''type_id'$db);
  31.     }
  32.  
  33.     /**
  34.      * Overloaded check method to ensure data integrity.
  35.      *
  36.      * @return  boolean  True on success.
  37.      *
  38.      * @since   3.1
  39.      * @throws  UnexpectedValueException
  40.      */
  41.     public function check()
  42.     {
  43.         // Check for valid name.
  44.         if (trim($this->type_title== '')
  45.         {
  46.             throw new UnexpectedValueException(sprintf('The title is empty'));
  47.         }
  48.  
  49.         $this->type_title ucfirst($this->type_title);
  50.  
  51.         if (empty($this->type_alias))
  52.         {
  53.             throw new UnexpectedValueException(sprintf('The type_alias is empty'));
  54.         }
  55.  
  56.         return true;
  57.     }
  58.  
  59.     /**
  60.      * Overridden JTable::store.
  61.      *
  62.      * @param   boolean  $updateNulls  True to update fields even if they are null.
  63.      *
  64.      * @return  boolean  True on success.
  65.      *
  66.      * @since   3.1
  67.      */
  68.     public function store($updateNulls false)
  69.     {
  70.         // Verify that the alias is unique
  71.         $table JTable::getInstance('Contenttype''JTable');
  72.  
  73.         if ($table->load(array('type_alias' => $this->type_alias)) && ($table->type_id != $this->type_id || $this->type_id == 0))
  74.         {
  75.             $this->setError(JText::_('COM_TAGS_ERROR_UNIQUE_ALIAS'));
  76.  
  77.             return false;
  78.         }
  79.  
  80.         return parent::store($updateNulls);
  81.     }
  82.  
  83.     /**
  84.      * Method to expand the field mapping
  85.      *
  86.      * @param   boolean  $assoc  True to return an associative array.
  87.      *
  88.      * @return  mixed  Array or object with field mappings. Defaults to object.
  89.      *
  90.      * @since   3.1
  91.      */
  92.     public function fieldmapExpand($assoc true)
  93.     {
  94.         return $this->fieldmap json_decode($this->fieldmappings$assoc);
  95.     }
  96.  
  97.     /**
  98.      * Method to get the id given the type alias
  99.      *
  100.      * @param   string  $typeAlias  Content type alias (for example, 'com_content.article').
  101.      *
  102.      * @return  mixed  type_id for this alias if successful, otherwise null.
  103.      *
  104.      * @since   3.2
  105.      */
  106.     public function getTypeId($typeAlias)
  107.     {
  108.         $db $this->_db;
  109.         $query $db->getQuery(true);
  110.         $query->select($db->quoteName('type_id'))
  111.             ->from($db->quoteName('#__content_types'))
  112.             ->where($db->quoteName('type_alias'' = ' $db->quote($typeAlias));
  113.         $db->setQuery($query);
  114.  
  115.         return $db->loadResult($query);
  116.     }
  117.  
  118.     /**
  119.      * Method to get the JTable object for the content type from the table object.
  120.      *
  121.      * @return  mixed  JTable object on success, otherwise false.
  122.      *
  123.      * @since   3.2
  124.      */
  125.     public function getContentTable()
  126.     {
  127.         $result false;
  128.         $tableInfo json_decode($this->table);
  129.  
  130.         if (is_object($tableInfo&& isset($tableInfo->special))
  131.         {
  132.             if (is_object($tableInfo->special&& isset($tableInfo->special->type&& isset($tableInfo->special->prefix))
  133.             {
  134.                 $result JTable::getInstance($tableInfo->special->type$tableInfo->special->prefix);
  135.             }
  136.         }
  137.  
  138.         return $result;
  139.     }
  140. }

Documentation generated on Tue, 19 Nov 2013 14:57:01 +0100 by phpDocumentor 1.4.3