示例#1
0
 public static function print_available_themes()
 {
     $installedThemesDirs = array();
     $themes = Theme::getAvailable(false);
     $installedThemes = Theme::getThemes();
     foreach ($installedThemes as $installedTheme) {
         $installedThemesDirs[] = $installedTheme->directory;
     }
     $table = new Cli\Table();
     $table->setHeaders(array('Directory', 'Installed'));
     foreach ($themes as $theme) {
         //check if theme is installed
         if (array_search($theme, $installedThemesDirs) === false) {
             $isInstalled = 'No';
         } else {
             $isInstalled = 'Yes';
         }
         $table->addRow(array($theme, $isInstalled));
     }
     $table->display();
 }
 public function renderForm()
 {
     $getAvailableThemes = Theme::getAvailable(false);
     $available_theme_dir = array();
     $selected_theme_dir = null;
     if ($this->object) {
         $selected_theme_dir = $this->object->directory;
     }
     foreach ($getAvailableThemes as $k => $dirname) {
         $available_theme_dir[$k]['value'] = $dirname;
         $available_theme_dir[$k]['label'] = $dirname;
         $available_theme_dir[$k]['id'] = $dirname;
     }
     $this->fields_form = array('tinymce' => false, 'legend' => array('title' => $this->l('Theme'), 'image' => '../img/admin/themes.gif'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name of the theme:'), 'name' => 'name', 'size' => 48, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}')), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
     // adding a new theme, you can create a directory, and copy from an existing theme
     if ($this->display == 'add' || !$this->object->id) {
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Name of the theme\'s directory:'), 'name' => 'directory', 'required' => true, 'desc' => $this->l('If the directory does not exists, it will be created.'));
         $theme_query = Theme::getThemes();
         $this->fields_form['input'][] = array('type' => 'select', 'name' => 'based_on', 'label' => $this->l('Copy missing files from existing theme:'), 'desc' => $this->l('If you create a new theme, it\'s recommended to use default theme files.'), 'options' => array('id' => 'id', 'name' => 'name', 'default' => array('value' => 0, 'label' => '&nbsp;-&nbsp;'), 'query' => $theme_query));
     } else {
         $this->fields_form['input'][] = array('type' => 'radio', 'label' => $this->l('Directory:'), 'name' => 'directory', 'required' => true, 'br' => true, 'class' => 't', 'values' => $available_theme_dir, 'selected' => $selected_theme_dir, 'desc' => $this->l('Please select a valid theme directory.'));
     }
     return parent::renderForm();
 }
