Пример #1
0
 public function display($tpl = null)
 {
     $application = JFactory::getApplication();
     $params = $application->getParams();
     // Set the request based upon the choosen layout
     switch ($this->getLayout()) {
         case 'logout':
             $intermediate_page = $params->get('intermediate_page');
             if ($intermediate_page != 1) {
                 $this->setRequest('customer/account/logout');
             } else {
                 $logout_url = MageBridgeUrlHelper::route('customer/account/logout');
                 $this->assignRef('logout_url', $logout_url);
             }
             break;
         default:
             $this->setRequest(MageBridgeUrlHelper::getLayoutUrl($this->getLayout()));
             break;
     }
     // Set which block to display
     $this->setBlock('content');
     // Assign the parameters to this template
     $this->assignRef('params', $params);
     parent::display($tpl);
 }
Пример #2
0
 public function build($params = null)
 {
     $products = parent::getCall('getAPI', 'magebridge_product.list', modMageBridgeProductsHelper::getArguments($params));
     if (!empty($products)) {
         foreach ($products as $index => $product) {
             // Use the URL-key to build a URL
             if (!empty($product['url_store'])) {
                 $product['url'] = MageBridgeUrlHelper::route($product['url_store']);
             } elseif (!empty($product['url_path'])) {
                 $product['url'] = MageBridgeUrlHelper::route($product['url_path']);
             } elseif (empty($product['url'])) {
                 $product['url'] = MageBridgeUrlHelper::route($product['url_key']);
             }
             $product['addtocart_url'] = MageBridgeUrlHelper::route('checkout/cart/add/product/' . $product['product_id'] . '/');
             // Create labels
             $product['addtocart_label'] = JText::sprintf($params->get('addtocart', 'MOD_MAGEBRIDGE_PRODUCTS_ADDTOCART'), $product['label']);
             $product['addtocart_text'] = JText::sprintf($params->get('addtocart', 'MOD_MAGEBRIDGE_PRODUCTS_ADDTOCART'), $product['name']);
             $product['readmore_label'] = JText::sprintf($params->get('readmore', 'MOD_MAGEBRIDGE_PRODUCTS_READMORE'), $product['label']);
             $product['readmore_text'] = JText::sprintf($params->get('readmore', 'MOD_MAGEBRIDGE_PRODUCTS_READMORE'), $product['name']);
             // Remove the current product from the list
             if (JURI::getInstance()->toString(array('path')) == $product['url']) {
                 unset($products[$index]);
                 continue;
             }
             $products[$index] = $product;
         }
     }
     return $products;
 }
Пример #3
0
 public function getJoomlaBridgeUrl($request = null, $force_ssl = null)
 {
     // Get important variables
     $application = JFactory::getApplication();
     $uri = JURI::getInstance();
     // Catch the backend URLs
     if ($application->isAdmin()) {
         return $uri->toString(array('scheme', 'host', 'port')) . '/administrator/index.php?option=com_magebridge&view=root&format=raw&request=' . $request;
     } else {
         if (empty($request)) {
             $root_item = MageBridgeUrlHelper::getRootItem();
             $root_item_id = $root_item && $root_item->id > 0 ? $root_item->id : JRequest::getInt('Itemid');
             $route = JRoute::_('index.php?option=com_magebridge&view=root&Itemid=' . $root_item_id, false);
         } else {
             $route = MageBridgeUrlHelper::route($request, false);
         }
         // Remove the html-suffix for Magento
         $route = preg_replace('/\\.html$/', '', $route);
         // Add a / as suffix
         if (!preg_match('/\\/$/', $route)) {
             $route .= '/';
         }
         if (!preg_match('/^(http|https):\\/\\//', $route)) {
             $route = JURI::getInstance()->toString(array('scheme', 'host', 'port')) . $route;
         }
         return $route;
     }
 }
Пример #4
0
 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);
 }
Пример #5
0
 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);
 }
