Beispiel #1
0
    public function main()
    {
        //init controller data
        $this->extensions->hk_InitData($this, __FUNCTION__);
        $this->loadLanguage('design/blocks');
        $page = $this->request->post['page'];
        // get the requested page
        if ((int) $page < 0) {
            $page = 0;
        }
        $limit = $this->request->post['rows'];
        // get how many rows we want to have into the grid
        //process custom search form
        $grid_filter_params = array('block_txt_id', 'name');
        $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params));
        $layout = new ALayoutManager();
        $total = $layout->getBlocksList($filter_grid->getFilterData(), 'total_only');
        $blocks = $layout->getBlocksList($filter_grid->getFilterData());
        $tmp = array();
        // prepare block list (delete template duplicates)
        foreach ($blocks as $block) {
            // skip base custom blocks
            if (!$block['custom_block_id'] && in_array($block['block_txt_id'], array('html_block', 'listing_block'))) {
                continue;
            }
            $tmp[$block['block_id'] . '_' . $block['custom_block_id']] = $block;
        }
        $blocks = $tmp;
        if ($total > 0) {
            $total_pages = ceil($total / $limit);
        } else {
            $total_pages = 0;
        }
        $response = new stdClass();
        $response->page = $page;
        $response->total = $total_pages;
        $response->records = $total;
        $i = 0;
        foreach ($blocks as $result) {
            if ($result['custom_block_id']) {
                $action = '<a id="action_edit_' . $result['block_id'] . '_' . $result['custom_block_id'] . '" class="btn_action" href="' . $this->html->getSecureURL('design/blocks/edit', '&custom_block_id=' . $result['custom_block_id']) . '"
						title="' . $this->language->get('text_edit') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_edit.png" alt="' . $this->language->get('text_edit') . '" />' . '</a>
				<a class="btn_action" href="' . $this->html->getSecureURL('design/blocks/delete', '&custom_block_id=' . $result['custom_block_id']) . '"
			 	onclick="return confirm(\'' . $this->language->get('text_delete_confirm') . '\')" title="' . $this->language->get('text_delete') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_delete.png" alt="' . $this->language->get('text_delete') . '" />' . '</a>';
            } else {
                $action = '<a id="' . $result['block_id'] . '" class="view btn_action"
						title="' . $this->language->get('text_view') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_view.png" alt="' . $this->language->get('text_view') . '" />' . '</a>';
            }
            $response->rows[$i]['id'] = $result['custom_block_id'] ? $result['block_id'] . '_' . $result['custom_block_id'] : $result['block_id'];
            $response->rows[$i]['cell'] = array($result['custom_block_id'] ? $result['block_id'] . '_' . $result['custom_block_id'] : $result['block_id'], $result['block_txt_id'], $result['block_name'], isset($result['status']) ? $this->html->buildCheckbox(array('name' => 'status[' . $result['product_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch', 'attr' => 'readonly="true"')) : '', $result['block_date_added'], $action);
            $i++;
        }
        $this->data = $response;
        //update controller data
        $this->extensions->hk_UpdateData($this, __FUNCTION__);
        $this->load->library('json');
        $this->response->addJSONHeader();
        $this->response->setOutput(AJson::encode($this->data));
    }
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('design/blocks');
     $page = $this->request->post['page'];
     // get the requested page
     if ((int) $page < 0) {
         $page = 0;
     }
     $limit = $this->request->post['rows'];
     // get how many rows we want to have into the grid
     //process custom search form
     $grid_filter_params = array('block_txt_id', 'name');
     $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params));
     $layout = new ALayoutManager();
     $total = $layout->getBlocksList($filter_grid->getFilterData(), 'total_only');
     $blocks = $layout->getBlocksList($filter_grid->getFilterData());
     $tmp = array();
     // prepare block list (delete template duplicates)
     foreach ($blocks as $block) {
         // skip base custom blocks
         if (!$block['custom_block_id'] && in_array($block['block_txt_id'], array('html_block', 'listing_block'))) {
             continue;
         }
         $tmp[$block['block_id'] . '_' . $block['custom_block_id']] = $block;
     }
     $blocks = $tmp;
     if ($total > 0) {
         $total_pages = ceil($total / $limit);
     } else {
         $total_pages = 0;
     }
     $response = new stdClass();
     $response->page = $page;
     $response->total = $total_pages;
     $response->records = $total;
     $response->userdata = new stdClass();
     $i = 0;
     foreach ($blocks as $result) {
         $response->rows[$i]['id'] = $result['custom_block_id'] ? $result['block_id'] . '_' . $result['custom_block_id'] : $result['block_id'];
         $id = $response->rows[$i]['id'];
         if (!$result['custom_block_id']) {
             $response->userdata->classes[$id] = 'disable-edit disable-delete';
         }
         $response->rows[$i]['cell'] = array($result['custom_block_id'] ? $result['block_id'] . '_' . $result['custom_block_id'] : $result['block_id'], $result['block_txt_id'], $result['block_name'], isset($result['status']) ? $this->html->buildCheckbox(array('name' => 'status[' . $id . ']', 'value' => $result['status'], 'style' => 'btn_switch', 'attr' => 'readonly="true"')) : '', $result['block_date_added']);
         $i++;
     }
     $this->data = $response;
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->load->library('json');
     $this->response->addJSONHeader();
     $this->response->setOutput(AJson::encode($this->data));
 }
<?php

if (!defined('DIR_CORE')) {
    header('Location: static_pages/');
}
// delete block
$lm = new ALayoutManager();
$lm->deleteBlock('default_pp_express_button');
$lm->deleteBlock('default_pp_express_banner');
$block_names = array('paypal_billmelater_marketing');
$custom_blocks = $lm->getBlocksList(array('subsql_filter' => 'cb.custom_block_id <> 0'));
foreach ($custom_blocks as $block) {
    if (in_array($block['block_name'], $block_names)) {
        $this->db->query("DELETE FROM " . DB_PREFIX . "block_layouts\n\t\t\t\t\t\t   WHERE custom_block_id = '" . (int) $block['custom_block_id'] . "'");
        $this->cache->delete('layout.a.blocks');
        $this->cache->delete('layout.blocks');
        $lm->deleteCustomBlock($block['custom_block_id']);
    }
}
$rm = new AResourceManager();
$rm->setType('image');
$resources = $rm->getResources('extensions', 'default_pp_express');
if (is_array($resources)) {
    foreach ($resources as $resource) {
        $rm->deleteResource($resource['resource_id']);
    }
}