示例#3
0
 public function renderForm()
 {
     $get_available_themes = Theme::getAvailable(false);
     $available_theme_dir = array();
     $selected_theme_dir = null;
     $metas = Meta::getMetas();
     $formated_metas = array();
     foreach ($metas as $meta) {
         $meta_object = new Meta($meta['id_meta']);
         $title = $meta['page'];
         if (isset($meta_object->title[(int) $this->context->language->id]) && $meta_object->title[(int) $this->context->language->id] != '') {
             $title = $meta_object->title[(int) $this->context->language->id];
         }
         $formated_metas[$meta['id_meta']] = array('title' => $title, 'left' => 0, 'right' => 0);
     }
     $image_url = false;
     if ($this->object) {
         if ((int) $this->object->id > 0) {
             $theme = new Theme((int) $this->object->id);
             $theme_metas = $theme->getMetas();
             // if no theme_meta are found, we must create them
             if (empty($theme_metas)) {
                 $metas = Db::getInstance()->executeS('SELECT id_meta FROM ' . _DB_PREFIX_ . 'meta');
                 $metas_default = array();
                 foreach ($metas as $meta) {
                     $tmp_meta['id_meta'] = (int) $meta['id_meta'];
                     $tmp_meta['left'] = 1;
                     $tmp_meta['right'] = 1;
                     $metas_default[] = $tmp_meta;
                 }
                 $theme->updateMetas($metas_default);
                 $theme_metas = $theme->getMetas();
             }
             $image_url = '<img alt="preview" src="' . __PS_BASE_URI__ . 'themes/' . $theme->directory . '/preview.jpg">';
             foreach ($theme_metas as $theme_meta) {
                 $formated_metas[$theme_meta['id_meta']]['id_theme_meta'] = (int) $theme_meta['id_theme_meta'];
                 $formated_metas[$theme_meta['id_meta']]['id_meta'] = (int) $theme_meta['id_meta'];
                 $formated_metas[$theme_meta['id_meta']]['left'] = (int) $theme_meta['left_column'];
                 $formated_metas[$theme_meta['id_meta']]['right'] = (int) $theme_meta['right_column'];
             }
         }
         $selected_theme_dir = $this->object->directory;
     }
     foreach ($get_available_themes as $k => $dirname) {
         $available_theme_dir[$k]['value'] = $dirname;
         $available_theme_dir[$k]['label'] = $dirname;
         $available_theme_dir[$k]['id'] = $dirname;
     }
     $this->fields_form = array('tinymce' => false, 'legend' => array('title' => $this->l('Theme'), 'icon' => 'icon-picture'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name of the theme'), 'name' => 'name', 'required' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'file', 'label' => $this->l('Preview image for the theme'), 'name' => 'image_preview', 'display_image' => true, 'hint' => sprintf($this->l('Max image size: %1s'), Tools::formatBytes(Tools::getMaxUploadSize())), 'image' => $image_url), array('type' => 'switch', 'label' => $this->l('Default left column'), 'name' => 'default_left_column', 'hint' => $this->l('Choose a default behavior when displaying the column in a new page added by you or by a module.'), 'values' => array(array('id' => 'default_left_column_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'default_left_column_off', 'value' => 0, 'label' => $this->l('No')))), array('type' => 'switch', 'label' => $this->l('Default right column'), 'name' => 'default_right_column', 'hint' => $this->l('Choose a default behavior when displaying the column in a new page added by you or by a module.'), 'values' => array(array('id' => 'default_right_column_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'default_right_column_off', 'value' => 0, 'label' => $this->l('No')))), array('type' => 'text', 'label' => $this->l('Number of products per page'), 'name' => 'product_per_page', 'hint' => $this->l('This value will be used when activating the theme.'))), 'submit' => array('title' => $this->l('Save')));
     // adding a new theme, you can create a directory, and copy from an existing theme
     if ($this->display == 'add' || !$this->object->id) {
         $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Name of the theme\'s directory'), 'name' => 'directory', 'required' => true, 'hint' => $this->l('If the directory does not exists, it will be created.'));
         $theme_query = Theme::getThemes();
         $this->fields_form['input'][] = array('type' => 'select', 'name' => 'based_on', 'label' => $this->l('Copy missing files from existing theme'), 'hint' => $this->l('If you create a new theme, it\'s recommended that you use the default theme files.'), 'options' => array('id' => 'id', 'name' => 'name', 'default' => array('value' => 0, 'label' => '-'), 'query' => $theme_query));
         $this->fields_form['input'][] = array('type' => 'switch', 'label' => $this->l('Responsive'), 'name' => 'responsive', 'hint' => $this->l('Please indicate if the theme is adapted to all screen sizes (mobile, tablet, desktop).'), 'values' => array(array('id' => 'responsive_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'responsive_off', 'value' => 0, 'label' => $this->l('No'))));
     } else {
         $this->fields_form['input'][] = array('type' => 'radio', 'label' => $this->l('Directory'), 'name' => 'directory', 'required' => true, 'br' => true, 'values' => $available_theme_dir, 'selected' => $selected_theme_dir, 'hint' => $this->l('Please select a valid theme directory.'));
     }
     $list = '';
     if (Tools::getIsset('update' . $this->table)) {
         $fields_list = array('title' => array('title' => $this->l('Meta'), 'align' => 'center', 'width' => 'auto'), 'left' => array('title' => $this->l('Left column'), 'active' => 'left', 'type' => 'bool', 'ajax' => true), 'right' => array('title' => $this->l('Right column'), 'active' => 'right', 'type' => 'bool', 'ajax' => true));
         $helper_list = new HelperList();
         $helper_list->tpl_vars = array('icon' => 'icon-columns');
         $helper_list->title = $this->l('Appearance of columns');
         $helper_list->no_link = true;
         $helper_list->shopLinkType = '';
         $helper_list->identifier = 'id_theme_meta';
         $helper_list->table = 'meta';
         $helper_list->currentIndex = $this->context->link->getAdminLink('AdminThemes', false);
         $helper_list->token = Tools::getAdminTokenLite('AdminThemes');
         $list = $helper_list->generateList($formated_metas, $fields_list);
     }
     return parent::renderForm() . $list;
 }
示例#4
0
 public function getContentExport()
 {
     if (_PS_VERSION_ < '1.5') {
         $this->theme_list = $this->getThemes14();
     } else {
         $this->theme_list = Theme::getAvailable();
     }
     $this->error = false;
     self::getModuleState();
     self::displayInformations();
     if (Tools::isSubmit('submitExport') && $this->error === false && $this->checkPostedDatas() == true) {
         self::getThemeVariations();
         self::getDocumentation();
         self::getHookState();
         self::getImageState();
         self::generateXML();
         self::generateArchive();
     }
     self::authorInformationForm();
     self::modulesInformationForm();
     self::themeInformationForm();
     self::docInformationForm();
     self::variationInformationForm();
     return $this->_html;
 }
示例#5
0
 public function getContentExport()
 {
     $this->theme_list = Theme::getAvailable();
     $this->error = false;
     self::getModuleState();
     self::displayInformations();
     if (Tools::isSubmit('submitExport') && $this->error === false && $this->checkPostedDatas() == true) {
         self::getThemeVariations();
         // Check variations exists
         if (empty($this->variations)) {
             $this->_html .= parent::displayError($this->l('You must select at least one theme'));
         } else {
             self::getDocumentation();
             self::getHookState();
             self::getImageState();
             self::generateXML();
             self::generateArchive();
         }
     }
     self::authorInformationForm();
     self::modulesInformationForm();
     self::themeInformationForm();
     self::docInformationForm();
     self::variationInformationForm();
     return $this->_html;
 }
function getTemplateVars()
{
    $vars = array();
    $controllers = getTemplateControllers();
    foreach (Theme::getAvailable(false) as $themeName) {
        $themeDir = getThemeDir($themeName);
        $path = $themeDir . '/templates/templates.php';
        if (file_exists($path)) {
            require_once $path;
        }
        foreach ($controllers as $type => $controller) {
            $name = getTemplateName($themeName, $type);
            $value = Configuration::get($name, false);
            if (!$value && isset($templates)) {
                // template settings has not been saved to database yet or it's preview theme
                foreach ($templates[$type] as $t) {
                    if (isset($t['name']) && $t['name'] == $type) {
                        $value = $type . '_' . $t['id'];
                    }
                }
            }
            if ($value) {
                $c = strtolower($controller);
                $vars[$themeName][$c] = $value;
            }
        }
    }
    return $vars;
}
 public static function buildThemesData($currentIndex = '', $adminDir = '')
 {
     $token = Designer::getToken();
     $baseUrl = Designer::getBaseUrlWithLastSlash();
     $themesUrl = $baseUrl . 'themes';
     $adminUrl = $baseUrl . $adminDir . '/' . ($currentIndex ? $currentIndex : 'index.php?controller=AdminAjax') . '&token=' . $token;
     $shop = Designer::getShop();
     $themes = array();
     foreach (Theme::getAvailable(false) as $themeName) {
         if (strpos($themeName, _PREVIEW_SUFFIX_) !== FALSE || !file_exists(getProjectPath($themeName))) {
             continue;
         }
         $id = Designer::getThemeId($themeName);
         $themeUrl = $themesUrl . '/' . $themeName;
         $url = $adminUrl . '&theme_name=' . $themeName;
         $themes['themes'][$themeName] = array('themeName' => $themeName, 'thumbnailUrl' => $themeUrl . '/preview.jpg', 'openUrl' => $url . '&ajax=1&ver=' . theme_get_manifest_version($themeName) . getDesktopParams(), 'settingsUrl' => $url . '&edit=1', 'isActive' => $id && $shop->id_theme == $id);
     }
     return $themes;
 }
function getTemplateVars()
{
    $vars = array();
    $templates = getTemplateControllers();
    foreach (Theme::getAvailable(false) as $themeName) {
        foreach ($templates as $type => $controller) {
            $name = getTemplateName($themeName, $type);
            $value = Configuration::get($name);
            if ($value) {
                $c = strtolower($controller);
                $vars[$themeName][$c] = $value;
            }
        }
    }
    return $vars;
}