php XLite-Core-Session类(方法)实例源码

下面列出了php XLite-Core-Session 类(方法)源码代码实例,从而了解它的用法。

作者:kirkbauer    项目:kirkx   
/**
  * Get _gaq options list
  *
  * @return array
  */
 protected function getGaqOptions()
 {
     $list = array(sprintf('\'_setAccount\', \'%s\'', \XLite\Core\Config::getInstance()->CDev->GoogleAnalytics->ga_account));
     if (2 == \XLite\Core\Config::getInstance()->CDev->GoogleAnalytics->ga_tracking_type) {
         $list[] = '\'_setDomainName\', \'.\' + self.location.host.replace(/^[^\\.]+\\./, \'\')';
     } elseif (3 == \XLite\Core\Config::getInstance()->CDev->GoogleAnalytics->ga_tracking_type) {
         $list[] = '\'_setDomainName\', \'none\'';
         $list[] = '\'_setAllowLinker\', true';
     }
     $list[] = '\'_trackPageview\'';
     $controller = \XLite::getController();
     if ($this->isEcommercePartEnabled() && $controller instanceof \XLite\Controller\Customer\CheckoutSuccess) {
         $orders = \XLite\Core\Session::getInstance()->gaProcessedOrders;
         if (!is_array($orders)) {
             $orders = array();
         }
         $order = $this->getOrder();
         if ($order->getProfile() && !in_array($order->getOrderId(), $orders)) {
             $bAddress = $order->getProfile()->getBillingAddress();
             $city = $bAddress ? $bAddress->getCity() : '';
             $state = $bAddress && $bAddress->getState() ? $bAddress->getState()->getState() : '';
             $country = $bAddress && $bAddress->getCountry() ? $bAddress->getCountry()->getCountry() : '';
             $tax = $order->getSurchargeSumByType(\XLite\Model\Base\Surcharge::TYPE_TAX);
             $shipping = $order->getSurchargeSumByType(\XLite\Model\Base\Surcharge::TYPE_SHIPPING);
             $list[] = '\'_addTrans\', ' . '\'' . $order->getOrderNumber() . '\', ' . '\'' . $this->escapeJavascript(\XLite\Core\Config::getInstance()->Company->company_name) . '\', ' . '\'' . $order->getTotal() . '\', ' . '\'' . $tax . '\', ' . '\'' . $shipping . '\', ' . '\'' . $this->escapeJavascript($city) . '\', ' . '\'' . $this->escapeJavascript($state) . '\', ' . '\'' . $this->escapeJavascript($country) . '\'';
             foreach ($order->getItems() as $item) {
                 $list[] = '\'_addItem\', ' . '\'' . $order->getOrderNumber() . '\', ' . '\'' . $this->escapeJavascript($item->getSku()) . '\', ' . '\'' . $this->escapeJavascript($item->getName()) . '\', ' . '\'\', ' . '\'' . $item->getPrice() . '\', ' . '\'' . $item->getAmount() . '\'';
             }
             $list[] = '\'_trackTrans\'';
             $orders[] = $order->getOrderId();
             \XLite\Core\Session::getInstance()->gaProcessedOrders = $orders;
         }
     }
     return $list;
 }

作者:kewaunite    项目:xcar   
/**
  * Validate return from Canada Post merchant registration process
  *
  * @return void
  */
 protected function capostValidateMerchant()
 {
     $token = \XLite\Core\Request::getInstance()->{'token-id'};
     $status = \XLite\Core\Request::getInstance()->{'registration-status'};
     if (\XLite\Module\XC\CanadaPost\Core\Service\Platforms::REG_STATUS_SUCCESS === $status) {
         // Registration is complete
         // Send request to Canada Post server to retrieve merchant details
         $data = \XLite\Module\XC\CanadaPost\Core\Service\Platforms::getInstance()->callGetMerchantRegistrationInfoByToken($token);
         if (isset($data->merchantInfo)) {
             // Update Canada Post settings
             $this->updateCapostMerchantSettings($data->merchantInfo);
             // Disable wizard
             $this->disableCapostWizard();
             \XLite\Core\TopMessage::getInstance()->addInfo('Registration process has been completed successfully.');
         } else {
             foreach ($data->errors as $err) {
                 \XLite\Core\TopMessage::getInstance()->addError('ERROR: [' . $err->code . '] ' . $err->description);
             }
         }
     } else {
         // An error occurred
         if (\XLite\Module\XC\CanadaPost\Core\Service\Platforms::REG_STATUS_CANCELLED === $status) {
             \XLite\Core\TopMessage::getInstance()->addError('Registration process has been canceled.');
         } else {
             \XLite\Core\TopMessage::getInstance()->addError('Failure to finish registration process.');
         }
     }
     // Remove token from the session
     \XLite\Core\Session::getInstance()->capost_token_id = null;
     \XLite\Core\Session::getInstance()->capost_token_ts = null;
     // Redirect back to the Canada Post settings page
     $this->setReturnURL($this->buildURL('capost'));
 }

