Exemplo n.º 1
0
 public function getScript($block, $element, $url = null)
 {
     // Set the default AJAX-URL
     if (empty($url)) {
         $url = self::getUrl($block);
     }
     // Load ProtoType
     if (MageBridgeTemplateHelper::hasPrototypeJs() == true) {
         $script = "Event.observe(window,'load',function(){new Ajax.Updater('{$element}','{$url}',{method:'get'});});";
         // Load jQuery
     } else {
         if (JFactory::getApplication()->get('jquery') == true) {
             $script = "jQuery(document).ready(function(){\n" . "    jQuery('#" . $element . "').load('" . $url . "');" . "});\n";
             // Load MooTools (Joomla!)
         } else {
             if (MageBridgeHelper::isJoomla15()) {
                 JHTML::_('behavior.mootools');
                 $script = "window.addEvent('domready', function(){\n" . "    var MBajax = new Ajax( '" . $url . "', {onSuccess: function(r){\n" . "        \$('" . $element . "').innerHTML = r;\n" . "    }});\n" . "    MBajax.request();\n" . "});\n";
                 // Load MooTools (Joomla! 1.6)
             } else {
                 JHTML::_('behavior.mootools');
                 $script = "window.addEvent('domready', function(){\n" . "    var MBajax = new Request({\n" . "        url: '" . $url . "', \n" . "        onComplete: function(r){\n" . "            \$('" . $element . "').innerHTML = r;\n" . "        }\n" . "    }).send();\n" . "});\n";
             }
         }
     }
     return $script;
 }
Exemplo n.º 2
0
 public function display($tpl = null)
 {
     // Page title
     $this->setTitle('Updates');
     // Toolbar options
     JToolBarHelper::custom('refresh', 'preview.png', 'preview_f2.png', 'Refresh', false);
     // Add jQuery for selection effects
     MageBridgeTemplateHelper::load('jquery');
     JHTML::script('media/com_magebridge/js/backend-update.js');
     $update = MAGEBRIDGE_UPDATE_NOTAVAILABLE;
     $component_version = null;
     $data = MageBridgeUpdateHelper::getData();
     foreach ($data as $index => $extension) {
         if (empty($extension['latest_version'])) {
             continue;
         }
         if ($extension['current_version'] != $extension['latest_version']) {
             $update = MAGEBRIDGE_UPDATE_AVAILABLE;
             break;
         } else {
             $update = MAGEBRIDGE_UPDATE_NOTNEEDED;
         }
         $data[$index] = $extension;
     }
     if ($update != MAGEBRIDGE_UPDATE_NOTAVAILABLE) {
         JToolBarHelper::custom('update', 'download.png', 'download_f2.png', 'Update', false);
     }
     if ($update == MAGEBRIDGE_UPDATE_AVAILABLE) {
         JError::raiseNotice('UPDATE', 'There are new updates available');
     }
     $this->assignRef('data', $data);
     $this->assignRef('update', $update);
     parent::display($tpl);
 }
Exemplo n.º 3
0
 /**
  * Method to display the requested view
  */
 public function display($tpl = null)
 {
     // Set which block to display
     $this->setBlock('content');
     // Build the bridge right away, because we need data from Magento
     $block = $this->build();
     // Determine which template to display
     if (MageBridgeTemplateHelper::isProductPage()) {
         $tpl = 'product';
     } else {
         if (MageBridgeTemplateHelper::isCategoryPage()) {
             $tpl = 'category';
         }
     }
     // Output component-only pages
     $bridge = MageBridge::getBridge();
     if ($bridge->isAjax()) {
         print $block;
         JFactory::getApplication()->close();
     }
     // Add controller information
     $mageConfig = $bridge->getMageConfig();
     $this->mage_controller = isset($mageConfig['controller']) ? $mageConfig['controller'] : null;
     $this->mage_action = isset($mageConfig['action']) ? $mageConfig['action'] : null;
     // Assemble the page class
     $contentClass = array('magebridge-content');
     if (!empty($mageController)) {
         $contentClass[] = 'magebridge-' . $mageController;
     }
     if (!empty($mageAction)) {
         $contentClass[] = 'magebridge-' . $mageController . '-' . $mageAction;
     }
     $this->content_class = $contentClass;
     parent::display($tpl);
 }
Exemplo n.º 4
0
 /**
  * Method to get the meta-data
  *
  * @return array
  */
 public function getRequestData()
 {
     // Compile the meta-data
     if (empty($this->_meta_data) || !is_array($this->_meta_data)) {
         $application = JFactory::getApplication();
         $input = $application->input;
         $user = JFactory::getUser();
         $uri = JURI::getInstance();
         $session = JFactory::getSession();
         $config = JFactory::getConfig();
         $storeHelper = MageBridgeStoreHelper::getInstance();
         $bridge = MageBridgeModelBridge::getInstance();
         $app_type = $storeHelper->getAppType();
         $app_value = $storeHelper->getAppValue();
         $arguments = array('api_session' => $bridge->getApiSession(), 'api_user' => MageBridgeEncryptionHelper::encrypt(MagebridgeModelConfig::load('api_user')), 'api_key' => MageBridgeEncryptionHelper::encrypt(MagebridgeModelConfig::load('api_key')), 'api_url' => JURI::root() . 'component/magebridge/?controller=jsonrpc&task=call', 'app' => $application->getClientId(), 'app_type' => $app_type, 'app_value' => $app_value, 'storeview' => MagebridgeModelConfig::load('storeview'), 'storegroup' => MagebridgeModelConfig::load('storegroup'), 'website' => MagebridgeModelConfig::load('website'), 'customer_group' => MagebridgeModelConfig::load('customer_group'), 'joomla_url' => $bridge->getJoomlaBridgeUrl(), 'joomla_sef_url' => $bridge->getJoomlaBridgeSefUrl(), 'joomla_sef_suffix' => (int) MageBridgeUrlHelper::hasUrlSuffix(), 'joomla_user_email' => $application->isSite() && !empty($user->email) ? $user->email : null, 'joomla_current_url' => $uri->current(), 'modify_url' => MagebridgeModelConfig::load('modify_url'), 'enforce_ssl' => MagebridgeModelConfig::load('enforce_ssl'), 'has_ssl' => (int) $uri->isSSL(), 'payment_urls' => MagebridgeModelConfig::load('payment_urls'), 'enable_messages' => MagebridgeModelConfig::load('enable_messages'), 'joomla_session' => session_id(), 'joomla_conf_caching' => $config->get('caching', 60), 'joomla_conf_lifetime' => $config->get('lifetime', 60) * 60, 'magento_session' => $bridge->getMageSession(), 'magento_persistent_session' => $bridge->getMagentoPersistentSession(), 'magento_user_allowed_save_cookie' => isset($_COOKIE['user_allowed_save_cookie']) ? $_COOKIE['user_allowed_save_cookie'] : null, 'request_uri' => MageBridgeUrlHelper::getRequest(), 'request_id' => md5(JURI::current() . serialize($input->get->getArray())), 'post' => !empty($_POST) ? $_POST : null, 'http_referer' => $bridge->getHttpReferer(), 'http_host' => $uri->toString(array('host')), 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '', 'remote_addr' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '', 'supportkey' => MagebridgeModelConfig::load('supportkey'), 'debug' => (int) MageBridgeModelDebug::isDebug(), 'debug_level' => MagebridgeModelConfig::load('debug_level'), 'debug_display_errors' => MagebridgeModelConfig::load('debug_display_errors'), 'protocol' => MagebridgeModelConfig::load('protocol'), 'state' => 'initializing', 'ajax' => (int) $bridge->isAjax(), 'disable_css' => MageBridgeHelper::getDisableCss(), 'disable_js' => MageBridgeHelper::getDisableJs());
         if (MageBridgeTemplateHelper::isMobile()) {
             $arguments['theme'] = MagebridgeModelConfig::load('mobile_magento_theme');
         } else {
             $arguments['theme'] = MagebridgeModelConfig::load('magento_theme');
         }
         foreach ($arguments as $name => $value) {
             if (is_string($value)) {
                 $arguments[$name] = MageBridgeEncryptionHelper::base64_encode($value);
             }
         }
         $this->_meta_data = $arguments;
     }
     return $this->_meta_data;
 }
 /**
  * Event onAfterDispatch
  *
  * @access public
  * @param null
  * @return null
  */
 public function onAfterDispatch()
 {
     // Don't do anything if MageBridge is not enabled
     if ($this->isEnabled() == false) {
         return false;
     }
     // Don't do anything in other applications than the frontend
     if (JFactory::getApplication()->isSite() == false) {
         return false;
     }
     // Read template-parameters and load specific stylesheet
     $application = JFactory::getApplication();
     // Read the template-related files
     $ini = JPATH_THEMES . DS . $application->getTemplate() . DS . 'params.ini';
     $ini_content = @file_get_contents($ini);
     $xml = JPATH_THEMES . DS . $application->getTemplate() . DS . 'templateDetails.xml';
     // WARP-usage of "config" file
     if (!empty($ini_content)) {
         // Create the parameters object
         jimport('joomla.html.parameter');
         $params = new JParameter($ini_content, $xml);
         // Load a specific stylesheet per color
         $color = $params->get('colorStyle');
         if (!empty($color)) {
             MageBridgeTemplateHelper::load('css', 'color-' . $color . '.css');
         }
     }
     // Check whether ProtoType is loaded, and add some fixes
     if (MageBridgeTemplateHelper::hasPrototypeJs()) {
         $document = JFactory::getDocument();
         $document->addStyleDeclaration('div.fusion-submenu-wrapper { margin-top: -12px !important; }');
     }
 }
 public function onPrepareModuleList(&$modules)
 {
     foreach ($modules as $id => $module) {
         if (MageBridgeTemplateHelper::allowPosition($module->position) == false) {
             unset($modules[$id]);
             continue;
         }
     }
 }
