/** * Display the template * * @param sting $tpl template * * @return void */ public function display($tpl = null) { if ($this->getLayout() == '_advancedsearch') { $this->advancedSearch($tpl); return; } $fbConfig = JComponentHelper::getParams('com_fabrik'); $profiler = JProfiler::getInstance('Application'); $app = JFactory::getApplication(); $input = $app->input; $model = $this->getModel(); // Force front end templates $tmpl = $model->getTmpl(); $this->_basePath = COM_FABRIK_FRONTEND . '/views'; $jTmplFolder = FabrikWorker::j3() ? 'tmpl' : 'tmpl25'; $this->addTemplatePath($this->_basePath . '/' . $this->_name . '/' . $jTmplFolder . '/' . $tmpl); $root = $app->isAdmin() ? JPATH_ADMINISTRATOR : JPATH_SITE; $this->addTemplatePath($root . '/templates/' . $app->getTemplate() . '/html/com_fabrik/list/' . $tmpl); $user = JFactory::getUser(); $document = JFactory::getDocument(); $item = $model->getTable(); $data = $model->render(); $w = new FabrikWorker(); // Add in some styling short cuts $c = 0; $form = $model->getFormModel(); $nav = $model->getPagination(); foreach ($data as $groupk => $group) { $last_pk = ''; $last_i = 0; $num_rows = 1; foreach (array_keys($group) as $i) { $o = new stdClass(); // $$$ rob moved merge wip code to FabrikModelTable::formatForJoins() - should contain fix for pagination $o->data = $data[$groupk][$i]; $o->cursor = $num_rows + $nav->limitstart; $o->total = $nav->total; $o->id = 'list_' . $model->getRenderContext() . '_row_' . @$o->data->__pk_val; $o->class = 'fabrik_row oddRow' . $c; $data[$groupk][$i] = $o; $c = 1 - $c; $num_rows++; } } $groups = $form->getGroupsHiarachy(); foreach ($groups as $groupModel) { $elementModels = $groupModel->getPublishedElements(); foreach ($elementModels as $elementModel) { $elementModel->setContext($groupModel, $form, $model); $rowclass = $elementModel->setRowClass($data); } } $this->rows = $data; reset($this->rows); // Cant use numeric key '0' as group by uses grouped name as key $firstRow = current($this->rows); $this->requiredFiltersFound = $model->getRequiredFiltersFound(); $this->advancedSearch = $model->getAdvancedSearchLink(); $this->advancedSearchURL = $model->getAdvancedSearchURL(); $this->nodata = empty($this->rows) || count($this->rows) == 1 && empty($firstRow) || !$this->requiredFiltersFound ? true : false; $this->tableStyle = $this->nodata ? 'display:none' : ''; $this->emptyStyle = $this->nodata ? '' : 'display:none'; $params = $model->getParams(); if (!$this->access($model)) { return false; } if (!class_exists('JSite')) { require_once JPATH_ROOT . '/includes/application.php'; } $app = JFactory::getApplication(); $package = $app->getUserState('com_fabrik.package', 'fabrik'); $this->setTitle($w, $params, $model); // Deprecated (keep in case people use them in old templates) $this->table = new stdClass(); $this->table->label = FabrikString::translate($w->parseMessageForPlaceHolder($item->label, $_REQUEST)); $this->table->intro = $params->get('show_into', 1) == 0 ? '' : FabrikString::translate($w->parseMessageForPlaceHolder($item->introduction)); $this->table->outro = $params->get('show_outro', 1) == 0 ? '' : FabrikString::translate($w->parseMessageForPlaceHolder($params->get('outro'))); $this->table->id = $item->id; $this->table->renderid = $model->getRenderContext(); $this->table->db_table_name = $item->db_table_name; // End deprecated $this->list = $this->table; $this->list->class = $model->htmlClass(); $this->group_by = $item->group_by; $this->form = new stdClass(); $this->form->id = $item->form_id; $this->renderContext = $model->getRenderContext(); $this->formid = 'listform_' . $this->renderContext; $form = $model->getFormModel(); $this->table->action = $model->getTableAction(); $this->showCSV = $model->canCSVExport(); $this->showCSVImport = $model->canCSVImport(); $this->toggleCols = $model->toggleCols(); $this->showToggleCols = (bool) $params->get('toggle_cols', false); $this->canGroupBy = $model->canGroupBy(); $this->navigation = $nav; $this->nav = $input->getInt('fabrik_show_nav', $params->get('show-table-nav', 1)) ? $nav->getListFooter($this->renderContext, $model->getTmpl()) : ''; $this->nav = '<div class="fabrikNav">' . $this->nav . '</div>'; $this->fabrik_userid = $user->get('id'); $this->canDelete = $model->deletePossible() ? true : false; $this->limitLength = $model->limitLength; $this->ajax = $model->isAjax(); // 3.0 observed in list.js & html moved into fabrik_actions rollover $this->showPDF = $params->get('pdf', $fbConfig->get('list_pdf', false)); if ($this->showPDF) { FabrikWorker::canPdf(); } $this->emptyLink = $model->canEmpty() ? '#' : ''; $this->csvImportLink = $this->showCSVImport ? JRoute::_('index.php?option=com_' . $package . '&view=import&filetype=csv&listid=' . $item->id) : ''; $this->showAdd = $model->canAdd(); if ($this->showAdd) { if ($params->get('show-table-add', 1)) { $this->addRecordLink = $model->getAddRecordLink(); } else { $this->showAdd = false; } } $this->addLabel = $model->addLabel(); $this->showRSS = $params->get('rss', 0) == 0 ? 0 : 1; if ($this->showRSS) { $this->rssLink = $model->getRSSFeedLink(); if ($this->rssLink != '') { $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink($this->rssLink, 'alternate', 'rel', $attribs); } } if ($app->isAdmin()) { // Admin always uses com_fabrik option $this->pdfLink = JRoute::_('index.php?option=com_fabrik&task=list.view&listid=' . $item->id . '&format=pdf&tmpl=component'); } else { $pdfLink = 'index.php?option=com_' . $package . '&view=list&format=pdf&listid=' . $item->id; if (!$this->nodata) { // If some data is shown then ensure that menu links reset filters (combined with require filters) doesn't produce an empty data set for the pdf $pdfLink .= '&resetfilters=0'; } $this->pdfLink = JRoute::_($pdfLink); } list($this->headings, $groupHeadings, $this->headingClass, $this->cellClass) = $model->getHeadings(); $this->groupByHeadings = $model->getGroupByHeadings(); $this->filter_action = $model->getFilterAction(); JDEBUG ? $profiler->mark('fabrik getfilters start') : null; $this->filters = $model->getFilters('listform_' . $this->renderContext); $fKeys = array_keys($this->filters); $this->bootShowFilters = count($fKeys) === 1 && $fKeys[0] === 'all' ? false : true; $this->clearFliterLink = $model->getClearButton(); JDEBUG ? $profiler->mark('fabrik getfilters end') : null; $this->filterMode = (int) $params->get('show-table-filters'); $this->toggleFilters = $this->filterMode == 2 || $this->filterMode == 4; $this->showFilters = $model->getShowFilters(); $this->filterCols = (int) $params->get('list_filter_cols', '1'); $this->showClearFilters = $this->showFilters || $params->get('advanced-filter') ? true : false; $this->emptyDataMessage = $model->getEmptyDataMsg(); $this->groupheadings = $groupHeadings; $this->calculations = $this->_getCalculations($this->headings); $this->isGrouped = !($model->getGroupBy() == ''); $this->colCount = count($this->headings); $this->hasButtons = $model->getHasButtons(); $this->grouptemplates = $model->groupTemplates; $this->params = $params; $this->loadTemplateBottom(); $this->getManagementJS($this->rows); // Get dropdown list of other tables for quick nav in admin $this->tablePicker = $app->isAdmin() && $app->input->get('format') !== 'pdf' ? FabrikHelperHTML::tableList($this->table->id) : ''; $this->buttons(); $this->pluginTopButtons = $model->getPluginTopButtons(); }
/** * Add buttons to the view e.g. print, pdf * * @return void */ protected function _addButtons() { $input = $this->app->input; if ($input->get('format') === 'pdf') { // If we're rendering as PDF, no point showing any buttons $this->showEmail = false; $this->showPrint = false; $this->showPDF = false; return; } $fbConfig = JComponentHelper::getParams('com_fabrik'); /** @var FabrikFEModelForm $model */ $model = $this->getModel(); $params = $model->getParams(); $this->showEmail = $params->get('email', $fbConfig->get('form_email', 0)); $this->emailLink = ''; $this->printLink = ''; $this->pdfLink = ''; $this->pdfURL = ''; $this->emailURL = ''; $this->printURL = ''; $this->showPrint = $params->get('print', $fbConfig->get('form_print', 0)); if ($this->showPrint) { $text = FabrikHelperHTML::image('print.png'); $this->printLink = '<a href="#" class="btn btn-default" class="printlink" onclick="window.print();return false;">' . $text . '</a>'; } if ($input->get('tmpl') != 'component') { if ($this->showEmail) { $this->emailLink = FabrikHelperHTML::emailIcon($model, $params); $this->emailURL = FabrikHelperHTML::emailURL($model); } if ($this->showPrint) { $this->printLink = FabrikHelperHTML::printIcon($model, $params); $this->printURL = FabrikHelperHTML::printURL($model); } } $this->showPDF = $params->get('pdf', $fbConfig->get('form_pdf', false)); if ($this->showPDF) { FabrikWorker::canPdf(); if ($this->app->isAdmin()) { $this->pdfURL = 'index.php?option=com_' . $this->package . '&task=details.view&format=pdf&formid=' . $model->getId() . '&rowid=' . $model->getRowId(); } else { $this->pdfURL = 'index.php?option=com_' . $this->package . '&view=details&formid=' . $model->getId() . '&rowid=' . $model->getRowId() . '&format=pdf'; } $this->pdfURL = JRoute::_($this->pdfURL); $layout = FabrikHelperHTML::getLayout('form.fabrik-pdf-icon'); $pdfDisplayData = new stdClass(); $pdfDisplayData->pdfURL = $this->pdfURL; $pdfDisplayData->tmpl = $this->tmpl; $this->pdfLink = $layout->render($pdfDisplayData); } }
/** * Add buttons to the view e.g. print, pdf * * @return void */ protected function _addButtons() { $fbConfig = JComponentHelper::getParams('com_fabrik'); $model = $this->getModel(); $params = $model->getParams(); $this->showEmail = $params->get('email', $fbConfig->get('form_email', 0)); $this->emailLink = ''; $this->printLink = ''; $this->pdfLink = ''; $this->pdfURL = ''; $this->emailURL = ''; $this->printURL = ''; $this->showPrint = $params->get('print', $fbConfig->get('form_print', 0)); if ($this->showPrint) { $text = JHTML::_('image.site', 'printButton.png', '/images/', null, null, JText::_('Print')); $this->printLink = '<a href="#" class="printlink" onclick="window.print();return false;">' . $text . '</a>'; } if (JRequest::getVar('tmpl') != 'component') { if ($this->showEmail) { $this->emailLink = FabrikHelperHTML::emailIcon($model, $params); $this->emailURL = FabrikHelperHTML::emailURL($model); } if ($this->showPrint) { $this->printLink = FabrikHelperHTML::printIcon($model, $params, $model->_rowId); $this->printURL = FabrikHelperHTML::printURL($model); } } $this->showPDF = $params->get('pdf', $fbConfig->get('form_pdf', false)); $buttonProperties = array('class' => 'fabrikTip', 'opts' => "{notice:true}", 'title' => '<span>' . JText::_('COM_FABRIK_PDF') . '</span>', 'alt' => JText::_('COM_FABRIK_PDF')); if ($this->showPDF) { if (!FabrikWorker::canPdf()) { JError::raiseNotice(500, JText::_('COM_FABRIK_NOTICE_DOMPDF_NOT_FOUND')); } else { $this->pdfURL = JRoute::_('index.php?option=com_fabrik&view=details&format=pdf&formid=' . $model->getId() . '&rowid=' . $model->_rowId); $this->pdfLink = '<a href="' . JRoute::_('index.php?option=com_fabrik&view=details&format=pdf&formid=' . $model->getId()) . '&rowid=' . $this->rowid . '">' . FabrikHelperHTML::image('pdf.png', 'list', $this->tmpl, $buttonProperties) . '</a>'; } } }
/** * Add buttons to the view e.g. print, pdf * * @return void */ protected function _addButtons() { $app = JFactory::getApplication(); if ($app->input->get('format') === 'pdf') { // If we're rendering as PDF, no point showing any buttons $this->showEmail = false; $this->showPrint = false; $this->showPDF = false; return; } $fbConfig = JComponentHelper::getParams('com_fabrik'); $package = $app->getUserState('com_fabrik.package', 'fabrik'); $input = $app->input; $model = $this->getModel(); $params = $model->getParams(); $this->showEmail = $params->get('email', $fbConfig->get('form_email', 0)); $this->emailLink = ''; $this->printLink = ''; $this->pdfLink = ''; $this->pdfURL = ''; $this->emailURL = ''; $this->printURL = ''; $this->showPrint = $params->get('print', $fbConfig->get('form_print', 0)); if ($this->showPrint) { $text = FabrikHelperHTML::image('print.png'); $this->printLink = '<a href="#" class="printlink" onclick="window.print();return false;">' . $text . '</a>'; } if ($input->get('tmpl') != 'component') { if ($this->showEmail) { $this->emailLink = FabrikHelperHTML::emailIcon($model, $params); $this->emailURL = FabrikHelperHTML::emailURL($model); } if ($this->showPrint) { $this->printLink = FabrikHelperHTML::printIcon($model, $params, $model->getRowId()); $this->printURL = FabrikHelperHTML::printURL($model); } } $this->showPDF = $params->get('pdf', $fbConfig->get('form_pdf', false)); $buttonProperties = array('class' => 'fabrikTip', 'opts' => "{notice:true}", 'title' => '<span>' . FText::_('COM_FABRIK_PDF') . '</span>', 'alt' => FText::_('COM_FABRIK_PDF')); if ($this->showPDF) { FabrikWorker::canPdf(); if ($app->isAdmin()) { $this->pdfURL = 'index.php?option=com_' . $package . '&task=details.view&format=pdf&formid=' . $model->getId() . '&rowid=' . $model->getRowId(); } else { $this->pdfURL = 'index.php?option=com_' . $package . '&view=details&formid=' . $model->getId() . '&rowid=' . $model->getRowId() . '&format=pdf'; } $this->pdfURL = JRoute::_($this->pdfURL); $this->pdfLink = '<a href="' . $this->pdfURL . '">' . FabrikHelperHTML::image('pdf.png', 'list', $this->tmpl, $buttonProperties) . '</a>'; } }
/** * Display the template * * @param sting $tpl template * * @return void */ public function display($tpl = null) { if ($this->getLayout() == '_advancedsearch') { $this->advancedSearch($tpl); return; } $fbConfig = JComponentHelper::getParams('com_fabrik'); $profiler = JProfiler::getInstance('Application'); $app = JFactory::getApplication(); // Force front end templates $tmpl = $this->get('tmpl'); $this->_basePath = COM_FABRIK_FRONTEND . '/views'; $this->addTemplatePath($this->_basePath . '/' . $this->_name . '/tmpl/' . $tmpl); $app = JFactory::getApplication(); $root = $app->isAdmin() ? JPATH_ADMINISTRATOR : JPATH_SITE; $this->addTemplatePath($root . '/templates/' . $app->getTemplate() . '/html/com_fabrik/list/' . $tmpl); require_once COM_FABRIK_FRONTEND . '/views/modifiers.php'; $user = JFactory::getUser(); $model = $this->getModel(); $document = JFactory::getDocument(); $item = $model->getTable(); $data = $model->render(); $w = new FabrikWorker(); // Add in some styling short cuts $c = 0; $form = $model->getFormModel(); $nav = $this->get('Pagination'); foreach ($data as $groupk => $group) { $last_pk = ''; $last_i = 0; $num_rows = 1; foreach (array_keys($group) as $i) { $o = new stdClass(); // $$$ rob moved merge wip code to FabrikModelTable::formatForJoins() - should contain fix for pagination $o->data = $data[$groupk][$i]; $o->cursor = $num_rows + $nav->limitstart; $o->total = $nav->total; $o->id = 'list_' . $model->getRenderContext() . '_row_' . @$o->data->__pk_val; $o->class = 'fabrik_row oddRow' . $c; $data[$groupk][$i] = $o; $c = 1 - $c; $num_rows++; } } $groups = $form->getGroupsHiarachy(); foreach ($groups as $groupModel) { $elementModels = $groupModel->getPublishedElements(); foreach ($elementModels as $elementModel) { $elementModel->setContext($groupModel, $form, $model); $rowclass = $elementModel->setRowClass($data); } } $this->rows = $data; reset($this->rows); // Cant use numeric key '0' as group by uses groupd name as key $firstRow = current($this->rows); $this->assign('requiredFiltersFound', $this->get('RequiredFiltersFound')); $this->assign('advancedSearch', $this->get('AdvancedSearchLink')); $this->nodata = empty($this->rows) || count($this->rows) == 1 && empty($firstRow) || !$this->requiredFiltersFound ? true : false; $this->tableStyle = $this->nodata ? 'display:none' : ''; $this->emptyStyle = $this->nodata ? '' : 'display:none'; $params = $model->getParams(); if (!$model->canPublish()) { echo JText::_('COM_FABRIK_LIST_NOT_PUBLISHED'); return false; } if (!$model->canView()) { echo JText::_('JERROR_ALERTNOAUTHOR'); return false; } if (!class_exists('JSite')) { require_once JPATH_ROOT . '/includes/application.php'; } $app = JFactory::getApplication(); $this->setTitle($w, $params, $model); /** depreciated (keep incase ppl use them in old tmpls**/ $this->table = new stdClass(); $this->table->label = $w->parseMessageForPlaceHolder($item->label, $_REQUEST); $this->table->intro = $w->parseMessageForPlaceHolder($item->introduction); $this->table->outro = $w->parseMessageForPlaceHolder($params->get('outro')); $this->table->id = $item->id; $this->table->renderid = $this->get('RenderContext'); $this->table->db_table_name = $item->db_table_name; /** end **/ $this->assign('list', $this->table); $this->group_by = $item->group_by; $this->form = new stdClass(); $this->form->id = $item->form_id; $this->assign('renderContext', $this->get('RenderContext')); $this->formid = 'listform_' . $this->renderContext; $form = $model->getFormModel(); $this->table->action = $this->get('TableAction'); $this->showCSV = $model->canCSVExport(); $this->showCSVImport = $model->canCSVImport(); $this->canGroupBy = $model->canGroupBy(); $this->assignRef('navigation', $nav); $this->nav = JRequest::getInt('fabrik_show_nav', $params->get('show-table-nav', 1)) ? $nav->getListFooter($this->renderContext, $this->get('tmpl')) : ''; $this->nav = '<div class="fabrikNav">' . $this->nav . '</div>'; $this->fabrik_userid = $user->get('id'); $this->canDelete = $model->deletePossible() ? true : false; // 3.0 observed in list.js & html moved into fabrik_actions rollover $canPdf = FabrikWorker::canPdf(); $this->showPDF = $params->get('pdf', $fbConfig->get('list_pdf', false)); if (!$canPdf && $this->showPDF) { JError::raiseNotice(500, JText::_('COM_FABRIK_NOTICE_DOMPDF_NOT_FOUND')); } $this->emptyLink = $model->canEmpty() ? '#' : ''; $this->csvImportLink = $this->showCSVImport ? JRoute::_("index.php?option=com_fabrik&view=import&filetype=csv&listid=" . $item->id) : ''; $this->showAdd = $model->canAdd(); if ($this->showAdd) { if ($params->get('show-table-add', 1)) { $this->assign('addRecordLink', $this->get('AddRecordLink')); } else { $this->showAdd = false; } } $this->assign('addLabel', $params->get('addlabel', JText::_('COM_FABRIK_ADD'))); $this->showRSS = $params->get('rss', 0) == 0 ? 0 : 1; if ($this->showRSS) { $this->rssLink = $model->getRSSFeedLink(); if ($this->rssLink != '') { $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink($this->rssLink, 'alternate', 'rel', $attribs); } } if ($app->isAdmin()) { $this->pdfLink = JRoute::_('index.php?option=com_fabrik&task=list.view&listid=' . $item->id . '&format=pdf&tmpl=component'); } else { $this->pdfLink = JRoute::_('index.php?option=com_fabrik&view=list&format=pdf&listid=' . $item->id); } list($this->headings, $groupHeadings, $this->headingClass, $this->cellClass) = $this->get('Headings'); $this->assign('groupByHeadings', $this->get('GroupByHeadings')); $this->filter_action = $this->get('FilterAction'); JDEBUG ? $profiler->mark('fabrik getfilters start') : null; $this->filters = $model->getFilters('listform_' . $this->renderContext); $this->assign('clearFliterLink', $this->get('clearButton')); JDEBUG ? $profiler->mark('fabrik getfilters end') : null; $this->assign('filterMode', (int) $params->get('show-table-filters')); $this->assign('toggleFilters', $this->filterMode == 2 || $this->filterMode == 4); $this->assign('showFilters', $this->get('showFilters')); $this->showClearFilters = $this->showFilters || $params->get('advanced-filter') ? true : false; $this->assign('emptyDataMessage', $this->get('EmptyDataMsg')); $this->assignRef('groupheadings', $groupHeadings); $this->calculations = $this->_getCalculations($this->headings, $model->actionMethod()); $this->assign('isGrouped', !($this->get('groupBy') == '')); $this->assign('colCount', count($this->headings)); $this->assign('hasButtons', $this->get('hasButtons')); $this->assignRef('grouptemplates', $model->groupTemplates); $this->assignRef('params', $params); $this->loadTemplateBottom(); $this->getManagementJS($this->rows); // Get dropdown list of other tables for quick nav in admin $this->tablePicker = $app->isAdmin() && $app->input->get('format') !== 'pdf' ? FabrikHelperHTML::tableList($this->table->id) : ''; $this->buttons(); $this->assign('pluginTopButtons', $this->get('PluginTopButtons')); }