コード例 #1
0
ファイル: vmcategories.php プロジェクト: romuland/khparts
 /**
  * Gets the list of vm categories with multiple select formatting
  * @author Florian Voutzinos
  * @return string
  */
 function getInput()
 {
     $categoryTree = VmJcommentsHelperFormField::categoryListTree();
     $key = $this->element['key_field'] ? $this->element['key_field'] : 'value';
     $val = $this->element['value_field'] ? $this->element['value_field'] : $this->name;
     // Dynamic height
     $size = count($categoryTree);
     if ($size > 100) {
         $size = 100;
     }
     // '[]' is needed after $this->name in order to multiselect !
     return JHTML::_('select.genericlist', $categoryTree, $this->name . '[]', 'class="inputbox" multiple="multiple" style="width: 150px" size="' . $size . '"', $key, $val, $this->value, $this->id);
 }
コード例 #2
0
ファイル: formfield.php プロジェクト: romuland/khparts
 /**
  * Creates and  returns an ordered array of categories with catids as keys
  * and category name as values
  * 
  * @author Florian Voutzinos (adapted from vm 2)
  * @param int $cid virtuemart category id
  * @param int $level category level
  * @return array with virtuemart_category_id as $key and category_name as $value
  */
 public static function categoryListTree($cid = 0, $level = 0)
 {
     if (empty(self::$categoryTree)) {
         $cache =& JFactory::getCache();
         $cache->setCaching(1);
         $categoryTree = $cache->call(array('VmJcommentsHelperFormField', 'getCategoryTree'), $cid, $level);
         // parse the retuned string and form a nice array with categories id
         // as key and categories name as value
         $cats = explode(':', $categoryTree);
         $categories = explode(',', $cats[0]);
         $catIds = explode(',', $cats[1]);
         $categoryTree = array_combine($catIds, $categories);
         array_pop($categoryTree);
         self::$categoryTree = $categoryTree;
     }
     return self::$categoryTree;
 }