public function render($data = null) { if (!isset($data)) { $data = $this->getData(); } if (isset($this->_disabled_categories) && !empty($this->_disabled_categories)) { $this->_disableCategories($data, $this->getDisabledCategories()); } if (isset($this->_selected_categories) && !empty($this->_selected_categories)) { $this->_getSelectedChildNumbers($data, $this->getSelectedCategories()); } //Default bootstrap style of search is push-right, so we add this button first if ($this->useSearch()) { $this->addAction(new TreeToolbarSearchCategories('Find a category:', $this->getId() . '-categories-search')); $this->setAttribute('use_search', $this->useSearch()); } $collapse_all = new TreeToolbarLink('Collapse All', '#', '$(\'#' . $this->getId() . '\').tree(\'collapseAll\');$(\'#collapse-all-' . $this->getId() . '\').hide();$(\'#expand-all-' . $this->getId() . '\').show(); return false;', 'icon-collapse-alt'); $collapse_all->setAttribute('id', 'collapse-all-' . $this->getId()); $expand_all = new TreeToolbarLink('Expand All', '#', '$(\'#' . $this->getId() . '\').tree(\'expandAll\');$(\'#collapse-all-' . $this->getId() . '\').show();$(\'#expand-all-' . $this->getId() . '\').hide(); return false;', 'icon-expand-alt'); $expand_all->setAttribute('id', 'expand-all-' . $this->getId()); $this->addAction($collapse_all); $this->addAction($expand_all); if ($this->useCheckBox()) { $check_all = new TreeToolbarLink('Check All', '#', 'checkAllAssociatedCategories($(\'#' . $this->getId() . '\')); return false;', 'icon-check-sign'); $check_all->setAttribute('id', 'check-all-' . $this->getId()); $uncheck_all = new TreeToolbarLink('Uncheck All', '#', 'uncheckAllAssociatedCategories($(\'#' . $this->getId() . '\')); return false;', 'icon-check-empty'); $uncheck_all->setAttribute('id', 'uncheck-all-' . $this->getId()); $this->addAction($check_all); $this->addAction($uncheck_all); $this->setNodeFolderTemplate('tree_node_folder_checkbox.tpl'); $this->setNodeItemTemplate('tree_node_item_checkbox.tpl'); $this->setAttribute('use_checkbox', $this->useCheckBox()); } $this->setAttribute('selected_categories', $this->getSelectedCategories()); $this->getContext()->smarty->assign('root_category', Configuration::get('PS_ROOT_CATEGORY')); $this->getContext()->smarty->assign('token', Tools::getAdminTokenLite('AdminProducts')); return parent::render($data); }
public function render($data = null, $use_default_actions = true, $use_selected_shop = true) { if (!isset($data)) { $data = $this->getData(); } if ($use_default_actions) { $this->setActions(array(new TreeToolbarLink('Collapse All', '#', '$(\'#' . $this->getId() . '\').tree(\'collapseAll\'); return false;', 'icon-collapse-alt'), new TreeToolbarLink('Expand All', '#', '$(\'#' . $this->getId() . '\').tree(\'expandAll\'); return false;', 'icon-expand-alt'), new TreeToolbarLink('Check All', '#', 'checkAllAssociatedShops($(\'#' . $this->getId() . '\')); return false;', 'icon-check-sign'), new TreeToolbarLink('Uncheck All', '#', 'uncheckAllAssociatedShops($(\'#' . $this->getId() . '\')); return false;', 'icon-check-empty'))); } if ($use_selected_shop) { $this->setAttribute('selected_shops', $this->getSelectedShops()); } return parent::render($data); }
public function render($data = null) { if (!isset($data)) { $data = $this->getData(); } if (isset($this->_disabled_categories) && !empty($this->_disabled_categories)) { $this->_disableCategories($data, $this->getDisabledCategories()); } if (isset($this->_selected_categories) && !empty($this->_selected_categories)) { $this->_getSelectedChildNumbers($data, $this->getSelectedCategories()); } //Default bootstrap style of search is push-right, so we add this button first if ($this->useSearch()) { $this->addAction(new TreeToolbarSearchCategories('Find a category:', $this->getId() . '-categories-search')); $this->setAttribute('use_search', $this->useSearch()); } $collapse_all = new TreeToolbarLink('Collapse All', '#', '$(\'#' . $this->getId() . '\').tree(\'collapseAll\');$(\'#collapse-all-' . $this->getId() . '\').hide();$(\'#expand-all-' . $this->getId() . '\').show(); return false;', 'icon-collapse-alt'); $collapse_all->setAttribute('id', 'collapse-all-' . $this->getId()); $expand_all = new TreeToolbarLink('Expand All', '#', '$(\'#' . $this->getId() . '\').tree(\'expandAll\');$(\'#collapse-all-' . $this->getId() . '\').show();$(\'#expand-all-' . $this->getId() . '\').hide(); return false;', 'icon-expand-alt'); $expand_all->setAttribute('id', 'expand-all-' . $this->getId()); $this->addAction($collapse_all); $this->addAction($expand_all); if ($this->useCheckBox()) { $check_all = new TreeToolbarLink('Check All', '#', 'checkAllAssociatedCategories($(\'#' . $this->getId() . '\')); return false;', 'icon-check-sign'); $check_all->setAttribute('id', 'check-all-' . $this->getId()); $uncheck_all = new TreeToolbarLink('Uncheck All', '#', 'uncheckAllAssociatedCategories($(\'#' . $this->getId() . '\')); return false;', 'icon-check-empty'); $uncheck_all->setAttribute('id', 'uncheck-all-' . $this->getId()); $this->addAction($check_all); $this->addAction($uncheck_all); $this->setNodeFolderTemplate('tree_node_folder_checkbox.tpl'); $this->setNodeItemTemplate('tree_node_item_checkbox.tpl'); $this->setAttribute('use_checkbox', $this->useCheckBox()); } $this->setAttribute('selected_categories', $this->getSelectedCategories()); $this->getContext()->smarty->assign('root_category', Configuration::get('PS_ROOT_CATEGORY')); $this->getContext()->smarty->assign('token', Tools::getAdminTokenLite('AdminBlogPost')); $return = parent::render($data); // $admin_webpath = str_ireplace(_PS_CORE_DIR_, '', _PS_ADMIN_DIR_); // $admin_webpath = preg_replace('/^'.preg_quote(DIRECTORY_SEPARATOR, '/').'/', '', $admin_webpath); // $bo_theme = ((Validate::isLoadedObject($this->getContext()->employee) // && $this->getContext()->employee->bo_theme) ? $this->getContext()->employee->bo_theme : 'default'); // // if (!file_exists(_PS_BO_ALL_THEMES_DIR_.$bo_theme.DIRECTORY_SEPARATOR.'template')) { // $bo_theme = 'default'; // } // $js_path = __PS_BASE_URI__.$admin_webpath.'/themes/'.$bo_theme.'/js/tree.js'; // // $foundIndex = array_search($js_path, Context::getContext()->controller->js_files); // if(!empty($foundIndex)) // Context::getContext()->controller->removeJS($js_path); // unset(Context::getContext()->controller->js_files[$foundIndex]); $js_path = _MODULE_DIR_ . 'smartblog/views/js/tree.js'; if (Context::getContext()->controller->ajax) { if (!$this->_no_js) { $html = '<script type="text/javascript" src="' . $js_path . '"></script>'; } } else { Context::getContext()->controller->addJS($js_path); } return (isset($html) ? $html : '') . $return; }