Source for file contenttype.php

Documentation is available at contenttype.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  Form
  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('JPATH_BASE'or die;
  11.  
  12.  
  13. /**
  14.  * Form Field class for the Joomla Framework.
  15.  *
  16.  * @package     Joomla.Libraries
  17.  * @subpackage  Form
  18.  * @since       3.1
  19.  */
  20. {
  21.     /**
  22.      * A flexible tag list that respects access controls
  23.      *
  24.      * @var    string 
  25.      * @since  3.1
  26.      */
  27.     public $type = 'Contenttype';
  28.  
  29.     /**
  30.      * Method to get the field input for a list of content types.
  31.      *
  32.      * @return  string  The field input.
  33.      *
  34.      * @since   3.1
  35.      */
  36.     protected function getInput()
  37.     {
  38.         if (!is_array($this->value))
  39.         {
  40.             if (is_object($this->value))
  41.             {
  42.                 $this->value = $this->value->tags;
  43.             }
  44.  
  45.             if (is_string($this->value))
  46.             {
  47.                 $this->value = explode(','$this->value);
  48.             }
  49.         }
  50.  
  51.         $input parent::getInput();
  52.  
  53.         return $input;
  54.     }
  55.  
  56.     /**
  57.      * Method to get a list of content types
  58.      *
  59.      * @return  array  The field option objects.
  60.      *
  61.      * @since   3.1
  62.      */
  63.     protected function getOptions()
  64.     {
  65.         $db        JFactory::getDbo();
  66.         $query    $db->getQuery(true)
  67.             ->select('a.type_id AS value, a.type_title AS text')
  68.             ->from('#__content_types AS a')
  69.  
  70.             ->order('a.type_title ASC');
  71.  
  72.         // Get the options.
  73.         $db->setQuery($query);
  74.  
  75.         try
  76.         {
  77.             $options $db->loadObjectList();
  78.         }
  79.         catch (RuntimeException $e)
  80.         {
  81.             return false;
  82.         }
  83.  
  84.         // Merge any additional options in the XML definition.
  85.         $options array_merge(parent::getOptions()$options);
  86.  
  87.         foreach ($options as $option)
  88.         {
  89.             $option->text mb_strtoupper(str_replace(' ''_'$option->text)'UTF-8');
  90.             $option->text 'COM_TAGS_CONTENT_TYPE_' $option->text;
  91.             $option->text JText::_($option->text);
  92.         }
  93.  
  94.         return $options;
  95.     }
  96. }

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