示例#1
0
 /**
  * Load the parameters of the User-plugin
  * 
  * @access private
  * @param null
  * @return JParameter
  */
 private function getUserParams()
 {
     require_once JPATH_SITE . '/components/com_magebridge/helpers/loader.php';
     $plugin = JPluginHelper::getPlugin('user', 'magebridge');
     $params = YireoHelper::toRegistry($plugin->params);
     return $params;
 }
示例#2
0
 public static function getDBO()
 {
     if (YireoHelper::isJoomla15()) {
         return JFactory::getDBO();
     }
     return JFactory::getDbo();
 }
示例#3
0
 /**
  * Event onAfterInitialise
  */
 public function onAfterInitialise()
 {
     // Don't do anything if MageBridge is not enabled
     if ($this->isEnabled() == false) {
         return false;
     }
     // Perform actions on the frontend
     $application = JFactory::getApplication();
     // Check for postlogin-cookie
     if (isset($_COOKIE['mb_postlogin']) && !empty($_COOKIE['mb_postlogin'])) {
         // If the user is already logged in, remove the cookie
         if (JFactory::getUser()->id > 0) {
             setcookie('mb_postlogin', '', time() - 3600, '/', '.' . JURI::getInstance()->toString(array('host')));
         }
         // Otherwise decrypt the cookie and use it here
         $data = MageBridgeEncryptionHelper::decrypt($_COOKIE['mb_postlogin']);
         if (!empty($data)) {
             $customer_email = $data;
         }
     }
     // Perform a postlogin if needed
     if (YireoHelper::isJoomla35()) {
         $post = $application->input->post->getArray();
     }
     if (empty($post)) {
         $postlogin_userevents = $this->params->get('postlogin_userevents', 0) == 1 ? true : false;
         if (empty($customer_email)) {
             $customer_email = MageBridgeModelBridge::getInstance()->getSessionData('customer/email');
         }
         if (!empty($customer_email)) {
             MageBridge::getUser()->postlogin($customer_email, null, $postlogin_userevents);
         }
     }
 }
示例#4
0
 /**
  * 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();
 }
示例#5
0
 /**
  * Display method
  *
  * @param string $tpl
  * @return null
  */
 public function display($tpl = null)
 {
     // Fetch this item
     $this->fetchItem();
     // Initialize the form-file
     $file = JPATH_ADMINISTRATOR . '/components/com_magebridge/models/product.xml';
     // Prepare the params-form
     $params = YireoHelper::toRegistry($this->item->params)->toArray();
     $params_form = JForm::getInstance('params', $file);
     $params_form->bind(array('params' => $params));
     $this->params_form = $params_form;
     // Prepare the actions-form
     $actions = YireoHelper::toRegistry($this->item->actions)->toArray();
     $actions_form = JForm::getInstance('actions', $file);
     JPluginHelper::importPlugin('magebridgeproduct');
     JFactory::getApplication()->triggerEvent('onMageBridgeProductPrepareForm', array(&$actions_form, (array) $this->item));
     $actions_form->bind(array('actions' => $actions));
     $this->actions_form = $actions_form;
     // Build the fields
     $this->lists['product'] = MageBridgeFormHelper::getField('magebridge.product', 'sku', $this->item->sku, null);
     // Check for a previous connector-value
     if (!empty($this->item->connector)) {
         $plugin = JPluginHelper::getPlugin('magebridgeproduct', $this->item->connector);
         if (empty($plugin)) {
             $plugin_warning = JText::sprintf('COM_MAGEBRIDGE_PRODUCT_PLUGIN_WARNING', $this->item->connector);
             JError::raiseWarning(500, $plugin_warning);
         }
     }
     parent::display($tpl);
 }
示例#6
0
 /**
  * Method to get the ordering query
  *
  * @access public 
  * @param null
  * @return string
  */
 public function getOrderingQuery()
 {
     if (YireoHelper::isJoomla15()) {
         $query = 'SELECT `ordering` AS `value`, `title` AS `text` FROM `#__categories` WHERE `section`="com_simplelists" ORDER BY ordering';
     } else {
         $query = 'SELECT `lft` AS `value`, `title` AS `text` FROM `#__categories` WHERE `extension`="com_simplelists" ORDER BY lft';
     }
     return $query;
 }