Пример #6
0
 /**
  * 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);
 }
 public function display($cachable = false, $urlparams = false)
 {
     // Check if the bridge is offline
     if (MageBridge::getBridge()->isOffline()) {
         JRequest::setVar('view', 'offline');
         JRequest::setVar('layout', 'default');
     }
     // Set a default view
     if (JRequest::getVar('view') == '') {
         JRequest::setVar('view', 'root');
     }
     // Check for a logout action and perform a logout in Joomla! first
     if (MageBridgeUrlHelper::getRequest() == 'customer/account/logout') {
         $session = JFactory::getSession();
         $session->destroy();
     }
     // Redirect if the layout is not supported by the view
     if (JRequest::getVar('view') == 'catalog' && !in_array(JRequest::getVar('layout'), array('product', 'category', 'addtocart'))) {
         $url = MageBridgeUrlHelper::route('/');
         $this->setRedirect($url);
         return;
     }
     parent::display($cachable, $urlparams);
 }
Пример #8
0
 /**
  * Method to set the breadcrumbs
  */
 public function setBreadcrumbs()
 {
     // Only run this once
     static $set = false;
     if ($set == true) {
         return true;
     } else {
         $set = true;
     }
     // Only run this for root-views
     if (JFactory::getApplication()->input->getCmd('view') != 'root') {
         return true;
     }
     // Get variables
     $application = JFactory::getApplication();
     $pathway = $application->getPathway();
     $data = $this->getResponseData();
     // Define empty data
     if (!is_array($data)) {
         $data = array();
     }
     // Add the shopping-cart to this pathway
     if (MageBridgeTemplateHelper::isCartPage()) {
         $pathway->addItem(JText::_('COM_MAGEBRIDGE_SHOPPING_CART'), MageBridgeUrlHelper::route('checkout/cart'));
         // Add the checkout to this pathway
     } else {
         if (MageBridgeTemplateHelper::isCheckoutPage()) {
             $pathway->addItem(JText::_('COM_MAGEBRIDGE_SHOPPING_CART'), MageBridgeUrlHelper::route('checkout/cart'));
             $pathway->addItem(JText::_('COM_MAGEBRIDGE_CHECKOUT'), MageBridgeUrlHelper::route('checkout'));
         }
     }
     // Remove the first entry which always the homepage
     @array_shift($data);
     if (empty($data)) {
         return true;
     }
     // Loop through the existing pathway-items and collect them
     $pathway_items = array();
     foreach ($pathway->getPathway() as $pathway_item) {
         if (!preg_match('/^(http|https):/', $pathway_item->link)) {
             $pathway_item->link = preg_replace('/\\/$/', '', JURI::root()) . JRoute::_($pathway_item->link);
         }
         $pathway_items[] = $pathway_item;
     }
     // Actions when we have a root-item
     $rootItem = MageBridgeUrlHelper::getRootItem();
     if ($rootItem != false) {
         // Remove the last entry because it always is inaccurate
         @array_pop($pathway_items);
         // Construct the root-item to this pathway
         $root_pathway_item = (object) null;
         if (isset($rootItem->name)) {
             $root_pathway_item->name = JText::_($rootItem->name);
         } else {
             $root_pathway_item->name = JText::_($rootItem->title);
         }
         $root_pathway_item->link = preg_replace('/\\/$/', '', JURI::base()) . JRoute::_($rootItem->link);
         // Scan the current items to see whether there is a match or not
         $homeMatch = false;
         foreach ($pathway_items as $pathway_item) {
             if ($pathway_item->link == $root_pathway_item->link || strstr($pathway_item->link, $root_pathway_item->link)) {
                 $homeMatch = true;
                 break;
             }
         }
         // If this root item is the homepage, skip it also
         if (!empty($rootItem->home) && $rootItem->home == 1) {
             $homeMatch = true;
         }
         // Only add the root, if there is no match yet
         if (!empty($root_pathway_item) && $homeMatch == false) {
             $pathway_items[] = $root_pathway_item;
         }
         // Actions when we do not have a root-item
     } else {
         // Remove the first entry because it always is inaccurate
         @array_shift($data);
     }
     // Loop through the Magento data
     foreach ($data as $item) {
         // Do not add the current link
         //if (MageBridgeUrlHelper::current() == $item['link']) continue;
         if (empty($item['link'])) {
             $item['link'] = JURI::current();
         }
         // Loop through the current pathway-items to prevent double links
         if (!empty($pathway_items)) {
             $match = false;
             foreach ($pathway_items as $pathway_item) {
                 if (empty($pathway_item) && !is_object($pathway_item)) {
                     continue;
                 }
                 if ($pathway_item->link == $item['link']) {
                     $match = true;
                 }
             }
             if ($match == true) {
                 continue;
             }
         }
         $pathway_item = (object) null;
         $pathway_item->name = JText::_($item['label']);
         $pathway_item->link = $item['link'];
         $pathway_item->magento = 1;
         $pathway_items[] = $pathway_item;
     }
     $pathway->setPathway($pathway_items);
     return true;
 }
