// Context part 13

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@7650 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2011-07-19 09:44:10 +00:00
parent 89213e18e5
commit 35e5efb530
35 changed files with 101 additions and 117 deletions
+7 -11
View File
@@ -65,15 +65,13 @@ class authorizeAIM extends PaymentModule
public function hookOrderConfirmation($params)
{
$context = Context::getContext();
if ($params['objOrder']->module != $this->name)
return;
if ($params['objOrder']->getCurrentState() != _PS_OS_ERROR_)
$context->smarty->assign(array('status' => 'ok', 'id_order' => intval($params['objOrder']->id)));
$this->context->smarty->assign(array('status' => 'ok', 'id_order' => intval($params['objOrder']->id)));
else
$context->smarty->assign('status', 'failed');
$this->context->smarty->assign('status', 'failed');
return $this->display(__FILE__, 'hookorderconfirmation.tpl');
}
@@ -135,8 +133,6 @@ class authorizeAIM extends PaymentModule
public function hookPayment($params)
{
$context = Context::getContext();
if (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off' AND Configuration::get('PS_SSL_ENABLED'))
{
$invoiceAddress = new Address((int)$params['cart']->id_address_invoice);
@@ -156,8 +152,8 @@ class authorizeAIM extends PaymentModule
$authorizeAIMParams['x_amount'] = number_format($params['cart']->getOrderTotal(true, 3), 2, '.', '');
$authorizeAIMParams['x_address'] = $invoiceAddress->address1.' '.$invoiceAddress->address2;
$authorizeAIMParams['x_zip'] = $invoiceAddress->postcode;
$authorizeAIMParams['x_first_name'] = $context->customer->firstname;
$authorizeAIMParams['x_last_name'] = $context->customer->lastname;
$authorizeAIMParams['x_first_name'] = $this->context->customer->firstname;
$authorizeAIMParams['x_last_name'] = $this->context->customer->lastname;
$isFailed = Tools::getValue('aimerror');
@@ -167,9 +163,9 @@ class authorizeAIM extends PaymentModule
$cards['discover'] = Configuration::get('AUTHORIZE_AIM_CARD_DISCOVER') == 'on' ? 1 : 0;
$cards['ax'] = Configuration::get('AUTHORIZE_AIM_CARD_AX') == 'on' ? 1 : 0;
$context->smarty->assign('p', $authorizeAIMParams);
$context->smarty->assign('cards', $cards);
$context->smarty->assign('isFailed', $isFailed);
$this->context->smarty->assign('p', $authorizeAIMParams);
$this->context->smarty->assign('cards', $cards);
$this->context->smarty->assign('isFailed', $isFailed);
return $this->display(__FILE__, 'authorizeaim.tpl');
}
+1 -3
View File
@@ -49,8 +49,6 @@ class BirthdayPresent extends Module
public function getContent()
{
$context = Context::getContext();
if (Tools::isSubmit('submitBirthday'))
{
Configuration::updateValue('BIRTHDAY_ACTIVE', (int)(Tools::getValue('bp_active')));
@@ -73,7 +71,7 @@ class BirthdayPresent extends Module
<label>'.$this->l('Type').'</label>
<div class="margin-form">
<select name="id_discount_type">';
$discountTypes = Discount::getDiscountTypes($context->language->id);
$discountTypes = Discount::getDiscountTypes($this->context->language->id);
foreach ($discountTypes AS $discountType)
$this->_html .= '<option value="'.(int)($discountType['id_discount_type']).'"'.((Configuration::get('BIRTHDAY_DISCOUNT_TYPE') == $discountType['id_discount_type']) ? ' selected="selected"' : '').'>'.$discountType['name'].'</option>';
$this->_html .= '
@@ -78,8 +78,7 @@ class BlockPermanentLinks extends Module
function hookHeader($params)
{
$context = Context::getContext();
$context->controller->addCSS(($this->_path).'blockpermanentlinks.css', 'all');
$this->context->controller->addCSS(($this->_path).'blockpermanentlinks.css', 'all');
}
}
+2 -2
View File
@@ -115,7 +115,7 @@ class Criteo extends Module
}
}
public static function buildCSV($context = null)
public static function buildCSV(Context $context = null)
{
if (!$context)
$context = Context::getContext();
@@ -184,7 +184,7 @@ class Criteo extends Module
echo $html;
}
public static function buildXML($context = null)
public static function buildXML(Context $context = null)
{
global $country_infos;
if (!$context)
+1 -2
View File
@@ -313,7 +313,6 @@ class Editorial extends Module
public function hookHeader()
{
$context = Context::getContext();
$context->controller->addCSS(($this->_path).'editorial.css', 'all');
$this->context->controller->addCSS(($this->_path).'editorial.css', 'all');
}
}
+8 -12
View File
@@ -140,10 +140,8 @@ XML;
* @param string $filename
* @return bool
*/
private function generateSitemap($shopID, $filename = '', $replaceUrl = array(), $context = null)
private function generateSitemap($shopID, $filename = '', $replaceUrl = array())
{
if (!$context)
$context = Context::getContext();
$langs = Language::getLanguages();
$shop = new Shop($shopID);
if (!$shop->id)
@@ -186,7 +184,7 @@ XML;
$cmss = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
foreach ($cmss AS $cms)
{
$tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $context->link->getCMSLink((int)$cms['id_cms'], $cms['link_rewrite'], false, (int)$cms['id_lang']) : $context->link->getCMSLink((int)$cms['id_cms']);
$tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $this->context->link->getCMSLink((int)$cms['id_cms'], $cms['link_rewrite'], false, (int)$cms['id_lang']) : $this->context->link->getCMSLink((int)$cms['id_cms']);
$this->_addSitemapNode($xml, $tmpLink, '0.8', 'daily');
}
@@ -221,7 +219,7 @@ XML;
if (($priority = 0.9 - ($category['level_depth'] / 10)) < 0.1)
$priority = 0.1;
$tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $context->link->getCategoryLink((int)$category['id_category'], $category['link_rewrite'], (int)$category['id_lang']) : $context->link->getCategoryLink((int)$category['id_category']);
$tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $this->context->link->getCategoryLink((int)$category['id_category'], $category['link_rewrite'], (int)$category['id_lang']) : $this->context->link->getCategoryLink((int)$category['id_category']);
$this->_addSitemapNode($xml, $tmpLink, $priority, 'weekly', substr($category['date_upd'], 0, 10));
}
@@ -250,7 +248,7 @@ XML;
if (($priority = 0.7 - ($product['level_depth'] / 10)) < 0.1)
$priority = 0.1;
$tmpLink = $context->link->getProductLink((int)($product['id_product']), $product['link_rewrite'], $product['category'], $product['ean13'], (int)($product['id_lang']));
$tmpLink = $this->context->link->getProductLink((int)($product['id_product']), $product['link_rewrite'], $product['category'], $product['ean13'], (int)($product['id_lang']));
$sitemap = $this->_addSitemapNode($xml, $tmpLink, $priority, 'weekly', substr($product['date_upd'], 0, 10));
$sitemap = $this->_addSitemapNodeImage($sitemap, $product);
}
@@ -279,10 +277,10 @@ XML;
if(Configuration::get('PS_REWRITING_SETTINGS'))
foreach ($pages AS $page => $ssl)
foreach($langs as $lang)
$this->_addSitemapNode($xml, $context->link->getPageLink($page, $ssl, $lang['id_lang']), '0.5', 'monthly');
$this->_addSitemapNode($xml, $this->context->link->getPageLink($page, $ssl, $lang['id_lang']), '0.5', 'monthly');
else
foreach($pages AS $page => $ssl)
$this->_addSitemapNode($xml, $context->link->getPageLink($page, $ssl), '0.5', 'monthly');
$this->_addSitemapNode($xml, $this->context->link->getPageLink($page, $ssl), '0.5', 'monthly');
$xmlString = $xml->asXML();
@@ -316,12 +314,10 @@ XML;
return $sitemap;
}
private function _addSitemapNodeImage($xml, $product, $context = null)
private function _addSitemapNodeImage($xml, $product)
{
if (!$context)
$context = Context::getContext();
$image = $xml->addChild('image', null, 'http://www.google.com/schemas/sitemap-image/1.1');
$image->addChild('loc', htmlspecialchars($context->link->getImageLink($product['link_rewrite'], (int)$product['id_product'].'-'.(int)$product['id_image'])), 'http://www.google.com/schemas/sitemap-image/1.1');
$image->addChild('loc', htmlspecialchars($this->context->link->getImageLink($product['link_rewrite'], (int)$product['id_product'].'-'.(int)$product['id_image'])), 'http://www.google.com/schemas/sitemap-image/1.1');
$legend_image = preg_replace('/(&+)/i', '&amp;', $product['legend_image']);
$image->addChild('caption', $legend_image, 'http://www.google.com/schemas/sitemap-image/1.1');
+4 -7
View File
@@ -318,20 +318,17 @@ class MailAlerts extends Module
$this->sendCustomerAlert((int)$result['id_product'], (int)$params['id_product_attribute']);
}
public function sendCustomerAlert($id_product, $id_product_attribute, $context = null)
public function sendCustomerAlert($id_product, $id_product_attribute)
{
if (!$context)
$context = Context::getContext();
$customers = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT id_customer, customer_email
FROM `'._DB_PREFIX_.'mailalert_customer_oos`
WHERE `id_product` = '.(int)$id_product.' AND `id_product_attribute` = '.(int)$id_product_attribute);
$product = new Product((int)$id_product, false, (int)$context->language->id);
$product = new Product((int)$id_product, false, $this->context->language->id);
$templateVars = array(
'{product}' => (is_array($product->name) ? $product->name[(int)Configuration::get('PS_LANG_DEFAULT')] : $product->name),
'{product_link}' => $context->link->getProductLink($product)
'{product_link}' => $this->context->link->getProductLink($product)
);
foreach ($customers AS $cust)
{
@@ -346,7 +343,7 @@ class MailAlerts extends Module
$customer_email = $cust['customer_email'];
$customer_id = 0;
}
$iso = $context->language->iso_code;
$iso = $this->context->language->iso_code;
if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/customer_qty.txt') AND file_exists(dirname(__FILE__).'/mails/'.$iso.'/customer_qty.html'))
Mail::Send((int)(Configuration::get('PS_LANG_DEFAULT')), 'customer_qty', Mail::l('Product available'), $templateVars, strval($customer_email), NULL, strval(Configuration::get('PS_SHOP_EMAIL')), strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__).'/mails/');
@@ -176,8 +176,7 @@ class productsCategory extends Module
public function hookHeader($params)
{
$context = Context::getContext();
$context->controller->addCSS($this->_path.'productscategory.css', 'all');
$context->controller->addJS(array($this->_path.'productscategory.js', _PS_JS_DIR_.'jquery/jquery.serialScroll-1.2.2-min.js'));
$this->context->controller->addCSS($this->_path.'productscategory.css', 'all');
$this->context->controller->addJS(array($this->_path.'productscategory.js', _PS_JS_DIR_.'jquery/jquery.serialScroll-1.2.2-min.js'));
}
}
@@ -426,7 +426,7 @@ class ThemeInstallator extends Module
$hookedModule = array();
$position = array();
$msg = '';
$shopID = Context::getContext()->shop->getID();
$shopID = $this->context->shop->getID();
foreach ($this->xml->modules->hooks->hook as $row)
{