Exemplo n.º 1
0
 public function showDefaultForm($tpl = null)
 {
     // Initialize the view
     $this->setTitle('Edit default store');
     // Load values from the configuration
     $storegroup = MageBridgeModelConfig::load('storegroup');
     $storeview = MageBridgeModelConfig::load('storeview');
     // Construct the arguments for the HTML-element
     if (!empty($storeview)) {
         $type = 'storeview';
         $name = $storeview;
     } else {
         if (!empty($storegroup)) {
             $type = 'storegroup';
             $name = $storegroup;
         } else {
             $type = null;
             $name = null;
         }
     }
     // Fetch the HTML-element
     $fields = array();
     $fields['store'] = $this->getFieldStore($type, $name);
     $this->assignRef('fields', $fields);
     parent::display($tpl);
 }
Exemplo n.º 2
0
 /**
  * Method to prepare the content for display
  *
  * @param string $tpl
  * @return null
  */
 public function showDefaultForm($tpl = null)
 {
     // Initialize the view
     $this->setTitle(JText::_('COM_MAGEBRIDGE_VIEW_STORE_DEFAULT_STORE'));
     // Override the normal toolbar
     JToolBarHelper::cancel();
     JToolBarHelper::save();
     JToolBarHelper::apply();
     // Load values from the configuration
     $storegroup = MageBridgeModelConfig::load('storegroup');
     $storeview = MageBridgeModelConfig::load('storeview');
     // Construct the arguments for the HTML-element
     if (!empty($storeview)) {
         $type = 'storeview';
         $name = $storeview;
     } else {
         if (!empty($storegroup)) {
             $type = 'storegroup';
             $name = $storegroup;
         } else {
             $type = null;
             $name = null;
         }
     }
     // Fetch the HTML-element
     $this->lists['store'] = $this->getFieldStore($type, $name);
     parent::display($tpl);
 }
Exemplo n.º 3
0
 public function getDefault()
 {
     // Construct the default object
     $default = (object) null;
     $default->id = null;
     $default->name = null;
     $default->title = null;
     $default->type = null;
     $default->connector = null;
     $default->connector_value = null;
     $default->hasState = false;
     $default->hasOrdering = false;
     $default->label = JText::_('JDEFAULT');
     $default->custom_edit_link = 'index.php?option=com_magebridge&view=store&task=default';
     // Load the configuration values
     $storegroup = MageBridgeModelConfig::load('storegroup');
     $storeview = MageBridgeModelConfig::load('storeview');
     if (!empty($storeview)) {
         $default->name = $storeview;
         $default->type = 'COM_MAGEBRIDGE_VIEW_STORE_FIELD_TYPE_VALUE_VIEW';
     } else {
         if (!empty($storegroup)) {
             $default->name = $storegroup;
             $default->type = 'COM_MAGEBRIDGE_VIEW_STORE_FIELD_TYPE_VALUE_GROUP';
         } else {
             $default->name = JText::_('JNONE');
             $default->type = JText::_('JNONE');
             $default->title = JText::_('JNONE');
         }
     }
     // Loop through the API-result just to get the title
     $options = MageBridgeWidgetHelper::getWidgetData('store');
     if (!empty($options)) {
         foreach ($options as $index => $group) {
             if ($default->type == 'Store Group') {
                 if ($default->name == $group['value']) {
                     $default->title = $group['label'];
                     return $default;
                 }
             } else {
                 foreach ($group['childs'] as $view) {
                     if ($default->name == $view['value']) {
                         $default->title = $view['label'];
                         return $default;
                     }
                 }
             }
         }
     }
     return $default;
 }
Exemplo n.º 4
0
 public function getDefaultJoomlaGroup()
 {
     if (MageBridgeHelper::isJoomla15()) {
         $usergroup = MageBridgeModelConfig::load('usergroup');
         if (!empty($usergroup)) {
             $usergroup_name = JFactory::getACL()->get_group_name($usergroup);
             return $usergroup_name;
         } else {
             $conf = JComponentHelper::getParams('com_users');
             return $conf->get('new_usertype', 'Registered');
         }
     }
     return null;
 }
Exemplo n.º 5
0
 public function getDefault()
 {
     // Load the configuration values
     $storegroup = MageBridgeModelConfig::load('storegroup');
     $storeview = MageBridgeModelConfig::load('storeview');
     if (!empty($storeview)) {
         $default = array('name' => $storeview, 'title' => '', 'type' => 'Store View');
     } else {
         if (!empty($storegroup)) {
             $default = array('name' => $storegroup, 'title' => '', 'type' => 'Store Group');
         } else {
             $default = array('name' => '', 'title' => '', 'type' => '');
         }
     }
     if (empty($default['type'])) {
         return $default;
     }
     // Loop through the API-result just to get the title
     $options = MageBridgeWidgetHelper::getWidgetData('store');
     if (!empty($options)) {
         foreach ($options as $index => $group) {
             if ($default['type'] == 'Store Group') {
                 if ($default['name'] == $group['value']) {
                     $default['title'] = $group['label'];
                     return $default;
                 }
             } else {
                 foreach ($group['childs'] as $view) {
                     if ($default['name'] == $view['value']) {
                         $default['title'] = $view['label'];
                         return $default;
                     }
                 }
             }
         }
     }
     return $default;
 }
