Example #1
0
 /**
  * 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();
 }
Example #2
0
	/**
	 * 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;
	}
Example #3
0
	/**
	 * display the template
	 *
	 * @param sting $tpl
	 */

	function display($tpl = null)
	{
		global $_PROFILER;
		$app = JFactory::getApplication();
		$Itemid	= $app->getMenu('site')->getActive()->id;
		// turn off deprecated warnings in 5.3 or greater,
		// or J!'s PDF lib throws warnings about set_magic_quotes_runtime()
		if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
			$current_level = error_reporting();
    		error_reporting($current_level & ~E_DEPRECATED);
		}
		require_once(COM_FABRIK_FRONTEND.DS.'views'.DS.'modifiers.php');
		$user 		= JFactory::getUser();
		$model		=& $this->getModel();

		$document = JFactory::getDocument();

		//this gets the component settings
		$usersConfig = JComponentHelper::getParams('com_fabrik');

		$table			=& $model->getTable();
		$model->render();

		$w = new FabrikWorker();
		if (!$this->isMambot) {
			$document->setTitle($w->parseMessageForPlaceHolder($table->label, $_REQUEST));
		}
		$document->setName($w->parseMessageForPlaceHolder($table->label, $_REQUEST));
		$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;
			for ($i=0; $i<count($group); $i++) {
				$o = new stdClass();
				// $$$ rob moved merge wip code to FabrikModelTable::formatForJoins() - should contain fix for pagination
				$o->data = $data[$groupk][$i];
				$o->cursor = $i + $nav->limitstart;
				$o->total = $nav->total;
				$o->id = "list_".$table->id."_row_".@$o->data->__pk_val;
				$o->class = "fabrik_row oddRow".$c;
				$data[$groupk][$i] = $o;
				$c = 1-$c;
			}
		}
		$groups = $form->getGroupsHiarachy();
		foreach ($groups as $groupModel) {
			$elementModels = $groupModel->getPublishedElements();
			foreach ($elementModels as $elementModel) {
				$e = $elementModel->getElement();
				$elementModel->setContext($groupModel, $form, $model);
				$elparams = $elementModel->getParams();
				$col 	= $elementModel->getFullName(false, true, false);
				$col .= "_raw";
				$rowclass = $elparams->get('use_as_row_class');
				if ($rowclass == 1) {
					foreach ($data as $groupk => $group) {
						for ($i=0; $i<count($group); $i++) {
							$data[$groupk][$i]->class .= " ". preg_replace('/[^A-Z|a-z|0-9]/', '-', $data[$groupk][$i]->data->$col);
						}
					}
				}
			}
		}
		$this->rows = $data;
		reset($this->rows);
		$firstRow = current($this->rows); //cant use numeric key '0' as group by uses groupd name as key
		$this->nodata = (empty($this->rows) || (count($this->rows) == 1 && empty($firstRow))) ? 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;
		}

		$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->group_by				= $table->group_by;
		$this->formid = 'listform_' . $table->id;
		$page = $model->isAjax() ? "index.php?format=raw" : "index.php?";
		$this->table->action 	=  $page . str_replace('&', '&amp;', JRequest::getVar('QUERY_STRING', 'index.php?option=com_fabrik', 'server'));

		if ($model->isAjax()) {
			$this->table->action .= '&format=raw';
			$this->table->action = str_replace("task=package", "task=viewTable", $this->table->action);
			//$this->table->action 	= JRoute::_($this->table->action);
		}
		$this->table->action 	= JRoute::_($this->table->action);

		$this->showCSV 				= $model->canCSVExport();
		$this->showCSVImport	= $model->canCSVImport();
		$this->nav 						= $params->get('show-table-nav', 1) ? $nav->getListFooter($model->getId(), $this->get('tmpl')) : '';
		$this->fabrik_userid 	= $user->get('id');
		$this->canDelete 			= $model->canDelete() ? true : false;
		$this->deleteButton 	= $model->canDelete() ?  "<input class='button' type='button' onclick=\"$jsdelete\" value='" . JText::_('COM_FABRIK_DELETE') . "' name='delete'/>" : '';

		$this->showPDF = false;
		$this->pdfLink = false;

		$this->emptyLink = $model->canEmpty() ? '#' : '';
		$this->csvImportLink = $this->showCSVImport ? JRoute::_("index.php?option=com_fabrik&view=import&filetype=csv&listid=" . $table->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');
				if (method_exists($document, 'addHeadLink')) {
					$document->addHeadLink($this->rssLink, 'alternate', 'rel', $attribs);
				}
			}
		}
		list($this->headings, $groupHeadings, $this->headingClass, $this->cellClass) = $this->get('Headings');

		$this->filter_action = $model->getFilterAction();
		$modelFilters = $model->makeFilters('list_'. $model->getId());
		$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('requiredFiltersFound', $this->get('RequiredFiltersFound'));
		$this->assign('emptyDataMessage', $this->get('EmptyDataMsg'));
		$this->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->assignRef('groupheadings', $groupHeadings);
		$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 = $params->get('pdf_template');
		if ($tmpl == -1) {
			$tmpl = JRequest::getVar('layout', $table->template);
		}

		$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);
		//ensure we don't have an incorrect version of mootools loaded

		$this->fixForPDF();

		parent::display();
	}
Example #4
0
 /**
  * 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;
 }
Example #5
0
 /**
  * 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'));
 }