public function add_code()
 {
     if (!$this->user->canModify('common/resource_library')) {
         $error = new AError('');
         return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'common/resource_library'), 'reset_value' => true));
     }
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->request->post['add_code'] = true;
     $this->request->post['resource_code'] = html_entity_decode($this->request->post['resource_code'], ENT_COMPAT, 'UTF-8');
     $rm = new AResourceManager();
     $rm->setType($this->request->get['type']);
     $data = $this->request->post;
     $language_id = (int) $this->request->post['language_id'];
     $language_id = !$language_id ? $this->language->getContentLanguageID() : $language_id;
     $data['name'] = array($language_id => $this->request->post['name']);
     $data['title'] = array($language_id => $this->request->post['title']);
     $data['description'] = array($language_id => $this->request->post['description']);
     $resource_id = $rm->addResource($data);
     if ($resource_id) {
         $this->request->post['resource_id'] = $resource_id;
         $this->request->post['resource_detail_url'] = $this->html->getSecureURL('common/resource_library/update_resource_details', '&resource_id=' . $resource_id);
         $this->request->post['thumbnail_url'] = $rm->getResourceThumb($resource_id, $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height'), $this->request->post['language_id']);
         if (!empty($this->request->get['object_name']) && !empty($this->request->get['object_id'])) {
             $rm->mapResource($this->request->get['object_name'], $this->request->get['object_id'], $resource_id);
         }
     } else {
         $error = new AError('');
         return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $this->language->get('error_not_added'), 'reset_value' => false));
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->load->library('json');
     $this->response->addJSONHeader();
     $this->response->setOutput(AJson::encode($resource_id));
 }
Exemple #2
0
   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 => '');
$resource_id = $rm->addResource($data);
$menu->insertMenuItem(array("item_id" => "banner_manager_stat", "parent_id" => "reports", "item_text" => "banner_manager_name_stat", "item_url" => "extension/banner_manager_stat", "item_icon_rl_id" => $resource_id, "item_type" => "extension", "sort_order" => "4"));
$sql = "SELECT block_id FROM " . $this->db->table('blocks') . " WHERE block_txt_id='banner_block'";
$result = $this->db->query($sql);
if (!$result->num_rows) {
    $this->db->query("INSERT INTO " . $this->db->table('blocks') . " (`block_txt_id`, `controller`, `date_added`)\n\t\t\t\t\t  VALUES ('banner_block', 'blocks/banner_block', NOW() );");
    $block_id = $this->db->getLastId();
    $sql = "INSERT INTO " . $this->db->table('block_templates') . " (`block_id`, `parent_block_id`, `template`, `date_added`)\n\t\t\tVALUES\n\t\t(" . $block_id . ", 1, 'blocks/banner_block_header.tpl', NOW() ),\n\t\t(" . $block_id . ", 2, 'blocks/banner_block_content.tpl', NOW() ),\n\t\t(" . $block_id . ", 3, 'blocks/banner_block.tpl', NOW() ),\n\t\t(" . $block_id . ", 4, 'blocks/banner_block_content.tpl', NOW() ),\n\t\t(" . $block_id . ", 5, 'blocks/banner_block_content.tpl', NOW() ),\n\t\t(" . $block_id . ", 6, 'blocks/banner_block.tpl', NOW() ),\n\t\t(" . $block_id . ", 7, 'blocks/banner_block_content.tpl', NOW() ),\n\t\t(" . $block_id . ", 8, 'blocks/banner_block_header.tpl', NOW() )";
Exemple #3
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;
 }
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'];
}
$settings['default_pp_express_custom_logo'] = $this->config->get('config_logo');
Exemple #5
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;
     }
 }