Example #1
0
<?php

/*------------------------------------------------------------------------------
  $Id$

  AbanteCart, Ideal OpenSource Ecommerce Solution
  http://www.AbanteCart.com

  Copyright © 2011-2014 Belavier Commerce LLC

  This source file is subject to Open Software License (OSL 3.0)
  Lincence 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/');
}
$block_info['block_txt_id'] = 'default_google_talk';
$block_info['controller'] = 'default_google_talk/default_google_talk';
$block_info['templates'] = array(array('parent_block_txt_id' => 'header', 'template' => 'default_google_talk/default_google_talk_tblock.tpl'), array('parent_block_txt_id' => 'header_bottom', 'template' => 'default_google_talk/default_google_talk_cblock.tpl'), array('parent_block_txt_id' => 'content_top', 'template' => 'default_google_talk/default_google_talk_cblock.tpl'), array('parent_block_txt_id' => 'content_bottom', 'template' => 'default_google_talk/default_google_talk_cblock.tpl'), array('parent_block_txt_id' => 'footer', 'template' => 'default_google_talk/default_google_talk_tblock.tpl'), array('parent_block_txt_id' => 'footer_top', 'template' => 'default_google_talk/default_google_talk_cblock.tpl'), array('parent_block_txt_id' => 'column_left', 'template' => 'default_google_talk/default_google_talk_sblock.tpl'), array('parent_block_txt_id' => 'column_right', 'template' => 'default_google_talk/default_google_talk_sblock.tpl'));
$block_info['descriptions'] = array(array('language_name' => 'english', 'name' => 'Google Talk Chat'), array('language_name' => 'espanol', 'name' => 'Google Talk Chat'));
$layout = new ALayoutManager();
$layout->saveBlock($block_info);
<?php

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'];
 public function edit_block()
 {
     $this->loadLanguage('developer_tools/developer_tools');
     $this->loadLanguage('design/blocks');
     $block_id = (int) $this->request->get['block_id'];
     if (!$block_id) {
         $this->redirect($this->html->getSecureURL('tool/developer_tools/insert_block'));
     }
     $layout = new ALayoutManager();
     if ($this->request->is_POST() && $this->_validateBlockForm()) {
         // saving
         //prepare data
         $data = $this->request->post;
         foreach ($data['templates'] as $i => $tpl) {
             if (!$tpl['template']) {
                 unset($data['templates'][$i]);
             }
         }
         //check is templates already in main.php file of extension
         $this->_check4NewTemplates($data);
         // saving block
         $block_id = $layout->saveBlock($data, $block_id);
         $this->session->data['success'] = $this->language->get('developer_tools_text_success_block_save');
         $this->redirect($this->html->getSecureURL('tool/developer_tools/edit_block', '&block_id=' . $block_id));
     }
     $this->document->setTitle($this->language->get('developer_tools_text_edit_block'));
     $this->data['heading_title'] = $this->language->get('developer_tools_text_edit_block');
     $all_blocks = $layout->getAllBlocks();
     foreach ($all_blocks as $k => $block) {
         if ($block_id == $block['block_id'] && !$block['custom_block_id']) {
             $this->data['block_info']['block_txt_id'] = $block['block_txt_id'];
             $this->data['block_info']['controller'] = $block['controller'];
             if ($block['parent_block_id']) {
                 foreach ($all_blocks as $b) {
                     if ($b['block_id'] == $block['parent_block_id']) {
                         $this->data['block_info']['templates'][$k]['parent_block_txt_id'] = $b['block_txt_id'];
                     }
                 }
             }
             $this->data['block_info']['templates'][$k]['template'] = $block['template'];
         }
     }
     $this->data['block_info']['templates'] = array_values($this->data['block_info']['templates']);
     $this->_getBlockForm();
 }