Beispiel #1
0
 /**
  * Set basic properties for the item, whether in a list or a singleton
  *
  * @param unknown_type $item
  * @param unknown_type $key
  * @param unknown_type $refresh
  */
 protected function prepareItem(&$item, $key = 0, $refresh = false)
 {
     $item->link = 'index.php?option=com_citruscart&view=addresses&task=edit&id=' . $item->address_id;
     /*
      * check extra fields empty or not
      */
     if (!empty($item->extra_fields)) {
         $extra_fields = new DSCParameter(trim($item->extra_fields));
         $extra_fields = $extra_fields->toArray();
         foreach ($extra_fields as $k => $v) {
             $item->{$k} = $v;
         }
     }
     /*
      * refer parent prepareItem method.
      */
     parent::prepareItem($item, $key, $refresh);
 }
Beispiel #2
0
 /**
  * Set basic properties for the item, whether in a list or a singleton
  *
  * @param unknown_type $item
  * @param unknown_type $key
  * @param unknown_type $refresh
  */
 protected function prepareItem(&$item, $key = 0, $refresh = false)
 {
     $input = JFactory::getApplication()->input;
     $getEav = $this->_getEav;
     $options = $this->_getEavOptions;
     $eavStates = count($this->getEavState()->getProperties());
     if (!empty($getEav) || $eavStates > 0) {
         $app = JFactory::getApplication();
         $editable_by = $app->isAdmin() ? 1 : 2;
         $view = $input->get('view', '');
         if ($app->isAdmin() && $view == 'pos') {
             $editable_by = array(1, 2);
         }
         Citruscart::load('CitruscartModelEavAttributes', 'models.eavattributes');
         Citruscart::load("CitruscartHelperBase", 'helpers._base');
         $eav_helper = CitruscartHelperBase::getInstance('Eav');
         $entity = $this->getTable()->get('_suffix');
         $tbl_key = $this->getTable()->getKeyName();
         $entity_id = $item->{$tbl_key};
         // add the custom fields as properties
         $eavs = $eav_helper->getAttributes($entity, $entity_id, false, $editable_by);
         // Mirrored table?
         if (!count($eavs) && strlen($this->getTable()->getLinkedTable())) {
             $entity = $this->getTable()->getLinkedTable();
             $entity_id = $item->{$this->getTable()->getLinkedTableKeyName()};
             $eavs = $eav_helper->getAttributes($entity, $entity_id, false, $editable_by);
         }
         foreach ($eavs as $eav) {
             $key = $eav->eavattribute_alias;
             $add = true;
             // Include Mode: Fetch only these fields
             if (array_key_exists('include', $options)) {
                 foreach ($options['include'] as $k) {
                     if ($key != $k) {
                         $add = false;
                     }
                 }
             } else {
                 // Exclude Mode: Fetch everything except these fields
                 if (array_key_exists('exclude', $options)) {
                     foreach ($options['exclude'] as $k) {
                         if ($key == $k) {
                             $add = false;
                         }
                     }
                 }
                 // Default Mode: Fetch Everything
             }
             if ($add) {
                 $value = $eav_helper->getAttributeValue($eav, $this->getTable()->get('_suffix'), $item->{$tbl_key}, false, true);
                 // Do NOT override properties
                 if (!property_exists($item, $key)) {
                     $item->{$key} = $value;
                 }
             }
         }
     }
     parent::prepareItem($item, $key, $refresh);
 }