/**
  * Event onAfterInitialise
  *
  * @access public
  * @param null
  * @return null
  */
 public function onAfterInitialise()
 {
     // Don't do anything if MageBridge is not enabled
     if ($this->isEnabled() == false) {
         return false;
     }
     // NewRelic support
     $this->loadNewRelic();
     // Perform actions on the frontend
     $application = JFactory::getApplication();
     if ($application->isSite()) {
         // Hard-spoof all MageBridge SEF URLs (for sh404SEF)
         if ($this->getParam('spoof_sef', 0) == 1) {
             $current_url = preg_replace('/\\.html$/', '', $_SERVER['REQUEST_URI']);
             $root_item = MageBridgeUrlHelper::getRootItem();
             $root_item_id = $root_item ? $root_item->id : null;
             $bridge_url = JRoute::_('index.php?option=com_magebridge&view=root&Itemid=' . $root_item_id, false);
             if (substr($current_url, 0, strlen($bridge_url)) == $bridge_url) {
                 $request = substr_replace($current_url, '', 0, strlen($bridge_url));
                 JRequest::setVar('option', 'com_magebridge');
                 JRequest::setVar('view', 'root');
                 JRequest::setVar('Itemid', $root_item_id);
                 JRequest::setVar('request', $request);
             }
         }
     }
 }
예제 #2
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;
     }
 }
예제 #3
0
 /**
  * Event onAfterInitialise
  *
  * @access public
  *
  * @param null
  *
  * @return null
  */
 public function onAfterInitialise()
 {
     // Don't do anything if MageBridge is not enabled
     if ($this->isEnabled() == false) {
         return false;
     }
     // Include JForm elements
     $this->loadJform();
     // NewRelic support
     $this->loadNewRelic();
     // Perform actions on the frontend
     if ($this->app->isSite()) {
         // Deny iframes
         if ($this->params->get('deny_iframe')) {
             header('X-Frame-Options: DENY');
         }
         // Hard-spoof all MageBridge SEF URLs (for sh404SEF)
         if ($this->getParam('spoof_sef', 0) == 1) {
             $current_url = preg_replace('/\\.html$/', '', $_SERVER['REQUEST_URI']);
             $root_item = MageBridgeUrlHelper::getRootItem();
             $root_item_id = $root_item ? $root_item->id : null;
             $bridge_url = JRoute::_('index.php?option=com_magebridge&view=root&Itemid=' . $root_item_id, false);
             if (substr($current_url, 0, strlen($bridge_url)) == $bridge_url) {
                 $request = substr_replace($current_url, '', 0, strlen($bridge_url));
                 $this->input->set('option', 'com_magebridge');
                 $this->input->set('view', 'root');
                 $this->input->set('Itemid', $root_item_id);
                 $this->input->set('request', $request);
             }
         }
         // Detect an user-login without remember-me tick
         if ($this->app->input->getString('option') == 'com_users' && $this->app->input->getString('task') == 'user.login') {
             $username = $this->app->input->getString('username');
             $password = $this->app->input->getString('password');
             $remember = $this->app->input->getString('remember');
             if (!empty($username) && !empty($password) && empty($remember)) {
                 $_COOKIE['persistent_shopping_cart'] = null;
             }
         }
     }
 }
