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


PHP Validate::isLinkRewrite方法代码示例

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


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

示例1: loadData

    public static function loadData($p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
    {
        $where = '';
        if (!empty($filter['id_onepage']) && Validate::isInt($filter['id_onepage'])) {
            $where .= ' AND a.`id_onepage`=' . intval($filter['id_onepage']);
        }
        if (!empty($filter['view_name']) && Validate::isEntityName($filter['view_name'])) {
            $where .= ' AND a.`view_name` LIKE "%' . pSQL($filter['view_name']) . '%"';
        }
        if (!empty($filter['meta_title']) && Validate::isGenericName($filter['meta_title'])) {
            $where .= ' AND a.`meta_title` LIKE "%' . pSQL($filter['meta_title']) . '%"';
        }
        if (!empty($filter['rewrite']) && Validate::isLinkRewrite($filter['rewrite'])) {
            $where .= ' AND a.`rewrite` LIKE "%' . pSQL($filter['rewrite']) . '%"';
        }
        if (!is_null($orderBy) and !is_null($orderWay)) {
            $postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
        } else {
            $postion = 'ORDER BY `id_onepage` DESC';
        }
        $total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'onepage` a
				WHERE 1 ' . $where);
        if ($total == 0) {
            return false;
        }
        $result = Db::getInstance()->getAll('SELECT a.* FROM `' . DB_PREFIX . 'onepage` a
				WHERE 1 ' . $where . '
				' . $postion . '
				LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
        $rows = array('total' => $total['total'], 'items' => $result);
        return $rows;
    }
开发者ID:yiuked,项目名称:tmcart,代码行数:32,代码来源:Onepage.php

示例2: getIdBySlug

 public static function getIdBySlug($slug)
 {
     if (!Validate::isLinkRewrite($slug)) {
         return Tools::displayError('getIdBySlug - invalid slug');
     }
     $sql = new DbQuery();
     $sql->select('id_simpleblog_post_type');
     $sql->from('simpleblog_post_type', 'sbpt');
     $sql->where('slug = \'' . $slug . '\'');
     return Db::getInstance()->getValue($sql);
 }
开发者ID:evgrishin,项目名称:se1614,代码行数:11,代码来源:SimpleBlogPostType.php

示例3: create_category

 public static function create_category($parent, $name, $linkRewrite, $description = '', $meta_title = '', $meta_description = '', $meta_keywords = '')
 {
     $configuration = PS_CLI_CONFIGURE::getConfigurationInstance();
     $category = new CMSCategory();
     if (!Validate::isUnsignedId($parent)) {
         echo "Error, {$parent} is not a valid category ID\n";
         return false;
     }
     $parentCat = new CMSCategory($parent);
     if (!Validate::isloadedObject($parentCat)) {
         echo "Error: category {$parentCat} does not exists\n";
         return false;
     }
     $category->id_parent = $parent;
     if (!Validate::isName($name)) {
         echo "Error, {$name} is not a valid category name\n";
         return false;
     }
     $category->name = array($configuration->lang => $name);
     if (!Validate::isLinkRewrite($linkRewrite)) {
         echo "Error, {$linkRewrite} is not a valid link rewrite\n";
         return false;
     }
     $category->link_rewrite = array($configuration->lang => $linkRewrite);
     if (!Validate::isCleanHtml($description)) {
         echo "Warning, {$description} is not a valid category description\n";
         $description = '';
     }
     $category->description = array($configuration->lang => $description);
     if (!Validate::isGenericName($meta_title)) {
         echo "Warning, {$meta_title} is not a valid value for meta_title\n";
         $meta_title = '';
     }
     $category->meta_title = array($configuration->lang => $meta_title);
     if (!Validate::isGenericName($meta_description)) {
         echo "Warning, {$meta_description} is not a valid value for meta_description\n";
         $meta_description = '';
     }
     $category->meta_description = array($configuration->lang => $meta_description);
     if (!Validate::isGenericName($meta_keywords)) {
         echo "Warning, {$meta_keywords} is not a valid value for meta_keywords\n";
         $meta_keywords = '';
     }
     $category->meta_keywords = array($configuration->lang => $meta_keywords);
     if ($category->add()) {
         if ($configuration->porcelain) {
             echo $category->id_cms_category;
         } else {
             echo "Successfully created category {$category->id_cms_category}\n";
         }
         return true;
     } else {
         echo "Error, could not create category {$name}\n";
         return false;
     }
 }
开发者ID:rodrisan,项目名称:ps-cli,代码行数:56,代码来源:cms.php

示例4: postProcess

 public function postProcess()
 {
     if (Tools::isSubmit('submitAddmeta')) {
         $langs = Language::getLanguages(false);
         $default_language = Configuration::get('PS_LANG_DEFAULT');
         if (Tools::getValue('page') != 'index') {
             $defaultLangIsValidated = Validate::isLinkRewrite(Tools::getValue('url_rewrite_' . $default_language));
             $englishLangIsValidated = Validate::isLinkRewrite(Tools::getValue('url_rewrite_1'));
         } else {
             // index.php can have empty rewrite rule
             $defaultLangIsValidated = !Tools::getValue('url_rewrite_' . $default_language) || Validate::isLinkRewrite(Tools::getValue('url_rewrite_' . $default_language));
             $englishLangIsValidated = !Tools::getValue('url_rewrite_1') || Validate::isLinkRewrite(Tools::getValue('url_rewrite_1'));
         }
         if (!$defaultLangIsValidated && !$englishLangIsValidated) {
             $this->errors[] = Tools::displayError('The URL rewrite field must be filled in either the default or English language.');
             return false;
         }
         foreach ($langs as $lang) {
             $current = Tools::getValue('url_rewrite_' . $lang['id_lang']);
             if (strlen($current) == 0) {
                 // Prioritize default language first
                 if ($defaultLangIsValidated) {
                     $_POST['url_rewrite_' . $lang['id_lang']] = Tools::getValue('url_rewrite_' . $default_language);
                 } else {
                     $_POST['url_rewrite_' . $lang['id_lang']] = Tools::getValue('url_rewrite_1');
                 }
             }
         }
         Hook::exec('actionAdminMetaSave');
     } else {
         if (Tools::isSubmit('submitRobots')) {
             $this->generateRobotsFile();
         }
     }
     if (Tools::isSubmit('PS_ROUTE_product_rule')) {
         Tools::clearCache($this->context->smarty);
     }
     return parent::postProcess();
 }
开发者ID:rongandat,项目名称:vatfairfoot,代码行数:39,代码来源:AdminMetaController.php

示例5: productImport


//.........这里部分代码省略.........
                         $categoryToCreate->name = self::createMultiLangField($value);
                         $categoryToCreate->active = 1;
                         $categoryToCreate->id_parent = 1;
                         // Default parent is home for unknown category to create
                         if (($fieldError = $categoryToCreate->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $categoryToCreate->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $categoryToCreate->add()) {
                             $product->id_category[] = (int) $categoryToCreate->id;
                         } else {
                             $this->_errors[] = $categoryToCreate->name[$defaultLanguageId] . (isset($categoryToCreate->id) ? ' (' . $categoryToCreate->id . ')' : '') . ' ' . Tools::displayError('Cannot be saved');
                             $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
                         }
                     }
                 } elseif (is_string($value) and !empty($value)) {
                     $category = Category::searchByName($defaultLanguageId, $value, true);
                     if ($category['id_category']) {
                         $product->id_category[] = (int) $category['id_category'];
                     } else {
                         $categoryToCreate = new Category();
                         $categoryToCreate->name = self::createMultiLangField($value);
                         $categoryToCreate->active = 1;
                         $categoryToCreate->id_parent = 1;
                         // Default parent is home for unknown category to create
                         if (($fieldError = $categoryToCreate->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $categoryToCreate->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $categoryToCreate->add()) {
                             $product->id_category[] = (int) $categoryToCreate->id;
                         } else {
                             $this->_errors[] = $categoryToCreate->name[$defaultLanguageId] . (isset($categoryToCreate->id) ? ' (' . $categoryToCreate->id . ')' : '') . ' ' . Tools::displayError('Cannot be saved');
                             $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
                         }
                     }
                 }
             }
         }
         $product->id_category_default = isset($product->id_category[0]) ? (int) $product->id_category[0] : '';
         $link_rewrite = is_array($product->link_rewrite) && count($product->link_rewrite) ? $product->link_rewrite[$defaultLanguageId] : '';
         $valid_link = Validate::isLinkRewrite($link_rewrite);
         if (isset($product->link_rewrite[$defaultLanguageId]) and empty($product->link_rewrite[$defaultLanguageId]) or !$valid_link) {
             $link_rewrite = Tools::link_rewrite($product->name[$defaultLanguageId]);
             if ($link_rewrite == '') {
                 $link_rewrite = 'friendly-url-autogeneration-failed';
             }
         }
         if (!$valid_link) {
             $this->_warnings[] = Tools::displayError('Rewrite link for') . ' ' . $link_rewrite . (isset($info['id']) ? ' (ID ' . $info['id'] . ') ' : '') . ' ' . Tools::displayError('was re-written as') . ' ' . $link_rewrite;
         }
         $product->link_rewrite = self::createMultiLangField($link_rewrite);
         $res = false;
         $fieldError = $product->validateFields(UNFRIENDLY_ERROR, true);
         $langFieldError = $product->validateFieldsLang(UNFRIENDLY_ERROR, true);
         if ($fieldError === true and $langFieldError === true) {
             // check quantity
             if ($product->quantity == NULL) {
                 $product->quantity = 0;
             }
             // If match ref is specified AND ref product AND ref product already in base, trying to update
             if (Tools::getValue('match_ref') == 1 and $product->reference and Product::existsRefInDatabase($product->reference)) {
                 $datas = Db::getInstance()->getRow('SELECT `date_add`, `id_product` FROM `' . _DB_PREFIX_ . 'product` WHERE `reference` = "' . $product->reference . '"');
                 $product->id = pSQL($datas['id_product']);
                 $product->date_add = pSQL($datas['date_add']);
                 $res = $product->update();
             } else {
                 if ($product->id and Product::existsInDatabase((int) $product->id, 'product')) {
                     $datas = Db::getInstance()->getRow('SELECT `date_add` FROM `' . _DB_PREFIX_ . 'product` WHERE `id_product` = ' . (int) $product->id);
                     $product->date_add = pSQL($datas['date_add']);
                     $res = $product->update();
                 }
             }
             // If no id_product or update failed
开发者ID:greench,项目名称:prestashop,代码行数:67,代码来源:AdminImport.php

示例6: postProcess

 public function postProcess()
 {
     if (Tools::isSubmit('submitAddmeta')) {
         $langs = Language::getLanguages(true);
         $default_language = Configuration::get('PS_LANG_DEFAULT');
         if (Tools::getValue('page') != 'index') {
             $defaultLangIsValidated = Validate::isLinkRewrite(Tools::getValue('url_rewrite_' . $default_language));
             $englishLangIsValidated = Validate::isLinkRewrite(Tools::getValue('url_rewrite_1'));
         } else {
             // index.php can have empty rewrite rule
             $defaultLangIsValidated = !Tools::getValue('url_rewrite_' . $default_language) or Validate::isLinkRewrite(Tools::getValue('url_rewrite_' . $default_language));
             $englishLangIsValidated = !Tools::getValue('url_rewrite_1') or Validate::isLinkRewrite(Tools::getValue('url_rewrite_1'));
         }
         if (!$defaultLangIsValidated and !$englishLangIsValidated) {
             $this->_errors[] = Tools::displayError('Url rewrite field must be filled at least in default or english language.');
             return false;
         }
         foreach ($langs as $lang) {
             $current = Tools::getValue('url_rewrite_' . $lang['id_lang']);
             if (strlen($current) == 0) {
                 // Prioritize default language first
                 if ($defaultLangIsValidated) {
                     $_POST['url_rewrite_' . $lang['id_lang']] = Tools::getValue('url_rewrite_' . $default_language);
                 } else {
                     $_POST['url_rewrite_' . $lang['id_lang']] = Tools::getValue('url_rewrite_1');
                 }
             }
         }
     }
     if (Tools::isSubmit('submitOptions' . $this->table)) {
         $baseUrls = array();
         if ($__PS_BASE_URI__ = Tools::getValue('__PS_BASE_URI__')) {
             $baseUrls['__PS_BASE_URI__'] = $__PS_BASE_URI__;
         }
         rewriteSettingsFile($baseUrls, NULL, NULL);
         unset($this->_fieldsGeneral['__PS_BASE_URI__']);
     }
     if (Tools::isSubmit('submitOptions' . $this->table) or Tools::isSubmit('submitAddmeta')) {
         Module::hookExec('afterSaveAdminMeta');
     }
     return parent::postProcess();
 }
开发者ID:hecbuma,项目名称:quali-fisioterapia,代码行数:42,代码来源:AdminMeta.php

示例7: generateHtaccess

 public static function generateHtaccess($path, $rewrite_settings, $cache_control, $specific = '', $disableMuliviews = false)
 {
     $tab = array('ErrorDocument' => array(), 'RewriteEngine' => array(), 'RewriteRule' => array());
     $multilang = Language::countActiveLanguages() > 1;
     // ErrorDocument
     $tab['ErrorDocument']['comment'] = '# Catch 404 errors';
     $tab['ErrorDocument']['content'] = '404 ' . __PS_BASE_URI__ . '404.php';
     // RewriteEngine
     $tab['RewriteEngine']['comment'] = '# URL rewriting module activation';
     // RewriteRules
     $tab['RewriteRule']['comment'] = '# URL rewriting rules';
     // Compatibility with the old image filesystem
     if (Configuration::get('PS_LEGACY_IMAGES')) {
         $tab['RewriteRule']['content']['^([a-z0-9]+)\\-([a-z0-9]+)(\\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1-$2$3.jpg [L]';
         $tab['RewriteRule']['content']['^([0-9]+)\\-([0-9]+)/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1-$2.jpg [L]';
     }
     // Rewriting for product image id < 100 millions
     $tab['RewriteRule']['content']['^([0-9])(\\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1/$1$2.jpg [L]';
     $tab['RewriteRule']['content']['^([0-9])([0-9])(\\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1/$2/$1$2$3.jpg [L]';
     $tab['RewriteRule']['content']['^([0-9])([0-9])([0-9])(\\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1/$2/$3/$1$2$3$4.jpg [L]';
     $tab['RewriteRule']['content']['^([0-9])([0-9])([0-9])([0-9])(\\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1/$2/$3/$4/$1$2$3$4$5.jpg [L]';
     $tab['RewriteRule']['content']['^([0-9])([0-9])([0-9])([0-9])([0-9])(\\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg [L]';
     $tab['RewriteRule']['content']['^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg [L]';
     $tab['RewriteRule']['content']['^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg [L]';
     $tab['RewriteRule']['content']['^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\\.jpg$'] = _PS_PROD_IMG_ . '$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg [L]';
     $tab['RewriteRule']['content']['^c/([0-9]+)(\\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\\.jpg$'] = 'img/c/$1$2.jpg [L]';
     $tab['RewriteRule']['content']['^c/([a-zA-Z-]+)/[a-zA-Z0-9-]+\\.jpg$'] = 'img/c/$1.jpg [L]';
     if ($multilang) {
         $tab['RewriteRule']['content']['^([a-z]{2})/[a-zA-Z0-9-]*/([0-9]+)\\-[a-zA-Z0-9-]*\\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';
         $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\\-[a-zA-Z0-9-]*\\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';
         $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+'] = 'category.php?id_category=$2&isolang=$1&noredirect=1 [QSA,L]';
         $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\\-[a-zA-Z0-9-]*'] = 'category.php?id_category=$2&isolang=$1 [QSA,L]';
         $tab['RewriteRule']['content']['^([a-z]{2})/content/([0-9]+)\\-[a-zA-Z0-9-]*'] = 'cms.php?isolang=$1&id_cms=$2 [QSA,L]';
         $tab['RewriteRule']['content']['^([a-z]{2})/content/category/([0-9]+)\\-[a-zA-Z0-9-]*'] = 'cms.php?isolang=$1&id_cms_category=$2 [QSA,L]';
         $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)__[a-zA-Z0-9-]*'] = 'supplier.php?isolang=$1&id_supplier=$2 [QSA,L]';
         $tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)_[a-zA-Z0-9-]*'] = 'manufacturer.php?isolang=$1&id_manufacturer=$2 [QSA,L]';
     }
     // PS BASE URI automaticaly prepend the string, do not use PS defines for the image directories
     $tab['RewriteRule']['content']['^([0-9]+)(\\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\\.jpg$'] = 'img/c/$1$2.jpg [L]';
     $tab['RewriteRule']['content']['^([0-9]+)\\-[a-zA-Z0-9-]*\\.html'] = 'product.php?id_product=$1 [QSA,L]';
     $tab['RewriteRule']['content']['^[a-zA-Z0-9-]*/([0-9]+)\\-[a-zA-Z0-9-]*\\.html'] = 'product.php?id_product=$1 [QSA,L]';
     // Notice : the id_category rule has to be after product rules.
     // If not, category with number in their name will result a bug
     $tab['RewriteRule']['content']['^([0-9]+)\\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+'] = 'category.php?id_category=$1&noredirect=1 [QSA,L]';
     $tab['RewriteRule']['content']['^([0-9]+)\\-[a-zA-Z0-9-]*'] = 'category.php?id_category=$1 [QSA,L]';
     $tab['RewriteRule']['content']['^([0-9]+)__([a-zA-Z0-9-]*)'] = 'supplier.php?id_supplier=$1 [QSA,L]';
     $tab['RewriteRule']['content']['^([0-9]+)_([a-zA-Z0-9-]*)'] = 'manufacturer.php?id_manufacturer=$1 [QSA,L]';
     $tab['RewriteRule']['content']['^content/([0-9]+)\\-([a-zA-Z0-9-]*)'] = 'cms.php?id_cms=$1 [QSA,L]';
     $tab['RewriteRule']['content']['^content/category/([0-9]+)\\-([a-zA-Z0-9-]*)'] = 'cms.php?id_cms_category=$1 [QSA,L]';
     // Compatibility with the old URLs
     if (!Configuration::get('PS_INSTALL_VERSION') or version_compare(Configuration::get('PS_INSTALL_VERSION'), '1.4.0.7') == -1) {
         // This is a nasty copy/paste of the previous links, but with "lang-en" instead of "en"
         // Do not update it when you add something in the one at the top, it's only for the old links
         $tab['RewriteRule']['content']['^lang-([a-z]{2})/([a-zA-Z0-9-]*)/([0-9]+)\\-([a-zA-Z0-9-]*)\\.html'] = 'product.php?id_product=$3&isolang=$1 [QSA,L]';
         $tab['RewriteRule']['content']['^lang-([a-z]{2})/([0-9]+)\\-([a-zA-Z0-9-]*)\\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';
         $tab['RewriteRule']['content']['^lang-([a-z]{2})/([0-9]+)\\-([a-zA-Z0-9-]*)'] = 'category.php?id_category=$2&isolang=$1 [QSA,L]';
         $tab['RewriteRule']['content']['^content/([0-9]+)\\-([a-zA-Z0-9-]*)'] = 'cms.php?id_cms=$1 [QSA,L]';
         $tab['RewriteRule']['content']['^content/category/([0-9]+)\\-([a-zA-Z0-9-]*)'] = 'cms.php?id_cms_category=$1 [QSA,L]';
     }
     Language::loadLanguages();
     $default_meta = Meta::getMetasByIdLang((int) Configuration::get('PS_LANG_DEFAULT'));
     if ($multilang) {
         foreach (Language::getLanguages() as $language) {
             foreach (Meta::getMetasByIdLang($language['id_lang']) as $key => $meta) {
                 if (!empty($meta['url_rewrite']) and Validate::isLinkRewrite($meta['url_rewrite'])) {
                     $tab['RewriteRule']['content']['^' . $language['iso_code'] . '/' . $meta['url_rewrite'] . '$'] = $meta['page'] . '.php?isolang=' . $language['iso_code'] . ' [QSA,L]';
                 } elseif (array_key_exists($key, $default_meta) && $default_meta[$key]['url_rewrite'] != '') {
                     $tab['RewriteRule']['content']['^' . $language['iso_code'] . '/' . $default_meta[$key]['url_rewrite'] . '$'] = $default_meta[$key]['page'] . '.php?isolang=' . $language['iso_code'] . ' [QSA,L]';
                 }
             }
             $tab['RewriteRule']['content']['^' . $language['iso_code'] . '$'] = $language['iso_code'] . '/ [QSA,L]';
             $tab['RewriteRule']['content']['^' . $language['iso_code'] . '/([^?&]*)$'] = '$1?isolang=' . $language['iso_code'] . ' [QSA,L]';
         }
     } else {
         foreach ($default_meta as $key => $meta) {
             if (!empty($meta['url_rewrite'])) {
                 $tab['RewriteRule']['content']['^' . $meta['url_rewrite'] . '$'] = $meta['page'] . '.php [QSA,L]';
             } elseif (array_key_exists($key, $default_meta) && $default_meta[$key]['url_rewrite'] != '') {
                 $tab['RewriteRule']['content']['^' . $default_meta[$key]['url_rewrite'] . '$'] = $default_meta[$key]['page'] . '.php [QSA,L]';
             }
         }
     }
     if (!($writeFd = @fopen($path, 'w'))) {
         return false;
     }
     // PS Comments
     fwrite($writeFd, "# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution\n");
     fwrite($writeFd, "# WARNING: PLEASE DO NOT MODIFY THIS FILE MANUALLY. IF NECESSARY, ADD YOUR SPECIFIC CONFIGURATION WITH THE HTACCESS GENERATOR IN BACK OFFICE\n");
     fwrite($writeFd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n\n");
     if (!empty($specific)) {
         fwrite($writeFd, $specific);
     }
     // RewriteEngine
     fwrite($writeFd, "\n<IfModule mod_rewrite.c>\n");
     if ($disableMuliviews) {
         fwrite($writeFd, "\n# Disable Multiviews\nOptions -Multiviews\n\n");
     }
     fwrite($writeFd, $tab['RewriteEngine']['comment'] . "\nRewriteEngine on\n\n");
     fwrite($writeFd, $tab['RewriteRule']['comment'] . "\n");
     // Webservice
//.........这里部分代码省略.........
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:101,代码来源:Tools14.php

示例8: postProcess

 public function postProcess()
 {
     /* PrestaShop demo mode */
     if (_PS_MODE_DEMO_ && Tools::isSubmit('submitOptionsmeta') && (Tools::getValue('domain') != Configuration::get('PS_SHOP_DOMAIN') || Tools::getValue('domain_ssl') != Configuration::get('PS_SHOP_DOMAIN_SSL'))) {
         $this->errors[] = Tools::displayError('This functionality has been disabled.');
         return;
     }
     if (Tools::isSubmit('submitAddmeta')) {
         $default_language = Configuration::get('PS_LANG_DEFAULT');
         if (Tools::getValue('page') != 'index') {
             $defaultLangIsValidated = Validate::isLinkRewrite(Tools::getValue('url_rewrite_' . $default_language));
             $englishLangIsValidated = Validate::isLinkRewrite(Tools::getValue('url_rewrite_1'));
         } else {
             // index.php can have empty rewrite rule
             $defaultLangIsValidated = !Tools::getValue('url_rewrite_' . $default_language) || Validate::isLinkRewrite(Tools::getValue('url_rewrite_' . $default_language));
             $englishLangIsValidated = !Tools::getValue('url_rewrite_1') || Validate::isLinkRewrite(Tools::getValue('url_rewrite_1'));
         }
         if (!$defaultLangIsValidated && !$englishLangIsValidated) {
             $this->errors[] = Tools::displayError('The URL rewrite field must be filled in either the default or English language.');
             return false;
         }
         foreach (Language::getIDs(false) as $id_lang) {
             $current = Tools::getValue('url_rewrite_' . $id_lang);
             if (strlen($current) == 0) {
                 // Prioritize default language first
                 if ($defaultLangIsValidated) {
                     $_POST['url_rewrite_' . $id_lang] = Tools::getValue('url_rewrite_' . $default_language);
                 } else {
                     $_POST['url_rewrite_' . $id_lang] = Tools::getValue('url_rewrite_1');
                 }
             }
         }
         Hook::exec('actionAdminMetaSave');
     } elseif (Tools::isSubmit('submitRobots')) {
         $this->generateRobotsFile();
     }
     if (Tools::isSubmit('PS_ROUTE_product_rule')) {
         Tools::clearCache($this->context->smarty);
     }
     if (Tools::isSubmit('deletemeta') && (int) Tools::getValue('id_meta') > 0) {
         Db::getInstance()->delete('theme_meta', 'id_meta=' . (int) Tools::getValue('id_meta'));
     }
     $ret = parent::postProcess();
     if (Tools::isSubmit('submitAddmeta') && Validate::isLoadedObject($ret)) {
         /** @var Theme $ret */
         $themes = Theme::getThemes();
         $theme_meta_value = array();
         foreach ($themes as $theme) {
             /** @var Theme $theme */
             $theme_meta_value[] = array('id_theme' => (int) $theme->id, 'id_meta' => (int) $ret->id, 'left_column' => (int) $theme->default_left_column, 'right_column' => (int) $theme->default_right_column);
         }
         if (count($theme_meta_value) > 0) {
             Db::getInstance()->insert('theme_meta', $theme_meta_value, false, true, DB::INSERT_IGNORE);
         }
     }
     return $ret;
 }
开发者ID:nmardones,项目名称:PrestaShop,代码行数:57,代码来源:AdminMetaController.php

示例9: productImportOne


//.........这里部分代码省略.........
                                $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
                            }
                        }
                    }
                } elseif (!$validateOnly && is_string($value) && !empty($value)) {
                    $category = Category::searchByPath($default_language_id, trim($value), $this, 'productImportCreateCat');
                    if ($category['id_category']) {
                        $product->id_category[] = (int) $category['id_category'];
                    } else {
                        $this->errors[] = sprintf($this->trans('%1$s cannot be saved', array(), 'Admin.Parameters.Notification'), trim($value));
                    }
                }
            }
            $product->id_category = array_values(array_unique($product->id_category));
            // Will update default category if category column is not ignored AND if there is categories that are set in the import file row.
            if (isset($product->id_category[0])) {
                $product->id_category_default = (int) $product->id_category[0];
            } else {
                $defaultProductShop = new Shop($product->id_shop_default);
                $product->id_category_default = Category::getRootCategory(null, Validate::isLoadedObject($defaultProductShop) ? $defaultProductShop : null)->id;
            }
        }
        // Will update default category if there is none set here. Home if no category at all.
        if (!isset($product->id_category_default) || !$product->id_category_default) {
            // this if will avoid ereasing default category if category column is not present in the CSV file (or ignored)
            if (isset($product->id_category[0])) {
                $product->id_category_default = (int) $product->id_category[0];
            } else {
                $defaultProductShop = new Shop($product->id_shop_default);
                $product->id_category_default = Category::getRootCategory(null, Validate::isLoadedObject($defaultProductShop) ? $defaultProductShop : null)->id;
            }
        }
        $link_rewrite = is_array($product->link_rewrite) && isset($product->link_rewrite[$id_lang]) ? trim($product->link_rewrite[$id_lang]) : '';
        $valid_link = Validate::isLinkRewrite($link_rewrite);
        if (isset($product->link_rewrite[$id_lang]) && empty($product->link_rewrite[$id_lang]) || !$valid_link) {
            $link_rewrite = Tools::link_rewrite($product->name[$id_lang]);
            if ($link_rewrite == '') {
                $link_rewrite = 'friendly-url-autogeneration-failed';
            }
        }
        if (!$valid_link) {
            $this->informations[] = sprintf($this->trans('Rewrite link for %1$s (ID %2$s): re-written as %3$s.', array(), 'Admin.Parameters.Notification'), $product->name[$id_lang], isset($info['id']) && !empty($info['id']) ? $info['id'] : 'null', $link_rewrite);
        }
        if (!$valid_link || !($match_ref || $force_ids) || !(is_array($product->link_rewrite) && count($product->link_rewrite) && !empty($product->link_rewrite[$id_lang]))) {
            $product->link_rewrite = AdminImportController::createMultiLangField($link_rewrite);
        }
        // replace the value of separator by coma
        if ($this->multiple_value_separator != ',') {
            if (is_array($product->meta_keywords)) {
                foreach ($product->meta_keywords as &$meta_keyword) {
                    if (!empty($meta_keyword)) {
                        $meta_keyword = str_replace($this->multiple_value_separator, ',', $meta_keyword);
                    }
                }
            }
        }
        // Convert comma into dot for all floating values
        foreach (Product::$definition['fields'] as $key => $array) {
            if ($array['type'] == Product::TYPE_FLOAT) {
                $product->{$key} = str_replace(',', '.', $product->{$key});
            }
        }
        // Indexation is already 0 if it's a new product, but not if it's an update
        $product->indexed = 0;
        $productExistsInDatabase = false;
        if ($product->id && Product::existsInDatabase((int) $product->id, 'product')) {
开发者ID:M03G,项目名称:PrestaShop,代码行数:67,代码来源:AdminImportController.php

示例10: modifierWsLinkRewrite

 public function modifierWsLinkRewrite()
 {
     foreach ($this->name as $id_lang => $name) {
         if (empty($this->link_rewrite[$id_lang])) {
             $this->link_rewrite[$id_lang] = Tools::link_rewrite($name);
         } elseif (!Validate::isLinkRewrite($this->link_rewrite[$id_lang])) {
             $this->link_rewrite[$id_lang] = Tools::link_rewrite($this->link_rewrite[$id_lang]);
         }
     }
     return true;
 }
开发者ID:yewed,项目名称:share,代码行数:11,代码来源:Product.php

示例11: mb_strimwidth

 $product->auteur = $prd['author'];
 $product->date_de_parution = $prd['date_de_parution'];
 $product->dimension = $prd['dimension'];
 $product->editeur = $prd['editeur'];
 $product->page = $prd['page'];
 $product->weight = $prd['weight'] ? $prd['weight'] : 0;
 $product->name[$id_lang] = $prd['name'];
 $product->description[$id_lang] = $prd['description'];
 $product->description_short[$id_lang] = mb_strimwidth($prd['mini-desc'], 0, 796, "...");
 $product->id_shop_default = (int) Configuration::get('PS_SHOP_DEFAULT');
 //price
 $product->price = $prd['price'] ? $prd['price'] : 0;
 //Category
 //Qte
 $link_rewrite = is_array($product->link_rewrite) && isset($product->link_rewrite[$id_lang]) ? trim($product->link_rewrite[$id_lang]) : '';
 $valid_link = Validate::isLinkRewrite($link_rewrite);
 if (isset($product->link_rewrite[$id_lang]) && empty($product->link_rewrite[$id_lang]) || !$valid_link) {
     $link_rewrite = Tools::link_rewrite($product->name[$id_lang]);
     if ($link_rewrite == '') {
         $link_rewrite = 'friendly-url-autogeneration-failed';
     }
 }
 if (!(is_array($product->link_rewrite) && count($product->link_rewrite) && !empty($product->link_rewrite[$id_lang]))) {
     $res = array();
     foreach (Language::getIDs(false) as $id_lang) {
         $res[$id_lang] = $link_rewrite;
     }
     $product->link_rewrite = $res;
 }
 if ($product->save()) {
     $id_image = array();
开发者ID:abdoumej,项目名称:libsamy,代码行数:31,代码来源:import.php

示例12: productImport


//.........这里部分代码省略.........
                         $categoryToCreate->name = self::createMultiLangField($value);
                         $categoryToCreate->active = 1;
                         $categoryToCreate->id_parent = 1;
                         // Default parent is home for unknown category to create
                         if (($fieldError = $categoryToCreate->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $categoryToCreate->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $categoryToCreate->add()) {
                             $product->id_category[] = intval($categoryToCreate->id);
                         } else {
                             $this->_errors[] = $categoryToCreate->name[$defaultLanguageId] . (isset($categoryToCreate->id) ? ' (' . $categoryToCreate->id . ')' : '') . ' ' . Tools::displayError('cannot be saved');
                             $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
                         }
                     }
                 } elseif (is_string($value) and !empty($value)) {
                     $category = Category::searchByName($defaultLanguageId, $value, true);
                     if ($category['id_category']) {
                         $product->id_category[] = intval($category['id_category']);
                     } else {
                         $categoryToCreate = new Category();
                         $categoryToCreate->name = self::createMultiLangField($value);
                         $categoryToCreate->active = 1;
                         $categoryToCreate->id_parent = 1;
                         // Default parent is home for unknown category to create
                         if (($fieldError = $categoryToCreate->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $categoryToCreate->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $categoryToCreate->add()) {
                             $product->id_category[] = intval($categoryToCreate->id);
                         } else {
                             $this->_errors[] = $categoryToCreate->name[$defaultLanguageId] . (isset($categoryToCreate->id) ? ' (' . $categoryToCreate->id . ')' : '') . ' ' . Tools::displayError('cannot be saved');
                             $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
                         }
                     }
                 }
             }
         }
         $product->id_category_default = isset($product->id_category[0]) ? intval($product->id_category[0]) : '';
         $link_rewrite = is_array($product->link_rewrite) ? $product->link_rewrite[$defaultLanguageId] : '';
         $valid_link = Validate::isLinkRewrite($link_rewrite);
         $bak = $product->link_rewrite;
         if (isset($product->link_rewrite[$defaultLanguageId]) and empty($product->link_rewrite[$defaultLanguageId]) or !$valid_link) {
             $link_rewrite = Tools::link_rewrite($product->name[$defaultLanguageId]);
         }
         if (!$valid_link) {
             $this->_warnings[] = Tools::displayError('Rewrited link for') . ' ' . $bak . (isset($info['id']) ? ' (ID ' . $info['id'] . ') ' : '') . ' ' . Tools::displayError('was re-written as') . ' ' . $link_rewrite;
         }
         $product->link_rewrite = self::createMultiLangField($link_rewrite);
         $res = false;
         $fieldError = $product->validateFields(UNFRIENDLY_ERROR, true);
         $langFieldError = $product->validateFieldsLang(UNFRIENDLY_ERROR, true);
         if ($fieldError === true and $langFieldError === true) {
             // check quantity
             if ($product->quantity == NULL) {
                 $product->quantity = 0;
             }
             // If id product AND id product already in base, trying to update
             if ($product->id and Product::existsInDatabase(intval($product->id))) {
                 $datas = Db::getInstance()->getRow('SELECT `date_add` FROM `' . _DB_PREFIX_ . 'product` WHERE `id_product` = ' . intval($product->id));
                 $product->date_add = pSQL($datas['date_add']);
                 $res = $product->update();
             }
             // If no id_product or update failed
             if (!$res) {
                 $res = $product->add();
             }
         }
         // If both failed, mysql error
         if (!$res) {
             $this->_errors[] = $info['name'] . (isset($info['id']) ? ' (ID ' . $info['id'] . ')' : '') . ' ' . Tools::displayError('cannot be saved');
             $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
         } else {
开发者ID:Bruno-2M,项目名称:prestashop,代码行数:67,代码来源:AdminImport.php

示例13: productImport


//.........这里部分代码省略.........
                            }
                        }
                    } else {
                        if (is_string($value) && !empty($value)) {
                            $category = Category::searchByName($default_language_id, trim($value), true);
                            if ($category['id_category']) {
                                $product->id_category[] = (int) $category['id_category'];
                            } else {
                                $category_to_create = new Category();
                                if (!Shop::isFeatureActive()) {
                                    $category_to_create->id_shop_default = 1;
                                } else {
                                    $category_to_create->id_shop_default = (int) Context::getContext()->shop->id;
                                }
                                $category_to_create->name = AdminImportController::createMultiLangField(trim($value));
                                $category_to_create->active = 1;
                                $category_to_create->id_parent = (int) Configuration::get('PS_HOME_CATEGORY');
                                // Default parent is home for unknown category to create
                                $category_link_rewrite = Tools::link_rewrite($category_to_create->name[$default_language_id]);
                                $category_to_create->link_rewrite = AdminImportController::createMultiLangField($category_link_rewrite);
                                if (($field_error = $category_to_create->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $category_to_create->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $category_to_create->add()) {
                                    $product->id_category[] = (int) $category_to_create->id;
                                } else {
                                    $this->errors[] = sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $category_to_create->name[$default_language_id], isset($category_to_create->id) ? $category_to_create->id : 'null');
                                    $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
                                }
                            }
                        }
                    }
                }
            }
            $product->id_category_default = isset($product->id_category[0]) ? (int) $product->id_category[0] : '';
            $link_rewrite = is_array($product->link_rewrite) && count($product->link_rewrite) ? trim($product->link_rewrite[$default_language_id]) : '';
            $valid_link = Validate::isLinkRewrite($link_rewrite);
            if (isset($product->link_rewrite[$default_language_id]) && empty($product->link_rewrite[$default_language_id]) || !$valid_link) {
                $link_rewrite = Tools::link_rewrite($product->name[$default_language_id]);
                if ($link_rewrite == '') {
                    $link_rewrite = 'friendly-url-autogeneration-failed';
                }
            }
            if (!$valid_link) {
                $this->warnings[] = sprintf(Tools::displayError('Rewrite link for %1$s (ID: %2$s) was re-written as %3$s.'), $product->name[$default_language_id], isset($info['id']) ? $info['id'] : 'null', $link_rewrite);
            }
            $product->link_rewrite = AdminImportController::createMultiLangField($link_rewrite);
            // replace the value of separator by coma
            if ($this->multiple_value_separator != ',') {
                foreach ($product->meta_keywords as &$meta_keyword) {
                    if (!empty($meta_keyword)) {
                        $meta_keyword = str_replace($this->multiple_value_separator, ',', $meta_keyword);
                    }
                }
            }
            // Convert comma into dot for all floating values
            foreach (Product::$definition['fields'] as $key => $array) {
                if ($array['type'] == Product::TYPE_FLOAT) {
                    $product->{$key} = str_replace(',', '.', $product->{$key});
                }
            }
            // Indexation is already 0 if it's a new product, but not if it's an update
            $product->indexed = 0;
            $res = false;
            $field_error = $product->validateFields(UNFRIENDLY_ERROR, true);
            $lang_field_error = $product->validateFieldsLang(UNFRIENDLY_ERROR, true);
            if ($field_error === true && $lang_field_error === true) {
                // check quantity
                if ($product->quantity == null) {
开发者ID:FAVHYAN,项目名称:a3workout,代码行数:67,代码来源:AdminImportController.php

示例14: getPictureLink

 public static function getPictureLink($link_rewrite, $productId, $productcombId, $idImage = false, $allPictures = 0)
 {
     $legend = null;
     if ($idImage) {
         //echo '+'.$productId.' - '.$productcombId.' - '.$idImage.'<br>';
         if ($allPictures && $productId == $productcombId) {
             //echo $productId.' - '.$idImage.'<br>';
             $links = array();
             //print_r(self::$_existingPictures[$productId]);
             foreach (self::$_existingPictures[$productId] as $key => $value) {
                 $pictureName = $productId . '-' . self::$_existingPictures[$productId][$key]['id_image'];
                 $legend = self::$_existingPictures[$productId][$key]['legend'];
                 if (!Validate::isLinkRewrite($legend)) {
                     $legend = strtolower(Tools::link_rewrite($legend));
                 }
                 $links[] = strtolower(self::getImageLink($link_rewrite, $pictureName, 'thickbox'));
             }
             return implode(',', $links);
         } else {
             $pictureName = $productId . '-' . $idImage;
             $legend = null;
             return strtolower(self::getImageLink($link_rewrite, $pictureName, 'thickbox'));
         }
     } elseif (array_key_exists($productId, self::$_existingPictures)) {
         if ($allPictures && $productId == $productcombId) {
             $links = array();
             foreach (self::$_existingPictures[$productId] as $key => $value) {
                 $pictureName = $productId . '-' . self::$_existingPictures[$productId][$key]['id_image'];
                 $legend = self::$_existingPictures[$productId][$key]['legend'];
                 if (!Validate::isLinkRewrite($legend)) {
                     $legend = strtolower(Tools::link_rewrite($legend));
                 }
                 $links[] = strtolower(self::getImageLink($link_rewrite, $pictureName, 'thickbox'));
             }
             return implode(',', $links);
         } else {
             $pictureName = $productId . '-' . self::$_existingPictures[$productId][0]['id_image'];
             $legend = self::$_existingPictures[$productId][0]['legend'];
             if (!Validate::isLinkRewrite($legend)) {
                 $legend = strtolower(Tools::link_rewrite($legend));
             }
             return strtolower(self::getImageLink($link_rewrite, $pictureName, 'thickbox'));
         }
     }
     return '';
 }
开发者ID:pedalracer,项目名称:free_modules_1.5,代码行数:46,代码来源:Export.php

示例15: postProcess

 public function postProcess()
 {
     /* PrestaShop demo mode */
     if (_PS_MODE_DEMO_ && Tools::isSubmit('submitOptionsmeta') && (Tools::getValue('domain') != Configuration::get('PS_SHOP_DOMAIN') || Tools::getValue('domain_ssl') != Configuration::get('PS_SHOP_DOMAIN_SSL'))) {
         $this->errors[] = $this->trans('This functionality has been disabled.', array(), 'Admin.Notifications.Error');
         return;
     }
     if (Tools::isSubmit('submitAddmeta')) {
         $default_language = Configuration::get('PS_LANG_DEFAULT');
         if (Tools::getValue('page') != 'index') {
             $defaultLangIsValidated = Validate::isLinkRewrite(Tools::getValue('url_rewrite_' . $default_language));
             $englishLangIsValidated = Validate::isLinkRewrite(Tools::getValue('url_rewrite_1'));
         } else {
             // index.php can have empty rewrite rule
             $defaultLangIsValidated = !Tools::getValue('url_rewrite_' . $default_language) || Validate::isLinkRewrite(Tools::getValue('url_rewrite_' . $default_language));
             $englishLangIsValidated = !Tools::getValue('url_rewrite_1') || Validate::isLinkRewrite(Tools::getValue('url_rewrite_1'));
         }
         if (!$defaultLangIsValidated && !$englishLangIsValidated) {
             $this->errors[] = $this->trans('The URL rewrite field must be filled in either the default or English language.', array(), 'Admin.Notifications.Error');
             return false;
         }
         foreach (Language::getIDs(false) as $id_lang) {
             $current = Tools::getValue('url_rewrite_' . $id_lang);
             if (strlen($current) == 0) {
                 // Prioritize default language first
                 if ($defaultLangIsValidated) {
                     $_POST['url_rewrite_' . $id_lang] = Tools::getValue('url_rewrite_' . $default_language);
                 } else {
                     $_POST['url_rewrite_' . $id_lang] = Tools::getValue('url_rewrite_1');
                 }
             }
         }
         Hook::exec('actionAdminMetaSave');
     } elseif (Tools::isSubmit('submitRobots')) {
         $this->generateRobotsFile();
     }
     if (Tools::isSubmit('PS_ROUTE_product_rule')) {
         Tools::clearCache($this->context->smarty);
     }
     return parent::postProcess();
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:41,代码来源:AdminMetaController.php


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