Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into development
This commit is contained in:
commit
36e3956267
28 files changed
+466
-352
No files matched your search
+34
-17
@@ -101,7 +101,7 @@ class LinkCore
|
|||||||
if (!is_object($product))
|
if (!is_object($product))
|
||||||
{
|
{
|
||||||
if (is_array($product) && isset($product['id_product']))
|
if (is_array($product) && isset($product['id_product']))
|
||||||
$product = new Product($product['id_product'], false, $id_lang);
|
$product = new Product($product['id_product'], false, $id_lang);
|
||||||
else if (is_numeric($product) || !$product)
|
else if (is_numeric($product) || !$product)
|
||||||
$product = new Product($product, false, $id_lang);
|
$product = new Product($product, false, $id_lang);
|
||||||
else
|
else
|
||||||
@@ -195,24 +195,28 @@ class LinkCore
|
|||||||
* @param int $id_lang
|
* @param int $id_lang
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCMSCategoryLink($category, $alias = null, $id_lang = null)
|
public function getCMSCategoryLink($cms_category, $alias = null, $id_lang = null)
|
||||||
{
|
{
|
||||||
if (!$id_lang)
|
if (!$id_lang)
|
||||||
$id_lang = Context::getContext()->language->id;
|
$id_lang = Context::getContext()->language->id;
|
||||||
|
|
||||||
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
|
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
|
||||||
|
|
||||||
if (!is_object($category))
|
$dispatcher = Dispatcher::getInstance();
|
||||||
$category = new CMSCategory($category, $id_lang);
|
if (!is_object($cms_category))
|
||||||
|
{
|
||||||
|
if ($alias !== null && !$dispatcher->hasKeyword('cms_category_rule', $id_lang, 'meta_keywords') && !$dispatcher->hasKeyword('cms_category_rule', $id_lang, 'meta_title'))
|
||||||
|
return $url.$dispatcher->createUrl('cms_category_rule', $id_lang, array('id' => (int)$cms_category, 'rewrite' => (string)$alias), $this->allow);
|
||||||
|
$cms_category = new CMSCategory($cms_category, $id_lang);
|
||||||
|
}
|
||||||
|
|
||||||
// Set available keywords
|
// Set available keywords
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['id'] = $category->id;
|
$params['id'] = $cms_category->id;
|
||||||
$params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias;
|
$params['rewrite'] = (!$alias) ? $cms_category->link_rewrite : $alias;
|
||||||
$params['meta_keywords'] = Tools::str2url($category->meta_keywords);
|
$params['meta_keywords'] = Tools::str2url($cms_category->meta_keywords);
|
||||||
$params['meta_title'] = Tools::str2url($category->meta_title);
|
$params['meta_title'] = Tools::str2url($cms_category->meta_title);
|
||||||
|
|
||||||
return $url.Dispatcher::getInstance()->createUrl('cms_category_rule', $id_lang, $params, $this->allow);
|
return $url.$dispatcher->createUrl('cms_category_rule', $id_lang, $params, $this->allow);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -232,25 +236,28 @@ class LinkCore
|
|||||||
$id_lang = Context::getContext()->language->id;
|
$id_lang = Context::getContext()->language->id;
|
||||||
$url = $base.__PS_BASE_URI__.$this->getLangLink($id_lang);
|
$url = $base.__PS_BASE_URI__.$this->getLangLink($id_lang);
|
||||||
|
|
||||||
|
$dispatcher = Dispatcher::getInstance();
|
||||||
if (!is_object($cms))
|
if (!is_object($cms))
|
||||||
|
{
|
||||||
|
if ($alias !== null && !$dispatcher->hasKeyword('cms_rule', $id_lang, 'meta_keywords') && !$dispatcher->hasKeyword('cms_rule', $id_lang, 'meta_title'))
|
||||||
|
return $url.$dispatcher->createUrl('cms_rule', $id_lang, array('id' => (int)$cms, 'rewrite' => (string)$alias), $this->allow);
|
||||||
$cms = new CMS($cms, $id_lang);
|
$cms = new CMS($cms, $id_lang);
|
||||||
|
}
|
||||||
|
|
||||||
// Set available keywords
|
// Set available keywords
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['id'] = $cms->id;
|
$params['id'] = $cms->id;
|
||||||
$params['rewrite'] = (!$alias) ? (is_array($cms->link_rewrite) ? $cms->link_rewrite[(int)$id_lang] : $cms->link_rewrite) : $alias;
|
$params['rewrite'] = (!$alias) ? (is_array($cms->link_rewrite) ? $cms->link_rewrite[(int)$id_lang] : $cms->link_rewrite) : $alias;
|
||||||
|
|
||||||
|
$params['meta_keywords'] = '';
|
||||||
if (isset($cms->meta_keywords) && !empty($cms->meta_keywords))
|
if (isset($cms->meta_keywords) && !empty($cms->meta_keywords))
|
||||||
$params['meta_keywords'] = is_array($cms->meta_keywords) ? Tools::str2url($cms->meta_keywords[(int)$id_lang]) : Tools::str2url($cms->meta_keywords);
|
$params['meta_keywords'] = is_array($cms->meta_keywords) ? Tools::str2url($cms->meta_keywords[(int)$id_lang]) : Tools::str2url($cms->meta_keywords);
|
||||||
else
|
|
||||||
$params['meta_keywords'] = '';
|
|
||||||
|
|
||||||
|
$params['meta_title'] = '';
|
||||||
if (isset($cms->meta_title) && !empty($cms->meta_title))
|
if (isset($cms->meta_title) && !empty($cms->meta_title))
|
||||||
$params['meta_title'] = is_array($cms->meta_title) ? Tools::str2url($cms->meta_title[(int)$id_lang]) : Tools::str2url($cms->meta_title);
|
$params['meta_title'] = is_array($cms->meta_title) ? Tools::str2url($cms->meta_title[(int)$id_lang]) : Tools::str2url($cms->meta_title);
|
||||||
else
|
|
||||||
$params['meta_title'] = '';
|
|
||||||
|
|
||||||
return $url.Dispatcher::getInstance()->createUrl('cms_rule', $id_lang, $params, $this->allow);
|
return $url.$dispatcher->createUrl('cms_rule', $id_lang, $params, $this->allow);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -267,8 +274,13 @@ class LinkCore
|
|||||||
$id_lang = Context::getContext()->language->id;
|
$id_lang = Context::getContext()->language->id;
|
||||||
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
|
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
|
||||||
|
|
||||||
|
$dispatcher = Dispatcher::getInstance();
|
||||||
if (!is_object($supplier))
|
if (!is_object($supplier))
|
||||||
|
{
|
||||||
|
if ($alias !== null && !$dispatcher->hasKeyword('supplier_rule', $id_lang, 'meta_keywords') && !$dispatcher->hasKeyword('supplier_rule', $id_lang, 'meta_title'))
|
||||||
|
return $url.$dispatcher->createUrl('supplier_rule', $id_lang, array('id' => (int)$supplier, 'rewrite' => (string)$alias), $this->allow);
|
||||||
$supplier = new Supplier($supplier, $id_lang);
|
$supplier = new Supplier($supplier, $id_lang);
|
||||||
|
}
|
||||||
|
|
||||||
// Set available keywords
|
// Set available keywords
|
||||||
$params = array();
|
$params = array();
|
||||||
@@ -277,7 +289,7 @@ class LinkCore
|
|||||||
$params['meta_keywords'] = Tools::str2url($supplier->meta_keywords);
|
$params['meta_keywords'] = Tools::str2url($supplier->meta_keywords);
|
||||||
$params['meta_title'] = Tools::str2url($supplier->meta_title);
|
$params['meta_title'] = Tools::str2url($supplier->meta_title);
|
||||||
|
|
||||||
return $url.Dispatcher::getInstance()->createUrl('supplier_rule', $id_lang, $params, $this->allow);
|
return $url.$dispatcher->createUrl('supplier_rule', $id_lang, $params, $this->allow);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -294,8 +306,13 @@ class LinkCore
|
|||||||
$id_lang = Context::getContext()->language->id;
|
$id_lang = Context::getContext()->language->id;
|
||||||
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
|
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
|
||||||
|
|
||||||
|
$dispatcher = Dispatcher::getInstance();
|
||||||
if (!is_object($manufacturer))
|
if (!is_object($manufacturer))
|
||||||
|
{
|
||||||
|
if ($alias !== null && !$dispatcher->hasKeyword('manufacturer_rule', $id_lang, 'meta_keywords') && !$dispatcher->hasKeyword('manufacturer_rule', $id_lang, 'meta_title'))
|
||||||
|
return $url.$dispatcher->createUrl('manufacturer_rule', $id_lang, array('id' => (int)$manufacturer, 'rewrite' => (string)$alias), $this->allow);
|
||||||
$manufacturer = new Manufacturer($manufacturer, $id_lang);
|
$manufacturer = new Manufacturer($manufacturer, $id_lang);
|
||||||
|
}
|
||||||
|
|
||||||
// Set available keywords
|
// Set available keywords
|
||||||
$params = array();
|
$params = array();
|
||||||
@@ -304,7 +321,7 @@ class LinkCore
|
|||||||
$params['meta_keywords'] = Tools::str2url($manufacturer->meta_keywords);
|
$params['meta_keywords'] = Tools::str2url($manufacturer->meta_keywords);
|
||||||
$params['meta_title'] = Tools::str2url($manufacturer->meta_title);
|
$params['meta_title'] = Tools::str2url($manufacturer->meta_title);
|
||||||
|
|
||||||
return $url.Dispatcher::getInstance()->createUrl('manufacturer_rule', $id_lang, $params, $this->allow);
|
return $url.$dispatcher->createUrl('manufacturer_rule', $id_lang, $params, $this->allow);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -208,9 +208,10 @@ class ProductSupplierCore extends ObjectModel
|
|||||||
*
|
*
|
||||||
* @param int $id_product
|
* @param int $id_product
|
||||||
* @param int $id_product_attribute Optional
|
* @param int $id_product_attribute Optional
|
||||||
|
* @param bool $converted_price Optional
|
||||||
* @return Array keys: price_te, id_currency
|
* @return Array keys: price_te, id_currency
|
||||||
*/
|
*/
|
||||||
public static function getProductPrice($id_supplier, $id_product, $id_product_attribute = 0)
|
public static function getProductPrice($id_supplier, $id_product, $id_product_attribute = 0, $converted_price = false)
|
||||||
{
|
{
|
||||||
if (is_null($id_supplier) || is_null($id_product))
|
if (is_null($id_supplier) || is_null($id_product))
|
||||||
return;
|
return;
|
||||||
@@ -222,6 +223,9 @@ class ProductSupplierCore extends ObjectModel
|
|||||||
$query->where('id_supplier = '.(int)$id_supplier);
|
$query->where('id_supplier = '.(int)$id_supplier);
|
||||||
|
|
||||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
|
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
|
||||||
|
if ($converted_price)
|
||||||
|
return Tools::convertPrice($row['price_te'], $row['id_currency']);
|
||||||
|
|
||||||
return $row['price_te'];
|
return $row['price_te'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+17
-1
@@ -53,6 +53,21 @@ class DbMySQLiCore extends Db
|
|||||||
return $this->link;
|
return $this->link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function createDatabase($host, $user, $password, $dbname, $dropit = false)
|
||||||
|
{
|
||||||
|
if (strpos($host, ':') !== false)
|
||||||
|
{
|
||||||
|
list($host, $port) = explode(':', $host);
|
||||||
|
$link = @new mysqli($host, $this->user, $this->password, null, $port);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$link = @new mysqli($host, $user, $password);
|
||||||
|
$success = $link->query('CREATE DATABASE `'.bqSQL($dbname).'`');
|
||||||
|
if ($dropit && ($link->exec('DROP DATABASE `'.bqSQL($dbname).'`') !== false))
|
||||||
|
return true;
|
||||||
|
return $success;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see DbCore::disconnect()
|
* @see DbCore::disconnect()
|
||||||
*/
|
*/
|
||||||
@@ -169,7 +184,8 @@ class DbMySQLiCore extends Db
|
|||||||
if (!$link->options(MYSQLI_OPT_CONNECT_TIMEOUT, $timeout))
|
if (!$link->options(MYSQLI_OPT_CONNECT_TIMEOUT, $timeout))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!$link->real_connect($server, $user, $pwd, $db))
|
// There is an @ because mysqli throw a warning when the database does not exists
|
||||||
|
if (!@$link->real_connect($server, $user, $pwd, $db))
|
||||||
return (mysqli_connect_errno() == 1049) ? 2 : 1;
|
return (mysqli_connect_errno() == 1049) ? 2 : 1;
|
||||||
|
|
||||||
$link->close();
|
$link->close();
|
||||||
|
|||||||
@@ -46,6 +46,19 @@ class DbPDOCore extends Db
|
|||||||
return new PDO($dsn, $user, $password, array(PDO::ATTR_TIMEOUT => $timeout, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true));
|
return new PDO($dsn, $user, $password, array(PDO::ATTR_TIMEOUT => $timeout, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function createDatabase($host, $user, $password, $dbname, $dropit = false)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$link = DbPDO::_getPDO($host, $user, $password, false);
|
||||||
|
$success = $link->exec('CREATE DATABASE `'.bqSQL($dbname).'`');
|
||||||
|
if ($dropit && ($link->exec('DROP DATABASE `'.bqSQL($dbname).'`') !== false))
|
||||||
|
return true;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $success;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see DbCore::connect()
|
* @see DbCore::connect()
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -47,6 +47,15 @@ class MySQLCore extends Db
|
|||||||
return $this->link;
|
return $this->link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function createDatabase($host, $user, $password, $dbname, $dropit = false)
|
||||||
|
{
|
||||||
|
$link = mysql_connect($host, $user, $password);
|
||||||
|
$success = mysql_query('CREATE DATABASE `'.bqSQL($dbname).'`', $link);
|
||||||
|
if ($dropit && ($link->exec('DROP DATABASE `'.bqSQL($dbname).'`') !== false))
|
||||||
|
return true;
|
||||||
|
return $success;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see DbCore::disconnect()
|
* @see DbCore::disconnect()
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -508,7 +508,7 @@ class OrderDetailCore extends ObjectModel
|
|||||||
|
|
||||||
$this->purchase_supplier_price = (float)$product['wholesale_price'];
|
$this->purchase_supplier_price = (float)$product['wholesale_price'];
|
||||||
if ($product['id_supplier'] > 0)
|
if ($product['id_supplier'] > 0)
|
||||||
$this->purchase_supplier_price = (float)ProductSupplier::getProductPrice((int)$product['id_supplier'], $product['id_product'], $product['id_product_attribute']);
|
$this->purchase_supplier_price = (float)ProductSupplier::getProductPrice((int)$product['id_supplier'], $product['id_product'], $product['id_product_attribute'], true);
|
||||||
|
|
||||||
$this->setSpecificPrice($order, $product);
|
$this->setSpecificPrice($order, $product);
|
||||||
|
|
||||||
|
|||||||
@@ -376,7 +376,7 @@ class WebserviceOutputBuilderCore
|
|||||||
{
|
{
|
||||||
if ($key !== 'empty')
|
if ($key !== 'empty')
|
||||||
{
|
{
|
||||||
if ($this->fieldsToDisplay === 'minimum')
|
if ($this->fieldsToDisplay === 'minimum')
|
||||||
$output .= $this->renderEntityMinimum($object, $depth);
|
$output .= $this->renderEntityMinimum($object, $depth);
|
||||||
else
|
else
|
||||||
$output .= $this->renderEntity($object, $depth);
|
$output .= $this->renderEntity($object, $depth);
|
||||||
|
|||||||
@@ -530,9 +530,10 @@ class WebserviceRequestCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->returnOutput();
|
$return = $this->returnOutput();
|
||||||
unset($webservice_call);
|
unset($webservice_call);
|
||||||
unset ($display_errors);
|
unset($display_errors);
|
||||||
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function webserviceChecks()
|
protected function webserviceChecks()
|
||||||
@@ -1158,6 +1159,7 @@ class WebserviceRequestCore
|
|||||||
$sorts = array($this->urlFragments['sort']);
|
$sorts = array($this->urlFragments['sort']);
|
||||||
|
|
||||||
$sql_sort .= ' ORDER BY ';
|
$sql_sort .= ' ORDER BY ';
|
||||||
|
|
||||||
foreach ($sorts as $sort)
|
foreach ($sorts as $sort)
|
||||||
{
|
{
|
||||||
$delimiterPosition = strrpos($sort, '_');
|
$delimiterPosition = strrpos($sort, '_');
|
||||||
@@ -1219,8 +1221,6 @@ class WebserviceRequestCore
|
|||||||
return $filters;
|
return $filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function getFilteredObjectList()
|
public function getFilteredObjectList()
|
||||||
{
|
{
|
||||||
$objects = array();
|
$objects = array();
|
||||||
@@ -1241,7 +1241,16 @@ class WebserviceRequestCore
|
|||||||
if ($sqlObjects)
|
if ($sqlObjects)
|
||||||
{
|
{
|
||||||
foreach ($sqlObjects as $sqlObject)
|
foreach ($sqlObjects as $sqlObject)
|
||||||
$objects[] = new $this->resourceConfiguration['retrieveData']['className']((int)$sqlObject[$this->resourceConfiguration['fields']['id']['sqlId']]);
|
{
|
||||||
|
if ($this->fieldsToDisplay == 'minimum')
|
||||||
|
{
|
||||||
|
$obj = new $this->resourceConfiguration['retrieveData']['className']();
|
||||||
|
$obj->id = (int)$sqlObject[$this->resourceConfiguration['fields']['id']['sqlId']];
|
||||||
|
$objects[] = $obj;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$objects[] = new $this->resourceConfiguration['retrieveData']['className']((int)$sqlObject[$this->resourceConfiguration['fields']['id']['sqlId']]);
|
||||||
|
}
|
||||||
return $objects;
|
return $objects;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2717,7 +2717,7 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
|
|
||||||
if (!$product_supplier_id)
|
if (!$product_supplier_id)
|
||||||
{
|
{
|
||||||
$product->addSupplierReference($supplier->id_supplier, (int)$attribute['id_product_attribute'], $reference, (float)Tools::convertPrice($price, $id_currency), (int)$id_currency);
|
$product->addSupplierReference($supplier->id_supplier, (int)$attribute['id_product_attribute'], $reference, (float)$price, (int)$id_currency);
|
||||||
if ($product->id_supplier == $supplier->id_supplier)
|
if ($product->id_supplier == $supplier->id_supplier)
|
||||||
{
|
{
|
||||||
if ((int)$attribute['id_product_attribute'] > 0)
|
if ((int)$attribute['id_product_attribute'] > 0)
|
||||||
@@ -2743,7 +2743,7 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
$product_supplier = new ProductSupplier($product_supplier_id);
|
$product_supplier = new ProductSupplier($product_supplier_id);
|
||||||
$product_supplier->id_currency = (int)$id_currency;
|
$product_supplier->id_currency = (int)$id_currency;
|
||||||
$product_supplier->product_supplier_price_te = (float)Tools::convertPrice($price, $id_currency); //converted in the default currency
|
$product_supplier->product_supplier_price_te = (float)$price;
|
||||||
$product_supplier->product_supplier_reference = pSQL($reference);
|
$product_supplier->product_supplier_reference = pSQL($reference);
|
||||||
$product_supplier->update();
|
$product_supplier->update();
|
||||||
|
|
||||||
|
|||||||
@@ -95,8 +95,8 @@ class InstallControllerHttpDatabase extends InstallControllerHttp
|
|||||||
{
|
{
|
||||||
if (Tools::getValue('checkDb'))
|
if (Tools::getValue('checkDb'))
|
||||||
$this->processCheckDb();
|
$this->processCheckDb();
|
||||||
else if (Tools::getValue('sendMail'))
|
elseif (Tools::getValue('createDb'))
|
||||||
$this->processSendMail();
|
$this->processCreateDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,28 +120,20 @@ class InstallControllerHttpDatabase extends InstallControllerHttp
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a test email
|
* Attempt to create the database
|
||||||
*/
|
*/
|
||||||
public function processSendMail()
|
public function processCreateDb()
|
||||||
{
|
{
|
||||||
$smtp_checked = (Tools::getValue('smtpChecked') == 'true');
|
$server = Tools::getValue('dbServer');
|
||||||
$server = Tools::getValue('smtpSrv');
|
$database = Tools::getValue('dbName');
|
||||||
$encryption = Tools::getValue('smtpEnc');
|
$login = Tools::getValue('dbLogin');
|
||||||
$port = Tools::getValue('smtpPort');
|
$password = Tools::getValue('dbPassword');
|
||||||
$login = Tools::getValue('smtpLogin');
|
|
||||||
$password = Tools::getValue('smtpPassword');
|
|
||||||
$email = Tools::getValue('testEmail');
|
|
||||||
|
|
||||||
require_once _PS_INSTALL_MODELS_PATH_.'mail.php';
|
$success = $this->model_database->createDatabase($server, $database, $login, $password);
|
||||||
$this->model_mail = new InstallModelMail($smtp_checked, $server, $login, $password, $port, $encryption, $email);
|
|
||||||
$result = $this->model_mail->send(
|
|
||||||
$this->l('Test message from PrestaShop'),
|
|
||||||
$this->l('This is a test message, your server is now available to send email')
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->ajaxJsonAnswer(
|
$this->ajaxJsonAnswer(
|
||||||
$result === false,
|
$success,
|
||||||
($result === false) ? $this->l('A test e-mail has been sent to %s', $email) : $this->l('An error occurred while sending email, please verify your parameters')
|
$success ? $this->l('Database is created') : $this->l('Cannot create the database automatically')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,11 @@ class InstallModelDatabase extends InstallAbstractModel
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
$errors[] = $this->language->l('Connection to MySQL server succeeded, but database "%s" not found', $database).$dbtype;
|
$error = $this->language->l('Connection to MySQL server succeeded, but database "%s" not found', $database).$dbtype;
|
||||||
|
if ($this->createDatabase($server, $database, $login, $password, true))
|
||||||
|
$error .= '<p>'.sprintf('<input type="button" value="%s" class="button" id="btCreateDB">', $this->language->l('Attempt to create the database automatically')).'</p>
|
||||||
|
<script type="text/javascript">bindCreateDB();</script>';
|
||||||
|
$errors[] = $error;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,6 +93,12 @@ class InstallModelDatabase extends InstallAbstractModel
|
|||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createDatabase($server, $database, $login, $password, $dropit = false)
|
||||||
|
{
|
||||||
|
$class = Db::getClass();
|
||||||
|
return $class::createDatabase($server, $login, $password, $database, $dropit);
|
||||||
|
}
|
||||||
|
|
||||||
public function getBestEngine($server, $database, $login, $password)
|
public function getBestEngine($server, $database, $login, $password)
|
||||||
{
|
{
|
||||||
$class = Db::getClass();
|
$class = Db::getClass();
|
||||||
|
|||||||
@@ -31,9 +31,46 @@ $(document).ready(function()
|
|||||||
$("#dbResultCheck")
|
$("#dbResultCheck")
|
||||||
.addClass('errorBlock')
|
.addClass('errorBlock')
|
||||||
.removeClass('okBlock')
|
.removeClass('okBlock')
|
||||||
.html('An error occurred:<br /><br />'+xhr.responseText)
|
.html('An error occurred:<br /><br />' + xhr.responseText)
|
||||||
.slideDown('slow');
|
.slideDown('slow');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function bindCreateDB()
|
||||||
|
{
|
||||||
|
// Attempt to create the database
|
||||||
|
$('#btCreateDB').click(function()
|
||||||
|
{
|
||||||
|
$("#dbResultCheck").slideUp('fast');
|
||||||
|
$.ajax({
|
||||||
|
url: 'index.php',
|
||||||
|
data: {
|
||||||
|
'createDb': 'true',
|
||||||
|
'dbServer': $('#dbServer').val(),
|
||||||
|
'dbName': $('#dbName').val(),
|
||||||
|
'dbLogin': $('#dbLogin').val(),
|
||||||
|
'dbPassword': $('#dbPassword').val()
|
||||||
|
},
|
||||||
|
dataType: 'json',
|
||||||
|
cache: false,
|
||||||
|
success: function(json)
|
||||||
|
{
|
||||||
|
$("#dbResultCheck")
|
||||||
|
.addClass((json.success) ? 'okBlock' : 'errorBlock')
|
||||||
|
.removeClass((json.success) ? 'errorBlock' : 'okBlock')
|
||||||
|
.html(json.message)
|
||||||
|
.slideDown('slow');
|
||||||
|
},
|
||||||
|
error: function(xhr)
|
||||||
|
{
|
||||||
|
$("#dbResultCheck")
|
||||||
|
.addClass('errorBlock')
|
||||||
|
.removeClass('okBlock')
|
||||||
|
.html('An error occurred:<br /><br />' + xhr.responseText)
|
||||||
|
.slideDown('slow');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -48,7 +48,7 @@ class BlockManufacturer extends Module
|
|||||||
Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT', true);
|
Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT', true);
|
||||||
Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT_NB', 5);
|
Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT_NB', 5);
|
||||||
Configuration::updateValue('MANUFACTURER_DISPLAY_FORM', true);
|
Configuration::updateValue('MANUFACTURER_DISPLAY_FORM', true);
|
||||||
return parent::install() &&
|
return parent::install() &&
|
||||||
$this->registerHook('leftColumn') &&
|
$this->registerHook('leftColumn') &&
|
||||||
$this->registerHook('header') &&
|
$this->registerHook('header') &&
|
||||||
$this->registerHook('actionObjectManufacturerDeleteAfter') &&
|
$this->registerHook('actionObjectManufacturerDeleteAfter') &&
|
||||||
|
|||||||
@@ -175,9 +175,9 @@ class PSCleaner extends Module
|
|||||||
array('delivery', 'id_carrier', 'carrier', 'id_carrier'),
|
array('delivery', 'id_carrier', 'carrier', 'id_carrier'),
|
||||||
array('delivery', 'id_zone', 'zone', 'id_zone'),
|
array('delivery', 'id_zone', 'zone', 'id_zone'),
|
||||||
array('editorial', 'id_shop', 'shop', 'id_shop', 'editorial'),
|
array('editorial', 'id_shop', 'shop', 'id_shop', 'editorial'),
|
||||||
array('favorite_product', 'id_product', 'product', 'id_product'),
|
array('favorite_product', 'id_product', 'product', 'id_product','favoriteproducts'),
|
||||||
array('favorite_product', 'id_customer', 'customer', 'id_customer'),
|
array('favorite_product', 'id_customer', 'customer', 'id_customer','favoriteproducts'),
|
||||||
array('favorite_product', 'id_shop', 'shop', 'id_shop'),
|
array('favorite_product', 'id_shop', 'shop', 'id_shop','favoriteproducts'),
|
||||||
array('feature_product', 'id_feature', 'feature', 'id_feature'),
|
array('feature_product', 'id_feature', 'feature', 'id_feature'),
|
||||||
array('feature_product', 'id_product', 'product', 'id_product'),
|
array('feature_product', 'id_product', 'product', 'id_product'),
|
||||||
array('feature_value', 'id_feature', 'feature', 'id_feature'),
|
array('feature_value', 'id_feature', 'feature', 'id_feature'),
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* Project: Smarty: the PHP compiling template engine
|
* Project: Smarty: the PHP compiling template engine
|
||||||
* File: Smarty.class.php
|
* File: Smarty.class.php
|
||||||
* SVN: $Id: Smarty.class.php 4694 2013-01-13 21:13:14Z uwe.tews@googlemail.com $
|
* SVN: $Id: Smarty.class.php 4742 2013-06-17 13:30:49Z Uwe.Tews@googlemail.com $
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
* @author Rodney Rehm
|
* @author Rodney Rehm
|
||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @version 3.1.13
|
* @version 3.1-DEV
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -113,7 +113,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = 'Smarty-3.1.13';
|
const SMARTY_VERSION = 'Smarty-3.1.14';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
@@ -128,6 +128,11 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
|||||||
const CACHING_OFF = 0;
|
const CACHING_OFF = 0;
|
||||||
const CACHING_LIFETIME_CURRENT = 1;
|
const CACHING_LIFETIME_CURRENT = 1;
|
||||||
const CACHING_LIFETIME_SAVED = 2;
|
const CACHING_LIFETIME_SAVED = 2;
|
||||||
|
/**
|
||||||
|
* define constant for clearing cache files be saved expiration datees
|
||||||
|
*/
|
||||||
|
const CLEAR_EXPIRED = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define compile check modes
|
* define compile check modes
|
||||||
*/
|
*/
|
||||||
@@ -1323,9 +1328,9 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
|||||||
* @param int $max_errors
|
* @param int $max_errors
|
||||||
* @return integer number of template files recompiled
|
* @return integer number of template files recompiled
|
||||||
*/
|
*/
|
||||||
public function compileAllTemplates($extention = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null)
|
public function compileAllTemplates($extension = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null)
|
||||||
{
|
{
|
||||||
return Smarty_Internal_Utility::compileAllTemplates($extention, $force_compile, $time_limit, $max_errors, $this);
|
return Smarty_Internal_Utility::compileAllTemplates($extension, $force_compile, $time_limit, $max_errors, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1337,9 +1342,9 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
|||||||
* @param int $max_errors
|
* @param int $max_errors
|
||||||
* @return integer number of template files recompiled
|
* @return integer number of template files recompiled
|
||||||
*/
|
*/
|
||||||
public function compileAllConfig($extention = '.conf', $force_compile = false, $time_limit = 0, $max_errors = null)
|
public function compileAllConfig($extension = '.conf', $force_compile = false, $time_limit = 0, $max_errors = null)
|
||||||
{
|
{
|
||||||
return Smarty_Internal_Utility::compileAllConfig($extention, $force_compile, $time_limit, $max_errors, $this);
|
return Smarty_Internal_Utility::compileAllConfig($extension, $force_compile, $time_limit, $max_errors, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
|||||||
$upper_string = mb_convert_case( $string, MB_CASE_TITLE, Smarty::$_CHARSET );
|
$upper_string = mb_convert_case( $string, MB_CASE_TITLE, Smarty::$_CHARSET );
|
||||||
} else {
|
} else {
|
||||||
// uppercase word breaks
|
// uppercase word breaks
|
||||||
$upper_string = preg_replace("!(^|[^\p{L}'])([\p{Ll}])!eS" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').mb_convert_case(stripslashes('\\2'),MB_CASE_UPPER, '" . addslashes(Smarty::$_CHARSET) . "')", $string);
|
$upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, create_function ('$matches', 'return stripslashes($matches[1]).mb_convert_case(stripslashes($matches[2]),MB_CASE_UPPER, "' . addslashes(Smarty::$_CHARSET) . '");'), $string);
|
||||||
}
|
}
|
||||||
// check uc_digits case
|
// check uc_digits case
|
||||||
if (!$uc_digits) {
|
if (!$uc_digits) {
|
||||||
@@ -40,7 +40,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$upper_string = preg_replace("!((^|\s)['\"])(\w)!e" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').mb_convert_case(stripslashes('\\3'),MB_CASE_UPPER, '" . addslashes(Smarty::$_CHARSET) . "')", $upper_string);
|
$upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, create_function ('$matches', 'return stripslashes($matches[1]).mb_convert_case(stripslashes($matches[3]),MB_CASE_UPPER, "' . addslashes(Smarty::$_CHARSET) . '");'), $upper_string);
|
||||||
return $upper_string;
|
return $upper_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
|||||||
$string = strtolower($string);
|
$string = strtolower($string);
|
||||||
}
|
}
|
||||||
// uppercase (including hyphenated words)
|
// uppercase (including hyphenated words)
|
||||||
$upper_string = preg_replace("!(^|[^\p{L}'])([\p{Ll}])!eS" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').ucfirst(stripslashes('\\2'))", $string);
|
$upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, create_function ('$matches', 'return stripslashes($matches[1]).ucfirst(stripslashes($matches[2]));'), $string);
|
||||||
// check uc_digits case
|
// check uc_digits case
|
||||||
if (!$uc_digits) {
|
if (!$uc_digits) {
|
||||||
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) {
|
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) {
|
||||||
@@ -58,7 +58,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$upper_string = preg_replace("!((^|\s)['\"])(\w)!e" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').strtoupper(stripslashes('\\3'))", $upper_string);
|
$upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, create_function ('$matches', 'return stripslashes($matches[1]).ucfirst(stripslashes($matches[3]));'), $upper_string);
|
||||||
return $upper_string;
|
return $upper_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,12 +21,7 @@
|
|||||||
* @param boolean $double_encode encode already encoded entitites again, used for htmlspecialchars() or htmlentities()
|
* @param boolean $double_encode encode already encoded entitites again, used for htmlspecialchars() or htmlentities()
|
||||||
* @return string escaped input string
|
* @return string escaped input string
|
||||||
*/
|
*/
|
||||||
/* PrestaShop
|
|
||||||
change double_encode to false by default
|
|
||||||
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
|
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
|
||||||
*/
|
|
||||||
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = false)
|
|
||||||
/* END */
|
|
||||||
{
|
{
|
||||||
static $_double_encode = null;
|
static $_double_encode = null;
|
||||||
if ($_double_encode === null) {
|
if ($_double_encode === null) {
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ function smarty_modifiercompiler_escape($params, $compiler)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// could not optimize |escape call, so fallback to regular plugin
|
// could not optimize |escape call, so fallback to regular plugin
|
||||||
if ($compiler->tag_nocache | $compiler->nocache) {
|
if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) {
|
||||||
$compiler->template->required_plugins['nocache']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR .'modifier.escape.php';
|
$compiler->template->required_plugins['nocache']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR .'modifier.escape.php';
|
||||||
$compiler->template->required_plugins['nocache']['escape']['modifier']['function'] = 'smarty_modifier_escape';
|
$compiler->template->required_plugins['nocache']['escape']['modifier']['function'] = 'smarty_modifier_escape';
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -20,14 +20,9 @@
|
|||||||
*/
|
*/
|
||||||
function smarty_modifiercompiler_strip_tags($params, $compiler)
|
function smarty_modifiercompiler_strip_tags($params, $compiler)
|
||||||
{
|
{
|
||||||
if (!isset($params[1])) {
|
if (!isset($params[1]) || $params[1] === true || trim($params[1],'"') == 'true') {
|
||||||
$params[1] = true;
|
return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})";
|
||||||
}
|
|
||||||
if ($params[1] === true) {
|
|
||||||
return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})";
|
|
||||||
} else {
|
} else {
|
||||||
return 'strip_tags(' . $params[0] . ')';
|
return 'strip_tags(' . $params[0] . ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -31,7 +31,7 @@ function smarty_modifiercompiler_wordwrap($params, $compiler)
|
|||||||
}
|
}
|
||||||
$function = 'wordwrap';
|
$function = 'wordwrap';
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
if ($compiler->tag_nocache | $compiler->nocache) {
|
if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) {
|
||||||
$compiler->template->required_plugins['nocache']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR .'shared.mb_wordwrap.php';
|
$compiler->template->required_plugins['nocache']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR .'shared.mb_wordwrap.php';
|
||||||
$compiler->template->required_plugins['nocache']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
|
$compiler->template->required_plugins['nocache']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ class Smarty_Template_Cached {
|
|||||||
public $timestamp = false;
|
public $timestamp = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Source Existance
|
* Source Existence
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
public $exists = false;
|
public $exists = false;
|
||||||
|
|||||||
@@ -1,271 +1,275 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin CacheResource File
|
* Smarty Internal Plugin CacheResource File
|
||||||
*
|
*
|
||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage Cacher
|
* @subpackage Cacher
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
* @author Rodney Rehm
|
* @author Rodney Rehm
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* This class does contain all necessary methods for the HTML cache on file system
|
|
||||||
*
|
|
||||||
* Implements the file system as resource for the HTML cache Version ussing nocache inserts.
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage Cacher
|
|
||||||
*/
|
|
||||||
class Smarty_Internal_CacheResource_File extends Smarty_CacheResource {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* populate Cached Object with meta data from Resource
|
* This class does contain all necessary methods for the HTML cache on file system
|
||||||
*
|
*
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
* Implements the file system as resource for the HTML cache Version ussing nocache inserts.
|
||||||
* @param Smarty_Internal_Template $_template template object
|
*
|
||||||
* @return void
|
* @package Smarty
|
||||||
*/
|
* @subpackage Cacher
|
||||||
public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template)
|
*/
|
||||||
{
|
class Smarty_Internal_CacheResource_File extends Smarty_CacheResource {
|
||||||
$_source_file_path = str_replace(':', '.', $_template->source->filepath);
|
|
||||||
$_cache_id = isset($_template->cache_id) ? preg_replace('![^\w\|]+!', '_', $_template->cache_id) : null;
|
/**
|
||||||
$_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!', '_', $_template->compile_id) : null;
|
* populate Cached Object with meta data from Resource
|
||||||
$_filepath = $_template->source->uid;
|
*
|
||||||
// if use_sub_dirs, break file into directories
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
if ($_template->smarty->use_sub_dirs) {
|
* @param Smarty_Internal_Template $_template template object
|
||||||
$_filepath = substr($_filepath, 0, 2) . DS
|
* @return void
|
||||||
|
*/
|
||||||
|
public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template)
|
||||||
|
{
|
||||||
|
$_source_file_path = str_replace(':', '.', $_template->source->filepath);
|
||||||
|
$_cache_id = isset($_template->cache_id) ? preg_replace('![^\w\|]+!', '_', $_template->cache_id) : null;
|
||||||
|
$_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!', '_', $_template->compile_id) : null;
|
||||||
|
$_filepath = $_template->source->uid;
|
||||||
|
// if use_sub_dirs, break file into directories
|
||||||
|
if ($_template->smarty->use_sub_dirs) {
|
||||||
|
$_filepath = substr($_filepath, 0, 2) . DS
|
||||||
. substr($_filepath, 2, 2) . DS
|
. substr($_filepath, 2, 2) . DS
|
||||||
. substr($_filepath, 4, 2) . DS
|
. substr($_filepath, 4, 2) . DS
|
||||||
. $_filepath;
|
. $_filepath;
|
||||||
}
|
}
|
||||||
$_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS : '^';
|
$_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS : '^';
|
||||||
if (isset($_cache_id)) {
|
if (isset($_cache_id)) {
|
||||||
$_cache_id = str_replace('|', $_compile_dir_sep, $_cache_id) . $_compile_dir_sep;
|
$_cache_id = str_replace('|', $_compile_dir_sep, $_cache_id) . $_compile_dir_sep;
|
||||||
} else {
|
|
||||||
$_cache_id = '';
|
|
||||||
}
|
|
||||||
if (isset($_compile_id)) {
|
|
||||||
$_compile_id = $_compile_id . $_compile_dir_sep;
|
|
||||||
} else {
|
|
||||||
$_compile_id = '';
|
|
||||||
}
|
|
||||||
$_cache_dir = $_template->smarty->getCacheDir();
|
|
||||||
if ($_template->smarty->cache_locking) {
|
|
||||||
// create locking file name
|
|
||||||
// relative file name?
|
|
||||||
if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_cache_dir)) {
|
|
||||||
$_lock_dir = rtrim(getcwd(), '/\\') . DS . $_cache_dir;
|
|
||||||
} else {
|
} else {
|
||||||
$_lock_dir = $_cache_dir;
|
$_cache_id = '';
|
||||||
}
|
}
|
||||||
$cached->lock_id = $_lock_dir.sha1($_cache_id.$_compile_id.$_template->source->uid).'.lock';
|
if (isset($_compile_id)) {
|
||||||
}
|
$_compile_id = $_compile_id . $_compile_dir_sep;
|
||||||
$cached->filepath = $_cache_dir . $_cache_id . $_compile_id . $_filepath . '.' . basename($_source_file_path) . '.php';
|
|
||||||
$cached->timestamp = @filemtime($cached->filepath);
|
|
||||||
$cached->exists = !!$cached->timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* populate Cached Object with timestamp and exists from Resource
|
|
||||||
*
|
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function populateTimestamp(Smarty_Template_Cached $cached)
|
|
||||||
{
|
|
||||||
$cached->timestamp = @filemtime($cached->filepath);
|
|
||||||
$cached->exists = !!$cached->timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read the cached template and process its header
|
|
||||||
*
|
|
||||||
* @param Smarty_Internal_Template $_template template object
|
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
|
||||||
* @return booelan true or false if the cached content does not exist
|
|
||||||
*/
|
|
||||||
public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached=null)
|
|
||||||
{
|
|
||||||
$_smarty_tpl = $_template;
|
|
||||||
return @include $_template->cached->filepath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write the rendered template output to cache
|
|
||||||
*
|
|
||||||
* @param Smarty_Internal_Template $_template template object
|
|
||||||
* @param string $content content to cache
|
|
||||||
* @return boolean success
|
|
||||||
*/
|
|
||||||
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
|
||||||
{
|
|
||||||
if (Smarty_Internal_Write_File::writeFile($_template->cached->filepath, $content, $_template->smarty) === true) {
|
|
||||||
$_template->cached->timestamp = @filemtime($_template->cached->filepath);
|
|
||||||
$_template->cached->exists = !!$_template->cached->timestamp;
|
|
||||||
if ($_template->cached->exists) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Empty cache
|
|
||||||
*
|
|
||||||
* @param Smarty_Internal_Template $_template template object
|
|
||||||
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
|
||||||
* @return integer number of cache files deleted
|
|
||||||
*/
|
|
||||||
public function clearAll(Smarty $smarty, $exp_time = null)
|
|
||||||
{
|
|
||||||
return $this->clear($smarty, null, null, null, $exp_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Empty cache for a specific template
|
|
||||||
*
|
|
||||||
* @param Smarty $_template template object
|
|
||||||
* @param string $resource_name template name
|
|
||||||
* @param string $cache_id cache id
|
|
||||||
* @param string $compile_id compile id
|
|
||||||
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
|
||||||
* @return integer number of cache files deleted
|
|
||||||
*/
|
|
||||||
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
|
|
||||||
{
|
|
||||||
$_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null;
|
|
||||||
$_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null;
|
|
||||||
$_dir_sep = $smarty->use_sub_dirs ? '/' : '^';
|
|
||||||
$_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0;
|
|
||||||
$_dir = $smarty->getCacheDir();
|
|
||||||
$_dir_length = strlen($_dir);
|
|
||||||
if (isset($_cache_id)) {
|
|
||||||
$_cache_id_parts = explode('|', $_cache_id);
|
|
||||||
$_cache_id_parts_count = count($_cache_id_parts);
|
|
||||||
if ($smarty->use_sub_dirs) {
|
|
||||||
foreach ($_cache_id_parts as $id_part) {
|
|
||||||
$_dir .= $id_part . DS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isset($resource_name)) {
|
|
||||||
$_save_stat = $smarty->caching;
|
|
||||||
$smarty->caching = true;
|
|
||||||
$tpl = new $smarty->template_class($resource_name, $smarty);
|
|
||||||
$smarty->caching = $_save_stat;
|
|
||||||
|
|
||||||
// remove from template cache
|
|
||||||
$tpl->source; // have the template registered before unset()
|
|
||||||
if ($smarty->allow_ambiguous_resources) {
|
|
||||||
$_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
|
|
||||||
} else {
|
} else {
|
||||||
$_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
|
$_compile_id = '';
|
||||||
}
|
}
|
||||||
if (isset($_templateId[150])) {
|
$_cache_dir = $_template->smarty->getCacheDir();
|
||||||
$_templateId = sha1($_templateId);
|
if ($_template->smarty->cache_locking) {
|
||||||
}
|
// create locking file name
|
||||||
unset($smarty->template_objects[$_templateId]);
|
// relative file name?
|
||||||
|
if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_cache_dir)) {
|
||||||
if ($tpl->source->exists) {
|
$_lock_dir = rtrim(getcwd(), '/\\') . DS . $_cache_dir;
|
||||||
$_resourcename_parts = basename(str_replace('^', '/', $tpl->cached->filepath));
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$_count = 0;
|
|
||||||
$_time = time();
|
|
||||||
if (file_exists($_dir)) {
|
|
||||||
$_cacheDirs = new RecursiveDirectoryIterator($_dir);
|
|
||||||
$_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
|
|
||||||
foreach ($_cache as $_file) {
|
|
||||||
|
|
||||||
/* PrestaShop - Do not delete index.php and .svn files */
|
|
||||||
if (preg_match('/^(\.|\.\.|\.svn|index\.php)$/', $_file->getFilename()))
|
|
||||||
continue;
|
|
||||||
/* End */
|
|
||||||
|
|
||||||
// directory ?
|
|
||||||
if ($_file->isDir()) {
|
|
||||||
if (!$_cache->isDot()) {
|
|
||||||
// delete folder if empty
|
|
||||||
@rmdir($_file->getPathname());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$_parts = explode($_dir_sep, str_replace('\\', '/', substr((string)$_file, $_dir_length)));
|
$_lock_dir = $_cache_dir;
|
||||||
$_parts_count = count($_parts);
|
}
|
||||||
// check name
|
$cached->lock_id = $_lock_dir.sha1($_cache_id.$_compile_id.$_template->source->uid).'.lock';
|
||||||
if (isset($resource_name)) {
|
}
|
||||||
if ($_parts[$_parts_count-1] != $_resourcename_parts) {
|
$cached->filepath = $_cache_dir . $_cache_id . $_compile_id . $_filepath . '.' . basename($_source_file_path) . '.php';
|
||||||
continue;
|
$cached->timestamp = @filemtime($cached->filepath);
|
||||||
}
|
$cached->exists = !!$cached->timestamp;
|
||||||
}
|
}
|
||||||
// check compile id
|
|
||||||
if (isset($_compile_id) && (!isset($_parts[$_parts_count-2 - $_compile_id_offset]) || $_parts[$_parts_count-2 - $_compile_id_offset] != $_compile_id)) {
|
/**
|
||||||
continue;
|
* populate Cached Object with timestamp and exists from Resource
|
||||||
}
|
*
|
||||||
// check cache id
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
if (isset($_cache_id)) {
|
* @return void
|
||||||
// count of cache id parts
|
*/
|
||||||
$_parts_count = (isset($_compile_id)) ? $_parts_count - 2 - $_compile_id_offset : $_parts_count - 1 - $_compile_id_offset;
|
public function populateTimestamp(Smarty_Template_Cached $cached)
|
||||||
if ($_parts_count < $_cache_id_parts_count) {
|
{
|
||||||
continue;
|
$cached->timestamp = @filemtime($cached->filepath);
|
||||||
}
|
$cached->exists = !!$cached->timestamp;
|
||||||
for ($i = 0; $i < $_cache_id_parts_count; $i++) {
|
}
|
||||||
if ($_parts[$i] != $_cache_id_parts[$i]) continue 2;
|
|
||||||
}
|
/**
|
||||||
}
|
* Read the cached template and process its header
|
||||||
// expired ?
|
*
|
||||||
if (isset($exp_time) && $_time - @filemtime($_file) < $exp_time) {
|
* @param Smarty_Internal_Template $_template template object
|
||||||
continue;
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
}
|
* @return booelan true or false if the cached content does not exist
|
||||||
$_count += @unlink((string) $_file) ? 1 : 0;
|
*/
|
||||||
|
public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached=null)
|
||||||
|
{
|
||||||
|
$_smarty_tpl = $_template;
|
||||||
|
return @include $_template->cached->filepath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write the rendered template output to cache
|
||||||
|
*
|
||||||
|
* @param Smarty_Internal_Template $_template template object
|
||||||
|
* @param string $content content to cache
|
||||||
|
* @return boolean success
|
||||||
|
*/
|
||||||
|
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
||||||
|
{
|
||||||
|
if (Smarty_Internal_Write_File::writeFile($_template->cached->filepath, $content, $_template->smarty) === true) {
|
||||||
|
$_template->cached->timestamp = @filemtime($_template->cached->filepath);
|
||||||
|
$_template->cached->exists = !!$_template->cached->timestamp;
|
||||||
|
if ($_template->cached->exists) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return $_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check is cache is locked for this template
|
* Empty cache
|
||||||
*
|
*
|
||||||
* @param Smarty $smarty Smarty object
|
* @param Smarty_Internal_Template $_template template object
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
||||||
* @return booelan true or false if cache is locked
|
* @return integer number of cache files deleted
|
||||||
*/
|
*/
|
||||||
public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
public function clearAll(Smarty $smarty, $exp_time = null)
|
||||||
{
|
{
|
||||||
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
return $this->clear($smarty, null, null, null, $exp_time);
|
||||||
clearstatcache(true, $cached->lock_id);
|
|
||||||
} else {
|
|
||||||
clearstatcache();
|
|
||||||
}
|
}
|
||||||
$t = @filemtime($cached->lock_id);
|
|
||||||
return $t && (time() - $t < $smarty->locking_timeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lock cache for this template
|
* Empty cache for a specific template
|
||||||
*
|
*
|
||||||
* @param Smarty $smarty Smarty object
|
* @param Smarty $_template template object
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
* @param string $resource_name template name
|
||||||
*/
|
* @param string $cache_id cache id
|
||||||
public function acquireLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
* @param string $compile_id compile id
|
||||||
{
|
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
||||||
$cached->is_locked = true;
|
* @return integer number of cache files deleted
|
||||||
touch($cached->lock_id);
|
*/
|
||||||
}
|
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
|
||||||
|
{
|
||||||
|
$_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null;
|
||||||
|
$_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null;
|
||||||
|
$_dir_sep = $smarty->use_sub_dirs ? '/' : '^';
|
||||||
|
$_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0;
|
||||||
|
$_dir = $smarty->getCacheDir();
|
||||||
|
$_dir_length = strlen($_dir);
|
||||||
|
if (isset($_cache_id)) {
|
||||||
|
$_cache_id_parts = explode('|', $_cache_id);
|
||||||
|
$_cache_id_parts_count = count($_cache_id_parts);
|
||||||
|
if ($smarty->use_sub_dirs) {
|
||||||
|
foreach ($_cache_id_parts as $id_part) {
|
||||||
|
$_dir .= $id_part . DS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isset($resource_name)) {
|
||||||
|
$_save_stat = $smarty->caching;
|
||||||
|
$smarty->caching = true;
|
||||||
|
$tpl = new $smarty->template_class($resource_name, $smarty);
|
||||||
|
$smarty->caching = $_save_stat;
|
||||||
|
|
||||||
/**
|
// remove from template cache
|
||||||
* Unlock cache for this template
|
$tpl->source; // have the template registered before unset()
|
||||||
*
|
if ($smarty->allow_ambiguous_resources) {
|
||||||
* @param Smarty $smarty Smarty object
|
$_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
} else {
|
||||||
*/
|
$_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
|
||||||
public function releaseLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
}
|
||||||
{
|
if (isset($_templateId[150])) {
|
||||||
$cached->is_locked = false;
|
$_templateId = sha1($_templateId);
|
||||||
@unlink($cached->lock_id);
|
}
|
||||||
|
unset($smarty->template_objects[$_templateId]);
|
||||||
|
|
||||||
|
if ($tpl->source->exists) {
|
||||||
|
$_resourcename_parts = basename(str_replace('^', '/', $tpl->cached->filepath));
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$_count = 0;
|
||||||
|
$_time = time();
|
||||||
|
if (file_exists($_dir)) {
|
||||||
|
$_cacheDirs = new RecursiveDirectoryIterator($_dir);
|
||||||
|
$_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
|
||||||
|
foreach ($_cache as $_file) {
|
||||||
|
if (substr(basename($_file->getPathname()),0,1) == '.' || strpos($_file, '.svn') !== false) continue;
|
||||||
|
// directory ?
|
||||||
|
if ($_file->isDir()) {
|
||||||
|
if (!$_cache->isDot()) {
|
||||||
|
// delete folder if empty
|
||||||
|
@rmdir($_file->getPathname());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$_parts = explode($_dir_sep, str_replace('\\', '/', substr((string)$_file, $_dir_length)));
|
||||||
|
$_parts_count = count($_parts);
|
||||||
|
// check name
|
||||||
|
if (isset($resource_name)) {
|
||||||
|
if ($_parts[$_parts_count-1] != $_resourcename_parts) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check compile id
|
||||||
|
if (isset($_compile_id) && (!isset($_parts[$_parts_count-2 - $_compile_id_offset]) || $_parts[$_parts_count-2 - $_compile_id_offset] != $_compile_id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// check cache id
|
||||||
|
if (isset($_cache_id)) {
|
||||||
|
// count of cache id parts
|
||||||
|
$_parts_count = (isset($_compile_id)) ? $_parts_count - 2 - $_compile_id_offset : $_parts_count - 1 - $_compile_id_offset;
|
||||||
|
if ($_parts_count < $_cache_id_parts_count) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for ($i = 0; $i < $_cache_id_parts_count; $i++) {
|
||||||
|
if ($_parts[$i] != $_cache_id_parts[$i]) continue 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// expired ?
|
||||||
|
if (isset($exp_time)) {
|
||||||
|
if ($exp_time < 0) {
|
||||||
|
preg_match('#\'cache_lifetime\' =>\s*(\d*)#', file_get_contents($_file), $match);
|
||||||
|
if ($_time < (@filemtime($_file) + $match[1])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($_time - @filemtime($_file) < $exp_time) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$_count += @unlink((string) $_file) ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check is cache is locked for this template
|
||||||
|
*
|
||||||
|
* @param Smarty $smarty Smarty object
|
||||||
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
|
* @return booelan true or false if cache is locked
|
||||||
|
*/
|
||||||
|
public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||||
|
{
|
||||||
|
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
||||||
|
clearstatcache(true, $cached->lock_id);
|
||||||
|
} else {
|
||||||
|
clearstatcache();
|
||||||
|
}
|
||||||
|
$t = @filemtime($cached->lock_id);
|
||||||
|
return $t && (time() - $t < $smarty->locking_timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lock cache for this template
|
||||||
|
*
|
||||||
|
* @param Smarty $smarty Smarty object
|
||||||
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
|
*/
|
||||||
|
public function acquireLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||||
|
{
|
||||||
|
$cached->is_locked = true;
|
||||||
|
touch($cached->lock_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unlock cache for this template
|
||||||
|
*
|
||||||
|
* @param Smarty $smarty Smarty object
|
||||||
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
|
*/
|
||||||
|
public function releaseLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||||
|
{
|
||||||
|
$cached->is_locked = false;
|
||||||
|
@unlink($cached->lock_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -84,7 +84,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
|||||||
$al = '';
|
$al = '';
|
||||||
}
|
}
|
||||||
if (0 == preg_match("!({$_ldl}{$al}block\s+)(name=)?(\w+|'.*'|\".*\")(\s*?)?((append|prepend|nocache)?(\s*)?(hide)?)?(\s*{$_rdl})!", $block_tag, $_match)) {
|
if (0 == preg_match("!({$_ldl}{$al}block\s+)(name=)?(\w+|'.*'|\".*\")(\s*?)?((append|prepend|nocache)?(\s*)?(hide)?)?(\s*{$_rdl})!", $block_tag, $_match)) {
|
||||||
$error_text = 'Syntax Error in template "' . $template->source->filepath . '" "' . htmlspecialchars($block_tag) . '" illegal options';
|
$error_text = 'Syntax Error in template "' . $template->source->filepath . '" "' . $block_tag . '" illegal options';
|
||||||
throw new SmartyCompilerException($error_text);
|
throw new SmartyCompilerException($error_text);
|
||||||
} else {
|
} else {
|
||||||
$_name = trim($_match[3], '\'"');
|
$_name = trim($_match[3], '\'"');
|
||||||
@@ -179,7 +179,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
$_tpl = new Smarty_Internal_template('string:' . $compiler->template->block_data[$_name]['source'], $compiler->smarty, $compiler->template, $compiler->template->cache_id,
|
$_tpl = new Smarty_Internal_template('string:' . $compiler->template->block_data[$_name]['source'], $compiler->smarty, $compiler->template, $compiler->template->cache_id,
|
||||||
$compiler->template->compile_id = null, $compiler->template->caching, $compiler->template->cache_lifetime);
|
$compiler->template->compile_id, $compiler->template->caching, $compiler->template->cache_lifetime);
|
||||||
$_tpl->variable_filters = $compiler->template->variable_filters;
|
$_tpl->variable_filters = $compiler->template->variable_filters;
|
||||||
$_tpl->properties['nocache_hash'] = $compiler->template->properties['nocache_hash'];
|
$_tpl->properties['nocache_hash'] = $compiler->template->properties['nocache_hash'];
|
||||||
$_tpl->source->filepath = $compiler->template->block_data[$_name]['file'];
|
$_tpl->source->filepath = $compiler->template->block_data[$_name]['file'];
|
||||||
@@ -190,6 +190,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
|||||||
$_tpl->compiler->forceNocache = 1;
|
$_tpl->compiler->forceNocache = 1;
|
||||||
}
|
}
|
||||||
$_tpl->compiler->suppressHeader = true;
|
$_tpl->compiler->suppressHeader = true;
|
||||||
|
$_tpl->compiler->suppressFilter = true;
|
||||||
$_tpl->compiler->suppressTemplatePropertyHeader = true;
|
$_tpl->compiler->suppressTemplatePropertyHeader = true;
|
||||||
$_tpl->compiler->suppressMergedTemplates = true;
|
$_tpl->compiler->suppressMergedTemplates = true;
|
||||||
if (strpos($compiler->template->block_data[$_name]['source'], '%%%%SMARTY_PARENT%%%%') !== false) {
|
if (strpos($compiler->template->block_data[$_name]['source'], '%%%%SMARTY_PARENT%%%%') !== false) {
|
||||||
|
|||||||
@@ -467,10 +467,15 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($cache) {
|
if ($cache) {
|
||||||
|
// CACHING_LIFETIME_SAVED cache expiry has to be validated here since otherwise we'd define the unifunc
|
||||||
|
if ($this->caching === Smarty::CACHING_LIFETIME_SAVED &&
|
||||||
|
$this->properties['cache_lifetime'] >= 0 &&
|
||||||
|
(time() > ($this->cached->timestamp + $this->properties['cache_lifetime']))) {
|
||||||
|
$is_valid = false;
|
||||||
|
}
|
||||||
$this->cached->valid = $is_valid;
|
$this->cached->valid = $is_valid;
|
||||||
} else {
|
} else {
|
||||||
$this->mustCompile = !$is_valid;
|
$this->mustCompile = !$is_valid; }
|
||||||
}
|
|
||||||
// store data in reusable Smarty_Template_Compiled
|
// store data in reusable Smarty_Template_Compiled
|
||||||
if (!$cache) {
|
if (!$cache) {
|
||||||
$this->compiled->_properties = $properties;
|
$this->compiled->_properties = $properties;
|
||||||
|
|||||||
@@ -106,6 +106,12 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
|||||||
*/
|
*/
|
||||||
public $suppressTemplatePropertyHeader = false;
|
public $suppressTemplatePropertyHeader = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* suppress pre and post filter
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $suppressFilter = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flag if compiled template file shall we written
|
* flag if compiled template file shall we written
|
||||||
* @var bool
|
* @var bool
|
||||||
@@ -184,7 +190,7 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
|||||||
// get template source
|
// get template source
|
||||||
$_content = $template->source->content;
|
$_content = $template->source->content;
|
||||||
// run prefilter if required
|
// run prefilter if required
|
||||||
if (isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])) {
|
if ((isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])) && !$this->suppressFilter) {
|
||||||
$_content = Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $template);
|
$_content = Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $template);
|
||||||
}
|
}
|
||||||
// on empty template just return header
|
// on empty template just return header
|
||||||
@@ -209,13 +215,9 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
|||||||
foreach ($this->merged_templates as $code) {
|
foreach ($this->merged_templates as $code) {
|
||||||
$merged_code .= $code;
|
$merged_code .= $code;
|
||||||
}
|
}
|
||||||
// run postfilter if required on merged code
|
|
||||||
if (isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) {
|
|
||||||
$merged_code = Smarty_Internal_Filter_Handler::runFilter('post', $merged_code, $template);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// run postfilter if required on compiled template code
|
// run postfilter if required on compiled template code
|
||||||
if (isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) {
|
if ((isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) && !$this->suppressFilter) {
|
||||||
$_compiled_code = Smarty_Internal_Filter_Handler::runFilter('post', $_compiled_code, $template);
|
$_compiled_code = Smarty_Internal_Filter_Handler::runFilter('post', $_compiled_code, $template);
|
||||||
}
|
}
|
||||||
if ($this->suppressTemplatePropertyHeader) {
|
if ($this->suppressTemplatePropertyHeader) {
|
||||||
@@ -331,7 +333,7 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
|||||||
}
|
}
|
||||||
// check plugins from plugins folder
|
// check plugins from plugins folder
|
||||||
foreach ($this->smarty->plugin_search_order as $plugin_type) {
|
foreach ($this->smarty->plugin_search_order as $plugin_type) {
|
||||||
if ($plugin_type == Smarty::PLUGIN_BLOCK && $this->smarty->loadPlugin('smarty_compiler_' . $tag) && (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this))) {
|
if ($plugin_type == Smarty::PLUGIN_COMPILER && $this->smarty->loadPlugin('smarty_compiler_' . $tag) && (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this))) {
|
||||||
$plugin = 'smarty_compiler_' . $tag;
|
$plugin = 'smarty_compiler_' . $tag;
|
||||||
if (is_callable($plugin)) {
|
if (is_callable($plugin)) {
|
||||||
// convert arguments format for old compiler plugins
|
// convert arguments format for old compiler plugins
|
||||||
@@ -605,7 +607,7 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
|||||||
$_output = addcslashes($content,'\'\\');
|
$_output = addcslashes($content,'\'\\');
|
||||||
$_output = str_replace("^#^", "'", $_output);
|
$_output = str_replace("^#^", "'", $_output);
|
||||||
$_output = "<?php echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/" . $_output . "/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n";
|
$_output = "<?php echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/" . $_output . "/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n";
|
||||||
// make sure we include modifer plugins for nocache code
|
// make sure we include modifier plugins for nocache code
|
||||||
foreach ($this->modifier_plugins as $plugin_name => $dummy) {
|
foreach ($this->modifier_plugins as $plugin_name => $dummy) {
|
||||||
if (isset($this->template->required_plugins['compiled'][$plugin_name]['modifier'])) {
|
if (isset($this->template->required_plugins['compiled'][$plugin_name]['modifier'])) {
|
||||||
$this->template->required_plugins['nocache'][$plugin_name]['modifier'] = $this->template->required_plugins['compiled'][$plugin_name]['modifier'];
|
$this->template->required_plugins['nocache'][$plugin_name]['modifier'] = $this->template->required_plugins['compiled'][$plugin_name]['modifier'];
|
||||||
@@ -641,7 +643,7 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
|||||||
$line = $this->lex->line;
|
$line = $this->lex->line;
|
||||||
}
|
}
|
||||||
$match = preg_split("/\n/", $this->lex->data);
|
$match = preg_split("/\n/", $this->lex->data);
|
||||||
$error_text = 'Syntax Error in template "' . $this->template->source->filepath . '" on line ' . $line . ' "' . htmlspecialchars(trim(preg_replace('![\t\r\n]+!', ' ', $match[$line - 1]))) . '" ';
|
$error_text = 'Syntax Error in template "' . $this->template->source->filepath . '" on line ' . $line . ' "' . trim(preg_replace('![\t\r\n]+!', ' ', $match[$line - 1])) . '" ';
|
||||||
if (isset($args)) {
|
if (isset($args)) {
|
||||||
// individual error message
|
// individual error message
|
||||||
$error_text .= $args;
|
$error_text .= $args;
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class Smarty_Internal_Utility {
|
|||||||
* @param Smarty $smarty Smarty instance
|
* @param Smarty $smarty Smarty instance
|
||||||
* @return integer number of template files compiled
|
* @return integer number of template files compiled
|
||||||
*/
|
*/
|
||||||
public static function compileAllTemplates($extention, $force_compile, $time_limit, $max_errors, Smarty $smarty)
|
public static function compileAllTemplates($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty)
|
||||||
{
|
{
|
||||||
// switch off time limit
|
// switch off time limit
|
||||||
if (function_exists('set_time_limit')) {
|
if (function_exists('set_time_limit')) {
|
||||||
@@ -74,7 +74,7 @@ class Smarty_Internal_Utility {
|
|||||||
foreach ($_compile as $_fileinfo) {
|
foreach ($_compile as $_fileinfo) {
|
||||||
$_file = $_fileinfo->getFilename();
|
$_file = $_fileinfo->getFilename();
|
||||||
if (substr(basename($_fileinfo->getPathname()),0,1) == '.' || strpos($_file, '.svn') !== false) continue;
|
if (substr(basename($_fileinfo->getPathname()),0,1) == '.' || strpos($_file, '.svn') !== false) continue;
|
||||||
if (!substr_compare($_file, $extention, - strlen($extention)) == 0) continue;
|
if (!substr_compare($_file, $extension, - strlen($extension)) == 0) continue;
|
||||||
if ($_fileinfo->getPath() == substr($_dir, 0, -1)) {
|
if ($_fileinfo->getPath() == substr($_dir, 0, -1)) {
|
||||||
$_template_file = $_file;
|
$_template_file = $_file;
|
||||||
} else {
|
} else {
|
||||||
@@ -122,7 +122,7 @@ class Smarty_Internal_Utility {
|
|||||||
* @param Smarty $smarty Smarty instance
|
* @param Smarty $smarty Smarty instance
|
||||||
* @return integer number of config files compiled
|
* @return integer number of config files compiled
|
||||||
*/
|
*/
|
||||||
public static function compileAllConfig($extention, $force_compile, $time_limit, $max_errors, Smarty $smarty)
|
public static function compileAllConfig($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty)
|
||||||
{
|
{
|
||||||
// switch off time limit
|
// switch off time limit
|
||||||
if (function_exists('set_time_limit')) {
|
if (function_exists('set_time_limit')) {
|
||||||
@@ -138,7 +138,7 @@ class Smarty_Internal_Utility {
|
|||||||
foreach ($_compile as $_fileinfo) {
|
foreach ($_compile as $_fileinfo) {
|
||||||
$_file = $_fileinfo->getFilename();
|
$_file = $_fileinfo->getFilename();
|
||||||
if (substr(basename($_fileinfo->getPathname()),0,1) == '.' || strpos($_file, '.svn') !== false) continue;
|
if (substr(basename($_fileinfo->getPathname()),0,1) == '.' || strpos($_file, '.svn') !== false) continue;
|
||||||
if (!substr_compare($_file, $extention, - strlen($extention)) == 0) continue;
|
if (!substr_compare($_file, $extension, - strlen($extension)) == 0) continue;
|
||||||
if ($_fileinfo->getPath() == substr($_dir, 0, -1)) {
|
if ($_fileinfo->getPath() == substr($_dir, 0, -1)) {
|
||||||
$_config_file = $_file;
|
$_config_file = $_file;
|
||||||
} else {
|
} else {
|
||||||
@@ -308,7 +308,7 @@ class Smarty_Internal_Utility {
|
|||||||
foreach($smarty->getTemplateDir() as $template_dir) {
|
foreach($smarty->getTemplateDir() as $template_dir) {
|
||||||
$_template_dir = $template_dir;
|
$_template_dir = $template_dir;
|
||||||
$template_dir = realpath($template_dir);
|
$template_dir = realpath($template_dir);
|
||||||
// resolve include_path or fail existance
|
// resolve include_path or fail existence
|
||||||
if (!$template_dir) {
|
if (!$template_dir) {
|
||||||
if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_template_dir)) {
|
if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_template_dir)) {
|
||||||
// try PHP include_path
|
// try PHP include_path
|
||||||
@@ -429,7 +429,7 @@ class Smarty_Internal_Utility {
|
|||||||
foreach($smarty->getPluginsDir() as $plugin_dir) {
|
foreach($smarty->getPluginsDir() as $plugin_dir) {
|
||||||
$_plugin_dir = $plugin_dir;
|
$_plugin_dir = $plugin_dir;
|
||||||
$plugin_dir = realpath($plugin_dir);
|
$plugin_dir = realpath($plugin_dir);
|
||||||
// resolve include_path or fail existance
|
// resolve include_path or fail existence
|
||||||
if (!$plugin_dir) {
|
if (!$plugin_dir) {
|
||||||
if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) {
|
if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) {
|
||||||
// try PHP include_path
|
// try PHP include_path
|
||||||
@@ -561,7 +561,7 @@ class Smarty_Internal_Utility {
|
|||||||
foreach($smarty->getConfigDir() as $config_dir) {
|
foreach($smarty->getConfigDir() as $config_dir) {
|
||||||
$_config_dir = $config_dir;
|
$_config_dir = $config_dir;
|
||||||
$config_dir = realpath($config_dir);
|
$config_dir = realpath($config_dir);
|
||||||
// resolve include_path or fail existance
|
// resolve include_path or fail existence
|
||||||
if (!$config_dir) {
|
if (!$config_dir) {
|
||||||
if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_config_dir)) {
|
if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_config_dir)) {
|
||||||
// try PHP include_path
|
// try PHP include_path
|
||||||
|
|||||||
@@ -584,7 +584,7 @@ abstract class Smarty_Resource {
|
|||||||
* @author Rodney Rehm
|
* @author Rodney Rehm
|
||||||
*
|
*
|
||||||
* @property integer $timestamp Source Timestamp
|
* @property integer $timestamp Source Timestamp
|
||||||
* @property boolean $exists Source Existance
|
* @property boolean $exists Source Existence
|
||||||
* @property boolean $template Extended Template reference
|
* @property boolean $template Extended Template reference
|
||||||
* @property string $content Source Content
|
* @property string $content Source Content
|
||||||
*/
|
*/
|
||||||
@@ -811,7 +811,7 @@ class Smarty_Template_Compiled {
|
|||||||
public $timestamp = null;
|
public $timestamp = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiled Existance
|
* Compiled Existence
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
public $exists = false;
|
public $exists = false;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class Smarty_Security {
|
|||||||
'nl2br',
|
'nl2br',
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* This is an array of trusted PHP modifers.
|
* This is an array of trusted PHP modifiers.
|
||||||
*
|
*
|
||||||
* If empty all modifiers are allowed.
|
* If empty all modifiers are allowed.
|
||||||
* To disable all modifier set $modifiers = null.
|
* To disable all modifier set $modifiers = null.
|
||||||
|
|||||||
Reference in new issue
Block a user