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 . '" />';
 }
示例#2
0
 public function getCustomergroupLabel($magento_group)
 {
     $customergroups = MageBridgeWidgetHelper::getWidgetData('customergroup');
     if (!empty($customergroups)) {
         foreach ($customergroups as $customergroup) {
             if ($customergroup['customer_group_id'] == $magento_group) {
                 return $customergroup['customer_group_code'];
             }
         }
     }
 }
示例#3
0
 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 . '" />';
 }
示例#4
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;
 }
示例#5
0
 /**
  * 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 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 . '" />';
 }
 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;
 }
示例#8
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 . '" />';
 }