public function display($tpl = null) { // Load the bridge $bridge = MageBridgeModelBridge::getInstance(); // Load the parameters $layout = $this->getLayout(); $params = MageBridgeHelper::getParams(); // Set the request based upon the choosen category $request = $params->get('request', false) ? $params->get('request') : MageBridgeUrlHelper::getRequest(); $prefix = preg_replace('/\\?(.*)/', '', $request); $suffix = preg_replace('/(.*)\\?/', '', $request); // Check if this a non-URL-optimized request if (is_numeric($prefix)) { $request = MageBridgeUrlHelper::getLayoutUrl($layout, $prefix); } else { // Determine the suffix if ($layout == 'product') { $suffix = $bridge->getMageConfig('catalog/seo/product_url_suffix'); } else { if ($layout == 'category') { $suffix = $bridge->getMageConfig('catalog/seo/category_url_suffix'); } } // Add the suffix, if this is set in the Magento configuration if (!empty($suffix) && !preg_match('/' . $suffix . '$/', $request)) { $request .= $suffix; } } // Add the $mode = $params->get('mode'); if (!empty($mode)) { $request .= '?mode=' . $mode; } // Set the request in the bridge $this->setRequest($request); // Handle the redirect request $redirect = JRequest::getString('redirect'); if (!empty($redirect)) { $bridge->setHttpReferer($redirect); } // Reuse this request to set the Canonical URL if (MagebridgeModelConfig::load('enable_canonical') == 1) { $uri = MageBridgeUrlHelper::route($request); $document = JFactory::getDocument(); $document->setMetaData('canonical', $uri); } // Set which block to display $this->setBlock('content'); parent::display($tpl); }
public function display($tpl = null) { // Load the parameters $params = MageBridgeHelper::getParams(); $request = $params->get('request'); $this->setRequest($request); // Reuse this request to set the Canonical URL if (MagebridgeModelConfig::load('enable_canonical') == 1) { $uri = MageBridgeUrlHelper::route($request); $document = JFactory::getDocument(); $document->setMetaData('canonical', $uri); } // Set which block to display $this->setBlock('content'); parent::display($tpl); }
/** * Method to display the requested view */ public function display($tpl = null) { // Load the parameters $params = MageBridgeHelper::getParams(); // Load the request $request = $params->get('request'); if (empty($request)) { $request = JFactory::getApplication()->input->getString('request'); } // Remove the dummy ID from the request $request = preg_replace('/^([0-9]+)\\:/', '', $request); // Set the request $this->setRequest($request); // Reuse this request to set the Canonical URL if (MagebridgeModelConfig::load('enable_canonical') == 1) { $uri = MageBridgeUrlHelper::route($request); $document = JFactory::getDocument(); $document->setMetaData('canonical', $uri); } // Set which block to display $this->setBlock('content'); parent::display($tpl); }
private function setApp() { // If the values are already initialized, return them if (!empty($this->app_type) && !empty($this->app_value)) { return; } // Initialize system variables $application = JFactory::getApplication(); // Check if the current Menu-Item has something to say about this $store = MageBridgeHelper::getParams()->get('store'); if (!empty($store) && ($store = explode(':', $store))) { if ($store[0] == 'v') { $this->app_type = 'store'; $this->app_value = $store[1]; $application->setUserState('magebridge.store.type', $this->app_type); $application->setUserState('magebridge.store.name', $this->app_value); return; } if ($store[0] == 'g') { $this->app_type = 'group'; $this->app_value = $store[1]; $application->setUserState('magebridge.store.type', $this->app_type); $application->setUserState('magebridge.store.name', $this->app_value); return; } } // Check whether the GET-connector is enabled $get_connector = MageBridgeConnectorStore::getInstance()->getConnector('get'); if (!empty($get_connector)) { // Check for GET-variables __store $store = $application->getUserState('___store'); if (!empty($store)) { $this->app_type = 'store'; $this->app_value = $store; return; } // Check if the current store is saved with the user session $saved_type = $application->getUserState('magebridge.store.type'); $saved_name = $application->getUserState('magebridge.store.name'); if (!empty($saved_type) && !empty($saved_name)) { $this->app_type = $saved_type; $this->app_value = $saved_name; return; } } // Determine the current store using MageBridge Store Connectors if ($application->isSite()) { $store = MageBridgeConnectorStore::getInstance()->getStore(); if (!empty($store)) { $this->app_type = $store['type']; $this->app_value = $store['name']; return; } } // Load the settings from the database $storeview = MagebridgeModelConfig::load('storeview'); $storegroup = MagebridgeModelConfig::load('storegroup'); $website = MagebridgeModelConfig::load('website'); // Never use a Store View or Store Group in the backend if ($application->isAdmin()) { if (JRequest::getCmd('view') == 'root') { $this->app_type = 'website'; $this->app_value = 'admin'; } else { $this->app_type = 'website'; $this->app_value = $website; } return; } // When in the frontend, determine which store-type to use if (!empty($storeview)) { $this->app_type = 'store'; $this->app_value = $storeview; } else { if (!empty($storegroup)) { $this->app_type = 'group'; $this->app_value = $storegroup; } else { $this->app_type = 'website'; $this->app_value = $website; } } return; }
/** * Method to display the requested view */ public function display($tpl = null) { // Load the bridge $bridge = MageBridgeModelBridge::getInstance(); // Load the parameters $layout = $this->getLayout(); $params = MageBridgeHelper::getParams(); // Set the request based upon the choosen category $request = $params->get('request', false) ? $params->get('request') : MageBridgeUrlHelper::getRequest(); $prefix = preg_replace('/\\?(.*)/', '', $request); $suffix = preg_replace('/(.*)\\?/', '', $request); // Check if this a non-URL-optimized request if (is_numeric($prefix)) { $request = MageBridgeUrlHelper::getLayoutUrl($layout, $prefix); } else { // Determine the suffix if ($layout == 'product') { $suffix = $bridge->getSessionData('catalog/seo/product_url_suffix'); } else { if ($layout == 'category') { $suffix = $bridge->getSessionData('catalog/seo/category_url_suffix'); } } // Add the suffix, if this is set in the Magento configuration if (!empty($suffix) && !preg_match('/' . $suffix . '$/', $request)) { $request .= $suffix; } } // Add the qty parameter $qty = JFactory::getApplication()->input->getInt('qty'); if (!empty($qty)) { $request .= 'qty/' . $qty . '/'; } // Check for the redirect parameter $redirect = $this->input->getString('redirect'); if ($layout == 'addtocart' && empty($redirect)) { $redirect = 'checkout/cart'; } // Add the redirect parameter if (!empty($redirect)) { $redirect = MageBridgeUrlHelper::route($redirect); if (!empty($redirect)) { $request .= 'uenc/' . MageBridgeEncryptionHelper::base64_encode($redirect) . '/'; } $form_key = MageBridgeModelBridge::getInstance()->getSessionData('form_key'); if (!empty($form_key)) { $request .= 'form_key/' . $form_key; } } // Add the mode (for catalog) $mode = $params->get('mode'); if (!empty($mode)) { $request .= '?mode=' . $mode; } // Set the request in the bridge and wait for the response $this->setRequest($request); // Reuse this request to set the Canonical URL if (MagebridgeModelConfig::load('enable_canonical') == 1) { $uri = MageBridgeUrlHelper::route($request); $document = JFactory::getDocument(); $document->setMetaData('canonical', $uri); } // Set which block to display $this->setBlock('content'); parent::display($tpl); }