Exemplo n.º 7
0
 /**
  * Event onAfterDispatch
  *
  * @access public
  * @param null
  * @return null
  */
 public function onAfterDispatch()
 {
     // Don't do anything if MageBridge is not enabled
     if ($this->isEnabled() == false) {
         return false;
     }
     // Load the application
     $application = JFactory::getApplication();
     // Don't do anything in other applications than the frontend
     if ($application->isSite() == false) {
         return false;
     }
     // Load the blacklist settings
     $blacklist = JFactory::getConfig()->get('magebridge.script.blacklist');
     if (empty($blacklist)) {
         $blacklist = array();
     }
     $blacklist[] = '/rokbox.js';
     $blacklist[] = 'gantry/js/browser-engines.js';
     JFactory::getConfig()->set('magebridge.script.blacklist', $blacklist);
     // Load the whitelist settings
     $whitelist = JFactory::getConfig()->get('magebridge.script.whitelist');
     if (empty($whitelist)) {
         $whitelist = array();
     }
     JFactory::getConfig()->set('magebridge.script.whitelist', $whitelist);
     // Read the template-related files
     $ini = JPATH_THEMES . '/' . $application->getTemplate() . '/params.ini';
     $ini_content = @file_get_contents($ini);
     $xml = JPATH_THEMES . '/' . $application->getTemplate() . '/templateDetails.xml';
     // WARP-usage of "config" file
     if (!empty($ini_content)) {
         // Create the parameters object
         jimport('joomla.html.parameter');
         $params = new JParameter($ini_content, $xml);
         // Load a specific stylesheet per color
         $color = $params->get('colorStyle');
         if (!empty($color)) {
             MageBridgeTemplateHelper::load('css', 'color-' . $color . '.css');
         }
     }
     // Check whether ProtoType is loaded, and add some fixes
     if (MageBridgeTemplateHelper::hasPrototypeJs()) {
         $document = JFactory::getDocument();
         if ($this->getParams()->get('fix_submenu_wrapper', 1)) {
             $document->addStyleDeclaration('div.fusion-submenu-wrapper { margin-top: -12px !important; }');
         }
         if ($this->getParams()->get('fix_body_zindex', 1)) {
             $document->addStyleDeclaration('div#rt-body-surround { z-index:0 !important; }');
         }
         $document->addStyleDeclaration('div.style-panel-container {left: -126px;}');
     }
 }
 public function fetchElement()
 {
     $options = null;
     if (MagebridgeModelConfig::load('api_widgets') == true) {
         $cache = JFactory::getCache('com_magebridge_admin');
         $cache->setCaching(0);
         $options = $cache->call(array('JElementStylesheets', 'getResult'));
         if (empty($options) && !is_array($options)) {
             MageBridgeModelDebug::getInstance()->trace('Unable to obtain MageBridge API Widget "stylesheets"', $options);
         }
     }
     MageBridgeTemplateHelper::load('jquery');
     JHTML::script('backend-customoptions.js', 'media/com_magebridge/js/');
     $html = '';
     $html .= JElementStylesheets::getRadioHTML();
     $html .= '<p/>';
     $html .= JElementStylesheets::getSelectHTML($options);
     return $html;
 }
Exemplo n.º 9
0
 /**
  * Method to get the output of this element
  *
  * @param null
  * @return string
  */
 protected function getInput()
 {
     $name = $this->name;
     $fieldName = $name;
     $value = $this->value;
     $options = null;
     if (MagebridgeModelConfig::load('api_widgets') == true) {
         $cache = JFactory::getCache('com_magebridge.admin');
         $options = $cache->call(array('MagebridgeFormFieldStylesheets', 'getResult'));
         if (empty($options) && !is_array($options)) {
             MageBridgeModelDebug::getInstance()->trace('Unable to obtain MageBridge API Widget "stylesheets"', $options);
         }
     }
     MageBridgeTemplateHelper::load('jquery');
     JHTML::script('media/com_magebridge/js/backend-customoptions.js');
     $html = '';
     $html .= self::getRadioHTML();
     $html .= '<br/><br/>';
     $html .= self::getSelectHTML($options);
     return $html;
 }
Exemplo n.º 10
0
 /**
  * Helper-method to return the right AJAX-script
  *
  * @param string $block
  * @param string $element
  * @param string $url
  * @return bool
  */
 public static function getScript($block, $element, $url = null)
 {
     // Set the default AJAX-URL
     if (empty($url)) {
         $url = self::getUrl($block);
     }
     // Load ProtoType
     if (MageBridgeTemplateHelper::hasPrototypeJs() == true) {
         $script = "Event.observe(window,'load',function(){new Ajax.Updater('{$element}','{$url}',{method:'get'});});";
         // Load jQuery
     } else {
         if (JFactory::getApplication()->get('jquery') == true) {
             $script = "jQuery(document).ready(function(){\n" . "\tjQuery('#" . $element . "').load('" . $url . "');" . "});\n";
             // Load jQuery ourselves
         } else {
             YireoHelper::jquery();
             $script = "jQuery(document).ready(function(){\n" . "\tjQuery('#" . $element . "').load('" . $url . "');" . "});\n";
         }
     }
     return $script;
 }