예제 #4
0
 /**
  * Method to return the Joomla!/MageBridge System URL
  *
  * @param string $request
  * @param int    $forceSsl
  *
  * @return string
  */
 public function getJoomlaBridgeUrl($request = null, $forceSsl = null)
 {
     // Get important variables
     $application = JFactory::getApplication();
     $uri = JURI::getInstance();
     // Catch the backend URLs
     if ($application->isAdmin()) {
         $baseUri = $uri->toString(array('scheme', 'host', 'port'));
         return $baseUri . '/administrator/index.php?option=com_magebridge&view=root&format=raw&request=' . $request;
     } else {
         // Return the MageBridge Root if the request is empty
         if (empty($request)) {
             $root_item = MageBridgeUrlHelper::getRootItem();
             $root_item_id = $root_item && $root_item->id > 0 ? $root_item->id : JFactory::getApplication()->input->getInt('Itemid');
             // Allow for experimental support for MijoSEF and sh404SEF
             if (self::sh404sef() || self::mijosef()) {
                 $route = 'index.php?option=com_magebridge&view=root&Itemid=' . $root_item_id . '&request=';
             } else {
                 $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 (!strstr($route, '?') && !preg_match('/\\/$/', $route)) {
             $route .= '/';
         }
         // Prepend the hostname
         if (!preg_match('/^(http|https):\\/\\//', $route)) {
             $url = JURI::getInstance()->toString(array('scheme', 'host', 'port'));
             if (!preg_match('/^\\//', $route) && !preg_match('/\\/$/', $url)) {
                 $route = $url . '/' . $route;
             } else {
                 $route = $url . $route;
             }
         }
         return $route;
     }
 }
예제 #5
0
/**
 * Function to convert a SEF URL back to a system URL
 */
function MagebridgeParseRoute($segments)
{
    $vars = array();
    // Strange bug: The first segment autoreplaces the first dash with a semi-column
    if (!empty($segments)) {
        foreach ($segments as $index => $segment) {
            $segments[$index] = preg_replace('/^([a-zA-Z0-9]+)\\:/', '\\1-', $segment);
        }
    }
    // Skip to the API if this is detected
    if (isset($segments[1]) && $segments[1] == 'jsonrpc') {
        $vars['view'] = 'jsonrpc';
        $vars['task'] = $segments[2];
        return $vars;
    }
    // Get the active menu item
    $menu = JFactory::getApplication()->getMenu('site');
    $current_item = $menu->getActive();
    $items = MageBridgeUrlHelper::getMenuItems();
    // Fetch the Root-Item
    $root_item = MageBridgeUrlHelper::getRootItem();
    $root_item_id = $root_item && $root_item->id > 0 ? $root_item->id : false;
    // Fix the segments when Root Menu-Item is enforced
    if (MageBridgeUrlHelper::enforceRootMenu()) {
        $current_item = $root_item;
        $current_path = JURI::getInstance()->toString(array('path'));
        $current_segments = explode('/', preg_replace('/^\\//', '', $current_path));
        $root_path = JRoute::_($root_item->link . '&Itemid=' . $root_item->id);
        $root_segments = explode('/', preg_replace('/^\\//', '', $root_path));
        $segments = array();
        foreach ($current_segments as $current_index => $current_segment) {
            if (isset($root_segments[$current_index]) && $root_segments[$current_index] == $current_segment) {
                continue;
            }
            if (empty($current_segment)) {
                continue;
            }
            $segments[] = $current_segment;
        }
    }
    // Parse the segments
    if (!empty($segments)) {
        $request = implode('/', $segments);
        $request = preg_replace('/^component\\/magebridge\\//', '', $request);
        $vars['request'] = $request;
    } else {
        $vars['request'] = null;
    }
    // A hack to set the active Menu-Item
    if (!empty($vars['request']) && !empty($items)) {
        foreach ($items as $item) {
            $preg_route = '/^' . str_replace('/', '\\/', $item->route) . '/';
            if (!empty($item->route) && preg_match($preg_route, $vars['request'])) {
                $menu->setActive($item->id);
                break;
            }
            if (isset($item->query['request']) && $item->query['request'] == $vars['request']) {
                $menu->setActive($item->id);
                break;
            }
        }
    }
    // Set the view based on the current item
    if (empty($vars['request']) && !empty($current_item->query['view'])) {
        $vars['view'] = $current_item->query['view'];
    }
    // Set the default
    if (!isset($vars['view'])) {
        $vars['view'] = 'root';
        // Override the Itemid if the root is available
        if ($root_item_id) {
            $vars['Itemid'] = $root_item_id;
        }
        // Add the current pathing
        if ($current_item && $current_item->id != $root_item_id && in_array($root_item_id, $current_item->tree) && MageBridgeUrlHelper::enableRootMenu()) {
            $path = str_replace($root_item->route . '/', '', $current_item->route);
            if (!empty($vars['request'])) {
                $vars['request'] = $path . '/' . $vars['request'];
            }
        }
    }
    // Re-spoof the current Itemid
    if (isset($vars['Itemid']) && $vars['Itemid'] > 0) {
        JFactory::getApplication()->input->set('Itemid', $vars['Itemid']);
    }
    return $vars;
}
예제 #6
0
 /**
  * Method to do all system checks
  *
  * @package MageBridge
  * @access public
  * @return null
  */
 public function doSystemChecks($installer = false)
 {
     $application = JFactory::getApplication();
     $db = JFactory::getDBO();
     $config = MagebridgeModelConfig::load();
     // System Compatibility
     $result = version_compare(phpversion(), '5.2.8', '>=') ? self::CHECK_OK : self::CHECK_ERROR;
     $this->addResult('compatibility', 'PHP version', $result, JText::sprintf('CHECK_PHP_VERSION', '5.2.8'));
     $result = version_compare(ini_get('memory_limit'), '31M', '>') ? self::CHECK_OK : self::CHECK_ERROR;
     $this->addResult('compatibility', 'PHP memory', $result, JText::sprintf('CHECK_PHP_MEMORY', '32Mb', ini_get('memory_limit')));
     $jversion = new JVersion();
     $result = version_compare($jversion->getShortVersion(), '1.5.12', '>=') ? self::CHECK_OK : self::CHECK_ERROR;
     $this->addResult('compatibility', 'Joomla! version', $result, JText::sprintf('CHECK_JOOMLA_VERSION', '1.5.12'));
     $result = function_exists('simplexml_load_string') ? self::CHECK_OK : self::CHECK_ERROR;
     $this->addResult('compatibility', 'SimpleXML', $result, JText::_('CHECK_SIMPLEXML'));
     $result = in_array('ssl', stream_get_transports()) ? self::CHECK_OK : self::CHECK_ERROR;
     $this->addResult('compatibility', 'OpenSSL', $result, JText::_('CHECK_OPENSSL'));
     $result = function_exists('json_decode') ? self::CHECK_OK : self::CHECK_ERROR;
     $this->addResult('compatibility', 'JSON', $result, JText::_('CHECK_JSON'));
     $result = function_exists('curl_init') ? self::CHECK_OK : self::CHECK_ERROR;
     $this->addResult('compatibility', 'CURL', $result, JText::_('CHECK_CURL'));
     $result = function_exists('mcrypt_cfb') ? self::CHECK_OK : self::CHECK_ERROR;
     $this->addResult('compatibility', 'mcrypt', $result, JText::_('CHECK_MCRYPT'));
     $result = ini_get('magic_quotes_gpc') ? self::CHECK_ERROR : self::CHECK_OK;
     $this->addResult('compatibility', 'magic_quotes_gpc', $result, JText::_('CHECK_MAGIC_QUOTES_GPC'));
     $result = ini_get('safe_mode') ? self::CHECK_ERROR : self::CHECK_OK;
     $this->addResult('compatibility', 'safe_mode', $result, JText::_('CHECK_SAFE_MODE'));
     if (function_exists('apache_get_modules')) {
         $modules = apache_get_modules();
         $result = in_array('mod_rewrite', $modules);
     } else {
         $result = getenv('HTTP_MOD_REWRITE') == 'On' ? true : false;
     }
     $this->addResult('compatibility', 'Apache mod_rewrite', $result, JText::_('CHECK_MOD_REWRITE'));
     $result = $this->checkWebOwner();
     $this->addResult('compatibility', 'File Ownership', $result, JText::_('CHECK_FILE_OWNERSHIP'));
     // System Configuration
     $result = file_exists(JPATH_SITE . '/.htaccess') ? self::CHECK_OK : self::CHECK_ERROR;
     $this->addResult('system', 'htaccess', $result, JText::_('CHECK_HTACCESS'));
     $result = $application->getCfg('sef') == 1 ? self::CHECK_OK : self::CHECK_ERROR;
     $this->addResult('system', 'SEF', $result, JText::_('CHECK_SEF'));
     $result = $application->getCfg('sef_rewrite') == 1 ? self::CHECK_OK : self::CHECK_WARNING;
     $this->addResult('system', 'SEF Rewrites', $result, JText::_('CHECK_SEF_REWRITE'));
     $result = $application->getCfg('caching') == 0 ? self::CHECK_OK : self::CHECK_WARNING;
     $this->addResult('system', 'Caching', $result, JText::_('CHECK_CACHING'));
     if ($installer == false) {
         $result = (bool) MageBridgeUrlHelper::getRootItem() ? self::CHECK_OK : self::CHECK_WARNING;
         $this->addResult('system', 'Root item', $result, JText::_('CHECK_ROOT_ITEM'));
     }
     $result = self::checkWritable($application->getCfg('tmp_path'));
     $this->addResult('system', 'Temporary path writable', $result, JText::_('CHECK_TMP'));
     $result = self::checkWritable($application->getCfg('log_path'));
     $this->addResult('system', 'Log path writable', $result, JText::_('CHECK_LOG'));
     $result = self::checkWritable(JPATH_SITE . '/cache');
     $this->addResult('system', 'Cache writable', $result, JText::_('CHECK_CACHE'));
     return;
 }
예제 #7
0
 /**
  * Method to set a redirect for later redirection
  *
  * @param string $redirect
  * @param int    $max_redirects
  *
  * @return bool
  */
 public function setRedirect($redirect = null, $max_redirects = 1)
 {
     // Do not redirect if the maximum redirect-count is reached
     if ($this->isMaxRedirect($redirect, $max_redirects) == true) {
         $this->debug->warning('Maximum redirects of ' . $max_redirects . ' reached');
         return false;
     }
     // Strip the base-path from the URL
     $menuitem = MageBridgeUrlHelper::getRootItem();
     if (empty($menuitem)) {
         $menuitem = MageBridgeUrlHelper::getCurrentItem();
     }
     if (!empty($menuitem)) {
         $root_path = str_replace('/', '\\/', $menuitem->route);
         $redirect = preg_replace('/^\\//', '', $redirect);
         $redirect = preg_replace('/^' . $root_path . '/', '', $redirect);
     }
     // When the URL doesnt start with HTTP or HTTPS, assume it is still the original Magento request
     if (!preg_match('/^(http|https):\\/\\//', $redirect)) {
         $redirect = JURI::base() . 'index.php?option=com_magebridge&view=root&request=' . $redirect;
     }
     // Replace the System URL for the site
     if ($this->app->isSite() && preg_match('/index.php\\?(.*)$/', $redirect, $match)) {
         $redirect = str_replace($match[0], preg_replace('/^\\//', '', MageBridgeHelper::filterUrl($match[0])), $redirect);
     }
     $this->debug->warning('Redirect set to ' . $redirect);
     $this->redirectUrl = $redirect;
     return true;
 }
예제 #8
0
 /**
  * Return a list of Root Menu Items associated with the current Root Menu Item
  *
  * @access public
  *
  * @param null
  *
  * @return array
  */
 public static function getRootItemAssociations()
 {
     $assoc = JLanguageAssociations::isEnabled();
     if ($assoc == false) {
         return false;
     }
     $root_item = MageBridgeUrlHelper::getRootItem();
     if ($root_item == false) {
         return false;
     }
     $associations = MenusHelper::getAssociations($root_item->id);
     return $associations;
 }
예제 #9
0
 /**
  * Method to check a specific configuratione-element
  * 
  * @param string $element
  * @param string $value
  * @return string|null
  */
 public static function check($element, $value = null)
 {
     // Reset an empty value to its original value
     if (empty($value)) {
         $value = MagebridgeModelConfig::load($element);
     }
     // Check for settings that should not be kept empty
     $nonempty = array('host', 'website', 'api_user', 'api_key');
     if (MagebridgeModelConfig::allEmpty() == false && in_array($element, $nonempty) && empty($value)) {
         return JText::sprintf('Setting "%s" is empty - Please configure it below', JText::_($element));
     }
     // Check host
     if ($element == 'host') {
         if (preg_match('/([^a-zA-Z0-9\\.\\-\\_\\:]+)/', $value) == true) {
             return JText::_('Hostname contains illegal characters. Note that a hostname is not an URL, but only a fully qualified domainname.');
         } else {
             if (gethostbyname($value) == $value && !preg_match('/([0-9\\.]+)/', $value)) {
                 return JText::sprintf('DNS lookup of hostname %s failed', $value);
             } else {
                 if (MagebridgeModelConfig::load('api_widgets') == true) {
                     $bridge = MageBridgeModelBridge::getInstance();
                     $data = $bridge->build();
                     if (empty($data)) {
                         $url = $bridge->getMagentoBridgeUrl();
                         return JText::sprintf('Unable to open a connection to <a href="%s" target="_new">%s</a>', $url, $url);
                     }
                 }
             }
         }
     }
     // Check supportkey
     if ($element == 'supportkey' && empty($value)) {
         return JText::sprintf('Please configure your support-key. Your support-key can be obtained from %s', MageBridgeHelper::getHelpText('subscriptions'));
     }
     // Check API widgets
     if ($element == 'api_widgets' && $value != 1) {
         return JText::_('API widgets are disabled');
     }
     // Check offline
     if ($element == 'offline' && $value == 1) {
         return JText::_('Bridge is disabled through settings');
     }
     // Check website
     if ($element == 'website' && !empty($value)) {
         if (is_numeric($value) == false) {
             return JText::sprintf('Website ID needs to be a numeric value. Current value is "%s"', $value);
         }
     }
     /**
     if ($element == 'storeview' && !empty($value)) {
     	if ( preg_match( '/([a-zA-Z0-9\.\-\_]+)/', $value ) == false ) {
     		return JText::_( 'Store-name contains illegal characters: '.$value );
     	} else {
     		$storeviews = MagebridgeModelConfig::getStoreNames();
     		if (!is_array($storeviews) && $storeviews != 0) {
     			return JText::_($storeviews);
     
     		} else {
     
     			$match = false;
     			if (!empty($storeviews)) {
     				foreach ($storeviews as $storeview) {
     					if ($storeview['value'] == $value) {
     						$match = true;
     						break;
     					}
     				}
     			}
     
     			if ($match == false) {
     				$msg = JText::sprintf( 'Store-names detected, but "%s" is not one of them', $value );
     				return $msg;
     			}
     		}
     	}
     }
     */
     // Check basedir
     if ($element == 'basedir') {
         if (empty($value)) {
             return null;
         }
         if (preg_match('/([a-zA-Z0-9\\.\\-\\_]+)/', $value) == false) {
             return JText::_('Basedir contains illegal characters');
         }
         $root = MageBridgeUrlHelper::getRootItem();
         $joomla_host = JFactory::getURI()->toString(array('host'));
         $magento_host = MagebridgeModelConfig::load('host');
         // Check whether the Magento basedir conflicts with the MageBridge alias
         if (!empty($root) && !empty($root->route) && $root->route == $value && $joomla_host == $magento_host) {
             return JText::_('Magento basedir is same as MageBridge alias, which is not possible');
         }
     }
     return null;
 }
예제 #10
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;
 }
예제 #11
0
 /**
  * Helper-method to set the debugging information
  *
  * @param null
  * @return null
  */
 public static function addDebug()
 {
     // Do not add debugging information when posting or redirecting
     if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
         return false;
     }
     // Only continue when debugging is enabled
     if (MageBridgeModelDebug::isDebug() && MagebridgeModelConfig::load('debug_bar')) {
         // Load variables
         $debug = MageBridgeModelDebug::getInstance();
         $bridge = MageBridgeModelBridge::getInstance();
         $register = MageBridgeModelRegister::getInstance();
         $original_request = MageBridgeUrlHelper::getOriginalRequest();
         $request = MageBridgeUrlHelper::getRequest();
         // Debug the MageBridge request
         if (MagebridgeModelConfig::load('debug_bar_request')) {
             $url = $bridge->getMagentoUrl() . $request;
             if (empty($request)) {
                 $request = '[empty]';
             }
             $Itemid = JFactory::getApplication()->input->getInt('Itemid');
             $root_item = MageBridgeUrlHelper::getRootItem();
             $root_item_id = $root_item ? $root_item->id : false;
             $menu_message = 'Menu-Item: ' . $Itemid;
             if ($root_item_id == $Itemid) {
                 $menu_message .= ' (Root Menu-Item)';
             }
             JError::raiseNotice('notice', $menu_message);
             JError::raiseNotice('notice', JText::sprintf('Page request: %s', !empty($request) ? $request : '[empty]'));
             JError::raiseNotice('notice', JText::sprintf('Original request: %s', $bridge->getSessionData('request')));
             JError::raiseNotice('notice', JText::sprintf('Received request: %s', $bridge->getSessionData('request')));
             JError::raiseNotice('notice', JText::sprintf('Received referer: %s', $bridge->getSessionData('referer')));
             JError::raiseNotice('notice', JText::sprintf('Current referer: %s', $bridge->getHttpReferer()));
             JError::raiseNotice('notice', JText::sprintf('Magento request: <a href="%s" target="_new">%s</a>', $url, $url));
             JError::raiseNotice('notice', JText::sprintf('Magento session: %s', $bridge->getMageSession()));
             if (MageBridgeTemplateHelper::isCategoryPage()) {
                 JError::raiseNotice('notice', JText::_('MageBridgeTemplateHelper::isCategoryPage() == TRUE'));
             }
             if (MageBridgeTemplateHelper::isProductPage()) {
                 JError::raiseNotice('notice', JText::_('MageBridgeTemplateHelper::isProductPage() == TRUE'));
             }
             if (MageBridgeTemplateHelper::isCatalogPage()) {
                 JError::raiseNotice('notice', JText::_('MageBridgeTemplateHelper::isCatalogPage() == TRUE'));
             }
             if (MageBridgeTemplateHelper::isCustomerPage()) {
                 JError::raiseNotice('notice', JText::_('MageBridgeTemplateHelper::isCustomerPage() == TRUE'));
             }
             if (MageBridgeTemplateHelper::isCartPage()) {
                 JError::raiseNotice('notice', JText::_('MageBridgeTemplateHelper::isCartPage() == TRUE'));
             }
             if (MageBridgeTemplateHelper::isCheckoutPage()) {
                 JError::raiseNotice('notice', JText::_('MageBridgeTemplateHelper::isCheckoutPage() == TRUE'));
             }
             if (MageBridgeTemplateHelper::isSalesPage()) {
                 JError::raiseNotice('notice', JText::_('MageBridgeTemplateHelper::isSalesPage() == TRUE'));
             }
             if (MageBridgeTemplateHelper::isHomePage()) {
                 JError::raiseNotice('notice', JText::_('MageBridgeTemplateHelper::isHomePage() == TRUE'));
             }
         }
         // Add store information
         if (MagebridgeModelConfig::load('debug_bar_store')) {
             JError::raiseNotice('notice', JText::sprintf('Magento store loaded: %s (%s)', $bridge->getSessionData('store_name'), $bridge->getSessionData('store_code')));
         }
         // Add category information
         $category_id = $bridge->getSessionData('current_category_id');
         if ($category_id > 0) {
             JError::raiseNotice('notice', JText::sprintf('Magento category: %d', $category_id));
         }
         // Add product information
         $product_id = $bridge->getSessionData('current_product_id');
         if ($product_id > 0) {
             JError::raiseNotice('notice', JText::sprintf('Magento product: %d', $product_id));
         }
         // Add information on bridge-segments
         if (MagebridgeModelConfig::load('debug_bar_parts')) {
             $i = 0;
             $segments = $register->getRegister();
             foreach ($segments as $segment) {
                 if (isset($segment['status']) && $segment['status'] == 1) {
                     switch ($segment['type']) {
                         case 'breadcrumbs':
                         case 'meta':
                         case 'debug':
                         case 'headers':
                         case 'events':
                             JError::raiseNotice('notice', JText::sprintf('Magento [%d]: %s', $i, ucfirst($segment['type'])));
                             break;
                         case 'api':
                             JError::raiseNotice('notice', JText::sprintf('Magento [%d]: API resource "%s"', $i, $segment['name']));
                             break;
                         case 'block':
                             JError::raiseNotice('notice', JText::sprintf('Magento [%d]: Block "%s"', $i, $segment['name']));
                             break;
                         default:
                             $name = isset($segment['name']) ? $segment['name'] : null;
                             $type = isset($segment['type']) ? $segment['type'] : null;
                             JError::raiseNotice('notice', JText::sprintf('Magento [%d]: type %s, name %s', $i, $type, $name));
                             break;
                     }
                     $i++;
                 }
             }
         }
     }
 }
