本文整理汇总了PHP中XLite::getController方法的典型用法代码示例。如果您正苦于以下问题:PHP XLite::getController方法的具体用法?PHP XLite::getController怎么用?PHP XLite::getController使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XLite
的用法示例。
在下文中一共展示了XLite::getController方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getGaqOptions
/**
* 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;
}
示例2: getTabberPages
/**
* Get prepared pages array for tabber
*
* @return void
*/
protected function getTabberPages()
{
$pages = array();
$url = $this->get('url');
$switch = $this->getParam(self::PARAM_SWITCH);
$functionName = $this->getParam(self::PARAM_TAB_PAGES);
// $functionName - from PARAM_TAB_PAGES parameter
$dialogPages = \XLite::getController()->{$functionName}();
if (is_array($dialogPages)) {
foreach ($dialogPages as $page => $title) {
$p = new \XLite\Base();
$pageURL = preg_replace('/' . $switch . '=(\\w+)/', $switch . '=' . $page, $url);
$p->set('url', $pageURL);
$p->set('title', $title);
$pageSwitch = sprintf($switch . '=' . $page);
$p->set('selected', preg_match('/' . preg_quote($pageSwitch) . '(\\Z|&)/Ss', $url));
$pages[] = $p;
}
}
// if there is only one tab page, set it as a seleted with the default URL
if (1 == count($pages) || 'default' === $this->getPage()) {
$pages[0]->set('selected', $url);
}
return $pages;
}
示例3: getRequiredFieldsByType
/**
* Get required fields by address type
*
* @param string $atype Address type code
*
* @return array
*/
public function getRequiredFieldsByType($atype)
{
$list = parent::getRequiredFieldsByType($atype);
if ('express_checkout_return' === \XLite::getController()->getAction()) {
$list = array_diff($list, array('phone'));
}
return $list;
}
示例4: getName
/**
* get Shipping Method name
* for Canada Post add '(Canada Post)' (except admin area, shipping methods page)
*
* @return string
*/
public function getName()
{
$name = parent::getName();
if ('capost' == $this->getProcessor() && !(\XLite::isAdminZone() && \XLite::getController() instanceof \XLite\Controller\Admin\ShippingMethods)) {
$name = 'Canada Post ' . $name;
}
return $name;
}
示例5: defineButtons
/**
* Define buttons widgets
*
* @return array
*/
protected function defineButtons()
{
$list = parent::defineButtons();
if (\XLite::getController()->isOrderEditable()) {
$list['sendNotification'] = $this->getSendNotificationWidget();
$list['recalculate'] = $this->getRecalculateButton();
}
return $list;
}
示例6: isOutOfStock
/**
* Check if product can be purchased
*
* @return boolean
*/
public function isOutOfStock()
{
$result = parent::isOutOfStock();
if (!$result) {
$membership = \XLite::getController() instanceof \XLite\Controller\ACustomer ? \XLite::getController()->getCart()->getProfile()->getMembership() : null;
$result = $this->getAvailableAmount() < $this->getProduct()->getMinQuantity($membership);
}
return $result;
}
示例7: getDefaultOptions
/**
* Get default options for selector
*
* @return array
*/
protected function getDefaultOptions()
{
$list = array();
/** @var \XLite\Model\Shipping\Method $method */
$method = \XLite::getController()->getMethod();
$processor = $method->getProcessorObject();
$packageBoxTypeOptions = $processor->getPackageBoxTypeOptions();
foreach ($packageBoxTypeOptions as $option) {
$list[$option['code']] = $option['name'];
}
return $list;
}
示例8: validateFields
/**
* Check if field is valid and (if needed) set an error message
*
* @param array $data Current section data
* @param string $section Current section name
*
* @return void
*/
protected function validateFields(array $data, $section)
{
parent::validateFields($data, $section);
if ('default' == $section && \XLite::getController() instanceof \XLite\Controller\Admin\Module && 'CDev\\AmazonS3Images' == $this->getModule()->getActualName() && !$this->errorMessages) {
$vars = array();
foreach ($data[self::SECTION_PARAM_FIELDS] as $field) {
$vars[$field->getName()] = $field->getValue();
}
$client = \XLite\Module\CDev\AmazonS3Images\Core\S3::getInstance();
if (!empty($vars['access_key']) && !empty($vars['secret_key']) && !empty($vars['bucket']) && !$client->checkSettings($vars['access_key'], $vars['secret_key'], $vars['bucket'])) {
$this->addErrorMessage('access_key', 'Connection to Amazon S3 failed.' . ' Check whether the AWS Access key и AWS Secret key specified in the module settings are correct.', $data);
}
}
}
示例9: getGaqOptions
/**
* Get _gaq options list
*
* @return array
*/
protected function getGaqOptions()
{
$list = array('\'_setAccount\', \'' . \XLite\Core\Config::getInstance()->GoogleAnalytics->ga_account . '\'');
if (2 == \XLite\Core\Config::getInstance()->GoogleAnalytics->ga_tracking_type) {
$list[] = '\'_setDomainName\', \'.\' + self.location.host.replace(/^[^\\.]+\\./, \'\')';
} elseif (3 == \XLite\Core\Config::getInstance()->GoogleAnalytics->ga_tracking_type) {
$list[] = '\'_setDomainName\', \'none\'';
$list[] = '\'_setAllowLinker\', true';
}
$list[] = '\'_trackPageview\'';
$list[] = '\'_trackPageLoadTime\'';
$controller = \XLite::getController();
if ($controller instanceof \XLite\Controller\Customer\CheckoutSuccess) {
$orders = \XLite\Core\Session::getInstance()->gaProcessedOrders;
if (!is_array($orders)) {
$orders = array();
}
$order = $this->getOrder();
if (!in_array($order->getOrderId(), $orders)) {
foreach ($order->getItems() as $item) {
$product = $item->getProduct();
$category = $product ? $product->getCategory() : null;
if ($category && $category->getCategoryId()) {
$categories = \XLite\Core\Database::getRepo('XLite\\Model\\Category')->getCategoryPath($category->getCategoryId());
$category = array();
foreach ($categories as $cat) {
$category[] = $cat->getName();
}
$category = implode(' / ', $category);
} else {
$category = '';
}
$list[] = '\'_addItem\', ' . '\'' . $order->getOrderId() . '\', ' . '\'' . $this->escapeJavascript($item->getSku()) . '\', ' . '\'' . $this->escapeJavascript($item->getName()) . '\', ' . '\'\', ' . '\'' . $item->getPrice() . '\', ' . '\'' . $item->getAmount() . '\'';
}
$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('TAX');
$shipping = $order->getSurchargeSumByType('SHIPPING');
$list[] = '\'_addTrans\', ' . '\'' . $order->getOrderId() . '\', ' . '\'' . $this->escapeJavascript(\XLite\Core\Config::getInstance()->Company->company_name) . '\', ' . '\'' . $order->getTotal() . '\', ' . '\'' . $tax . '\', ' . '\'' . $shipping . '\', ' . '\'' . $this->escapeJavascript($city) . '\', ' . '\'' . $this->escapeJavascript($state) . '\', ' . '\'' . $this->escapeJavascript($country) . '\'';
$list[] = '\'_trackTrans\'';
$orders[] = $order->getOrderId();
\XLite\Core\Session::getInstance()->gaProcessedOrders = $orders;
}
}
return $list;
}
示例10: getValidator
/**
* Get validator
*
* @return \XLite\Core\Validator\HashArray
*/
protected function getValidator()
{
$validator = parent::getValidator();
$validator->addPair('email', new \XLite\Core\Validator\String\Email(), \XLite\Core\Validator\Pair\APair::SOFT);
$validator->addPair('password', new \XLite\Core\Validator\String(), \XLite\Core\Validator\Pair\APair::SOFT);
$validator->addPair('create_profile', new \XLite\Core\Validator\String\Switcher(), \XLite\Core\Validator\Pair\APair::SOFT);
$validator->addPair('guest_agree', new \XLite\Core\Validator\String\Switcher(), \XLite\Core\Validator\Pair\APair::SOFT);
$validator->addPair('same_address', new \XLite\Core\Validator\String\Switcher(), \XLite\Core\Validator\Pair\APair::SOFT);
$onlyCalculate = (bool) \XLite\Core\Request::getInstance()->only_calculate;
$mode = $onlyCalculate ? \XLite\Core\Validator\Pair\APair::SOFT : \XLite\Core\Validator\Pair\APair::STRICT;
$nonEmpty = !$onlyCalculate;
// Shipping address
$shippingAddress = $validator->addPair('shippingAddress', new \XLite\Core\Validator\HashArray(), \XLite\Core\Validator\Pair\APair::SOFT);
$addressFields = \XLite::getController()->getAddressFields();
$isCountryStateAdded = false;
foreach ($addressFields as $fieldName => $fieldData) {
if (in_array($fieldName, array('country_code', 'state_id'))) {
if (!$isCountryStateAdded) {
$shippingAddress->addPair(new \XLite\Core\Validator\Pair\CountryState());
$isCountryStateAdded = true;
}
} else {
$mode = $onlyCalculate || !$fieldData[\XLite\View\Model\Address\Address::SCHEMA_REQUIRED] ? \XLite\Core\Validator\Pair\APair::SOFT : \XLite\Core\Validator\Pair\APair::STRICT;
$shippingAddress->addPair($fieldName, new \XLite\Core\Validator\String($nonEmpty && $fieldData[\XLite\View\Model\Address\Address::SCHEMA_REQUIRED]), $mode);
}
}
$shippingAddress->addPair('save_in_book', new \XLite\Core\Validator\String\Switcher(), \XLite\Core\Validator\Pair\APair::SOFT);
// Billing address
if (!\XLite\Core\Request::getInstance()->same_address) {
$billingAddress = $validator->addPair('billingAddress', new \XLite\Core\Validator\HashArray(), \XLite\Core\Validator\Pair\APair::SOFT);
$isCountryStateAdded = false;
foreach ($addressFields as $fieldName => $fieldData) {
if (in_array($fieldName, array('country_code', 'state_id'))) {
if (!$isCountryStateAdded) {
$billingAddress->addPair(new \XLite\Core\Validator\Pair\CountryState());
$isCountryStateAdded = true;
}
} else {
$billingAddress->addPair($fieldName, new \XLite\Core\Validator\String($nonEmpty && $fieldData[\XLite\View\Model\Address\Address::SCHEMA_REQUIRED]), $mode);
}
}
$billingAddress->addPair('save_in_book', new \XLite\Core\Validator\String\Switcher(), \XLite\Core\Validator\Pair\APair::SOFT);
}
return $validator;
}
示例11: isActiveItem
/**
* Check - specified item is active or not
*
* @param array $item Menu item
*
* @return boolean
*/
protected function isActiveItem(array $item)
{
$result = parent::isActiveItem($item);
if (false === $item['controller']) {
$result = \XLite::getInstance()->getShopURL($item['url']) === \XLite\Core\URLManager::getCurrentURL() ?: $result;
} else {
if (!is_array($item['controller'])) {
$item['controller'] = array($item['controller']);
}
$controller = \XLite::getController();
foreach ($item['controller'] as $controllerName) {
if ($controller instanceof $controllerName) {
$result = true;
break;
}
}
}
return $result;
}
示例12: getGAOptions
/**
* Get GA options list
*
* @return array
*/
protected function getGAOptions()
{
$str = "'create', '" . \XLite\Core\Config::getInstance()->CDev->GoogleAnalytics->ga_account . "', 'auto'";
if (2 == \XLite\Core\Config::getInstance()->CDev->GoogleAnalytics->ga_tracking_type) {
$str .= ', {cookieDomain: \'.\' + self.location.host.replace(/^[^\\.]+\\./, \'\')}';
} elseif (3 == \XLite\Core\Config::getInstance()->CDev->GoogleAnalytics->ga_tracking_type) {
$str .= ", {'allowLinker': true}";
}
$list = array($str);
$list[] = "'send', 'pageview'";
$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 (!in_array($order->getOrderId(), $orders) && $order->getProfile()) {
$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[] = "'require', 'ecommerce'";
$list[] = "'ecommerce:addTransaction', {" . "'id': '" . $order->getOrderNumber() . "', " . "'affiliation': '" . $this->escapeJavascript(\XLite\Core\Config::getInstance()->Company->company_name) . "', " . "'revenue': '" . $order->getTotal() . "', " . "'tax': '" . $tax . "', " . "'shipping': '" . $shipping . "'}";
foreach ($order->getItems() as $item) {
$list[] = "'ecommerce:addItem', {" . "'id': '" . $order->getOrderNumber() . "', " . "'sku': '" . $this->escapeJavascript($item->getSku()) . "', " . "'name': '" . $this->escapeJavascript($item->getName()) . "', " . "'price': '" . $item->getPrice() . "', " . "'quantity': '" . $item->getAmount() . "'}";
}
$list[] = "'ecommerce:send'";
$orders[] = $order->getOrderId();
\XLite\Core\Session::getInstance()->gaProcessedOrders = $orders;
}
}
return $list;
}
示例13: getCart
/**
* Returns cart
*
* @return \XLite\Model\Cart
*/
protected function getCart()
{
return $this->getParam(static::PARAM_CART) ?: \XLite::getController()->getCart();
}
示例14: getClosedShopURL
/**
* Get accessible shop URL
*
* @return string
*/
protected function getClosedShopURL()
{
return \XLite::getController()->getAccessibleShopURL(false);
}
示例15: doQuery
/**
* doQuery
*
* @param array $data Data
* @param boolean $ignoreCache Flag: if true then do not get rates from cache
*
* @return array
*/
protected function doQuery($data, $ignoreCache)
{
$rates = array();
$key = $this->getConfigurationFingerPrint() . serialize($data);
if (!$ignoreCache) {
$cachedResponse = $this->getDataFromCache($key);
}
$response = null;
if (isset($cachedResponse)) {
$response = $cachedResponse;
} elseif (!\XLite\Model\Shipping::isIgnoreLongCalculations()) {
$APIConnector = $this->getAPIConnector();
$this->setRequestData($data);
$status = false;
if (\XLite\Module\XC\AuctionInc\Main::isSSAvailable()) {
$status = $APIConnector->GetItemShipRateSS($response);
} elseif (\XLite\Module\XC\AuctionInc\Main::isXSAvailable()) {
$methods = $this->getEnabledMethods();
if (count($methods)) {
$status = $APIConnector->GetItemShipRateXS($response);
}
}
$this->logResponse($status, $data, $response);
if ($status) {
$this->saveDataInCache($key, $response);
// drop selected shipping method to set it to cheapest
if (!\XLite::isAdminZone()) {
/** @var \XLite\Model\Cart $cart */
$cart = \XLite::getController()->getCart();
$cart->setShippingId(0);
if ($cart->getProfile()) {
$cart->getProfile()->setLastShippingId(0);
}
}
} elseif (isset($response['ErrorList'])) {
// report error
$errorMessages = array();
foreach ($response['ErrorList'] as $error) {
$errorMessages[] = $error['Message'];
}
$this->errorMsg = implode('; ', $errorMessages);
}
}
if ($response && empty($this->errorMsg)) {
$rates = $this->parseResponse($response);
} else {
$this->saveDataInCache($key, $response, static::CACHE_TTL);
}
if (!$response || empty($rates)) {
// Apply fallback rate
if (empty($rates) && 'N' != \XLite\Core\Config::getInstance()->XC->AuctionInc->fallbackRate) {
$rateValue = $this->getFallbackRateValue($data['package']);
$rate = new \XLite\Model\Shipping\Rate();
$rate->setBaseRate($rateValue);
$method = $this->findMethod('FF', 'FIXEDFEE', 'Fixed fee');
$rate->setMethod($method);
$rates[] = $rate;
$this->errorMsg = null;
}
}
return $rates;
}