Пример #1
0
 public function updateAll($allow_update = array())
 {
     // Fetch all the available packages
     $packages = MageBridgeUpdateHelper::getPackageList();
     $count = 0;
     foreach ($packages as $package) {
         // Skip optional packages which are not yet installed and not selected in the list
         if (!in_array($package['name'], $allow_update)) {
             continue;
         }
         // Update the package and add an error if something goes wrong
         if ($this->update($package['name']) == false) {
             JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('Installation of %s failed', $package['name']));
             // Only crash when installing the component, continue for all other extensions
             if ($package['name'] == 'com_magebridge') {
                 return false;
             }
             continue;
         } else {
             $count++;
         }
     }
     // Run the helper for post-install tasks
     $helper = new MageBridgeInstallHelper();
     $helper->cleanFiles();
     // Simple notices as feedback
     JError::raiseNotice('SOME_ERROR_CODE', JText::sprintf('Updated %d extensions successfully', $count));
     JError::raiseNotice('SOME_ERROR_CODE', JText::sprintf('Check %s for upgrade notices', MageBridgeHelper::getHelpText('builds')));
     return true;
 }
Пример #2
0
 public static function help($text = null)
 {
     if (MagebridgeModelConfig::load('show_help') == 1) {
         if (preg_match('/\\{([^\\}]+)\\}/', $text, $match)) {
             $array = explode(':', $match[1]);
             $text = str_replace($match[0], MageBridgeHelper::getHelpText($array[0], $array[1]), $text);
         }
         $html = '<div class="magebridge-help">';
         $html .= $text;
         $html .= '</div>';
         return $html;
     }
 }
Пример #3
0
 public function display($tpl = null)
 {
     //JToolBarHelper::help( 'screen.magebridge.usage' );
     $this->addMenuItems();
     $this->addCss('backend.css', 'media/com_magebridge/css/');
     if (JRequest::getCmd('view') == 'home') {
         $this->addCss('backend-home.css', 'media/com_magebridge/css/');
     }
     if (!MageBridgeHelper::isJoomla15()) {
         $this->addCss('backend-j16.css', 'media/com_magebridge/css/');
     }
     // If we detect the API is down, report it
     $bridge = MageBridgeModelBridge::getInstance();
     if ($bridge->getApiState() != null) {
         $message = null;
         switch (strtoupper($bridge->getApiState())) {
             case 'EMPTY METADATA':
                 $message = JText::_('The bridge-data arrived empty in Magento.');
                 break;
             case 'LICENSE FAILED':
                 $message = JText::sprintf('The Joomla! support-key is different from the one in Magento (%s).', $bridge->getApiExtra());
                 break;
             case 'AUTHENTICATION FAILED':
                 $message = JText::_('API authentication failed. Please check your API-user and API-key.');
                 break;
             case 'INTERNAL ERROR':
                 $help = MageBridgeHelper::getHelpText('troubleshooting');
                 $message = JText::sprintf('Bridge encountered a 500 Internal Server Error. Please check out the %s for more information.', $help);
                 break;
             case 'FAILED LOAD':
                 $help = MageBridgeHelper::getHelpText('faq-troubleshooting:api-widgets');
                 $message = JText::sprintf('Failed to load API-widgets. Please check out the %s for more information.', $help);
                 break;
             default:
                 $message = JText::_('An API-error occurred: ' . $bridge->getApiState());
                 break;
         }
         MageBridgeModelDebug::getInstance()->feedback($message);
     }
     // If debugging is enabled report it
     if (MagebridgeModelConfig::load('debug') == 1 && JRequest::getCmd('tmpl') != 'component' && in_array(JRequest::getCmd('view'), array('config', 'home'))) {
         MageBridgeModelDebug::getInstance()->feedback('Debugging is currently enabled');
     }
     parent::display($tpl);
 }
Пример #4
0
Another thing to check is whether the Magento MageBridge-API is actually there. You can check this by opening up the URL <a target="_new" href="<?php 
echo $this->url;
?>
"><?php 
echo $this->url;
?>
</a>. 
The feedback should be a bit cryptic, but should look like the following:
</p>
<pre>
{"meta":{"type":"meta","data":{"state":"empty metadata","extra":null}}}
</pre>
</p>
</div>
<h3>Step 3: Interpreting the results</h3>
<div class="description">
<ul>
<li>If you receive a 404-error in <strong>Step 1</strong> AND <strong>Step 2</strong>, it is most likely that MageBridge is not installed correctly in Magento.</li>
<li>If you receive a 500-error in <strong>Step 1</strong> AND <strong>Step 2</strong>, it is most likely that the permissions on the MageBridge files in Magento are incorrect</li>
<li>If you receive a 404-error in <strong>Step 1</strong> but NOT <strong>Step 2</strong>, something lacks in the webserver configuration: You should contact the system administrator
of this webserver to fix this problem.</li>
</ul>
<p>
Refer to the <?php 
echo MageBridgeHelper::getHelpText('troubleshooting');
?>
 for more information.