作者:kirkbauer    项目:kirkx   
/**
  * Search total amount
  *
  * @return \Doctrine\ORM\PersistentCollection
  */
 protected function getSearchTotals()
 {
     // Get search conditions
     $name = \XLite\View\ItemsList\Model\Order\Admin\Search::getSessionCellName();
     $cnd = new \XLite\Core\CommonCell(\XLite\Core\Session::getInstance()->{$name});
     return \XLite\Core\Database::getRepo('XLite\\Model\\Order')->getSearchTotal($cnd);
 }

作者:kirkbauer    项目:kirkx   
/**
  * Return full URL for the resource
  *
  * @param string  $url             URL part to add           OPTIONAL
  * @param boolean $isSecure        Use HTTP or HTTPS         OPTIONAL
  * @param array   $params          URL parameters            OPTIONAL
  * @param string  $output          URL output type           OPTIONAL
  * @param boolean $isSession       Use session ID parameter  OPTIONAL
  * @param boolean $isProtoRelative Use protocol-relative URL OPTIONAL
  *
  * @return string
  */
 public static function getShopURL($url = '', $isSecure = null, array $params = array(), $output = null, $isSession = null, $isProtoRelative = false)
 {
     $url = trim($url);
     if (!preg_match('/^https?:\\/\\//Ss', $url)) {
         // We are using the protocol-relative URLs for resources
         $protocol = true === $isSecure || is_null($isSecure) && static::isHTTPS() ? 'https' : 'http';
         if (!isset($output)) {
             $output = static::URL_OUTPUT_FULL;
         }
         $hostDetails = static::getOptions('host_details');
         $host = $hostDetails[$protocol . '_host'];
         if ($host) {
             if ('/' != substr($url, 0, 1)) {
                 $url = $hostDetails['web_dir_wo_slash'] . '/' . $url;
             }
             $isSession = !isset($isSession) ? true === $isSecure && !static::isHTTPS() : $isSession;
             if ($isSession) {
                 $session = \XLite\Core\Session::getInstance();
                 $url .= (false !== strpos($url, '?') ? '&' : '?') . $session->getName() . '=' . $session->getID();
             }
             foreach ($params as $name => $value) {
                 $url .= (false !== strpos($url, '?') ? '&' : '?') . $name . '=' . $value;
             }
             if (static::URL_OUTPUT_FULL == $output) {
                 if (substr($url, 0, 2) != '//') {
                     $url = '//' . $host . $url;
                 }
                 $url = ($isProtoRelative ? '' : $protocol . ':') . $url;
             }
         }
     }
     return $url;
 }

作者:kewaunite    项目:xcar   
/**
  * Handles the request.
  * Parses the request variables if necessary. Attempts to call the specified action function
  *
  * @return void
  */
 public function handleRequest()
 {
     if (\XLite\Core\Session::getInstance()->inContextRedirect) {
         unset(\XLite\Core\Session::getInstance()->inContextRedirect);
     }
     parent::handleRequest();
 }

作者:kirkbauer    项目:kirkx   
/**
  * Preprocessor for no-action ren
  *
  * @return void
  */
 protected function doNoAction()
 {
     parent::doNoAction();
     if (!\XLite\Core\Request::getInstance()->isAJAX()) {
         \XLite\Core\Session::getInstance()->productListURL = $this->getURL();
     }
 }

