/** * Method to set the messages */ public function setMessages() { if (MagebridgeModelConfig::load('enable_messages') == 0) { return false; } $messages = $this->getResponseData(); if (!empty($messages) && is_array($messages)) { $application = JFactory::getApplication(); foreach ($messages as $message) { if (!is_array($message)) { continue; } switch ($message['type']) { case 'warning': $type = 'warning'; break; case 'error': $type = 'error'; break; default: $type = 'message'; break; } $application->enqueueMessage($message['message'], $type); } } return true; }
protected function getInput() { $name = $this->name; $fieldName = $name; $value = $this->value; if (MagebridgeModelConfig::load('api_widgets') == true) { $cache = JFactory::getCache('com_magebridge_admin'); $cache->setCaching(0); $options = $cache->call(array('JElementStoreview', 'getResult')); // Parse the result into an HTML form-field if (!empty($options) && is_array($options)) { foreach ($options as $index => $option) { if (!isset($option[$return])) { $return = 'value'; } $option['label'] = $option['label'] . ' (' . $option[$return] . ') '; $option['value'] = $option[$return]; $options[$index] = $option; } array_unshift($options, array('value' => '', 'label' => '')); return JHTML::_('select.genericlist', $options, $fieldName, null, 'value', 'label', $value); } else { MageBridgeModelDebug::getInstance()->warning('Unable to obtain MageBridge API Widget "storeview": ' . var_export($options, true)); } } return '<input type="text" name="' . $fieldName . '" value="' . $value . '" />'; }
protected function getInput() { $name = $this->name; $fieldName = $name; $value = $this->value; // Are the API widgets enabled? if (MagebridgeModelConfig::load('api_widgets') == true) { // Load the javascript JHTML::script('media/com_magebridge/js/backend-elements.js'); JHTML::_('behavior.modal', 'a.modal'); $returnType = (string) $this->element['return']; $title = $value; $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); $link = 'index.php?option=com_magebridge&view=element&tmpl=component&type=customer&object=' . $name . '&return=' . $returnType . '&current=' . $value; $html = '<div style="float: left;">'; $html .= '<input type="text" id="' . $name . '_name" value="' . $title . '" disabled="disabled" />'; $html .= '</div>'; $html .= '<div class="button2-left"><div class="blank">'; $html .= '<a class="modal" title="' . JText::_('Select a Customer') . '" href="' . $link . '" rel="{handler: \'iframe\', size: {x:800, y:450}}">' . JText::_('Select') . '</a>'; $html .= '</div></div>' . "\n"; $html .= '<input type="hidden" id="' . $name . '_id" name="' . $fieldName . '" value="' . $value . '" />'; return $html; } return '<input type="text" name="' . $fieldName . '" value="' . $value . '" />'; }
/** * Method to get the HTML of this element * * @param null * @return string */ protected function getInput() { $name = $this->name; $value = $this->value; $id = preg_replace('/([^0-9a-zA-Z]+)/', '_', $name); // Are the API widgets enabled? if (MagebridgeModelConfig::load('api_widgets') == true) { // Load the javascript JHTML::script('media/com_magebridge/js/backend-elements.js'); JHTML::_('behavior.modal', 'a.modal'); $returnType = (string) $this->element['return']; if (empty($returnType)) { $returnType = 'sku'; } $title = $value; $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); $link = 'index.php?option=com_magebridge&view=element&tmpl=component&ajax=1'; $link .= '&type=product&object=' . $id . '&return=' . $returnType . '&current=' . $value; $html = array(); $html[] = '<span class="input-append">'; $html[] = '<input type="text" class="input-medium" id="' . $id . '" name="' . $name . '" value="' . $title . '" size="35" />'; $html[] = '<a class="modal btn" role="button" href="' . $link . '" rel="{handler: \'iframe\', size: {x: 800, y: 450}}"><i class="icon-file"></i> ' . JText::_('JSELECT') . '</a>'; $html[] = '</span>'; $html = implode("\n", $html); return $html; } return '<input type="text" name="' . $name . '" value="' . $value . '" />'; }
/** * Method to export users to CSV * * @param null * @return null */ public function export() { // Gather the variables $users = $this->getUserList(); $website_id = MagebridgeModelConfig::load('users_website_id'); $group_id = MagebridgeModelConfig::load('users_group_id'); // Perform preliminary checks if (empty($users)) { $this->setRedirect('index.php?option=com_magebridge&view=users', JText::_('No users found'), 'error'); return false; } if (empty($website_id)) { $this->setRedirect('index.php?option=com_magebridge&view=users', JText::_('Website not configured in export parameters'), 'error'); return false; } if (empty($group_id)) { $this->setRedirect('index.php?option=com_magebridge&view=users', JText::_('Customer Group not configured in export parameters'), 'error'); return false; } $date = date('Ymd'); $filename = 'magebridge-export-joomla-users_' . $date . '.csv'; $output = $this->getOutput($users, $website_id, $group_id); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Length: ' . YireoHelper::strlen($output)); header('Content-type: text/x-csv'); header('Content-Disposition: attachment; filename=' . $filename); print $output; // Close the application $application = JFactory::getApplication(); $application->close(); }
public static function load() { if (MagebridgeModelConfig::load('preload_all_modules') == 0 && JRequest::getInt('Itemid') != 0) { static $modules = null; if (is_array($modules) == false) { $modules = JModuleHelper::_load(); foreach ($modules as $index => $module) { if (strstr($module->module, 'mod_magebridge') == false) { unset($modules[$index]); } } } return $modules; } $application = JFactory::getApplication(); $db = JFactory::getDBO(); $where = array(); $where[] = 'm.published = 1'; $where[] = 'm.module LIKE "mod_magebridge%"'; $where[] = 'm.client_id = ' . (int) $application->getClientId(); $query = 'SELECT m.*' . ' FROM #__modules AS m' . ' LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id' . ' WHERE ' . implode(' AND ', $where) . ' ORDER BY m.position, m.ordering'; $db->setQuery($query); $modules = $db->loadObjectList(); return $modules; }
public function fetchElement($name, $value, $node = null, $control_name = null) { if (!empty($control_name)) { $fieldName = $control_name . '[' . $name . ']'; } else { $fieldName = $name; } // Are the API widgets enabled? if (MagebridgeModelConfig::load('api_widgets') == true) { // Load the javascript JHTML::script('backend-elements.js', 'media/com_magebridge/js/'); JHTML::_('behavior.modal', 'a.modal'); if (!empty($node) && is_object($node)) { $returnType = $node->attributes('return'); } else { if (!empty($node) && is_array($node) && !empty($node['return'])) { $returnType = $node['return']; } else { $returnType = 'sku'; } } $title = $value; $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); $link = 'index.php?option=com_magebridge&view=element&tmpl=component&ajax=1&type=widget&object=' . $name . '&return=' . $returnType . '&current=' . $value; $html = '<div style="float: left;">'; $html .= '<input type="text" id="' . $name . '" name="' . $fieldName . '" value="' . $title . '" />'; $html .= '</div>'; $html .= '<div class="button2-left"><div class="blank">'; $html .= '<a class="modal" title="' . JText::_('Select a widget') . '" href="' . $link . '" rel="{handler: \'iframe\', size: {x:800, y:450}}">' . JText::_('Select') . '</a>'; $html .= '</div></div>' . "\n"; return $html; } return '<input type="text" name="' . $fieldName . '" value="' . $value . '" />'; }
public function getStore() { // If the database configuration specified no stores, skip this step if (MagebridgeModelConfig::load('load_stores') == 0) { return null; } // Get the conditions $db = JFactory::getDBO(); $db->setQuery("SELECT * FROM #__magebridge_stores WHERE `published`=1 ORDER BY `ordering`"); $conditions = $db->loadObjectList(); if (empty($conditions)) { return null; } // Get the connectors $connectors = $this->getConnectors(); // Try to match a condition with one of the connectors foreach ($conditions as $condition) { foreach ($connectors as $connector) { if ($condition->connector == $connector->name) { if ($connector->checkCondition($condition->connector_value) == TRUE) { $type = $condition->type == 'storeview' ? 'store' : 'group'; return array('type' => $type, 'name' => $condition->name); } } } } return null; }
protected function getInput() { $name = $this->name; $fieldName = $name; $value = $this->value; // Only build a dropdown when the API-widgets are enabled if (MagebridgeModelConfig::load('api_widgets') == true) { // Fetch the widget data from the API $options = MageBridgeWidgetHelper::getWidgetData('website'); // Parse the result into an HTML form-field if (!empty($options) && is_array($options)) { foreach ($options as $index => $option) { // Customize the return-value when the attribute "output" is defined $output = (string) $this->element['output']; if (!empty($output) && array_key_exists($output, $option)) { $option['value'] = $option[$output]; } // Customize the label $option['label'] = $option['label'] . ' (' . $option['value'] . ') '; // Add the option back to the list of options $options[$index] = $option; } // Return a dropdown list array_unshift($options, array('value' => '', 'label' => '')); return JHTML::_('select.genericlist', $options, $fieldName, null, 'value', 'label', $value); // Fetching data from the bridge failed, so report a warning } else { MageBridgeModelDebug::getInstance()->warning('Unable to obtain MageBridge API Widget "website": ' . var_export($options, true)); } } // Return a simple input-field by default return '<input type="text" name="' . $fieldName . '" value="' . $value . '" />'; }
/** * 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; }
/** * Encrypt data for security * * @param mixed $data * @return string */ public static function encrypt($data) { // Don't do anything with empty data $data = trim($data); if (empty($data)) { return null; } // Check if encryption was turned off if (MagebridgeModelConfig::load('encryption') == 0) { return $data; } // Check if SSL is already in use, so encryption is not needed if (MagebridgeModelConfig::load('protocol') == 'https') { return $data; } // Check for mcrypt if (!function_exists('mcrypt_get_iv_size') || !function_exists('mcrypt_cfb')) { return $data; } // Generate a random key $random = str_shuffle('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'); $key = MageBridgeEncryptionHelper::getSaltedKey($random); try { $td = mcrypt_module_open(MCRYPT_CAST_256, '', 'ecb', ''); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); mcrypt_generic_init($td, $key, $iv); $encrypted = mcrypt_generic($td, $data); $encoded = MageBridgeEncryptionHelper::base64_encode($encrypted); } catch (Exception $e) { Mage::getSingleton('magebridge/debug')->error("Error while decrypting: " . $e->getMessage()); return null; } return $encoded . '|=|' . $random; }
public function call($call = '', $options = array()) { if (empty($this->session_id)) { $api_user = MagebridgeModelConfig::load('api_user'); $api_key = MagebridgeModelConfig::load('api_key'); $msg = new xmlrpcmsg('login', array($this->encode($api_user), $this->encode($api_key))); $doc = $this->client->send($msg, $this->timeout); if (!is_object($doc)) { return JText::_('XML-RPC non-object document: ' . $doc); } $value = $doc->value(); if (!is_object($value)) { return JText::_('XML-RPC non-object value: ' . $value); } $this->session_id = $doc->value()->getval(); if (!$this->session_id > 0) { return JText::_('Empty session ID: ' . $doc->faultString()); } } $msg = new xmlrpcmsg('call', array($this->encode($this->session_id), $this->encode($call))); $doc = $this->client->send($msg, $this->timeout); if ($doc->faultCode() == 0) { return $this->decode($doc->value()); } else { return $doc->faultString(); } }
/** * Method to store the item * * @package MageBridge * @access public * @param array $data * @return bool */ public function store($data) { // Store the item $rt = parent::store($data); // Change the setting "load_urls" in the MageBridge configuration if ($data['published'] == 1) { MagebridgeModelConfig::saveValue('load_urls', 1); } return $rt; }
public function fetchElement($name, $value, &$node, $control_name) { if (MagebridgeModelConfig::load('api_widgets') == true) { $options = MageBridgeWidgetHelper::getWidgetData('theme'); if (!empty($options) && is_array($options)) { array_unshift($options, array('value' => '', 'label' => '-- Select --')); return JHTML::_('select.genericlist', $options, $name, null, 'value', 'label', $value); } else { MageBridgeModelDebug::getInstance()->warning('Unable to obtain MageBridge API Widget "theme": ' . var_export($options, true)); } } return '<input type="text" name="' . $name . '" value="' . $value . '" />'; }
/** * Method to get the output of this element * * @param null * @return string */ protected function getInput() { $name = $this->name; $fieldName = $this->fieldname; $value = $this->value; require_once JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php'; $options = TemplatesHelper::getTemplateOptions(0); if (!empty($options) && is_array($options)) { array_unshift($options, array('value' => '', 'text' => '')); return JHTML::_('select.genericlist', $options, $fieldName, null, 'value', 'text', MagebridgeModelConfig::load($fieldName)); } return '<input type="text" name="' . $name . '" value="' . $value . '" />'; }
/** * Method to get the output of this element * * @param null * @return string */ protected function getInput() { $name = $this->name; $fieldName = $this->fieldname; $value = $this->value; if (MagebridgeModelConfig::load('api_widgets') == true) { $options = MageBridgeWidgetHelper::getWidgetData('theme'); if (!empty($options) && is_array($options)) { array_unshift($options, array('value' => '', 'label' => '')); return JHTML::_('select.genericlist', $options, $name, null, 'value', 'label', MagebridgeModelConfig::load($fieldName)); } } return '<input type="text" name="' . $name . '" value="' . $value . '" />'; }
public function display($tpl = null) { // Load the bridge $bridge = MageBridgeModelBridge::getInstance(); // Load the parameters $layout = $this->getLayout(); $params = MageBridgeHelper::getParams(); // Set the request based upon the choosen category $request = $params->get('request', false) ? $params->get('request') : MageBridgeUrlHelper::getRequest(); $prefix = preg_replace('/\\?(.*)/', '', $request); $suffix = preg_replace('/(.*)\\?/', '', $request); // Check if this a non-URL-optimized request if (is_numeric($prefix)) { $request = MageBridgeUrlHelper::getLayoutUrl($layout, $prefix); } else { // Determine the suffix if ($layout == 'product') { $suffix = $bridge->getMageConfig('catalog/seo/product_url_suffix'); } else { if ($layout == 'category') { $suffix = $bridge->getMageConfig('catalog/seo/category_url_suffix'); } } // Add the suffix, if this is set in the Magento configuration if (!empty($suffix) && !preg_match('/' . $suffix . '$/', $request)) { $request .= $suffix; } } // Add the $mode = $params->get('mode'); if (!empty($mode)) { $request .= '?mode=' . $mode; } // Set the request in the bridge $this->setRequest($request); // Handle the redirect request $redirect = JRequest::getString('redirect'); if (!empty($redirect)) { $bridge->setHttpReferer($redirect); } // Reuse this request to set the Canonical URL if (MagebridgeModelConfig::load('enable_canonical') == 1) { $uri = MageBridgeUrlHelper::route($request); $document = JFactory::getDocument(); $document->setMetaData('canonical', $uri); } // Set which block to display $this->setBlock('content'); parent::display($tpl); }
/** * Method to get the current store definition * * @param null * @return array */ public function getStore() { // If the database configuration specified no stores, skip this step if (MagebridgeModelConfig::load('load_stores') == 0) { return null; } // Get the conditions $db = JFactory::getDBO(); $db->setQuery("SELECT * FROM #__magebridge_stores WHERE `published`=1 ORDER BY `ordering`"); $conditions = $db->loadObjectList(); if (empty($conditions)) { return null; } // Import the plugins JPluginHelper::importPlugin('magebridgestore'); $plugins = JPluginHelper::getPlugin('magebridgestore'); // Try to match a condition with one of the connectors foreach ($conditions as $condition) { // Extract the parameters and make sure there's something to do $actions = YireoHelper::toRegistry($condition->actions)->toArray(); // Detect the deprecated connector-architecture if (!empty($condition->connector) && !empty($condition->connector_value)) { JFactory::getApplication()->triggerEvent('onMageBridgeStoreConvertField', array($condition, &$actions)); } // With empty actions, there is nothing to do if (empty($actions)) { continue; } // Loop through the plugins and validate the stored actions foreach ($plugins as $plugin) { $className = 'plg' . $plugin->type . $plugin->name; if (class_exists($className)) { $plugin = new $className($this, (array) $plugin); // Validate the stored actions if ($rt = $plugin->onMageBridgeValidate($actions, $condition)) { // Construct the condition parameters $name = $condition->name; $type = $condition->type == 'storeview' ? 'store' : 'group'; // Check for the return value if (is_array($rt)) { return $rt; } // Return the store-configuration of this condition return array('type' => $type, 'name' => $name); } } } } return null; }
public function display($tpl = null) { // Load the parameters $params = MageBridgeHelper::getParams(); $request = $params->get('request'); $this->setRequest($request); // Reuse this request to set the Canonical URL if (MagebridgeModelConfig::load('enable_canonical') == 1) { $uri = MageBridgeUrlHelper::route($request); $document = JFactory::getDocument(); $document->setMetaData('canonical', $uri); } // Set which block to display $this->setBlock('content'); parent::display($tpl); }
private function authenticate($auth) { if (!empty($auth) && !empty($auth['api_user']) && !empty($auth['api_key'])) { $api_user = MageBridgeEncryptionHelper::decrypt($auth['api_user']); $api_key = MageBridgeEncryptionHelper::decrypt($auth['api_key']); if ($api_user != MagebridgeModelConfig::load('api_user')) { MageBridgeModelDebug::getInstance()->error('XML-RPC plugin: API-authentication failed: Username did not match'); } elseif ($api_key != MagebridgeModelConfig::load('api_key')) { MageBridgeModelDebug::getInstance()->error('XML-RPC plugin: API-authentication failed: Key did not match'); } else { MageBridgeModelDebug::getInstance()->notice('XML-RPC plugin: API-authentication succeeded'); return true; } } return false; }
public function getSelectHTML($options) { $name = 'disable_css_mage'; $value = MageBridgeHelper::getDisableCss(); $current = MagebridgeModelConfig::load('disable_css_all'); if ($current == 1 || $current == 0) { $disabled = ' disabled="disabled"'; } else { $disabled = null; } if (!empty($options) && is_array($options)) { array_unshift($options, array('value' => '', 'label' => '- ' . JText::_('None') . ' -')); return JHTML::_('select.genericlist', $options, $name . '[]', 'multiple' . $disabled, 'value', 'label', $value); } return '<input type="text" name="' . $name . '" value="' . implode(',', $value) . '" />'; }
/** * Get a list of all the packages * * @param null * @return array */ public static function getPackageList() { $url = 'http://api.yireo.com/'; $domain = preg_replace('/\\:(.*)/', '', $_SERVER['HTTP_HOST']); $arguments = array('key' => MagebridgeModelConfig::load('supportkey'), 'domain' => $domain, 'resource' => 'packages', 'request' => 'magebridge'); foreach ($arguments as $name => $value) { $arguments[$name] = "{$name},{$value}"; } $url = $url . implode('/', $arguments); $proxy = MageBridgeModelProxy::getInstance(); $result = $proxy->getRemote($url, null, 'get', false); if (empty($result)) { return array(); } $packages = json_decode($result, true); if (empty($packages) || empty($packages['joomla'])) { return array(); } $packages = $packages['joomla']; // Load the currently configured connectors $db = JFactory::getDBO(); $query = 'SELECT DISTINCT(`connector`) FROM `#__magebridge_products`'; $db->setQuery($query); $usedConnectorsList = $db->loadObjectList(); $usedConnectors = array(); if (!empty($usedConnectorsList)) { foreach ($usedConnectorsList as $usedConnector) { if (!empty($usedConnector->connector)) { $usedConnectors[] = $usedConnector->connector; } } } // Process the postinstall queries foreach ($packages as $packageIndex => $package) { if ($package['type'] == 'module' && !empty($package['position'])) { $package['post_install_query'] = self::getPostInstallQuery('module', $package['name'], $package['position']); } if ($package['type'] == 'plugin' && !empty($package['enable'])) { $package['post_install_query'] = self::getPostInstallQuery('plugin', $package['file'], $package['group']); } if ($package['type'] == 'plugin' && $package['group'] == 'magebridgeproduct' && in_array($package['file'], $usedConnectors)) { $package['post_install_query'] = self::getPostInstallQuery('plugin', $package['file'], $package['group']); } $packages[$packageIndex] = $package; } return $packages; }
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); }
public function fetchElement($name, $value, &$node, $control_name) { // Add the control name if (!empty($control_name)) { $name = $control_name . '[' . $name . ']'; } // Only build a dropdown when the API-widgets are enabled if (MagebridgeModelConfig::load('api_widgets') == true) { // Fetch the widget data from the API $cache = JFactory::getCache('com_magebridge_admin'); $cache->setCaching(0); $options = $cache->call(array('JElementCustomerGroup', 'getResult')); // Parse the result into an HTML form-field if (!empty($options) && is_array($options)) { foreach ($options as $index => $option) { // Set default return-value $option['value'] = $option['customer_group_id']; // Customize the return-value when the XML-attribute "output" is defined if (is_object($node)) { $output = $node->attributes('output'); if (!empty($output) && array_key_exists($output, $option)) { $option['value'] = $option[$output]; } } // Strip empty options (like the "NOT LOGGED IN" group) if (empty($option['value']) || $option['value'] == 0) { unset($options[$index]); continue; } // Customize the label $option['label'] = $option['customer_group_code']; // Add the option back to the list of options $options[$index] = $option; } // Return a dropdown list array_unshift($options, array('value' => '', 'label' => '')); return JHTML::_('select.genericlist', $options, $name, null, 'value', 'label', $value); // Fetching data from the bridge failed, so report a warning } else { MageBridgeModelDebug::getInstance()->warning('Unable to obtain MageBridge API Widget "customer group": ' . var_export($options, true)); } } // Return a simple input-field by default return '<input type="text" name="' . $name . '" value="' . $value . '" />'; }
/** * Method to get the HTML of this element * * @param null * @return string */ protected function getInput() { $options = array(array('value' => 0, 'text' => JText::_('JNO')), array('value' => 1, 'text' => JText::_('JYES')), array('value' => 2, 'text' => JText::_('JONLY')), array('value' => 3, 'text' => JText::_('JALL_EXCEPT'))); foreach ($options as $index => $option) { $options[$index] = JArrayHelper::toObject($option); } $current = MagebridgeModelConfig::load('disable_js_all'); if ($current == 1 || $current == 0) { $disabled = 'disabled="disabled"'; } else { $disabled = null; } $html = null; $html .= JHTML::_('select.radiolist', $options, 'disable_js_all', 'class="btn-group"', 'value', 'text', $current); $html .= '<br/><br/>'; $html .= '<textarea type="text" id="disable_js_custom" name="disable_js_custom" ' . $disabled . 'rows="5" cols="40" maxlength="255">' . MagebridgeModelConfig::load('disable_js_custom') . '</textarea>'; return $html; }
protected function getInput() { $name = $this->name; $fieldName = $name; $value = $this->value; // Are the API widgets enabled? if (MagebridgeModelConfig::load('api_widgets') == true) { $bridge = MageBridgeModelBridge::getInstance(); $path = $bridge->getMageConfig('backend/path'); if (!empty($path)) { $html = '<input type="text" value="' . $path . '" disabled="disabled" />'; $html .= '<input type="hidden" name="' . $fieldName . '" value="' . $path . '" />'; return $html; } else { MageBridgeModelDebug::getInstance()->warning('Unable to obtain MageBridge API Widget "backend"'); } } return '<input type="text" name="' . $fieldName . '" value="' . $value . '" />'; }
public function display($tpl = null) { $this->setTitle('Control Panel'); $lang = JFactory::getLanguage(); $alignment = $lang->isRTL() ? 'right' : 'left'; $this->assignRef('alignment', $alignment); $icons = array(); $icons[] = $this->icon('config', 'Configuration', 'config.png'); $icons[] = $this->icon('stores', 'Store Conditions', 'store.png'); $icons[] = $this->icon('products', 'Product Relations', 'product.png'); $icons[] = $this->icon('connectors', 'Connectors', 'connect.png'); $icons[] = $this->icon('users', 'Users', 'user.png'); $icons[] = $this->icon('check', 'System Check', 'cpanel.png'); $icons[] = $this->icon('logs', 'Logs', 'info.png'); $icons[] = $this->icon('update', 'Update', 'install.png'); $icons[] = $this->icon('cache', 'Empty Cache', 'trash.png'); $icons[] = $this->icon('magento', 'Magento Admin', 'magento.png', '_blank'); $icons[] = $this->icon('tutorials', 'Tutorials', 'tutorials.png', '_blank'); $icons[] = $this->icon('forum', 'Forum', 'forum.png', '_blank'); $this->assignRef('icons', $icons); //jimport('joomla.html.pane'); //$pane = JPane::getInstance('sliders'); //$this->assignRef('pane', $pane); $current_version = MageBridgeUpdateHelper::getComponentVersion(); $this->assignRef('current_version', $current_version); $changelog_url = 'http://www.yireo.com/tutorials/magebridge/updates/975-magebridge-changelog'; $this->assignRef('changelog_url', $changelog_url); $jed_url = 'http://extensions.joomla.org/extensions/bridges/e-commerce-bridges/9440'; $this->assignRef('jed_url', $jed_url); $backend_feed = MagebridgeModelConfig::load('backend_feed'); $this->assignRef('backend_feed', $backend_feed); if ($backend_feed == 1) { $this->ajax('index.php?option=com_magebridge&view=home&format=ajax&layout=feeds', 'latest_news'); $this->ajax('index.php?option=com_magebridge&view=home&format=ajax&layout=promotion', 'promotion'); $document = JFactory::getDocument(); if (JURI::getInstance()->isSSL() == true) { $document->addStylesheet('https://fonts.googleapis.com/css?family=Just+Me+Again+Down+Here'); } else { $document->addStylesheet('http://fonts.googleapis.com/css?family=Just+Me+Again+Down+Here'); } } parent::display($tpl); }
public function fetchElement($name, $value, &$node, $control_name) { // Add the control name if (!empty($control_name)) { $name = $control_name . '[' . $name . ']'; } // Only build a dropdown when the API-widgets are enabled if (MagebridgeModelConfig::load('api_widgets') == true) { // Fetch the widget data from the API $options = MageBridgeWidgetHelper::getWidgetData('cmspage'); // Parse the result into an HTML form-field if (!empty($options) && is_array($options)) { foreach ($options as $index => $option) { // Customize the return-value when the XML-attribute "output" is defined if (is_object($node)) { $output = $node->attributes('output'); if (!empty($output) && array_key_exists($output, $option)) { $option['value'] = $option[$output]; } } // Customize the label $option['label'] = $option['label'] . ' (' . $option['value'] . ') '; // Add the option back to the list of options $options[$index] = $option; // Support the new format "[0-9]:(.*)" if (preg_match('/([0-9]+)\\:/', $value) == false) { $v = explode(':', $option['value']); if ($v[1] == $value) { $value = $option['value']; } } } // Return a dropdown list array_unshift($options, array('value' => '', 'label' => '')); return JHTML::_('select.genericlist', $options, $name, null, 'value', 'label', $value); // Fetching data from the bridge failed, so report a warning } else { MageBridgeModelDebug::getInstance()->warning('Unable to obtain MageBridge API Widget "cmspage": ' . var_export($options, true)); } } // Return a simple input-field by default return '<input type="text" name="' . $name . '" value="' . $value . '" />'; }
/** * Display method * * @param string $tpl * @return null */ public function display($tpl = null) { // Add CSS-code $this->addCss('backend.css', 'media/com_magebridge/css/'); if (MageBridgeHelper::isJoomla25()) { $this->addCss('backend-j25.css', 'media/com_magebridge/css/'); } if (MageBridgeHelper::isJoomla35()) { $this->addCss('backend-j35.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::_('COM_MAGEBRIDGE_VIEW_API_ERROR_EMPTY_METADATA'); break; case 'SUPPORTKEY FAILED': $message = JText::sprintf('COM_MAGEBRIDGE_VIEW_API_ERROR_KEY_FAILED', $bridge->getApiExtra()); break; case 'AUTHENTICATION FAILED': $message = JText::_('COM_MAGEBRIDGE_VIEW_API_ERROR_AUTHENTICATION_FAILED'); break; case 'INTERNAL ERROR': $message = JText::sprintf('COM_MAGEBRIDGE_VIEW_API_ERROR_INTERNAL_ERROR', MageBridgeHelper::getHelpLink('troubleshooting')); break; case 'FAILED LOAD': $message = JText::sprintf('COM_MAGEBRIDGE_VIEW_API_ERROR_FAILED_LOAD', MageBridgeHelper::getHelpLink('faq-troubleshooting:api-widgets')); break; default: $message = JText::sprintf('COM_MAGEBRIDGE_VIEW_API_ERROR_GENERIC', $bridge->getApiState()); break; } MageBridgeModelDebug::getInstance()->feedback($message); } // If debugging is enabled report it if (MagebridgeModelConfig::load('debug') == 1 && JFactory::getApplication()->input->getCmd('tmpl') != 'component' && in_array(JFactory::getApplication()->input->getCmd('view'), array('config', 'home'))) { MageBridgeModelDebug::getInstance()->feedback('COM_MAGEBRIDGE_VIEW_API_DEBUGGING_ENABLED'); } parent::display($tpl); }
public function fetchElement($name, $value, &$node, $control_name) { // Add the control name if (!empty($control_name)) { $name = $control_name . '[' . $name . ']'; } // Are the API widgets enabled? if (MagebridgeModelConfig::load('api_widgets') == true) { $bridge = MageBridgeModelBridge::getInstance(); $path = $bridge->getMageConfig('backend/path'); if (!empty($path)) { $html = '<input type="text" value="' . $path . '" disabled="disabled" />'; $html .= '<input type="hidden" name="' . $name . '" value="' . $path . '" />'; return $html; } else { MageBridgeModelDebug::getInstance()->warning('Unable to obtain MageBridge API Widget "backend"'); } } return '<input type="text" name="' . $name . '" value="' . $value . '" />'; }