/** * display the template * * @param sting $tpl */ function display($tpl = null) { if ($this->getLayout() == '_advancedsearch') { $this->advancedSearch($tpl); return; } global $_PROFILER; $app =& JFactory::getApplication(); require_once COM_FABRIK_FRONTEND . DS . 'views' . DS . 'modifiers.php'; $user =& JFactory::getUser(); $model =& $this->getModel(); $document =& JFactory::getDocument(); //this gets the component settings $this->getId(); $table =& $model->getTable(); //$model->getPostMethod(); $$$ rob dont think we need it here? $model->render(); $w = new FabrikWorker(); $data =& $model->getData(); //add in some styling short cuts $c = 0; $form =& $model->getForm(); $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 = "table_" . $table->id . "_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); $col = $elementModel->getFullName(false, true, false); $col .= "_raw"; $rowclass = $elementModel->getParams()->get('use_as_row_class'); if ($rowclass == 1) { foreach ($data as $groupk => $group) { for ($i = 0; $i < count($group); $i++) { $c = preg_replace('/[^A-Z|a-z|0-9]/', '-', $data[$groupk][$i]->data->{$col}); // $$$ rob 24/02/2011 can't have numeric class names so prefix with element name if (is_numeric($c)) { $c = $elementModel->getElement()->name . $c; } $data[$groupk][$i]->class .= " " . $c; } } } } } $this->rows =& $data; reset($this->rows); $firstRow = current($this->rows); //cant use numeric key '0' as group by uses groupd name as key $this->assign('requiredFiltersFound', $this->get('RequiredFiltersFound')); $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::_('SORRY THIS TABLE IS NOT PUBLISHED'); return false; } if (!$model->canView()) { echo JText::_('ALERTNOTAUTH'); return false; } if (!class_exists('JSite')) { require_once JPATH_ROOT . DS . 'includes' . DS . 'application.php'; } $menus =& JSite::getMenu(); $menu = $menus->getActive(); // because the application sets a default page title, we need to get it // right from the menu item itself //if there is a menu item available AND the form is not rendered in a content plugin or module if (is_object($menu) && !$this->_isMambot) { $menu_params = new JParameter($menu->params); if (!$menu_params->get('page_title') || $menu_params->get('show_page_title') == 0) { $params->set('page_title', ''); $params->set('show_page_title', 0); } else { $params->set('page_title', $menu_params->get('page_title')); $params->set('show_page_title', $menu_params->get('show_page_title', 0)); } } else { $params->set('show_page_title', JRequest::getInt('show_page_title', 0)); $params->set('page_title', JRequest::getVar('title', '')); $params->set('show-title', JRequest::getInt('show-title', 1)); } if (!$this->_isMambot) { $document->setTitle($w->parseMessageForPlaceHolder($params->get('page_title'), $_REQUEST)); } $this->table = new stdClass(); $this->table->label = $w->parseMessageForPlaceHolder($table->label, $_REQUEST); $this->table->intro = $w->parseMessageForPlaceHolder($table->introduction); $this->table->id = $table->id; $this->table->db_table_name = $table->db_table_name; $this->group_by = $table->group_by; $this->form = new stdClass(); $this->form->id = $table->form_id; $this->formid = 'tableform_' . $table->id; $form =& $model->getForm(); FabrikHelperHTML::tips('.hasTip', array(), "\$('" . $this->formid . "')"); $this->table->action = $this->get('TableAction'); $this->showCSV = $model->canCSVExport(); $this->showCSVImport = $model->canCSVImport(); $this->assignRef('navigation', $nav); $this->nav = JRequest::getInt('fabrik_show_nav', $params->get('show-table-nav', 1)) ? $nav->getListFooter($model->_id, $this->getTmpl()) : ''; $this->nav = '<div class="fabrikNav">' . $this->nav . '</div>'; $this->fabrik_userid = $user->get('id'); $this->canDelete = $model->deletePossible() ? true : false; $jsdelete = "oPackage.submitfabrikTable({$table->id}, 'delete')"; $this->deleteButton = $model->deletePossible() ? "<input class=\"button\" type=\"button\" onclick=\"{$jsdelete}\" value=\"" . JText::_('DELETE') . "\" name=\"delete\"/>" : ''; $this->showPDF = $params->get('pdf', 0); if ($this->showPDF) { $this->pdfLink = FabrikHelperHTML::pdfIcon($model, $params); } $this->emptyButton = $model->canEmpty() ? "<input class=\"button\" type=\"button\" value=\"" . JText::_('EMPTY') . "\" name=\"doempty\"/>" : ""; $this->csvImportLink = $this->showCSVImport ? JRoute::_("index.php?option=com_fabrik&c=import&view=import&filetype=csv&tableid=" . $table->id) : ''; $this->showAdd = $model->canAdd(); if ($this->showAdd) { if ($params->get('show-table-add', 1)) { $this->assign('addRecordLink', $this->get('AddRecordLink')); $this->assign('addRecordLabel', $this->get('AddRecordLabel')); } else { $this->showAdd = false; } } $this->assign('addRecordId', "table_" . $model->_id . "_addRecord"); $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); } } list($this->headings, $groupHeadings, $this->headingClass, $this->cellClass) = $this->get('Headings'); $this->filter_action = $model->getFilterAction(); JDEBUG ? $_PROFILER->mark('fabrik getfilters start') : null; $this->filters =& $model->getFilters('tableform_' . $model->_id, 'table'); $this->assign('clearFliterLink', $this->get('clearButton')); JDEBUG ? $_PROFILER->mark('fabrik getfilters end') : null; $form->getGroupsHiarachy(); $this->assign('showFilters', count($this->filters) > 0 && $params->get('show-table-filters', 1) && JRequest::getVar('showfilters', 1) == 1 ? 1 : 0); $this->assign('emptyDataMessage', $this->get('EmptyDataMsg')); $this->assignRef('groupheadings', $groupHeadings); $this->assignRef('calculations', $this->_getCalculations($this->headings)); $this->assign('isGrouped', $table->group_by); $this->assign('colCount', count($this->headings)); $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() ? FabrikHelperHTML::tableList($this->table->id) : ''; $this->pluginButtons = $model->getPluginButtons(); //force front end templates $this->_basePath = COM_FABRIK_FRONTEND . DS . 'views'; $tmpl = $this->getTmpl(); $this->_setPath('template', $this->_basePath . DS . $this->_name . DS . 'tmpl' . DS . $tmpl); $this->setLayout('default'); // kludge for convincing J! to look for the right files in loadTemplate() $text = $this->loadTemplate(); if ($params->get('process-jplugins')) { $opt = JRequest::getVar('option'); JRequest::setVar('option', 'com_content'); jimport('joomla.html.html.content'); $text .= '{emailcloak=off}'; $text = JHTML::_('content.prepare', $text); $text = preg_replace('/\\{emailcloak\\=off\\}/', '', $text); JRequest::setVar('option', $opt); } FabrikHelperHTML::cleanMootools(); JDEBUG ? $_PROFILER->mark('end fabrik display') : null; // $$$ rob 09/06/2011 no need for isMambot test? should use ob_start() in module / plugin to capture the output echo $text; }
/** * display the template * * @param sting $tpl */ function display($tpl = null) { FabrikHelperHTML::framework(); if ($this->getLayout() == '_advancedsearch') { $this->advancedSearch($tpl); return; } global $_PROFILER; $app = JFactory::getApplication(); require_once(COM_FABRIK_FRONTEND.DS.'views'.DS.'modifiers.php'); $user = JFactory::getUser(); $model = $this->getModel(); $document = JFactory::getDocument(); $item = $model->getTable(); $model->render(); $w = new FabrikWorker(); $data = $this->get('Data'); //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_".$item->id."_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); $col = $elementModel->getFullName(false, true, false); $col .= "_raw"; $rowclass = $elementModel->getParams()->get('use_as_row_class'); if ($rowclass == 1) { foreach ($data as $groupk => $group) { for ($i=0; $i<count($group); $i++) { $c = preg_replace('/[^A-Z|a-z|0-9]/', '-', $data[$groupk][$i]->data->$col); // $$$ rob 24/02/2011 can't have numeric class names so prefix with element name if (is_numeric($c)) { $c = $elementModel->getElement()->name . $c; } $data[$groupk][$i]->class .= " " . $c; } } } } } $this->rows = $data; reset($this->rows); $firstRow = current($this->rows); //cant use numeric key '0' as group by uses groupd name as key $this->assign('requiredFiltersFound', $this->get('RequiredFiltersFound')); $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.DS.'includes'.DS.'application.php'); } $menus = JSite::getMenu(); $menu = $menus->getActive(); // because the application sets a default page title, we need to get it // right from the menu item itself //if there is a menu item available AND the form is not rendered in a content plugin or module if (is_object($menu) && !$this->isMambot) { $menu_params = new JParameter($menu->params); if (!$menu_params->get('page_title') || $menu_params->get('show_page_title') == 0) { $params->set('page_title', ''); $params->set('show_page_title', 0); } else { $params->set('page_title', $menu_params->get('page_title')); $params->set('show_page_title', $menu_params->get('show_page_title', 0)); } } else { $params->set('show_page_title', JRequest::getInt('show_page_title', 0)); $params->set('page_title', JRequest::getVar('title', '')); $params->set('show-title', JRequest::getInt('show-title', 1)); } if (!$this->isMambot) { $document->setTitle($w->parseMessageForPlaceHolder($params->get('page_title'), $_REQUEST)); } /** 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->id = $item->id; $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->id; $this->formid = 'listform_'.$item->id; $form = $model->getFormModel(); $this->table->action = $this->get('TableAction'); $this->showCSV = $model->canCSVExport(); $this->showCSVImport = $model->canCSVImport(); $this->assignRef('navigation', $nav); $this->nav = JRequest::getInt('fabrik_show_nav', $params->get('show-table-nav', 1)) ? $nav->getListFooter($item->id, $this->get('tmpl')) : ''; $this->nav = '<div class="fabrikNav">'.$this->nav.'</div>'; $this->fabrik_userid = $user->get('id'); $this->canDelete = $model->deletePossible() ? true : false; $tmpl = $this->get('tmpl'); // 3.0 observed in list.js & html moved into fabrik_actions rollover $this->showPDF = $params->get('pdf', 0); if ($this->showPDF) { $this->pdfLink = FabrikHelperHTML::pdfIcon($model, $params); } $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->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); } } list($this->headings, $groupHeadings, $this->headingClass, $this->cellClass) = $this->get('Headings'); $this->assignRef('groupByHeadings', $this->get('GroupByHeadings')); $this->filter_action = $this->get('FilterAction'); JDEBUG ? $_PROFILER->mark('fabrik getfilters start') : null; $this->filters = $model->getFilters('listform_'. $item->id); $this->assign('clearFliterLink', $this->get('clearButton')); JDEBUG ? $_PROFILER->mark('fabrik getfilters end') : null; //$form->getGroupsHiarachy(); $this->assign('showFilters', (count($this->filters) > 0 && $params->get('show-table-filters', 1) !== 0) && JRequest::getVar('showfilters', 1) == 1 ? 1 : 0); $this->assign('emptyDataMessage', $this->get('EmptyDataMsg')); $this->assignRef('groupheadings', $groupHeadings); $this->assignRef('calculations', $this->_getCalculations($this->headings)); $this->assign('isGrouped', !($this->get('groupBy') == '')); $this->assign('colCount', count($this->headings)); $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() ? FabrikHelperHTML::tableList($this->table->id) : ''; // 3.0 buttons now rendered in fabrik_action <ul> //$this->pluginButtons = $model->getPluginButtons(); //force front end templates $this->_basePath = COM_FABRIK_FRONTEND.DS.'views'; $this->addTemplatePath($this->_basePath.DS.$this->_name.DS.'tmpl'.DS.$tmpl); $this->addTemplatePath(JPATH_SITE.DS.'templates'.DS.$app->getTemplate().DS.'html'.DS.'com_fabrik'.DS.'list'.DS.$tmpl); $text = $this->loadTemplate(); if ($params->get('process-jplugins')) { $opt = JRequest::getVar('option'); JRequest::setVar('option', 'com_content'); jimport('joomla.html.html.content'); $text .= '{emailcloak=off}'; $text = JHTML::_('content.prepare', $text); $text = preg_replace('/\{emailcloak\=off\}/', '', $text); JRequest::setVar('option', $opt); } JDEBUG ? $_PROFILER->mark('end fabrik display') : null; // $$$ rob 09/06/2011 no need for isMambot test? should use ob_start() in module / plugin to capture the output echo $text; }
/** * add buttons to the view e.g. print, pdf */ protected function _addButtons() { $model = $this->getModel(); $params = $model->getParams(); $this->showEmail = $params->get('email', 0); $this->emailLink = ''; $this->printLink = ''; $this->pdfLink = ''; $this->showPrint = $params->get('print', 0); if ($this->showPrint) { $text = JHTML::_('image.site', 'printButton.png', '/images/M_images/', NULL, NULL, JText::_('Print')); $this->printLink = '<a href="#" onclick="window.print();return false;">' . $text . '</a>'; } if (JRequest::getVar('tmpl') != 'component') { if ($this->showEmail) { $this->emailLink = FabrikHelperHTML::emailIcon($model, $params); } if ($this->showPrint) { $this->printLink = FabrikHelperHTML::printIcon($model, $params, $model->_rowId); } $this->showPDF = $params->get('pdf', 0); if ($this->showPDF) { $this->pdfLink = FabrikHelperHTML::pdfIcon($model, $params, $model->_rowId); } } else { $this->showPDF = false; } }