Exemplo n.º 6
0
 public function fetchElement($name, $value = null, $node = null, $control_name = null, $extra = null)
 {
     // Add the control name
     if (!empty($control_name)) {
         $name = $control_name . '[' . $name . ']';
     }
     // Check whether the API widgets are enabled
     if (MagebridgeModelConfig::load('api_widgets') == true) {
         $rows = MageBridgeWidgetHelper::getWidgetData('store');
         // Parse the result into an HTML form-field
         $options = array();
         if (!empty($rows) && is_array($rows)) {
             foreach ($rows as $index => $group) {
                 if ($group['website'] != MageBridgeModelConfig::load('website')) {
                     continue;
                 }
                 $options[] = array('value' => 'g:' . $group['value'] . ':' . $group['label'], 'label' => $group['label'] . ' (' . $group['value'] . ') ');
                 if (preg_match('/^g\\:' . $group['value'] . '/', $value)) {
                     $value = 'g:' . $group['value'] . ':' . $group['label'];
                 }
                 if (!empty($group['childs'])) {
                     foreach ($group['childs'] as $child) {
                         $options[] = array('value' => 'v:' . $child['value'] . ':' . $child['label'], 'label' => '-- ' . $child['label'] . ' (' . $child['value'] . ') ');
                         if (preg_match('/^v\\:' . $child['value'] . '/', $value)) {
                             $value = 'v:' . $child['value'] . ':' . $child['label'];
                         }
                     }
                 }
             }
             array_unshift($options, array('value' => '', 'label' => '-- Select --'));
             return JHTML::_('select.genericlist', $options, $name, $extra, 'value', 'label', $value);
         } else {
             MageBridgeModelDebug::getInstance()->warning('Unable to obtain MageBridge API Widget "store": ' . var_export($options, true));
         }
     }
     return '<input type="text" name="' . $name . '" value="' . $value . '" />';
 }
Exemplo n.º 7
0
 /**
  * Helper-method to convert user data into a valid user record
  *
  * @param mixed $user User data
  * @return mixed $user
  */
 public static function convert($user)
 {
     jimport('joomla.utilities.arrayhelper');
     $rt = 'object';
     if (is_array($user)) {
         $rt = 'array';
         foreach ($user as $name => $value) {
             if (empty($value)) {
                 unset($user[$name]);
             }
         }
         $user = JArrayHelper::toObject($user);
     }
     $name = isset($user->name) ? $user->name : null;
     $firstname = isset($user->firstname) ? $user->firstname : null;
     $lastname = isset($user->lastname) ? $user->lastname : null;
     $username = isset($user->username) ? $user->username : null;
     // Generate an username
     if (empty($username)) {
         $username = $user->email;
     }
     // Generate a firstname and lastname
     if (!empty($name) && (empty($firstname) && empty($lastname))) {
         $array = explode(' ', $name);
         $firstname = array_shift($array);
         $lastname = implode(' ', $array);
     }
     // Generate a name
     if (empty($name) && (!empty($firstname) && !empty($lastname))) {
         if (MageBridgeModelConfig::load('realname_with_space')) {
             $name = $firstname . $lastname;
         } else {
             $name = $firstname . ' ' . $lastname;
         }
     } else {
         if (empty($name)) {
             $name = $username;
         }
     }
     // Insert the values back into the object
     $user->name = trim($name);
     $user->username = trim($username);
     $user->firstname = trim($firstname);
     $user->lastname = trim($lastname);
     $user->admin = (int) self::isBackendUser($username, 'username');
     // Return either an array or an object
     if ($rt == 'array') {
         return JArrayHelper::fromObject($user);
     }
     return $user;
 }