作者:kings    项目:cor   
/**
  * Return full URL for the resource
  *
  * @param string  $url       URL part to add          OPTIONAL
  * @param boolean $isSecure  Use HTTP or HTTPS        OPTIONAL
  * @param array   $params    URL parameters           OPTIONAL
  * @param string  $output    URL output type          OPTIONAL
  * @param boolean $isSession Use session ID parameter OPTIONAL
  *
  * @return string
  */
 public static function getShopURL($url = '', $isSecure = null, array $params = array(), $output = null, $isSession = null)
 {
     if (!preg_match('/^https?:\\/\\//Ss', $url)) {
         if (!isset($isSecure)) {
             $isSecure = static::isHTTPS();
         }
         if (!isset($output)) {
             $output = static::URL_OUTPUT_FULL;
         }
         $hostDetails = \Includes\Utils\ConfigParser::getOptions('host_details');
         $host = $hostDetails['http' . ($isSecure ? 's' : '') . '_host'];
         if ($host) {
             $proto = ($isSecure ? 'https' : 'http') . '://';
             if ('/' != substr($url, 0, 1)) {
                 $url = $hostDetails['web_dir_wo_slash'] . '/' . $url;
             }
             $isSession = is_null($isSession) ? $isSecure : $isSession;
             if ($isSession) {
                 $session = \XLite\Core\Session::getInstance();
                 $url .= (false !== strpos($url, '?') ? '&' : '?') . $session->getName() . '=' . $session->getID();
             }
             foreach ($params as $name => $value) {
                 $url .= (false !== strpos($url, '?') ? '&' : '?') . $name . '=' . $value;
             }
             if (static::URL_OUTPUT_FULL == $output) {
                 $url = $proto . $host . $url;
             }
         }
     }
     return $url;
 }

作者:kirkbauer    项目:kirkx   
/**
     * Preprocessor for no-action run
     *
     * @return void
     */
    protected function doNoAction()
    {
        if (\XLite\Core\Session::getInstance()->inContextRedirect) {
            unset(\XLite\Core\Session::getInstance()->inContextRedirect);
            echo <<<HTML
            <html><head></head><body>
<script type="text/javascript">

(function(d, s, id){
  var js, ref = d.getElementsByTagName(s)[0];
  if (!d.getElementById(id)){
    js = d.createElement(s); js.id = id; js.async = true;
    js.src = "//www.paypalobjects.com/js/external/paypal.v1.js";
    ref.parentNode.insertBefore(js, ref);
  }
}(document, "script", "paypal-js"));

</script>
            </body></html>
HTML;
            exit;
        } elseif (\XLite\Core\Session::getInstance()->cancelUrl) {
            $this->setReturnURL(\XLite\Core\Session::getInstance()->cancelUrl);
            unset(\XLite\Core\Session::getInstance()->cancelUrl);
        } else {
            parent::doNoAction();
        }
    }

作者:kings    项目:cor   
/**
  * Define widget parameters
  *
  * @return void
  */
 protected function defineWidgetParams()
 {
     parent::defineWidgetParams();
     $this->widgetParams[self::PARAM_PARAMS]->setValue(array('target' => 'order_list', 'mode' => 'search'));
     $this->widgetParams[self::PARAM_SORT_CRITERIONS]->setValue(array('order_id' => 'Order id', 'date' => 'Date', 'status' => 'Status', 'total' => 'Total'));
     $this->widgetParams[self::PARAM_CELL]->setValue(\XLite\Core\Session::getInstance()->orders_search);
 }

作者:kings    项目:cor   
/**
  * Preprocessor for no-action ren
  *
  * @return void
  */
 protected function doNoAction()
 {
     parent::doNoAction();
     if (!\XLite\Core\Request::getInstance()->isAJAX()) {
         \XLite\Core\Session::getInstance()->continueShoppingURL = $this->getURL();
     }
 }

作者:kewaunite    项目:xcar   
/**
  * Add codes from csv file
  *
  * @return void
  */
 protected function doActionImport()
 {
     $stream = fopen(\XLite\Core\Session::getInstance()->pinCodesImportFile, 'r');
     $this->addFromStreamAction($stream);
     if ($stream) {
         fclose($stream);
     }
     $this->setReturnUrl($this->buildUrl('product', '', array('product_id' => \XLite\Core\Request::getInstance()->product_id, 'page' => 'pin_codes')));
 }

作者:kirkbauer    项目:kirkx   
/**
  * Get search conditions
  *
  * @return array
  */
 protected function getConditions()
 {
     $cellName = \XLite\View\ItemsList\Model\AttributeOption::getSessionCellName();
     $searchParams = \XLite\Core\Session::getInstance()->{$cellName};
     if (!is_array($searchParams)) {
         $searchParams = array();
     }
     return $searchParams;
 }

作者:kirkbauer    项目:kirkx   
/**
  * Change template
  *
  * @return void
  */
 protected function doActionChangeTemplate()
 {
     \XLite\Core\Request::getInstance()->switch = $this->getSwitchData();
     unset(\XLite\Core\Session::getInstance()->returnURL);
     $controller = new \XLite\Controller\Admin\AddonsListInstalled(\XLite\Core\Request::getInstance()->getData());
     $controller->init();
     $controller->doActionSwitch();
     $this->setReturnURL($this->buildURL('layout', '', array('moduleId' => \Xlite\Core\Request::getInstance()->template)));
 }

