/** * Display the template * * @param sting $tpl template * * @return void */ public function display($tpl = null) { if (parent::display($tpl) !== false) { if (!$this->app->isAdmin()) { $state = $this->get('State'); $this->params = $state->get('params'); if ($this->params->get('menu-meta_description')) { $this->doc->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $this->doc->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $this->doc->setMetadata('robots', $this->params->get('robots')); } } // Set the response to indicate a file download $this->app->setHeader('Content-Type', 'application/vnd.ms-word'); $name = $this->getModel()->getTable()->label; $name = JStringNormalise::toDashSeparated($name); $this->app->setHeader('Content-Disposition', "attachment;filename=\"" . $name . ".doc\""); $this->doc->setMimeEncoding('text/html; charset=Windows-1252', false); $this->output(); } }
/** * Display the Feed * * @param sting $tpl template * * @return void */ public function display($tpl = null) { $this->doc->setMimeEncoding('application/xml'); $model = $this->getModel(); $this->oaiModel->setListModel($model); $root = $this->oaiModel->root(); $root->appendChild($this->oaiModel->responseDate()); $root->appendChild($this->request()); $this->params = $model->getParams(); $model->setOutPutFormat('feed'); $this->app->allowCache(true); if (!parent::access($model)) { exit; } $filter = $this->filter(); foreach ($filter as $key => $val) { $_GET[$key] = $val; } $model->render(); $rows = $model->getData(); $total = $model->getTotalRecords(); if ($total === 0) { echo $this->model->generateError(array('code' => 'noRecordsMatch', 'msg' => 'No records matched')); } $this->rowIdentifier = 'oai:' . $this->oaiModel->repositoryIdentifier() . ':' . $model->getId() . '/'; $listRecords = $this->listRecords($rows); if ($total > count($rows)) { $listRecords->appendChild($this->oaiModel->resumptionToken($total, $filter)); } $root->appendChild($listRecords); $this->oaiModel->appendChild($root); print_r($this->oaiModel->dom->saveXML()); }
/** * Set page title * * @param object $w Fabrikworker * @param object &$params list params * @param object $model list model * * @return void */ protected function setTitle($w, &$params, $model) { parent::setTitle($w, $params, $model); // Set the download file name based on the document title $document = JFactory::getDocument(); $document->setName($document->getTitle()); }
/** * Execute and display a template script. * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return mixed A string if successful, otherwise a JError object. */ public function display($tpl = null) { $input = $this->app->input; /** @var FabrikFEModelCSVExport $exporter */ $exporter = JModelLegacy::getInstance('Csvexport', 'FabrikFEModel'); /** @var FabrikFEModelList $model */ $model = JModelLegacy::getInstance('list', 'FabrikFEModel'); $model->setId($input->getInt('listid')); if (!parent::access($model)) { exit; } $model->setOutPutFormat('csv'); $exporter->model = $model; $input->set('limitstart' . $model->getId(), $input->getInt('start', 0)); $limit = $exporter->getStep(); $input->set('limit' . $model->getId(), $limit); // $$$ rob moved here from csvimport::getHeadings as we need to do this before we get // the list total $selectedFields = $input->get('fields', array(), 'array'); $model->setHeadingsForCSV($selectedFields); if (empty($model->asfields)) { throw new LengthException('CSV Export - no fields found', 500); } $request = $model->getRequestData(); $model->storeRequestData($request); $key = 'fabrik.list.' . $model->getId() . 'csv.total'; $start = $input->getInt('start', 0); // If we are asking for a new export - clear previous total as list may be filtered differently if ($start === 0) { $this->session->clear($key); } if (!$this->session->has($key)) { // Only get the total if not set - otherwise causes memory issues when we downloading $total = $model->getTotalRecords(); $this->session->set($key, $total); } else { $total = $this->session->get($key); } if ($start < $total) { if ((int) $total === 0) { $notice = new stdClass(); $notice->err = FText::_('COM_FABRIK_CSV_EXPORT_NO_RECORDS'); echo json_encode($notice); return; } $download = (bool) $input->getInt('download', true); $canDownload = $start + $limit >= $total && $download; $exporter->writeFile($total, $canDownload); if ($canDownload) { $this->download($model, $exporter, $key); } } else { $this->download($model, $exporter, $key); } return; }
/** * Display a json object representing the table data. * Not used for updating fabrik list, use raw view for that, here in case you want to export the data to another application * * @param string $tpl Template * * @return void */ public function display($tpl = null) { $app = JFactory::getApplication(); $model = $this->getModel(); $model->setId($app->input->getInt('listid')); if (!parent::access($model)) { exit; } $data = $model->getData(); echo json_encode($data); }
/** * Execute and display a template script. * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return mixed A string if successful, otherwise a JError object. */ public function display($tpl = null) { $input = $this->app->input; $model = $this->getModel(); $model->setId($input->getInt('listid')); // Get the active menu item if (!parent::access($model)) { exit; } $form = $model->getFormModel(); $joins = $model->getJoins(); $form->getJoinGroupIds($joins); //$params = $model->getParams(); //$params->def('icons', $this->app->get('icons')); //$pop = ($input->get('tmpl') == 'component') ? 1 : 0; //$params->set('popup', $pop); $view = $input->get('view', 'list'); $groups = $form->getGroupsHiarachy(); $gkeys = array_keys($groups); $JSONarray = array(); $JSONHtml = array(); for ($i = 0; $i < count($gkeys); $i++) { $groupModel = $groups[$gkeys[$i]]; $groupTable = $groupModel->getGroup(); $group = new stdClass(); $groupParams = $groupModel->getParams(); $aElements = array(); // Check if group is actually a table join $repeatGroup = 1; $foreignKey = null; $elementModels = $groupModel->getPublishedElements(); foreach ($elementModels as $elementModel) { $elId = $elementModel->getElement()->id; $fullname = $elementModel->getFullName(true, false); if ($elementModel->getElement()->plugin == 'tags' && $elId == $input->get('elID')) { $data = $elementModel->allTagsJSON($elId); foreach ($data as $d) { if (stristr($d->text, $input->get('like'))) { $tagdata[] = $d; } } } } } echo json_encode($tagdata); }
/** * Display the template * * @param sting $tpl template * * @return void */ public function display($tpl = null) { if (parent::display($tpl) !== false) { $app = JFactory::getApplication(); if (!$app->isAdmin()) { $this->state = $this->get('State'); $this->params = $this->state->get('params'); $this->document = JFactory::getDocument(); if ($this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } } $this->output(); } }
/** * Display the template * * @param string $tpl Template * * @return void */ public function display($tpl = null) { if (parent::display($tpl) !== false) { /** @var FabrikFEModelList $model */ $model = $this->getModel(); $this->tabs = $model->loadTabs(); if (!$this->app->isAdmin() && isset($this->params)) { /** @var JObject $state */ $state = $model->getState(); $stateParams = $state->get('params'); if ($stateParams->get('menu-meta_description')) { $this->doc->setDescription($stateParams->get('menu-meta_description')); } if ($stateParams->get('menu-meta_keywords')) { $this->doc->setMetadata('keywords', $stateParams->get('menu-meta_keywords')); } if ($stateParams->get('robots')) { $this->doc->setMetadata('robots', $stateParams->get('robots')); } } $this->output(); } }
/** * Display the Feed * * @param sting $tpl template * * @return void */ public function display($tpl = null) { $input = $this->app->input; $itemId = FabrikWorker::itemId(); $model = $this->getModel(); $model->setOutPutFormat('feed'); $this->app->allowCache(true); if (!parent::access($model)) { exit; } $this->doc->_itemTags = array(); // $$$ hugh - modified this so you can enable QS filters on RSS links // by setting &incfilters=1 $input->set('incfilters', $input->getInt('incfilters', 0)); $table = $model->getTable(); $model->render(); $params = $model->getParams(); if ($params->get('rss') == '0') { return ''; } $formModel = $model->getFormModel(); $form = $formModel->getForm(); $aJoinsToThisKey = $model->getJoinsToThisKey(); // Get headings $aTableHeadings = array(); $groupModels = $formModel->getGroupsHiarachy(); $titleEl = $params->get('feed_title'); $dateEl = (int) $params->get('feed_date'); //$imageEl = $formModel->getElement($imageEl, true); $titleEl = $formModel->getElement($titleEl, true); $dateEl = $formModel->getElement($dateEl, true); $titleElName = $titleEl === false ? '' : $titleEl->getFullName(true, false); $dateElName = $dateEl === false ? '' : $dateEl->getFullName(true, false); $dateElNameRaw = $dateElName . '_raw'; foreach ($groupModels as $groupModel) { $elementModels = $groupModel->getPublishedElements(); foreach ($elementModels as $elementModel) { $element = $elementModel->getElement(); $elParams = $elementModel->getParams(); if ($elParams->get('show_in_rss_feed') == '1') { $heading = $element->label; if ($elParams->get('show_label_in_rss_feed') == '1') { $aTableHeadings[$heading]['label'] = $heading; } else { $aTableHeadings[$heading]['label'] = ''; } $aTableHeadings[$heading]['colName'] = $elementModel->getFullName(); $aTableHeadings[$heading]['dbField'] = $element->name; // $$$ hugh - adding enclosure stuff for podcasting if ($element->plugin == 'fileupload' || $elParams->get('use_as_rss_enclosure', '0') == '1') { $aTableHeadings[$heading]['enclosure'] = true; } else { $aTableHeadings[$heading]['enclosure'] = false; } } } } foreach ($aJoinsToThisKey as $element) { $element = $elementModel->getElement(); $elParams = new Registry($element->attribs); if ($elParams->get('show_in_rss_feed') == '1') { $heading = $element->label; if ($elParams->get('show_label_in_rss_feed') == '1') { $aTableHeadings[$heading]['label'] = $heading; } else { $aTableHeadings[$heading]['label'] = ''; } $aTableHeadings[$heading]['colName'] = $element->db_table_name . "___" . $element->name; $aTableHeadings[$heading]['dbField'] = $element->name; // $$$ hugh - adding enclosure stuff for podcasting if ($element->plugin == 'fileupload' || $elParams->get('use_as_rss_enclosure', '0') == '1') { $aTableHeadings[$heading]['enclosure'] = true; } else { $aTableHeadings[$heading]['enclosure'] = false; } } } $w = new FabrikWorker(); $rows = $model->getData(); $this->doc->title = htmlspecialchars($w->parseMessageForPlaceHolder($table->label, $_REQUEST), ENT_COMPAT, 'UTF-8'); $this->doc->description = htmlspecialchars(trim(strip_tags($w->parseMessageForPlaceHolder($table->introduction, $_REQUEST)))); $this->doc->link = JRoute::_('index.php?option=com_' . $this->package . '&view=list&listid=' . $table->id . '&Itemid=' . $itemId); $this->addImage($params); // Check for a custom css file and include it if it exists $tmpl = $input->get('layout', $table->template); $cssPath = COM_FABRIK_FRONTEND . 'views/list/tmpl/' . $tmpl . '/feed.css'; if (file_exists($cssPath)) { $this->doc->addStyleSheet(COM_FABRIK_LIVESITE . 'components/com_fabrik/views/list/tmpl/' . $tmpl . '/feed.css'); } $view = $model->canEdit() ? 'form' : 'details'; // List of tags to look for in the row data // If they are there don't put them in the desc but put them in as a separate item param $rssTags = array('<georss:point>' => 'xmlns:georss="http://www.georss.org/georss"'); foreach ($rows as $group) { foreach ($group as $row) { // Get the content $str2 = ''; $str = ''; $tStart = '<table style="margin-top:10px;padding-top:10px;">'; $title = ''; $item = new JFabrikFeedItem(); $enclosures = array(); foreach ($aTableHeadings as $heading => $dbColName) { if ($dbColName['enclosure']) { // $$$ hugh - diddling around trying to add enclosures $colName = $dbColName['colName'] . '_raw'; $enclosureUrl = $row->{$colName}; if (!empty($enclosureUrl)) { $remoteFile = false; // Element value should either be a full path, or relative to J! base if (strstr($enclosureUrl, 'http://') && !strstr($enclosureUrl, COM_FABRIK_LIVESITE)) { $enclosureFile = $enclosureUrl; $remoteFile = true; } elseif (strstr($enclosureUrl, COM_FABRIK_LIVESITE)) { $enclosureFile = str_replace(COM_FABRIK_LIVESITE, COM_FABRIK_BASE, $enclosureUrl); } elseif (preg_match('#^' . COM_FABRIK_BASE . "#", $enclosureUrl)) { $enclosureFile = $enclosureUrl; $enclosureUrl = str_replace(COM_FABRIK_BASE, '', $enclosureUrl); } else { $enclosureFile = COM_FABRIK_BASE . $enclosureUrl; $enclosureUrl = COM_FABRIK_LIVESITE . str_replace('\\', '/', $enclosureUrl); } if ($remoteFile || file_exists($enclosureFile) && !is_dir($enclosureFile)) { $enclosureType = ''; if ($enclosureType = FabrikWorker::getPodcastMimeType($enclosureFile)) { $enclosure_size = $this->get_filesize($enclosureFile, $remoteFile); $enclosures[] = array('url' => $enclosureUrl, 'length' => $enclosure_size, 'type' => $enclosureType); /** * No need to insert the URL in the description, as feed readers should * automagically show 'media' when they see an 'enclosure', so just move on .. */ continue; } } } } if ($title == '') { // Set a default title $title = $row->{$dbColName}['colName']; } // Rob - was stripping tags - but aren't they valid in the content? $rssContent = $row->{$dbColName}['colName']; $found = false; foreach ($rssTags as $rssTag => $namespace) { if (strstr($rssContent, $rssTag)) { $found = true; $rssTag = JString::substr($rssTag, 1, JString::strlen($rssTag) - 2); if (!strstr($this->doc->_namespace, $namespace)) { $this->doc->_itemTags[] = $rssTag; $this->doc->_namespace .= $namespace . " "; } break; } } if ($found) { $item->{$rssTag} = $rssContent; } else { if ($dbColName['label'] == '') { $str2 .= $rssContent . "<br />\n"; } else { $str .= "<tr><td>" . $dbColName['label'] . ":</td><td>" . $rssContent . "</td></tr>\n"; } } } if (isset($row->{$titleElName})) { $title = $row->{$titleElName}; } if (FArrayHelper::getValue($dbColName, 'label') != '') { $str = $tStart . $str . "</table>"; } else { $str = $str2; } // Url link to article $link = JRoute::_('index.php?option=com_' . $this->package . '&view=' . $view . '&listid=' . $table->id . '&formid=' . $form->id . '&rowid=' . $row->slug); $guid = COM_FABRIK_LIVESITE . 'index.php?option=com_' . $this->package . '&view=' . $view . '&listid=' . $table->id . '&formid=' . $form->id . '&rowid=' . $row->slug; // Strip html from feed item description text $author = @$row->created_by_alias ? @$row->created_by_alias : @$row->author; $item->date = isset($row->{$dateElName}) && $row->{$dateElName} ? date('r', strtotime(@$row->{$dateElNameRaw})) : ''; // Load individual item creator class $item->title = $title; $item->link = $link; $item->guid = $guid; $item->description = $str; // $$$ hugh - not quite sure where we were expecting $row->category to come from. Comment out for now. // $item->category = $row->category; foreach ($enclosures as $enclosure) { $item->setEnclosure($enclosure); } // Loads item info into rss array $res = $this->doc->addItem($item); } } }
/** * Set page title * * @param object $w Fabrikworker * @param object &$params list params * @param object $model list model * * @return void */ protected function setTitle($w, &$params, $model) { parent::setTitle($w, $params, $model); // Set the download file name based on the document title $this->doc->setName($this->doc->getTitle()); }
/** * Display the template * * @param sting $tpl template * * @return void */ public function display($tpl = null) { $input = $this->app->input; /** @var FabrikFEModelList $model */ $model = $this->getModel(); $model->setId($input->getInt('listid')); if (!parent::access($model)) { exit; } $table = $model->getTable(); $params = $model->getParams(); $rowId = $input->getString('rowid', '', 'string'); list($this->headings, $groupHeadings, $this->headingClass, $this->cellClass) = $this->get('Headings'); $data = $model->render(); $this->emptyDataMessage = $this->get('EmptyDataMsg'); $nav = $model->getPagination(); $form = $model->getFormModel(); $c = 0; foreach ($data as $groupKey => $group) { foreach ($group as $i => $x) { $o = new stdClass(); if (is_object($data[$groupKey])) { $o->data = ArrayHelper::fromObject($data[$groupKey]); } else { $o->data = $data[$groupKey][$i]; } if (array_key_exists($groupKey, $model->groupTemplates)) { $o->groupHeading = $model->groupTemplates[$groupKey] . ' ( ' . count($group) . ' )'; } $o->cursor = $i + $nav->limitstart; $o->total = $nav->total; $o->id = 'list_' . $model->getRenderContext() . '_row_' . @$o->data->__pk_val; $o->class = 'fabrik_row oddRow' . $c; if (is_object($data[$groupKey])) { $data[$groupKey] = $o; } else { $data[$groupKey][$i] = $o; } $c = 1 - $c; } } $groups = $form->getGroupsHiarachy(); foreach ($groups as $groupModel) { $elementModels = $groupModel->getPublishedElements(); foreach ($elementModels as $elementModel) { $elementModel->setContext($groupModel, $form, $model); $elementModel->setRowClass($data); } } $d = array('id' => $table->id, 'listRef' => $input->get('listref'), 'rowid' => $rowId, 'model' => 'list', 'data' => $data, 'headings' => $this->headings, 'formid' => $model->getTable()->form_id, 'lastInsertedRow' => $this->session->get('lastInsertedRow', 'test')); $d['nav'] = get_object_vars($nav); $tmpl = $input->get('tmpl', $this->getTmpl()); $d['htmlnav'] = $params->get('show-table-nav', 1) ? $nav->getListFooter($model->getId(), $tmpl) : ''; $d['calculations'] = $model->getCalculations(); // $$$ hugh - see if we have a message to include, set by a list plugin $context = 'com_' . $this->package . '.list' . $model->getRenderContext() . '.msg'; if ($this->session->has($context)) { $d['msg'] = $this->session->get($context); $this->session->clear($context); } echo json_encode($d); }