Exemplo n.º 11
0
 public function display($tpl = null)
 {
     // Set which block to display
     $this->setBlock('content');
     // Build the bridge right away, because we need data from Magento
     $this->build();
     // Determine which template to display
     if (MageBridgeTemplateHelper::isProductPage()) {
         $tpl = 'product';
     } else {
         if (MageBridgeTemplateHelper::isCategoryPage()) {
             $tpl = 'category';
         }
     }
     // Output component-only pages
     $bridge = MageBridge::getBridge();
     if ($bridge->isAjax()) {
         print $this->block;
         JFactory::getApplication()->close();
     }
     parent::display($tpl);
 }
Exemplo n.º 12
0
 /**
  * Event onAfterRender
  *
  * @access public
  * @param null
  * @return null
  */
 public function onAfterRender()
 {
     // Don't do anything if MageBridge is not enabled
     if ($this->isEnabled() == false) {
         return false;
     }
     $disable_js_mootools = MagebridgeModelConfig::load('disable_js_mootools');
     if (MageBridgeTemplateHelper::hasPrototypeJs() && $disable_js_mootools == 1) {
         $body = JResponse::getBody();
         $body = preg_replace('/Warp.Settings(.*);/', '', $body);
         JResponse::setBody($body);
     }
 }
Exemplo n.º 13
0
 function renderModule($module, $attribs = array())
 {
     static $chrome;
     global $mainframe, $option;
     if (is_object($module) && !empty($module->position) && MageBridgeTemplateHelper::allowPosition($module->position) == false) {
         return null;
     }
     $scope = $mainframe->scope;
     //record the scope
     $mainframe->scope = $module->module;
     //set scope to component name
     // Handle legacy globals if enabled
     if ($mainframe->getCfg('legacy')) {
         // Include legacy globals
         global $my, $database, $acl, $mosConfig_absolute_path;
         // Get the task variable for local scope
         $task = JRequest::getString('task');
         // For backwards compatibility extract the config vars as globals
         $registry =& JFactory::getConfig();
         foreach (get_object_vars($registry->toObject()) as $k => $v) {
             $name = 'mosConfig_' . $k;
             ${$name} = $v;
         }
         $contentConfig =& JComponentHelper::getParams('com_content');
         foreach (get_object_vars($contentConfig->toObject()) as $k => $v) {
             $name = 'mosConfig_' . $k;
             ${$name} = $v;
         }
         $usersConfig =& JComponentHelper::getParams('com_users');
         foreach (get_object_vars($usersConfig->toObject()) as $k => $v) {
             $name = 'mosConfig_' . $k;
             ${$name} = $v;
         }
     }
     // Get module parameters
     $params = new JParameter($module->params);
     // Get module path
     $module->module = preg_replace('/[^A-Z0-9_\\.-]/i', '', $module->module);
     $path = JPATH_BASE . DS . 'modules' . DS . $module->module . DS . $module->module . '.php';
     // Load the module
     if (!isset($module->user)) {
         $module->user = 0;
     }
     if (!$module->user && file_exists($path) && empty($module->content)) {
         $lang =& JFactory::getLanguage();
         $lang->load($module->module);
         $content = '';
         ob_start();
         require $path;
         $module->content = ob_get_contents() . $content;
         ob_end_clean();
     }
     // Load the module chrome functions
     if (!$chrome) {
         $chrome = array();
     }
     require_once JPATH_BASE . DS . 'templates' . DS . 'system' . DS . 'html' . DS . 'modules.php';
     $chromePath = JPATH_BASE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'modules.php';
     if (!isset($chrome[$chromePath])) {
         if (file_exists($chromePath)) {
             require_once $chromePath;
         }
         $chrome[$chromePath] = true;
     }
     //make sure a style is set
     if (!isset($attribs['style'])) {
         $attribs['style'] = 'none';
     }
     //dynamically add outline style
     if (JRequest::getBool('tp')) {
         $attribs['style'] .= ' outline';
     }
     foreach (explode(' ', $attribs['style']) as $style) {
         $chromeMethod = 'modChrome_' . $style;
         // Apply chrome and render module
         if (function_exists($chromeMethod)) {
             $module->style = $attribs['style'];
             ob_start();
             $chromeMethod($module, $params, $attribs);
             $module->content = ob_get_contents();
             ob_end_clean();
         }
     }
     $mainframe->scope = $scope;
     //revert the scope
     return $module->content;
 }
 *
 * @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';
