Beispiel #1
0
 /**
  * Import data from CSV cell
  * @param      $value
  * @param null $position
  * @return Item
  */
 public function fromCSV($value, $position = null)
 {
     $value = $this->_getAutoClean($value);
     if ($this->_element) {
         if ($this->_isRepeatable) {
             // for repeatable objects
             if (strpos($value, JBCSVItem::SEP_ROWS)) {
                 $tmpData = $this->_getArray($value, JBCSVItem::SEP_ROWS);
                 foreach ($tmpData as $val) {
                     if ($val === '') {
                         return $this->_item;
                     }
                     $data[] = array('value' => $val);
                 }
                 $this->_element->bindData($data);
             } else {
                 if ($value === '') {
                     return $this->_item;
                 }
                 $data = $position == 1 ? array() : ($data = $this->_element->data());
                 $data[] = array('value' => JString::trim($value));
                 $this->_element->bindData($data);
             }
         } else {
             if ($value === '') {
                 return $this->_item;
             }
             // for no repeatable objects
             $this->_element->bindData(array('value' => $value));
         }
     }
     return $this->_item;
 }
Beispiel #2
0
 public function bindData($data = array())
 {
     parent::bindData($data);
     // add image width/height
     $file = $this->get('file');
     if ($file && ($filepath = $this->app->path->path('root:' . $file))) {
         $size = getimagesize($filepath);
         $this->set('width', $size ? $size[0] : 0);
         $this->set('height', $size ? $size[1] : 0);
     }
 }
Beispiel #3
0
 public function bindData($data = array())
 {
     parent::bindData($data);
     // calculate rating/votes
     $query = 'SELECT AVG(value) AS rating, COUNT(id) AS votes' . ' FROM ' . ZOO_TABLE_RATING . ' WHERE element_id = ' . $this->app->database->Quote($this->identifier) . ' AND item_id = ' . $this->_item->id . ' GROUP BY item_id';
     if ($this->_item->id && ($res = $this->app->database->queryAssoc($query))) {
         $this->set('votes', $res['votes']);
         $this->set('value', $res['rating']);
     } else {
         $this->set('votes', 0);
         $this->set('value', 0);
     }
 }
Beispiel #4
0
 /**
  * @param array $data
  */
 public function bindData($data = array())
 {
     $saveData = $data;
     if ($this->getItem()) {
         $newData = JFactory::getSession()->get($this->_getSaveKey(), null, __CLASS__);
     }
     if (!empty($newData)) {
         $saveData = $newData;
     }
     $saveData = array_merge($saveData, $data);
     if ($saveData['is_modified'] == self::MODIFIED_EXEC) {
         parent::bindData($saveData);
         $this->modifyItem();
     } else {
         parent::bindData($saveData);
     }
 }
Beispiel #5
0
 /**
  * Bind data on save
  * Hack for save from admin
  * @param array $data
  */
 public function bindData($data = array())
 {
     $saveData = $data;
     if ($this->getItem()) {
         $newData = JFactory::getSession()->get('items-' . $this->getItem()->id . '-' . $this->identifier, null, __CLASS__);
     }
     if (!empty($newData)) {
         $saveData = $newData;
     }
     // for administator only
     if (isset($data['order_info_admin'])) {
         $orderInfo = array('status' => $data['order_info_status'], 'description' => $data['order_info_description']);
         if (isset($saveData['is_advance'])) {
             $saveData['order_info'] = array_merge($saveData['order_info'], $orderInfo);
         } else {
             reset($saveData);
             $firstKey = key($saveData);
             if (!isset($saveData[$firstKey]['order_info'])) {
                 $saveData[$firstKey]['order_info'] = array();
             }
             $saveData[$firstKey]['order_info'] = array_merge($saveData[$firstKey]['order_info'], $orderInfo);
         }
     }
     parent::bindData($saveData);
 }
Beispiel #6
0
 public function bindData($data = array())
 {
     $images_arr = $data['images'];
     if (empty($images_arr)) {
         $images_arr = $data;
     }
     $key = 0;
     if (!empty($images_arr)) {
         foreach ($images_arr as $image) {
             $datanew[$key]['file'] = $this->getUploadedFilePath($image['name']);
             $datanew[$key]['title'] = '';
             $datanew[$key]['link'] = '';
             $datanew[$key]['target'] = '0';
             $datanew[$key]['rel'] = '';
             $key++;
         }
         parent::bindData($datanew);
     }
 }
Beispiel #7
0
 public function bindData($data = array())
 {
     parent::bindData($data);
 }
Beispiel #8
0
 public function bindData($data = array())
 {
     if (!isset($data['hits'])) {
         $this->setData($this->getItem()->elements);
         $data['hits'] = $this->_data->get('hits', 0);
     }
     parent::bindData($data);
 }
Beispiel #9
0
 /**
  *  Clean data before bind into element
  * @param array $data
  * @return null | array
  */
 public function bindData($data = array())
 {
     if (isset($data['option'])) {
         foreach ($data['option'] as $key => $value) {
             $data['option'][$key] = $this->_jbcolor->clean($value);
         }
         parent::bindData($data);
     }
     return null;
 }