示例#7
0
 /**
  * Method to build the database query
  *
  * @access protected
  * @param null
  * @return mixed
  */
 protected function buildQuery()
 {
     if (YireoHelper::isJoomla15()) {
         $query = "SELECT `plugin`.*, {access}, {editor} FROM `#__plugins` AS `plugin`\n";
     } else {
         $query = "SELECT `plugin`.*, {access}, {editor} FROM `#__extensions` AS `plugin`\n";
     }
     return parent::buildQuery($query);
 }
示例#8
0
 /**
  * Display method
  *
  * @param string $tpl
  *
  * @return string
  */
 public function display($tpl = null)
 {
     // Add CSS
     JHTML::stylesheet('media/com_magebridge/css/backend-elements.css');
     // Load jQuery
     YireoHelper::jquery();
     $this->current = JFactory::getApplication()->input->get('current');
     $this->object = JFactory::getApplication()->input->get('object');
     parent::display($tpl);
 }
示例#9
0
 /**
  * Display method
  *
  * @param string $tpl
  * @return null
  */
 public function display($tpl = null)
 {
     // Set toolbar items for the page
     JToolBarHelper::custom('export', 'export.png', null, 'Export', false);
     JToolBarHelper::custom('import', 'import.png', null, 'Import', false);
     // Initialize common variables
     $application = JFactory::getApplication();
     $option = JFactory::getApplication()->input->getCmd('option') . '-users';
     // Handle the filters
     $filter_type = $application->getUserStateFromRequest($option . 'filter_type', 'filter_type', '', 'word');
     $filter_state = $application->getUserStateFromRequest($option . 'filter_state', 'filter_state', '', 'word');
     $filter_order = $application->getUserStateFromRequest($option . 'filter_order', 'filter_order', 'p.ordering', 'cmd');
     $filter_order_Dir = $application->getUserStateFromRequest($option . 'filter_order_Dir', 'filter_order_Dir', '', 'word');
     // Get data from the model
     $this->fetchItems();
     $items = $this->get('Data');
     $total = $this->get('Total');
     $pagination = $this->get('Pagination');
     // Table ordering
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     // Prepare the items for display
     if (!empty($items)) {
         // Get a matching user list from the API
         $musers = $this->getMagentoUsers($items);
         foreach ($items as $index => $item) {
             $item->magento_name = null;
             $item->magento_id = null;
             if (!empty($musers)) {
                 foreach ($musers as $muser) {
                     if ($muser['email'] == $item->email) {
                         $item->magento_name = $muser['name'];
                         $item->magento_id = $muser['entity_id'];
                         break;
                     }
                 }
             }
             // Make sure demo-users are not seeing any sensitive data
             if (MageBridgeAclHelper::isDemo() == true) {
                 $censored_values = array('name', 'username', 'email', 'magento_name');
                 foreach ($censored_values as $censored_value) {
                     $item->{$censored_value} = str_repeat('*', YireoHelper::strlen($item->{$censored_value}));
                 }
             }
             $item->migrate_link = 'index.php?option=com_magebridge&view=user&task=migrate&cid[]=' . $item->id;
             $items[$index] = $item;
         }
     }
     $this->user = JFactory::getUser();
     $this->lists = $lists;
     $this->items = $items;
     $this->pagination = $pagination;
     parent::display($tpl);
 }
示例#10
0
 public function getId($category_alias = null)
 {
     $db = YireoHelper::getDBO();
     if (YireoHelper::isJoomla15()) {
         $query = "SELECT `id` FROM `#__categories` WHERE `alias`=" . $db->quote($category_alias) . " AND `section`='com_simplelists' LIMIT 1";
     } else {
         $query = "SELECT `id` FROM `#__categories` WHERE `alias`=" . $db->quote($category_alias) . " AND `extension`='com_simplelists' LIMIT 1";
     }
     $db->setQuery($query);
     return $db->loadResult();
 }