$products = modMageBridgeProductsHelper::build($params);
// Add CSS and JavaScript
$templateHelper = new MageBridgeTemplateHelper();
if ($layout == 'slideshow') {
    if ($params->get('load_slideshow_jquery', 1) == 1) {
        $templateHelper->load('jquery');
    }
    if ($params->get('load_slideshow_jquery_easing', 1) == 1) {
        $templateHelper->load('jquery-easing');
    }
    if ($params->get('load_slideshow_jquery_cycle', 1) == 1) {
        $templateHelper->load('js', 'jquery/jquery.cycle.all.min.js');
    }
    if ($params->get('load_slideshow_css', 1) == 1) {
        $templateHelper->load('css', 'mod-products-slideshow.css');
    }
} else {
    if ($params->get('load_default_css', 1) == 1) {
Exemplo n.º 15
0
 /**
  * /**
  * Method to determine which JavaScript to use and which not
  *
  * @access private
  *
  * @param null
  *
  * @return null
  */
 private function handleJavaScript()
 {
     // Get MageBridge variables
     $disableJsMootools = $this->loadConfig('disable_js_mootools');
     $disableJsFootools = $this->loadConfig('disable_js_footools');
     $disableJsFrototype = $this->loadConfig('disable_js_frototype');
     $disable_js_jquery = $this->loadConfig('disable_js_jquery');
     $disable_js_prototype = $this->loadConfig('disable_js_prototype');
     $disable_js_custom = $this->loadConfig('disable_js_custom');
     $disable_js_all = $this->loadConfig('disable_js_all');
     $magento_js = MageBridgeModelBridgeHeaders::getInstance()->getScripts();
     $uri = JURI::getInstance();
     $foo_script = JURI::root(true) . '/media/com_magebridge/js/foo.js';
     $footools_script = JURI::root(true) . '/media/com_magebridge/js/footools.min.js';
     $frototype_script = JURI::root(true) . '/media/com_magebridge/js/frototype.min.js';
     $base_url = $this->getBaseUrl();
     $base_js_url = $this->getBaseJsUrl();
     // Parse the disable_js_custom string into an array
     $disable_js_custom = explode(',', $disable_js_custom);
     foreach ($disable_js_custom as $index => $script) {
         $script = trim($script);
         if (!empty($script)) {
             $disable_js_custom[$index] = $script;
         }
     }
     // Fetch the body
     $body = JResponse::getBody();
     // Determine whether ProtoType is loaded
     $has_prototype = MageBridgeTemplateHelper::hasPrototypeJs();
     if ($has_prototype == false) {
         if (stristr($body, '/js/protoaculous') || stristr($body, '/js/protoculous') || stristr($body, '/prototype.js')) {
             $has_prototype = true;
         }
     }
     // Load the whitelist
     $whitelist = JFactory::getConfig()->get('magebridge.script.whitelist');
     if (!is_array($whitelist)) {
         $whitelist = array();
     }
     // Add some items to the whitelist
     if ($disable_js_jquery == false) {
         $whitelist[] = 'media/system/js/calendar.js';
         $whitelist[] = 'media/system/js/calendar-setup.js';
         $whitelist[] = '/com_jce/';
         $whitelist[] = '/footools.js';
         $whitelist[] = 'www.googleadservices.com';
         $whitelist[] = 'media/jui/js';
         $whitelist[] = 'protostar/js/template.js';
     }
     // Load the blacklist
     $blacklist = JFactory::getConfig()->get('magebridge.script.blacklist');
     // Only parse the body, if MageBridge has loaded the ProtoType library and only if configured
     if ($has_prototype == true && ($disable_js_all > 0 || $disableJsMootools == 1 || !empty($disable_js_custom))) {
         // Disable MooTools (and caption) and replace it with FooTools
         if ($disableJsMootools == 1 && $disableJsFootools == 0) {
             $this->console[] = 'MageBridge removed MooTools core and replaced it with FooTools';
             $footools_tag = '<script type="text/javascript" src="' . $footools_script . '"></script>';
             $body = preg_replace('/\\<script/', $footools_tag . "\n" . '<script ', $body, 1);
         }
         // Find all script tags
         preg_match_all('/\\<script([^<]+)\\>\\<\\/script\\>/', $body, $tags);
         $commented = array();
         foreach ($tags[0] as $tag) {
             // Filter the src="" attribute
             preg_match('/src=([\\"\']{1})([^\\"\']+)/', $tag, $src);
             if (is_array($src) && !empty($src[2])) {
                 $script = $src[2];
             } else {
                 continue;
             }
             // Load the whitelist
             if (!empty($whitelist) && is_array($whitelist)) {
                 $match = false;
                 foreach ($whitelist as $w) {
                     if (stristr($script, $w)) {
                         $match = true;
                         break;
                     }
                 }
                 if ($match == true) {
                     continue;
                 }
             }
             // If this looks like a jQuery script, skip it
             if (stristr($script, 'jquery') && $disable_js_jquery == 0) {
                 continue;
             }
             // If this looks like a ProtoType script, skip it
             if ((stristr($script, 'scriptaculous') || stristr($script, 'prototype')) && $disable_js_prototype == 0) {
                 continue;
             }
             // If this looks like a MageBridge script, skip it
             if (stristr($script, 'com_magebridge')) {
                 continue;
             }
             // Skip URLs that seem to belong to Magento
             if (!empty($base_url) && (strstr($script, 'http://' . $base_url) || strstr($script, 'https://' . $base_url))) {
                 continue;
             } else {
                 if (!empty($base_js_url) && (strstr($script, 'http://' . $base_js_url) || strstr($script, 'https://' . $base_js_url))) {
                     continue;
                     // Skip Magento frontend scripts
                 } else {
                     if (preg_match('/\\/skin\\/frontend\\//', $script)) {
                         continue;
                     } else {
                         // Do some more complex tests
                         $skip = false;
                         // Loop through the whitelist
                         if (!empty($magento_js)) {
                             foreach ($magento_js as $js) {
                                 if (strstr($script, $js)) {
                                     $skip = true;
                                     break;
                                 }
                             }
                         }
                         if ($skip == true) {
                             continue;
                         }
                         // Loop through the known Magento scripts
                         if (!empty($magento_js)) {
                             foreach ($magento_js as $js) {
                                 if (strstr($script, $js)) {
                                     $skip = true;
                                     break;
                                 }
                             }
                         }
                         if ($skip == true) {
                             continue;
                         }
                     }
                 }
             }
             // Decide whether to remove this script by default
             if ($disable_js_all == 1 || $disable_js_all == 3) {
                 $remove = true;
             } else {
                 $remove = false;
             }
             // Load the blacklist
             if (!empty($blacklist) && is_array($blacklist)) {
                 foreach ($blacklist as $b) {
                     if (preg_match('/' . str_replace('/', '\\/', $js) . '$/', $b)) {
                         $remove = true;
                         break;
                     }
                 }
             }
             // Scan for exceptions
             if ($disable_js_all > 1 && !empty($disable_js_custom)) {
                 foreach ($disable_js_custom as $js) {
                     if (preg_match('/' . str_replace('/', '\\/', $js) . '$/', $script)) {
                         $remove = $disable_js_all == 2 ? true : false;
                         break;
                     }
                 }
                 // Disable MooTools
             } else {
                 if ($disableJsMootools == 1) {
                     $mootools_scripts = array('media/system/js/modal.js', 'media/system/js/validate.js', 'beez_20/javascript/hide.js', 'md_stylechanger.js', 'media/com_finder/js/autocompleter.js');
                     if (MageBridgeHelper::isJoomla25()) {
                         $mootools_scripts[] = 'media/system/js/caption.js';
                     }
                     if (preg_match('/mootools/', $script)) {
                         $remove = true;
                     }
                     foreach ($mootools_scripts as $js) {
                         if (preg_match('/' . str_replace('/', '\\/', $js) . '$/', $script)) {
                             $remove = true;
                         }
                     }
                 }
             }
             // Remove this script
             if ($remove) {
                 // Decide how to remove the scripts
                 $filter = $this->getParam('filter_js', 'foo');
                 // Remove the script entirely from the page
                 if ($filter == 'remove') {
                     $body = str_replace($tag . "\n", '', $body);
                     $body = str_replace($tag, '', $body);
                     // Comment the tag
                 } else {
                     if ($filter == 'comment') {
                         if (!in_array($tag, $commented)) {
                             $commented[] = $tag;
                             $body = str_replace($tag, '<!-- MB: ' . $tag . ' -->', $body);
                         }
                         // Replace the script with the foo-script
                     } else {
                         $this->console[] = 'MageBridge removed ' . $script;
                         $body = str_replace($script, $foo_script, $body);
                     }
                 }
             }
         }
         // Log to the JavaScript Console
         if (MagebridgeModelDebug::isDebug() == true && $this->loadConfig('debug_console') == 1) {
             $console = '';
             foreach ($this->console as $c) {
                 $console .= 'console.warn("' . $c . '");';
             }
             $script = "<script type=\"text/javascript\">\n" . $console . "\n</script>";
             $body = str_replace('<head>', '<head>' . $script, $body);
         }
         // Set the body
         JResponse::setBody($body);
     } else {
         // Add FrotoType to the page
         if ($disableJsFrototype == 0) {
             $body = JResponse::getBody();
             $frototype_tag = '<script type="text/javascript" src="' . $frototype_script . '"></script>';
             $body = preg_replace('/\\<script/', $frototype_tag . "\n" . '<script ', $body, 1);
             JResponse::setBody($body);
         }
     }
 }
Exemplo n.º 16
0
 public static function loadJquery()
 {
     return MageBridgeTemplateHelper::load('jquery');
 }
Exemplo n.º 17
0
 /**
  * Render the module.
  *
  * @param   object  $module   A module object.
  * @param   array   $attribs  An array of attributes for the module (probably from the XML).
  *
  * @return  string  The HTML content of the module output.
  *
  * @since   11.1
  */
 public static function renderModule($module, $attribs = array())
 {
     static $chrome;
     if (is_object($module) && isset($module->position) && MageBridgeTemplateHelper::allowPosition($module->position) == false) {
         return null;
     }
     if (constant('JDEBUG')) {
         JProfiler::getInstance('Application')->mark('beforeRenderModule ' . $module->module . ' (' . $module->title . ')');
     }
     $app = JFactory::getApplication();
     // Record the scope.
     $scope = $app->scope;
     // Set scope to component name
     $app->scope = $module->module;
     // Get module parameters
     $params = new JRegistry();
     $params->loadString($module->params);
     // Get module path
     $module->module = preg_replace('/[^A-Z0-9_\\.-]/i', '', $module->module);
     $path = JPATH_BASE . '/modules/' . $module->module . '/' . $module->module . '.php';
     // Load the module
     // $module->user is a check for 1.0 custom modules and is deprecated refactoring
     if (empty($module->user) && file_exists($path)) {
         $lang = JFactory::getLanguage();
         // 1.5 or Core then 1.6 3PD
         $lang->load($module->module, JPATH_BASE, null, false, false) || $lang->load($module->module, dirname($path), null, false, false) || $lang->load($module->module, JPATH_BASE, $lang->getDefault(), false, false) || $lang->load($module->module, dirname($path), $lang->getDefault(), false, false);
         $content = '';
         ob_start();
         include $path;
         $module->content = ob_get_contents() . $content;
         ob_end_clean();
     }
     // Load the module chrome functions
     if (!$chrome) {
         $chrome = array();
     }
     include_once JPATH_THEMES . '/system/html/modules.php';
     $chromePath = JPATH_THEMES . '/' . $app->getTemplate() . '/html/modules.php';
     if (!isset($chrome[$chromePath])) {
         if (file_exists($chromePath)) {
             include_once $chromePath;
         }
         $chrome[$chromePath] = true;
     }
     // Make sure a style is set
     if (!isset($attribs['style'])) {
         $attribs['style'] = 'none';
     }
     // Dynamically add outline style
     if (JRequest::getBool('tp') && JComponentHelper::getParams('com_templates')->get('template_positions_display')) {
         $attribs['style'] .= ' outline';
     }
     foreach (explode(' ', $attribs['style']) as $style) {
         $chromeMethod = 'modChrome_' . $style;
         // Apply chrome and render module
         if (function_exists($chromeMethod)) {
             $module->style = $attribs['style'];
             ob_start();
             $chromeMethod($module, $params, $attribs);
             $module->content = ob_get_contents();
             ob_end_clean();
         }
     }
     //revert the scope
     $app->scope = $scope;
     if (constant('JDEBUG')) {
         JProfiler::getInstance('Application')->mark('afterRenderModule ' . $module->module . ' (' . $module->title . ')');
     }
     return $module->content;
 }
Exemplo n.º 18
0
 private function allowPosition($position)
 {
     // Don't do anything if MageBridge is not enabled
     if ($this->isEnabled() == false) {
         return true;
     }
     // If the position is empty, default to true
     $position = trim($position);
     if (empty($position)) {
         return true;
     }
     // Check for a certain page
     if (MageBridgeTemplateHelper::isHomePage()) {
         $setting = 'flush_positions_home';
     } else {
         if (MageBridgeTemplateHelper::isCustomerPage()) {
             $setting = 'flush_positions_customer';
         } else {
             if (MageBridgeTemplateHelper::isProductPage()) {
                 $setting = 'flush_positions_product';
             } else {
                 if (MageBridgeTemplateHelper::isCategoryPage()) {
                     $setting = 'flush_positions_category';
                 } else {
                     if (MageBridgeTemplateHelper::isCartPage()) {
                         $setting = 'flush_positions_cart';
                     } else {
                         if (MageBridgeTemplateHelper::isCheckoutPage()) {
                             $setting = 'flush_positions_checkout';
                         } else {
                             $setting = null;
                         }
                     }
                 }
             }
         }
     }
     // If the page-check returns empty, default to true
     if (empty($setting)) {
         return true;
     }
     // Check for flushing of positions within the MageBridge configuration
     $array = explode(',', $this->params->get($setting));
     if (!empty($array)) {
         foreach ($array as $a) {
             if ($position == trim($a)) {
                 return false;
             }
         }
     }
     // Default to true
     return true;
 }
Exemplo n.º 19
0
 /**
  * Method to see whether a given page is a secure page
  *
  * @param string $request
  *
  * @return boolean
  */
 public static function isSSLPage($request = null)
 {
     $app = JFactory::getApplication();
     // Check current page
     if ($app->input->getCmd('option') == 'com_magebridge' && $app->input->getCmd('view') == 'content') {
         if (in_array($app->input->getCmd('layout'), array('checkout', 'cart'))) {
             return true;
         }
     }
     // Default pages to be served with SSL
     $pages = array('checkout/*', 'customer/*', 'wishlist/*');
     // Extra payment-pages to be served with SSL
     $payment_urls = explode(',', MagebridgeModelConfig::load('payment_urls'));
     if (!empty($payment_urls)) {
         foreach ($payment_urls as $url) {
             $url = trim($url);
             if (!empty($url)) {
                 $pages[] = $url . '/*';
             }
         }
     }
     return MageBridgeTemplateHelper::isPage($pages, $request);
 }
Exemplo n.º 20
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;
 }
Exemplo n.º 21
0
 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;
 }
