[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

/administrator/components/com_modules/helpers/html/ -> modules.php (source)

   1  <?php
   2  /**
   3   * @copyright    Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
   4   * @license        GNU General Public License version 2 or later; see LICENSE.txt
   5   */
   6  
   7  // no direct access
   8  defined('_JEXEC') or die;
   9  
  10  /**
  11   * @package        Joomla.Administrator
  12   * @subpackage    com_modules
  13   * @since        1.6
  14   */
  15  abstract class JHtmlModules
  16  {
  17      /**
  18       * @param    int $clientId    The client id
  19       * @param    string $state     The state of the template
  20       */
  21  	static public function templates($clientId = 0, $state = '')
  22      {
  23          $templates = ModulesHelper::getTemplates($clientId, $state);
  24          foreach ($templates as $template) {
  25              $options[]    = JHtml::_('select.option', $template->element, $template->name);
  26          }
  27          return $options;
  28      }
  29      /**
  30       */
  31  	static public function types()
  32      {
  33          $options = array();
  34          $options[] = JHtml::_('select.option', 'user', 'COM_MODULES_OPTION_POSITION_USER_DEFINED');
  35          $options[] = JHtml::_('select.option', 'template', 'COM_MODULES_OPTION_POSITION_TEMPLATE_DEFINED');
  36          return $options;
  37      }
  38  
  39      /**
  40       */
  41  	static public function templateStates()
  42      {
  43          $options = array();
  44          $options[] = JHtml::_('select.option', '1', 'JENABLED');
  45          $options[] = JHtml::_('select.option', '0', 'JDISABLED');
  46          return $options;
  47      }
  48  
  49      /**
  50       * Returns a published state on a grid
  51       *
  52       * @param   integer       $value            The state value.
  53       * @param   integer       $i                The row index
  54       * @param   boolean       $enabled            An optional setting for access control on the action.
  55       * @param   string        $checkbox            An optional prefix for checkboxes.
  56       *
  57       * @return  string        The Html code
  58       *
  59       * @see JHtmlJGrid::state
  60       *
  61       * @since   1.7.1
  62       */
  63  	public static function state($value, $i, $enabled = true, $checkbox = 'cb')
  64      {
  65          $states    = array(
  66              1    => array(
  67                  'unpublish',
  68                  'COM_MODULES_EXTENSION_PUBLISHED_ENABLED',
  69                  'COM_MODULES_HTML_UNPUBLISH_ENABLED',
  70                  'COM_MODULES_EXTENSION_PUBLISHED_ENABLED',
  71                  true,
  72                  'publish',
  73                  'publish'
  74              ),
  75              0    => array(
  76                  'publish',
  77                  'COM_MODULES_EXTENSION_UNPUBLISHED_ENABLED',
  78                  'COM_MODULES_HTML_PUBLISH_ENABLED',
  79                  'COM_MODULES_EXTENSION_UNPUBLISHED_ENABLED',
  80                  true,
  81                  'unpublish',
  82                  'unpublish'
  83              ),
  84              -1    => array(
  85                  'unpublish',
  86                  'COM_MODULES_EXTENSION_PUBLISHED_DISABLED',
  87                  'COM_MODULES_HTML_UNPUBLISH_DISABLED',
  88                  'COM_MODULES_EXTENSION_PUBLISHED_DISABLED',
  89                  true,
  90                  'warning',
  91                  'warning'
  92              ),
  93              -2    => array(
  94                  'publish',
  95                  'COM_MODULES_EXTENSION_UNPUBLISHED_DISABLED',
  96                  'COM_MODULES_HTML_PUBLISH_DISABLED',
  97                  'COM_MODULES_EXTENSION_UNPUBLISHED_DISABLED',
  98                  true,
  99                  'unpublish',
 100                  'unpublish'
 101              ),
 102          );
 103  
 104          return JHtml::_('jgrid.state', $states, $value, $i, 'modules.', $enabled, true, $checkbox);
 105      }
 106  
 107      /**
 108       * Display a batch widget for the module position selector.
 109       *
 110       * @param   integer  $clientId  The client ID
 111       *
 112       * @return  string  The necessary HTML for the widget.
 113       *
 114       * @since   2.5
 115       */
 116  	public static function positions($clientId)
 117      {
 118          // Create the copy/move options.
 119          $options = array(
 120              JHtml::_('select.option', 'c', JText::_('JLIB_HTML_BATCH_COPY')),
 121              JHtml::_('select.option', 'm', JText::_('JLIB_HTML_BATCH_MOVE'))
 122          );
 123  
 124          // Create the batch selector to change select the category by which to move or copy.
 125          $lines = array(
 126              '<label id="batch-choose-action-lbl" for="batch-choose-action">',
 127              JText::_('COM_MODULES_BATCH_POSITION_LABEL'),
 128              '</label>',
 129              '<fieldset id="batch-choose-action" class="combo">',
 130              '<select name="batch[position_id]" class="inputbox" id="batch-position-id">',
 131              '<option value="">' . JText::_('JSELECT') . '</option>',
 132              '<option value="nochange">' . JText::_('COM_MODULES_BATCH_POSITION_NOCHANGE') . '</option>',
 133              '<option value="noposition">' . JText::_('COM_MODULES_BATCH_POSITION_NOPOSITION') . '</option>',
 134              JHtml::_('select.options',    self::positionList($clientId)),
 135              '</select>',
 136              JHtml::_('select.radiolist', $options, 'batch[move_copy]', '', 'value', 'text', 'm'),
 137              '</fieldset>'
 138          );
 139  
 140          return implode("\n", $lines);
 141      }
 142  
 143      /**
 144       * Method to get the field options.
 145       *
 146       * @param   integer  $clientId  The client ID
 147       *
 148       * @return  array  The field option objects.
 149       *
 150       * @since   2.5
 151       */
 152  	public static function positionList($clientId = 0)
 153      {
 154          $db        = JFactory::getDbo();
 155          $query    = $db->getQuery(true);
 156  
 157          $query->select('DISTINCT(position) as value');
 158          $query->select('position as text');
 159          $query->from($db->quoteName('#__modules'));
 160          $query->where($db->quoteName('client_id') . ' = ' . (int) $clientId);
 161          $query->order('position');
 162  
 163          // Get the options.
 164          $db->setQuery($query);
 165  
 166          $options = $db->loadObjectList();
 167  
 168          // Check for a database error.
 169          if ($db->getErrorNum())
 170          {
 171              JError::raiseWarning(500, $db->getErrorMsg());
 172          }
 173  
 174          // Pop the first item off the array if it's blank
 175          if (strlen($options[0]->text) < 1)
 176          {
 177              array_shift($options);
 178          }
 179  
 180          return $options;
 181      }
 182  }


Generated: Tue Apr 3 11:40:28 2012 Cross-referenced by PHPXref 0.7.1