/**
  * 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 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);
 }
Esempio n. 3
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;
 }
Esempio n. 5
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;
 }
Esempio n. 6
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 variables
     $application = JFactory::getApplication();
     // Don't do anything in other applications than the frontend
     if ($application->isSite() == false) {
         return false;
     }
     // Load the whitelist settings
     $whitelist = JFactory::getConfig()->get('magebridge.script.whitelist');
     if (empty($whitelist)) {
         $whitelist = array();
     }
     if ($this->getParams()->get('enable_js_widgetkit', 1) == 1) {
         $whitelist[] = '/widgetkit/';
     }
     if ($this->getParams()->get('enable_js_warp', 1) == 1) {
         $whitelist[] = '/warp/';
     }
     if ($this->getParams()->get('enable_js_template', 1) == 1) {
         $whitelist[] = '/js/';
     }
     JFactory::getConfig()->set('magebridge.script.whitelist', $whitelist);
     // Read the template-related files
     $ini = JPATH_THEMES . '/' . $application->getTemplate() . '/params.ini';
     $conf = JPATH_THEMES . '/' . $application->getTemplate() . '/config';
     if (!file_exists($conf)) {
         $conf = JPATH_THEMES . '/' . $application->getTemplate() . '/config.json';
     }
     $xml = JPATH_THEMES . '/' . $application->getTemplate() . '/templateDetails.xml';
     $ini_content = @file_get_contents($ini);
     $conf_content = @file_get_contents($conf);
     // WARP-usage of "config" file
     if (!empty($conf_content)) {
         // Unjson the data-array
         $data = json_decode($conf_content, true);
         if (is_array($data)) {
             // Fetch the Itemid
             $Itemid = JFactory::getApplication()->input->getInt('Itemid');
             // Define the current profile-indications
             $profileDefault = isset($data['profile_default']) ? $data['profile_default'] : null;
             // Load the profile-specific CSS, set in GET
             $profileGet = JFactory::getApplication()->input->getCmd('profile');
             if (!empty($profileGet)) {
                 $profile = $profileGet;
                 MageBridgeTemplateHelper::load('css', 'profile-' . $profile . '.css');
                 // Load the profile-specific CSS, set through the Itemid-mapping
             } else {
                 if (isset($data['profile_map'][$Itemid])) {
                     $profileMapped = $data['profile_map'][$Itemid];
                     if (!empty($profileMapped)) {
                         $profile = $profileMapped;
                         MageBridgeTemplateHelper::load('css', 'profile-' . $profile . '.css');
                     }
                     // Load the default profile-CSS
                 } else {
                     if (!empty($profileDefault)) {
                         $profile = $profileDefault;
                         MageBridgeTemplateHelper::load('css', 'profile-' . $profile . '.css');
                     }
                 }
             }
             // Load a profile-specific color-definition
             if (!empty($profile) && isset($data['profile_data'][$profile]['color'])) {
                 $color = $data['profile_data'][$profile]['color'];
             } else {
                 if (isset($data['profile_data']['default']['color'])) {
                     $color = $data['profile_data']['default']['color'];
                 }
             }
             // If a color-definition is detected, load the CSS
             if (!empty($color)) {
                 MageBridgeTemplateHelper::load('css', 'color-' . $color . '.css');
             }
             // Load a profile-specific style-definition
             if (!empty($profile) && isset($data['profile_data'][$profile]['style'])) {
                 $style = $data['profile_data'][$profile]['style'];
             } else {
                 if (isset($data['profile_data']['default']['style'])) {
                     $style = $data['profile_data']['default']['style'];
                 }
             }
             // If a style-definition is detected, load the CSS
             if (!empty($style)) {
                 if ($style == 'default') {
                     $style = $profileDefault;
                 }
                 MageBridgeTemplateHelper::load('css', 'style-' . $style . '.css');
             }
             // Load a layout-specific style-definition
             if (!empty($profile) && isset($data['layouts'][$profile]['style'])) {
                 $layout = $data['layouts'][$profile]['style'];
             } else {
                 if (isset($data['layouts']['default']['style'])) {
                     $layout = $data['layouts']['default']['style'];
                 }
             }
             // If a style-definition is detected, load the CSS
             if (!empty($layout)) {
                 if ($layout == 'default') {
                     $layout = $profileDefault;
                 }
                 MageBridgeTemplateHelper::load('css', 'style-' . $layout . '.css');
             }
         }
         // Pre-WARP reading of Joomla! parameters
     } else {
         // Create the parameters object
         $params = YireoHelper::toRegistry($ini_content, $xml);
         // Load a specific stylesheet per color
         $color = $params->get('color');
         if (!empty($color)) {
             MageBridgeTemplateHelper::load('css', 'color-' . $color . '.css');
         }
         // Load a specific stylesheet per style
         $style = $params->get('style');
         if (!empty($style)) {
             MageBridgeTemplateHelper::load('css', 'style-' . $style . '.css');
         }
     }
 }
 * @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) {
        $templateHelper->load('css', 'mod-products-default.css');
    }
}
 public static function loadJquery()
 {
     return MageBridgeTemplateHelper::load('jquery');
 }
 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);
 }
Esempio n. 10
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;
 }
 /**
  * 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 variables
     $application = JFactory::getApplication();
     // Don't do anything in other applications than the frontend
     if ($application->isSite() == false) {
         return false;
     }
     // Load the whitelist settings
     $whitelist = $application->get('magebridge.script.whitelist');
     if (empty($whitelist)) {
         $whitelist = array();
     }
     if ($this->getParams()->get('enable_js_widgetkit', 1) == 1) {
         $whitelist[] = '/widgetkit/';
     }
     if ($this->getParams()->get('enable_js_warp', 1) == 1) {
         $whitelist[] = '/warp/js/';
     }
     if ($this->getParams()->get('enable_js_template', 1) == 1) {
         $whitelist[] = '/js/template.js';
     }
     $application->set('magebridge.script.whitelist', $whitelist);
     // Read the template-related files
     $ini = JPATH_THEMES . '/' . $application->getTemplate() . '/params.ini';
     $conf = JPATH_THEMES . '/' . $application->getTemplate() . '/config';
     $xml = JPATH_THEMES . '/' . $application->getTemplate() . '/templateDetails.xml';
     $ini_content = @file_get_contents($ini);
     $conf_content = @file_get_contents($conf);
     // WARP-usage of "config" file
     if (!empty($conf_content)) {
         $data = json_decode($conf_content, true);
         if (is_array($data)) {
             $Itemid = JRequest::getInt('Itemid');
             $profileGet = JRequest::getCmd('profile');
             $profileDefault = isset($data['profile_default']) ? $data['profile_default'] : null;
             if (!empty($profileGet)) {
                 $profile = $profileGet;
                 MageBridgeTemplateHelper::load('css', 'profile-' . $profile . '.css');
             } else {
                 if (isset($data['profile_map'][$Itemid])) {
                     $profileMapped = $data['profile_map'][$Itemid];
                     if (!empty($profileMapped)) {
                         $profile = $profileMapped;
                         MageBridgeTemplateHelper::load('css', 'profile-' . $profile . '.css');
                     }
                 } else {
                     if (!empty($profileDefault)) {
                         $profile = $profileDefault;
                         MageBridgeTemplateHelper::load('css', 'profile-' . $profile . '.css');
                     }
                 }
             }
             if (isset($data['profile_data'][$profile]['color'])) {
                 $color = $data['profile_data'][$profile]['color'];
             } else {
                 if (isset($data['profile_data']['default']['color'])) {
                     $color = $data['profile_data']['default']['color'];
                 }
             }
             if (!empty($color)) {
                 MageBridgeTemplateHelper::load('css', 'color-' . $color . '.css');
             }
             if (isset($data['profile_data'][$profile]['style'])) {
                 $style = $data['profile_data'][$profile]['style'];
             } else {
                 if (isset($data['profile_data']['default']['style'])) {
                     $style = $data['profile_data']['default']['style'];
                 }
             }
             if (!empty($style)) {
                 if ($style == 'default') {
                     $style = $profileDefault;
                 }
                 MageBridgeTemplateHelper::load('css', 'style-' . $style . '.css');
             }
         }
         // Pre-WARP reading of Joomla! parameters
     } else {
         // Create the parameters object
         jimport('joomla.html.parameter');
         $params = new JParameter($ini_content, $xml);
         // Load a specific stylesheet per color
         $color = $params->get('color');
         if (!empty($color)) {
             MageBridgeTemplateHelper::load('css', 'color-' . $color . '.css');
         }
         // Load a specific stylesheet per style
         $style = $params->get('style');
         if (!empty($style)) {
             MageBridgeTemplateHelper::load('css', 'style-' . $style . '.css');
         }
     }
 }
Esempio n. 12
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');
         }
     }
 }
Esempio n. 13
0
 /**
  * Display method
  *
  * @param string $tpl
  * @return null
  */
 public function display($tpl = null)
 {
     // ???
     MageBridgeViewHelper::initialize('UPDATE');
     // Filters - type
     $options = array(array('value' => '', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_NONE')), array('value' => 'module', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_MODULE')), array('value' => 'module-site', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_MODULE_SITE')), array('value' => 'module-admin', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_MODULE_ADMIN')), array('value' => 'plugin', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_PLUGIN')), array('value' => 'plugin-other', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_PLUGIN_OTHER')), array('value' => 'plugin-magebridgeproduct', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_PLUGIN_PRODUCT')), array('value' => 'plugin-magebridgestore', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_PLUGIN_STORE')), array('value' => 'plugin-magebridgeprofile', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_PLUGIN_PROFILE')), array('value' => 'plugin-magebridgenewsletter', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_PLUGIN_NEWSLETTER')));
     $filter_type = $this->getFilter('type');
     $javascript = 'onchange="document.adminForm.submit();"';
     $this->lists['type'] = JHTML::_('select.genericlist', $options, 'filter_type', $javascript, 'value', 'text', $filter_type);
     // Filters - search
     $filter_search = $this->getFilter('search');
     // Toolbar options
     JToolBarHelper::custom('home', 'back', '', 'LIB_YIREO_VIEW_TOOLBAR_HOME', false);
     JToolBarHelper::custom('refresh', 'preview.png', 'preview_f2.png', 'LIB_YIREO_VIEW_TOOLBAR_REFRESH', false);
     JToolBarHelper::custom('updateQueries', 'archive', '', 'LIB_YIREO_VIEW_TOOLBAR_DBUPGRADE', false);
     // Add jQuery for selection effects
     MageBridgeTemplateHelper::load('jquery');
     $this->addJs('backend-update.js');
     // Load the packages
     $data = MageBridgeUpdateHelper::getData();
     // Add filtering
     if (!empty($filter_type) || !empty($filter_search)) {
         if (!empty($filter_type)) {
             $filter_type = explode('-', $filter_type);
         }
         foreach ($data as $index => $extension) {
             if (!empty($filter_search)) {
                 if (!stristr($extension['name'], $filter_search) && !stristr($extension['title'], $filter_search) && !stristr($extension['description'], $filter_search)) {
                     unset($data[$index]);
                     continue;
                 }
             }
             if (!empty($filter_type)) {
                 if (count($filter_type) == 1) {
                     if ($extension['type'] != $filter_type[0]) {
                         unset($data[$index]);
                         continue;
                     }
                 } else {
                     if ($filter_type[0] == 'module') {
                         if ($extension['type'] != 'module') {
                             unset($data[$index]);
                             continue;
                         } elseif ($extension['type'] != $filter_type[0] || $extension['app'] != $filter_type[1]) {
                             unset($data[$index]);
                             continue;
                         }
                     } elseif ($filter_type[0] == 'plugin') {
                         if ($extension['type'] != 'plugin') {
                             unset($data[$index]);
                             continue;
                         } elseif ($filter_type[1] == 'other' && in_array($extension['group'], array('magebridgeproduct', 'magebridgenewsletter', 'magebridgestore', 'magebridgeprofile'))) {
                             unset($data[$index]);
                             continue;
                         } elseif ($filter_type[1] != 'other' && $extension['group'] != $filter_type[1]) {
                             unset($data[$index]);
                             continue;
                         }
                     }
                 }
             }
         }
     }
     // Detect whether updates are available
     $update = MAGEBRIDGE_UPDATE_NOTAVAILABLE;
     if (!empty($data)) {
         $update = MAGEBRIDGE_UPDATE_NOTNEEDED;
         foreach ($data as $index => $extension) {
             // Skip this entry for version detection
             if (empty($extension['version']) || empty($extension['current_version'])) {
                 continue;
             }
             if ($extension['current_version'] != $extension['version']) {
                 $update = MAGEBRIDGE_UPDATE_AVAILABLE;
                 break;
             }
         }
     }
     if ($update == MAGEBRIDGE_UPDATE_NOTAVAILABLE) {
         JError::raiseWarning('MB', JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_EMPTY_VERSION'));
     } else {
         JToolBarHelper::custom('update', 'download.png', 'download_f2.png', 'Update', false);
     }
     if ($update == MAGEBRIDGE_UPDATE_AVAILABLE) {
         JError::raiseNotice('UPDATE', JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_NEW_VERSIONS'));
     }
     $this->data = $data;
     $this->update = $update;
     $this->search = $filter_search;
     parent::display($tpl);
 }