protected function _build_menu($values)
 {
     // need to resort by sort_order property
     $offset = 0;
     // it needs for process repeating sort numbers
     $tmp = $this->item_ids = array();
     if (is_array($values)) {
         $rm = new AResourceManager();
         $rm->setType('image');
         $language_id = $this->registry->get('language')->getContentLanguageID();
         foreach ($values as &$item) {
             if ($item['item_icon_rl_id']) {
                 $r = $rm->getResource($item['item_icon_rl_id'], $language_id);
                 $item['item_icon_code'] = $r['resource_code'];
             }
             if (isset($tmp[$item['parent_id']][$item['sort_order']])) {
                 $offset++;
             }
             $tmp[$item['parent_id']][$item['sort_order'] + $offset] = $item;
             $this->item_ids[] = $item['item_id'];
         }
     }
     unset($item);
     $this->dataset_rows = $values;
     $menu = array();
     foreach ($tmp as $key => $item) {
         ksort($item);
         $menu[$key] = $item;
     }
     return $menu;
 }
Beispiel #2
0
 private function _getForm()
 {
     $view = new AView($this->registry, 0);
     $view->batchAssign($this->language->getASet('tool/rl_manager'));
     $view->assign('error_warning', $this->error['warning']);
     $view->assign('success', $this->session->data['success']);
     if (isset($this->session->data['success'])) {
         unset($this->session->data['success']);
     }
     $this->data = array();
     $this->data['error'] = $this->error;
     $rm = new AResourceManager();
     if (isset($this->request->get['rl_type'])) {
         $type_data = $rm->getResourceTypeByName($this->request->get['rl_type']);
     }
     $fields = array('type_id', 'type_name', 'default_directory', 'default_icon', 'file_types', 'access_type');
     foreach ($fields as $f) {
         if (isset($this->request->post[$f])) {
             $this->data[$f] = $this->request->post[$f];
         } elseif (isset($type_data)) {
             $this->data[$f] = $type_data[$f];
         } else {
             $this->data[$f] = '';
         }
     }
     if (!isset($this->data['type_id'])) {
         return null;
     } else {
         $this->data['action'] = $this->html->getSecureURL('r/tool/rl_manager/save', '&rl_type=' . $this->data['type_name']);
         $this->data['heading_title'] = $this->data['form_title'] = $this->language->get('text_edit') . ' ' . $this->data['type_name'] . ' ' . $this->language->get('text_rl_type');
         $form = new AForm('ST');
     }
     $this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['form_title'], 'separator' => ' :: '));
     $form->setForm(array('form_name' => 'rl_typeFrm', 'update' => $this->data['update']));
     $this->data['form']['id'] = 'rl_typeFrm';
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'rl_typeFrm', 'action' => $this->data['action'], 'attr' => 'data-confirm-exit="true"  class="aform form-horizontal"')) . ($this->data['form']['fields']['type_id'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'type_id', 'value' => $this->data['type_id'])));
     $this->data['form']['fields']['type_name'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'type_name', 'value' => $this->data['type_name'], 'style' => 'tiny-field', 'attr' => 'readonly'));
     $this->data['form']['fields']['default_icon'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'default_icon', 'value' => $this->data['default_icon'], 'style' => 'small-field'));
     $this->data['form']['fields']['default_directory'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'default_directory', 'value' => $this->data['default_directory'], 'style' => 'small-field', 'attr' => 'readonly'));
     $this->data['form']['fields']['file_types'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'file_types', 'value' => $this->data['file_types'], 'style' => 'small-field'));
     $this->data['button_save'] = $this->language->get('button_save');
     $this->data['button_close'] = $this->language->get('button_close');
     $this->data['button_save_and_close'] = $this->language->get('button_save_and_close');
     $view->assign('help_url', $this->gen_help_url('resource_library_types'));
     $view->batchAssign($this->data);
     $this->data['response'] = $view->fetch('responses/tool/rl_types_form.tpl');
     $this->response->setOutput($this->data['response']);
 }