Exemplo n.º 22
0
/**
 * Joomla! component MageBridge
 *
 * @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');
// Handy variables
$request = MageBridgeUrlHelper::getRequest();
$bridge = MageBridgeModelBridge::getInstance();
$page_layout = MageBridgeTemplateHelper::getRootTemplate();
/*
 * Developers note: Do NOT edit the contents of this file directly. 
 * Instead, create a override of this file by copying it to:
 *
 * "templates/YOUR_TEMPLATE/html/com_magebridge/fixes.php
 */
// FIX: Magento refers from opcheckout.js to these specific HTML-classes, but currently we do not care
if (strstr($request, 'checkout/onepage') && $bridge->getBlock('checkout.progress') == '') {
    $html .= '<!-- Begin Checkout Progress Fix -->';
    $html .= '<div class="col-right" style="display:none;">';
    $html .= '<div class="one-page-checkout-progress"></div>';
    $html .= '<div id="checkout-progress-wrapper"></div>';
    $html .= '<div id="col-right-opcheckout"></div>';
    $html .= '</div>';
    $html .= '<!-- End Checkout Progress Fix -->';
Exemplo n.º 23
0
 public function postlogin($user_email = null, $user_id = null, $throw_event = true)
 {
     // Check if the arguments are set
     if (empty($user_email) && $user_id > 0 == false) {
         return false;
     }
     // Check if this is the frontend
     $application = JFactory::getApplication();
     if ($application->isSite() == false) {
         return false;
     }
     // Check if this current request is actually a POST-request
     $post = JRequest::get('post');
     if (!empty($post)) {
         return false;
     }
     // Fetch the current user
     $user = JFactory::getUser();
     // Set the changed-flag
     $changed = false;
     // Check whether the Joomla! ID is different
     if ($user_id > 0 && $user->id != $user_id) {
         $db = JFactory::getDBO();
         $query = "SELECT id FROM #__users WHERE `id` = " . (int) $user_id;
         $db->setQuery($query);
         $row = $db->loadObject();
         if (!empty($row)) {
             $user->load($user_id);
             $changed = true;
         }
     }
     // Double-check whether the Joomla! email is different
     if (!empty($user_email) && $user->email != $user_email) {
         $user = $this->loadByEmail($user_email);
         $changed = true;
     }
     // Check whether the Joomla! ID is set, but guest is still 1
     if ($user->id > 0 && $user->guest == 1) {
         $changed = true;
     }
     // If there is still no valid user, autocreate it
     // @note: Removed because this makes things overly complex
     /*if (!empty($user_email) && empty($user->email)) {
           $data = array(
               'name' => $user_email,
               'username' => $user_email,
               'email' => $user_email,
           );
           $user = $this->create($data);
           $changed = true;
       }*/
     // Do not fire the event when using the onepage-checkout
     if (MageBridgeTemplateHelper::isPage('checkout/onepage') == true && MageBridgeTemplateHelper::isPage('checkout/onepage/success') == false) {
         $throw_event = false;
     }
     if ($changed == true) {
         MageBridgeModelDebug::getInstance()->notice("Postlogin on user = "******"Firing event " . $eventName);
         JPluginHelper::importPlugin('user');
         JFactory::getApplication()->triggerEvent($eventName, array($user, $options));
     } else {
         // Update the user-session
         if (!empty($user)) {
             $this->updateSession($user);
         }
     }
     return true;
 }
Exemplo n.º 24
0
 public static function debug()
 {
     $prototype_loaded = MageBridgeTemplateHelper::hasPrototypeJs() ? 'Yes' : 'No';
     JError::raiseNotice('notice', JText::sprintf('View: %s', JRequest::getCmd('view')));
     JError::raiseNotice('notice', JText::sprintf('Page layout: %s', MageBridgeTemplateHelper::getPageLayout()));
     JError::raiseNotice('notice', JText::sprintf('Prototype JavaScript loaded: %s', $prototype_loaded));
 }
Exemplo n.º 25
0
 /**
  * Method to load the JavaScript headers
  *
  * @param array $headers
  * @return null
  */
 public function loadJs($headers)
 {
     // Dot not load if this is not the right document-class
     $document = JFactory::getDocument();
     if ($document->getType() != 'html') {
         return false;
     }
     // Check whether all scripts are disabled
     $disable_js = MagebridgeModelConfig::load('disable_js_mage');
     if ($disable_js == 'all') {
         return false;
     }
     // Check whether the bridge is offline
     $offline = MageBridge::getBridge()->isOffline();
     if ($offline == true) {
         return false;
     }
     // Initialize the internal array
     $this->_scripts = array();
     // Get system variables
     $bridge = MageBridge::getBridge();
     $html = "<script type=\"text/javascript\">\n" . "//<![CDATA[\n" . "var BLANK_URL = '" . $this->getBaseJsUrl() . "blank.html';\n" . "var BLANK_IMG = '" . $this->getBaseJsUrl() . "spacer.gif';\n" . "//]]>\n" . "</script>\n";
     $document->addCustomTag($html);
     // Load Prototype
     if ($this->loadPrototype() == true) {
         $this->_has_prototype = true;
     }
     // Loop through all the header-items fetched from Magento
     if (!empty($headers['items'])) {
         $jslist = array();
         $jstags = array();
         foreach ($headers['items'] as $item) {
             if ($item['type'] == 'skin_js' || $item['type'] == 'js') {
                 if (MageBridgeHelper::jsIsDisabled($item['name']) == true) {
                     continue;
                 }
                 $this->_stylesheets[] = $item['name'];
                 $this->_scripts[] = $item['name'];
                 if (empty($item['name'])) {
                     continue;
                 }
                 // If this is a skin-script, construct the tag but add it later to the HTML-header
                 if ($item['type'] == 'skin_js') {
                     if (!preg_match('/^http/', $item['path'])) {
                         $item['path'] = $bridge->getMagentoUrl() . $item['path'];
                     }
                     $tag = '<script type="text/javascript" src="' . $item['path'] . '"></script>' . "\n";
                     $jstags[] = $tag;
                     continue;
                 }
                 // If this is a conditional script, construct the tag but add it later to the HTML-header
                 if (!empty($item['if'])) {
                     if (!preg_match('/^http/', $item['path'])) {
                         $item['path'] = $bridge->getMagentoUrl() . $item['path'];
                     }
                     $tag = '<script type="text/javascript" src="' . $item['path'] . '"></script>' . "\n";
                     $tag = '<!--[if ' . $item['if'] . ' ]>' . "\n" . $tag . '<![endif]-->' . "\n";
                     $jstags[] = $tag;
                     continue;
                 }
                 // Detect Prototype
                 if (strstr($item['path'], 'prototype') || strstr($item['path'], 'scriptaculous')) {
                     $this->_has_prototype = true;
                     // Load an optimized Prototype/script.acul.us version
                     if (MagebridgeModelConfig::load('use_protoaculous') == 1 || MagebridgeModelConfig::load('use_protoculous') == 1) {
                         $skip_scripts = array('prototype/prototype.js', 'scriptaculous/builder.js', 'scriptaculous/effects.js', 'scriptaculous/dragdrop.js', 'scriptaculous/controls.js', 'scriptaculous/slider.js');
                         if (in_array($item['name'], $skip_scripts)) {
                             continue;
                         }
                     }
                     // Skip these, if the Google API is already loaded
                     if (MagebridgeModelConfig::load('use_google_api') == 1) {
                         if (preg_match('/prototype.js$/', $item['name'])) {
                             continue;
                         }
                         if (preg_match('/scriptaculous.js$/', $item['name'])) {
                             continue;
                         }
                     }
                 }
                 // Detect jQuery and replace it
                 if (preg_match('/jquery-([0-9]+)\\.([0-9]+)\\.([0-9]+)/', $item['path']) || preg_match('/jquery.js$/', $item['path']) || preg_match('/jquery.min.js$/', $item['path'])) {
                     if (MagebridgeModelConfig::load('replace_jquery') == 1) {
                         MageBridgeTemplateHelper::load('jquery');
                         continue;
                     }
                 }
                 // Detect the translation script
                 if (strstr($item['name'], 'translate.js')) {
                     $translate = true;
                 }
                 // Load this script through JS merging or not
                 if (MagebridgeModelConfig::load('merge_js') == 1) {
                     $jslist[] = $item['name'];
                 } else {
                     if (MagebridgeModelConfig::load('merge_js') == 2 && !empty($headers['merge_js'])) {
                         // Don't do anything here yet
                     } else {
                         if (!preg_match('/^http/', $item['path'])) {
                             $item['path'] = $bridge->getMagentoUrl() . $item['path'];
                         }
                         $item['path'] = $this->convertUrl($item['path']);
                         $tag = '<script type="text/javascript" src="' . $item['path'] . '"></script>' . "\n";
                         $jstags[] = $tag;
                     }
                 }
             }
         }
         if (MagebridgeModelConfig::load('merge_js') == 2 && !empty($headers['merge_js'])) {
             $this->addScript($headers['merge_js']);
         } else {
             if (!empty($jslist)) {
                 $this->addScript($this->getBaseJsUrl() . 'index.php?c=auto&amp;f=,' . implode(',', $jslist));
             }
         }
         if (!empty($jstags)) {
             foreach ($jstags as $tag) {
                 if (!empty($tag)) {
                     $document->addCustomTag($tag);
                 }
             }
         }
     }
     // Load some extra JavaScript tags
     if (isset($headers['custom'])) {
         foreach ($headers['custom'] as $custom) {
             $custom = MageBridgeEncryptionHelper::base64_decode($custom);
             $custom = preg_replace('/Mage.Cookies.domain([^;]+)\\;/m', 'Mage.Cookies.domain = null;', $custom);
             $document->addCustomTag($custom);
         }
     } else {
         if (isset($translate) && $translate == true) {
             $html = '<script type="text/javascript">var Translator = new Translate([]);</script>';
             $document->addCustomTag($html);
         }
     }
     return;
 }
Exemplo n.º 26
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++;
                 }
             }
         }
     }
 }
