Example #1
0
 /**
  * Return the views output
  *
  *  @return string 	The output of the view
  */
 public function render()
 {
     $rows = '';
     $columns = array();
     $rowset = $this->getModel()->getRowset();
     // Get the columns
     foreach ($rowset as $row) {
         $data = $row->toArray();
         $columns = array_merge($columns + array_flip(array_keys($data)));
     }
     // Empty the column values
     foreach ($columns as $key => $value) {
         $columns[$key] = '';
     }
     //Create the rows
     foreach ($rowset as $row) {
         $data = $row->toArray();
         $data = array_merge($columns, $data);
         $rows .= $this->_arrayToString(array_values($data)) . $this->eol;
     }
     // Create the header
     $header = $this->_arrayToString(array_keys($columns)) . $this->eol;
     // Set the content
     $this->setContent($header . $rows);
     return parent::render();
 }
Example #2
0
 /**
  * Return the views output
  *
  *  @return string  The output of the view
  */
 public function render()
 {
     //Set the filename
     $filename = $this->getObject('lib:filter.filename')->sanitize($this->_properties['FN']);
     $this->filename = !empty($filename) ? $filename . '.vcf' : 'vcard.vcf';
     //Render the vcard
     $data = 'BEGIN:VCARD';
     $data .= "\r\n";
     $data .= 'VERSION:2.1';
     $data .= "\r\n";
     foreach ($this->_properties as $key => $value) {
         $data .= "{$key}:{$value}";
         $data .= "\r\n";
     }
     $data .= 'REV:' . date('Y-m-d') . 'T' . date('H:i:s') . 'Z';
     $data .= "\r\n";
     $data .= 'END:VCARD';
     $data .= "\r\n";
     $this->setContent($data);
     parent::render();
 }