作者:kirkbauer    项目:kirkx   
/**
  * Get filter values
  *
  * @return array
  */
 protected function getFilterValues()
 {
     $filterValues = array();
     if ('category_filter' == $this->getTarget()) {
         $cellName = \XLite\Module\XC\ProductFilter\View\ItemsList\Product\Customer\Category\CategoryFilter::getSessionCellName();
         $filterValues = \XLite\Core\Session::getInstance()->{$cellName};
         $filterValues = is_array($filterValues) && isset($filterValues['filter']) && is_array($filterValues['filter']) ? $filterValues['filter'] : array();
     }
     return $filterValues;
 }

作者:kirkbauer    项目:kirkx   
/**
  * Get continue URL
  *
  * @return string
  */
 protected function getContinueURL()
 {
     if (\XLite\Core\Session::getInstance()->continueShoppingURL) {
         $url = $this->getURL(\XLite\Core\Session::getInstance()->continueShoppingURL);
     } elseif (isset($_SERVER['HTTP_REFERER'])) {
         $url = $_SERVER['HTTP_REFERER'];
     } else {
         $url = $this->buildURL();
     }
     return $url;
 }

作者:kings    项目:cor   
/**
  * Add language subquery with language code relation
  *
  * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder
  * @param string                     $alias        Main model alias OPTIONAL
  * @param string                     $code         Language code OPTIONAL
  *
  * @return \Doctrine\ORM\QueryBuilder
  */
 protected function addLanguageQuery(\Doctrine\ORM\QueryBuilder $queryBuilder, $alias = null, $code = null, $translationsAlias = 'translations')
 {
     if (!isset($alias)) {
         $alias = $this->getMainAlias($queryBuilder);
     }
     if (!isset($code)) {
         $code = !\XLite::isCacheBuilding() && \XLite\Core\Session::getInstance()->getLanguage() ? \XLite\Core\Session::getInstance()->getLanguage()->getCode() : 'en';
     }
     $queryBuilder->leftJoin($alias . '.translations', $translationsAlias, \Doctrine\ORM\Query\Expr\Join::WITH, $translationsAlias . '.code = :lng')->setParameter('lng', $code);
     return $queryBuilder;
 }

作者:kings    项目:cor   
/**
  * Return URL to redirect to
  *
  * @return string
  */
 protected function getAdminAreaURLArgs()
 {
     $query = '';
     if (\XLite\Core\Auth::getInstance()->isAdmin()) {
         $query .= '?' . \XLite\Core\Session::getInstance()->getName();
         $query .= '=' . \XLite\Core\Session::getInstance()->getId();
         $query .= '&' . static::PARAM_DRUPAL_RETURN_URL;
         $query .= '=' . urlencode(\Includes\Utils\URLManager::getCurrentURL());
     }
     return $query;
 }

作者:kirkbauer    项目:kirkx   
protected function doActionGetTree()
 {
     $treeKey = \XLite\Core\Request::getInstance()->treeKey;
     $session = \XLite\Core\Session::getInstance();
     if ($treeKey && $session->{$treeKey}) {
         header('Content-type: application/json');
         echo $session->{$treeKey};
         unset($session->{$treeKey});
         exit;
     }
 }

作者:kings    项目:cor   
/**
  * Handles the request.
  * Parses the request variables if necessary. Attempts to call the specified action function
  *
  * @return void
  */
 public function handleRequest()
 {
     \XLite\Core\Session::getInstance()->iframePaymentData = null;
     // security check on return page
     $orderId = \XLite\Core\Request::getInstance()->order_id;
     if ($orderId != \XLite\Core\Session::getInstance()->last_order_id && $orderId != $this->getCart()->getOrderId()) {
         $this->redirect($this->buildURL('cart'));
     } else {
         parent::handleRequest();
     }
 }

作者:kings    项目:cor   
/**
  * Get continue URL
  *
  * @return string
  */
 public function getContinueURL()
 {
     $url = \XLite\Core\Session::getInstance()->continueURL;
     if (!$url && isset($_SERVER['HTTP_REFERER'])) {
         $url = $_SERVER['HTTP_REFERER'];
     }
     if (!$url) {
         $url = $this->buildURL('main');
     }
     return $url;
 }


问题


面经


文章

微信
公众号

扫码关注公众号