コード例 #1
0
ファイル: category.php プロジェクト: jeprodev/jeproshop
 public function initialize()
 {
     $app = JFactory::getApplication();
     $context = JeproshopContext::getContext();
     parent::initialize();
     $category_id = $app->input->get('category_id');
     $task = $app->input->get('task');
     if ($category_id && $task != 'delete') {
         $this->category = new JeproshopCategoryModelCategory($category_id);
     } else {
         if (JeproshopShopModelShop::isFeaturePublished() && JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP) {
             $this->category = new JeproshopCategoryModelCategory($context->shop->category_id);
         } elseif (count(JeproshopCategoryModelCategory::getCategoriesWithoutParent()) > 1 && JeproshopSettingModelSetting::getValue('multishop_feature_active') && count(JeproshopShopModelShop::getShops(true, null, true)) != 1) {
             $this->category = JeproshopCategoryModelCategory::getTopCategory();
         } else {
             $this->category = new JeproshopCategoryModelCategory(JeproshopSettingModelSetting::getValue('root_category'));
         }
     }
     if (JeproshopTools::isLoadedObject($this->category, 'category_id') && !$this->category->isAssociatedToShop() && JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP) {
         $app->redirect('index.php?option=com_jeproshop&view=category&task=edit&category_id=' . (int) $context->shop->getCategoryId() . '&' . JeproshopTools::getCategoryToken() . '=1');
     }
 }
コード例 #2
0
ファイル: category.php プロジェクト: jeprodev/jeproshop
 /**
  * Recursive scan of subcategories
  *
  * @param integer $max_depth Maximum depth of the tree (i.e. 2 => 3 levels depth)
  * @param integer $current_depth specify the current depth in the tree (don't use it, only for recursive!)
  * @param integer $lang_id Specify the id of the language used
  * @param array $excluded_ids_array specify a list of ids to exclude of results
  *
  * @return array Subcategories lite tree
  */
 public function recurseLiteCategoryTree($max_depth = 3, $current_depth = 0, $lang_id = null, $excluded_ids_array = null)
 {
     $lang_id = is_null($lang_id) ? JeproshopContext::getContext()->language->lang_id : (int) $lang_id;
     $children = array();
     $subCategories = $this->getSubCategories($lang_id, true);
     if (($max_depth == 0 || $current_depth < $max_depth) && $subCategories && count($subCategories)) {
         foreach ($subCategories as &$subCategory) {
             if (!$subCategory->category_id) {
                 break;
             } else {
                 if (!is_array($excluded_ids_array) || !in_array($subCategory->category_id, $excluded_ids_array)) {
                     $category = new JeproshopCategoryModelCategory($subCategory->category_id, $lang_id);
                     $children[] = $category->recurseLiteCategoryTree($max_depth, $current_depth + 1, $lang_id, $excluded_ids_array);
                 }
             }
         }
     }
     if (is_array($this->description)) {
         foreach ($this->description as $language_id => $description) {
             $this->description[$language_id] = JeproshopTools::getDescriptionClean($description);
         }
     } else {
         $this->description = JeproshopTools::getDescriptionClean($this->description);
     }
     return array('category_id' => (int) $this->category_id, 'link' => JRoute::_('index.php?option=com_jeproshop&view=category&category_id=' . $this->category_id . '&link_rewrite=' . $this->link_rewrite . '&' . JeproshopTools::getCategoryToken() . '=1'), 'name' => $this->name, 'desc' => $this->description, 'children' => $children);
 }