Esempio n. 1
0
 protected function getOptions()
 {
     //check com_vituemart existed
     $path = JPATH_ADMINISTRATOR . '/components/com_virtuemart';
     if (!is_dir($path) || !file_exists(JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php')) {
         $this->options[] = JHtml::_('select.option', '', JText::_('COM_VIRTUEMART_NOT_EXIST'));
     } else {
         // Initialize variables
         require_once JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php';
         require_once JPATH_ADMINISTRATOR . '/components/com_virtuemart/models/category.php';
         VmConfig::loadConfig();
         $categoryModel = new VirtueMartModelCategory();
         $categoryModel->_noLimit = true;
         $categories = $categoryModel->getCategories();
         if (count($categories)) {
             // iterating
             $temp_options = array();
             foreach ($categories as $item) {
                 array_push($temp_options, array($item->virtuemart_category_id, $item->category_name, $item->category_parent_id));
             }
             foreach ($temp_options as $option) {
                 if ($option[2] == 0) {
                     $this->options[] = JHtml::_('select.option', $option[0], $option[1]);
                     $this->recursive_options($temp_options, 1, $option[0]);
                 }
             }
         }
     }
     return $this->options;
 }