Пример #9
0
 public function filterHtml($html)
 {
     // Fix everything regarding URLs
     $html = MageBridgeHelper::filterContent($html);
     // Replace URLs where neccessary
     $replacement_urls = MageBridgeUrlHelper::getReplacementUrls();
     if (!empty($replacement_urls)) {
         foreach ($replacement_urls as $replacement_url) {
             $source = $replacement_url->source;
             $destination = $replacement_url->destination;
             // Prepare the source URL
             if ($replacement_url->source_type == 0) {
                 $source = MageBridgeUrlHelper::route($source);
             } else {
                 $source = str_replace('/', '\\/', $source);
             }
             // Prepare the destination URL
             if (preg_match('/^index\\.php\\?option=/', $destination)) {
                 $destination = JRoute::_($destination);
             }
             // Replace the actual URLs
             if ($replacement_url->source_type == 0) {
                 $html = str_replace($source . '\'', $destination . '\'', $html);
                 $html = str_replace($source . '"', $destination . '"', $html);
             } else {
                 $html = preg_replace('/href=\\"([^\\"]+)' . $source . '([^\\"]+)/', 'href="' . $destination, $html);
             }
         }
     }
     return $html;
 }
Пример #10
0
 /**
  * Method to check the SSO-request coming back from Magento
  * 
  * @param null
  * @return bool|exit
  */
 public static function checkSSOLogin()
 {
     // Check the security token
     JSession::checkToken('get') or die('SSO redirect failed due to wrong token');
     // Get system variables
     $application = JFactory::getApplication();
     $session = JFactory::getSession();
     // Get the current Magento session
     $magento_session = JFactory::getApplication()->input->getCmd('session');
     if (!empty($magento_session)) {
         MageBridgeModelBridge::getInstance()->setMageSession($magento_session);
         MageBridgeModelDebug::getInstance()->notice("SSO: Magento session " . $magento_session);
     }
     // Redirect back to the original URL
     $redirect = $session->get('magento_redirect', JURI::base());
     if (empty($redirect)) {
         $redirect = MageBridgeUrlHelper::route('customer/account');
     }
     MageBridgeModelDebug::getInstance()->notice("SSO: Redirect to {$redirect}");
     $application->redirect($redirect);
     return true;
 }
<?php

/**
 * Joomla! module MageBridge: Newsletter block
 *
 * @author Yireo (info@yireo.com)
 * @package MageBridge
 * @copyright Copyright 2012
 * @license GNU Public License
 * @link http://www.yireo.com
 */
// No direct access
defined('_JEXEC') or die('Restricted access');
// Read the parameters
$layout = $params->get('layout', 'default');
// Call the helper
require_once dirname(__FILE__) . '/helper.php';
$block = modMageBridgeNewsletterHelper::build($params);
// Get the current user
$user = JFactory::getUser();
// Set the form URL
$form_url = MageBridgeUrlHelper::route('newsletter/subscriber/new');
// Include the layout-file
require JModuleHelper::getLayoutPath('mod_magebridge_newsletter', $layout);
Пример #12
0
 /**
  * Redirect a specific URL
  *
  * @access private
  *
  * @param string $name
  * @param string $value
  * @param string $redirect
  *
  * @return null
  */
 private function doRedirect($name = '', $value = '', $redirect = null)
 {
     if ($this->input->getCmd($name) == $value) {
         $return = base64_decode($this->input->getString('return'));
         if (!empty($return)) {
             $return = MageBridgeEncryptionHelper::base64_encode($return);
             $redirect .= '/referer/' . $return . '/';
         }
         header('Location: ' . MageBridgeUrlHelper::route($redirect));
         exit;
     }
 }