示例#11
0
 /**
  * Load the parameters
  * 
  * @access private
  * @param null
  * @return JParameter
  */
 private function getParams()
 {
     if (YireoHelper::isJoomla15() == false) {
         return $this->params;
     } else {
         jimport('joomla.html.parameter');
         $plugin = JPluginHelper::getPlugin('content', 'simplelists');
         $params = new JParameter($plugin->params);
         return $params;
     }
 }
示例#12
0
 /**
  * Constructor
  *
  * @param object Database connector object
  */
 public function __construct(&$db)
 {
     // Initialize the default values
     if (YireoHelper::isJoomla15()) {
         $this->_defaults = array('section' => 'com_simplelists');
     } else {
         $this->_defaults = array('extension' => 'com_simplelists', 'level' => 1);
     }
     // Set the required fields
     $this->_required = array('title');
     parent::__construct('#__categories', 'id', $db);
 }
示例#13
0
 public static function isAuthorized()
 {
     // Initialize system variables
     $user =& JFactory::getUser();
     // Check the ACLs for Joomla! 1.5
     if (YireoHelper::isJoomla15() && !$user->authorize('com_simplelists', 'manage')) {
         return false;
         // Check the ACLs for Joomla! 1.6 and later
     } elseif (YireoHelper::isJoomla15() == false && $user->authorise('core.manage', 'com_simplelists') == false) {
         return false;
     }
     return true;
 }
示例#14
0
 public function display($tpl = null)
 {
     switch ($this->jinput->get('layout')) {
         case 'feeds':
             $feeds = $this->fetchFeeds('http://www.yireo.com/blog?format=feed&type=rss', 3);
             $this->feeds = $feeds;
             break;
         case 'promotion':
             $html = YireoHelper::fetchRemote('http://www.yireo.com/advertizement.php', $this->_option);
             print $html;
             exit;
     }
     parent::display($tpl);
 }
示例#15
0
 public function display($tpl = null)
 {
     switch (JRequest::getVar('layout')) {
         case 'feeds':
             $feeds = $this->fetchFeeds('http://www.yireo.com/blog?format=feed&type=rss', 3);
             $this->assignRef('feeds', $feeds);
             break;
         case 'promotion':
             $html = YireoHelper::fetchRemote('http://www.yireo.com/advertizement.php', 'SimpleLists');
             print $html;
             exit;
     }
     parent::display($tpl);
 }
