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


PHP FrontController::smarty方法代码示例

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


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

示例1: init

        public function init()
	{
		/*
		 * Globals are DEPRECATED as of version 1.5.
		 * Use the Context to access objects instead.
		 * Example: $this->context->cart
		 */
		global $useSSL, $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files, $currency;

		if (self::$initialized)
			return;
		self::$initialized = true;

		parent::init();

		// If current URL use SSL, set it true (used a lot for module redirect)
		if (Tools::usingSecureMode())
			$useSSL = true;

		// For compatibility with globals, DEPRECATED as of version 1.5
		$css_files = $this->css_files;
		$js_files = $this->js_files;

		// If we call a SSL controller without SSL or a non SSL controller with SSL, we redirect with the right protocol
		if (Configuration::get('PS_SSL_ENABLED') && $_SERVER['REQUEST_METHOD'] != 'POST' && $this->ssl != Tools::usingSecureMode())
		{	
			header('HTTP/1.1 301 Moved Permanently');
			header('Cache-Control: no-cache');
			if ($this->ssl)					
				header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']);
			else						
				header('Location: '.Tools::getShopDomain(true).$_SERVER['REQUEST_URI']);
			exit();
		}
		
		if ($this->ajax)
		{
			$this->display_header = false;
			$this->display_footer = false;
		}

		// if account created with the 2 steps register process, remove 'accoun_created' from cookie
		if (isset($this->context->cookie->account_created))
		{
			$this->context->smarty->assign('account_created', 1);
			unset($this->context->cookie->account_created);
		}

		ob_start();

		// Init cookie language
		// @TODO This method must be moved into switchLanguage
		Tools::setCookieLanguage($this->context->cookie);

		$protocol_link = (Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode()) ? 'https://' : 'http://';
		$useSSL = ((isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED')) || Tools::usingSecureMode()) ? true : false;
		$protocol_content = ($useSSL) ? 'https://' : 'http://';
		$link = new Link($protocol_link, $protocol_content);
		$this->context->link = $link;

		if ($id_cart = (int)$this->recoverCart())
			$this->context->cookie->id_cart = (int)$id_cart;

		if ($this->auth && !$this->context->customer->isLogged($this->guestAllowed))
			Tools::redirect('index.php?controller=authentication'.($this->authRedirection ? '&back='.$this->authRedirection : ''));

		/* Theme is missing */
		if (!is_dir(_PS_THEME_DIR_))
			throw new PrestaShopException((sprintf(Tools::displayError('Current theme unavailable "%s". Please check your theme directory name and permissions.'), basename(rtrim(_PS_THEME_DIR_, '/\\')))));

		if (Configuration::get('PS_GEOLOCATION_ENABLED'))
			if (($newDefault = $this->geolocationManagement($this->context->country)) && Validate::isLoadedObject($newDefault))
				$this->context->country = $newDefault;

		$currency = Tools::setCurrency($this->context->cookie);

		if (isset($_GET['logout']) || ($this->context->customer->logged && Customer::isBanned($this->context->customer->id)))
		{
			$this->context->customer->logout();

			Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
		}
		elseif (isset($_GET['mylogout']))
		{
			$this->context->customer->mylogout();
			Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
		}

		/* Cart already exists */
		if ((int)$this->context->cookie->id_cart)
		{
			$cart = new Cart($this->context->cookie->id_cart);
			if ($cart->OrderExists())
			{
				unset($this->context->cookie->id_cart, $cart, $this->context->cookie->checkedTOS);
				$this->context->cookie->check_cgv = false;
			}
			/* Delete product of cart, if user can't make an order from his country */
			elseif (intval(Configuration::get('PS_GEOLOCATION_ENABLED')) &&
					!in_array(strtoupper($this->context->cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) &&
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例2: init

 public function init()
 {
     global $cookie, $smarty, $iso, $defaultCountry, $protocol_link, $protocol_content, $css_files, $js_files;
     if (self::$initialized) {
         return;
     }
     self::$initialized = true;
     $css_files = array();
     $js_files = array();
     ob_start();
     /* Loading default country */
     $cookieLifetime = time() + ((int) Configuration::get('TAS_COOKIE_LIFETIME_FO') > 0 ? (int) Configuration::get('TAS_COOKIE_LIFETIME_FO') : 1) * 3600;
     $cookie = new Cookie('tas', '', $cookieLifetime);
     //var_dump($cookie);
     if ($this->php_self != "login.php") {
         // If calling url is not login.php then check user is logged
         if ($this->auth and !$cookie->isLogged(false)) {
             //echo "test";die;
             $this->authRedirection = urlencode($_SERVER['REQUEST_URI']);
             Tools::redirect('login.php' . ($this->authRedirection ? '?back=' . $this->authRedirection : ''));
         }
     }
     /* Theme is missing or maintenance */
     if (!is_dir(_TAS_THEME_DIR_)) {
         die(Tools::displayError('Current theme unavailable. Please check your theme directory name and permissions.'));
     }
     Tools::setCookieLanguage();
     /* attribute LanguageID is often needed, so we create a constant for performance reasons */
     if (!defined('_USER_ID_LANG_')) {
         define('_USER_ID_LANG_', (int) $cookie->LanguageID);
     }
     if (isset($_GET['logout']) or $cookie->logged and Member::isBanned((int) $cookie->UserID)) {
         $cookie->logout();
         Tools::redirect("index.php");
     } elseif (isset($_GET['mylogout'])) {
         $cookie->mylogout();
         Tools::redirect("index.php");
     }
     if (Validate::isLoadedObject($tas_language = new Language((int) $cookie->LanguageID))) {
         $smarty->tas_language = $tas_language;
     }
     $iso = $tas_language->LanguageShortName;
     /* get page name to display it in body id */
     $page_name = isset($this->php_self) ? preg_replace('/\\.php$/', '', $this->php_self) : '';
     $smarty->assign(Tools::getMetaTags($cookie->LanguageID, $page_name));
     $smarty->assign('request_uri', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
     $protocol_link = 'http://';
     $protocol_content = 'http://';
     $smarty->assign(array('cookie' => $cookie, 'page_name' => $page_name, 'base_dir' => __TAS_BASE_URI__, 'tpl_dir' => _TAS_THEME_DIR_, 'lang_iso' => $iso, 'come_from' => Tools::getHttpHost(true, true) . Tools::htmlentitiesUTF8(str_replace('\'', '', urldecode($_SERVER['REQUEST_URI']))), 'languages' => Tools::getLanguages(), 'sl_lang' => $cookie->LanguageID, 'shop_name' => 'TAS'));
     // Deprecated
     $smarty->assign(array('logged' => $cookie->isLogged(), 'userName' => $cookie->logged ? $cookie->LoginUserName : false));
     // TODO for better performances (cache usage), remove these assign and use a smarty function to get the right media server in relation to the full ressource name
     $assignArray = array('img_dir' => _THEME_IMG_DIR_, 'css_dir' => _THEME_CSS_DIR_, 'js_dir' => _THEME_JS_DIR_);
     foreach ($assignArray as $assignKey => $assignValue) {
         $smarty->assign($assignKey, $assignValue);
     }
     // setting properties from global var
     self::$cookie = $cookie;
     self::$smarty = $smarty;
     $this->iso = $iso == "" ? "en" : $iso;
     $this->setMedia();
 }
开发者ID:khuyennd,项目名称:dev-tasagent,代码行数:62,代码来源:FrontController.php


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