예제 #1
0
 protected function getOptions()
 {
     // Initialise variables.
     $options = array();
     $published = (string) $this->element['published'];
     $languages = (string) $this->element['languages'];
     $name = (string) $this->element['name'];
     // insert custom options passed in xml file
     $options = array();
     if (!is_null($this->element->option)) {
         foreach ($this->element->option as $option) {
             $options[] = JHtml::_('select.option', $option->getAttribute('value'), JText::_($option->data()));
         }
     }
     // Filter over published state or not depending upon if it is present.
     // include k2item helper, which has the method we want
     require_once JPATH_PLUGINS . '/josetta_ext/k2item/helpers/helper.php';
     if ($published) {
         $categoriesoptions = JosettaK2ItemHelper::getCategoryOptionsPerLanguage(array('filter.published' => explode(',', $published), 'filter.languages' => explode(',', $languages)));
     } else {
         $categoriesoptions = JosettaK2ItemHelper::getCategoryOptionsPerLanguage(array('filter.languages' => explode(',', $languages)));
     }
     $options = array_merge($options, $categoriesoptions);
     if (!empty($this->element['show_root']) && strtolower($this->element['show_root']) == 'yes') {
         array_unshift($options, JHtml::_('select.option', '0', JText::_('JGLOBAL_ROOT')));
     }
     return $options;
 }
예제 #2
0
 /**
  * Format a the original field value for display on the translate view
  *
  * @param object $originalItem the actual data of the original item
  * @param string $originalFieldTitle the field title
  * @param object $field the Joomla! field object
  * @param string the formatted, ready to display, string
  */
 public function onJosettaGet3rdPartyFormatOriginalField($originalItem, $originalFieldTitle, $field)
 {
     $html = null;
     switch (strtolower($field->type)) {
         case 'k2languagecategory':
             // element id can be stored in 2 different locations, depending on plugin
             $elementId = empty($originalItem->request) || !isset($originalItem->request['id']) ? null : $originalItem->request['id'];
             $elementId = is_null($elementId) ? $originalItem->{$originalFieldTitle} : $elementId;
             if (is_array($elementId)) {
                 // mmultiple categories selected
                 $size = $field->element->getAttribute('size');
                 $size = empty($size) ? 10 : $size;
                 $html = '<select name="josetta_dummy" id="josetta_dummy" class="inputbox" size="' . $size . '" multiple="multiple" disabled="disabled">' . "\n";
                 $categoriesSelectConfig = array('filter.published' => array(0, 1), 'filter.languages' => array('*', JosettaHelper::getSiteDefaultLanguage()));
                 require_once JPATH_PLUGINS . '/josetta_ext/k2item/helpers/helper.php';
                 $categoriesOptionsHtml = JosettaK2ItemHelper::getCategoryOptionsPerLanguage($categoriesSelectConfig);
                 $html .= JHtml::_('select.options', $categoriesOptionsHtml, 'value', 'text', $elementId) . "\n";
                 $html .= "</select>\n";
             } else {
                 // just one category
                 if (empty($elementId)) {
                     $html = JText::_('ROOT');
                 } else {
                     require_once JPATH_PLUGINS . '/josetta_ext/k2item/helpers/helper.php';
                     $categories = JosettaK2ItemHelper::getCategoriesPerLanguage(null, 'id');
                     $categoryDetails = empty($categories[$elementId]) ? null : $categories[$elementId];
                     $html = empty($categoryDetails) ? $elementId : $categoryDetails->title;
                     if ($html == 'ROOT') {
                         $html = JText::_('ROOT');
                     }
                 }
             }
             break;
     }
     return $html;
 }