</p>
</div>
</fieldset>
Пример #5
0
 public function checkConfig()
 {
     // Check if the settings are all empty
     if (MagebridgeModelConfig::allEmpty() == true) {
         JError::raiseWarning(500, JText::sprintf('Check the online %s for more information.', MageBridgeHelper::getHelpText('quickstart')));
         return;
     }
     // Otherwise check all values
     $config = MagebridgeModelConfig::load();
     foreach ($config as $c) {
         if (isset($c['name']) && isset($c['value']) && ($message = MageBridge::getConfig()->check($c['name'], $c['value']))) {
             JError::raiseWarning(500, $message);
         }
     }
     return;
 }
Пример #6
0
 /**
  * Method to check a specific configuratione-element
  * 
  * @param string $element
  * @param string $value
  * @return string|null
  */
 public static function check($element, $value = null)
 {
     // Reset an empty value to its original value
     if (empty($value)) {
         $value = MagebridgeModelConfig::load($element);
     }
     // Check for settings that should not be kept empty
     $nonempty = array('host', 'website', 'api_user', 'api_key');
     if (MagebridgeModelConfig::allEmpty() == false && in_array($element, $nonempty) && empty($value)) {
         return JText::sprintf('Setting "%s" is empty - Please configure it below', JText::_($element));
     }
     // Check host
     if ($element == 'host') {
         if (preg_match('/([^a-zA-Z0-9\\.\\-\\_\\:]+)/', $value) == true) {
             return JText::_('Hostname contains illegal characters. Note that a hostname is not an URL, but only a fully qualified domainname.');
         } else {
             if (gethostbyname($value) == $value && !preg_match('/([0-9\\.]+)/', $value)) {
                 return JText::sprintf('DNS lookup of hostname %s failed', $value);
             } else {
                 if (MagebridgeModelConfig::load('api_widgets') == true) {
                     $bridge = MageBridgeModelBridge::getInstance();
                     $data = $bridge->build();
                     if (empty($data)) {
                         $url = $bridge->getMagentoBridgeUrl();
                         return JText::sprintf('Unable to open a connection to <a href="%s" target="_new">%s</a>', $url, $url);
                     }
                 }
             }
         }
     }
     // Check supportkey
     if ($element == 'supportkey' && empty($value)) {
         return JText::sprintf('Please configure your support-key. Your support-key can be obtained from %s', MageBridgeHelper::getHelpText('subscriptions'));
     }
     // Check API widgets
     if ($element == 'api_widgets' && $value != 1) {
         return JText::_('API widgets are disabled');
     }
     // Check offline
     if ($element == 'offline' && $value == 1) {
         return JText::_('Bridge is disabled through settings');
     }
     // Check website
     if ($element == 'website' && !empty($value)) {
         if (is_numeric($value) == false) {
             return JText::sprintf('Website ID needs to be a numeric value. Current value is "%s"', $value);
         }
     }
     /**
     if ($element == 'storeview' && !empty($value)) {
     	if ( preg_match( '/([a-zA-Z0-9\.\-\_]+)/', $value ) == false ) {
     		return JText::_( 'Store-name contains illegal characters: '.$value );
     	} else {
     		$storeviews = MagebridgeModelConfig::getStoreNames();
     		if (!is_array($storeviews) && $storeviews != 0) {
     			return JText::_($storeviews);
     
     		} else {
     
     			$match = false;
     			if (!empty($storeviews)) {
     				foreach ($storeviews as $storeview) {
     					if ($storeview['value'] == $value) {
     						$match = true;
     						break;
     					}
     				}
     			}
     
     			if ($match == false) {
     				$msg = JText::sprintf( 'Store-names detected, but "%s" is not one of them', $value );
     				return $msg;
     			}
     		}
     	}
     }
     */
     // Check basedir
     if ($element == 'basedir') {
         if (empty($value)) {
             return null;
         }
         if (preg_match('/([a-zA-Z0-9\\.\\-\\_]+)/', $value) == false) {
             return JText::_('Basedir contains illegal characters');
         }
         $root = MageBridgeUrlHelper::getRootItem();
         $joomla_host = JFactory::getURI()->toString(array('host'));
         $magento_host = MagebridgeModelConfig::load('host');
         // Check whether the Magento basedir conflicts with the MageBridge alias
         if (!empty($root) && !empty($root->route) && $root->route == $value && $joomla_host == $magento_host) {
             return JText::_('Magento basedir is same as MageBridge alias, which is not possible');
         }
     }
     return null;
 }