Example #1
0
 private function _installDataSample()
 {
     if (!file_exists(_PS_MODULE_DIR_ . 'leotempcp/libs/DataSample.php')) {
         return true;
     }
     require_once _PS_MODULE_DIR_ . 'leotempcp/libs/DataSample.php';
     $sample = new Datasample(1);
     return $sample->processImport($this->name);
 }
 /**
  * Build Fields Parameter Options
  */
 public function makeFieldsOptions()
 {
     $soption = array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')));
     $tskins = LeoFrameworkHelper::getSkins($this->themeName);
     $directions = LeoFrameworkHelper::getLayoutDirections($this->themeName);
     $this->lang = true;
     $skins = array();
     $skins[] = array('name' => $this->l('Default'), 'id' => 'default');
     $skins = array_merge_recursive($skins, $tskins);
     /* GENERAL SETTING */
     $general_fields = array(array('type' => 'setting_list', 'name' => 'moduleList', 'values' => "", 'default' => ''), array('type' => 'hidden', 'label' => $this->l('Theme Key'), 'name' => "theme_key", 'default' => Tools::strtoupper($this->themeKey), 'cast' => 'string'), array('type' => 'switch', 'label' => $this->l('Enable Responsive'), 'name' => $this->getConfigName('enable_responsive'), 'default' => 0, 'values' => $soption), array('label' => $this->l('Layout Direction'), 'name' => $this->getConfigName('layout_direction'), 'default' => 'default', 'type' => 'select', 'options' => array('query' => $directions, 'id' => 'id', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('Layout Width'), 'name' => $this->getConfigName('layout_width'), 'default' => "auto", 'cast' => 'intval', 'desc' => $this->l('You can input auto or WIDTHpx, such as: 1170px')), array('type' => 'switch', 'label' => $this->l('Enable Copyright'), 'name' => $this->getConfigName('enable_copyright'), 'values' => $soption, 'default' => "0", 'desc' => $this->l('Allow to display your copyright information at bottom of site.')), array('type' => 'textarea', 'label' => $this->l('Copyright'), 'name' => $this->getConfigName('copyright'), 'default' => "Copyright " . date('Y') . " Powered by PrestaShop. All Rights Reserved.", 'rows' => '12', 'cols' => '30', 'autoload_rte' => true, 'lang' => true, 'autoload_rte' => true), array('type' => 'switch', 'label' => $this->l('Enable Panel Tool'), 'name' => $this->getConfigName('paneltool'), 'default' => 0, 'values' => $soption, 'desc' => $this->l('Whethere to display Panel Tool appearing on left of site.')), array('type' => 'select', 'label' => $this->l('Default Skin'), 'name' => $this->getConfigName('default_skin'), 'default' => 'default', 'options' => array('query' => $skins, 'id' => 'id', 'name' => 'name')));
     $theme_customizations = LeoFrameworkHelper::getLayoutSettingByTheme($this->themeName);
     if (isset($theme_customizations['layout'])) {
         foreach ($theme_customizations['layout'] as $key => $value) {
             $o = array('label' => $this->l(isset($value['title']) ? $value['title'] : $key), 'name' => $this->getConfigName(trim($key)), 'default' => $value['default'], 'type' => 'select', 'options' => array('query' => $value['option'], 'id' => 'id', 'name' => 'name'), 'desc' => isset($value['desc']) ? $this->l($value['desc']) : null);
             array_push($general_fields, $o);
         }
     }
     $theme_customizations_header = LeoFrameworkHelper::getPanelConfigByTheme('header', $this->themeName);
     if (isset($theme_customizations_header['configs'])) {
         foreach ($theme_customizations_header['configs'] as $key => $value) {
             $headerStyleOption = array('label' => $this->l(isset($value['title']) ? $value['title'] : $key), 'name' => $this->getConfigName(trim($key)), 'default' => $value['default'], 'type' => 'select', 'options' => array('query' => $value['option'], 'id' => 'id', 'name' => 'name'), 'desc' => isset($value['desc']) ? $this->l($value['desc']) : null);
             array_push($general_fields, $headerStyleOption);
         }
     }
     $theme_customizations_sidebar = LeoFrameworkHelper::getPanelConfigByTheme('sidebarmenu', $this->themeName);
     if (isset($theme_customizations_sidebar['configs'])) {
         foreach ($theme_customizations_sidebar['configs'] as $key => $value) {
             $headerStyleOption = array('label' => $this->l(isset($value['title']) ? $value['title'] : $key), 'name' => $this->getConfigName(trim($key)), 'default' => $value['default'], 'type' => 'select', 'options' => array('query' => $value['option'], 'id' => 'id', 'name' => 'name'), 'desc' => isset($value['desc']) ? $this->l($value['desc']) : null);
             array_push($general_fields, $headerStyleOption);
         }
     }
     /* Page Setting */
     $page_fields = array(array('type' => 'setting_list', 'name' => 'moduleList', 'values' => "", 'default' => ''), array('type' => 'select', 'label' => $this->l('Products Listing Mode'), 'name' => $this->getConfigName('listing_mode'), 'default' => "grid", 'options' => array('query' => array(array('id' => 'grid', 'name' => $this->l('Grid Mode')), array('id' => 'list', 'name' => $this->l('List Mode'))), 'id' => 'id', 'name' => 'name'), 'desc' => $this->l('Display Products In List Mode Or Grid Mode In Product List....')), array('type' => 'select', 'label' => $this->l('Columns in Product List page On Desktop'), 'name' => $this->getConfigName('grid_column'), 'default' => ' ', 'options' => array('query' => array(array('id' => '', 'name' => $this->l('Default')), array('id' => '2', 'name' => $this->l('2 Columns')), array('id' => '3', 'name' => $this->l('3 Columns')), array('id' => '4', 'name' => $this->l('4 Columns')), array('id' => '5', 'name' => $this->l('5 Columns')), array('id' => '6', 'name' => $this->l('6 Columns'))), 'id' => 'id', 'name' => 'name'), 'desc' => $this->l('How many column display in grid mode of product list.')), array('type' => 'select', 'label' => $this->l('Columns in Default Module On Desktop'), 'name' => $this->getConfigName('grid_column_module'), 'default' => ' ', 'options' => array('query' => array(array('id' => '', 'name' => $this->l('Default')), array('id' => '2', 'name' => $this->l('2 Columns')), array('id' => '3', 'name' => $this->l('3 Columns')), array('id' => '4', 'name' => $this->l('4 Columns')), array('id' => '5', 'name' => $this->l('5 Columns')), array('id' => '6', 'name' => $this->l('6 Columns'))), 'id' => 'id', 'name' => 'name'), 'desc' => $this->l('How many column display in default module of prestashop.')), array('type' => 'select', 'label' => $this->l('Product Grid Columns On Tablet'), 'name' => $this->getConfigName('grid_column_tablet'), 'default' => '', 'options' => array('query' => array(array('id' => '', 'name' => $this->l('Default')), array('id' => '1', 'name' => $this->l('1 Column')), array('id' => '2', 'name' => $this->l('2 Columns')), array('id' => '3', 'name' => $this->l('3 Columns'))), 'id' => 'id', 'name' => 'name'), 'desc' => $this->l('How many column display in table of grid mode.')), array('type' => 'select', 'label' => $this->l('Product Grid Columns On Mobile'), 'name' => $this->getConfigName('grid_column_mobile'), 'default' => '', 'options' => array('query' => array(array('id' => '', 'name' => $this->l('Default')), array('id' => '1', 'name' => $this->l('1 Column')), array('id' => '2', 'name' => $this->l('2 Columns'))), 'id' => 'id', 'name' => 'name'), 'desc' => $this->l('How many column display in Mobile of grid mode')), array('type' => 'switch', 'label' => $this->l('Enable Wishlist Link'), 'name' => $this->getConfigName('enable_wishlist'), 'default' => 0, 'values' => $soption, 'desc' => $this->l('Select no when you don not enable wishlist moduel of prestashop')), array('type' => 'switch', 'label' => $this->l('Enable Color Option'), 'name' => $this->getConfigName('enable_color'), 'default' => 0, 'values' => $soption, 'desc' => $this->l('Select no when you don not want to show color option')), array('type' => 'switch', 'label' => $this->l('Enable Tab in product Detail'), 'name' => $this->getConfigName('enable_ptab'), 'default' => 0, 'values' => $soption, 'desc' => $this->l('Select no when you don not want to use tab in product detail')), array('type' => 'switch', 'label' => $this->l('Enable Float Header'), 'name' => $this->getConfigName('enable_fheader'), 'default' => 0, 'values' => $soption, 'desc' => $this->l('Select no when you don not want your header float')));
     $font_fields = array();
     $tskins = LeoFrameworkHelper::getUserProfiles($this->themeName);
     $skins = array();
     $skins[] = array('name' => $this->l('No Use'), 'skin' => '');
     $skins = array_merge_recursive($skins, $tskins);
     $cssCode = '';
     $id_shop = $this->context->shop->id;
     $customCssFile = $this->themePath . 'css/local/' . $id_shop . 'custom.css';
     if (file_exists($customCssFile)) {
         $cssCode = trim(Tools::file_get_contents($customCssFile));
     }
     $customization_fields = array(array('type' => 'setting_list', 'name' => 'moduleList', 'values' => "", 'default' => ''), array('type' => 'select', 'label' => $this->l('Custom Profile'), 'name' => $this->getConfigName('c_profile'), 'default' => 0, 'options' => array('query' => $skins, 'id' => 'skin', 'name' => 'name'), 'desc' => $this->l('Select A Custom Theme Profile Which Generated Via Using Live Customizing Theme Tool.')), array('type' => 'switch', 'label' => $this->l('Enable Custom Css Code'), 'name' => $this->getConfigName('enable_codecss'), 'default' => 0, 'values' => $soption), array('type' => 'textarea', 'label' => $this->l('Custom Css Code'), 'name' => $this->getConfigName('c_codecss'), 'default' => $cssCode, 'values' => $soption, 'rows' => '6', 'cols' => ''), array('type' => 'switch', 'label' => $this->l('Enable Custom JS Code'), 'name' => $this->getConfigName('enable_codejs'), 'default' => "", 'values' => $soption, 'desc' => $this->l('Whethere to display Custom JS Code In Theme.')), array('type' => 'textarea', 'label' => $this->l('Custom JS Code'), 'name' => $this->getConfigName('c_codejs'), 'default' => "", 'values' => $soption, 'rows' => '6', 'cols' => ''));
     $this->context->controller->addJs(__PS_BASE_URI__ . str_replace("//", "/", 'modules/leotempcp') . '/assets/admin/form.js', 'all');
     /* FONTS FORM */
     $fonts_fields = array();
     $fonts = array(array('id' => 'Verdana', 'font' => htmlspecialchars('Verdana, Geneva, sans-serif'), 'name' => 'Verdana'), array('id' => 'Georgia', 'font' => htmlspecialchars('Georgia, "Times New Roman", Times, serif'), 'name' => 'Georgia'), array('id' => 'Arial', 'font' => htmlspecialchars('Arial, Helvetica, sans-serif'), 'name' => 'Arial'), array('id' => 'Impact', 'font' => htmlspecialchars('Impact, Arial, Helvetica, sans-serif'), 'name' => 'Impact'), array('id' => 'Tahoma', 'font' => htmlspecialchars('Tahoma, Geneva, sans-serif'), 'name' => 'Tahoma'), array('id' => 'Trebuchet', 'font' => htmlspecialchars('"Trebuchet MS", Arial, Helvetica, sans-serif'), 'name' => 'Trebuchet MS'), array('id' => 'Arial', 'font' => htmlspecialchars('"Arial Black", Gadget, sans-serif'), 'name' => 'Arial Black'), array('id' => 'Times', 'font' => htmlspecialchars('Times, "Times New Roman", serif'), 'name' => 'Times'), array('id' => 'Palatino', 'font' => htmlspecialchars('"Palatino Linotype", "Book Antiqua", Palatino, serif'), 'name' => 'Palatino Linotype'), array('id' => 'Lucida', 'font' => htmlspecialchars('"Lucida Sans Unicode", "Lucida Grande", sans-serif'), 'name' => 'Lucida Sans Unicode'), array('id' => 'MS', 'font' => htmlspecialchars('"MS Serif", "New York", serif'), 'name' => 'MS Serif'), array('id' => 'Comic', 'font' => htmlspecialchars('"Comic Sans MS", cursive'), 'name' => 'Comic Sans MS'), array('id' => 'Courier', 'font' => htmlspecialchars('"Courier New", Courier, monospace'), 'name' => 'Courier New'), array('id' => 'Lucida', 'font' => htmlspecialchars('"Lucida Console", Monaco, monospace'), 'name' => 'Lucida Console'));
     $fs = array(array('id' => '', 'name' => $this->l('Default')), array('id' => '10', 'name' => $this->l('10')), array('id' => '11', 'name' => $this->l('11')), array('id' => '12', 'name' => $this->l('12')), array('id' => '13', 'name' => $this->l('13')), array('id' => '14', 'name' => $this->l('14')));
     $fonts_fields = array(array('type' => 'setting_list', 'name' => 'moduleList', 'values' => "", 'default' => ''), array('type' => 'switch', 'label' => $this->l('Enable Custom Font'), 'name' => $this->getConfigName('enable_customfont'), 'default' => 0, 'values' => $soption), array('type' => 'select', 'label' => $this->l('Font Engines 1'), 'name' => $this->getConfigName('font_engine1'), 'default' => 'local', 'options' => array('query' => array(array('id' => 'local', 'name' => $this->l('Local')), array('id' => 'google', 'name' => $this->l('Google'))), 'id' => 'id', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Local Font Family'), 'name' => $this->getConfigName('engine1_local_font'), 'default' => '', 'options' => array('query' => $fonts, 'id' => 'id', 'name' => 'name'), 'identifier' => 'id', 'class' => 'localfont'), array('type' => 'text', 'label' => $this->l('Google Link'), 'name' => $this->getConfigName('engine1_google_link'), 'default' => '', 'identifier' => 'id', 'class' => 'localfont', 'desc' => 'For Example: http://fonts.googleapis.com/css?family=Gorditas'), array('type' => 'text', 'label' => $this->l('Google Font Family'), 'name' => $this->getConfigName('engine1_google_font'), 'default' => '', 'desc' => "For Example: 'Gorditas', cursive", 'identifier' => 'id', 'class' => 'localfont'), array('type' => 'textarea', 'label' => $this->l('Css Selector'), 'name' => $this->getConfigName('font1_selector'), 'default' => '', 'rows' => '6', 'cols' => '', 'desc' => $this->l('Example: body, h1,h2,h3, #yourstyle, .myrule div')), array('type' => 'select', 'label' => $this->l('Font Engines 2'), 'name' => $this->getConfigName('font_engine2'), 'default' => 'local', 'options' => array('query' => array(array('id' => 'local', 'name' => $this->l('Local')), array('id' => 'google', 'name' => $this->l('Google'))), 'id' => 'id', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Local Font Family'), 'name' => $this->getConfigName('engine2_local_font'), 'default' => '', 'options' => array('query' => $fonts, 'id' => 'id', 'name' => 'name'), 'identifier' => 'id', 'class' => 'localfont'), array('type' => 'text', 'label' => $this->l('Google Link'), 'name' => $this->getConfigName('engine2_google_link'), 'default' => '', 'identifier' => 'id', 'class' => 'localfont'), array('type' => 'text', 'label' => $this->l('Google Font Family'), 'name' => $this->getConfigName('engine2_google_font'), 'default' => '', 'identifier' => 'id', 'class' => 'localfont'), array('type' => 'textarea', 'label' => $this->l('Css Selector'), 'name' => $this->getConfigName('font2_selector'), 'default' => '', 'rows' => '6', 'cols' => '', 'desc' => $this->l('Example: body, h1,h2,h3, #yourstyle, .myrule div')), array('type' => 'select', 'label' => $this->l('Font Engines 3'), 'name' => $this->getConfigName('font_engine3'), 'default' => 'local', 'options' => array('query' => array(array('id' => 'local', 'name' => $this->l('Local')), array('id' => 'google', 'name' => $this->l('Google'))), 'id' => 'id', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Local Font Family'), 'name' => $this->getConfigName('engine3_local_font'), 'default' => '', 'options' => array('query' => $fonts, 'id' => 'id', 'name' => 'name'), 'identifier' => 'id', 'class' => 'localfont'), array('type' => 'text', 'label' => $this->l('Google Link'), 'name' => $this->getConfigName('engine3_google_link'), 'default' => '', 'identifier' => 'id', 'class' => 'localfont'), array('type' => 'text', 'label' => $this->l('Google Font Family'), 'name' => $this->getConfigName('engine3_google_font'), 'default' => '', 'identifier' => 'id', 'class' => 'localfont'), array('type' => 'textarea', 'label' => $this->l('Css Selector'), 'name' => $this->getConfigName('font3_selector'), 'default' => '', 'rows' => '6', 'cols' => '', 'desc' => $this->l('Example: body, h1,h2,h3, #yourstyle, .myrule div')));
     $liveThemeURL = 'index.php?tab=AdminLeotempcpTheme&token=' . Tools::getAdminTokenLite('AdminLeotempcpTheme') . '&refer=1';
     /* RENDER */
     $this->fields_options[0]['form'] = array('tinymce' => true, 'legend' => array('title' => '<span class="label label-info">' . $this->l('General Setting') . '</span>', 'icon' => 'icon-cogs'), 'description' => 'Configure Default Skin and General Information', 'input' => $general_fields, 'submit' => array('title' => $this->l('Save'), 'class' => 'button btn btn-danger'));
     $this->fields_options[1]['form'] = array('legend' => array('title' => '<span class="label label-success">' . $this->l('Pages Setting') . '</span>', 'icon' => 'icon-cogs'), 'input' => $page_fields, 'submit' => array('title' => $this->l('Save'), 'class' => 'button btn btn-danger'));
     $this->fields_options[2]['form'] = array('legend' => array('title' => '<span class="label label-danger">' . $this->l('Customization Setting') . '</span>', 'icon' => 'icon-cogs'), 'description' => $this->l('Support Customize Theme Skin Without experting Css Code') . $this->l(' The framework supports you two way to put your customization on theme.') . '<br />
             <p>' . $this->l('1. You create your css file(s) and put in LEO_YOURTHEME/css/local.') . '</p>' . $this->l('2. All files will be loaded automatic Or use tools at bellow') . '</p><hr>' . $this->l('Click Live Customizing Theme to create custom-theme-profiles and they will be listed in above dropdown box. You select one profile theme to apply for your site') . '<p>' . $this->l('!important: All theme profiles are stored in folder LEO_YOURTHEME/css/customize, it need permission 0755 to put files inside') . '</p>
             <a href="' . $liveThemeURL . '" class="btn-danger btn"><i class="icon-external-link-sign"></i> ' . $this->l('Live Customizing Theme') . '</a><br /><hr>', 'input' => $customization_fields, 'submit' => array('title' => $this->l('Save'), 'class' => 'button btn btn-danger'));
     $this->fields_options[3]['form'] = array('legend' => array('title' => '<span class="label label-default">' . $this->l('Font Setting') . '</span>', 'icon' => 'icon-cogs'), 'description' => $this->l('Enable Custom Configure Font With Google Font Or Local Font') . '<hr>' . $this->l('To Use Google Font, Please visit google font page to explore all avariable fonts http://www.google.com/fonts. Then Add Expected to Collection and paste link and font name for following inputs') . '<p><a href="#">' . $this->l('Click Here To Read Guide') . '</a></p>', 'input' => $fonts_fields, 'submit' => array('title' => $this->l('Save'), 'class' => 'button btn btn-danger'));
     $sample = new Datasample();
     $moduleList = $sample->getModuleList();
     $sample_field = array(array('type' => 'setting_list', 'name' => 'moduleList', 'values' => "", 'default' => ''), array('type' => 'modules_block', 'label' => $this->l('Module List:'), 'name' => 'moduleList', 'values' => $moduleList, 'default' => ''));
     //data sample
     $this->fields_options[4]['form'] = array('legend' => array('title' => '<span class="label label-default">' . $this->l('Sample data') . '</span>', 'icon' => 'icon-cogs'), 'description' => $this->l('You can import-Export Sample data') . '<hr>' . $this->l('Or can Back-up, Restore Database of Module from Leotheme'), 'input' => $sample_field, 'submit' => array('title' => $this->l('Save'), 'class' => 'button btn btn-danger'));
 }
Example #3
0
 /**
  * @see Module::install()
  */
 public function install()
 {
     if ($this->_leotype == 0) {
         LeoManagewidgetsInstall::installModuleTab($this->name, 'Leo Manage widgets', 'widgets', 'AdminParentModules');
         LeoManagewidgetsInstall::installModuleTab($this->name, 'Leo Manage Widget Images', 'images', -1);
     }
     /* Adds Module */
     $res = true;
     if (parent::install()) {
         $res &= $this->registerHook('header');
         $res &= $this->registerHook('actionShopDataDuplication');
         $res &= $this->registerHook('actionAdminPerformanceControllerAfter');
         // clear cache
         foreach ($this->_hooksPos as $value) {
             $res &= $this->registerHook($value);
         }
     }
     /* Creates tables */
     if ($this->_leotype == 1) {
         Configuration::updateValue('LEO_MANAGERWIDGETS_VERSION', $this->version);
         require_once _PS_MODULE_DIR_ . 'leotempcp/libs/DataSample.php';
         $sample = new Datasample(1);
         return $sample->processImport($this->name);
     } else {
         $res &= LeoManagewidgetsInstall::createTables();
     }
     return (bool) $res;
 }