示例#16
0
 /**
  * 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;
 }
示例#17
0
 public function getMenuItems()
 {
     static $items = null;
     if (empty($items)) {
         $component =& JComponentHelper::getComponent('com_simplelists');
         $menu =& JSite::getMenu();
         if (YireoHelper::isJoomla15()) {
             $items = $menu->getItems('componentid', $component->id);
         } else {
             $items = $menu->getItems('component_id', $component->id);
         }
     }
     return $items;
 }
示例#18
0
 public function display($tpl = null)
 {
     JResponse::allowCache(false);
     if (YireoHelper::isJoomla15()) {
         JHTML::_('stylesheet', 'popup-imagelist.css', 'administrator/components/com_media/assets/');
     } else {
         JHTML::_('stylesheet', 'popup-imagelist.css', 'media/media/css/');
     }
     JHTML::_('behavior.mootools');
     JHTML::_('behavior.modal');
     $this->assignRef('files', $this->get('files'));
     $this->assignRef('folders', $this->get('folders'));
     $this->assignRef('state', $this->get('state'));
     parent::display($tpl);
 }
示例#19
0
 public function display($tpl = null)
 {
     // Get system variables
     $application = JFactory::getApplication();
     $document = JFactory::getDocument();
     // Get the item from our model
     $this->fetchItem();
     // Set the meta-data
     $document->setTitle($this->item->title);
     $document->setMetaData('title', $this->item->title);
     // Initialize the parameters
     if ($this->item->params) {
         $p = clone $this->params;
         $this->item->params = YireoHelper::toParameter($this->item->params);
         $p->merge($this->item->params);
         $this->item->params = $p;
     } else {
         $this->item->params = $this->params;
     }
     if ($this->item->params->get('meta_author') != '') {
         $document->setMetaData('author', $this->item->params->get('meta_author'));
     }
     if ($this->item->params->get('meta_description') != '') {
         $document->setDescription($this->item->params->get('meta_description'));
     }
     if ($this->item->params->get('meta_keywords') != '') {
         $document->setMetadata('keywords', $this->item->params->get('meta_keywords'));
     }
     // Parse important parameters
     $layout = null;
     $this->item = $this->_prepareItem($this->item, $layout);
     // Check whether the item is still here
     if (empty($this->item)) {
         JError::raiseError(404, JText::_('Resource Not Found'));
     }
     // when the link was "hidden", we call the link-plugin to decide what to do
     if (JRequest::getCmd('task') == 'hidden') {
         $this->item->params->set('show_link', 0);
         $this->item->extra = SimplelistsPluginHelper::getPluginLinkHidden($item);
     } else {
         $this->item->extra = null;
     }
     parent::display($tpl);
 }
示例#20
0
 /**
  * Method to do something on purchase
  *
  * @param string $sku
  * @param JUser $user
  * @param string $status
  * @return mixed
  */
 public function runOnPurchase($sku = null, $qty = 1, $user = null, $status = null, $arguments = null)
 {
     // Get the conditions
     $conditions = $this->getConditions($sku);
     if (empty($conditions)) {
         return null;
     }
     // Import the plugins
     JPluginHelper::importPlugin('magebridgeproduct');
     // Foreach of these conditions, run the product-plugins
     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('onMageBridgeProductConvertField', array($condition, &$actions));
         }
         // With empty actions, there is nothing to do
         if (empty($actions)) {
             continue;
         }
         // Check for the parameters
         if (!empty($condition->params)) {
             $params = YireoHelper::toRegistry($condition->params);
             $allowed_statuses = $params->get('allowed_status', array('any'));
             $expire_amount = $params->get('expire_amount', 0);
             $expire_unit = $params->get('expire_unit', 'day');
         } else {
             $allowed_statuses = array('any');
             $expire_amount = 0;
             $expire_unit = null;
         }
         // Do not continue if the order-status is not matched
         if (!empty($allowed_statuses) && !in_array('any', $allowed_statuses) && !in_array($status, $allowed_statuses)) {
             continue;
         }
         // Run the product plugins
         JFactory::getApplication()->triggerEvent('onMageBridgeProductPurchase', array($actions, $user, $status, $sku));
         // Log this event
         $this->saveLog($user->id, $sku, $expire_unit, $expire_amount);
     }
 }
示例#21
0
 public static function remove($files = array())
 {
     if (empty($files)) {
         $files = YireoHelper::getData('obsolete_files');
     }
     if (!empty($files)) {
         foreach ($files as $file) {
             if (file_exists($file)) {
                 if (is_file($file)) {
                     jimport('joomla.filesystem.file');
                     JFile::delete($file);
                 }
                 if (is_dir($file)) {
                     jimport('joomla.filesystem.folder');
                     JFolder::delete($file);
                 }
             }
         }
     }
 }
示例#22
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;
 }
示例#23
0
 /**
  * Method to display a print-icon
  *
  * @access public
  * @param null
  * @return string HTML output
  */
 public function print_popup()
 {
     // Construct the URL
     $url = 'index.php?option=com_simplelists&view=items';
     if (JRequest::getInt('category_id') > 0) {
         $url .= '&category_id=' . JRequest::getInt('category_id');
     }
     if (JRequest::getInt('Itemid') > 0) {
         $url .= '&Itemid=' . JRequest::getInt('Itemid');
     }
     $url .= '&tmpl=component';
     // Add JavaScript variables
     $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no';
     // Checks template image directory for image, if non found default are loaded
     $image_folder = YireoHelper::isJoomla15() ? '/images/M_images/' : '/media/system/images/';
     $text = JHTML::_('image.site', 'printButton.png', $image_folder, NULL, NULL, JText::_('Print'));
     // Construct the link-attributes
     $attribs['title'] = JText::_('Print');
     $attribs['onclick'] = "window.open(this.href,'win2','" . $status . "'); return false;";
     $attribs['rel'] = 'nofollow';
     return JHTML::_('link', JRoute::_($url), $text);
 }
