Beispiel #1
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();
 }
Beispiel #2
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();
 }
Beispiel #3
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();
 }