Example #1
0
 public function renderEditForm($tpl = null)
 {
     $this->loadObject(true);
     $app = JFactory::getApplication();
     if (!isset($this->context)) {
         $this->context = JeproshopContext::getContext();
     }
     $shop_id = JeproshopContext::getContext()->shop->shop_id;
     $selected_categories = array(isset($this->context->controller->category->parent_id) && $this->context->controller->category->isParentCategoryAvailable($shop_id) ? (int) $this->context->controller->category->parent_id : $app->input->get('parent_id', JeproshopCategoryModelCategory::getRootCategory()->category_id));
     $unidentified = new JeproshopGroupModelGroup(JeproshopSettingModelSetting::getValue('unidentified_group'));
     $guest = new JeproshopGroupModelGroup(JeproshopSettingModelSetting::getValue('guest_group'));
     $default = new JeproshopGroupModelGroup(JeproshopSettingModelSetting::getValue('customer_group'));
     $unidentified_group_information = '<b>' . $unidentified->name[$this->context->language->lang_id] . '</b> ' . JText::_('COM_JEPROSHOP_ALL_PEOPLE_WITHOUT_A_VALID_CUSTOMER_ACCOUNT_MESSAGE');
     $guest_group_information = '<b>' . $guest->name[$this->context->language->lang_id] . '</b> ' . JText::_('COM_JEPROSHOP_CUSTOMER_WHO_PLACED_AN_ORDER_WITH_THE_GUEST_CHECKOUT_MESSAGE');
     $default_group_information = '<b>' . $default->name[$this->context->language->lang_id] . '</b> ' . JText::_('COM_JEPROSHOP_ALL_PEOPLE_WHO_HAVE_CREATED_AN_CREATED_AN_ACCOUNT_ON_THIS_SITE_MESSAGE');
     $this->assignRef('unidentified_group_information', $unidentified_group_information);
     $this->assignRef('guest_group_information', $guest_group_information);
     $this->assignRef('default_group_information', $default_group_information);
     $image = COM_JEPROSHOP_CATEGORY_IMAGE_DIR . $this->context->controller->category->category_id . '.jpg';
     $image_url = JeproshopImageManager::thumbnail($image, 'category_' . $this->context->controller->category->category_id . '.jpg', 350, 'jpg', true, true);
     $imageSize = file_exists($image) ? filesize($image) / 1000 : false;
     $shared_category = JeproshopTools::isLoadedObject($this->context->controller->category, 'category_id') && $this->context->controller->category->hasMultishopEntries();
     $this->assignRef('shared_category', $shared_category);
     $allow_accented_chars_url = (int) JeproshopSettingModelSetting::getValue('allow_accented_chars_url');
     $this->assignRef('allow_accented_chars_url', $allow_accented_chars_url);
     //$this->assignRef('selected_categories', $selected_categories);
     $categories_tree = new JeproshopCategoriesTree('jform_categories_tree', JText::_('COM_JEPROSHOP_CATEGORIES_LABEL'), null, $this->context->language->lang_id);
     $categories_tree->setTreeTemplate('associated_categories')->setSelectedCategories($selected_categories)->setUseCheckBox(true)->setInputName('parent_id');
     $categories_data = $categories_tree->render();
     $this->assignRef('categories_tree', $categories_data);
     $image = JeproshopImageManager::thumbnail(COM_JEPROSHOP_CATEGORY_IMAGE_DIR . '/' . $this->context->controller->category->category_id . '.jpg', 'category_' . (int) $this->context->controller->category->category_id . '.jpg', 350, 'jpg', true);
     $this->assignRef('image', $image ? $image : false);
     $size = $image ? filesize(COM_JEPROSHOP_CATEGORY_IMAGE_DIR . '/' . $this->context->controller->category->category_id . 'jpg') / 1000 : false;
     $this->assignRef('size', $size);
     $category_group_ids = $this->context->controller->category->getGroups();
     $groups = JeproshopGroupModelGroup::getGroups($this->context->language->lang_id);
     //if empty $carrier_groups_ids : object creation : we set the default groups
     if (empty($category_group_ids)) {
         $preSelected = array(JeproshopSettingModelSetting::getValue('unidentified_group'), JeproshopSettingModelSetting::getValue('guest_group'), JeproshopSettingModelSetting::getValue('customer_group'));
         $category_group_ids = array_merge($category_group_ids, $preSelected);
     }
     foreach ($groups as $group) {
         $groupBox = $app->input->get('group_box_' . $group->group_id, in_array($group->group_id, $category_group_ids));
         $this->assignRef('group_box_' . $group->group_id, $groupBox);
     }
     $is_root_category = (bool) $app->input->get('is_root_category');
     $this->assignRef('is_root_category', $is_root_category);
     $helper = new JeproshopHelper();
     $this->assignRef('helper', $helper);
     $this->assignRef('groups', $groups);
     $this->addToolBar();
     $this->sideBar = JHtmlSideBar::render();
     parent::display($tpl);
 }