示例#24
0
 /**
  * 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'];
         $allowRoot = (string) $this->element['allow_root'];
         $title = $value;
         $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
         $link = 'index.php?option=com_magebridge&view=element&tmpl=component&ajax=1';
         $link .= '&type=category&object=' . $id . '&return=' . $returnType;
         $link .= '&allow_root=' . $allowRoot . '&current=' . $value;
         $html = array();
         if (YireoHelper::isJoomla25()) {
             $html[] = '<div style="float: left;">';
             $html[] = '<input type="text" id="' . $id . '" name="' . $name . '" value="' . $title . '" />';
             $html[] = '</div>';
             $html[] = '<div class="button2-left"><div class="blank">';
             $html[] = '<a class="modal btn" title="' . JText::_('JSELECT') . '"  href="' . $link . '" rel="{handler: \'iframe\', size: {x:800, y:450}}">' . JText::_('JSELECT') . '</a>';
             $html[] = '</div></div>' . "\n";
         } else {
             $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 . '" />';
 }
示例#25
0
 /**
  * Helper-method to get the specified Menu-Item
  *
  * @param int $id
  *
  * @return object
  */
 public static function getItem($id = 0)
 {
     $items = MageBridgeUrlHelper::getMenuItems();
     if (!empty($items)) {
         foreach ($items as $item) {
             if ($item->id == $id) {
                 if (!isset($item->route)) {
                     $item->route = null;
                 }
                 if (!isset($item->query)) {
                     $item->query = array();
                 }
                 if (!isset($item->query['view'])) {
                     $item->query['view'] = 'root';
                 }
                 if (!isset($item->query['request'])) {
                     $item->query['request'] = null;
                 }
                 if (!isset($item->query['layout'])) {
                     $item->query['layout'] = null;
                 }
                 // If the parameters include the request, set is as query-request
                 if (!empty($item->params)) {
                     if (is_object($item->params)) {
                         $item->params = YireoHelper::toRegistry($item->params);
                     }
                     if (is_object($item->params)) {
                         $item->query['request'] = $item->params->get('request');
                     }
                 }
                 return $item;
             }
         }
     }
     return null;
 }
示例#26
0
 public function setTitle($title = null, $class = 'logo')
 {
     $component_title = YireoHelper::getData('title');
     $title = JText::_('LIB_YIREO_VIEW_HOME');
     if (file_exists(JPATH_SITE . '/media/' . $this->_option . '/images/' . $class . '.png')) {
         JToolBarHelper::title($component_title . ': ' . $title, $class);
     } else {
         JToolBarHelper::title($component_title . ': ' . $title, 'generic.png');
     }
 }
示例#27
0
 /**
  * Helper-method to return the Joomla! usergroup based on the current Magento customergroup
  *
  * @param null
  * @return array
  */
 public static function getJoomlaGroupIds($customer, $current_groups = array())
 {
     if (!isset($customer['group_id'])) {
         return array();
     }
     static $rows = null;
     if (!is_array($rows)) {
         $db = JFactory::getDBO();
         $query = 'SELECT `magento_group`,`joomla_group`,`params` ' . ' FROM #__magebridge_usergroups WHERE `published`=1 ORDER BY `ordering`';
         $db->setQuery($query);
         $rows = $db->loadObjectList();
     }
     if (!empty($rows)) {
         foreach ($rows as $row) {
             if ($row->magento_group == $customer['group_id']) {
                 $override_existing = false;
                 $new_groups = array($row->joomla_group);
                 if (!empty($row->params)) {
                     $params = YireoHelper::toRegistry($row->params);
                     $override_existing = (bool) $params->get('override_existing');
                     $extra_groups = $params->get('usergroup');
                     if (!empty($extra_groups)) {
                         foreach ($extra_groups as $extra_group) {
                             $new_groups[] = $extra_group;
                         }
                     }
                     $new_groups = array_unique($new_groups);
                 }
                 if ($override_existing == true) {
                     return $new_groups;
                 } else {
                     return array_merge($current_groups, $new_groups);
                 }
             }
         }
     }
     return $current_groups;
 }