예제 #12
0
 public function addDebug()
 {
     if (MageBridgeModelDebug::isDebug() && MagebridgeModelConfig::load('debug_bar')) {
         $debug = MageBridgeModelDebug::getInstance();
         $bridge = MageBridgeModelBridge::getInstance();
         $register = MageBridgeModelRegister::getInstance();
         $request = MageBridgeUrlHelper::getRequest();
         if (MagebridgeModelConfig::load('debug_bar_request')) {
             $url = $bridge->getMagentoUrl() . $request;
             if (empty($request)) {
                 $request = '[empty]';
             }
             $Itemid = JRequest::getInt('Itemid');
             $root_item = MageBridgeUrlHelper::getRootItem();
             $root_item_id = $root_item ? $root_item->id : false;
             $menu_message = 'Menu-Item: ' . $Itemid;
             if ($root_item_id == $Itemid) {
                 $menu_message .= ' (Root Menu-Item)';
             }
             JError::raiseNotice('notice', $menu_message);
             JError::raiseNotice('notice', JText::sprintf('Page request: %s', !empty($request) ? $request : '[empty]'));
             JError::raiseNotice('notice', JText::sprintf('Received request: %s', $bridge->getMageConfig('request')));
             JError::raiseNotice('notice', JText::sprintf('Received referer: %s', $bridge->getMageConfig('referer')));
             JError::raiseNotice('notice', JText::sprintf('Current referer: %s', $bridge->getHttpReferer()));
             JError::raiseNotice('notice', JText::sprintf('Magento request: <a href="%s" target="_new">%s</a>', $url, $url));
             JError::raiseNotice('notice', JText::sprintf('Magento session: %s', $bridge->getMageSession()));
             if (MageBridgeTemplateHelper::isCategoryPage()) {
                 JError::raiseNotice('notice', JText::_('MageBridgeTemplateHelper::isCategoryPage() == TRUE'));
             }
             if (MageBridgeTemplateHelper::isProductPage()) {
                 JError::raiseNotice('notice', JText::_('MageBridgeTemplateHelper::isProductPage() == TRUE'));
             }
             if (MageBridgeTemplateHelper::isCatalogPage()) {
                 JError::raiseNotice('notice', JText::_('MageBridgeTemplateHelper::isCatalogPage() == TRUE'));
             }
             if (MageBridgeTemplateHelper::isCustomerPage()) {
                 JError::raiseNotice('notice', JText::_('MageBridgeTemplateHelper::isCustomerPage() == TRUE'));
             }
             if (MageBridgeTemplateHelper::isCartPage()) {
                 JError::raiseNotice('notice', JText::_('MageBridgeTemplateHelper::isCartPage() == TRUE'));
             }
             if (MageBridgeTemplateHelper::isCheckoutPage()) {
                 JError::raiseNotice('notice', JText::_('MageBridgeTemplateHelper::isCheckoutPage() == TRUE'));
             }
             if (MageBridgeTemplateHelper::isSalesPage()) {
                 JError::raiseNotice('notice', JText::_('MageBridgeTemplateHelper::isSalesPage() == TRUE'));
             }
             if (MageBridgeTemplateHelper::isHomePage()) {
                 JError::raiseNotice('notice', JText::_('MageBridgeTemplateHelper::isHomePage() == TRUE'));
             }
         }
         if (MagebridgeModelConfig::load('debug_bar_store')) {
             JError::raiseNotice('notice', JText::sprintf('Magento store loaded: %s', $bridge->getMageConfig('store_name')));
         }
         if (MagebridgeModelConfig::load('debug_bar_parts')) {
             $i = 0;
             foreach ($register->getRegister() as $segment) {
                 if (isset($segment['status']) && $segment['status'] == 1) {
                     switch ($segment['type']) {
                         case 'breadcrumbs':
                         case 'meta':
                         case 'debug':
                         case 'headers':
                         case 'events':
                             JError::raiseNotice('notice', JText::sprintf('Magento [%d]: %s', $i, ucfirst($segment['type'])));
                             break;
                         case 'api':
                             JError::raiseNotice('notice', JText::sprintf('Magento [%d]: API resource "%s"', $i, $segment['name']));
                             break;
                         case 'block':
                             JError::raiseNotice('notice', JText::sprintf('Magento [%d]: Block "%s"', $i, $segment['name']));
                             break;
                         default:
                             $name = isset($segment['name']) ? $segment['name'] : null;
                             $type = isset($segment['type']) ? $segment['type'] : null;
                             JError::raiseNotice('notice', JText::sprintf('Magento [%d]: type %s, name %s', $i, $type, $name));
                             break;
                     }
                     $i++;
                 }
             }
         }
         $this->assignRef('debug', $debug->getData());
     }
 }