Exemplo n.º 27
0
 /**
  * Method to postlogin a Magento customer
  *
  * @param string $user_email
  * @param int $user_id
  * @param bool $throw_event
  * @param bool $allow_post
  * @return bool
  */
 public function postlogin($user_email = null, $user_id = null, $throw_event = true, $allow_post = false)
 {
     // Check if the arguments are set
     if (empty($user_email) && $user_id > 0 == false) {
         return false;
     }
     // Bugfix for malformed email
     if (strstr($user_email, '%40')) {
         $user_email = urldecode($user_email);
     }
     // Check on the email
     if ($this->isValidEmail($user_email) == false) {
         return false;
     }
     // Check if this is the frontend
     $application = JFactory::getApplication();
     if ($application->isSite() == false) {
         return false;
     }
     // Check if this current request is actually a POST-request
     $post = JFactory::getApplication()->input->post->getArray();
     if (!empty($post) && $allow_post == false) {
         return false;
     }
     // Fetch the current user
     $user = JFactory::getUser();
     // Set the changed-flag
     $changed = false;
     // Check whether the Joomla! ID is different
     if ($user_id > 0 && $user->id != $user_id) {
         $db = JFactory::getDBO();
         $query = "SELECT id FROM #__users WHERE `id` = " . (int) $user_id;
         $db->setQuery($query);
         $row = $db->loadObject();
         if (!empty($row)) {
             $user = JFactory::getUser($user_id);
             $changed = true;
         }
     }
     // Double-check whether the Joomla! email is different
     if (!empty($user_email) && $user->email != $user_email) {
         $user = $this->loadByEmail($user_email);
         $changed = true;
     }
     // Check whether the Joomla! ID is set, but guest is still 1
     if (!empty($user) && $user->id > 0 && isset($user->guest) && $user->guest == 1) {
         $changed = true;
     }
     // If there is still no valid user, autocreate it
     if (!empty($user_email) && (empty($user) || empty($user->email))) {
         $data = array('name' => $user_email, 'username' => $user_email, 'email' => $user_email);
         $user = $this->create($data);
         $changed = true;
     }
     // Do not fire the event when using the onepage-checkout
     if (MageBridgeTemplateHelper::isPage('checkout/onepage') == true && MageBridgeTemplateHelper::isPage('checkout/onepage/success') == false) {
         $throw_event = false;
     } elseif (MageBridgeTemplateHelper::isPage('firecheckout') == true) {
         $throw_event = false;
     }
     // Give a simple log-entry
     if ($changed == true) {
         MageBridgeModelDebug::getInstance()->notice("Postlogin on user = " . $user_email);
     }
     // If there are changes, throw the onLoginUser event
     $throw_event = true;
     if ($throw_event == true && $changed == true && !empty($user)) {
         // Add options for our own user-plugin
         $options = array('disable_bridge' => true, 'action' => 'core.login.site', 'return' => null);
         $options['remember'] = 1;
         // Convert the user-object to an array
         $user = JArrayHelper::fromObject($user);
         // Fire the event
         MageBridgeModelDebug::getInstance()->notice('Firing event onUserLogin');
         JPluginHelper::importPlugin('user');
         JFactory::getApplication()->triggerEvent('onUserLogin', array($user, $options));
     }
     return true;
 }