Beispiel #3
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->document->setTitle($this->language->get('heading_title'));
     $this->document->resetBreadcrumbs();
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('tool/error_log'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: ', 'current' => true));
     $this->view->assign('current_url', $this->html->currentURL());
     //load all RL types to be listed
     $rm = new AResourceManager();
     $this->view->assign('types', $rm->getResourceTypes());
     $latest_limit = 13;
     $resources_scripts = $this->dispatch('responses/common/resource_library/get_resources_scripts', array(null, null, null, null, 'mode' => 'list_all', 'page' => 1, 'limit' => $latest_limit, 'sort' => 'date_added', 'order' => 'DESC'));
     $this->view->assign('latest_limit', $latest_limit);
     $this->view->assign('rl_types_url', $this->html->getSecureURL('r/tool/rl_manager/update'));
     $this->view->assign('resources_scripts', $resources_scripts->dispatchGetOutput());
     $this->view->assign('form_language_switch', $this->html->getContentLanguageSwitcher());
     $this->processTemplate('pages/tool/rl_manager.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
 /**
  * @param int $download_id
  * @return null
  */
 public function deleteDownload($download_id)
 {
     $download_id = (int) $download_id;
     if (!$download_id) {
         return null;
     }
     $download = $this->getDownload($download_id);
     if (!$download) {
         return null;
     }
     $rm = new AResourceManager();
     $rm->setType('download');
     $path = ltrim($download['filename'], 'download/');
     $rl_id = $rm->getIdFromHexPath($path);
     if ($rl_id && !$rm->isMapped($rl_id)) {
         $rm->deleteResource($rl_id);
     }
     $this->db->query("DELETE FROM " . $this->db->table("downloads") . " WHERE download_id = '" . (int) $download_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("download_descriptions") . " WHERE download_id = '" . (int) $download_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("download_attribute_values") . " WHERE download_id = '" . (int) $download_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("products_to_downloads") . " WHERE download_id = '" . (int) $download_id . "'");
 }
 public function getCustomListingSubForm()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->load->library('json');
     $lm = new ALayoutManager();
     $form_name = has_value($this->request->get['form_name']) ? $this->request->get['form_name'] : 'BlockFrm';
     $custom_block_id = (int) $this->request->get['custom_block_id'];
     $listing_datasource = $this->request->post_or_get('listing_datasource');
     // need to get data of custom listing
     if ($custom_block_id) {
         $content = $lm->getBlockDescriptions($custom_block_id);
         $content = $content[$this->language->getContentLanguageID()]['content'];
         $content = unserialize($content);
         if ($content['listing_datasource'] == $listing_datasource) {
             $lm = new AListingManager($custom_block_id);
             $list = $lm->getCustomList();
             $options_list = array();
             if ($list) {
                 foreach ($list as $row) {
                     $options_list[(int) $row['id']] = array();
                 }
                 $ids = array_keys($options_list);
                 switch ($listing_datasource) {
                     case 'custom_products':
                         $this->loadModel('catalog/product');
                         $filter = array('subsql_filter' => 'p.product_id in (' . implode(',', $ids) . ')');
                         $results = $this->model_catalog_product->getProducts($filter);
                         $id_name = 'product_id';
                         $rl_object_name = 'products';
                         break;
                     case 'custom_categories':
                         $this->loadModel('catalog/category');
                         $filter = array('subsql_filter' => 'c.category_id in (' . implode(',', $ids) . ')');
                         $results = $this->model_catalog_category->getCategoriesData($filter);
                         $id_name = 'category_id';
                         $rl_object_name = 'categories';
                         break;
                     case 'custom_manufacturers':
                         $this->loadModel('catalog/manufacturer');
                         $filter = array('subsql_filter' => 'm.manufacturer_id in (' . implode(',', $ids) . ')');
                         $results = $this->model_catalog_manufacturer->getManufacturers($filter);
                         $id_name = 'manufacturer_id';
                         $rl_object_name = 'manufacturers';
                         break;
                 }
                 $rm = new AResourceManager();
                 $rm->setType('image');
                 foreach ($results as $item) {
                     $id = $item[$id_name];
                     if (in_array($id, $ids)) {
                         $thumbnail = $rm->getMainThumb($rl_object_name, $id, (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), false);
                         $icon = $thumbnail['thumb_html'] ? $thumbnail['thumb_html'] : '<i class="fa fa-code fa-4x"></i>&nbsp;';
                         $options_list[$id] = array('image' => $icon, 'id' => $id, 'name' => $item['name'], 'meta' => $item['model'], 'sort_order' => (int) $item['sort_order']);
                     }
                 }
             }
         }
     }
     switch ($listing_datasource) {
         case 'custom_products':
             $ajax_url = $this->html->getSecureURL('r/product/product/products');
             break;
         case 'custom_categories':
             $ajax_url = $this->html->getSecureURL('r/listing_grid/category/categories');
             break;
         case 'custom_manufacturers':
             $ajax_url = $this->html->getSecureURL('r/listing_grid/manufacturer/manufacturers');
             break;
     }
     $form = new AForm('ST');
     $form->setForm(array('form_name' => $form_name));
     $multivalue_html = $form->getFieldHtml(array('type' => 'multiselectbox', 'name' => 'selected[]', 'value' => $ids, 'options' => $options_list, 'style' => 'chosen', 'ajax_url' => $ajax_url, 'placeholder' => $this->language->get('text_select_from_lookup')));
     $this->view->assign('multivalue_html', $multivalue_html);
     $this->view->assign('form_name', $form_name);
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->processTemplate('responses/design/block_custom_listing_subform.tpl');
 }
Beispiel #6
0
 public function main()
 {
     //use to init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->load->helper('html');
     $this->view->assign('breadcrumbs', $this->document->getBreadcrumbs());
     if ($this->request->is_POST() && isset($this->request->post['language_code'])) {
         unset($this->session->data['content_language']);
         $this->session->data['language'] = $this->request->post['language_code'];
         $this->cache->delete('admin_menu');
         if (!empty($this->request->post['redirect'])) {
             $this->redirect($this->request->post['redirect']);
         } else {
             $this->redirect($this->html->getURL('index/home'));
         }
     }
     $this->view->assign('language_code', $this->session->data['language']);
     $this->view->assign('languages', array());
     $this->view->assign('languages', $this->language->getActiveLanguages());
     $this->view->assign('content_language_id', $this->language->getContentLanguageID());
     $this->view->assign('language_settings', $this->html->getSecureURL('localisation/language'));
     $this->view->assign('new_messages', $this->messages->getShortList());
     $this->view->assign('messages_link', $this->html->getSecureURL('tool/message_manager'));
     $this->view->assign('action', $this->html->getSecureURL('index/home'));
     $this->view->assign('search_action', $this->html->getSecureURL('tool/global_search'));
     //redirect after language change
     if (!$this->request->get['rt'] || $this->request->get['rt'] == 'index/home') {
         $this->view->assign('redirect', $this->html->getSecureURL('index/home'));
         $this->view->assign('home_page', true);
     } else {
         $this->view->assign('home_page', false);
         $this->view->assign('redirect', HTTPS_SERVER . '?' . $_SERVER['QUERY_STRING']);
     }
     if (!$this->user->isLogged() || !isset($this->request->get['token']) || !isset($this->session->data['token']) || $this->request->get['token'] != $this->session->data['token']) {
         $this->view->assign('logged', '');
         $this->view->assign('home', $this->html->getSecureURL('index/login', '', true));
     } else {
         $this->view->assign('home', $this->html->getSecureURL('index/home', '', true));
         $this->view->assign('logged', sprintf($this->language->get('text_logged'), $this->user->getUserName()));
         $this->view->assign('avatar', $this->user->getAvatar());
         $this->view->assign('username', $this->user->getUserName());
         $this->view->assign('last_login', sprintf($this->language->get('text_last_login'), $this->user->getLastLogin()));
         $this->view->assign('account_edit', $this->html->getSecureURL('index/edit_details', '', true));
         $stores = array();
         $this->loadModel('setting/store');
         $results = $this->model_setting_store->getStores();
         foreach ($results as $result) {
             $stores[] = array('name' => $result['name'], 'href' => $result['config_url']);
         }
         $this->view->assign('stores', $stores);
         $this->view->assign('logout', $this->html->getSecureURL('index/logout'));
         $this->view->assign('store', HTTP_CATALOG);
         // add dynamic menu based on dataset scheme
         $this->addChild('common/menu', 'menu', 'common/menu.tpl');
         //Get surrent menu item
         $menu = new AMenu('admin');
         $current_menu = $menu->getMenuByRT($this->request->get['rt']);
         if ($current_menu['item_icon_rl_id']) {
             $rm = new AResourceManager();
             $rm->setType('image');
             $resource = $rm->getResource($current_menu['item_icon_rl_id']);
             $current_menu['icon'] = $resource['resource_code'];
         }
         unset($current_menu['item_icon_rl_id']);
         $this->view->assign('current_menu', $current_menu);
     }
     if ($this->user->isLogged()) {
         $ant_message = $this->messages->getANTMessage();
         $this->view->assign('ant', $ant_message['html']);
         $this->view->assign('mark_read_url', $this->html->getSecureURL('common/common/antMessageRead', '&message_id=' . $ant_message['id']));
         $this->view->assign('ant_viewed', $ant_message['viewed']);
     }
     $this->view->assign('config_voicecontrol', $this->config->get('config_voicecontrol'));
     $this->view->assign('voicecontrol_setting_url', $this->html->getSecureURL('setting/setting/system'));
     $this->view->assign('command_lookup_url', $this->html->getSecureURL('common/action_commands'));
     $this->view->assign('search_suggest_url', $this->html->getSecureURL('listing_grid/global_search_result/suggest'));
     $this->view->assign('search_everywhere', $this->language->get('search_everywhere'));
     $this->view->assign('text_all_matches', $this->language->get('text_all_matches'));
     $this->view->assign('dialog_title', $this->language->get('text_quick_edit_form'));
     $this->view->assign('button_go', $this->html->buildButton(array('name' => 'searchform_go', 'text' => $this->language->get('button_go'), 'style' => 'button5')));
     //check if install dir existing. warn
     if (file_exists(DIR_ROOT . '/install')) {
         $this->messages->saveWarning($this->language->get('text_install_warning_subject'), $this->language->get('text_install_warning'));
     }
     //backwards compatability from 1.2.1. Can remove this check in the future.
     if (!defined('ENCRYPTION_KEY')) {
         $cmbody = "To be compatible with v" . VERSION . " add below line to configuration file: <br>\n" . DIR_ROOT . '/system/config.php';
         $cmbody .= "<br>\n" . "define('ENCRYPTION_KEY', '" . $this->config->get('encryption_key') . "');\n";
         $this->messages->saveWarning('Compatibility warning for v' . VERSION, $cmbody);
     }
     //prepare quick stats
     $this->loadModel('tool/online_now');
     $online_new = $this->model_tool_online_now->getTotalTodayOnline('new');
     $online_registered = $this->model_tool_online_now->getTotalTodayOnline('registered');
     $this->view->assign('online_new', $online_new);
     $this->view->assign('online_registered', $online_registered);
     $this->loadModel('report/sale');
     $data = array('filter' => array('date_start' => dateISO2Display(date('Y-m-d', time()), $this->language->get('date_format_short')), 'date_end' => dateISO2Display(date('Y-m-d', time()), $this->language->get('date_format_short'))));
     $today_orders = $this->model_report_sale->getSaleReportSummary($data);
     $today_order_count = $today_orders['orders'];
     $today_sales_amount = $this->currency->format($today_orders['total_amount'], $this->config->get('config_currency'));
     $this->view->assign('today_order_count', $today_order_count);
     $this->view->assign('today_sales_amount', $today_sales_amount);
     $this->loadModel('sale/customer');
     $filter = array('date_added' => date('Y-m-d', time()));
     $today_customer_count = $this->model_sale_customer->getTotalCustomers(array('filter' => $filter));
     $this->view->assign('today_customer_count', $today_customer_count);
     $this->loadModel('catalog/review');
     $today_review_count = $this->model_catalog_review->getTotalToday();
     $this->view->assign('today_review_count', $today_review_count);
     $this->processTemplate('common/header.tpl');
     //use to update data before render
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
if (!defined('DIR_CORE')) {
    header('Location: static_pages/');
}
$registry = Registry::getInstance();
//Current extension text id from extension maanger
$extension_txt_id = $name;
$language_list = $this->model_localisation_language->getLanguages();
$lm = new ALayoutManager();
// block with button
$block_data = array('block_txt_id' => 'default_pp_express_button', 'controller' => 'blocks/default_pp_express_button', 'templates' => array(array('parent_block_txt_id' => 'header_bottom', 'template' => 'blocks/default_pp_express_button.tpl'), array('parent_block_txt_id' => 'header', 'template' => 'blocks/default_pp_express_button.tpl'), array('parent_block_txt_id' => 'column_left', 'template' => 'blocks/default_pp_express_button.tpl'), array('parent_block_txt_id' => 'column_right', 'template' => 'blocks/default_pp_express_button.tpl'), array('parent_block_txt_id' => 'content_top', 'template' => 'blocks/default_pp_express_button.tpl'), array('parent_block_txt_id' => 'content_bottom', 'template' => 'blocks/default_pp_express_button.tpl'), array('parent_block_txt_id' => 'footer_top', 'template' => 'blocks/default_pp_express_button.tpl'), array('parent_block_txt_id' => 'footer', 'template' => 'blocks/default_pp_express_button.tpl')));
$lm->saveBlock($block_data);
// paypal banner block
$block_data = array('block_txt_id' => 'default_pp_express_bml_button', 'controller' => 'blocks/default_pp_express_button', 'templates' => array(array('parent_block_txt_id' => 'column_left', 'template' => 'blocks/default_pp_express_bml_button_lr.tpl'), array('parent_block_txt_id' => 'column_right', 'template' => 'blocks/default_pp_express_bml_button_lr.tpl'), array('parent_block_txt_id' => 'footer_top', 'template' => 'blocks/default_pp_express_bml_button_fb.tpl'), array('parent_block_txt_id' => 'footer', 'template' => 'blocks/default_pp_express_bml_button_fb.tpl'), array('parent_block_txt_id' => 'header_bottom', 'template' => 'blocks/default_pp_express_bml_button_fb.tpl')));
$lm->saveBlock($block_data);
$rm = new AResourceManager();
$rm->setType('image');
$result = copy(DIR_EXT . 'default_pp_express/image/secure_paypal_icon.jpg', DIR_RESOURCE . 'image/secure_paypal_icon.jpg');
$resource = array('language_id' => $this->config->get('storefront_language_id'), 'name' => array(), 'title' => array(), 'description' => array(), 'resource_path' => 'secure_paypal_icon.jpg', 'resource_code' => '');
foreach ($language_list as $lang) {
    $resource['name'][$lang['language_id']] = 'secure_paypal_icon.jpg';
    $resource['title'][$lang['language_id']] = 'default_pp_express_default_storefront_icon';
    $resource['description'][$lang['language_id']] = 'PayPal Express Checkout Default Storefront Icon';
}
$resource_id = $rm->addResource($resource);
if ($resource_id) {
    // get hexpath of resource (RL moved given file from rl-image-directory in own dir tree)
    $resource_info = $rm->getResource($resource_id, $this->config->get('admin_language_id'));
    // write it path in settings (array from parent method "install" of extension manager)
    $settings['default_pp_express_payment_storefront_icon'] = 'image/' . $resource_info['resource_path'];
}
Beispiel #8
0
 /**
  * @param int $product_id
  * @return bool
  */
 public function deleteProduct($product_id)
 {
     if (!(int) $product_id) {
         return false;
     }
     $rm = new AResourceManager();
     $this->db->query("DELETE FROM " . $this->db->table("products") . " WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("product_descriptions") . " WHERE product_id = '" . (int) $product_id . "'");
     $resources = $rm->getResourcesList(array('object_name' => 'products', 'object_id' => (int) $product_id));
     foreach ($resources as $r) {
         $rm->unmapResource('products', $product_id, $r['resource_id']);
         //if resource become orphan - delete it
         if (!$rm->isMapped($r['resource_id'])) {
             $rm->deleteResource($r['resource_id']);
         }
     }
     //delete product's downloads
     $this->load->model('catalog/download');
     $downloads = $this->model_catalog_download->getProductDownloadsDetails($product_id, array('subsql_filter' => 'AND d.shared<>1'));
     foreach ($downloads as $d) {
         $this->model_catalog_download->deleteDownload($d['download_id']);
     }
     $this->db->query("DELETE FROM " . $this->db->table("product_options") . " WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("product_option_descriptions") . " WHERE product_id = '" . (int) $product_id . "'");
     $sql = "SELECT product_option_value_id FROM " . $this->db->table("product_option_values") . " WHERE product_id = '" . (int) $product_id . "'";
     $result = $this->db->query($sql);
     foreach ($result->rows as $row) {
         $pd_opt_val_id = $row['product_option_value_id'];
         $resources = $rm->getResourcesList(array('object_name' => 'product_option_value', 'object_id' => (int) $pd_opt_val_id));
         foreach ($resources as $r) {
             $rm->unmapResource('product_option_value', $pd_opt_val_id, $r['resource_id']);
         }
     }
     $this->db->query("DELETE FROM " . $this->db->table("product_option_values") . " WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("product_option_value_descriptions") . " WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("product_discounts") . " WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("products_related") . " WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("products_to_downloads") . " WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("products_to_categories") . " WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("reviews") . " WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("products_to_stores") . " WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("url_aliases") . " WHERE query = 'product_id=" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("product_tags") . " WHERE product_id='" . (int) $product_id . "'");
     $lm = new ALayoutManager();
     $lm->deletePageLayout('pages/product/product', 'product_id', (int) $product_id);
     $this->cache->remove('product');
     return true;
 }
Beispiel #9
0
  This source file is subject to Open Software License (OSL 3.0)
  License details is bundled with this package in the file LICENSE.txt.
  It is also available at this URL:
  <http://www.opensource.org/licenses/OSL-3.0>

 UPGRADE NOTE:
   Do not edit or add to this file if you wish to upgrade AbanteCart to newer
   versions in the future. If you wish to customize AbanteCart for your
   needs please refer to http://www.AbanteCart.com for more information.
------------------------------------------------------------------------------*/
if (!defined('DIR_CORE')) {
    header('Location: static_pages/');
}
// add new menu item
$rm = new AResourceManager();
$rm->setType('image');
$language_id = $this->language->getContentLanguageID();
$data = array();
$data['resource_code'] = '<i class="fa fa-picture-o"></i>&nbsp;';
$data['name'] = array($language_id => 'Menu Icon Banner Manager');
$data['title'] = array($language_id => '');
$data['description'] = array($language_id => '');
$resource_id = $rm->addResource($data);
$menu = new AMenu("admin");
$menu->insertMenuItem(array("item_id" => "banner_manager", "parent_id" => "design", "item_text" => "banner_manager_name", "item_url" => "extension/banner_manager", "item_icon_rl_id" => $resource_id, "item_type" => "extension", "sort_order" => "6"));
$data = array();
$data['resource_code'] = '<i class="fa fa-reply-all"></i>&nbsp;';
$data['name'] = array($language_id => 'Menu Icon Banner Manager Stat');
$data['title'] = array($language_id => '');
$data['description'] = array($language_id => '');
<?php

if (!defined('DIR_CORE')) {
    header('Location: static_pages/');
}
$rm = new AResourceManager();
$rm->setType('image');
$resources = $rm->getResources('extensions', 'default_pp_standart');
//echo_array($resources);exit;
if (is_array($resources)) {
    foreach ($resources as $resource) {
        $rm->deleteResource($resource['resource_id']);
    }
}
Beispiel #11
0
 /**
  * @param AResourceManager $rm
  * @param $object_txt_id
  * @param $object_id
  * @param string $image_basename
  * @param string $code
  * @return null
  */
 private function _create_resource($rm, $object_txt_id, $object_id, $image_basename = '', $code = '')
 {
     $language_list = $this->language->getAvailableLanguages();
     $resource = array('language_id' => $this->config->get('storefront_language_id'), 'name' => array(), 'title' => '', 'description' => '', 'resource_path' => $image_basename, 'resource_code' => $code);
     foreach ($language_list as $lang) {
         $resource['name'][$lang['language_id']] = str_replace('%20', ' ', $image_basename);
     }
     $resource_id = $rm->addResource($resource);
     if ($resource_id) {
         $rm->mapResource($object_txt_id, $object_id, $resource_id);
         return $resource_id;
     } else {
         return null;
     }
 }
Beispiel #12
0
 /**
  * @param int $manufacturer_id
  */
 public function deleteManufacturer($manufacturer_id)
 {
     $this->db->query("DELETE FROM " . $this->db->table("manufacturers") . " WHERE manufacturer_id = '" . (int) $manufacturer_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("manufacturers_to_stores") . " WHERE manufacturer_id = '" . (int) $manufacturer_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("url_aliases") . " WHERE query = 'manufacturer_id=" . (int) $manufacturer_id . "'");
     $lm = new ALayoutManager();
     $lm->deletePageLayout('pages/product/manufacturer', 'manufacturer_id', (int) $manufacturer_id);
     //delete resources
     $rm = new AResourceManager();
     $resources = $rm->getResourcesList(array('object_name' => 'manufacturers', 'object_id' => (int) $manufacturer_id));
     foreach ($resources as $r) {
         $rm->unmapResource('manufacturers', $manufacturer_id, $r['resource_id']);
         //if resource became orphan - delete it
         if (!$rm->isMapped($r['resource_id'])) {
             $rm->deleteResource($r['resource_id']);
         }
     }
     $this->cache->remove('manufacturer');
 }
Beispiel #13
0
 private function _getChildItems($item_id, $menu_items)
 {
     $rm = new AResourceManager();
     $rm->setType('image');
     $result = array();
     foreach ($menu_items as $item) {
         if ($item['parent_id'] == $item_id && isset($item['item_id'])) {
             if (isset($item['language'])) {
                 $this->loadLanguage($item['language'], 'silent');
             }
             $childen = $this->_getChildItems($item['item_id'], $menu_items);
             $rt = '';
             $menu_link = '';
             if (preg_match("/(http|https):/", $item['item_url'])) {
                 $menu_link = $item['item_url'];
             } else {
                 if ($item['item_url']) {
                     //rt based link, need to save rt
                     $menu_link = $this->html->getSecureURL($item['item_url'], '', true);
                     $rt = $item['item_url'];
                 }
             }
             $link_keyname = strpos($item['item_url'], "http") ? "onclick" : "href";
             $icon = $rm->getResource($item['item_icon_rl_id']);
             $icon = $icon['resource_code'] ? $icon['resource_code'] : '';
             $temp = array('id' => $item['item_id'], $link_keyname => $menu_link, 'text' => $this->language->get($item['item_text']), 'icon' => $icon);
             if ($rt) {
                 $temp['rt'] = $rt;
             }
             if ($childen) {
                 $temp['children'] = $childen;
             }
             $result[$item['item_id']] = $temp;
         }
     }
     return $result;
 }
Beispiel #14
0
 /**
  * @param int $category_id
  */
 public function deleteCategory($category_id)
 {
     $this->db->query("DELETE FROM " . $this->db->table("categories") . " WHERE category_id = '" . (int) $category_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("category_descriptions") . " WHERE category_id = '" . (int) $category_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("categories_to_stores") . " WHERE category_id = '" . (int) $category_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("url_aliases") . " WHERE query = 'category_id=" . (int) $category_id . "'");
     $this->db->query("DELETE FROM " . $this->db->table("products_to_categories") . " WHERE category_id = '" . (int) $category_id . "'");
     //delete resources
     $rm = new AResourceManager();
     $resources = $rm->getResourcesList(array('object_name' => 'categories', 'object_id' => (int) $category_id));
     foreach ($resources as $r) {
         $rm->unmapResource('products', $category_id, $r['resource_id']);
         //if resource became orphan - delete it
         if (!$rm->isMapped($r['resource_id'])) {
             $rm->deleteResource($r['resource_id']);
         }
     }
     //remove layout
     $lm = new ALayoutManager();
     $lm->deletePageLayout('pages/product/category', 'path', $category_id);
     //delete children categories
     $query = $this->db->query("SELECT category_id\n\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("categories") . "\n\t\t\t\t\t\t\t\t\tWHERE parent_id = '" . (int) $category_id . "'");
     foreach ($query->rows as $result) {
         $this->deleteCategory($result['category_id']);
     }
     $this->cache->remove('category');
 }
Beispiel #15
0
 public function getMediaListingSubForm()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('design/blocks');
     $custom_block_id = (int) $this->request->get['custom_block_id'];
     $lm = new ALayoutManager();
     if (!$custom_block_id) {
         $form = new AForm('ST');
     } else {
         $form = new AForm('HS');
         $content = $lm->getBlockDescriptions($custom_block_id);
         $content = $content[$this->language->getContentLanguageID()]['content'];
         $content = unserialize($content);
     }
     $form->setForm(array('form_name' => 'BlockFrm'));
     $rl = new AResourceManager();
     $types = $rl->getResourceTypes();
     $resource_types[''] = $this->language->get('text_select');
     foreach ($types as $type) {
         $resource_types[$type['type_name']] = $type['type_name'];
     }
     $view = new AView($this->registry, 0);
     $view->batchAssign(array('entry_media_resource_type' => $this->language->get('entry_resource_type'), 'media_resource_type' => $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'resource_type', 'value' => (string) $content['resource_type'], 'options' => $resource_types, 'style' => 'no-save', 'help_url' => $this->gen_help_url('block_resource_type'))), 'entry_media_resource_limit' => $this->language->get('entry_limit'), 'media_resource_limit' => $form->getFieldHtml(array('type' => 'input', 'name' => 'limit', 'value' => $content['limit'], 'style' => 'no-save', 'help_url' => $this->gen_help_url('block_limit')))));
     $this->data['response'] = $view->fetch('responses/design/block_media_listing_subform.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->response->setOutput($this->data['response']);
 }
Beispiel #16
0
 /**
  * @param int $product_id
  */
 public function deleteProduct($product_id)
 {
     $this->db->query("DELETE FROM " . DB_PREFIX . "products WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . DB_PREFIX . "product_descriptions WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . DB_PREFIX . "product_options WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . DB_PREFIX . "product_option_descriptions WHERE product_id = '" . (int) $product_id . "'");
     $sql = "SELECT product_option_value_id FROM " . DB_PREFIX . "product_option_values WHERE product_id = '" . (int) $product_id . "'";
     $result = $this->db->query($sql);
     $rm = new AResourceManager();
     foreach ($result->rows as $row) {
         $pd_opt_val_id = $row['product_option_value_id'];
         $resources = $rm->getResourcesList(array('object_name' => 'product_option_value', 'object_id' => (int) $pd_opt_val_id));
         foreach ($resources as $r) {
             $rm->unmapResource('product_option_value', $pd_opt_val_id, $r['resource_id']);
         }
     }
     $this->db->query("DELETE FROM " . DB_PREFIX . "product_option_values WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . DB_PREFIX . "product_option_value_descriptions WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . DB_PREFIX . "product_discounts WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . DB_PREFIX . "products_related WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . DB_PREFIX . "products_to_downloads WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . DB_PREFIX . "products_to_categories WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . DB_PREFIX . "reviews WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . DB_PREFIX . "products_to_stores WHERE product_id = '" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . DB_PREFIX . "url_aliases WHERE query = 'product_id=" . (int) $product_id . "'");
     $this->db->query("DELETE FROM " . DB_PREFIX . "product_tags WHERE product_id='" . (int) $product_id . "'");
     $lm = new ALayoutManager();
     $lm->deletePageLayout('pages/product/product', 'product_id', (int) $product_id);
     $this->cache->delete('product');
 }
 public function banners()
 {
     //$products = array();
     $banners_data = array();
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadModel('extension/banner_manager');
     if (isset($this->request->post['term'])) {
         $rm = new AResourceManager();
         $rm->setType('image');
         $filter = array('subsql_filter' => "b.target_url LIKE '%" . $this->db->escape($this->request->post['term']) . "%'\n\t\t\t\t\t\t\t\t\t\t\t\tOR bd.name LIKE '%" . $this->db->escape($this->request->post['term']) . "%'\n\t\t\t\t\t\t\t\t\t\t\t\tOR bd.description LIKE '%" . $this->db->escape($this->request->post['term']) . "%'\n\t\t\t\t\t\t\t\t\t\t\t\tOR bd.meta LIKE '%" . $this->db->escape($this->request->post['term']) . "%'", 'limit' => 20);
         $banners = $this->model_extension_banner_manager->getBanners($filter);
         $ids = array();
         foreach ($banners as $result) {
             $ids[] = (int) $result['banner_id'];
         }
         $resource = new AResource('image');
         $thumbnails = $resource->getMainThumbList('banners', $ids, $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height'), false);
         foreach ($banners as $banner) {
             $thumbnail = $thumbnails[$banner['banner_id']];
             $icon = $thumbnail['thumb_html'] ? $thumbnail['thumb_html'] : '<i class="fa fa-code fa-4x"></i>&nbsp;';
             $banners_data[] = array('image' => $icon, 'id' => $banner['banner_id'], 'name' => $banner['name'], 'sort_order' => (int) $banner['sort_order']);
         }
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->load->library('json');
     $this->response->addJSONHeader();
     $this->response->setOutput(AJson::encode($banners_data));
 }
 public function get_resources_scripts()
 {
     list($object_name, $object_id, $types, $onload, $mode) = func_get_args();
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->data['onload'] = is_bool($onload) ? $onload : true;
     //sign of call js-function on page load. default true.
     $rm = new AResourceManager();
     $this->data['types'] = $rm->getResourceTypes();
     if ($types) {
         $types = (array) $types;
         foreach ($this->data['types'] as $key => $type) {
             if (!in_array($type['type_name'], $types)) {
                 unset($this->data['types'][$key]);
             }
         }
     }
     $this->session->data['rl_types'] = $this->data['types'];
     $this->data['default_type'] = reset($this->data['types']);
     $this->data['object_name'] = $object_name;
     $this->data['object_id'] = $object_id;
     $this->data['mode'] = $mode;
     $params = '&mode=' . $mode . '&object_name=' . $object_name . '&object_id=' . $object_id;
     $this->data['rl_resource_library'] = $this->html->getSecureURL('common/resource_library', $params);
     $this->data['rl_resources'] = $this->html->getSecureURL('common/resource_library/resources', $params);
     $this->data['rl_resource_single'] = $this->html->getSecureURL('common/resource_library/get_resource_details', $params);
     $this->data['rl_delete'] = $this->html->getSecureURL('common/resource_library/delete');
     $this->data['rl_unmap'] = $this->html->getSecureURL('common/resource_library/unmap', $params);
     $this->data['rl_map'] = $this->html->getSecureURL('common/resource_library/map', $params);
     $this->data['rl_download'] = $this->html->getSecureURL('common/resource_library/get_resource_preview');
     $this->data['rl_upload'] = $this->html->getSecureURL('common/resource_library/upload', $params);
     $this->view->batchAssign($this->data);
     $this->processTemplate('responses/common/resource_library_scripts.tpl');
 }
 public function get_resources_scripts()
 {
     /**
      * @var string $object_name - name of RL-object for assistance of resources, for ex. products, categories, etc
      * @var int $object_id - id of object
      * @var array $types - array with RL-types (image, audio,video,archive etc)
      * @var bool $onload - sign of call function after js-script load
      * @var string $mode - mode of RL
      */
     list($object_name, $object_id, $types, $onload, $mode) = func_get_args();
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->data['onload'] = is_bool($onload) ? $onload : true;
     //sign of call js-function on page load. default true.
     $rm = new AResourceManager();
     $this->data['types'] = $rm->getResourceTypes();
     if ($types) {
         $types = (array) $types;
         foreach ($this->data['types'] as $key => $type) {
             if (!in_array($type['type_name'], $types)) {
                 unset($this->data['types'][$key]);
             }
         }
     }
     $this->session->data['rl_types'] = $this->data['types'];
     $this->data['default_type'] = reset($this->data['types']);
     $this->data['object_name'] = $object_name;
     $this->data['object_id'] = $object_id;
     $this->data['mode'] = $mode;
     $params = '&mode=' . $mode . '&object_name=' . $object_name . '&object_id=' . $object_id;
     $this->data['rl_resource_library'] = $this->html->getSecureURL('common/resource_library', $params);
     $this->data['rl_resources'] = $this->html->getSecureURL('common/resource_library/resources', $params);
     $this->data['rl_resource_single'] = $this->html->getSecureURL('common/resource_library/get_resource_details', $params);
     $this->data['rl_delete'] = $this->html->getSecureURL('common/resource_library/delete');
     $this->data['rl_unmap'] = $this->html->getSecureURL('common/resource_library/unmap', $params);
     $this->data['rl_map'] = $this->html->getSecureURL('common/resource_library/map', $params);
     $this->data['rl_download'] = $this->html->getSecureURL('common/resource_library/get_resource_preview');
     $this->data['rl_upload'] = $this->html->getSecureURL('common/resource_library/upload', $params);
     $this->view->batchAssign($this->data);
     $this->processTemplate('responses/common/resource_library_scripts.tpl');
 }
Beispiel #20
0
 private function _migrateImages($data = array(), $object_txt_id = '', $object_id = 0)
 {
     $objects = array('products' => 'Product', 'categories' => 'Category', 'manufacturers' => 'Brand');
     if (!in_array($object_txt_id, array_keys($objects)) || !$data || !is_array($data)) {
         $this->addLog('Error: data array for object "' . $object_txt_id . '" wrong.');
         return false;
     }
     $language_list = $this->language->getAvailableLanguages();
     $rm = new AResourceManager();
     $rm->setType('image');
     //IMAGE PROCESSING
     $success_db = false;
     // sign of imported image from database query result(not generated additional)
     $data['image'] = (array) $data['image'];
     foreach ($data['image'] as $k => $source) {
         $src_exists = @getimagesize($source);
         // check is image exists
         if ($src_exists) {
             $image_basename = basename($source);
             $target = DIR_RESOURCE . 'image/' . $image_basename;
             if (($file = $this->downloadFile($source)) === false) {
                 $this->is_error = true;
                 if ($k == 'db') {
                     $this->addLog($objects[$object_txt_id] . " " . $data['name'] . " File  " . $source . " couldn't be uploaded.");
                 }
                 continue;
             }
             if (!$this->is_error) {
                 if (!is_dir(DIR_RESOURCE . 'image/')) {
                     mkdir(DIR_RESOURCE . 'image/', 0777);
                 }
                 if (!$this->writeToFile($file, $target)) {
                     $this->is_error = true;
                     if ($k == 'db') {
                         $this->addLog("Cannot create " . $objects[$object_txt_id] . " " . $data['name'] . " ( " . $source . " )  file " . $target . " in resource/image folder ");
                     }
                     continue;
                 }
                 $resource = array('language_id' => $this->config->get('storefront_language_id'), 'name' => array(), 'title' => '', 'description' => '', 'resource_path' => $image_basename, 'resource_code' => '');
                 foreach ($language_list as $lang) {
                     $resource['name'][$lang['language_id']] = str_replace('%20', ' ', $image_basename);
                 }
                 $resource_id = $rm->addResource($resource);
                 if ($resource_id) {
                     $rm->mapResource($object_txt_id, $object_id, $resource_id);
                     $this->pic_count++;
                     $success_db = $k == 'db' ? true : $success_db;
                 } else {
                     $this->addLog($this->db->error);
                     continue;
                 }
             }
         }
     }
     // end of processing images
     return true;
 }
 private function _getBlockForm()
 {
     if (isset($this->session->data['warning'])) {
         $this->data['error_warning'] = $this->session->data['warning'];
         $this->session->data['warning'] = '';
     } else {
         $this->data['error_warning'] = '';
     }
     $this->load->library('json');
     $this->view->assign('success', $this->session->data['success']);
     if (isset($this->session->data['success'])) {
         unset($this->session->data['success']);
     }
     $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('design/blocks'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
     $this->data['cancel'] = $this->html->getSecureURL('design/blocks');
     $custom_block_id = (int) $this->request->get['custom_block_id'];
     // need to get data of custom listing
     $options_list = array();
     if ($custom_block_id) {
         $lm = new ALayoutManager();
         $block_info = $lm->getBlockDescriptions($custom_block_id);
         $language_id = $this->session->data['content_language_id'];
         if (!isset($block_info[$language_id])) {
             $language_id = key($block_info);
         }
         foreach ($block_info[$language_id] as $k => $v) {
             $this->data[$k] = $v;
         }
         $content = $block_info[$this->language->getContentLanguageID()]['content'];
         if ($content) {
             $content = unserialize($content);
         } else {
             $content = current($block_info);
             $content = unserialize($content['content']);
         }
         $this->data['banner_group_name'] = $content['banner_group_name'];
         $lm = new AListingManager($this->request->get['custom_block_id']);
         $list = $lm->getCustomList();
         $options_list = array();
         if ($list) {
             foreach ($list as $row) {
                 $options_list[(int) $row['id']] = array();
             }
             $ids = array_keys($options_list);
             $assigned_banners = $this->model_extension_banner_manager->getBanners(array('subsql_filter' => 'b.banner_id IN (' . implode(', ', $ids) . ')'));
             $rm = new AResourceManager();
             $rm->setType('image');
             foreach ($assigned_banners as $banner) {
                 $id = $banner['banner_id'];
                 if (in_array($id, $ids)) {
                     $thumbnail = $rm->getMainThumb('banners', $banner['banner_id'], (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), false);
                     $icon = $thumbnail['thumb_html'] ? $thumbnail['thumb_html'] : '<i class="fa fa-code fa-4x"></i>&nbsp;';
                     $options_list[$id] = array('image' => $icon, 'id' => $id, 'name' => $banner['name'], 'sort_order' => (int) $banner['sort_order']);
                 }
             }
         }
     }
     if (!$custom_block_id) {
         $this->data['action'] = $this->html->getSecureURL('extension/banner_manager/insert_block');
         $this->data['form_title'] = $this->language->get('text_create_block');
         $this->data['update'] = '';
         $form = new AForm('ST');
     } else {
         $this->data['action'] = $this->html->getSecureURL('extension/banner_manager/edit_block', '&custom_block_id=' . $custom_block_id);
         $this->data['form_title'] = $this->language->get('text_edit') . ' ' . $this->data['name'];
         $this->data['update'] = $this->html->getSecureURL('listing_grid/blocks_grid/update_field', '&custom_block_id=' . $custom_block_id);
         $form = new AForm('HS');
     }
     $this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['form_title'], 'separator' => ' :: ', 'current' => true));
     $form->setForm(array('form_name' => 'BannerBlockFrm', 'update' => $this->data['update']));
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'BannerBlockFrm', 'action' => $this->data['action'], 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"'));
     $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1'));
     $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2'));
     if ($custom_block_id) {
         $this->data['form']['fields']['block_status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'block_status', 'value' => $this->data['status'], 'style' => 'btn_switch'));
         $this->data['form']['text']['block_status'] = $this->html->convertLinks($this->language->get('entry_block_status'));
         $this->data['form']['fields']['block_status_note'] = '';
         $this->data['form']['text']['block_status_note'] = $this->html->convertLinks($this->language->get('entry_block_status_note'));
     }
     $this->data['form']['fields']['block_name'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'block_id', 'value' => $this->data['block_id']));
     $this->data['form']['fields']['block_name'] .= $form->getFieldHtml(array('type' => 'input', 'name' => 'block_name', 'value' => $this->data['name'], 'required' => true));
     $this->data['form']['text']['block_name'] = $this->language->get('entry_block_name');
     $this->data['form']['fields']['block_title'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'block_title', 'required' => true, 'value' => $this->data['title']));
     $this->data['form']['text']['block_title'] = $this->language->get('entry_block_title');
     // list of templates for block
     $tmpl_ids = $this->extensions->getInstalled('template');
     $tmpl_ids[] = 'default';
     $this->data['block_wrappers'] = array();
     foreach ($tmpl_ids as $tmpl_id) {
         // for tpls of block that stores in db
         $layout_manager = new ALayoutManager($tmpl_id);
         $block = $layout_manager->getBlockByTxtId('banner_block');
         $block_templates = (array) $layout_manager->getBlockTemplates($block['block_id']);
         foreach ($block_templates as $item) {
             if ($item['template']) {
                 $this->data['block_wrappers'][$item['template']] = $item['template'];
             }
         }
         //Automatic block template selection mode based on parent is limited to 1 template per location
         //To extend, allow custom block's template to be selected to suppress automatic selection
         //for tpls that stores in main.php (other extensions templates)
         $ext_tpls = $this->extensions->getExtensionTemplates();
         foreach ($ext_tpls as $section) {
             foreach ($section as $s => $tpls) {
                 if ($s != 'storefront') {
                     continue;
                 }
                 foreach ($tpls as $tpl) {
                     if (isset($this->data['block_wrappers'][$tpl]) || strpos($tpl, 'blocks/banner_block/') === false) {
                         continue;
                     }
                     $this->data['block_wrappers'][$tpl] = $tpl;
                 }
             }
         }
         $tpls = glob(DIR_STOREFRONT . 'view/*/template/blocks/banner_block/*.tpl');
         foreach ($tpls as $tpl) {
             $pos = strpos($tpl, 'blocks/banner_block/');
             $tpl = substr($tpl, $pos);
             if (!isset($this->data['block_wrappers'][$tpl])) {
                 $this->data['block_wrappers'][$tpl] = $tpl;
             }
         }
     }
     ksort($this->data['block_wrappers']);
     array_unshift($this->data['block_wrappers'], $this->language->get('text_automatic'));
     if ($this->data['block_wrapper'] && !isset($this->data['block_wrappers'][$this->data['block_wrapper']])) {
         $this->data['block_wrappers'] = array_merge(array($this->data['block_wrapper'] => $this->data['block_wrapper']), $this->data['block_wrappers']);
     }
     $this->data['form']['fields']['block_wrapper'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'block_wrapper', 'options' => $this->data['block_wrappers'], 'value' => $this->data['block_wrapper'], 'help_url' => $this->gen_help_url('block_wrapper')));
     $this->data['form']['text']['block_wrapper'] = $this->language->get('entry_block_wrapper');
     $this->data['form']['fields']['block_framed'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'block_framed', 'value' => $this->data['block_framed'], 'style' => 'btn_switch', 'help_url' => $this->gen_help_url('block_framed')));
     $this->data['form']['text']['block_framed'] = $this->language->get('entry_block_framed');
     $this->data['form']['fields']['block_description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'block_description', 'value' => $this->data['description'], 'attr' => ' style="height: 50px;"'));
     $this->data['form']['text']['block_description'] = $this->language->get('entry_block_description');
     // groups of banners
     $this->loadModel('extension/banner_manager');
     $result = $this->model_extension_banner_manager->getBannerGroups();
     $groups = array('0' => $this->language->get('text_select'));
     if ($result) {
         foreach ($result as $row) {
             $groups[$row['banner_group_name']] = $row['banner_group_name'];
         }
     }
     $this->data['form']['fields']['banner_group_name'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'banner_group_name', 'options' => $groups, 'value' => $this->data['banner_group_name'], 'style' => 'no-save'));
     $this->data['form']['text']['banner_group_name'] = $this->language->get('entry_banner_group_name');
     $this->data['form']['text']['listed_banners'] = $this->language->get('entry_banners_selected');
     //load only prior saved products
     $this->data['banners'] = array();
     $this->data['form']['fields']['listed_banners'] = $form->getFieldHtml(array('type' => 'multiselectbox', 'name' => 'block_banners[]', 'value' => $ids, 'options' => $options_list, 'style' => 'no-save chosen', 'ajax_url' => $this->html->getSecureURL('listing_grid/banner_manager/banners'), 'placeholder' => $this->language->get('text_select_from_lookup')));
     $this->view->batchAssign($this->language->getASet());
     $this->view->batchAssign($this->data);
     $this->view->assign('form_language_switch', $this->html->getContentLanguageSwitcher());
     $this->view->assign('language_code', $this->session->data['language']);
     $this->view->assign('help_url', $this->gen_help_url('banner_edit'));
     $this->view->assign('rl', $this->html->getSecureURL('common/resource_library', '&object_name=banners&type=image&mode=url'));
     $this->processTemplate('pages/extension/banner_manager_block_form.tpl');
 }
 public function get_resources_scripts()
 {
     list($object_name, $object_id, $types, $mode) = func_get_args();
     $rm = new AResourceManager();
     $this->data['types'] = $rm->getResourceTypes();
     if (!empty($types)) {
         foreach ($this->data['types'] as $key => $type) {
             if (!in_array($type['type_name'], (array) $types)) {
                 unset($this->data['types'][$key]);
             }
         }
     }
     $this->session->data['rl_types'] = $this->data['types'];
     $this->data['mode'] = preg_replace('/[^a-z]/', '', $mode);
     $this->data['default_type'] = reset($this->data['types']);
     $this->data['object_name'] = $object_name;
     $this->data['object_id'] = $object_id;
     $params = '&object_name=' . $object_name . '&object_id=' . $object_id . '&mode=' . $mode;
     $this->data['rl_resource_library'] = $this->html->getSecureURL('common/resource_library', $params);
     $this->data['rl_resources'] = $this->html->getSecureURL('common/resource_library/resources', $params);
     $this->data['rl_resource_single'] = $this->html->getSecureURL('common/resource_library/get_resource_details', $params);
     $this->data['rl_delete'] = $this->html->getSecureURL('common/resource_library/delete');
     $this->data['rl_unmap'] = $this->html->getSecureURL('common/resource_library/unmap', $params);
     $this->view->batchAssign($this->data);
     $this->processTemplate('responses/common/resource_library_scripts.tpl');
 }