Exemplo n.º 8
0
 /**
  * Method to do all bridge-based checks
  *
  * @package MageBridge
  * @access public
  * @return null
  */
 public function doBridgeChecks()
 {
     $register = MageBridgeModelRegister::getInstance();
     $bridge = MageBridgeModelBridge::getInstance();
     // First add all the things we need to the bridge
     $version_id = $register->add('version');
     // Build the bridge
     $bridge->build();
     $magebridge_version_magento = $register->getDataById($version_id);
     $magebridge_version_joomla = MageBridgeUpdateHelper::getComponentVersion();
     if (empty($magebridge_version_magento)) {
         $this->addResult('bridge', 'Bridge version', self::CHECK_WARNING, JText::_('CHECK_BRIDGE_NO_VERSION'));
     } else {
         $result = version_compare($magebridge_version_magento, $magebridge_version_joomla, '=') ? self::CHECK_OK : self::CHECK_ERROR;
         $this->addResult('bridge', 'Bridge version', $result, JText::sprintf('CHECK_BRIDGE_VERSION', $magebridge_version_magento, $magebridge_version_joomla));
     }
     $result = MageBridgeModelConfig::load('modify_url') == 1 ? self::CHECK_OK : self::CHECK_WARNING;
     $this->addResult('bridge', 'Modify URLs', $result, JText::_('CHECK_BRIDGE_MODIFY_URL'));
     $result = MageBridgeModelConfig::load('link_to_magento') == 0 ? self::CHECK_OK : self::CHECK_WARNING;
     $this->addResult('bridge', 'Link to Magento', $result, JText::_('CHECK_BRIDGE_LINK_TO_MAGENTO'));
     //$result = (defined('MAGEBRIDGE_MODULEHELPER_OVERRIDE') == true) ? self::CHECK_OK : self::CHECK_WARNING;
     //$this->addResult('bridge', 'Modulehelper override', $result, JText::_('CHECK_BRIDGE_MODULEHELPER_OVERRIDE'));
     return;
 }
        </td>
        <td class="status">
        </td>
        <td class="description">
            <span><?php 
echo JText::_('BASEDIR_DESCRIPTION');
?>
</span>
        </td>
    </tr>
</table>
</fieldset>
    
<?php 
if ($this->mode == 'advanced') {
    $display = MageBridgeModelConfig::load('http_auth') == 1 ? 'block' : 'none';
    ?>
<fieldset class="adminform">
<legend><a onclick="return toggleFieldset('http_auth');" href="#"><?php 
    echo JText::_('HTTP_Auth');
    ?>
</a></legend>
<table class="admintable" id="http_auth" style="display:<?php 
    echo $display;
    ?>
">
    <tr>
        <td class="key" valign="top">
            <?php 
    echo JText::_('HTTP_Auth');
    ?>
Exemplo n.º 10
0
 public function getStoreSelect($stores, $params = null)
 {
     $options = array();
     $currentName = MageBridgeStoreHelper::getInstance()->getAppType() == 'store' ? MageBridgeStoreHelper::getInstance()->getAppValue() : null;
     $currentValue = null;
     if (!empty($stores) && is_array($stores)) {
         foreach ($stores as $group) {
             if ($group['website'] != MageBridgeModelConfig::load('website')) {
                 continue;
             }
             if (!empty($group['childs'])) {
                 foreach ($group['childs'] as $child) {
                     $url = JURI::current() . '?__store=' . $child['value'];
                     if ($child['value'] == $currentName) {
                         $currentValue = $url;
                     }
                     $options[] = array('value' => $url, 'label' => $child['label']);
                 }
             }
         }
     }
     array_unshift($options, array('value' => '', 'label' => '-- Select --'));
     return JHTML::_('select.genericlist', $options, 'magebridge_store', 'onChange="window.location.href=this.value"', 'value', 'label', $currentValue);
 }
Exemplo n.º 11
0
 /**
  * Default method showing a JView
  *
  * @param boolean $cachable
  * @param boolean $urlparams
  *
  * @return null
  */
 public function display($cachable = false, $urlparams = false)
 {
     // Check if the bridge is offline
     if (MageBridge::getBridge()->isOffline()) {
         JFactory::getApplication()->input->set('view', 'offline');
         JFactory::getApplication()->input->set('layout', 'default');
     }
     // Set a default view
     if (JFactory::getApplication()->input->get('view') == '') {
         JFactory::getApplication()->input->set('view', 'root');
     }
     // Check for a logout action and perform a logout in Joomla! first
     $request = MageBridgeUrlHelper::getRequest();
     if ($request == 'customer/account/logout') {
         $session = JFactory::getSession();
         $session->destroy();
     }
     // Check for an admin request
     $backend = MageBridgeModelConfig::load('backend');
     if (!empty($backend) && substr($request, 0, strlen($backend)) === $backend) {
         $request = str_replace($backend, '', $request);
         $url = MageBridgeModelBridge::getInstance()->getMagentoAdminUrl($request);
         $this->setRedirect($url);
         return;
     }
     // Redirect if the layout is not supported by the view
     if (JFactory::getApplication()->input->get('view') == 'catalog' && !in_array(JFactory::getApplication()->input->get('layout'), array('product', 'category', 'addtocart'))) {
         $url = MageBridgeUrlHelper::route('/');
         $this->setRedirect($url);
         return;
     }
     parent::display($cachable, $urlparams);
 }