Example #1
0
 public function bindData($array = array())
 {
     $this->_data_array = array();
     // set raw input for textarea
     $post = JRequest::get('post', JREQUEST_ALLOWRAW);
     foreach ($array as $index => $instance_data) {
         if (isset($post['elements'][$this->identifier][$index]['value'])) {
             $array[$index]['value'] = $post['elements'][$this->identifier][$index]['value'];
         }
     }
     // set data
     foreach ($array as $instance_data) {
         $data = ElementData::newInstance($this);
         foreach ($instance_data as $key => $value) {
             $data->set($key, $value);
         }
         $this->_data_array[] = $data;
     }
     if (empty($this->_data_array)) {
         $this->_data_array[0] = ElementData::newInstance($this);
     }
     $this->_data = $this->_data_array[0];
 }
Example #2
0
 public function bindData($array = array())
 {
     $this->_data_array = array();
     foreach ($array as $instance_data) {
         $data = ElementData::newInstance($this);
         foreach ($instance_data as $key => $value) {
             $data->set($key, $value);
         }
         $this->_data_array[] = $data;
     }
     if (empty($this->_data_array)) {
         $this->_data_array[0] = ElementData::newInstance($this);
     }
     $this->_data = $this->_data_array[0];
 }
Example #3
0
 public function encodeData()
 {
     if ($this->_element->getItem()) {
         $db = YDatabase::getInstance();
         // calculate rating/votes
         $query = 'SELECT AVG(value) AS rating, COUNT(id) AS votes' . ' FROM ' . ZOO_TABLE_RATING . ' WHERE element_id = ' . $db->Quote($this->_element->identifier) . ' AND item_id = ' . $this->_element->getItem()->id . ' GROUP BY item_id';
         if ($res = $db->queryAssoc($query)) {
             $this->set('votes', $res['votes']);
             $this->set('value', $res['rating']);
         } else {
             $this->set('votes', 0);
             $this->set('value', 0);
         }
     }
     return parent::encodeData();
 }
Example #4
0
 public function bindData($data = array())
 {
     $this->_data = ElementData::newInstance($this);
     foreach ($data as $key => $value) {
         $this->_data->set($key, $value);
     }
 }
Example #5
0
 public function encodeData()
 {
     // add image width/height
     $filepath = JPATH_ROOT . DS . $this->_params->get('file');
     if (JFile::exists($filepath)) {
         $size = getimagesize($filepath);
         $this->set('width', $size ? $size[0] : 0);
         $this->set('height', $size ? $size[1] : 0);
     }
     return parent::encodeData();
 }
Example #6
0
 public function encodeData()
 {
     // add size to xml
     $filepath = JPATH_ROOT . '/' . $this->get('file');
     if (is_readable($filepath) && is_file($filepath)) {
         $this->set('size', sprintf('%u', filesize($filepath)));
     } else {
         $this->set('size', 0);
     }
     return parent::encodeData();
 }