public function block_info() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('design/blocks'); //load specific template/page/layout $template = $this->request->get['template']; $page_id = $this->request->get['page_id']; $layout_id = $this->request->get['layout_id']; $lm = new ALayoutManager($template, $page_id, $layout_id); //acccept 2 type of ids. Number based and custom [block]_[custom_block] $custom_block_id = $this->request->get['block_id']; if (preg_match("/(\\d+)_(\\d+)/", $custom_block_id, $match)) { //take last postion of id for custom block $block_id = $match[1]; $custom_block_id = $match[2]; } else { if (is_numeric($custom_block_id)) { $block_id = $custom_block_id; $custom_block_id = 0; } else { //error $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode(array('error' => 'Incorrect Block ID'))); return null; } } $info = $lm->getBlockInfo((int) $block_id); foreach ($info as &$i) { $i['block_date_added'] = dateISO2Display($i['block_date_added'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format')); } //expect only 1 block details per layout $this->data = array_merge($info[0], $this->data); $this->data['block_info'] = $info; //get specific description if ($custom_block_id > 0) { $descr = $lm->getBlockDescriptions((int) $custom_block_id); $language_id = $this->language->getContentLanguageID(); $this->data['title'] = $descr[$language_id]['title']; $this->data['description'] = $descr[$language_id]['description']; //detect edit URL and build button if ($this->data['block_txt_id'] == 'html_block' || $this->data['block_txt_id'] == 'listing_block') { $edit_url = $this->html->getSecureURL('design/blocks/edit', '&custom_block_id=' . $custom_block_id); } else { if ($this->data['block_txt_id'] == 'banner_block') { $edit_url = $this->html->getSecureURL('extension/banner_manager/edit_block', '&custom_block_id=' . $custom_block_id); } else { //just list all $edit_url = $this->html->getSecureURL('design/blocks'); } } $this->data['block_edit'] = $edit_url; $this->data['allow_edit'] = 'true'; } else { //get details from language for static blocks from storefront $alang = new ALanguage($this->registry, $this->language->getContentLanguageCode(), 0); $alang->load($this->data['controller'], 'silent'); $this->data['title'] = $alang->get('heading_title'); $this->data['title'] = $this->data['title'] == 'heading_title' ? $this->data['block_txt_id'] : $this->data['title']; } $this->data['blocks_layouts'] = $lm->getBlocksLayouts($block_id, $custom_block_id); $this->data['text_edit'] = $this->language->get('text_edit'); $this->data['text_close'] = $this->language->get('text_close'); //update controller data $this->view->batchAssign($this->data); $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->processTemplate('responses/design/block_details.tpl'); }
public function block_info() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('design/blocks'); //load specific template/page/layout $template = $this->request->get['template']; $page_id = $this->request->get['page_id']; $layout_id = $this->request->get['layout_id']; $lm = new ALayoutManager($template, $page_id, $layout_id); //acccept 2 type of ids. Number based and custom [block]_[custom_block] $custom_block_id = $this->request->get['block_id']; if (preg_match("/(\\d+)_(\\d+)/", $custom_block_id, $match)) { //take last postion of id for custom block $block_id = $match[1]; $custom_block_id = $match[2]; } else { //error $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode(array('error' => 'Incorrect Block ID'))); return null; } $info = $lm->getBlockInfo((int) $block_id); //expect only 1 block details per layout $this->data = array_merge($info[0], $this->data); //get specific description if ($custom_block_id > 0) { $descr = $lm->getBlockDescriptions((int) $custom_block_id); $language_id = $this->language->getContentLanguageID(); $this->data['block_id'] = $block_id; $this->data['custom_block_id'] = $custom_block_id; $this->data['title'] = $descr[$language_id]['title']; $this->data['description'] = $descr[$language_id]['description']; //detect edit URL and build button if ($this->data['block_txt_id'] == 'html_block' || $this->data['block_txt_id'] == 'listing_block') { $edit_url = $this->html->getSecureURL('design/blocks/edit', '&custom_block_id=' . $custom_block_id); } else { if ($this->data['block_txt_id'] == 'banner_block') { $edit_url = $this->html->getSecureURL('extension/banner_manager/edit_block', '&custom_block_id=' . $custom_block_id); } else { //just list all $edit_url = $this->html->getSecureURL('design/blocks'); } } $this->data['block_edit_brn'] = $this->html->buildButton(array('type' => 'button', 'name' => 'btn_edit', 'id' => 'btn_edit', 'text' => $this->language->get('text_edit'), 'href' => $edit_url, 'target' => '_new', 'style' => 'button1')); $this->data['allow_edit'] = 'true'; } else { //get details from language for static blocks from storefront $alang = new ALanguage($this->registry, $language_id, 0); $alang->load($this->data['controller'], 'silent'); $this->data['title'] = $alang->get('heading_title'); $this->data['title'] = $this->data['title'] == 'heading_title' ? $this->data['block_txt_id'] : $this->data['title']; $this->data['description'] = $this->language->get('text_controller') . ": " . $this->data['controller']; $this->data['description'] .= "<br/>" . $this->language->get('text_templates') . ": "; $this->data['description'] .= "<br/>" . str_replace(',', '<br/>', $this->data['templates']); } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode($this->data)); }