Exemplo n.º 28
0
 public function loadDefaultCss()
 {
     // Dot not load if this is not the right document-class
     $document = JFactory::getDocument();
     if ($document->getType() != 'html') {
         return false;
     }
     // Check whether the bridge is offline
     $offline = MageBridge::getBridge()->isOffline();
     if ($offline == true) {
         return false;
     }
     // Determine whether to load the default CSS or not
     if (MagebridgeModelConfig::load('disable_default_css') == 0) {
         // Load common stylesheets
         MageBridgeTemplateHelper::load('css', 'default.css');
         MageBridgeTemplateHelper::load('css', 'custom.css');
         // Load specific stylesheets per page
         if (MageBridgeTemplateHelper::isHomePage()) {
             MageBridgeTemplateHelper::load('css', 'homepage.css');
         }
         if (MageBridgeTemplateHelper::isProductPage()) {
             MageBridgeTemplateHelper::load('css', 'product.css');
         }
         if (MageBridgeTemplateHelper::isCategoryPage()) {
             MageBridgeTemplateHelper::load('css', 'category.css');
         }
         // Determine browser-specific stylesheets
         jimport('joomla.environment.browser');
         $browser = JBrowser::getInstance();
         if ($browser->getBrowser() == 'msie') {
             MageBridgeTemplateHelper::load('css', 'default-ie.css');
         }
         if ($browser->getBrowser() == 'msie' && $browser->getVersion() == '6.0') {
             MageBridgeTemplateHelper::load('css', 'default-ie6.css');
         }
         if ($browser->getBrowser() == 'msie' && $browser->getVersion() == '7.0') {
             MageBridgeTemplateHelper::load('css', 'default-ie7.css');
         }
         if ($browser->getBrowser() == 'msie' && $browser->getVersion() == '8.0') {
             MageBridgeTemplateHelper::load('css', 'default-ie8.css');
         }
     }
 }