Пример #13
0
 /**
  * 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);
 }
Пример #14
0
 /**
  * Redirect a specific URL
  *
  * @access private
  * @param string $name
  * @param string $value
  * @param string $redirect
  * @param string $function
  * @return null
  */
 private function doRedirect($name = '', $value = '', $redirect = null, $function = 'getCmd')
 {
     if (JRequest::$function($name) == $value) {
         header('Location: ' . MageBridgeUrlHelper::route($redirect));
         exit;
     }
 }
        $return_url = MageBridgeUrlHelper::route('/');
        break;
    case 'mbaccount':
        $return_url = MageBridgeUrlHelper::route('customer/account');
        break;
}
$return_url = base64_encode($return_url);
// Set the greeting name
switch ($params->get('greeting_name')) {
    case 'name':
        $name = !empty($user->name) ? $user->name : $user->username;
        break;
    default:
        $name = $user->username;
        break;
}
// Construct the URLs
$account_url = MageBridgeUrlHelper::route('customer/account');
$forgotpassword_url = MageBridgeUrlHelper::route('customer/account/forgotpassword');
$createnew_url = MageBridgeUrlHelper::route('customer/account/create');
// Construct the component variables
$component = 'com_users';
$password_field = 'password';
$task_login = '******';
$task_logout = 'user.logout';
// Construct the component URL
$component_url = JRoute::_('index.php');
//$component_url = JRoute::_('index.php?option='.$component);
// Include the template-helper
$magebridge = new MageBridgeTemplateHelper();
require JModuleHelper::getLayoutPath('mod_magebridge_login', $layout);
 public function setBreadcrumbs()
 {
     static $set = false;
     if ($set == true) {
         return true;
     } else {
         $set = true;
     }
     if (JRequest::getCmd('view') != 'root') {
         return true;
     }
     $application = JFactory::getApplication();
     $pathway = $application->getPathway();
     $data = $this->getResponseData();
     if (!is_array($data)) {
         $data = array();
     }
     if (MageBridgeTemplateHelper::isCartPage()) {
         $pathway->addItem(JText::_('COM_MAGEBRIDGE_SHOPPING_CART'), MageBridgeUrlHelper::route('checkout/cart'));
     } else {
         if (MageBridgeTemplateHelper::isCheckoutPage()) {
             $pathway->addItem(JText::_('COM_MAGEBRIDGE_SHOPPING_CART'), MageBridgeUrlHelper::route('checkout/cart'));
             $pathway->addItem(JText::_('COM_MAGEBRIDGE_CHECKOUT'), MageBridgeUrlHelper::route('checkout'));
         }
     }
     @array_shift($data);
     if (empty($data)) {
         return true;
     }
     $pathway_items = array();
     foreach ($pathway->getPathway() as $pathway_item) {
         $pathway_item->link = preg_replace('/\\/$/', '', JURI::root()) . JRoute::_($pathway_item->link);
         $pathway_items[] = $pathway_item;
     }
     @array_pop($pathway_items);
     foreach ($data as $item) {
         // Do not add the current link
         if (MageBridgeUrlHelper::current() == $item['link']) {
             continue;
         }
         // Loop through the current pathway-items to prevent double links
         if (!empty($pathway_items)) {
             $match = false;
             foreach ($pathway_items as $pathway_item) {
                 if ($pathway_item->link == $item['link']) {
                     $match = true;
                 }
             }
             if ($match == true) {
                 continue;
             }
         }
         $pathway_item = (object) null;
         $pathway_item->name = JText::_($item['label']);
         $pathway_item->link = $item['link'];
         $pathway_item->magento = 1;
         $pathway_items[] = $pathway_item;
     }
     $pathway->setPathway($pathway_items);
     return true;
 }
Пример #17
0
 /**
  * Perform a delayed redirect
  *
  * @access private
  * @param null
  * @return null
  */
 private function doDelayedRedirect()
 {
     $bridge = MageBridge::getBridge();
     $redirect_url = $bridge->getMageConfig('redirect_url');
     if (!empty($redirect_url)) {
         $redirect_url = MageBridgeUrlHelper::route($redirect_url);
         $application = JFactory::getApplication();
         $application->redirect($redirect_url);
         $application->close();
     }
 }
Пример #18
0
?>
<div id="magebridge-cart" class="magebridge-module">
    <?php 
