public function renderList()
 {
     $languages = Language::getLanguages(false);
     $id_lang_default = (int) Configuration::get('PS_LANG_DEFAULT');
     $view = Tools::getValue('view', 'displaylist');
     $tpl = $this->createTemplate('oviclayoutbuilder.tpl');
     $current_theme = Theme::getThemeInfo($this->context->shop->id_theme);
     $tpl->assign(array('postUrl' => self::$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminLayoutBuilder'), 'absoluteUrl' => __PS_BASE_URI__ . 'modules/' . $this->module->name, 'thumbnails_dir' => __PS_BASE_URI__ . 'modules/oviclayoutcontrol', 'logo_url' => $this->context->link->getMediaLink(_PS_IMG_ . Configuration::get('PS_LOGO')), 'view' => $view));
     if ($view == 'displaylist') {
         $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'ovic_options` o
         WHERE LCASE(o.`theme`) =\'' . strtolower($current_theme['theme_name']) . '\'';
         $options = Db::getInstance()->executeS($sql);
         $tpl->assign(array('options' => $options));
     } elseif ($view == 'setting') {
         $id_option = (int) Tools::getValue('id_option');
         if ($id_option && Validate::isUnsignedId($id_option) && OvicLayoutControl::isAvailablebyId($id_option)) {
             $option = new Options($id_option);
         } else {
             $option = new Options();
         }
         if (Tools::isSubmit('submitnewOption')) {
             $option->column = Tools::getValue('colselected');
             $option->active = (int) Tools::getValue('active');
             $option->alias = Tools::getValue('alias');
             $option->name = Tools::getValue('option_name');
             $option->image = Tools::getValue('old_img');
         } elseif (Tools::isSubmit('submitCopyOption')) {
             $id_copy_option = Tools::getValue('id_copy_option');
             $copy_option = new Options($id_copy_option);
             $option->name = $copy_option->name;
             $option->column = $copy_option->column;
             $option->active = $copy_option->active;
             $tpl->assign('id_copy_option', $id_copy_option);
         }
         $tpl->assign(array('option' => $option, 'langguages' => array('default_lang' => $id_lang_default, 'all' => $languages, 'lang_dir' => _THEME_LANG_DIR_)));
     } elseif ($view == 'detail') {
         $id_option = (int) Tools::getValue('id_option');
         if ($id_option && Validate::isUnsignedId($id_option)) {
             $optionTheme = new Options($id_option);
             $displayLeft = false;
             $displayRight = false;
             $homeWidth = 12;
             if (substr_count($optionTheme->column, '1') > 0 || substr_count($optionTheme->column, '0') > 0) {
                 $displayLeft = true;
                 $homeWidth -= 3;
             }
             if (substr_count($optionTheme->column, '2') > 0 || substr_count($optionTheme->column, '0') > 0) {
                 $displayRight = true;
                 $homeWidth -= 3;
             }
             $optionModulesHook = OvicLayoutControl::getOptionModulesHook($optionTheme);
             $tpl->assign(array('multistyle' => $this->renderColorForm($id_option), 'id_option' => $id_option, 'optionModulesHook' => $optionModulesHook, 'displayLeft' => $displayLeft, 'displayRight' => $displayRight, 'homeWidth' => $homeWidth, 'moduleDir' => _MODULE_DIR_, 'templatePath' => $this->getTemplatePath()));
         }
     }
     return $tpl->fetch();
 }
示例#2
0
 public function hookDisplayHeader($params)
 {
     $this->context->controller->removeJS('/granada/js/jquery/plugins/jqzoom/jquery.jqzoom.js');
     $id_shop = (int) $this->context->shop->id;
     $current_id_option = Configuration::get('OVIC_CURRENT_OPTION', null, null, $id_shop);
     $current_option = new Options($current_id_option);
     $current_theme = Theme::getThemeInfo($this->context->shop->id_theme);
     if (strtolower($current_option->theme) != strtolower($current_theme['theme_name'])) {
         Configuration::deleteByName('OVIC_CURRENT_OPTION');
         Configuration::deleteByName('OVIC_LAYOUT_COLUMN');
         Configuration::deleteByName('OVIC_CURRENT_DIR');
         $current_id_option = null;
     }
     $emptyOption = false;
     if (!$current_id_option || !Validate::isUnsignedId($current_id_option) || !OvicLayoutControl::isAvailablebyId($current_id_option)) {
         $id_lang_default = (int) Configuration::get('PS_LANG_DEFAULT');
         $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'ovic_options` o
                WHERE LCASE(o.`theme`) =\'' . strtolower($current_theme['theme_name']) . '\'';
         $options = Db::getInstance()->executeS($sql);
         if ($options && is_array($options) && sizeof($options) > 0) {
             foreach ($options as $option) {
                 $current_option = new Options($option['id_option']);
                 Configuration::updateValue('OVIC_CURRENT_OPTION', $option['id_option'], false, null, $id_shop);
                 Configuration::updateValue('OVIC_CURRENT_DIR', str_replace(' ', '_', $current_option->alias), false, null, $id_shop);
                 $current_id_option = $option['id_option'];
                 break;
             }
         } else {
             $emptyOption = true;
         }
     }
     if (!$emptyOption) {
         $current_option = new Options($current_id_option);
         if (strtolower($current_option->theme) == strtolower($current_theme['theme_name'])) {
             $selected_layout = Configuration::get('OVIC_LAYOUT_COLUMN', null, null, $id_shop);
             if (!$selected_layout || substr_count($current_option->column, $selected_layout) < 1) {
                 if (strlen($current_option->column) > 0) {
                     $selected_layout = (int) substr($current_option->column, 0, 1);
                     Configuration::updateValue('OVIC_LAYOUT_COLUMN', $selected_layout, false, null, $id_shop);
                     $this->ProcessLayoutColumn();
                 }
             }
         } else {
             $emptyOption = true;
         }
     }
     if ($emptyOption) {
         $this->context->smarty->assign(array('emptyOption' => Tools::displayError('There is no Option, please add new Option from Layout Builder menu.')));
         return '';
     }
     $output = '';
     global $smarty;
     $optionStyle = $this->getOptionStyle($current_option->theme, $current_option->alias);
     $fonts = array();
     if ($optionStyle['font'] && is_array($optionStyle['font']) && sizeof($optionStyle['font']) > 0) {
         foreach ($optionStyle['font'] as $key => $font) {
             $start = strpos($font, 'family');
             $fontName = substr_replace($font, '', 0, $start + 7);
             $start = strpos($fontName, "'");
             $fontName = substr_replace($fontName, '', $start, strlen($fontName));
             if (strpos($fontName, ":") > 0) {
                 $start = strpos($fontName, ":");
                 $fontName = substr_replace($fontName, '', $start, strlen($fontName));
             }
             $fontName = str_replace('+', ' ', $fontName);
             if (strlen($font) > 0) {
                 $start = strpos($font, 'http');
                 $substr = substr_replace($font, '', $start, strlen($font) - $start);
                 $start = strpos($font, ':');
                 $font = substr_replace($font, '', 0, $start);
                 $font = $substr . (empty($_SERVER['HTTPS']) ? 'http' : 'https') . $font;
             }
             $fonts[] = array('fontname' => $fontName, 'linkfont' => $font);
         }
     }
     if ($optionStyle['color'] && is_array($optionStyle['color']) && sizeof($optionStyle['color']) > 0) {
         $grbacolor = $this->hex2rgba($optionStyle['color']['main']);
     }
     $current_id_option = Configuration::get('OVIC_CURRENT_OPTION', null, null, $id_shop);
     $current_dir = trim(Configuration::get('OVIC_CURRENT_DIR', null, null, $id_shop));
     if (Dispatcher::getInstance()->getController() == 'contact') {
         $default_country = new Country((int) Tools::getCountry());
         //$a = 'http'.((Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE')) ? 's' : '').'://maps.google.com/maps/api/js?sensor=true&region='.substr($default_country->iso_code, 0, 2);
         $this->context->controller->addJS('http' . (Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE') ? 's' : '') . '://maps.google.com/maps/api/js?sensor=true&region=' . substr($default_country->iso_code, 0, 2));
         $this->context->controller->addJS(_THEME_JS_DIR_ . 'contact.js');
         $distanceUnit = Configuration::get('PS_DISTANCE_UNIT');
         if (!in_array($distanceUnit, array('km', 'mi'))) {
             $distanceUnit = 'km';
         }
         $this->context->smarty->assign(array('mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'defaultLat' => (double) Configuration::get('PS_STORES_CENTER_LAT'), 'defaultLong' => (double) Configuration::get('PS_STORES_CENTER_LONG'), 'searchUrl' => $this->context->link->getPageLink('stores'), 'logo_store' => Configuration::get('PS_STORES_ICON'), 'distanceUnit' => $distanceUnit, 'hasStoreIcon' => file_exists(_PS_IMG_DIR_ . Configuration::get('PS_STORES_ICON'))));
     }
     $smarty->assign(array('grbacolor' => isset($grbacolor) ? $grbacolor : '', 'font' => $fonts, 'color' => $optionStyle['color'], 'current_id_option' => $current_id_option, 'current_dir' => $current_dir, 'BEFORE_LOGO' => Hook::exec('displayBeforeLogo'), 'HOOK_HOME_TOP_COLUMN' => Hook::exec('displayHomeTopColumn'), 'HOME_BOTTOM_CONTENT' => Hook::exec('displayHomeBottomContent'), 'HOME_BOTTOM_COLUMN' => Hook::exec('displayHomeBottomColumn'), 'HOME_TOP_CONTENT' => Hook::exec('displayHomeTopContent'), 'BOTTOM_COLUMN' => Hook::exec('displayBottomColumn')));
     return $this->display(__FILE__, 'multistyle.tpl');
 }
 public function renderList()
 {
     $view = Tools::getValue('view', 'default');
     $id_lang = $this->context->language->id;
     $id_shop = $this->context->shop->id;
     if ($view == 'default') {
         $languages = Language::getLanguages(false);
         $id_lang_default = (int) Configuration::get('PS_LANG_DEFAULT');
         $tpl = $this->createTemplate('oviclayout.tpl');
         $id_tab = (int) Tools::getValue('id_tab', 0);
         $current_id_option = Configuration::get('OVIC_CURRENT_OPTION', null, null, $id_shop);
         $check_option = new Options($current_id_option);
         $current_theme = Theme::getThemeInfo($this->context->shop->id_theme);
         if (strtolower($check_option->theme) != strtolower($current_theme['theme_name'])) {
             Configuration::deleteByName('OVIC_CURRENT_OPTION');
             Configuration::deleteByName('OVIC_LAYOUT_COLUMN');
             Configuration::deleteByName('OVIC_CURRENT_DIR');
             $current_id_option = null;
         }
         $emptyOption = false;
         $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'ovic_options` o
             WHERE LCASE(o.`theme`) =\'' . strtolower($current_theme['theme_name']) . '\'';
         $options = Db::getInstance()->executeS($sql);
         if ($options && is_array($options) && sizeof($options) > 0) {
             if (!$current_id_option || !Validate::isUnsignedId($current_id_option) || !OvicLayoutControl::isAvailablebyId($current_id_option)) {
                 foreach ($options as $option) {
                     $current_option = new Options($option['id_option']);
                     Configuration::updateValue('OVIC_CURRENT_OPTION', $option['id_option'], false, null, $id_shop);
                     Configuration::updateValue('OVIC_CURRENT_DIR', str_replace(' ', '_', $current_option->alias), false, null, $id_shop);
                     $current_id_option = $option['id_option'];
                     break;
                 }
             }
         } else {
             $emptyOption = true;
         }
         if ($options && is_array($options) && sizeof($options) > 0) {
             $current_option = new Options($current_id_option);
         }
         if (!$emptyOption) {
             $selected_layout = Configuration::get('OVIC_LAYOUT_COLUMN', null, null, $id_shop);
             if (!$selected_layout || substr_count($current_option->column, $selected_layout) < 1) {
                 if (strlen($current_option->column) > 0) {
                     $selected_layout = (int) substr($current_option->column, 0, 1);
                     Configuration::updateValue('OVIC_LAYOUT_COLUMN', $selected_layout, false, null, $id_shop);
                     $this->ProcessLayoutColumn();
                 }
             }
         } else {
             $tpl->assign(array('emptyOption' => Tools::displayError('There is no Option, please add new Option from Layout Builder menu.')));
         }
         //get sidebar infomation
         $pagelist = Meta::getMetas();
         $sidebarPages = array();
         if ($pagelist && is_array($pagelist) && sizeof($pagelist) > 0) {
             $theme = new Theme((int) $this->context->shop->id_theme);
             foreach ($pagelist as $page) {
                 $sidebarPage = array();
                 $meta_object = new Meta($page['id_meta']);
                 $title = $page['page'];
                 if (isset($meta_object->title[(int) $id_lang]) && $meta_object->title[(int) $id_lang] != '') {
                     $title = $meta_object->title[(int) $id_lang];
                 }
                 $sidebarPage['id_meta'] = $page['id_meta'];
                 $sidebarPage['title'] = $title;
                 $sidebarPage['page_name'] = $page['page'];
                 $sidebarPage['displayLeft'] = $theme->hasLeftColumn($page['page']) ? 1 : 0;
                 $sidebarPage['displayRight'] = $theme->hasRightColumn($page['page']) ? 1 : 0;
                 $sidebarPages[] = $sidebarPage;
             }
         }
         $tpl->assign(array('postUrl' => self::$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminLayoutSetting'), 'absoluteUrl' => __PS_BASE_URI__ . 'modules/' . $this->module->name, 'id_tab' => $id_tab, 'options' => $options, 'current_option' => isset($current_option) ? $current_option : null, 'selected_layout' => isset($selected_layout) ? $selected_layout : null, 'sidebarPages' => $sidebarPages));
     } elseif ($view == 'detail') {
         $tpl = $this->createTemplate('sidebarmodule.tpl');
         $pagemeta = Tools::getValue('pagemeta');
         $meta = Meta::getMetaByPage($pagemeta, $id_lang);
         $theme = new Theme((int) $this->context->shop->id_theme);
         $LeftModules = array();
         $RightModules = array();
         if ($theme->hasLeftColumn($pagemeta)) {
             $LeftModules = OvicLayoutControl::getSideBarModulesByPage($pagemeta, 'left');
         }
         if ($theme->hasRightColumn($pagemeta)) {
             $RightModules = OvicLayoutControl::getSideBarModulesByPage($pagemeta, 'right');
         }
         $tpl->assign(array('postUrl' => self::$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminLayoutSetting'), 'leftModule' => $LeftModules, 'rightModule' => $RightModules, 'pagemeta' => $pagemeta, 'pagename' => $meta['title'], 'displayLeft' => $theme->hasLeftColumn($pagemeta), 'displayRight' => $theme->hasRightColumn($pagemeta), 'templatePath' => $this->getTemplatePath(), 'moduleDir' => _MODULE_DIR_));
     }
     return $tpl->fetch();
 }
 public function renderList()
 {
     $languages = Language::getLanguages(false);
     $id_lang_default = (int) Configuration::get('PS_LANG_DEFAULT');
     $view = Tools::getValue('view', 'displaylist');
     $tpl = $this->createTemplate('oviclayoutbuilder.tpl');
     $tpl->assign(array('postUrl' => self::$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminLayoutBuilder'), 'absoluteUrl' => __PS_BASE_URI__ . 'modules/' . $this->module->name, 'thumbnails_dir' => __PS_BASE_URI__ . 'modules/oviclayoutcontrol', 'logo_url' => $this->context->link->getMediaLink(_PS_IMG_ . Configuration::get('PS_LOGO')), 'view' => $view));
     if ($view == 'displaylist') {
         $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'ovic_options` o
             LEFT JOIN `' . _DB_PREFIX_ . 'ovic_options_lang` ol ON (o.`id_option` = ol.`id_option`) WHERE `id_lang`=' . $id_lang_default;
         $options = Db::getInstance()->executeS($sql);
         $tpl->assign(array('options' => $options));
     } elseif ($view == 'setting') {
         $id_option = (int) Tools::getValue('id_option');
         if ($id_option && Validate::isUnsignedId($id_option) && OvicLayoutControl::isAvailablebyId($id_option)) {
             $option = new Options($id_option);
         } else {
             $option = new Options();
         }
         if (Tools::isSubmit('submitnewOption')) {
             $option->column = Tools::getValue('colselected');
             $option->active = (int) Tools::getValue('active');
             foreach ($languages as $language) {
                 $option->name[$language['id_lang']] = Tools::getValue('option_name_' . $language['id_lang']);
             }
             $option->image = Tools::getValue('old_img');
         } elseif (Tools::isSubmit('submitCopyOption')) {
             $id_copy_option = Tools::getValue('id_copy_option');
             $copy_option = new Options($id_copy_option);
             $option->name = $copy_option->name;
             $option->column = $copy_option->column;
             $option->active = $copy_option->active;
             $tpl->assign('id_copy_option', $id_copy_option);
         }
         $lang_ul = '<ul class="dropdown-menu">';
         foreach ($languages as $lg) {
             $lang_ul .= '<li><a href="javascript:hideOtherLanguage(' . $lg['id_lang'] . ');" tabindex="-1">' . $lg['name'] . '</a></li>';
         }
         $lang_ul .= '</ul>';
         $tpl->assign(array('option' => $option, 'lang_ul' => $lang_ul, 'langguages' => array('default_lang' => $id_lang_default, 'all' => $languages, 'lang_dir' => _THEME_LANG_DIR_)));
     } elseif ($view == 'detail') {
         $id_option = (int) Tools::getValue('id_option');
         if ($id_option && Validate::isUnsignedId($id_option)) {
             $optionTheme = new Options($id_option);
             $displayLeft = false;
             $displayRight = false;
             $homeWidth = 12;
             if (substr_count($optionTheme->column, '1') > 0 || substr_count($optionTheme->column, '0') > 0) {
                 $displayLeft = true;
                 $homeWidth -= 3;
             }
             if (substr_count($optionTheme->column, '2') > 0 || substr_count($optionTheme->column, '0') > 0) {
                 $displayRight = true;
                 $homeWidth -= 3;
             }
             $optionModulesHook = OvicLayoutControl::getOptionModulesHook($id_option);
             $tpl->assign(array('id_option' => $id_option, 'optionModulesHook' => $optionModulesHook, 'displayLeft' => $displayLeft, 'displayRight' => $displayRight, 'homeWidth' => $homeWidth, 'moduleDir' => _MODULE_DIR_, 'templatePath' => $this->getTemplatePath()));
         }
     }
     return $tpl->fetch();
 }
 public function hookDisplayHeader($params)
 {
     $current_id_option = Configuration::get('OVIC_CURRENT_OPTION');
     $emptyOption = false;
     if (!$current_id_option || !Validate::isUnsignedId($current_id_option) || !OvicLayoutControl::isAvailablebyId($current_id_option)) {
         $id_lang_default = (int) Configuration::get('PS_LANG_DEFAULT');
         $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'ovic_options` o
                 LEFT JOIN `' . _DB_PREFIX_ . 'ovic_options_lang` ol ON (o.`id_option` = ol.`id_option`) WHERE `id_lang`=' . $id_lang_default;
         $options = Db::getInstance()->executeS($sql);
         if ($options && is_array($options) && sizeof($options) > 0) {
             foreach ($options as $option) {
                 $current_option = new Options($option['id_option'], $this->context->language->id);
                 Configuration::updateValue('OVIC_CURRENT_OPTION', $option['id_option']);
                 $current_id_option = $option['id_option'];
                 break;
             }
         } else {
             $emptyOption = true;
         }
     }
     if (!$emptyOption) {
         $current_option = new Options($current_id_option, $this->context->language->id);
         $selected_layout = Configuration::get('OVIC_LAYOUT_COLUMN');
         if (!$selected_layout || substr_count($current_option->column, $selected_layout) < 1) {
             if (strlen($current_option->column) > 0) {
                 $selected_layout = (int) substr($current_option->column, 0, 1);
                 Configuration::updateValue('OVIC_LAYOUT_COLUMN', $selected_layout);
                 $this->ProcessLayoutColumn();
             }
         }
     } else {
         $this->context->smarty->assign(array('emptyOption' => Tools::displayError('There is no Option, please add new Option from Layout Builder menu.')));
     }
     $output = '';
     global $smarty;
     //$linkfont =  Configuration::get('OVIC_FONT_LINK');
     //       $start = strpos($linkfont,'family');
     //       $linkfont = substr_replace($linkfont,'',0,$start+7);
     //       $start = strpos($linkfont,"'");
     //       $linkfont = substr_replace($linkfont,'',$start,strlen($linkfont));
     //       if (strpos($linkfont,":")>0){
     //            $start = strpos($linkfont,":");
     //            $linkfont = substr_replace($linkfont,'',$start,strlen($linkfont));
     //       }
     //       $font_name = str_replace('+',' ',$linkfont);
     //       $linkfont =  Configuration::get('OVIC_FONT_LINK');
     //       $start = strpos($linkfont,'http');
     //       $substr = substr_replace($linkfont,'',$start,strlen($linkfont)-$start);
     //       $start = strpos($linkfont,'://');
     //       $linkfont = substr_replace($linkfont,'',0,$start);
     //       $linkfont = $substr.(empty( $_SERVER['HTTPS'] ) ? 'http' : 'https') .$linkfont;
     //       $maincolor = Configuration::get('OVIC_MAIN_COLOR');
     //       $btncolor = Configuration::get('OVIC_BTN_COLOR');
     //       $btnHovercolor = Configuration::get('OVIC_BTN_HOVER_COLOR');
     //       $btntextcolor = Configuration::get('OVIC_BTN_TEXT_COLOR');
     //       $btntextHovercolor = Configuration::get('OVIC_BTN_TEXT_HOVER_COLOR');
     //       $grbacolor = $this->hex2rgba($maincolor);
     // $this->context->smarty->assign(array(
     //            'current_id_option' => Configuration::get('OVIC_CURRENT_OPTION'),
     //'linkfont' => $linkfont,
     //			'fontname' => $font_name,
     //			'maincolor' => $maincolor,
     //            'btncolor' => $btncolor,
     //            'btnHovercolor' => $btnHovercolor,
     //            'btntextcolor' => $btntextcolor,
     //            'btntextHovercolor' => $btntextHovercolor,
     //            'grbacolor' => $grbacolor
     //	      	));
     $current_id_option = Configuration::get('OVIC_CURRENT_OPTION');
     $smarty->assign(array('current_id_option' => $current_id_option, 'BEFORE_LOGO' => Hook::exec('displayBeforeLogo'), 'HOOK_HOME_TOP_COLUMN' => Hook::exec('displayHomeTopColumn'), 'HOME_BOTTOM_CONTENT' => Hook::exec('displayHomeBottomContent'), 'HOME_BOTTOM_COLUMN' => Hook::exec('displayHomeBottomColumn'), 'HOME_TOP_CONTENT' => Hook::exec('displayHomeTopContent'), 'BOTTOM_COLUMN' => Hook::exec('displayBottomColumn')));
     $this->context->controller->addCSS(_THEME_CSS_DIR_ . 'option' . $current_id_option . '.css', 'all');
     return $output;
 }