/** * Return the views output * * @return string The output of the view */ public function display() { //Set the filename $filename = KFactory::get('koowa:filter.filename')->sanitize($this->_properties['FN']); $this->filename = $filename.'.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->output = $data; parent::display(); }
/** * Return the views output * * @return string The output of the view */ public function display() { $rows = ''; $columns = array(); $rowset = $this->getModel()->getList(); // 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 output $this->output = $header . $rows; return parent::display(); }
public function display() { $path = base64_decode(KRequest::get('get.path', 'base64')); $container = $this->getService('com://admin/files.model.containers')->slug('downloads-downloads')->getItem(); $this->path = $container->path . DS . $path; $this->filename = basename($path); return parent::display(); }
public function display() { $item = $this->getModel()->getItem(); $state = $this->getModel()->getState(); $container = $this->getService('com://admin/files.model.containers')->slug($item->container)->getItem(); $this->path = $container->path . '/' . $item->path; $this->filename = $item->name; if (!file_exists($this->path)) { throw new KViewException('File not found'); } return parent::display(); }
/** * Return the views output * * @return string The output of the view */ public function display() { //Get the rowset $rowset = $this->getModel()->getList(); // Header $this->output .= $this->_arrayToString($rowset->getColumns()) . $this->eol; // Data foreach ($rowset as $row) { $this->output .= $this->_arrayToString($row->toArray()) . $this->eol; } return parent::display(); }
public function display() { $state = $this->getModel()->getState(); $controller = $this->getService('com://admin/files.controller.file', array('request' => $state->getData())); $file = $controller->read(); $this->path = $file->fullpath; $this->filename = $file->name; $this->mimetype = $file->mimetype ? $file->mimetype : 'application/octet-stream'; if ($file->isImage() || $file->extension === 'pdf') { $this->disposition = 'inline'; } if (!file_exists($this->path)) { throw new KViewException(JText::_('File not found')); } return parent::display(); }
public function display() { require_once JPATH_ROOT . '/components/com_media/helpers/media.php'; $params = KFactory::get('admin::com.ninjaboard.model.settings')->getParams(); $params = $params['attachment_settings']; $attachment = $this->getModel()->getItem(); if (!$attachment->id) { return $this->notFound(); } $post = KFactory::tmp('admin::com.ninjaboard.model.posts')->id($attachment->post)->getItem(); if (!$post->id) { return $this->notFound(); } $topic = KFactory::tmp('admin::com.ninjaboard.model.topics')->id($post->ninjaboard_topic_id)->getItem(); if (!$topic->id) { return $this->notFound(); } $forum = KFactory::tmp('admin::com.ninjaboard.model.forums')->id($topic->forum_id)->getItem(); if (!$forum->id) { return $this->notFound(); } if ($forum->attachment_permissions < 1) { return $this->forbidden(); } $path = JPATH_ROOT . '/media/com_ninjaboard/attachments/' . $attachment->file; if (JFile::getExt($attachment->file) == 'pdf') { $this->mimetype = 'application/pdf'; } if ($attachment->isImage()) { $this->disposition = $params['disposition']; $this->mimetype = 'image/' . $attachment->type; } else { $this->mimetype = 'text/' . $attachment->type; } $this->output = JFile::read($path); $this->filename = $attachment->name; return parent::display(); }
public function display() { //Prepare MediaHelper JLoader::register('MediaHelper', JPATH_ROOT . '/components/com_media/helpers/media.php'); //Set the cache expire, which is 3 months in seconds $this->expires = 7889231; $item = $this->getModel()->getItem(); $image = $this->getModel()->getImage(); if (is_a($image, 'ComNinjaHelperImage')) { $path = $image->file; } else { $path = $image; $image = KFactory::get('admin::com.ninja.helper.image', array('image' => $path)); } //$this->mimetype = 'image/'.MediaHelper::getTypeIcon($image->file); $this->mimetype = $image->mime; $identifier = $this->getIdentifier(); $cache = JPATH_ROOT . '/cache/com_' . $identifier->package . '/' . KInflector::pluralize($this->getName()); $cache .= '/' . $item->id . '/' . $identifier->name . '&' . urldecode(http_build_query($image->actions)) . '.' . $image->ext; if (!JFile::exists($cache)) { //To avoid "image directory unwritable" messages JFile::write($cache, ''); $image->save($cache); JPath::setPermissions($cache); } else { //Time since created, in seconds $mtime = filemtime($cache); $created = time() - date('U', $mtime); //Set modified since header //header('Last-Modified: '.gmdate("D, d M Y H:i:s", $mtime).' GMT'); if ($created > $this->expires) { //To avoid permission errors on some systems, delete the image first instead of overwriting JFile::delete($cache); $image->save($cache); JPath::setPermissions($cache); } } $this->disposition = 'inline'; $this->output = JFile::read($cache); $this->filename = basename($path); return parent::display(); }