// Context part 7

This commit is contained in:
tDidierjean
2011-07-15 13:59:26 +00:00
parent c8acd7a824
commit 6e93cc2848
24 changed files with 101 additions and 163 deletions
-6
View File
@@ -43,12 +43,9 @@ class AdminAttributes extends AdminTab
/**
* Display form
*
* @global string $currentIndex Current URL in order to keep current Tab
*/
public function displayForm($token = NULL)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
@@ -127,12 +124,9 @@ class AdminAttributes extends AdminTab
/**
* Manage page processing
*
* @global string $currentIndex Current URL in order to keep current Tab
*/
public function postProcess($token = NULL)
{
global $currentIndex;
if (Tools::getValue('submitDel'.$this->table))
{
if ($this->tabAccess['delete'] === '1')
+3 -10
View File
@@ -50,8 +50,6 @@ class AdminAttributesGroups extends AdminTab
public function display()
{
global $currentIndex;
if ((isset($_POST['submitAddattribute']) AND sizeof($this->adminAttributes->_errors))
OR isset($_GET['updateattribute']) OR isset($_GET['addattribute']))
{
@@ -66,10 +64,8 @@ class AdminAttributesGroups extends AdminTab
}
public function postProcess()
{
global $cookie, $currentIndex;
$this->adminAttributes->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id);
{
$this->adminAttributes->tabAccess = Profile::getProfileAccess(Context::getContext()->employee->id_profile, $this->id);
$this->adminAttributes->postProcess($this->token);
if(Tools::getValue('submitDel'.$this->table))
@@ -102,8 +98,6 @@ class AdminAttributesGroups extends AdminTab
/* Report to AdminTab::displayList() for more details */
public function displayList()
{
global $currentIndex, $cookie;
echo '<br /><a href="'.self::$currentIndex.'&add'.$this->table.'&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> <b>'.$this->l('Add attributes group').'</b></a><br />
<a href="'.self::$currentIndex.'&addattribute&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Add attribute').'</a><br /><br />
'.$this->l('Click on the group name to view its attributes. Click again to hide them.').'<br /><br />';
@@ -132,7 +126,7 @@ class AdminAttributesGroups extends AdminTab
<th width="100%">'.$this->l('Attribute').'</th>
<th>'.$this->l('Actions').'</th>
</tr>';
$attributes = AttributeGroup::getAttributes((int)($cookie->id_lang), $id);
$attributes = AttributeGroup::getAttributes(Context::getContext()->language->id, $id);
foreach ($attributes AS $attribute)
{
echo '
@@ -173,7 +167,6 @@ class AdminAttributesGroups extends AdminTab
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
+3 -9
View File
@@ -111,8 +111,6 @@ class AdminBackup extends AdminTab
*/
public function viewbackup()
{
global $currentIndex;
if (!($object = $this->loadObject()))
return;
if ($object->id)
@@ -131,8 +129,6 @@ class AdminBackup extends AdminTab
public function displayHowTo($showForm = true)
{
global $currentIndex;
echo '
<div class="error width1" style="float: left; margin-right: 10px;">
<p>'.$this->l('Disclaimer before creating a new Backup').'</p>
@@ -176,8 +172,6 @@ class AdminBackup extends AdminTab
public function displayList()
{
global $currentIndex;
// Test if the backup dir is writable
if(!is_writable(PS_ADMIN_DIR.'/backups/'))
$this->displayWarning($this->l('"Backups" Directory in admin directory must be writeable (CHMOD 755 / 777)'));
@@ -190,7 +184,7 @@ class AdminBackup extends AdminTab
public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL, $id_lang_shop = NULL)
{
global $cookie;
$context = Context::getContext();
if (!Validate::isTableOrIdentifier($this->table))
die('filter is corrupted');
@@ -223,9 +217,9 @@ class AdminBackup extends AdminTab
$orderWay = 'desc';
}
if (empty($limit))
$limit = ((!isset($cookie->{$this->table.'_pagination'})) ? $this->_pagination[0] : $limit = $cookie->{$this->table.'_pagination'});
$limit = ((!isset($context->cookie->{$this->table.'_pagination'})) ? $this->_pagination[0] : $limit = $context->cookie->{$this->table.'_pagination'});
$limit = (int)(Tools::getValue('pagination', $limit));
$cookie->{$this->table.'_pagination'} = $limit;
$context->cookie->{$this->table.'_pagination'} = $limit;
/* Determine offset from current page */
if (!empty($_POST['submitFilter'.$this->table]) AND is_numeric($_POST['submitFilter'.$this->table]))
+12 -18
View File
@@ -75,11 +75,10 @@ class AdminCMS extends AdminTab
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
$context = Context::getContext();
parent::displayForm();
$obj = $this->loadObject(true);
$iso = Language::getIsoById((int)($cookie->id_lang));
$divLangName = 'meta_title¤meta_description¤meta_keywords¤ccontent¤link_rewrite';
echo '
@@ -92,7 +91,7 @@ class AdminCMS extends AdminTab
echo '<label>'.$this->l('CMS Category:').' </label>
<div class="margin-form">
<select name="id_cms_category">';
$categories = CMSCategory::getCategories((int)($cookie->id_lang), false);
$categories = CMSCategory::getCategories($context->language->id, false);
CMSCategory::recurseCMSCategory($categories, $categories[0][1], 1, $this->getFieldValue($obj, 'id_cms_category'));
echo '
</select>
@@ -168,9 +167,7 @@ class AdminCMS extends AdminTab
'.$this->_displayDraftWarning($obj->active).'
</form>';
// TinyMCE
global $cookie;
$iso = Language::getIsoById((int)($cookie->id_lang));
$isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$iso.'.js') ? $iso : 'en');
$isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$context->language->iso_code.'.js') ? $context->language->iso_code : 'en');
$ad = dirname($_SERVER["PHP_SELF"]);
echo '
<script type="text/javascript">
@@ -184,12 +181,12 @@ class AdminCMS extends AdminTab
public function display($token = NULL)
{
global $currentIndex, $cookie;
$context = Context::getContext();
if (($id_cms_category = (int)Tools::getValue('id_cms_category')))
$currentIndex .= '&id_cms_category='.$id_cms_category;
$this->getList((int)($cookie->id_lang), !$cookie->__get($this->table.'Orderby') ? 'position' : NULL, !$cookie->__get($this->table.'Orderway') ? 'ASC' : NULL);
//$this->getList((int)($cookie->id_lang));
$this->getList($context->language->id, !$context->cookie->__get($this->table.'Orderby') ? 'position' : NULL, !$context->cookie->__get($this->table.'Orderway') ? 'ASC' : NULL);
if (!$id_cms_category)
$id_cms_category = 1;
echo '<h3>'.(!$this->_listTotal ? ($this->l('No pages found')) : ($this->_listTotal.' '.($this->_listTotal > 1 ? $this->l('pages') : $this->l('page')))).' '.
@@ -201,9 +198,7 @@ class AdminCMS extends AdminTab
}
public function displayList($token = NULL)
{
global $currentIndex;
{
/* Display list header (filtering, pagination and column names) */
$this->displayListHeader($token);
if (!sizeof($this->_list))
@@ -218,11 +213,10 @@ class AdminCMS extends AdminTab
function postProcess()
{
global $cookie, $link, $currentIndex;
if (Tools::isSubmit('viewcms') AND ($id_cms = (int)(Tools::getValue('id_cms'))) AND $cms = new CMS($id_cms, (int)($cookie->id_lang)) AND Validate::isLoadedObject($cms))
$context = Context::getContext();
if (Tools::isSubmit('viewcms') AND ($id_cms = (int)(Tools::getValue('id_cms'))) AND $cms = new CMS($id_cms, $context->language->id) AND Validate::isLoadedObject($cms))
{
$redir = $link->getCMSLink($cms);
$redir = $context->link->getCMSLink($cms);
if (!$cms->active)
{
$admin_dir = dirname($_SERVER['PHP_SELF']);
@@ -282,7 +276,7 @@ class AdminCMS extends AdminTab
$this->_errors[] = Tools::displayError('An error occurred while creating object.').' <b>'.$this->table.' ('.mysql_error().')</b>';
elseif (Tools::isSubmit('submitAddcmsAndPreview'))
{
$preview_url = $link->getCMSLink($cms, $this->getFieldValue($object, 'link_rewrite', $this->_defaultFormLanguage), (int)($cookie->id_lang));
$preview_url = $context->link->getCMSLink($cms, $this->getFieldValue($object, 'link_rewrite', $this->_defaultFormLanguage), $context->language->id);
if (!$cms->active)
{
$admin_dir = dirname($_SERVER['PHP_SELF']);
@@ -304,7 +298,7 @@ class AdminCMS extends AdminTab
$this->_errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.' ('.mysql_error().')</b>';
elseif (Tools::isSubmit('submitAddcmsAndPreview'))
{
$preview_url = $link->getCMSLink($cms, $this->getFieldValue($object, 'link_rewrite', $this->_defaultFormLanguage), (int)($cookie->id_lang));
$preview_url = $context->link->getCMSLink($cms, $this->getFieldValue($object, 'link_rewrite', $this->_defaultFormLanguage), $context->language->id);
if (!$cms->active)
{
$admin_dir = dirname($_SERVER['PHP_SELF']);
+1 -7
View File
@@ -33,8 +33,6 @@ class AdminCarriers extends AdminTab
public function __construct()
{
global $cookie;
$this->table = 'carrier';
$this->className = 'Carrier';
$this->lang = true;
@@ -82,12 +80,10 @@ class AdminCarriers extends AdminTab
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
$currentLanguage = (int)($cookie->id_lang);
echo '<script type="text/javascript">
$(document).ready(function(){
@@ -139,7 +135,7 @@ class AdminCarriers extends AdminTab
</div>
<label>'.$this->l('Group access').'</label>
<div class="margin-form">';
$groups = Group::getGroups((int)($cookie->id_lang));
$groups = Group::getGroups(Context::getContext()->language->id));
if (sizeof($groups))
{
echo '
@@ -274,8 +270,6 @@ class AdminCarriers extends AdminTab
public function postProcess()
{
global $currentIndex;
if (Tools::getValue('submitAdd'.$this->table))
{
/* Checking fields validity */
+9 -16
View File
@@ -58,10 +58,9 @@ class AdminCarts extends AdminTab
public function viewDetails()
{
global $currentIndex, $cookie;
if (!($cart = $this->loadObject(true)))
return;
$context = Context::getContext();
$customer = new Customer($cart->id_customer);
$customerStats = $customer->getStats();
$products = $cart->getProducts();
@@ -69,9 +68,7 @@ class AdminCarts extends AdminTab
Product::addCustomizationPrice($products, $customizedDatas);
$summary = $cart->getSummaryDetails();
$discounts = $cart->getDiscounts();
$currency = new Currency($cart->id_currency);
$currentLanguage = new Language((int)($cookie->id_lang));
// display cart header
echo '<h2>'.(($customer->id) ? $customer->firstname.' '.$customer->lastname : $this->l('Guest')).' - '.$this->l('Cart #').sprintf('%06d', $cart->id).' '.$this->l('from').' '.$cart->date_upd.'</h2>';
@@ -85,9 +82,9 @@ class AdminCarts extends AdminTab
<span style="font-weight: bold; font-size: 14px;">';
if ($customer->id)
echo '
<a href="?tab=AdminCustomers&id_customer='.$customer->id.'&viewcustomer&token='.Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($cookie->id_employee)).'"> '.$customer->firstname.' '.$customer->lastname.'</a></span> ('.$this->l('#').$customer->id.')<br />
<a href="?tab=AdminCustomers&id_customer='.$customer->id.'&viewcustomer&token='.Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)$context->employee->id).'"> '.$customer->firstname.' '.$customer->lastname.'</a></span> ('.$this->l('#').$customer->id.')<br />
(<a href="mailto:'.$customer->email.'">'.$customer->email.'</a>)<br /><br />
'.$this->l('Account registered:').' '.Tools::displayDate($customer->date_add, (int)($cookie->id_lang), true).'<br />
'.$this->l('Account registered:').' '.Tools::displayDate($customer->date_add, $context->language->id, true).'<br />
'.$this->l('Valid orders placed:').' <b>'.$customerStats['nb_orders'].'</b><br />
'.$this->l('Total paid since registration:').' <b>'.Tools::displayPrice($customerStats['total_orders'], $currency, false).'</b><br />';
else
@@ -122,9 +119,9 @@ class AdminCarts extends AdminTab
<span style="font-weight: bold; font-size: 14px;">';
if ($order->id)
echo '
<a href="?tab=AdminOrders&id_order='.(int)($order->id).'&vieworder&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee)).'"> '.$this->l('Order #').sprintf('%06d', $order->id).'</a></span>
<a href="?tab=AdminOrders&id_order='.(int)($order->id).'&vieworder&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)$context->employee->id).'"> '.$this->l('Order #').sprintf('%06d', $order->id).'</a></span>
<br /><br />
'.$this->l('Made on:').' '.Tools::displayDate($order->date_add, (int)$cookie->id_lang, true).'<br /><br /><br /><br />';
'.$this->l('Made on:').' '.Tools::displayDate($order->date_add, $context->language->id, true).'<br /><br /><br /><br />';
else
echo $this->l('No order created from this cart').'</span>';
echo '</fieldset>';
@@ -147,7 +144,7 @@ class AdminCarts extends AdminTab
<th style="width: 30px; text-align: center">'.$this->l('Stock').'</th>
<th style="width: 90px; text-align: right; font-weight:bold;">'.$this->l('Total').'</th>
</tr>';
$tokenCatalog = Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee));
$tokenCatalog = Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$context->employee->id);
foreach ($products as $k => $product)
{
if ($order->getTaxCalculationMethod() == PS_TAX_EXC)
@@ -238,7 +235,7 @@ class AdminCarts extends AdminTab
foreach ($discounts as $discount)
echo '
<tr>
<td><a href="?tab=AdminDiscounts&id_discount='.$discount['id_discount'].'&updatediscount&token='.Tools::getAdminToken('AdminDiscounts'.(int)(Tab::getIdFromClassName('AdminDiscounts')).(int)($cookie->id_employee)).'">'.$discount['name'].'</a></td>
<td><a href="?tab=AdminDiscounts&id_discount='.$discount['id_discount'].'&updatediscount&token='.Tools::getAdminToken('AdminDiscounts'.(int)(Tab::getIdFromClassName('AdminDiscounts')).(int)$context->employee->id).'">'.$discount['name'].'</a></td>
<td align="center">- '.Tools::displayPrice($discount['value_real'], $currency, false).'</td>
</tr>';
echo '
@@ -312,21 +309,17 @@ class AdminCarts extends AdminTab
public function display()
{
global $cookie;
if (isset($_GET['view'.$this->table]))
$this->viewDetails();
else
{
$this->getList((int)($cookie->id_lang), !Tools::getValue($this->table.'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL);
$this->getList(Context::getContext()->language->id, !Tools::getValue($this->table.'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL);
$this->displayList();
}
}
protected function _displayDeleteLink($token = NULL, $id)
{
global $currentIndex;
{
foreach ($this->_list as $cart)
if ($id == $cart['id_cart'])
if ($cart['id_order'])
+2 -4
View File
@@ -136,8 +136,6 @@ class AdminCatalog extends AdminTab
public function display()
{
global $currentIndex;
if (((Tools::isSubmit('submitAddcategory') OR Tools::isSubmit('submitAddcategoryAndStay')) AND sizeof($this->adminCategories->_errors)) OR isset($_GET['updatecategory']) OR isset($_GET['addcategory']))
{
$this->adminCategories->displayForm($this->token);
@@ -180,10 +178,10 @@ class AdminCatalog extends AdminTab
}
$catalog_tabs = array('category', 'product');
// Cleaning links
$catBarIndex = $currentIndex;
$catBarIndex = self::$currentIndex;
foreach ($catalog_tabs AS $tab)
if (Tools::getValue($tab.'Orderby') && Tools::getValue($tab.'Orderway'))
$catBarIndex = preg_replace('/&'.$tab.'Orderby=([a-z _]*)&'.$tab.'Orderway=([a-z]*)/i', '', $currentIndex);
$catBarIndex = preg_replace('/&'.$tab.'Orderby=([a-z _]*)&'.$tab.'Orderway=([a-z]*)/i', '', self::$currentIndex);
echo '<div class="cat_bar"><span style="color: #3C8534;">'.$this->l('Current category').' :</span>&nbsp;&nbsp;&nbsp;'.getPath($catBarIndex, $id_category, '', '', 'catalog', $home).'</div>';
echo '<h2>'.$this->l('Categories').'</h2>';
-1
View File
@@ -58,7 +58,6 @@ class AdminContacts extends AdminTab
public function displayForm($isMainTab = true)
{
global $currentIndex;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
+1 -4
View File
@@ -31,8 +31,6 @@ class AdminCountries extends AdminTab
{
public function __construct()
{
global $cookie;
$this->table = 'country';
$this->className = 'Country';
$this->lang = true;
@@ -50,7 +48,7 @@ class AdminCountries extends AdminTab
'a!active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'a!active'));
$this->optionTitle = $this->l('Countries options');
$this->_fieldsOptions = array('PS_COUNTRY_DEFAULT' => array('title' => $this->l('Default country:'), 'desc' => $this->l('The default country used in shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_country', 'list' => Country::getCountries((int)($cookie->id_lang))));
$this->_fieldsOptions = array('PS_COUNTRY_DEFAULT' => array('title' => $this->l('Default country:'), 'desc' => $this->l('The default country used in shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_country', 'list' => Country::getCountries(Context::getContext()->language->id)));
parent::__construct();
}
@@ -126,7 +124,6 @@ class AdminCountries extends AdminTab
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
$defaultLayout = '';
-5
View File
@@ -65,8 +65,6 @@ class AdminCurrencies extends AdminTab
public function postProcess()
{
global $currentIndex;
if (isset($_GET['delete'.$this->table]))
{
if ($this->tabAccess['delete'] === '1')
@@ -126,8 +124,6 @@ class AdminCurrencies extends AdminTab
public function displayOptionsList()
{
global $currentIndex;
parent::displayOptionsList();
echo '<br /><br />
<form action="'.self::$currentIndex.'&token='.$this->token.'" method="post">
@@ -146,7 +142,6 @@ class AdminCurrencies extends AdminTab
public function displayForm($isMainTab = true)
{
global $currentIndex;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
-3
View File
@@ -45,8 +45,6 @@ class AdminDb extends AdminPreferences
public function postProcess()
{
global $currentIndex;
if (isset($_POST['submitDatabase'.$this->table]))
{
if ($this->tabAccess['edit'] === '1')
@@ -101,7 +99,6 @@ class AdminDb extends AdminPreferences
public function display()
{
global $currentIndex;
echo $this->displayWarning($this->l('Be VERY CAREFUL with these settings, as changes may cause your PrestaShop online store to malfunction. For all issues, check the config/settings.inc.php file.')).'<br />';
$this->_displayForm('database', $this->_fieldsDatabase, $this->l('Database'), 'width2', 'database_gear');
$engines = $this->_getEngines();
+4 -8
View File
@@ -148,15 +148,13 @@ class AdminHome extends AdminTab
}
public function display()
{
global $cookie;
$context = Context::getContext();
$this->warnDomainName();
$tab = get_class();
$protocol = (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')?'https':'http';
$isoDefault = Language::getIsoById(intval(Configuration::get('PS_LANG_DEFAULT')));
$isoUser = Language::getIsoById(intval($cookie->id_lang));
$isoCountry = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
$currency = new Currency((int)(Configuration::get('PS_CURRENCY_DEFAULT')));
$isoUser = $context->language->iso_code;
$currency = $context->currency;
echo '<div>
<h1>'.$this->l('Dashboard').'</h1>
<hr style="background-color: #812143;color: #812143;" />
@@ -172,9 +170,7 @@ class AdminHome extends AdminTab
}
echo '</div>';
if (!isset($cookie->show_screencast))
$cookie->show_screencast = true;
if ($cookie->show_screencast)
if ($context->employee->show_screencast)
echo'
<div id="adminpresentation">
<iframe src="'.$protocol.'://screencasts.prestashop.com/screencast.php?iso_lang='.Tools::strtolower($isoUser).'" style="border:none;width:100%;height:420px;" scrolling="no"></iframe>
+2 -4
View File
@@ -169,18 +169,16 @@ class AdminPreferences extends AdminTab
*/
protected function _postConfig($fields)
{
global $smarty;
$languages = Language::getLanguages(false);
if (!Configuration::get('PS_FORCE_SMARTY_2'))
{
$files = scandir(_PS_THEME_DIR_);
foreach ($files AS $file)
if (!preg_match('/^\..*/', $file))
$smarty->clearCache($file);
$this->smarty->clearCache($file);
}
else
$smarty->clear_all_cache();
$this->smarty->clear_all_cache();
/* Check required fields */
foreach ($fields AS $field => $values)