当前位置: 首页>>代码示例>>PHP>>正文


PHP Theme::add方法代码示例

本文整理汇总了PHP中Theme::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Theme::add方法的具体用法?PHP Theme::add怎么用?PHP Theme::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Theme的用法示例。


在下文中一共展示了Theme::add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: importThemeXmlConfig

 /**
  * @param SimpleXMLElement $xml
  * @param bool             $theme_dir only used if the theme directory to import is already located on the shop
  *
  * @return string|Theme return theme on success, otherwise the error as a string is returned
  */
 protected function importThemeXmlConfig(SimpleXMLElement $xml, $theme_dir = false)
 {
     $themes = Theme::getThemes();
     $name = strval($xml->variations->variation[0]['name']);
     $new_theme = new Theme();
     $new_theme->name = $name;
     $new_theme->directory = strval($xml->variations->variation[0]['directory']);
     if ($theme_dir) {
         $new_theme->name = $theme_dir;
         $new_theme->directory = $theme_dir;
     }
     foreach ($themes as $theme_object) {
         if ($theme_object->name == $new_theme->name) {
             return $this->l('Theme already installed.');
         }
     }
     $new_theme->product_per_page = Configuration::get('PS_PRODUCTS_PER_PAGE');
     if (isset($xml->variations->variation[0]['product_per_page'])) {
         $new_theme->product_per_page = intval($xml->variations->variation[0]['product_per_page']);
     }
     $new_theme->responsive = false;
     if (isset($xml->variations->variation[0]['responsive'])) {
         $new_theme->responsive = (bool) strval($xml->variations->variation[0]['responsive']);
     }
     $new_theme->default_left_column = true;
     $new_theme->default_right_column = true;
     if (isset($xml->variations->variation[0]['default_left_column'])) {
         $new_theme->default_left_column = (bool) strval($xml->variations->variation[0]['default_left_column']);
     }
     if (isset($xml->variations->variation[0]['default_right_column'])) {
         $new_theme->default_right_column = (bool) strval($xml->variations->variation[0]['default_right_column']);
     }
     $metas_xml = array();
     if ($xml->metas->meta) {
         foreach ($xml->metas->meta as $meta) {
             $meta_id = Db::getInstance()->getValue('SELECT id_meta FROM ' . _DB_PREFIX_ . 'meta WHERE page=\'' . pSQL($meta['meta_page']) . '\'');
             if ((int) $meta_id > 0) {
                 $tmp_meta = array();
                 $tmp_meta['id_meta'] = (int) $meta_id;
                 $tmp_meta['left'] = intval($meta['left']);
                 $tmp_meta['right'] = intval($meta['right']);
                 $metas_xml[] = $tmp_meta;
             }
         }
     } else {
         $metas = Db::getInstance()->executeS('SELECT id_meta FROM ' . _DB_PREFIX_ . 'meta');
         foreach ($metas as $meta) {
             $tmp_meta['id_meta'] = (int) $meta['id_meta'];
             $tmp_meta['left'] = 1;
             $tmp_meta['right'] = 1;
             $metas_xml[] = $tmp_meta;
         }
     }
     if (!is_dir(_PS_ALL_THEMES_DIR_ . $new_theme->directory)) {
         mkdir(_PS_ALL_THEMES_DIR_ . $new_theme->directory);
     }
     $new_theme->add();
     if ($new_theme->id > 0) {
         $new_theme->updateMetas($metas_xml);
     } else {
         return $this->l('Error while installing theme');
     }
     return $new_theme;
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:70,代码来源:AdminThemesController.php

示例2: initContent

 public function initContent()
 {
     $this->checkMobileNeeds();
     $themes = array();
     foreach (Theme::getThemes() as $theme) {
         $themes[] = $theme->directory;
     }
     foreach (scandir(_PS_ALL_THEMES_DIR_) as $theme_dir) {
         if ($theme_dir[0] != '.' && Validate::isDirName($theme_dir) && is_dir(_PS_ALL_THEMES_DIR_ . $theme_dir) && file_exists(_PS_ALL_THEMES_DIR_ . $theme_dir . '/preview.jpg') && !in_array($theme_dir, $themes)) {
             $theme = new Theme();
             $theme->name = $theme->directory = $theme_dir;
             $theme->add();
         }
     }
     $content = '';
     if (file_exists(_PS_IMG_DIR_ . 'logo.jpg')) {
         list($width, $height, $type, $attr) = getimagesize(_PS_IMG_DIR_ . Configuration::get('PS_LOGO'));
         Configuration::updateValue('SHOP_LOGO_HEIGHT', (int) round($height));
         Configuration::updateValue('SHOP_LOGO_WIDTH', (int) round($width));
     }
     $this->content .= $content;
     return parent::initContent();
 }
开发者ID:rrameshsat,项目名称:Prestashop,代码行数:23,代码来源:AdminThemesController.php

示例3: importThemeXmlConfig

 protected function importThemeXmlConfig(SimpleXMLElement $xml, $theme_dir = false)
 {
     $attr = $xml->attributes();
     $th_name = (string) $attr->name;
     if ($this->isThemeInstalled($th_name)) {
         return array(sprintf($this->l('Theme %s already installed.'), $th_name));
     }
     $new_theme_array = array();
     foreach ($xml->variations->variation as $variation) {
         $name = strval($variation['name']);
         $new_theme = new Theme();
         $new_theme->name = $name;
         $new_theme->directory = strval($variation['directory']);
         if ($theme_dir) {
             $new_theme->name = $theme_dir;
             $new_theme->directory = $theme_dir;
         }
         if ($this->isThemeInstalled($new_theme->name)) {
             continue;
         }
         $new_theme->product_per_page = Configuration::get('PS_PRODUCTS_PER_PAGE');
         if (isset($variation['product_per_page'])) {
             $new_theme->product_per_page = intval($variation['product_per_page']);
         }
         $new_theme->responsive = false;
         if (isset($variation['responsive'])) {
             $new_theme->responsive = (bool) strval($variation['responsive']);
         }
         $new_theme->default_left_column = true;
         $new_theme->default_right_column = true;
         if (isset($variation['default_left_column'])) {
             $new_theme->default_left_column = (bool) strval($variation['default_left_column']);
         }
         if (isset($variation['default_right_column'])) {
             $new_theme->default_right_column = (bool) strval($variation['default_right_column']);
         }
         $fill_default_meta = true;
         $metas_xml = array();
         if ($xml->metas->meta) {
             foreach ($xml->metas->meta as $meta) {
                 $meta_id = Db::getInstance()->getValue('SELECT id_meta FROM ' . _DB_PREFIX_ . 'meta WHERE page=\'' . pSQL($meta['meta_page']) . '\'');
                 if ((int) $meta_id > 0) {
                     $tmp_meta = array();
                     $tmp_meta['id_meta'] = (int) $meta_id;
                     $tmp_meta['left'] = intval($meta['left']);
                     $tmp_meta['right'] = intval($meta['right']);
                     $metas_xml[(int) $meta_id] = $tmp_meta;
                 }
             }
             $fill_default_meta = false;
             if (count($xml->metas->meta) < (int) Db::getInstance()->getValue('SELECT count(*) FROM ' . _DB_PREFIX_ . 'meta')) {
                 $fill_default_meta = true;
             }
         }
         if ($fill_default_meta == true) {
             $metas = Db::getInstance()->executeS('SELECT id_meta FROM ' . _DB_PREFIX_ . 'meta');
             foreach ($metas as $meta) {
                 if (!isset($metas_xml[(int) $meta['id_meta']])) {
                     $tmp_meta['id_meta'] = (int) $meta['id_meta'];
                     $tmp_meta['left'] = $new_theme->default_left_column;
                     $tmp_meta['right'] = $new_theme->default_right_column;
                     $metas_xml[(int) $meta['id_meta']] = $tmp_meta;
                 }
             }
         }
         if (!is_dir(_PS_ALL_THEMES_DIR_ . $new_theme->directory)) {
             if (!mkdir(_PS_ALL_THEMES_DIR_ . $new_theme->directory)) {
                 return sprintf($this->l('Error while creating %s directory'), _PS_ALL_THEMES_DIR_ . $new_theme->directory);
             }
         }
         $new_theme->add();
         if ($new_theme->id > 0) {
             $new_theme->updateMetas($metas_xml);
             $new_theme_array[] = $new_theme;
         } else {
             $new_theme_array[] = sprintf($this->l('Error while installing theme %s'), $new_theme->name);
         }
     }
     return $new_theme_array;
 }
开发者ID:tmdhosting,项目名称:TMDHosting-PrestaShop-Technology-Theme,代码行数:80,代码来源:ThemeInstallHelper.php

示例4: displayForm3

    private function displayForm3()
    {
        $res = true;
        $theme_directory = Tools::getValue('theme_directory');
        $xml = simplexml_load_file(_IMPORT_FOLDER_ . XMLFILENAME);
        $this->xml = $xml;
        if ($this->selected_variations && count($this->selected_variations) > 0) {
            $ok = array();
            foreach ($this->selected_variations as $variation) {
                if ($variation == $this->default_theme) {
                    continue;
                }
                if ($variation != $theme_directory) {
                    $theme_directory = $variation;
                }
                if (empty($theme_directory)) {
                    $theme_directory = str_replace(' ', '', (string) $this->xml['name']);
                }
                if (_PS_VERSION_ < '1.5') {
                    self::recurseCopy(_IMPORT_FOLDER_ . 'themes/' . $variation, _PS_ALL_THEMES_DIR_ . $variation);
                    if (file_exists(_PS_ALL_THEMES_DIR_ . $variation)) {
                        $ok[] = $variation;
                    }
                } else {
                    $target_dir = _PS_ALL_THEMES_DIR_ . $theme_directory;
                    $res &= self::recurseCopy(_IMPORT_FOLDER_ . 'themes/' . $variation, $target_dir);
                    $new_theme = new Theme();
                    $new_theme->name = (string) $this->xml['name'];
                    $new_theme->directory = $theme_directory;
                    $name_exist = true;
                    // Check name theme
                    $themes = $new_theme->getThemes();
                    foreach ($themes as $row) {
                        if ($row->name == $new_theme->name) {
                            $name_exist &= false;
                        }
                    }
                    if ($name_exist) {
                        $res &= $new_theme->add();
                    }
                    if ($res) {
                        $ok[] = $variation;
                    }
                }
            }
            if (count($ok) > 0) {
                $msg = $this->l('The following themes were successfully imported:') . '<ul><i>';
                foreach ($ok as $row) {
                    $msg .= '<li> ' . $row . '</li>';
                }
                $msg .= '</i></ul>';
                $this->_msg = parent::displayConfirmation($msg);
            }
        }
        self::getModules();
        if (file_exists(_IMPORT_FOLDER_ . 'doc') && count($xml->docs->doc) != 0) {
            self::loadDocForm();
        }
        $this->_html .= '<fieldset>';
        if ($this->to_install && count($this->to_install) > 0) {
            $var = '';
            foreach ($this->to_install as $row) {
                if (file_exists(_IMPORT_FOLDER_ . 'modules/' . $row)) {
                    $module_already_exists = file_exists(_PS_MODULE_DIR_ . $row);
                    $var .= '<input type="checkbox" name="modulesToExport[]" id="' . $row . '" value="' . $row . '" checked="checked" />
						<label style="display:bock;float:none" for="' . $row . '">' . $row . ($module_already_exists ? ' <span style="font-size:0.8em;color:red;">' . $this->l('Warning: a module with the same name already exists.') . '</span>' : '') . '</label><br />';
                }
            }
            if ($var != '') {
                $this->_html .= '
					<fieldset>
						<legend>' . $this->l('Select the theme\'s modules you wish to install') . '</legend>
						<p class="margin-form">' . $var . '</p>
					</fieldset>
					<p>&nbsp;</p>';
            }
        }
        $var = '';
        if (is_array($this->to_enable) && !empty($this->to_enable)) {
            $list_to_disabled = array_diff($this->native_modules, $this->to_enable);
        } else {
            $list_to_disabled = $this->native_modules;
        }
        foreach ($list_to_disabled as $row) {
            $obj = Module::getInstanceByName($row);
            if (Validate::isLoadedObject($obj)) {
                if (!file_exists(_IMPORT_FOLDER_ . 'modules/' . $row) && $obj->tab == 'front_office_features') {
                    $var .= '<input type="checkbox" name="modulesToDisable[]" id="' . $row . '" value="' . $row . '" checked="checked" />
						<label style="display:bock;float:none" for="' . $row . '">' . $row . '</label><br />';
                }
            }
        }
        if (!empty($var)) {
            $this->_html .= '
				<fieldset>
					<legend>' . $this->l('Select the modules which must be disabled for this theme') . '</legend>
					<p class="margin-form">' . $var . '</p>
				</fieldset>
				<p>&nbsp;</p>';
        }
//.........这里部分代码省略.........
开发者ID:jep004,项目名称:prestashop,代码行数:101,代码来源:themeinstallator.php

示例5: displayForm3

    private function displayForm3()
    {
        $res = true;
        $theme_directory = Tools::getValue('theme_directory');
        $xml = simplexml_load_file(_IMPORT_FOLDER_ . XMLFILENAME);
        $this->xml = $xml;
        if ($this->selected_variations && count($this->selected_variations) > 0) {
            $ok = array();
            foreach ($this->selected_variations as $variation) {
                if ($variation == $this->default_theme) {
                    continue;
                }
                if ($variation != $theme_directory) {
                    $theme_directory .= $variation;
                }
                if (empty($theme_directory)) {
                    $theme_directory = str_replace(' ', '', (string) $this->xml['name']);
                }
                $target_dir = _PS_ALL_THEMES_DIR_ . $theme_directory;
                $res &= self::recurseCopy(_IMPORT_FOLDER_ . 'themes/' . $variation, $target_dir);
                $new_theme = new Theme();
                $new_theme->name = (string) $this->xml['name'];
                $new_theme->directory = $theme_directory;
                $name_exist = true;
                // Check name theme
                $themes = $new_theme->getThemes();
                foreach ($themes as $row) {
                    if ($row->name == $new_theme->name) {
                        $name_exist &= false;
                    }
                }
                if ($name_exist) {
                    $res &= $new_theme->add();
                }
                if ($res) {
                    $ok[] = $variation;
                }
            }
            if (count($ok) > 0) {
                $msg = $this->l('The following themes were successfully imported') . ':<ul><i>';
                foreach ($ok as $row) {
                    $msg .= '<li> ' . $row;
                }
                $msg .= '</i></ul>';
                $this->_msg = parent::displayConfirmation($msg);
            }
        }
        self::getModules();
        if (file_exists(_IMPORT_FOLDER_ . 'doc') && count($xml->docs->doc) != 0) {
            self::loadDocForm();
        }
        $this->_html .= '<fieldset>';
        if ($this->to_install && count($this->to_install) > 0) {
            $var = '';
            foreach ($this->to_install as $row) {
                if (file_exists(_IMPORT_FOLDER_ . 'modules/' . $row)) {
                    $module_already_exists = file_exists(_PS_MODULE_DIR_ . $row);
                    $var .= '<input type="checkbox" name="modulesToExport[]" id="' . $row . '" value="' . $row . '" checked="checked" />
						<label style="display:bock;float:none" for="' . $row . '">' . $row . ($module_already_exists ? ' <span style="font-size:0.8em">-> ' . $this->l('Warning: a module with the same name already exists') . '</span>' : '') . '</label><br />';
                }
            }
            if ($var != '') {
                $this->_html .= '
					<fieldset>
						<legend>' . $this->l('Select the theme\'s modules you wish to install') . '</legend>
						<p class="margin-form">' . $var . '</p>
					</fieldset>
					<p>&nbsp;</p>';
            }
        }
        $var = '';
        foreach (array_diff($this->native_modules, $this->to_disable) as $row) {
            $obj = Module::getInstanceByName($row);
            if (Validate::isLoadedObject($obj)) {
                if (!file_exists(_IMPORT_FOLDER_ . 'modules/' . $row) && $obj->tab == 'front_office_features') {
                    $var .= '<input type="checkbox" name="modulesToDisable[]" id="' . $row . '" value="' . $row . '" />
						<label style="display:bock;float:none" for="' . $row . '">' . $row . '</label><br />';
                }
            }
        }
        $this->_html .= '
			<fieldset>
				<legend>' . $this->l('Select modules which must be disabled for this theme') . '</legend>
				<p class="margin-form">' . $var . '</p>
			</fieldset>
			<p>&nbsp;</p>';
        $this->_html .= '
			<fieldset>
				<legend>' . $this->l('Native modules configuration') . '</legend>
				<ul class="margin-form" style="list-style:none">
					<li>
						<input type="radio" name="nativeModules" value="1" id="nativemoduleconfig1"/>
						<label style="display:bock;float:none" for="nativemoduleconfig1">' . $this->l('Current configuration') . '</label>
					</li>
					<li>
						<input type="radio" name="nativeModules" value="2" id="nativemoduleconfig2" checked="checked" />
						<label style="display:bock;float:none" for="nativemoduleconfig2">' . $this->l('Theme\'s configuration') . '</label>
					</li>
					<li>
						<input type="radio" name="nativeModules" value="3" id="nativemoduleconfig3" />
//.........这里部分代码省略.........
开发者ID:jicheng17,项目名称:vipinsg,代码行数:101,代码来源:themeinstallator.php


注:本文中的Theme::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。