/** * 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(); }
/** * Render and return the views output * * If the view 'output' variable is empty the output will be generated based on the model data, if it set it will * be returned instead. * * @return string The output of the view */ public function render() { if (empty($this->_content)) { $this->_content = StringInflector::isPlural($this->getName()) ? $this->_getRowset() : $this->_getRow(); } if (!is_string($this->_content)) { // Root should be JSON object, not array if (is_array($this->_content) && 0 === count($this->_content)) { $this->_content = new \ArrayObject(); } // Encode <, >, ', &, and " for RFC4627-compliant JSON, which may also be embedded into HTML. $this->_content = json_encode($this->_content, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT); } return parent::render(); }
/** * Return the views output * * @return string The output of the view */ public function render() { //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(); }
/** * Return the views output * * @return string The output of the view */ public function render() { $layout = $this->getLayout(); $format = $this->getFormat(); $identifier = clone $this->getIdentifier(); $identifier->name = $layout . '.' . $format; $this->_content = $this->getTemplate()->loadFile($identifier, $this->_data)->render(); return parent::render(); }