Esempio n. 1
0
function fn_twg_get_images_path()
{
    return TwigmoImage::getImagesPath();
}
Esempio n. 2
0
             } else {
                 $response->addError('ERROR_WRONG_OBJECT_DATA', str_replace('[object]', 'products', __('twgadmin_wrong_api_object_data')));
             }
         }
     }
 }
 if ($object == 'categories') {
     if ($_REQUEST['action'] == 'update') {
         foreach ($data as $category) {
             // allow to update only order status
             if (!empty($category['category_id'])) {
                 if (!fn_update_category($category, $category['category_id'], $lang_code)) {
                     $msg = str_replace('[object_id]', $category['category_id'], __('twgadmin_wrong_api_object_data'));
                     $response->addError('ERROR_OBJECT_UPDATE', str_replace('[object]', 'categories', __('twgadmin_wrong_api_object_data')));
                 } elseif (!empty($category['icon'])) {
                     TwigmoImage::updateIconsByApiData($category['icon'], $category['category_id'], 'category');
                 }
             } else {
                 $response->addError('ERROR_WRONG_OBJECT_DATA', str_replace('[object]', 'categories', __('twgadmin_wrong_api_object_data')));
             }
         }
     }
 }
 if ($object == 'images') {
     if ($_REQUEST['action'] == 'delete') {
         foreach ($data as $image) {
             if (empty($image['image_id'])) {
                 $response->addError('ERROR_WRONG_OBJECT_DATA', str_replace('[object]', 'images', __('twgadmin_wrong_api_object_data')));
                 continue;
             }
             $image_info = db_get_row("SELECT pair_id, object_type FROM ?:images_links WHERE image_id = ?i", $image['image_id']);
Esempio n. 3
0
            $company_id = fn_twg_get_current_company_id();
            TwigmoSettings::set(array('customer_connections' => array($company_id => $_REQUEST['tw_settings'])));
        }
        return array(CONTROLLER_STATUS_REDIRECT, 'addons.update?addon=twigmo');
    }
} elseif ($mode == 'update') {
    if ($_REQUEST['addon'] == 'twigmo') {
        if (!empty($_REQUEST['selected_section']) and $_REQUEST['selected_section'] == 'twigmo_addon') {
            fn_delete_notification('twigmo_upgrade');
        }
        if (!fn_twg_is_updated()) {
            fn_set_notification('W', __('notice'), __('twgadmin_reinstall'));
        }
        $company_id = fn_twg_get_current_company_id();
        $view = Registry::get('view');
        $view->assign('default_logo', TwigmoImage::getDefaultLogoUrl($company_id));
        $urls = TwigmoConnector::getMobileScriptsUrls();
        $view->assign('favicon', $urls['favicon']);
        $view->assign('logo_object_id', $company_id * 10 + 1);
        $view->assign('favicon_object_id', $company_id * 10 + 2);
        $tw_register['version'] = TWIGMO_VERSION;
        $view->assign('tw_register', $tw_register);
        $view->assign('next_version_info', TwigmoUpgrade::getNextVersionInfo());
        $view->assign('twg_is_connected', TwigmoConnector::anyFrontendIsConnected());
        $stores = fn_twg_get_stores();
        $platinum_stores = fn_twg_init_push_comment(fn_twg_filter_connected_platinum_stores($stores));
        $view->assign('stores', $stores);
        $view->assign('platinum_stores', $platinum_stores);
        $view->assign('max_push_length', TwigmoConnector::MAX_PUSH_LENGTH);
        $view->assign('twg_all_stores_connected', TwigmoConnector::allStoresAreConnected($stores));
        $view->assign('reset_pass_link', TwigmoConnector::getResetPassLink());
Esempio n. 4
0
 /**
  * Get blocks for the twigmo homepage
  * @param  string $dispatch        Dispatch of needed location
  * @param  array  $allowed_objects - array of blocks types
  * @return array  blocks
  */
 public static final function getBlocksForLocation($dispatch, $allowed_objects)
 {
     $allowed_page_types = array('T', 'L', 'F');
     $blocks = array();
     $location = Location::instance(fn_twg_get_default_layout_id())->get($dispatch);
     if (!$location) {
         return $blocks;
     }
     $get_cont_params = array('location_id' => $location['location_id']);
     $container = Container::getList($get_cont_params);
     if (!$container or !$container['CONTENT']) {
         return $blocks;
     }
     $grids_params = array('container_ids' => $container['CONTENT']['container_id']);
     $grids = Grid::getList($grids_params);
     if (!$grids) {
         return $blocks;
     }
     $block_grids = Block::instance()->getList(array('?:bm_snapping.*', '?:bm_blocks.*', '?:bm_blocks_descriptions.*'), Grid::getIds($grids));
     $image_params = TwigmoSettings::get('images.catalog');
     foreach ($block_grids as $block_grid) {
         foreach ($block_grid as $block) {
             if ($block['status'] != 'A' or !in_array($block['type'], $allowed_objects)) {
                 continue;
             }
             $block_data = array('block_id' => $block['block_id'], 'title' => $block['name'], 'hide_header' => isset($block['properties']['hide_header']) ? $block['properties']['hide_header'] : 'N', 'user_class' => $block['user_class']);
             $block_scheme = SchemesManager::getBlockScheme($block['type'], array());
             if ($block['type'] == 'html_block') {
                 // Html block
                 if (isset($block['content']['content']) and fn_string_not_empty($block['content']['content'])) {
                     $block_data['html'] = $block['content']['content'];
                 }
             } elseif (!empty($block_scheme['content']) and !empty($block_scheme['content']['items'])) {
                 // Products and categories: get items
                 $template_variable = 'items';
                 $field = $block_scheme['content']['items'];
                 fn_set_hook('render_block_content_pre', $template_variable, $field, $block_scheme, $block);
                 $items = RenderManager::getValue($template_variable, $field, $block_scheme, $block);
                 // Filter pages - only texts, links and forms posible
                 if ($block['type'] == 'pages') {
                     foreach ($items as $item_id => $item) {
                         if (!in_array($item['page_type'], $allowed_page_types)) {
                             unset($items[$item_id]);
                         }
                     }
                 }
                 if (empty($items)) {
                     continue;
                 }
                 $block_data['total_items'] = count($items);
                 // Images
                 if ($block['type'] == 'products' or $block['type'] == 'categories') {
                     $object_type = $block['type'] == 'products' ? 'product' : 'category';
                     foreach ($items as $items_id => $item) {
                         if (!empty($item['main_pair'])) {
                             $main_pair = $item['main_pair'];
                         } else {
                             $main_pair = fn_get_image_pairs($item[$object_type . '_id'], $object_type, 'M', true, true);
                         }
                         if (!empty($main_pair)) {
                             $items[$items_id]['icon'] = TwigmoImage::getApiImageData($main_pair, $object_type, 'icon', $image_params);
                         }
                     }
                 }
                 // Banners properties
                 if ($block['type'] == 'banners') {
                     $rotation = $block['properties']['template'] == 'addons/banners/blocks/carousel.tpl' ? 'Y' : 'N';
                     $block_data['delay'] = $rotation == 'Y' ? $block['properties']['delay'] : 0;
                     $block_data['hide_navigation'] = isset($block['properties']['navigation']) && $block['properties']['navigation'] == 'N' ? 'Y' : 'N';
                 }
                 $block_data[$block['type']] = Api::getAsList($block['type'], $items);
             }
             $blocks[$block['block_id']] = $block_data;
         }
     }
     return $blocks;
 }
Esempio n. 5
0
 /**
  * Save uploaded logo and favicon and return array of their urls
  * @return Array of Strings
  */
 private static function _saveUploadedLogos()
 {
     $logo_names = array('logo', 'favicon');
     $options = array();
     foreach ($logo_names as $logo_name) {
         $pair_ids = fn_attach_image_pairs($logo_name, 'twg_logos');
         if (!empty($pair_ids)) {
             $image_id = TwigmoImage::getImageId(array('pair_id' => reset($pair_ids), 'object_type' => 'twg_logos'));
             $image_data = fn_get_image($image_id, 'twg_logos');
             $options[$logo_name . '_url'] = $image_data['http_image_path'];
         }
     }
     return $options;
 }