Exemplo n.º 29
0
 public function display($tpl = null)
 {
     // Load important variables
     $application = JFactory::getApplication();
     $option = JRequest::getCmd('option') . '-connectors';
     $layout = JRequest::getCmd('layout');
     // Load the import-layout directly
     if ($layout == 'import') {
         return parent::display($tpl);
     }
     // Load the tabs
     jimport('joomla.html.pane');
     $activeTab = $application->getUserStateFromRequest($option . '.tab', 'tab', 1, 'int');
     $pane = JPane::getInstance('tabs', array('startOffset' => $activeTab));
     $this->assignRef('pane', $pane);
     // Page title
     if (MagebridgeModelConfig::load('advanced') == 1) {
         $this->setTitle('Configuration (Advanced Mode)');
     } else {
         $this->setTitle('Configuration (Basic Mode)');
     }
     // Deal with the advanced mode
     if (MagebridgeModelConfig::load('advanced') == 1) {
         $mode = 'advanced';
         $mode_button = 'Basic';
     } else {
         $mode = 'basic';
         $mode_button = 'Advanced';
     }
     // Toolbar options
     if (MageBridgeAclHelper::isDemo() == false) {
         JToolBarHelper::custom('export', 'export.png', null, 'Export', false);
         JToolBarHelper::custom('import', 'import.png', null, 'Import', false);
     }
     JToolBarHelper::custom('toggleMode', 'mode.png', 'mode.png', $mode_button, false);
     if (MageBridgeHelper::isJoomla15() == false) {
         JToolBarHelper::preferences('com_magebridge');
     }
     MageBridgeToolBarHelper::help('magebridge.configuration');
     JToolBarHelper::save();
     JToolBarHelper::apply();
     JToolBarHelper::cancel();
     JToolBarHelper::custom('cache', 'preview.png', 'preview_f2.png', 'Empty cache', false);
     // Extra scripts
     MageBridgeTemplateHelper::load('jquery');
     JHTML::_('script', 'media/com_magebridge/js/backend-config.js', '');
     // Before loading anything, we build the bridge
     $this->preBuildBridge();
     // Load the configuration and check it
     $config = MagebridgeModelConfig::load();
     $this->checkConfig();
     // Make sure demo-users are not seeing any sensitive data
     if (MageBridgeAclHelper::isDemo() == true) {
         $censored_values = array('license', 'api_user', 'api_key');
         foreach ($censored_values as $censored_value) {
             $config[$censored_value]['value'] = str_repeat('*', strlen($config[$censored_value]['value']));
         }
     }
     // Generate input fields
     $fields = array();
     $fields['disable_css'] = $this->getFieldDisableCss();
     $fields['disable_js_mage'] = $this->getFieldDisableJsMage();
     $fields['disable_js_all'] = $this->getFieldDisableJsJoomla();
     $fields['website'] = $this->getFieldWebsite();
     $fields['customer_group'] = $this->getFieldCustomerGroup();
     $fields['usergroup'] = $this->getFieldUsergroup();
     $fields['show_help'] = JHTML::_('select.booleanlist', 'show_help', null, $config['show_help']['value']);
     $fields['encryption'] = JHTML::_('select.booleanlist', 'encryption', null, $config['encryption']['value']);
     $fields['enable_sso'] = JHTML::_('select.booleanlist', 'enable_sso', null, $config['enable_sso']['value']);
     $fields['enable_usersync'] = JHTML::_('select.booleanlist', 'enable_usersync', null, $config['enable_usersync']['value']);
     $fields['username_from_email'] = JHTML::_('select.booleanlist', 'username_from_email', null, $config['username_from_email']['value']);
     $fields['realname_from_firstlast'] = JHTML::_('select.booleanlist', 'realname_from_firstlast', null, $config['realname_from_firstlast']['value']);
     $fields['enable_auth_backend'] = JHTML::_('select.booleanlist', 'enable_auth_backend', null, $config['enable_auth_backend']['value']);
     $fields['enable_auth_frontend'] = JHTML::_('select.booleanlist', 'enable_auth_frontend', null, $config['enable_auth_frontend']['value']);
     $fields['enable_canonical'] = JHTML::_('select.booleanlist', 'enable_canonical', null, $config['enable_canonical']['value']);
     $fields['protocol'] = $this->getFieldProtocol();
     $fields['method'] = $this->getFieldMethod();
     $fields['http_auth'] = JHTML::_('select.booleanlist', 'http_auth', null, $config['http_auth']['value']);
     $fields['http_authtype'] = $this->getFieldHttpAuthType();
     $fields['backend'] = $this->getFieldBackend();
     $fields['template'] = $this->getFieldTemplate();
     $fields['enforce_ssl'] = $this->getFieldEnforceSSL();
     $fields['update_format'] = $this->getFieldUpdateFormat();
     $fields['update_method'] = $this->getFieldUpdateMethod();
     $fields['debug_log'] = $this->getFieldDebugLog();
     $fields['debug_level'] = $this->getFieldDebugLevel();
     $fields['mobile_magento_theme'] = $this->getFieldMobileMagentoTheme();
     $fields['mobile_joomla_theme'] = $this->getFieldMobileJoomlaTheme();
     $fields['merge_js'] = $this->getFieldMergeJs();
     $fields['users_website_id'] = $this->getFieldUsersWebsiteId();
     $fields['users_group_id'] = $this->getFieldUsersGroupId();
     $fields['api_type'] = $this->getFieldApiType();
     $fields['api_widgets'] = JHTML::_('select.booleanlist', 'api_widgets', null, $config['api_widgets']['value']);
     $fields['preload_all_modules'] = JHTML::_('select.booleanlist', 'preload_all_modules', null, $config['preload_all_modules']['value']);
     $fields['advanced'] = JHTML::_('select.booleanlist', 'advanced', null, $config['advanced']['value']);
     $fields['use_rootmenu'] = JHTML::_('select.booleanlist', 'use_rootmenu', null, $config['use_rootmenu']['value']);
     $fields['enforce_rootmenu'] = JHTML::_('select.booleanlist', 'enforce_rootmenu', null, $config['enforce_rootmenu']['value']);
     $fields['enable_cache'] = JHTML::_('select.booleanlist', 'enable_cache', null, $config['enable_cache']['value']);
     $fields['enable_content_plugins'] = JHTML::_('select.booleanlist', 'enable_content_plugins', null, $config['enable_content_plugins']['value']);
     $fields['enable_block_rendering'] = JHTML::_('select.booleanlist', 'enable_block_rendering', null, $config['enable_block_rendering']['value']);
     $fields['enable_jdoc_tags'] = JHTML::_('select.booleanlist', 'enable_jdoc_tags', null, $config['enable_jdoc_tags']['value']);
     $fields['disable_default_css'] = JHTML::_('select.booleanlist', 'disable_default_css', null, $config['disable_default_css']['value']);
     $fields['disable_js_mootools'] = JHTML::_('select.booleanlist', 'disable_js_mootools', null, $config['disable_js_mootools']['value']);
     $fields['disable_js_footools'] = JHTML::_('select.booleanlist', 'disable_js_footools', null, $config['disable_js_footools']['value']);
     $fields['disable_js_frototype'] = JHTML::_('select.booleanlist', 'disable_js_frototype', null, $config['disable_js_frototype']['value']);
     $fields['disable_js_jquery'] = JHTML::_('select.booleanlist', 'disable_js_jquery', null, $config['disable_js_jquery']['value']);
     $fields['disable_js_prototype'] = JHTML::_('select.booleanlist', 'disable_js_prototype', null, $config['disable_js_prototype']['value']);
     $fields['use_google_api'] = JHTML::_('select.booleanlist', 'use_google_api', null, $config['use_google_api']['value']);
     $fields['use_protoaculous'] = JHTML::_('select.booleanlist', 'use_protoaculous', null, $config['use_protoaculous']['value']);
     $fields['use_protoculous'] = JHTML::_('select.booleanlist', 'use_protoculous', null, $config['use_protoculous']['value']);
     $fields['offline'] = JHTML::_('select.booleanlist', 'offline', null, $config['offline']['value']);
     $fields['debug'] = JHTML::_('select.booleanlist', 'debug', null, $config['debug']['value']);
     $fields['debug_bar'] = JHTML::_('select.booleanlist', 'debug_bar', null, $config['debug_bar']['value']);
     $fields['debug_console'] = JHTML::_('select.booleanlist', 'debug_console', null, $config['debug_console']['value']);
     $fields['debug_bar_parts'] = JHTML::_('select.booleanlist', 'debug_bar_parts', null, $config['debug_bar_parts']['value']);
     $fields['debug_bar_request'] = JHTML::_('select.booleanlist', 'debug_bar_request', null, $config['debug_bar_request']['value']);
     $fields['debug_bar_store'] = JHTML::_('select.booleanlist', 'debug_bar_store', null, $config['debug_bar_store']['value']);
     $fields['debug_display_errors'] = JHTML::_('select.booleanlist', 'debug_display_errors', null, $config['debug_display_errors']['value']);
     $fields['enable_messages'] = JHTML::_('select.booleanlist', 'enable_messages', null, $config['enable_messages']['value']);
     $fields['enable_notfound'] = JHTML::_('select.booleanlist', 'enable_notfound', null, $config['enable_notfound']['value']);
     $fields['modify_url'] = JHTML::_('select.booleanlist', 'modify_url', null, $config['modify_url']['value']);
     $fields['link_to_magento'] = JHTML::_('select.booleanlist', 'link_to_magento', null, $config['link_to_magento']['value']);
     $fields['spoof_browser'] = JHTML::_('select.booleanlist', 'spoof_browser', null, $config['spoof_browser']['value']);
     $fields['spoof_headers'] = JHTML::_('select.booleanlist', 'spoof_headers', null, $config['spoof_headers']['value']);
     $fields['curl_post_as_array'] = JHTML::_('select.booleanlist', 'curl_post_as_array', null, $config['curl_post_as_array']['value']);
     $fields['backend_feed'] = JHTML::_('select.booleanlist', 'backend_feed', null, $config['backend_feed']['value']);
     $fields['keep_alive'] = JHTML::_('select.booleanlist', 'keep_alive', null, $config['keep_alive']['value']);
     $fields['filter_content'] = JHTML::_('select.booleanlist', 'filter_content', null, $config['filter_content']['value']);
     $this->assignRef('mode', $mode);
     $this->assignRef('config', $config);
     $this->assignRef('fields', $fields);
     parent::display($tpl);
 }
Exemplo n.º 30
0
 /**
  * Method to see whether a given page is a secure page
  * 
  * @access public
  * @param string $request
  * @return boolean
  */
 public static function isSSLPage($request = null)
 {
     // Default pages to be served with SSL
     $pages = array('checkout/*', 'customer/*', 'wishlist/*');
     // Extra payment-pages to be served with SSL
     $payment_urls = explode(',', MagebridgeModelConfig::load('payment_urls'));
     if (!empty($payment_urls)) {
         foreach ($payment_urls as $url) {
             $url = trim($url);
             if (!empty($url)) {
                 $pages[] = $url . '/*';
             }
         }
     }
     return MageBridgeTemplateHelper::isPage($pages, $request);
 }