Example #2
0
 private function initAssociationsForm()
 {
     $app = JFactory::getApplication();
     /** prepare category tree **/
     $root = JeproshopCategoryModelCategory::getRootCategory();
     $default_category_id = $this->context->cookie->products_filter_category_id ? $this->context->cookie->products_filter_category_id : JeproshopContext::getContext()->shop->category_id;
     $categoryBox = $app->input->get('category_box', array($default_category_id));
     if (!$this->product->product_id || !$this->product->isAssociatedToShop()) {
         $selected_category = JeproshopCategoryModelCategory::getCategoryInformations($categoryBox, $this->context->controller->default_form_language);
     } else {
         if ($categoryBox) {
             $selected_category = JeproshopCategoryModelCategory::getCategoryInformations($categoryBox);
         } else {
             $selected_category = JeproshopProductModelProduct::getProductCategoriesFull($this->product->product_id, $this->context->controller->default_form_language);
         }
     }
     // Multishop block
     $feature_shop_active = JeproshopShopModelShop::isFeaturePublished();
     $this->assignRef('feature_shop_published', $feature_shop_active);
     /** Accessories **/
     $accessories = JeproshopProductModelProduct::getAccessoriesLight($this->context->language->lang_id, $this->product->product_id);
     $postAccessories = $app->input->get('input_accessories');
     if ($postAccessories) {
         $postAccessoriesTab = explode('-', $postAccessories);
         foreach ($postAccessoriesTab as $accessory_id) {
             $accessory = JeproshopProductModelProduct::getAccessoryById($accessory_id);
             if (!$this->hasThisAccessory($accessory_id, $accessories) && $accessory) {
                 $accessories[] = $accessory;
             }
         }
     }
     $this->assignRef('accessories', $accessories);
     $this->product->manufacturer_name = JeproshopManufacturerModelManufacturer::getNameById($this->product->manufacturer_id);
     $categories = array();
     foreach ($selected_category as $key => $category) {
         $categories[] = $key;
     }
     $manufacturers = JeproshopManufacturerModelManufacturer::getManufacturers($this->context->language->lang_id);
     $categories_tree = new JeproshopCategoriesTree('associated_categories_tree', JText::_('COM_JEPROSHOP_ASSOCIATED_CATEGORIES_LABEL'));
     $categories_tree->setTreeLayout('associated_categories')->setRootCategory((int) $root->category_id)->setUseCheckBox(true)->setSelectedCategories($categories);
     $this->assignRef('manufacturers', $manufacturers);
     $selected_category_ids = implode(',', array_keys($selected_category));
     $this->assignRef('selected_category_ids', $selected_category_ids);
     $this->assignRef('selected_category', $selected_category);
     $categoryId = $this->product->getDefaultCategoryId();
     $this->assignRef('default_category_id', $categoryId);
     $category_tree = $categories_tree->render();
     $this->assignRef('category_tree', $category_tree);
     $is_shop_context = JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP;
     $this->assignRef('is_shop_context', $is_shop_context);
 }