// Merge -> revision 9061

This commit is contained in:
rMalie
2011-10-05 15:21:55 +00:00
parent d8f04cedb7
commit bbc6c6bdc4
53 changed files with 795 additions and 456 deletions
+6
View File
@@ -180,6 +180,12 @@ abstract class AdminTabCore
public $ajax = false;
/**
* if true, ajax-tab will not wait 1 sec
* @var boolean
*/
public $ignore_sleep = false;
public static $tabParenting = array(
'AdminProducts' => 'AdminCatalog',
'AdminCategories' => 'AdminCatalog',
+23
View File
@@ -444,6 +444,29 @@ class CarrierCore extends ObjectModel
return $countries;
}
/**
* Return the default carrier to use
*
* @param array $carriers
* @param array $defaultCarrier the last carrier selected
* @return number the id of the default carrier
*/
public static function getDefaultCarrierSelection($carriers, $defaultCarrier = 0)
{
if(empty($carriers))
return 0;
if ((int)$defaultCarrier != 0)
foreach ($carriers AS $carrier)
if ($carrier['id_carrier'] == (int)$defaultCarrier)
return (int)$carrier['id_carrier'];
foreach ($carriers AS $carrier)
if ($carrier['id_carrier'] == (int)Configuration::get('PS_CARRIER_DEFAULT'))
return (int)$carrier['id_carrier'];
return (int)$carriers[0]['id_carrier'];
}
/**
*
* @param int $id_zone
+6
View File
@@ -1004,6 +1004,12 @@ class CategoryCore extends ObjectModel
return $return;
}
/** this function return the number of category + 1 having $id_category_parent as parent.
*
* @todo rename that function to make it understandable (getNewLastPosition for example)
* @param int $id_category_parent the parent category
* @return int
*/
public static function getLastPosition($id_category_parent)
{
return (Db::getInstance()->getValue('SELECT MAX(position)+1 FROM `'._DB_PREFIX_.'category` WHERE `id_parent` = '.(int)($id_category_parent)));
+19
View File
@@ -175,6 +175,25 @@ class GroupCore extends ObjectModel
// Refresh cache of feature detachable
Configuration::updateGlobalValue('PS_GROUP_FEATURE_ACTIVE', self::isCurrentlyUsed());
// Add default group (id 1) to customers without groups
Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'customer_group` (
SELECT c.id_customer, 1 FROM `'._DB_PREFIX_.'customer` c
LEFT JOIN `'._DB_PREFIX_.'customer_group` cg
ON cg.id_customer = c.id_customer
WHERE cg.id_customer IS NULL)');
// Set to the customer the default group
// Select the minimal id from customer_group
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'customer` cg
SET id_default_group =
IFNULL((
SELECT min(id_group) FROM `'._DB_PREFIX_.'customer_group`
WHERE id_customer = cg.id_customer),
1)
WHERE `id_default_group` = '.(int)$this->id);
Discount::deleteByIdGroup($this->id);
return true;
}
return false;
+40 -54
View File
@@ -38,15 +38,22 @@ class LanguageCore extends ObjectModel
/** @var string 5-letter iso code */
public $language_code;
/** @var string date format http://http://php.net/manual/en/function.date.php with the date only */
public $date_format_lite = 'Y-m-d';
/** @var string date format http://http://php.net/manual/en/function.date.php with hours and minutes */
public $date_format_full = 'Y-m-d H:i:s';
/** @var bool true if this language is right to left language */
public $is_rtl = false;
/** @var boolean Status */
public $active = true;
protected $fieldsRequired = array('name', 'iso_code');
protected $fieldsSize = array('name' => 32, 'iso_code' => 2, 'language_code' => 5);
protected $fieldsValidate = array('name' => 'isGenericName', 'iso_code' => 'isLanguageIsoCode', 'language_code' => 'isLanguageCode', 'active' => 'isBool', 'is_rtl' => 'isBool');
protected $fieldsRequired = array('name', 'iso_code', 'date_format_lite', 'date_format_full');
protected $fieldsSize = array('name' => 32, 'iso_code' => 2, 'language_code' => 5, 'date_format_lite' => 32, 'date_format_full' => 32);
protected $fieldsValidate = array('name' => 'isGenericName', 'iso_code' => 'isLanguageIsoCode', 'language_code' => 'isLanguageCode',
'active' => 'isBool', 'is_rtl' => 'isBool', 'date_format_lite' => 'isPhpDateFormat', 'date_format_full' => 'isPhpDateFormat');
protected $table = 'lang';
protected $identifier = 'id_lang';
@@ -82,17 +89,19 @@ class LanguageCore extends ObjectModel
$fields['is_rtl'] = (int)$this->is_rtl;
if (empty($fields['language_code']))
$fields['language_code'] = $fields['iso_code'];
$fields['date_format_lite'] = pSQL($this->date_format_lite);
$fields['date_format_full'] = pSQL($this->date_format_full);
$fields['active'] = (int)$this->active;
return $fields;
}
/**
* Generate traslations files
*
*
*/
private function _generateFiles($newIso){
$iso_code = $newIso?$newIso:$this->iso_code;
if (!file_exists(_PS_TRANSLATIONS_DIR_.$iso_code))
mkdir(_PS_TRANSLATIONS_DIR_.$iso_code);
foreach ($this->translationsFilesAndVars as $file => $var)
@@ -102,7 +111,7 @@ class LanguageCore extends ObjectModel
$'.$var.' = array();
?>');
}
/**
* Move translations files after editiing language iso code
*/
@@ -122,7 +131,7 @@ class LanguageCore extends ObjectModel
{
if (file_exists(_PS_MODULE_DIR_.$moduleDir.'/mails/'.$this->iso_code))
rename(_PS_MODULE_DIR_.$moduleDir.'/mails/'.$this->iso_code, _PS_MODULE_DIR_.$moduleDir.'/mails/'.$newIso);
if (file_exists(_PS_MODULE_DIR_.$moduleDir.'/'.$this->iso_code.'.php'))
rename(_PS_MODULE_DIR_.$moduleDir.'/'.$this->iso_code.'.php', _PS_MODULE_DIR_.$moduleDir.'/'.$newIso.'.php');
}
@@ -140,7 +149,7 @@ class LanguageCore extends ObjectModel
rename(_PS_ALL_THEMES_DIR_.$theme.'/modules/'.$module.'/'.$this->iso_code.'.php', _PS_ALL_THEMES_DIR_.$theme.'/modules/'.$module.'/'.$newIso.'.php');
}
}
/**
* Return an array with themes and thumbnails
*
@@ -152,10 +161,10 @@ class LanguageCore extends ObjectModel
while ($folder = readdir($dir))
if ($folder != '.' AND $folder != '..' AND file_exists(_PS_ALL_THEMES_DIR_.'/'.$folder.'/preview.jpg'))
$themes[$folder]['name'] = $folder;
closedir($dir);
closedir($dir);
return isset($themes) ? $themes : array();
}
public function add($autodate = true, $nullValues = false)
{
if (!parent::add($autodate))
@@ -237,37 +246,19 @@ class LanguageCore extends ObjectModel
}
$lFiles = array('admin'.'.php', 'errors'.'.php', 'fields'.'.php', 'pdf'.'.php');
$mFiles = array(
'account.html', 'account.txt',
'bankwire.html', 'bankwire.txt',
'cheque.html', 'cheque.txt',
'contact.html', 'contact.txt',
'contact_form.html', 'contact_form.txt',
'credit_slip.html', 'credit_slip.txt',
'download_product.html', 'download_product.txt',
'download-product.tpl',
'employee_password.html', 'employee_password.txt',
'forward_msg.html', 'forward_msg.txt',
'guest_to_customer.html', 'guest_to_customer.txt',
'in_transit.html', 'in_transit.txt',
'newsletter.html', 'newsletter.txt',
'order_canceled.html', 'order_canceled.txt',
'order_conf.html', 'order_conf.txt',
'order_customer_comment.html', 'order_customer_comment.txt',
'order_merchant_comment.html', 'order_merchant_comment.txt',
'order_return_state.html', 'order_return_state.txt',
'outofstock.html', 'outofstock.txt',
'password.html', 'password.txt',
'password_query.html', 'password_query.txt',
'payment.html', 'payment.txt',
'payment_error.html', 'payment_error.txt',
'preparation.html', 'preparation.txt',
'refund.html', 'refund.txt',
'reply_msg.html', 'reply_msg.txt',
'shipped.html', 'shipped.txt',
'test.html', 'test.txt',
'voucher.html', 'voucher.txt',
);
$mFiles = array('account.html', 'account.txt', 'bankwire.html', 'bankwire.txt',
'cheque.html', 'cheque.txt', 'contact.html', 'contact.txt', 'contact_form.html',
'contact_form.txt', 'credit_slip.html', 'credit_slip.txt', 'download_product.html',
'download_product.txt', 'download-product.tpl', 'employee_password.html', 'employee_password.txt',
'forward_msg.html', 'forward_msg.txt', 'guest_to_customer.html', 'guest_to_customer.txt',
'in_transit.html', 'in_transit.txt', 'log_alert.html', 'log_alert.txt', 'newsletter.html', 'newsletter.txt',
'order_canceled.html', 'order_canceled.txt', 'order_conf.html', 'order_conf.txt',
'order_customer_comment.html', 'order_customer_comment.txt', 'order_merchant_comment.html',
'order_merchant_comment.txt', 'order_return_state.html', 'order_return_state.txt',
'outofstock.html', 'outofstock.txt', 'password.html', 'password.txt', 'password_query.html',
'password_query.txt', 'payment.html', 'payment.txt', 'payment_error.html', 'payment_error.txt',
'preparation.html', 'preparation.txt', 'refund.html', 'refund.txt', 'reply_msg.html',
'reply_msg.txt', 'shipped.html', 'shipped.txt', 'test.html', 'test.txt', 'voucher.html', 'voucher.txt');
$number = -1;
@@ -277,7 +268,6 @@ class LanguageCore extends ObjectModel
$files_mail = array();
$files_modules = array();
// When a copy is made from a theme in specific language
// to an other theme for the same language,
// it's avoid to copy Translations, Mails files
@@ -351,7 +341,7 @@ class LanguageCore extends ObjectModel
/**
* loadUpdateSQL will create default lang values when you create a new lang, based on default id lang
*
*
* @return boolean true if succeed
*/
public function loadUpdateSQL()
@@ -612,18 +602,14 @@ class LanguageCore extends ObjectModel
{
self::$_LANGUAGES = array();
$result = Db::getInstance()->ExecuteS('
SELECT l.`id_lang`, l.`name`, l.`iso_code`, l.`active`, ls.`id_shop`
FROM `'._DB_PREFIX_.'lang` l
LEFT JOIN `'._DB_PREFIX_.'lang_shop` ls ON (l.id_lang = ls.id_lang)');
$sql = 'SELECT l.*, ls.`id_shop`
FROM `'._DB_PREFIX_.'lang` l
LEFT JOIN `'._DB_PREFIX_.'lang_shop` ls ON (l.id_lang = ls.id_lang)';
$result = Db::getInstance()->ExecuteS($sql);
foreach ($result AS $row)
{
if (!isset(self::$_LANGUAGES[(int)$row['id_lang']]))
self::$_LANGUAGES[(int)$row['id_lang']] = array('id_lang' => (int)$row['id_lang'],
'name' => $row['name'],
'iso_code' => $row['iso_code'],
'active' => (int)$row['active'],);
self::$_LANGUAGES[(int)$row['id_lang']] = $row;
self::$_LANGUAGES[(int)$row['id_lang']]['shops'][(int)$row['id_shop']] = true;
}
}
@@ -631,7 +617,7 @@ class LanguageCore extends ObjectModel
public function update($nullValues = false)
{
if (!parent::update($nullValues))
return false;
@@ -732,7 +718,7 @@ class LanguageCore extends ObjectModel
/**
* Check if more on than one language is activated
*
*
* @since 1.5.0
* @return bool
*/
+7
View File
@@ -870,6 +870,13 @@ abstract class ModuleCore
return $output;
}
/**
* Returns the list of the payment module associated to the current customer
* @see PaymentModule::getInstalledPaymentModules() if you don't care about the context
*
* @return array module informations
*/
public static function getPaymentModules()
{
$context = Context::getContext();
+6 -3
View File
@@ -148,6 +148,7 @@ abstract class ObjectModelCore
$this->id = (int)($id);
foreach ($result AS $key => $value)
if (key_exists($key, $this))
// Todo: stripslashes() MUST BE removed in 1.4.6 and later, but is kept in 1.4.5 for a compatibility issue
$this->{$key} = stripslashes($value);
if (!$id_lang AND method_exists($this, 'getTranslationsFieldsChild'))
@@ -164,6 +165,8 @@ abstract class ObjectModelCore
{
if (!is_array($this->{$key}))
$this->{$key} = array();
// @Todo: stripslashes() MUST BE removed in 1.4.6 and later, but is kept in 1.4.5 for a compatibility issue
$this->{$key}[$row['id_lang']] = stripslashes($value);
}
}
@@ -200,7 +203,7 @@ abstract class ObjectModelCore
public function add($autodate = true, $nullValues = false)
{
if (!Validate::isTableOrIdentifier($this->table))
die(Tools::displayError());
die(Tools::displayError('not table or identifier : ').$this->table);
/* Automatically fill dates */
if ($autodate AND key_exists('date_add', $this))
@@ -229,7 +232,7 @@ abstract class ObjectModelCore
{
foreach (array_keys($field) AS $key)
if (!Validate::isTableOrIdentifier($key))
die(Tools::displayError());
die(Tools::displayError('key is not table or identifier, ').$key);
$field[$this->identifier] = (int)$this->id;
if (isset($assos[$this->table.'_lang']) && $assos[$this->table.'_lang']['type'] == 'fk_shop')
@@ -401,7 +404,7 @@ abstract class ObjectModelCore
{
/* WARNING : Product do not use this function, so do not forget to report any modification if necessary */
if (!Validate::isTableOrIdentifier($this->identifier))
die(Tools::displayError());
die(Tools::displayError('identifier is not table or identifier : ').$this->identifier);
$fields = array();
+5 -2
View File
@@ -537,6 +537,8 @@ class OrderCore extends ObjectModel
/**
* Check if order contains (only) virtual products
*
* @param boolean $strict If false return true if there are at least one product virtual
* @return boolean true if is a virtual order or false
*
*/
@@ -545,7 +547,7 @@ class OrderCore extends ObjectModel
$products = $this->getProducts();
if (count($products) < 1)
return false;
$virtual = false;
$virtual = true;
foreach ($products AS $product)
{
$pd = ProductDownload::getIdFromIdProduct((int)($product['product_id']));
@@ -553,8 +555,9 @@ class OrderCore extends ObjectModel
{
if ($strict === false)
return true;
$virtual &= true;
}
else
$virtual &= false;
}
return $virtual;
}
+4 -1
View File
@@ -775,7 +775,7 @@ class PDFCore extends PDF_PageGroupCore
$products = self::$order->getProducts();
}
else
$products = self::$orderSlip->getProducts();
$products = self::$orderSlip->getOrdersSlipProducts(self::$orderSlip->id, self::$order);
$customizedDatas = Product::getAllCustomizedDatas((int)(self::$order->id_cart));
Product::addCustomizationPrice($products, $customizedDatas);
@@ -974,7 +974,10 @@ class PDFCore extends PDF_PageGroupCore
$tmp = 0;
$product = &$tmp;
/* And secondly assign to each tax its own reduction part */
$discountAmount = 0;
if (!self::$orderSlip)
$discountAmount = (float)(self::$order->total_discounts);
foreach ($products as $product)
{
$ratio = $amountWithoutTax == 0 ? 0 : $product['priceWithoutTax'] / $amountWithoutTax;
+2 -2
View File
@@ -276,7 +276,7 @@ abstract class PaymentModuleCore extends Module
$productsList .=
'<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
<td style="padding: 0.6em 0.4em;">'.$product['reference'].'</td>
<td style="padding: 0.6em 0.4em;"><strong>'.$product['name'].(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '').' - '.$this->l('Customized').(!empty($customizationText) ? ' - '.$customizationText : '').'</strong></td>
<td style="padding: 0.6em 0.4em;"><strong>'.$product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').' - '.$this->l('Customized').(!empty($customizationText) ? ' - '.$customizationText : '').'</strong></td>
<td style="padding: 0.6em 0.4em; text-align: right;">'.Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $price : $price_wt, $currency, false).'</td>
<td style="padding: 0.6em 0.4em; text-align: center;">'.$customizationQuantity.'</td>
<td style="padding: 0.6em 0.4em; text-align: right;">'.Tools::displayPrice($customizationQuantity * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? $price : $price_wt), $currency, false).'</td>
@@ -287,7 +287,7 @@ abstract class PaymentModuleCore extends Module
$productsList .=
'<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
<td style="padding: 0.6em 0.4em;">'.$product['reference'].'</td>
<td style="padding: 0.6em 0.4em;"><strong>'.$product['name'].(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '').'</strong></td>
<td style="padding: 0.6em 0.4em;"><strong>'.$product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').'</strong></td>
<td style="padding: 0.6em 0.4em; text-align: right;">'.Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $price : $price_wt, $currency, false).'</td>
<td style="padding: 0.6em 0.4em; text-align: center;">'.((int)($product['cart_quantity']) - $customizationQuantity).'</td>
<td style="padding: 0.6em 0.4em; text-align: right;">'.Tools::displayPrice(((int)($product['cart_quantity']) - $customizationQuantity) * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? $price : $price_wt), $currency, false).'</td>
+4 -37
View File
@@ -353,7 +353,6 @@ class SearchCore
public static function indexation($full = false, $id_product = false)
{
$db = Db::getInstance();
$dropIndex = false;
if ($id_product)
$full = false;
@@ -363,11 +362,10 @@ class SearchCore
$db->Execute('TRUNCATE '._DB_PREFIX_.'search_index');
$db->Execute('TRUNCATE '._DB_PREFIX_.'search_word');
$db->Execute('UPDATE '._DB_PREFIX_.'product SET indexed = 0');
$dropIndex = true;
}
else
{
// Do it even if you already know the product id on order to be sure that it exists
// Do it even if you already know the product id in order to be sure that it exists
$products = $db->ExecuteS('
SELECT id_product
FROM '._DB_PREFIX_.'product
@@ -377,24 +375,8 @@ class SearchCore
if ($products)
foreach($products AS $product)
$ids[] = (int)$product['id_product'];
if (sizeof($ids))
if (count($ids))
$db->Execute('DELETE FROM '._DB_PREFIX_.'search_index WHERE id_product IN ('.implode(',', $ids).')');
if (count($products) > 2000)
$dropIndex = true;
}
if ($dropIndex)
{
$dropIndex = false;
$result = $db->ExecuteS('SHOW INDEX FROM `'._DB_PREFIX_.'search_index`');
foreach ($result as $row)
if (strtolower($row['Key_name']) == 'primary')
$dropIndex = true;
if ($dropIndex)
$db->Execute('ALTER TABLE '._DB_PREFIX_.'search_index DROP PRIMARY KEY');
$dropIndex = true;
}
// Every fields are weighted according to the configuration in the backend
@@ -477,11 +459,10 @@ class SearchCore
}
$existingWords = $db->ExecuteS('
SELECT word FROM '._DB_PREFIX_.'search_word
SELECT DISTINCT word FROM '._DB_PREFIX_.'search_word
WHERE word IN ('.implode(',', $queryArray2).')
AND id_lang = '.(int)$product['id_lang'].' GROUP BY word');
AND id_lang = '.(int)$product['id_lang']);
if($existingWords)
foreach($existingWords as $data)
unset($queryArray[Tools::replaceAccentedChars($data['word'])]);
@@ -530,20 +511,6 @@ class SearchCore
// One last save is done at the end in order to save what's left
Search::saveIndex($queryArray3);
}
// If it has been deleted, the index is created again once the indexation is done
if (!$dropIndex)
{
$dropIndex = true;
$result = $db->ExecuteS('SHOW INDEX FROM `'._DB_PREFIX_.'search_index`');
foreach ($result as $row)
if (strtolower($row['Key_name']) == 'primary')
$dropIndex = false;
}
if ($dropIndex)
$db->Execute('ALTER TABLE `'._DB_PREFIX_.'search_index` ADD PRIMARY KEY (`id_word`, `id_product`)');
Configuration::updateValue('PS_NEED_REBUILD_INDEX', 0);
return true;
}
+38 -6
View File
@@ -70,9 +70,18 @@ class TabCore extends ObjectModel
return $this->getTranslationsFields(array('name'));
}
public function add($autodate = true, $null_values = false)
/**
* additionnal treatments for Tab when creating new one :
* - generate a new position
* - add access for admin profile
*
* @param boolean $autodate
* @param boolean $nullValues
* @return int id_tab
*/
public function add($autodate = true, $nullValues = false)
{
$this->position = self::getNbTabs($this->id_parent) + 1;
$this->position = self::getNewLastPosition($this->id_parent);
if (parent::add($autodate, $null_values))
{
// refresh cache when adding new tab
@@ -82,6 +91,12 @@ class TabCore extends ObjectModel
return false;
}
/** When creating a new tab $id_tab, this add default rights to the table access
*
* @todo this should not be public static but protected
* @param int $id_tab
* @return boolean true if succeed
*/
public static function initAccess($id_tab, Context $context = null)
{
if (!$context)
@@ -89,16 +104,22 @@ class TabCore extends ObjectModel
if (!$context->employee->id_profile)
return false;
/* Profile selection */
$profiles = Db::getInstance()->ExecuteS('SELECT `id_profile` FROM '._DB_PREFIX_.'profile');
$profiles = Db::getInstance()->ExecuteS('SELECT `id_profile` FROM '._DB_PREFIX_.'profile where `id_profile` != 1');
if (!$profiles || empty($profiles))
return false;
/* Query definition */
$query = 'INSERT INTO `'._DB_PREFIX_.'access` VALUES ';
// note : insert ignore should be avoided
$query = 'INSERT IGNORE INTO `'._DB_PREFIX_.'access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `delete`) VALUES ';
// default admin
$query .= '(1, '.(int)$id_tab.', 1, 1, 1, 1),';
foreach ($profiles as $profile)
{
$rights = (((int)$profile['id_profile'] == 1 || (int)$profile['id_profile'] == $context->employee->id_profile) ? 1 : 0);
$query .= ($profile === $profiles[0] ? '' : ', ').'('.(int)$profile['id_profile'].', '.(int)($id_tab).', '.$rights.', '.$rights.', '.$rights.', '.$rights.')';
// no cast needed for profile[id_profile], which cames from db
// And we disable all profile but current one
$rights = $profile['id_profile'] == $context->employee->id_profile ? 1 : 0;
$query .= '('.$profile['id_profile'].', '.(int)$id_tab.', '.$rights.', '.$rights.', '.$rights.', '.$rights.'),';
}
$query = trim($query, ', ');
return Db::getInstance()->Execute($query);
}
@@ -205,6 +226,17 @@ class TabCore extends ObjectModel
'.(!is_null($id_parent) ? 'WHERE t.`id_parent` = '.(int)$id_parent : ''));
}
/**
* return an available position in subtab for parent $id_parent
*
* @param mixed $id_parent
* @return int
*/
public static function getNewLastPosition($id_parent)
{
return (Db::getInstance()->getValue('SELECT MAX(position)+1 FROM `'._DB_PREFIX_.'tab` WHERE `id_parent` = '.(int)($id_parent)));
}
public function move($direction)
{
$nb_tabs = self::getNbTabs($this->id_parent);
+5 -8
View File
@@ -485,20 +485,16 @@ class ToolsCore
*/
public static function displayDate($date, $id_lang, $full = false, $separator='-')
{
if (!$date OR !strtotime($date))
if (!$date OR !($time = strtotime($date)))
return $date;
if (!Validate::isDate($date) OR !Validate::isBool($full))
die (self::displayError('Invalid date'));
$tmpTab = explode($separator, substr($date, 0, 10));
$hour = ' '.substr($date, -8);
$language = Language::getLanguage((int)($id_lang));
if ($language AND strtolower($language['iso_code']) == 'fr')
return ($tmpTab[2].'-'.$tmpTab[1].'-'.$tmpTab[0].($full ? $hour : ''));
else
return ($tmpTab[0].'-'.$tmpTab[1].'-'.$tmpTab[2].($full ? $hour : ''));
$language = Language::getLanguage((int)$id_lang);
return date($full ? $language['date_format_full'] : $language['date_format_lite'], $time);
}
/**
* Sanitize a string
*
@@ -1191,6 +1187,7 @@ class ToolsCore
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $curlTimeOut);
curl_setopt($curl, CURLOPT_TIMEOUT, $curlTimeOut);
$content = curl_exec($curl);
curl_close($curl);
return $content;
+12
View File
@@ -408,6 +408,18 @@ class ValidateCore
return preg_match('/^[a-zA-Z_0-9-]+$/', $configName);
}
/**
* Check date formats like http://php.net/manual/en/function.date.php
*
* @param string $date_format date format to check
* @return boolean Validity is ok or not
*/
public static function isPhpDateFormat($date_format)
{
// We can't really check if this is valid or not, because this is a string and you can write whatever you want in it. That's why only < et > are forbidden (HTML)
return preg_match('/^[^<>]+$/', $date_format);
}
/**
* Check for date format
*