示例#28
0
                }
            }
        }
        if (JFactory::getApplication()->input->getCmd('current') == $return) {
            $css[] = 'current';
        }
        $css = array();
        if (isset($product['status']) && $product['status'] == 1) {
            $css[] = 'active';
        } else {
            $css[] = 'inactive';
        }
        if (YireoHelper::strlen($product['name']) > 50) {
            $product['name'] = substr($product['name'], 0, 47) . '...';
        }
        if (YireoHelper::strlen($product['url_key']) > 30) {
            $product['url_key'] = substr($product['url_key'], 0, 27) . '...';
        }
        $product_name = htmlspecialchars(str_replace("'", '', $product['name']));
        $jsDefault = "window.parent.jSelectProduct('{$return}', '{$product_name}', '" . JFactory::getApplication()->input->get('object') . "');";
        ?>
				<tr class="<?php 
        echo implode(' ', $css);
        ?>
">
					<td>
						<?php 
        echo $this->pagination->getRowOffset($i);
        ?>
					</td>
					<td>
示例#29
0
/**
 * Function to convert a system URL to a SEF URL
 */
function MagebridgeBuildRoute(&$query)
{
    // If there's only an Itemid (and an option), skip because this Menu-Item is fine already
    if (isset($query['Itemid']) && count($query) <= 2 && MageBridgeUrlHelper::enforceRootMenu() == false) {
        return array();
    }
    // Initialize some parts
    $segments = array();
    $Itemid = isset($query['Itemid']) ? $query['Itemid'] : 0;
    $orig_Itemid = $Itemid;
    // Get the menu items for this component
    $items = MageBridgeUrlHelper::getMenuItems();
    $current_item = MageBridgeUrlHelper::getItem($Itemid);
    // Strip the slug
    if (!empty($query['request']) && preg_match('/^([0-9]+)\\:(.*)/', $query['request'], $match)) {
        $query['id'] = $match[1];
        $query['request'] = $match[2];
    }
    // Try to match the current query with a Menu-Item
    if (!empty($items)) {
        foreach ($items as $item) {
            // Match a specific combination of view-layout-request
            if (!empty($item->query['request']) && !empty($query['request']) && isset($item->query['view']) && isset($query['view']) && $item->query['view'] == $query['view'] && isset($item->query['layout']) && isset($query['layout']) && $item->query['layout'] == $query['layout']) {
                // Match a specific combination of view-layout-request (string)
                if ($item->query['request'] == $query['request']) {
                    $query = array('option' => 'com_magebridge', 'Itemid' => $item->id);
                    return array();
                    // Match a specific combination of view-layout-request (ID)
                } else {
                    if (isset($query['id']) && $item->query['request'] == $query['id']) {
                        $query = array('option' => 'com_magebridge', 'Itemid' => $item->id);
                        return array();
                    }
                }
                // Match a specific combination of view-layout
            } else {
                if (empty($query['request']) && isset($item->query['view']) && isset($query['view']) && $item->query['view'] == $query['view'] && isset($item->query['layout']) && isset($query['layout']) && $item->query['layout'] == $query['layout']) {
                    $query = array('option' => 'com_magebridge', 'Itemid' => $item->id);
                    return array();
                }
            }
        }
    }
    // Fetch the Root-Item
    $query_option = isset($query['option']) ? $query['option'] : null;
    $query_view = isset($query['view']) ? $query['view'] : null;
    if ($query_option == 'com_magebridge' && $query_view == 'root' && !empty($query['Itemid'])) {
        $root_item = false;
        $root_item_id = false;
    } else {
        $root_item = MageBridgeUrlHelper::getRootItem();
        $root_item_id = $root_item && $root_item->id > 0 ? $root_item->id : false;
    }
    // Set a default empty view
    if (!isset($query['view'])) {
        $query['view'] = null;
    }
    // Reset fake views (used by JCE editor)
    if (in_array($query['view'], array('product', 'category'))) {
        $query['view'] = 'root';
    }
    // If there is a root-item (and therefor "use_rootmenu" is enabled), see if we need to replace the current URL with the root-items URL
    if ($root_item_id > 0) {
        // If there is a root-view or when "enforce_rootmenu" is enabled, reset the Itemid to the Root Menu-Item
        if ($query['view'] == 'root' || MageBridgeUrlHelper::enforceRootMenu()) {
            $query['Itemid'] = $root_item_id;
        }
        // Build the Magento request based upon the current Menu-Item
        if (!empty($current_item)) {
            // Get data from the current Menu-Item
            $cparams = YireoHelper::toRegistry($current_item->params);
            $cquery = $current_item->query;
            // Complete the Magento request if it is still empty
            if (empty($query['request']) && $query['Itemid'] == $root_item_id) {
                // Determine the request if set in the $query['link']
                if (empty($cquery['request'])) {
                    parse_str(preg_replace('/^index.php\\?/', '', $current_item->link), $link);
                    if (!empty($link['request'])) {
                        $cquery['request'] = $link['request'];
                    }
                }
                // Use the MVC-layout to determine the request
                if (!empty($query['layout'])) {
                    $query['request'] = MageBridgeUrlHelper::getLayoutUrl($query['layout']);
                    // Use the MVC-layout plus the current request to determine the request (f.i. configured Menu-Items)
                } else {
                    if (!empty($cquery['layout'])) {
                        $query['request'] = MageBridgeUrlHelper::getLayoutUrl($cquery['layout'], $cquery['request']);
                        // Use the Menu-Item request as Magento request
                    } else {
                        if (!empty($cquery['request'])) {
                            $query['request'] = $cquery['request'];
                            // Use the Menu-Item parameter as Magento request
                        } else {
                            if ($cparams->get('request') != '') {
                                $query['request'] = $cparams->get('request');
                                // Obsolete?
                                //} else if ($current_item->id != $root_item_id) {
                                //	$query['request'] = $current_item->route;
                            }
                        }
                    }
                }
            }
            if (isset($query['request']) && is_numeric($query['request']) && !empty($query['layout'])) {
                $query['request'] = MageBridgeUrlHelper::getLayoutUrl($query['layout'], $query['request']);
            }
            // Enforce the Itemid of the MageBridge Root upon the current route
            if (MageBridgeUrlHelper::enforceRootMenu() && !in_array($root_item_id, $current_item->tree)) {
                $query['Itemid'] = $root_item_id;
                $query['view'] = 'root';
                // If the request is not empty, set the route to the MageBridge Root
            } else {
                if (!empty($query['request'])) {
                    $query['Itemid'] = $root_item_id;
                }
            }
            // If there is no current item, assume to apply the Itemid of the MageBridge Root
        } else {
            $query['Itemid'] = $root_item_id;
        }
    }
    // Add the request as only segment
    if (!empty($query['request']) && !empty($query['Itemid']) && $query['Itemid'] == $root_item_id) {
        $segments[] = $query['request'];
    } else {
        if (!empty($query['request']) && (empty($root_item_id) && $query['view'] == 'root')) {
            $segments[] = $query['request'];
        }
    }
    // Unset an Itemid that does not make sense
    if (isset($query['Itemid']) && $query['Itemid'] == 0) {
        unset($query['Itemid']);
    }
    // Unset all unneeded query-parts because they should be now either segmented or referenced from the Itemid
    $unset_elements = array('view', 'task', 'request', 'layout', 'format', 'SID', 'language', 'id');
    foreach ($unset_elements as $u) {
        unset($query[$u]);
    }
    // Return the segments
    return $segments;
}
示例#30
0
        $this->setFolder($i);
        echo $this->loadTemplate('default_folder');
    }
}
if (count($this->files) > 0) {
    for ($i = 0, $n = count($this->files); $i < $n; $i++) {
        $this->setFile($i);
        echo $this->loadTemplate('default_item');
    }
}
if (!is_readable(JPATH_SITE . DS . $base_path)) {
    $message = JText::_('Folder not readable');
} elseif (empty($this->files) && empty($this->folders)) {
    $message = JText::_('No files or folders found');
} elseif (empty($this->files)) {
    $message = JText::_('No files found');
}
if (!empty($message)) {
    echo '<div id="files-message">' . $message . '</div>';
}
?>
    </div>

	<input type="hidden" id="dirPath" name="dirPath" />
	<input type="hidden" id="f_file" name="f_file" />
	<input type="hidden" id="tmpl" name="component" />
</form>
<?php 
if (YireoHelper::isJoomla15() == false) {
    echo $this->loadTemplate('default_upload');
}