if (isset($data['items']) && is_array($data['items']) && !empty($data['items'])) {
    ?>
        <p><?php 
    echo JText::sprintf('MOD_MAGEBRIDGE_CART_ITEMS_COUNT', $data['items_count']);
    ?>
</p>
        <ul>
        <?php 
    foreach ($data['items'] as $item) {
        ?>
            <li style="height:100px;"> 
                <?php 
        $url = MageBridgeUrlHelper::route($item['url_path']);
        ?>
                <a href="<?php 
        echo $url;
        ?>
" title="<?php 
        echo $item['name'];
        ?>
"><img src="<?php 
        echo $item['thumbnail'];
        ?>
" alt="<?php 
        echo $item['name'];
        ?>
" title="<?php 
        echo $item['name'];
Пример #19
0
 /**
  * Helper-method to get the HTTP Referer to send to Magento
  *
  * @return string
  */
 public function getHttpReferer()
 {
     // If this is a non-MageBridge page, use it
     if (JFactory::getApplication()->input->getCmd('option') != 'com_magebridge') {
         $referer = JURI::getInstance()->toString();
         // If the referer is set on the URL, use it also
     } elseif (preg_match('/\\/(uenc|referer)\\/([a-zA-Z0-9\\,\\_\\-]+)/', JURI::current(), $match)) {
         $referer = MageBridgeEncryptionHelper::base64_decode($match[2]);
         // If this is the MageBridge page checkout/cart/updatePost, return to the checkout
     } else {
         if (preg_match('/\\/checkout\\/cart\\/([a-zA-Z0-9]+)Post/', JURI::current()) == true) {
             $referer = MageBridgeUrlHelper::route('checkout/cart');
             // If this is a MageBridge page, use it only if its not a customer-page, or homepage
         } else {
             if (preg_match('/\\/customer\\/account\\//', JURI::current()) == false && preg_match('/\\/persistent\\/index/', JURI::current()) == false && preg_match('/\\/review\\/product\\/post/', JURI::current()) == false && preg_match('/\\/remove\\/item/', JURI::current()) == false && preg_match('/\\/newsletter\\/subscriber/', JURI::current()) == false && preg_match('/\\/checkout\\/cart/', JURI::current()) == false && $this->isAjax() == false && JURI::current() != $this->getJoomlaBridgeUrl()) {
                 $referer = JURI::getInstance()->toString();
             }
         }
     }
     // Load the stored referer from the session
     if (empty($referer)) {
         $session = JFactory::getSession();
         $referer = $session->get('magebridge.http_referer');
     }
     // Use the default referer
     if (empty($this->_http_referer)) {
         if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != JURI::current()) {
             $referer = $_SERVER['HTTP_REFERER'];
         }
     }
     $this->_http_referer = $referer;
     return $this->_http_referer;
 }
Пример #20
0
 public function parseTree($tree, $endLevel = 99)
 {
     if (is_array($tree) && count($tree) > 0) {
         foreach ($tree as $index => $item) {
             if (empty($item)) {
                 unset($tree[$index]);
                 continue;
             }
             // Remove disabled categories
             if ($item['is_active'] != 1) {
                 unset($tree[$index]);
                 continue;
             }
             // Remove categories that should not be in the menu
             if (isset($item['include_in_menu']) && $item['include_in_menu'] != 1) {
                 unset($tree[$index]);
                 continue;
             }
             // Remove items from the wrong level
             if ($item['level'] >= $endLevel) {
                 unset($tree[$index]);
                 continue;
             }
             // Handle HTML-entities in the title
             if (isset($item['name'])) {
                 $item['name'] = htmlspecialchars($item['name']);
             }
             // Parse the children-tree
             if (!empty($item['children'])) {
                 $item['children'] = modMageBridgeMenuHelper::parseTree($item['children'], $endLevel);
             } else {
                 $item['children'] = array();
             }
             // Translate the URL into Joomla! SEF URL
             if (empty($item['url'])) {
                 $item['url'] = '';
             } else {
                 $item['url'] = MageBridgeUrlHelper::route($item['url']);
             }
             $tree[$index] = $item;
         }
     }
     return $tree;
 }
Пример #21
0
 /**
  * Default method showing a JView
  *
  * @param boolean $cachable
  * @param boolean $urlparams
  *
  * @return null
  */
 public function display($cachable = false, $urlparams = false)
 {
     // Check if the bridge is offline
     if (MageBridge::getBridge()->isOffline()) {
         JFactory::getApplication()->input->set('view', 'offline');
         JFactory::getApplication()->input->set('layout', 'default');
     }
     // Set a default view
     if (JFactory::getApplication()->input->get('view') == '') {
         JFactory::getApplication()->input->set('view', 'root');
     }
     // Check for a logout action and perform a logout in Joomla! first
     $request = MageBridgeUrlHelper::getRequest();
     if ($request == 'customer/account/logout') {
         $session = JFactory::getSession();
         $session->destroy();
     }
     // Check for an admin request
     $backend = MageBridgeModelConfig::load('backend');
     if (!empty($backend) && substr($request, 0, strlen($backend)) === $backend) {
         $request = str_replace($backend, '', $request);
         $url = MageBridgeModelBridge::getInstance()->getMagentoAdminUrl($request);
         $this->setRedirect($url);
         return;
     }
     // Redirect if the layout is not supported by the view
     if (JFactory::getApplication()->input->get('view') == 'catalog' && !in_array(JFactory::getApplication()->input->get('layout'), array('product', 'category', 'addtocart'))) {
         $url = MageBridgeUrlHelper::route('/');
         $this->setRedirect($url);
         return;
     }
     parent::display($cachable, $urlparams);
 }
<?php

/**
 * Joomla! module MageBridge: Newsletter block
 *
 * @author	Yireo (info@yireo.com)
 * @package   MageBridge
 * @copyright Copyright 2015
 * @license   GNU Public License
 * @link	  http://www.yireo.com
 */
// No direct access
defined('_JEXEC') or die('Restricted access');
// Import the MageBridge autoloader
require_once JPATH_SITE . '/components/com_magebridge/helpers/loader.php';
// Read the parameters
$layout = $params->get('layout', 'default');
// Call the helper
require_once dirname(__FILE__) . '/helper.php';
$block = modMageBridgeNewsletterHelper::build($params);
// Get the current user
$user = JFactory::getUser();
// Set the form URL
$form_url = MageBridgeUrlHelper::route('newsletter/subscriber/new');
$redirect_url = MageBridgeUrlHelper::route(MageBridgeUrlHelper::getRequest());
$redirect_url = MageBridgeEncryptionHelper::base64_encode($redirect_url);
// Require form validation
JHTML::_('behavior.formvalidation');
// Include the layout-file
require JModuleHelper::getLayoutPath('mod_magebridge_newsletter', $layout);
Пример #23
0
 /**
  * Parse the categories of a tree for display
  *
  * @access public
  * @param array $tree
  * @param int $endLevel
  * @return mixed
  */
 public static function parseTree($tree, $startLevel = 1, $endLevel = 99)
 {
     $current_category_id = modMageBridgeMenuHelper::getCurrentCategoryId();
     $current_category_path = modMageBridgeMenuHelper::getCurrentCategoryPath();
     if (is_array($tree) && count($tree) > 0) {
         foreach ($tree as $index => $item) {
             $item['path'] = explode('/', $item['path']);
             if (empty($item)) {
                 unset($tree[$index]);
                 continue;
             }
             // Remove disabled categories
             if ($item['is_active'] != 1) {
                 unset($tree[$index]);
                 continue;
             }
             // Remove categories that should not be in the menu
             if (isset($item['include_in_menu']) && $item['include_in_menu'] != 1) {
                 unset($tree[$index]);
                 continue;
             }
             // Remove items from the wrong start-level
             if ($startLevel > 0 && $item['level'] < $startLevel && !in_array($current_category_id, $item['path'])) {
                 unset($tree[$index]);
                 continue;
             }
             // Remove items from the wrong end-level
             if ($item['level'] > $endLevel) {
                 unset($tree[$index]);
                 continue;
             }
             // Handle HTML-entities in the title
             if (isset($item['name'])) {
                 $item['name'] = htmlspecialchars($item['name']);
             }
             // Parse the children-tree
             if (!empty($item['children'])) {
                 $item['children'] = modMageBridgeMenuHelper::parseTree($item['children'], $startLevel, $endLevel);
             } else {
                 $item['children'] = array();
             }
             // Translate the URL into Joomla! SEF URL
             if (empty($item['url'])) {
                 $item['url'] = '';
             } else {
                 $item['url'] = MageBridgeUrlHelper::route($item['url']);
             }
             $tree[$index] = $item;
         }
     }
     return $tree;
 }
Пример #24
0
 /**
  * Create a specific MageBridge route
  */
 public static function route($request = null, $xhtml = null)
 {
     return MageBridgeUrlHelper::route($request, $xhtml);
 }