/** * 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 = 'default') { $app = JFactory::getApplication(); $input = $app->input; $j3 = FabrikWorker::j3(); $srcs = FabrikHelperHTML::framework(); $model = $this->getModel(); $usersConfig = JComponentHelper::getParams('com_fabrik'); $model->setId($input->getInt('id', $usersConfig->get('visualizationid', $input->getInt('visualizationid', 0)))); $this->row = $model->getVisualization(); if (!$model->canView()) { echo FText::_('JERROR_ALERTNOAUTHOR'); return false; } $this->js = $this->get('JS'); $viewName = $this->getName(); $params = $model->getParams(); $this->params = $params; $pluginManager = JModelLegacy::getInstance('Pluginmanager', 'FabrikFEModel'); $plugin = $pluginManager->getPlugIn('slideshow', 'visualization'); $this->showFilters = $model->showFilters(); $this->filters = $this->get('Filters'); $this->filterFormURL = $this->get('FilterFormURL'); $this->params = $model->getParams(); $this->containerId = $this->get('ContainerId'); $srcs['FbListFilter'] = 'media/com_fabrik/js/listfilter.js'; if ($this->get('RequiredFiltersFound')) { $srcs['Slideshow2'] = 'components/com_fabrik/libs/slideshow2/js/slideshow.js'; $mode = $params->get('slideshow_viz_type', 1); switch ($mode) { case 1: break; case 2: $srcs['Kenburns'] = 'components/com_fabrik/libs/slideshow2/js/slideshow.kenburns.js'; break; case 3: $srcs['Push'] = 'components/com_fabrik/libs/slideshow2/js/slideshow.push.js'; break; case 4: $srcs['Fold'] = 'components/com_fabrik/libs/slideshow2/js/slideshow.fold.js'; break; default: break; } JHTML::stylesheet('components/com_fabrik/libs/slideshow2/css/slideshow.css'); $srcs['SlideShow'] = 'plugins/fabrik_visualization/slideshow/slideshow.js'; } FabrikHelperHTML::slimbox(); FabrikHelperHTML::iniRequireJs($model->getShim()); FabrikHelperHTML::script($srcs, $this->js); //FabrikHelperHTML::slimbox(); $tpl = $j3 ? 'bootstrap' : 'default'; $tpl = $params->get('slideshow_viz_layout', $tpl); $tmplpath = $model->pathBase . 'slideshow/views/slideshow/tmpl/' . $tpl; $this->_setPath('template', $tmplpath); FabrikHelperHTML::stylesheetFromPath('plugins/fabrik_visualization/slideshow/views/slideshow/tmpl/' . $tpl . '/template.css'); FabrikHelperHTML::stylesheetFromPath('plugins/fabrik_visualization/slideshow/views/slideshow/tmpl/' . $tpl . '/custom.css'); echo parent::display(); }
/** * 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 = 'default') { $app = JFactory::getApplication(); $input = $app->input; $model = $this->getModel(); $usersConfig = JComponentHelper::getParams('com_fabrik'); $id = $input->get('id', $usersConfig->get('visualizationid', $input->get('visualizationid', 0))); $model->setId($id); $this->row = $model->getVisualization(); if (!$model->canView()) { echo FText::_('JERROR_ALERTNOAUTHOR'); return false; } $params = $model->getParams(); $this->events = $model->setUpEvents(); $this->params = $params; $this->containerId = $model->getJSRenderContext(); $this->filters = $this->get('Filters'); $this->showFilters = $model->showFilters(); $this->showTitle = $input->getInt('show-title', 1); $this->filterFormURL = $this->get('FilterFormURL'); $this->canAdd = (bool) $params->get('fullcalendar-read-only', 0) == 1 ? false : $model->getCanAdd(); $this->requiredFiltersFound = $this->get('RequiredFiltersFound'); if ($params->get('fullcalendar_show_messages', '1') == '1' && $this->canAdd && $this->requiredFiltersFound) { $msg = FText::_('PLG_VISUALIZATION_FULLCALENDAR_DOUBLE_CLICK_TO_ADD'); $msg .= $model->getDateLimitsMsg(); $app->enqueueMessage($msg); } $this->jLayouts(); $this->jsText(); $this->iniJs(); FabrikHelperHTML::slimbox(); $this->params = $model->getParams(); $tpl = $params->get('calendar_layout', $tpl); $tmplPath = JPATH_ROOT . '/plugins/fabrik_visualization/fullcalendar/views/fullcalendar/tmpl/' . $tpl; $this->_setPath('template', $tmplPath); $this->css($tpl); return parent::display(); }
/** * Returns javascript which creates an instance of the class defined in formJavascriptClass() * * @param int $repeatCounter Repeat group counter * * @return array */ public function elementJavascript($repeatCounter) { $listModel = $this->getlistModel(); $params = $this->getParams(); $target = $params->get('link_target', ''); $smart_link = $params->get('link_smart_link', false); if ($listModel->getOutPutFormat() != 'rss' && ($smart_link || $target == 'mediabox')) { FabrikHelperHTML::slimbox(); } $id = $this->getHTMLId($repeatCounter); $opts = $this->getElementJSOptions($repeatCounter); return array('FbLink', $id, $opts); }
protected function getManagementJS($data = array()) { global $Itemid; // $$$ rob ALWAYS load the calendar (so its avaible in ajax forms) FabrikHelperHTML::loadcalendar(); $app =& JFactory::getApplication(); $model =& $this->getModel(); $table =& $model->getTable(); $formModel =& $model->getForm(); $elementsNotInTable =& $formModel->getElementsNotInTable(); $keys = array('id' => '', 'name' => '', 'label' => ''); foreach ($elementsNotInTable as &$i) { if (is_a($i, 'TableElement')) { $i = array_intersect_key($i->getPublicProperties(), $keys); } } FabrikHelperHTML::packageJS(); $document =& JFactory::getDocument(); if ($model->requiresSlimbox()) { FabrikHelperHTML::slimbox(); } if ($model->requiresMocha()) { FabrikHelperHTML::mocha(); } FabrikHelperHTML::script('table.js', 'media/com_fabrik/js/', true); $tmpl = $this->getTmpl(); FabrikHelperHTML::stylesheet('table.css', 'media/com_fabrik/css/'); // check for a custom css file and include it if it exists FabrikHelperHTML::stylesheetFromPath("components" . DS . "com_fabrik" . DS . "views" . DS . "table" . DS . "tmpl" . DS . $tmpl . DS . "template.css"); //check and add a general fabrik custom css file overrides template css and generic table css FabrikHelperHTML::stylesheetFromPath("media" . DS . "com_fabrik" . DS . "css" . DS . "custom.css"); //check and add a specific table template css file overrides template css generic table css and generic custom css FabrikHelperHTML::stylesheetFromPath("components" . DS . "com_fabrik" . DS . "views" . DS . "table" . DS . "tmpl" . DS . $tmpl . DS . "custom.css"); // check for a custom js file and include it if it exists $aJsPath = JPATH_SITE . DS . "components" . DS . "com_fabrik" . DS . "views" . DS . "table" . DS . "tmpl" . DS . $tmpl . DS . "javascript.js"; if (JFile::exists($aJsPath)) { FabrikHelperHTML::script("javascript.js", 'components/com_fabrik/views/table/tmpl/' . $tmpl . '/', true); } $origRows = $this->rows; $this->rows = array(array()); $tmpItemid = !isset($Itemid) ? 0 : $Itemid; $this->_c = 0; $this->_row = new stdClass(); $script = ''; // $$$ rob done in HTMLHelper //$script = "/* <![CDATA[ */ \n"; static $tableini; if (!$tableini) { $tableini = true; $script .= "var oTables = \$H();\n"; } $opts = new stdClass(); $opts->admin = $app->isAdmin(); $opts->postMethod = $model->getPostMethod(); $opts->filterMethod = $this->filter_action; $opts->form = 'tableform_' . $model->_id; $opts->headings = $model->_jsonHeadings(); $labels = $this->headings; foreach ($labels as &$l) { $l = strip_tags($l); } $opts->labels = $labels; $opts->primaryKey = $table->db_primary_key; $opts->Itemid = $tmpItemid; $opts->formid = $model->_oForm->getId(); $opts->canEdit = $model->canEdit() ? "1" : "0"; $opts->canView = $model->canView() ? "1" : "0"; $opts->page = JRoute::_('index.php'); $opts->isGrouped = $this->isGrouped; $opts->mooversion = FabrikWorker::getMooVersion() == 1 ? 1.2 : 1.1; if (FabrikWorker::nativeMootools12()) { $opts->mooversion = 1.24; } $opts->formels = $elementsNotInTable; //if table data starts as empty then we need the html from the row // template otherwise we can't add a row to the table if ($model->_postMethod == 'ajax') { ob_start(); $this->_row = new stdClass(); $this->_row->id = ''; $this->_row->class = 'fabrik_row'; require COM_FABRIK_FRONTEND . DS . 'views' . DS . 'table' . DS . 'tmpl' . DS . 'default' . DS . 'default_row.php'; $opts->rowtemplate = ob_get_contents(); ob_end_clean(); } //$$$rob if you are loading a table in a window from a form db join select record option // then we want to know the id of the window so we can set its showSpinner() method $opts->winid = JRequest::getVar('winid', ''); $opts->ajaxEditViewLink = $model->ajaxEditViewLink() ? 1 : 0; $opts = json_encode($opts); $lang = new stdClass(); $lang->select_rows = JText::_('SELECT SOME ROWS FOR DELETION'); $lang->yes = JText::_('Yes'); $lang->no = JText::_('No'); $lang->select_colums_to_export = JText::_('SELECT_COLUMNS_TO_EXPORT'); $lang->include_filters = JText::_('INCLUDE_FILTERS'); $lang->include_data = JText::_('INCLUDE_DATA'); $lang->inlcude_raw_data = JText::_('INCLUDE_RAW_DATA'); $lang->include_calculations = JText::_('INLCUDE_CALCULATIONS'); $lang->export = JText::_('EXPORT'); $lang->loading = JText::_('loading'); $lang->savingto = JText::_('Saving to'); $lang->confirmDelete = JText::_('CONFIRMDELETE'); $lang->csv_downloading = JText::_('COM_FABRIK_CSV_DOWNLOADING'); $lang->download_here = JText::_('COM_FABRIK_DOWNLOAD_HERE'); $lang->csv_complete = JText::_('COM_FABRIK_CSV_COMPLETE'); $lang = json_encode($lang); $script .= "\n" . "var oTable{$model->_id} = new fabrikTable({$model->_id},"; $script .= $opts . "," . $lang; $script .= "\n" . ");"; $script .= "\n" . "oTable{$model->_id}.addListenTo('form_{$model->_oForm->_id}');"; $script .= "\n" . "oTable{$model->_id}.addListenTo('table_{$model->_id}');"; $script .= "\n" . "oPackage.addBlock('table_{$model->_id}', oTable{$model->_id});"; //add in plugin objects $plugins = $this->get('PluginJsObjects'); $script .= "\noTable{$model->_id}.addPlugins([\n"; $script .= " " . implode(",\n ", $plugins); $script .= "]\n);\n"; $script .= "oTables.set({$model->_id}, oTable{$model->_id});\n"; FabrikHelperHTML::addScriptDeclaration($script); $this->getElementJs(); //reset data back to original settings $this->rows = $origRows; $this->get('CustomJsAction'); }
protected function getManagementJS($data = array()) { $app = JFactory::getApplication(); $menuItem = $app->getMenu('site')->getActive(); $Itemid = is_object($menuItem) ? $menuItem->id : 0; $model = $this->getModel(); $item = $model->getTable(); $listref = $model->getRenderContext(); $listid = $model->getId(); $formModel = $model->getFormModel(); $elementsNotInTable = $formModel->getElementsNotInTable(); if ($model->requiresSlimbox()) { FabrikHelperHTML::slimbox(); } $src = $this->get('PluginJsClasses'); array_unshift($src, 'media/com_fabrik/js/list.js'); array_unshift($src, 'media/com_fabrik/js/advanced-search.js'); FabrikHelperHTML::script($src); $tmpl = $this->get('tmpl'); $this->assign('tmpl', $tmpl); $this->get('ListCss'); // check for a custom js file and include it if it exists $aJsPath = JPATH_SITE . DS . "components" . DS . "com_fabrik" . DS . "views" . DS . "list" . DS . "tmpl" . DS . $tmpl . DS . "javascript.js"; if (JFile::exists($aJsPath)) { FabrikHelperHTML::script('components/com_fabrik/views/list/tmpl/' . $tmpl . '/javascript.js'); } $origRows = $this->rows; $this->rows = array(array()); $tmpItemid = !isset($Itemid) ? 0 : $Itemid; $this->_row = new stdClass(); $script = array(); $script[] = "head.ready(function() {"; $params = $model->getParams(); $opts = new stdClass(); $opts->admin = $app->isAdmin(); $opts->ajax = (int) $model->isAjax(); $opts->ajax_links = (bool) $params->get('list_ajax_links', $opts->ajax); $opts->links = array('detail' => $params->get('detailurl'), 'edit' => $params->get('editurl'), 'add' => $params->get('addurl')); $opts->filterMethod = $this->filter_action; $opts->form = 'listform_' . $listref; $opts->headings = $model->_jsonHeadings(); $labels = $this->headings; foreach ($labels as &$l) { $l = strip_tags($l); } $opts->labels = $labels; $opts->primaryKey = $item->db_primary_key; $opts->Itemid = $tmpItemid; $opts->listRef = $listref; $opts->formid = $model->getFormModel()->getId(); $opts->canEdit = $model->canEdit() ? "1" : "0"; $opts->canView = $model->canView() ? "1" : "0"; $opts->page = JRoute::_('index.php'); $opts->isGrouped = $this->isGrouped; $opts->formels = $elementsNotInTable; $opts->actionMethod = $params->get('actionMethod'); $opts->floatPos = $params->get('floatPos'); $opts->csvChoose = (bool) $params->get('csv_frontend_selection'); $popUpWidth = $params->get('popup_width', ''); if ($popUpWidth !== '') { $opts->popup_width = (int) $popUpWidth; } $popUpHeight = $params->get('popup_height', ''); if ($popUpHeight !== '') { $opts->popup_height = (int) $popUpHeight; } $xOffset = $params->get('popup_offset_x', ''); if ($xOffset !== '') { $opts->popup_offset_x = (int) $xOffset; } $yOffset = $params->get('popup_offset_y', ''); if ($yOffset !== '') { $opts->popup_offset_y = (int) $yOffset; } $opts->popup_edit_label = $params->get('editlabel', JText::_('COM_FABRIK_EDIT')); $opts->popup_view_label = $params->get('detaillabel', JText::_('COM_FABRIK_VIEW')); $opts->popup_add_label = $params->get('addlabel', JText::_('COM_FABRIK_ADD')); $opts->limitLength = $model->limitLength; $opts->limitStart = $model->limitStart; $csvOpts = new stdClass(); $csvOpts->excel = (int) $params->get('csv_format'); $csvOpts->inctabledata = (int) $params->get('csv_include_data'); $csvOpts->incraw = (int) $params->get('csv_include_raw_data'); $csvOpts->inccalcs = (int) $params->get('csv_include_calculations'); $opts->csvOpts = $csvOpts; $opts->csvFields = $this->get('CsvFields'); $csvOpts->incfilters = (int) $params->get('incfilters'); $opts->data = $data; //if table data starts as empty then we need the html from the row // template otherwise we can't add a row to the table ob_start(); $this->_row = new stdClass(); $this->_row->id = ''; $this->_row->class = 'fabrik_row'; /* if (JFile::exists(COM_FABRIK_FRONTEND . '/views/list/tmpl/' . $tmpl . '/default_row.php')) { require(COM_FABRIK_FRONTEND . '/views/list/tmpl/' . $tmpl . '/default_row.php'); } */ echo $this->loadTemplate('row'); $opts->rowtemplate = ob_get_contents(); ob_end_clean(); //$$$rob if you are loading a table in a window from a form db join select record option // then we want to know the id of the window so we can set its showSpinner() method $opts->winid = JRequest::getVar('winid', ''); $opts = json_encode($opts); JText::script('COM_FABRIK_PREV'); JText::script('COM_FABRIK_SELECT_ROWS_FOR_DELETION'); JText::script('JYES'); JText::script('JNO'); JText::script('COM_FABRIK_SELECT_COLUMNS_TO_EXPORT'); JText::script('COM_FABRIK_INCLUDE_FILTERS'); JText::script('COM_FABRIK_INCLUDE_DATA'); JText::script('COM_FABRIK_INCLUDE_RAW_DATA'); JText::script('COM_FABRIK_INLCUDE_CALCULATIONS'); JText::script('COM_FABRIK_EXPORT'); JText::script('COM_FABRIK_START'); JText::script('COM_FABRIK_NEXT'); JText::script('COM_FABRIK_END'); JText::script('COM_FABRIK_PAGE'); JText::script('COM_FABRIK_OF'); JText::script('COM_FABRIK_LOADING'); JText::script('COM_FABRIK_RECORDS'); JText::script('COM_FABRIK_SAVING_TO'); JText::script('COM_FABRIK_CONFIRM_DROP'); JText::script('COM_FABRIK_CONFIRM_DELETE'); JText::script('COM_FABRIK_NO_RECORDS'); JText::script('COM_FABRIK_CSV_COMPLETE'); JText::script('COM_FABRIK_CSV_DOWNLOAD_HERE'); JText::script('COM_FABRIK_CONFIRM_DELETE'); JText::script('COM_FABRIK_CSV_DOWNLOADING'); JText::script('COM_FABRIK_FILE_TYPE'); JText::script('COM_FABRIK_ADVANCED_SEARCH'); //keyboard short cuts JText::script('COM_FABRIK_LIST_SHORTCUTS_ADD'); JText::script('COM_FABRIK_LIST_SHORTCUTS_EDIT'); JText::script('COM_FABRIK_LIST_SHORTCUTS_DELETE'); JText::script('COM_FABRIK_LIST_SHORTCUTS_FILTER'); $script[] = "var list = new FbList('{$listid}',"; $script[] = $opts; $script[] = ");"; $script[] = "Fabrik.addBlock('list_{$listref}', list);"; //add in plugin objects $params = $model->getParams(); $pluginManager = FabrikWorker::getPluginManager(); $c = 0; $pluginManager->runPlugins('onLoadJavascriptInstance', $model, 'list'); $aObjs = $pluginManager->_data; if (!empty($aObjs)) { $script[] = "list.addPlugins([\n"; $script[] = " " . implode(",\n ", $aObjs); $script[] = "]);"; } //@since 3.0 inserts content before the start of the list render (currently on f3 tmpl only) $pluginManager->runPlugins('onGetContentBeforeList', $model, 'list'); $this->assign('pluginBeforeList', $pluginManager->_data); $script[] = $model->filterJs; $script[] = "});"; $script = implode("\n", $script); FabrikHelperHTML::addScriptDeclaration($script); $this->getElementJs(); //reset data back to original settings $this->rows = $origRows; }
/** * return the javascript to create an instance of the class defined in formJavascriptClass * @return string javascript to create instance. Instance name must be 'el' */ function elementJavascript($repeatCounter) { $tableModel =& $this->getTableModel(); $params =& $this->getParams(); $target = $params->get('link_target', ''); $smart_link = $params->get('link_smart_link', false); if ($tableModel->_outPutFormat != 'rss' && ($smart_link || $target == 'mediabox')) { FabrikHelperHTML::slimbox(); } $id = $this->getHTMLId($repeatCounter); $opts =& $this->getElementJSOptions($repeatCounter); $opts = json_encode($opts); return "new fbLink('{$id}', {$opts})"; }
protected function getManagementJS($data = array()) { $app = JFactory::getApplication(); $menuItem = $app->getMenu('site')->getActive(); $Itemid = is_object($menuItem) ? $menuItem->id : 0; $model = $this->getModel(); $item = $model->getTable(); $listid = $model->getId(); $formModel = $model->getFormModel(); $elementsNotInTable = $formModel->getElementsNotInTable(); if ($model->requiresSlimbox()) { FabrikHelperHTML::slimbox(); } if ($model->requiresMocha()) { FabrikHelperHTML::mocha(); } FabrikHelperHTML::script('media/com_fabrik/js/list.js', true); $tmpl = $this->get('tmpl'); $this->assign('tmpl', $tmpl); $this->get('ListCss'); // check for a custom js file and include it if it exists $aJsPath = JPATH_SITE.DS."components".DS."com_fabrik".DS."views".DS."list".DS."tmpl".DS.$tmpl.DS."javascript.js"; if (JFile::exists($aJsPath)) { FabrikHelperHTML::script('components/com_fabrik/views/list/tmpl/'.$tmpl.'/javascript.js', true); } $origRows = $this->rows; $this->rows = array(array()); $tmpItemid = !isset($Itemid) ? 0 : $Itemid; $this->_c = 0; $this->_row = new stdClass(); $script = ''; $opts = new stdClass(); $opts->admin = $app->isAdmin(); $opts->ajax = (int)$model->isAjax(); $opts->filterMethod = $this->filter_action; $opts->form = 'listform_' . $listid; $opts->headings = $model->_jsonHeadings(); $labels = $this->headings; foreach ($labels as &$l) { $l = strip_tags($l); } $opts->labels = $labels; $opts->primaryKey = $item->db_primary_key; $opts->Itemid = $tmpItemid; $opts->formid = $model->getFormModel()->getId(); $opts->canEdit = $model->canEdit() ? "1" : "0"; $opts->canView = $model->canView() ? "1" : "0"; $opts->page = JRoute::_('index.php'); $opts->isGrouped = $this->isGrouped; $opts->formels = $elementsNotInTable; $opts->actionMethod = $model->getParams()->get('actionMethod'); $opts->data = $data; //if table data starts as empty then we need the html from the row // template otherwise we can't add a row to the table if ($model->isAjax()) { ob_start(); $this->_row = new stdClass(); $this->_row->id = ''; $this->_row->class = 'fabrik_row'; require(COM_FABRIK_FRONTEND.DS.'views'.DS.'list'.DS.'tmpl'.DS.$tmpl.DS.'default_row.php'); $opts->rowtemplate = ob_get_contents(); ob_end_clean(); } //$$$rob if you are loading a table in a window from a form db join select record option // then we want to know the id of the window so we can set its showSpinner() method $opts->winid = JRequest::getVar('winid', ''); $opts = json_encode($opts); JText::script('COM_FABRIK_PREV'); JText::script('COM_FABRIK_SELECT_ROWS_FOR_DELETION'); JText::script('JYES'); JText::script('JNO'); JText::script('COM_FABRIK_SELECT_COLUMNS_TO_EXPORT'); JText::script('COM_FABRIK_INCLUDE_FILTERS'); JText::script('COM_FABRIK_INCLUDE_DATA'); JText::script('COM_FABRIK_INCLUDE_RAW_DATA'); JText::script('COM_FABRIK_INLCUDE_CALCULATIONS'); JText::script('COM_FABRIK_EXPORT'); JText::script('COM_FABRIK_START'); JText::script('COM_FABRIK_NEXT'); JText::script('COM_FABRIK_END'); JText::script('COM_FABRIK_PAGE'); JText::script('COM_FABRIK_OF'); JText::script('COM_FABRIK_LOADING'); JText::script('COM_FABRIK_RECORDS'); JText::script('COM_FABRIK_SAVING_TO'); JText::script('COM_FABRIK_CONFIRM_DROP'); JText::script('COM_FABRIK_CONFIRM_DELETE'); JText::script('COM_FABRIK_NO_RECORDS'); JText::script('COM_FABRIK_CSV_COMPLETE'); JText::script('COM_FABRIK_CSV_DOWNLOAD_HERE'); JText::script('COM_FABRIK_CONFIRM_DELETE'); JText::script('COM_FABRIK_CSV_DOWNLOADING'); JText::script('COM_FABRIK_FILE_TYPE'); //keyboard short cuts JText::script('COM_FABRIK_LIST_SHORTCUTS_ADD'); JText::script('COM_FABRIK_LIST_SHORTCUTS_EDIT'); JText::script('COM_FABRIK_LIST_SHORTCUTS_DELETE'); JText::script('COM_FABRIK_LIST_SHORTCUTS_FILTER'); $script .= "\n" . "var list = new FbList($listid,"; $script .= $opts; $script .= "\n" . ");"; $script .= "\n" . "Fabrik.addBlock('list_{$listid}', list);"; //add in plugin objects $params = $model->getParams(); //$activePlugins = $params->get('plugins'); $pluginManager = $model->getPluginManager(); $c = 0; $pluginManager->runPlugins('onLoadJavascriptInstance', $model, 'list'); $aObjs = $pluginManager->_data; $script .= "\nlist.addPlugins([\n"; $script .= " " . implode(",\n ", $aObjs); $script .= "\n]);\n"; //@since 3.0 inserts content before the start of the list render (currently on f3 tmpl only) $pluginManager->runPlugins('onGetContentBeforeList', $model, 'list'); $this->assign('pluginBeforeList', $pluginManager->_data); $script = " head.ready(function() { ".$model->filterJs." $script })"; FabrikHelperHTML::addScriptDeclaration($script); $this->getElementJs(); //reset data back to original settings $this->rows = $origRows; }
/** * Append the form javascript into the document head * * @param int $listId table id * * @return void|boolean */ protected function _addJavascript($listId) { $pluginManager = FabrikWorker::getPluginManager(); /** @var FabrikFEModelForm $model */ $model = $this->getModel(); $aLoadedElementPlugins = array(); $jsActions = array(); $bKey = $model->jsKey(); $srcs = FabrikHelperHTML::framework(); $shim = array(); if (!defined('_JOS_FABRIK_FORMJS_INCLUDED')) { define('_JOS_FABRIK_FORMJS_INCLUDED', 1); FabrikHelperHTML::slimbox(); $dep = new stdClass(); $dep->deps = array('fab/element', 'lib/form_placeholder/Form.Placeholder', 'fab/encoder'); $shim['fabrik/form'] = $dep; $deps = new stdClass(); $deps->deps = array('fab/fabrik', 'fab/element', 'fab/form-submit'); $framework['fab/elementlist'] = $deps; $srcs[] = 'media/com_fabrik/js/lib/form_placeholder/Form.Placeholder.js'; FabrikHelperHTML::addToFrameWork($srcs, 'media/com_fabrik/js/form'); FabrikHelperHTML::addToFrameWork($srcs, 'media/com_fabrik/js/form-submit'); FabrikHelperHTML::addToFrameWork($srcs, 'media/com_fabrik/js/element'); } $aWYSIWYGNames = array(); // $$$ hugh - yet another one where if we =, the $groups array pointer get buggered up and it // skips a group $groups = $model->getGroupsHiarachy(); foreach ($groups as $groupModel) { $elementModels = $groupModel->getPublishedElements(); foreach ($elementModels as $elementModel) { $res = $elementModel->useEditor(); if ($res !== false && $elementModel->canUse() && $model->isEditable()) { $aWYSIWYGNames[] = $res; } // Load in once the element js class files $element = $elementModel->getElement(); if (!in_array($element->plugin, $aLoadedElementPlugins)) { /* $$$ hugh - certain elements, like file-upload, need to load different JS files * on a per-element basis, so as a test fix, I modified the file-upload's formJavaScriptClass to return false, * and test for that here, so as to not add it to aLoadedElementPlugins[]. The existing 'static' tests in * formJavascriptClass() should still prevent scripts being added twice. */ if ($elementModel->formJavascriptClass($srcs, '', $shim) !== false) { $aLoadedElementPlugins[] = $element->plugin; } } $eventMax = $groupModel->repeatTotal == 0 ? 1 : $groupModel->repeatTotal; for ($c = 0; $c < $eventMax; $c++) { $jsAct = $elementModel->getFormattedJSActions($bKey, $c); if (!empty($jsAct)) { $jsActions[] = $jsAct; } } } } FabrikHelperHTML::iniRequireJS($shim); $actions = trim(implode("\n", $jsActions)); FabrikHelperHTML::windows('a.fabrikWin'); FabrikHelperHTML::tips('.hasTip', array(), "\$('{$bKey}')"); $model->getFormCss(); $opts = $this->jsOpts(); $model->jsOpts = $opts; $pluginManager->runPlugins('onJSOpts', $model); $opts = json_encode($model->jsOpts); if (!FabrikHelperHTML::inAjaxLoadedPage()) { JText::script('COM_FABRIK_VALIDATING'); JText::script('COM_FABRIK_SUCCESS'); JText::script('COM_FABRIK_NO_REPEAT_GROUP_DATA'); JText::script('COM_FABRIK_VALIDATION_ERROR'); JText::script('COM_FABRIK_CONFIRM_DELETE_1'); } JText::script('COM_FABRIK_FORM_SAVED'); // $$$ rob don't declare as var $bKey, but rather assign to window, as if loaded via ajax window the function is wrapped // inside an anonymous function, and therefore $bKey wont be available as a global var in window $script = array(); $script[] = "\t\tvar {$bKey} = Fabrik.form('{$bKey}', " . $model->getId() . ", {$opts});"; // Instantiate js objects for each element $vstr = "\n"; $groups = $model->getGroupsHiarachy(); $script[] = "\tFabrik.blocks['{$bKey}'].addElements("; $groupedJs = new stdClass(); foreach ($groups as $groupModel) { $groupId = $groupModel->getGroup()->id; $groupedJs->{$groupId} = array(); if (!$groupModel->canView('form')) { continue; } $elementJs = array(); $elementModels = $groupModel->getPublishedElements(); // $$$ rob if repeatTotal is 0 we still want to add the js objects as the els are only hidden $max = $groupModel->repeatTotal > 0 ? $groupModel->repeatTotal : 1; foreach ($elementModels as $elementModel) { $element = $elementModel->getElement(); if ($element->published == 0) { continue; } // If the view is a form then we should always add the js as long as the element is editable or viewable // if the view is details then we should only add the js if the element is viewable. if ($elementModel->canUse() && $model->isEditable() || $elementModel->canView()) { for ($c = 0; $c < $max; $c++) { $ref = $elementModel->elementJavascript($c); if (!empty($ref)) { $elementJs[] = $ref; } $validations = $elementModel->validator->findAll(); if (!empty($validations) && $elementModel->isEditable()) { $watchElements = $elementModel->getValidationWatchElements($c); foreach ($watchElements as $watchElement) { $vstr .= "\tFabrik.blocks['{$bKey}'].watchValidation('" . $watchElement['id'] . "', '" . $watchElement['triggerEvent'] . "');\n"; } } } } } $groupedJs->{$groupId} = $elementJs; } $script[] = json_encode($groupedJs); $script[] = "\t);"; $script[] = $actions; $script[] = $vstr; // Placeholder $script[] = "\tnew Form.Placeholder('.fabrikForm input');"; $this->_addJavascriptSumbit($script, $listId, $aWYSIWYGNames); if (FabrikHelperHTML::inAjaxLoadedPage()) { $tipOpts = FabrikHelperHTML::tipOpts(); $script[] = "new FloatingTips('#" . $bKey . " .fabrikTip', " . json_encode($tipOpts) . ");"; } $res = $pluginManager->runPlugins('onJSReady', $model); if (in_array(false, $res)) { return false; } $str = implode("\n", $script); $model->getCustomJsAction($srcs); $pluginManager->runPlugins('onAfterJSLoad', $model); // 3.1 call form js plugin code within main require method $srcs = array_merge($srcs, $model->formPluginShim); $str .= $model->formPluginJS; FabrikHelperHTML::script($srcs, $str); }
/** * Get the link options * * @return array */ protected function linkOpts() { $fbConfig = JComponentHelper::getParams('com_fabrik'); $params = $this->getParams(); $target = $params->get('link_target_options', 'default'); $opts = array(); $opts['rel'] = $params->get('rel', ''); switch ($target) { default: $opts['target'] = $target; break; case 'default': break; case 'lightbox': FabrikHelperHTML::slimbox(); $opts['rel'] = 'lightbox[]'; if ($fbConfig->get('use_mediabox', false)) { $opts['target'] = 'mediabox'; } break; } return $opts; }
/** * append the form javascript into the document head * @param int table id */ function _addJavascript($tableId) { // $$$ rob ALWAYS load the calendar (so its avaible in ajax forms) FabrikHelperHTML::loadcalendar(); $app =& JFactory::getApplication(); $document =& JFactory::getDocument(); $model =& $this->getModel(); $aLoadedElementPlugins = array(); $jsActions = array(); $jsControllerKey = $model->_editable ? 'form_' . $model->getId() : 'details_' . $model->getId(); $allJsActions = $model->getJsActions(); FabrikHelperHTML::packageJS(); if (!defined('_JOS_FABRIK_FORMJS_INCLUDED')) { define('_JOS_FABRIK_FORMJS_INCLUDED', 1); FabrikHelperHTML::slimbox(); FabrikHelperHTML::script('form.js', 'media/com_fabrik/js/', true); FabrikHelperHTML::script('element.js', 'media/com_fabrik/js/', true); } $aWYSIWYGNames = array(); // $$$ hugh - yeat another one where if we =&, the $groups array pointer get buggered up and it // skips a group $groups = $model->getGroupsHiarachy(); foreach ($groups as $groupModel) { $elementModels =& $groupModel->getPublishedElements(); foreach ($elementModels as $elementModel) { $res = $elementModel->useEditor(); if ($res !== false) { $aWYSIWYGNames[] = $res; } $eparams =& $elementModel->getParams(); //load in once the element js class files // $$$ hugh - only needed getParent when we weren't saving changes to parent params to child // which we should now be doing ... and getParent() causes an extra table lookup for every child // element on the form. //$element =& $elementModel->getParent(); $element =& $elementModel->getElement(); if (!in_array($element->plugin, $aLoadedElementPlugins)) { $aLoadedElementPlugins[] = $element->plugin; $elementModel->formJavascriptClass(); } $eventMax = $groupModel->_repeatTotal == 0 ? 1 : $groupModel->_repeatTotal; for ($c = 0; $c < $eventMax; $c++) { $jsActions[] = $elementModel->getFormattedJSActions($allJsActions, $jsControllerKey, $c); } } } //new $actions = trim(implode("\n", $jsActions)); //end new $params =& $model->getParams(); $tableModel =& $model->getTableModel(); $table =& $tableModel->getTable(); $form =& $model->getForm(); FabrikHelperHTML::mocha(); $bkey = $model->_editable ? 'form_' . $model->getId() : 'details_' . $model->getId(); FabrikHelperHTML::tips('.hasTip', array(), "\$('{$bkey}')"); $key = FabrikString::safeColNameToArrayKey($table->db_primary_key); $this->get('FormCss'); $this->get('CustomJsAction'); //$startJs = "window.addEvent('domready', function() {\n"; $startJs = "window.addEvent('" . FabrikHelperHTML::useLoadEvent() . "', function() {\n"; $endJs = "});\n"; $start_page = isset($model->sessionModel->last_page) ? (int) $model->sessionModel->last_page : 0; if ($start_page !== 0) { $app->enqueueMessage(JText::_('RESTARTINGMUTLIPAGEFORM')); } else { // form submitted but fails validation - needs to go to the last page $start_page = JRequest::getInt('currentPage', 0); } $opts = new stdClass(); $opts->admin = $app->isAdmin(); $opts->postMethod = $this->get('PostMethod'); $opts->ajaxValidation = $params->get('ajax_validations'); $opts->primaryKey = $key; $opts->liveSite = COM_FABRIK_LIVESITE; $opts->error = @$form->origerror; $opts->pages = $model->getPages(); $opts->plugins = array(); $opts->multipage_save = (bool) $model->saveMultiPage(); $opts->editable = $model->_editable; $opts->start_page = $start_page; $opts->mooversion = FabrikWorker::getMooVersion() == 1 ? 1.2 : 1.1; //$$$rob dont int this as keys may be string $opts->rowid = $model->_rowId; //$$$rob if you are loading a table in a window from a form db join select record option // then we want to know the id of the window so we can set its showSpinner() method $opts->winid = JRequest::getVar('winid', ''); //for editing groups with joined data and an empty joined record (ie no joined records) $hidden = array(); $maxRepeat = array(); $showMaxRepeats = array(); $postedRepeatGroupCounts = (array) JRequest::getVar('fabrik_repeat_group'); foreach ($this->groups as $g) { $hidden[$g->id] = $g->startHidden; if (JArrayHelper::getValue($postedRepeatGroupCounts, $g->id, 1) == 0) { $hidden[$g->id] = true; } $maxRepeat[$g->id] = $g->maxRepeat; $showMaxRepeats[$g->id] = $g->showMaxRepeats; } $opts->hiddenGroup = $hidden; $opts->maxRepeat = $maxRepeat; $opts->showMaxRepeats = $showMaxRepeats; //$$$ rob 26/04/2011 joomfish translations of password validation error messages $opts->lang = FabrikWorker::getJoomfishLang(); // $$$ hugh adding these so calc element can easily find joined and repeated join groups // when it needs to add observe events ... don't ask ... LOL! $opts->join_group_ids = array(); $opts->group_repeats = array(); $opts->group_joins_ids = array(); $groups =& $model->getGroupsHiarachy(); foreach ($groups as $groupModel) { if ($groupModel->getGroup()->is_join) { $opts->join_group_ids[$groupModel->getGroup()->join_id] = (int) $groupModel->getGroup()->id; $opts->group_join_ids[$groupModel->getGroup()->id] = (int) $groupModel->getGroup()->join_id; $opts->group_repeats[$groupModel->getGroup()->id] = $groupModel->canRepeat(); } } $opts = json_encode($opts); $lang = new stdClass(); $lang->validation_altered_content = JText::_('VALIDATION_HAS_ALTERED_CONTENT'); $lang->validating = JText::_('VALIDATING'); $lang->success = JText::_('SUCCESS'); $lang->nodata = JText::_('NOREPEATGROUPDATA'); $lang->validation_error = JText::_('VALIDATION_ERROR'); $lang->form_saved = JText::_('FORM_SAVED'); $lang->confirmDelete = JText::_('CONFIRMDELETE'); $lang = json_encode($lang); //$$$ rob dont declare as var $bkey, but rather assign to window, as if loaded via ajax window the function is wrapped // inside an anoymous function, and therefore $bkey wont be available as a global var in window $str = "window.{$bkey} = new fabrikForm(" . $model->getId() . ", {$opts}, {$lang});\n"; $str .= "{$bkey}.addListenTo('table_" . $tableModel->getId() . "');\n"; $str .= "{$bkey}.addListenTo('form_" . $model->getId() . "');\n"; $str .= "if(\$type(window.oPackage) !== false) {\n"; $str .= "oPackage.addBlock('{$bkey}', {$bkey});\n"; $str .= "}\n"; //instantaite js objects for each element $groupstr = ''; $vstr = "\n"; $str .= "{$startJs}"; // $$$ rob in php5.2.6 (and possibly elsewhere) $groups's elements havent been updated // to contain the default value used by the element //foreach ($groups as $groupModel) { //testing this one again as Ive updated getGroupsHiarchy $str .= "{$bkey}.addElements({"; foreach ($groups as $groupModel) { $showGroup = $groupModel->getParams()->get('repeat_group_show_first'); if ($showGroup == -1 || $showGroup == 2 && $model->_editable) { // $$$ rob unpublished group so dont include the element js continue; } $aObjs = array(); $elementModels =& $groupModel->getPublishedElements(); // $$$ rob if _repeatTotal is 0 we still want to add the js objects as the els are only hidden $max = $groupModel->_repeatTotal > 0 ? $groupModel->_repeatTotal : 1; $str .= $groupModel->getGroup()->id . ":["; foreach ($elementModels as $elementModel) { $element =& $elementModel->getElement(); if ($element->state == 0) { continue; } $fullName = $elementModel->getFullName(); $id = $elementModel->getHTMLId(); $elementModel->_editable = $model->_editable; if ($elementModel->canUse() || $elementModel->canView()) { for ($c = 0; $c < $max; $c++) { // $$$ rob ensure that some js code has been returned otherwise dont add empty data to array $ref = trim($elementModel->elementJavascript($c)); if ($ref !== '') { $aObjs[] = $ref; } $validations =& $elementModel->getValidations(); if (!empty($validations) && $elementModel->_editable) { $watchElements = $elementModel->getValidationWatchElements($c); foreach ($watchElements as $watchElement) { $vstr .= "{$bkey}.watchValidation('" . $watchElement['id'] . "', '" . $watchElement['triggerEvent'] . "');\n"; } } } } } $str .= implode(",\n", $aObjs); $str .= "],"; $groupParams =& $groupModel->getParams(); $addJs = str_replace('"', "'", $groupParams->get('repeat_group_js_add')); $addJs = str_replace(array("\n", "\r"), "", $addJs); $delJs = str_replace('"', "'", $groupParams->get('repeat_group_js_delete')); $gdelJs = str_replace(array("\n", "\r"), "", $delJs); if ($delJs !== '') { $groupstr .= "{$bkey}.addGroupJS(" . $groupModel->getId() . ", 'delete', \"{$delJs}\");\n"; } if ($addJs !== '') { $groupstr .= "{$bkey}.addGroupJS(" . $groupModel->getId() . ", 'add', \"{$addJs}\");\n"; } } $str = FabrikString::rtrimword($str, ','); $str .= "});\n"; $str .= $groupstr; $str .= $actions; $str .= $vstr; $str .= $endJs; $str .= "function submit_form() {"; if (!empty($aWYSIWYGNames)) { jimport('joomla.html.editor'); $editor =& FabrikHelperHTML::getEditor(); $str .= $editor->save('label'); foreach ($aWYSIWYGNames as $parsedName) { $str .= $editor->save($parsedName); } } $str .= "\n\t\t\treturn false;\n\t\t}\n\n\t\tfunction submitbutton(button) {\n\t\t\tif (button==\"cancel\") {\n\t\t\t\tdocument.location = '" . JRoute::_('index.php?option=com_fabrik&task=viewTable&cid=' . $tableId) . "';\n\t\t\t}\n\t\t\tif (button == \"cancelShowForm\") {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n"; FabrikHelperHTML::addScriptDeclaration($str); $pluginManager =& $model->getPluginManager(); $pluginManager->runPlugins('onAfterJSLoad', $model); FabrikHelperHTML::mootools(); }
/** * Append the form javascript into the document head * * @param int $tableId table id * * @return void */ protected function _addJavascript($tableId) { $app = JFactory::getApplication(); $document = JFactory::getDocument(); $model = $this->getModel(); $aLoadedElementPlugins = array(); $jsActions = array(); $jsControllerKey = $model->isEditable() ? 'form_' . $model->getId() : 'details_' . $model->getId(); $srcs = FabrikHelperHTML::framework(); if (!defined('_JOS_FABRIK_FORMJS_INCLUDED')) { define('_JOS_FABRIK_FORMJS_INCLUDED', 1); FabrikHelperHTML::slimbox(); $srcs[] = 'media/com_fabrik/js/form.js'; $srcs[] = 'media/com_fabrik/js/element.js'; $srcs[] = 'media/com_fabrik/js/lib/form_placeholder/Form.Placeholder.js'; } $aWYSIWYGNames = array(); // $$$ hugh - yeat another one where if we =, the $groups array pointer get buggered up and it // skips a group $groups = $model->getGroupsHiarachy(); foreach ($groups as $groupModel) { $elementModels = $groupModel->getPublishedElements(); foreach ($elementModels as $elementModel) { $res = $elementModel->useEditor(); if ($res !== false) { $aWYSIWYGNames[] = $res; } $eparams = $elementModel->getParams(); /* load in once the element js class files * $$$ hugh - only needed getParent when we weren't saving changes to parent params to child * which we should now be doing ... and getParent() causes an extra table lookup for every child * element on the form. * $element = $elementModel->getParent(); */ $element = $elementModel->getElement(); if (!in_array($element->plugin, $aLoadedElementPlugins)) { /* $$$ hugh - certain elements, like fileupload, need to load different JS files * on a per-element basis, so as a test fix, I modified the fileupload's formJavaScriptClass to return false, * and test for that here, so as to not add it to aLoadedElementPlugins[]. The existing 'static' tests in * formJavascriptClass() should still prevent scripts being added twice. */ if ($elementModel->formJavascriptClass($srcs) !== false) { $aLoadedElementPlugins[] = $element->plugin; } } $eventMax = $groupModel->repeatTotal == 0 ? 1 : $groupModel->repeatTotal; for ($c = 0; $c < $eventMax; $c++) { $jsActions[] = $elementModel->getFormattedJSActions($jsControllerKey, $c); } } } $actions = trim(implode("\n", $jsActions)); $params = $model->getParams(); $listModel = $model->getlistModel(); $table = $listModel->getTable(); $form = $model->getForm(); FabrikHelperHTML::mocha(); $bkey = $model->isEditable() ? 'form_' . $model->getId() : 'details_' . $model->getId(); FabrikHelperHTML::tips('.hasTip', array(), "\$('{$bkey}')"); $key = FabrikString::safeColNameToArrayKey($table->db_primary_key); $this->get('FormCss'); $start_page = isset($model->sessionModel->last_page) ? (int) $model->sessionModel->last_page : 0; if ($start_page !== 0) { $app->enqueueMessage(JText::_('COM_FABRIK_RESTARTING_MUTLIPAGE_FORM')); } else { // Form submitted but fails validation - needs to go to the last page $start_page = JRequest::getInt('currentPage', 0); } $opts = new stdClass(); $opts->admin = $app->isAdmin(); $opts->ajax = $model->isAjax(); $opts->ajaxValidation = (bool) $params->get('ajax_validations'); $opts->primaryKey = $key; $opts->error = @$form->origerror; $opts->pages = $model->getPages(); $opts->plugins = array(); $opts->multipage_save = (int) $model->saveMultiPage(); $opts->editable = $model->isEditable(); $opts->start_page = $start_page; $opts->inlineMessage = (bool) $this->isMambot; // $$$rob dont int this as keys may be string $opts->rowid = (string) $model->_rowId; // 3.0 needed for ajax requests $opts->listid = (int) $this->get('ListModel')->getId(); $imgs = new stdClass(); $imgs->alert = FabrikHelperHTML::image('alert.png', 'form', $this->tmpl, '', true); $imgs->action_check = FabrikHelperHTML::image('action_check.png', 'form', $this->tmpl, '', true); $imgs->ajax_loader = FabrikHelperHTML::image('ajax-loader.gif', 'form', $this->tmpl, '', true); $opts->images = $imgs; // $$$rob if you are loading a table in a window from a form db join select record option // then we want to know the id of the window so we can set its showSpinner() method // 3.0 changed to fabrik_window_id (automatically appended by Fabrik.Window xhr request to load window data $opts->fabrik_window_id = JRequest::getVar('fabrik_window_id', ''); $opts->submitOnEnter = (bool) $params->get('submit_on_enter', false); // For editing groups with joined data and an empty joined record (ie no joined records) $hidden = array(); $maxRepeat = array(); $showMaxRepeats = array(); foreach ($this->groups as $g) { $hidden[$g->id] = $g->startHidden; $maxRepeat[$g->id] = $g->maxRepeat; $showMaxRepeats[$g->id] = $g->showMaxRepeats; } $opts->hiddenGroup = $hidden; $opts->maxRepeat = $maxRepeat; $opts->showMaxRepeats = $showMaxRepeats; // $$$ rob 26/04/2011 joomfish translations of password validation error messages // $opts->lang = FabrikWorker::getJoomfishLang(); // $$$ hugh adding these so calc element can easily find joined and repeated join groups // when it needs to add observe events ... don't ask ... LOL! $opts->join_group_ids = array(); $opts->group_repeats = array(); $opts->group_joins_ids = array(); $groups = $model->getGroupsHiarachy(); foreach ($groups as $groupModel) { if ($groupModel->getGroup()->is_join) { $joinParams = new JRegistry($groupModel->getJoinModel()->getJoin()->params); $opts->group_pk_ids[$groupModel->getGroup()->id] = FabrikString::safeColNameToArrayKey($joinParams->get('pk')); $opts->join_group_ids[$groupModel->getGroup()->join_id] = (int) $groupModel->getGroup()->id; $opts->group_join_ids[$groupModel->getGroup()->id] = (int) $groupModel->getGroup()->join_id; $opts->group_repeats[$groupModel->getGroup()->id] = $groupModel->canRepeat(); $opts->group_copy_element_values[$groupModel->getGroup()->id] = $groupModel->canCopyElementValues(); } } $opts = json_encode($opts); if (!FabrikHelperHTML::inAjaxLoadedPage()) { JText::script('COM_FABRIK_VALIDATING'); JText::script('COM_FABRIK_SUCCESS'); JText::script('COM_FABRIK_NO_REPEAT_GROUP_DATA'); JText::script('COM_FABRIK_VALIDATION_ERROR'); JText::script('COM_FABRIK_FORM_SAVED'); Jtext::script('COM_FABRIK_CONFIRM_DELETE'); } // $$$ rob dont declare as var $bkey, but rather assign to window, as if loaded via ajax window the function is wrapped // inside an anoymous function, and therefore $bkey wont be available as a global var in window $script = array(); $script[] = "window.{$bkey} = new FbForm(" . $model->getId() . ", {$opts});"; $script[] = "if(typeOf(Fabrik) !== 'null') {"; $script[] = "Fabrik.addBlock('{$bkey}', {$bkey});"; $script[] = "}"; // Instantaite js objects for each element $vstr = "\n"; $groups = $model->getGroupsHiarachy(); $script[] = "{$bkey}.addElements({"; $gs = array(); foreach ($groups as $groupModel) { $showGroup = $groupModel->getParams()->get('repeat_group_show_first'); if ($showGroup == -1 || $showGroup == 2 && $model->isEditable()) { // $$$ rob unpublished group so dont include the element js continue; } $aObjs = array(); $elementModels = $groupModel->getPublishedElements(); // $$$ rob if repeatTotal is 0 we still want to add the js objects as the els are only hidden $max = $groupModel->repeatTotal > 0 ? $groupModel->repeatTotal : 1; foreach ($elementModels as $elementModel) { $element = $elementModel->getElement(); if ($element->published == 0) { continue; } $fullName = $elementModel->getFullName(); $id = $elementModel->getHTMLId(); $elementModel->setEditable($model->isEditable()); // If the view is a form then we should always add the js as long as the element is editable or viewable // if the view is details then we should only add hte js if the element is viewable. if ($elementModel->canUse() && $model->isEditable() || $elementModel->canView()) { for ($c = 0; $c < $max; $c++) { // $$$ rob ensure that some js code has been returned otherwise dont add empty data to array $ref = trim($elementModel->elementJavascript($c)); if ($ref !== '') { $aObjs[] = $ref; } $validations = $elementModel->getValidations(); if (!empty($validations) && $elementModel->isEditable()) { $watchElements = $elementModel->getValidationWatchElements($c); foreach ($watchElements as $watchElement) { $vstr .= "{$bkey}.watchValidation('" . $watchElement['id'] . "', '" . $watchElement['triggerEvent'] . "');\n"; } } } } } $gs[] = $groupModel->getGroup()->id . ':[' . implode(",\n", $aObjs) . ']'; } $script[] = implode(", ", $gs); $script[] = '});'; $script[] = $actions; $script[] = $vstr; // Placholder test $script[] = "new Form.Placeholder('.fabrikForm input');"; $script[] = "function submit_form() {"; if (!empty($aWYSIWYGNames)) { jimport('joomla.html.editor'); $editor = JFactory::getEditor(); $script[] = $editor->save('label'); foreach ($aWYSIWYGNames as $parsedName) { $script[] = $editor->save($parsedName); } } $script[] = "\treturn false;"; $script[] = "}"; $script[] = "function submitbutton(button) {"; $script[] = "\tif (button==\"cancel\") {"; $script[] = "\t\tdocument.location = '" . JRoute::_('index.php?option=com_fabrik&task=viewTable&cid=' . $tableId) . "';"; $script[] = "\t}"; $script[] = "\tif (button == \"cancelShowForm\") {"; $script[] = "\t\treturn false;"; $script[] = "\t}"; $script[] = "}"; if (FabrikHelperHTML::inAjaxLoadedPage()) { $tipOpts = FabrikHelperHTML::tipOpts(); $script[] = "new FloatingTips('#" . $bkey . " .fabrikTip', " . json_encode($tipOpts) . ");"; } $pluginManager = FabrikWorker::getPluginManager(); $res = $pluginManager->runPlugins('onJSReady', $model); if (in_array(false, $res)) { return false; } $str = implode("\n", $script); $model->getCustomJsAction($srcs); $srcs[] = 'media/com_fabrik/js/encoder.js'; FabrikHelperHTML::script($srcs, $str); $pluginManager->runPlugins('onAfterJSLoad', $model); }
/** * Get the link options * * @return array */ protected function linkOpts() { $params = $this->getParams(); $target = $params->get('link_target_options', 'default'); $opts = array(); $opts['rel'] = $params->get('rel', ''); switch ($target) { default: $opts['target'] = $target; break; case 'default': break; case 'lightbox': FabrikHelperHTML::slimbox(); $opts['rel'] = 'lightbox[]'; break; } return $opts; }
function getManagementJS($data = array()) { global $Itemid; $app =& JFactory::getApplication(); $model =& $this->getModel(); $table =& $model->getTable(); FabrikHelperHTML::packageJS(); $document =& JFactory::getDocument(); FabrikHelperHTML::slimbox(); FabrikHelperHTML::mocha(); FabrikHelperHTML::script('table.js', 'media/com_fabrik/js/', true); $tmpl = JRequest::getVar('layout', $table->template); // check for a custom css file and include it if it exists $ab_css_file = JPATH_SITE . DS . "components" . DS . "com_fabrik" . DS . "views" . DS . "table" . DS . "tmpl" . DS . $tmpl . DS . "template.css"; if (file_exists($ab_css_file)) { JHTML::stylesheet('template.css', 'components/com_fabrik/views/table/tmpl/' . $tmpl . '/'); } // check for a custom js file and include it if it exists $aJsPath = JPATH_SITE . DS . "components" . DS . "com_fabrik" . DS . "views" . DS . "table" . DS . "tmpl" . DS . $tmpl . DS . "javascript.js"; if (file_exists($aJsPath)) { FabrikHelperHTML::script("javascript.js", 'components/com_fabrik/views/table/tmpl/' . $tmpl . '/', true); } // temporarily set data to load requierd info for js templates $origRows = $this->rows; $this->rows = array(array()); $tmpItemid = !isset($Itemid) ? 0 : $Itemid; $this->_c = 0; $this->_row = new stdClass(); $script = ''; static $tableini; if (!$tableini) { $tableini = true; $script .= "var oTables = \$H();\n"; } $opts = new stdClass(); $opts->admin = $app->isAdmin(); $opts->postMethod = $model->getPostMethod(); $opts->filterMethod = $this->filter_action; $opts->form = 'tableform_' . $model->getId(); $opts->headings = $model->_jsonHeadings(); $opts->labels = $this->headings; $opts->primaryKey = $table->db_primary_key; $opts->data = $data; $opts->Itemid = $tmpItemid; $opts->formid = $model->_oForm->getId(); $opts->canEdit = $model->canEdit() ? "1" : "0"; $opts->canView = $model->canView() ? "1" : "0"; $opts->page = JRoute::_('index.php'); $opts->mooversion = FabrikWorker::getMooVersion() == 1 ? 1.2 : 1.1; $opts = json_encode($opts); $lang = new stdClass(); $lang->select_rows = JText::_('SELECT SOME ROWS FOR DELETION'); $lang = json_encode($lang); $script .= "\n" . "var oTable = new fabrikTable(" . $model->getId() . ","; $script .= $opts . "," . $lang; $script .= "\n" . ");"; $script .= "\n" . "oTable.addListenTo('form_" . $model->_oForm->getId() . "');"; $script .= "\n" . "oTable.addListenTo('table_" . $model->getId() . "');"; $script .= "\n" . "oPackage.addBlock('table_" . $model->getId() . "', oTable);"; //add in plugin objects $plugins = $this->get('PluginJsObjects'); $script .= "\noTable{$model->_id}.addPlugins([\n"; $script .= " " . implode(",\n ", $plugins); $script .= "]\n);\n"; $script .= "oTables.set({$model->_id}, oTable);\n"; FabrikHelperHTML::addScriptDeclaration($script); //reset data back to original settings $this->rows = $origRows; }
function display($tmpl = 'default') { FabrikHelperHTML::slimbox(); $document =& JFactory::getDocument(); FabrikHelperHTML::packageJS(); $usersConfig =& JComponentHelper::getParams('com_fabrik'); $model =& $this->getModel(); $model->setId(JRequest::getVar('id', $usersConfig->get('visualizationid', JRequest::getInt('visualizationid', 0)))); $this->row =& $model->getVisualization(); $model->setTableIds(); $js = $model->getJs(); $model->getCustomJsAction(); $this->txt = $model->getText(); $this->params =& $model->getParams(); $params =& $model->getPluginParams(); $this->assignRef('params', $params); $tmpl = $params->get('fb_gm_layout', $tmpl); $tmplpath = COM_FABRIK_FRONTEND . DS . 'plugins' . DS . 'visualization' . DS . 'googlemap' . DS . 'views' . DS . 'googlemap' . DS . 'tmpl' . DS . $tmpl; FabrikHelperHTML::script('table.js', 'media/com_fabrik/js/', true); FabrikHelperHTML::script('Event.Delegation.js', 'media/com_fabrik/js/', true); if ($params->get('fb_gm_center') == 'userslocation') { $document->addScript('http://code.google.com/apis/gears/gears_init.js'); FabrikHelperHTML::script('geo.js', 'components/com_fabrik/libs/geo-location/'); } $this->get('PluginJsClasses'); $tableplugins = "window.addEvent('domready', function(){\n" . $this->get('PluginJsObjects') . "\n});"; FabrikHelperHTML::addScriptDeclaration($tableplugins); JHTML::stylesheet('table.css', 'media/com_fabrik/css/'); global $ispda; if ($ispda == 1) { //pdabot $template = 'static'; $this->assign('staticmap', $this->get('StaticMap')); } else { //$src = "http://maps.google.com/maps/api/js?sensor=".$params->get('fb_gm_sensor', 'false'); $uri = JURI::getInstance(); $src = $uri->getScheme() . "://maps.google.com/maps/api/js?sensor=" . $params->get('fb_gm_sensor', 'false'); $document->addScript($src); FabrikHelperHTML::script('googlemap.js', 'components/com_fabrik/plugins/visualization/googlemap/', true); if ($this->params->get('fb_gm_clustering') == 1) { $document->addScript('http://google-maps-utility-library-v3.googlecode.com/svn/tags/markermanager/1.0/src/markermanager.js'); } else { if ($this->params->get('fb_gm_clustering') == 2) { //$document->addScript('http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer_compiled.js'); FabrikHelperHTML::script('markerclusterer_packed.js', 'components/com_fabrik/libs/googlemaps/markerclustererplus/src/', true); } else { //doesnt work in v3 //FabrikHelperHTML::script('markermanager.js', 'components/com_fabrik/libs/googlemaps/', true); } } FabrikHelperHTML::addScriptDeclaration($js); $ab_css_file = $tmplpath . DS . 'template.css'; if (JFile::exists($ab_css_file)) { JHTML::stylesheet('template.css', 'components/com_fabrik/plugins/visualization/googlemap/views/googlemap/tmpl/' . $tmpl . '/', true); } $template = null; } //check and add a general fabrik custom css file overrides template css and generic table css FabrikHelperHTML::stylesheetFromPath("media" . DS . "com_fabrik" . DS . "css" . DS . "custom.css"); //check and add a specific viz template css file overrides template css generic table css and generic custom css FabrikHelperHTML::stylesheetFromPath("components" . DS . "com_fabrik" . DS . "plugins" . DS . "visualization" . DS . "googlemap" . DS . "views" . DS . "googlemap" . DS . "tmpl" . DS . $tmpl . DS . "custom.css"); $this->assignRef('filters', $this->get('Filters')); $this->assign('showFilters', JRequest::getInt('showfilters', 1) === 1 ? 1 : 0); $this->assign('filterFormURL', $this->get('FilterFormURL')); $this->assign('sidebarPosition', $params->get('fb_gm_use_overlays_sidebar')); //if ((int)$params->get('fb_gm_use_overlays', 0) === 1 && (int)$params->get('fb_gm_use_overlays_sidebar', 0) > 0) { if ($this->get('ShowSideBar')) { $this->assign('showSidebar', 1); $this->assign('overlayUrls', $params->get('fb_gm_overlay_urls', array(), '_default', 'array')); $this->assign('overlayLabels', $params->get('fb_gm_overlay_labels', array(), '_default', 'array')); } else { $this->assign('showSidebar', 0); } $this->_setPath('template', $tmplpath); $this->assign('containerId', $this->get('ContainerId')); $this->assignRef('grouptemplates', $this->get('GroupTemplates')); //ensure we don't have an incorrect version of mootools loaded FabrikHelperHTML::cleanMootools(); echo parent::display(); }
/** * Get JS objects * * @param array $data list data * * @return void */ protected function getManagementJS($data = array()) { $input = $this->app->input; $itemId = FabrikWorker::itemId(); /** @var FabrikFEModelList $model */ $model = $this->getModel(); $params = $model->getParams(); $item = $model->getTable(); $listRef = $model->getRenderContext(); $listId = $model->getId(); $formModel = $model->getFormModel(); $elementsNotInTable = $formModel->getElementsNotInTable(); $toggleCols = (bool) $params->get('toggle_cols', false); $ajax = (int) $model->isAjax(); $ajaxLinks = (bool) $params->get('list_ajax_links', $ajax); $opts = new stdClass(); $pluginManager = FabrikWorker::getPluginManager(); if ($ajaxLinks) { $modalTitle = 'test'; $modalOpts = array('content' => '', 'id' => 'ajax_links', 'title' => JText::_($modalTitle), 'modal' => false, 'expandable' => true); FabrikHelperHTML::jLayoutJs('ajax_links', 'fabrik-modal', (object) $modalOpts); } // Advanced search if ($params->get('advanced-filter')) { $modalOpts = array('content' => '', 'id' => 'advanced-filter', 'title' => JText::_('COM_FABRIK_FIELD_ADVANCED_SEARCH_LABEL'), 'modal' => false, 'expandable' => true); FabrikHelperHTML::jLayoutJs('advanced-filter', 'fabrik-modal', (object) $modalOpts); } FabrikHelperHTML::jLayoutJs('modal-state-label', 'list.fabrik-filters-modal-state-label', $layoutData = (object) array('label' => '', 'displayValue' => '', 'key' => '')); $this->csvJS($opts, $model); if ($model->requiresSlimbox()) { FabrikHelperHTML::slimbox(); } if ($model->requiresSlideshow()) { FabrikHelperHTML::slideshow(); } $src = FabrikHelperHTML::framework(); $shim = array(); $dep = new stdClass(); $dep->deps = array(); $shim['fab/list'] = $dep; $src['FbList'] = FabrikHelperHTML::mediaFile('list.js'); $src['FbListFilter'] = FabrikHelperHTML::mediaFile('listfilter.js'); $src['ListPlugin'] = FabrikHelperHTML::mediaFile('list-plugin.js'); $src = $model->getPluginJsClasses($src, $shim); $pluginManager->runPlugins('loadJavascriptClassName', $model, 'list'); $pluginManager->data = array_filter($pluginManager->data, function ($v) { return $v !== ''; }); $model->getCustomJsAction($src); $tmpl = $model->getTmpl(); $this->tmpl = $tmpl; $model->getListCss(); // Check for a custom js file and include it if it exists $aJsPath = JPATH_SITE . '/components/com_fabrik/views/list/tmpl/' . $tmpl . '/javascript.js'; if (JFile::exists($aJsPath)) { $src['CustomJs'] = 'components/com_fabrik/views/list/tmpl/' . $tmpl . '/javascript.js'; } $origRows = $this->rows; $this->rows = array(array()); $tmpItemid = !isset($itemId) ? 0 : $itemId; $this->_row = new stdClass(); $script = array(); $params = $model->getParams(); $opts->admin = $this->app->isAdmin(); $opts->ajax = $ajax; $opts->ajax_links = $ajaxLinks; $opts->links = array('detail' => $params->get('detailurl', ''), 'edit' => $params->get('editurl', ''), 'add' => $params->get('addurl', '')); $opts->filterMethod = $this->filter_action; $opts->advancedFilters = $model->getAdvancedFilterValues(); $opts->resetFilters = (bool) FabrikWorker::getMenuOrRequestVar('resetfilters', 0, false, 'request'); $opts->form = 'listform_' . $listRef; $this->listref = $listRef; $opts->headings = $model->jsonHeadings(); $labels = $this->headings; foreach ($labels as &$l) { $l = strip_tags($l); } $opts->labels = $labels; $opts->primaryKey = $item->db_primary_key; $opts->Itemid = $tmpItemid; $opts->listRef = $listRef; $opts->formid = $model->getFormModel()->getId(); $opts->canEdit = $model->canEdit() ? '1' : '0'; $opts->canView = $model->canView() ? '1' : '0'; $opts->page = JRoute::_('index.php'); $opts->isGrouped = $this->isGrouped; $opts->toggleCols = $toggleCols; $opts->j3 = FabrikWorker::j3(); $opts->singleOrdering = (bool) $model->singleOrdering(); // Reset data back to original settings $this->rows = $origRows; $formEls = array(); foreach ($elementsNotInTable as $tmpElement) { $oo = new stdClass(); $oo->name = $tmpElement->name; $oo->label = $tmpElement->label; $formEls[] = $oo; } $opts->formels = $formEls; $opts->fabrik_show_in_list = $input->get('fabrik_show_in_list', array(), 'array'); $opts->popup_width = $params->get('popup_width', ''); $opts->popup_height = $params->get('popup_height', ''); $xOffset = $params->get('popup_offset_x', ''); $yOffset = $params->get('popup_offset_y', ''); if ($xOffset !== '') { $opts->popup_offset_x = (int) $xOffset; } if ($yOffset !== '') { $opts->popup_offset_y = (int) $yOffset; } /** * Added the $nodata object as we now weed something to pass in just to keep editLabel * and viewLabel happy, after adding placeholder replacement to the labels for a Pro user, * because the tooltips said we did that, which we never actually did. * * http://fabrikar.com/forums/index.php?threads/placeholders-in-list-links-and-labels.37726/#post-191081 * * However, this means that using placeholders will yield funky labels for the popups, as * this isn't per row. So we may need to not use editLabel / viewLabel here any more, * and just use the default COM_FABRIK_VIEW/EDIT. Or add YAFO's, ::sigh::. * * But for now, it's too corner case to worry about! */ $nodata = new stdClass(); $opts->popup_edit_label = $model->editLabel($nodata); $opts->popup_view_label = $model->viewLabel($nodata); $opts->popup_add_label = $model->addLabel(); $opts->limitLength = $model->limitLength; $opts->limitStart = $model->limitStart; $opts->tmpl = $tmpl; $opts->data = $data; $opts->groupByOpts = new stdClass(); $opts->groupByOpts->isGrouped = (bool) $this->isGrouped; $opts->groupByOpts->collapseOthers = (bool) $params->get('group_by_collapse_others', false); $opts->groupByOpts->startCollapsed = (bool) $params->get('group_by_start_collapsed', false); $opts->groupByOpts->bootstrap = FabrikWorker::j3(); // If table data starts as empty then we need the html from the row // template otherwise we can't add a row to the table ob_start(); $this->_row = new stdClass(); $this->_row->id = ''; $this->_row->class = 'fabrik_row'; echo $this->loadTemplate('row'); $opts->itemTemplate = ob_get_contents(); ob_end_clean(); // $$$rob if you are loading a table in a window from a form db join select record option // then we want to know the id of the window so we can set its showSpinner() method $opts->winid = $input->get('winid', ''); $this->jsText(); $script[] = "window.addEvent('domready', function () {"; $script[] = "\tvar list = new FbList('{$listId}',"; $script[] = "\t" . json_encode($opts); $script[] = "\t);"; $script[] = "\tFabrik.addBlock('list_{$listRef}', list);"; // Add in plugin objects $pluginManager->runPlugins('onLoadJavascriptInstance', $model, 'list'); $aObjs = $pluginManager->data; if (!empty($aObjs)) { $script[] = "list.addPlugins([\n"; $script[] = "\t" . implode(",\n ", $aObjs); $script[] = "]);"; } // @since 3.0 inserts content before the start of the list render (currently on f3 tmpl only) $pluginManager->runPlugins('onGetContentBeforeList', $model, 'list'); $this->pluginBeforeList = $pluginManager->data; $script[] = $model->filterJs; $script[] = $this->getModel()->getElementJs($src); // End domready wrapper $script[] = '})'; $script = implode("\n", $script); FabrikHelperHTML::iniRequireJS($shim); FabrikHelperHTML::script($src, $script); }
/** * Return the javascript to create an instance of the class defined in formJavascriptClass * * @param array $args Array [0] => string table's form id to contain plugin * * @return bool */ public function onLoadJavascriptInstance($args) { FabrikHelperHTML::slimbox(); parent::onLoadJavascriptInstance($args); $opts = $this->getElementJSOptions(); $opts->renderOrder = $this->renderOrder; $opts = json_encode($opts); $this->jsInstance = "new FbListEmail({$opts})"; return true; }
/** * append the form javascript into the document head * @param int table id */ protected function _addJavascript($tableId) { $app = JFactory::getApplication(); $document = JFactory::getDocument(); $model = $this->getModel(); $aLoadedElementPlugins = array(); $jsActions = array(); $jsControllerKey = $model->_editable ? 'form_' . $model->getId() : 'details_' . $model->getId(); if (!defined('_JOS_FABRIK_FORMJS_INCLUDED')) { define('_JOS_FABRIK_FORMJS_INCLUDED', 1); FabrikHelperHTML::slimbox(); $srcs = array('media/com_fabrik/js/form.js', 'media/com_fabrik/js/element.js'); } $aWYSIWYGNames = array(); // $$$ hugh - yeat another one where if we =&, the $groups array pointer get buggered up and it // skips a group $groups = $model->getGroupsHiarachy(); foreach ($groups as $groupModel) { $elementModels = $groupModel->getPublishedElements(); foreach ($elementModels as $elementModel) { $res = $elementModel->useEditor(); if ($res !== false) { $aWYSIWYGNames[] = $res; } $eparams = $elementModel->getParams(); //load in once the element js class files // $$$ hugh - only needed getParent when we weren't saving changes to parent params to child // which we should now be doing ... and getParent() causes an extra table lookup for every child // element on the form. //$element =& $elementModel->getParent(); $element = $elementModel->getElement(); if (!in_array($element->plugin, $aLoadedElementPlugins)) { $aLoadedElementPlugins[] = $element->plugin; $elementModel->formJavascriptClass($srcs); } $eventMax = $groupModel->_repeatTotal == 0 ? 1 : $groupModel->_repeatTotal; for ($c = 0; $c < $eventMax; $c++) { $jsActions[] = $elementModel->getFormattedJSActions($jsControllerKey, $c); } } } FabrikHelperHTML::script($srcs, true); //new $actions = trim(implode("\n", $jsActions)); //end new $params = $model->getParams(); $listModel = $model->getlistModel(); $table = $listModel->getTable(); $form = $model->getForm(); FabrikHelperHTML::mocha(); $bkey = $model->_editable ? 'form_' . $model->getId() : 'details_' . $model->getId(); FabrikHelperHTML::tips('.hasTip', array(), "\$('{$bkey}')"); $key = FabrikString::safeColNameToArrayKey($table->db_primary_key); $this->get('FormCss'); $this->get('CustomJsAction'); $startJs = "head.ready(function() {\n"; $endJs = "});\n"; $start_page = isset($model->sessionModel->last_page) ? (int) $model->sessionModel->last_page : 0; if ($start_page !== 0) { $app->enqueueMessage(JText::_('COM_FABRIK_RESTARTING_MUTLIPAGE_FORM')); } else { // form submitted but fails validation - needs to go to the last page $start_page = JRequest::getInt('currentPage', 0); } $opts = new stdClass(); $opts->admin = $app->isAdmin(); $opts->ajax = $model->isAjax(); $opts->ajaxValidation = $params->get('ajax_validations'); $opts->primaryKey = $key; $opts->error = @$form->origerror; $opts->pages = $model->getPages(); $opts->plugins = array(); $opts->multipage_save = (bool) $model->saveMultiPage(); $opts->editable = $model->_editable; $opts->start_page = $start_page; $opts->inlineMessage = (bool) $this->isMambot; //$$$rob dont int this as keys may be string $opts->rowid = $model->_rowId; //3.0 needed for ajax requests $opts->listid = (int) $this->get('ListModel')->getId(); $imgs = new stdClass(); $imgs->alert = FabrikHelperHTML::image('alert.png', 'form', $this->tmpl, '', true); $imgs->action_check = FabrikHelperHTML::image('action_check.png', 'form', $this->tmpl, '', true); $imgs->ajax_loader = FabrikHelperHTML::image('ajax-loader.gif', 'form', $this->tmpl, '', true); $opts->images = $imgs; //$$$rob if you are loading a table in a window from a form db join select record option // then we want to know the id of the window so we can set its showSpinner() method $opts->fabrik_window_id = JRequest::getVar('fabrik_window_id', ''); //3.0 changed to fabrik_window_id (automatically appended by Fabrik.Window xhr request to load window data //for editing groups with joined data and an empty joined record (ie no joined records) $hidden = array(); $maxRepeat = array(); foreach ($this->groups as $g) { $hidden[$g->id] = $g->startHidden; $maxRepeat[$g->id] = $g->maxRepeat; } $opts->hiddenGroup = $hidden; $opts->maxRepeat = $maxRepeat; //$$$ rob 26/04/2011 joomfish translations of password validation error messages $opts->lang = FabrikWorker::getJoomfishLang(); $opts = json_encode($opts); $lang = new stdClass(); JText::script('COM_FABRIK_VALIDATING'); JText::script('COM_FABRIK_SUCCESS'); JText::script('COM_FABRIK_NO_REPEAT_GROUP_DATA'); JText::script('COM_FABRIK_VALIDATION_ERROR'); JText::script('COM_FABRIK_FORM_SAVED'); Jtext::script('COM_FABRIK_CONFIRM_DELETE'); //$$$ rob dont declare as var $bkey, but rather assign to window, as if loaded via ajax window the function is wrapped // inside an anoymous function, and therefore $bkey wont be available as a global var in window $str = "head.ready(function() {\r\n\t\t{$bkey} = new FbForm(" . $model->getId() . ", {$opts});\n"; //$str .= "$bkey.addListenTo('list_" . $listModel->getId() . "');\n"; //$str .= "$bkey.addListenTo('form_" . $model->getId() . "');\n"; $str .= "if(typeOf(Fabrik) !== 'null') {\n"; $str .= "Fabrik.addBlock('{$bkey}', {$bkey});\n"; $str .= "}\n\r\n\t\t});"; //instantaite js objects for each element $vstr = "\n"; $str .= "{$startJs}"; $groups =& $model->getGroupsHiarachy(); // $$$ rob in php5.2.6 (and possibly elsewhere) $groups's elements havent been updated // to contain the default value used by the element //foreach ($groups as $groupModel) { //testing this one again as Ive updated getGroupsHiarchy $str .= "{$bkey}.addElements({"; foreach ($groups as $groupModel) { $showGroup = $groupModel->getParams()->get('repeat_group_show_first'); if ($showGroup == -1 || $showGroup == 2 && $model->_editable) { // $$$ rob unpublished group so dont include the element js continue; } $aObjs = array(); $elementModels =& $groupModel->getPublishedElements(); // $$$ rob if _repeatTotal is 0 we still want to add the js objects as the els are only hidden $max = $groupModel->_repeatTotal > 0 ? $groupModel->_repeatTotal : 1; $str .= $groupModel->getGroup()->id . ":["; foreach ($elementModels as $elementModel) { $element =& $elementModel->getElement(); if ($element->published == 0) { continue; } $fullName = $elementModel->getFullName(); $id = $elementModel->getHTMLId(); $elementModel->_editable = $model->_editable; if ($elementModel->canUse() || $elementModel->canView()) { for ($c = 0; $c < $max; $c++) { // $$$ rob ensure that some js code has been returned otherwise dont add empty data to array $ref = trim($elementModel->elementJavascript($c)); if ($ref !== '') { $aObjs[] = $ref; } $validations =& $elementModel->getValidations(); if (!empty($validations) && $elementModel->_editable) { $watchElements = $elementModel->getValidationWatchElements($c); foreach ($watchElements as $watchElement) { $vstr .= "{$bkey}.watchValidation('" . $watchElement['id'] . "', '" . $watchElement['triggerEvent'] . "');\n"; } } } } } $str .= implode(",\n", $aObjs); $str .= "],"; } $str = FabrikString::rtrimword($str, ','); $str .= "});\n"; $str .= $actions; $str .= $vstr; $str .= $endJs; $str .= "function submit_form() {"; if (!empty($aWYSIWYGNames)) { jimport('joomla.html.editor'); $editor = JFactory::getEditor(); $str .= $editor->save('label'); foreach ($aWYSIWYGNames as $parsedName) { $str .= $editor->save($parsedName); } } $str .= "\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tfunction submitbutton(button) {\r\n\t\t\tif (button==\"cancel\") {\r\n\t\t\t\tdocument.location = '" . JRoute::_('index.php?option=com_fabrik&task=viewTable&cid=' . $tableId) . "';\r\n\t\t\t}\r\n\t\t\tif (button == \"cancelShowForm\") {\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}\r\n"; FabrikHelperHTML::addScriptDeclaration($str); $pluginManager = $model->getPluginManager(); $pluginManager->runPlugins('onAfterJSLoad', $model); FabrikHelperHTML::mootools(); }
function display($tmpl = 'default') { FabrikHelperHTML::framework(); FabrikHelperHTML::slimbox(); $document = JFactory::getDocument(); $usersConfig = JComponentHelper::getParams('com_fabrik'); $model = $this->getModel(); $model->setId(JRequest::getVar('id', $usersConfig->get('visualizationid', JRequest::getInt('visualizationid', 0)))); $this->row = $model->getVisualization(); $model->setListIds(); $js = $model->getJs(); $this->txt = $model->getText(); $params = $model->getParams(); $this->assign('params', $params); $tmpl = $params->get('fb_gm_layout', $tmpl); $tmplpath = JPATH_ROOT . '/plugins/fabrik_visualization/googlemap/views/googlemap/tmpl/' . $tmpl; FabrikHelperHTML::script('media/com_fabrik/js/list.js'); $uri = JURI::getInstance(); if ($params->get('fb_gm_center') == 'userslocation') { $document->addScript($uri->getScheme() . '://code.google.com/apis/gears/gears_init.js'); FabrikHelperHTML::script('components/com_fabrik/libs/geo-location/geo.js'); } $src = $this->get('PluginJsClasses'); FabrikHelperHTML::script($src); $tableplugins = "head.ready(function() {\n" . $this->get('PluginJsObjects') . "\n});"; FabrikHelperHTML::addScriptDeclaration($tableplugins); global $ispda; if ($ispda == 1) { //pdabot $template = 'static'; $this->assign('staticmap', $this->get('StaticMap')); } else { $src = $uri->getScheme() . '://maps.google.com/maps/api/js?sensor=' . $params->get('fb_gm_sensor', 'false'); $document->addScript($src); FabrikHelperHTML::script('plugins/fabrik_visualization/googlemap/googlemap.js'); if ((int) $this->params->get('fb_gm_clustering', '0') == 1) { FabrikHelperHTML::script('components/com_fabrik/libs/googlemaps/markerclusterer/src/markerclusterer.js'); //FabrikHelperHTML::script('http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer_compiled.js'); //FabrikHelperHTML::script('components/com_fabrik/libs/googlemaps/markermanager.js'); } else { //doesnt work in v3 //FabrikHelperHTML::script('components/com_fabrik/libs/googlemaps/markermanager.js'); } FabrikHelperHTML::addScriptDeclaration($js); $template = null; } FabrikHelperHTML::stylesheetFromPath('plugins/fabrik_visualization/googlemap/views/googlemap/tmpl/' . $tmpl . '/template.css'); //check and add a general fabrik custom css file overrides template css and generic table css FabrikHelperHTML::stylesheetFromPath('media/com_fabrik/css/custom.css'); //check and add a specific viz template css file overrides template css generic table css and generic custom css FabrikHelperHTML::stylesheetFromPath('plugins/fabrik_visualization/googlemap/views/googlemap/tmpl/' . $tmpl . '/custom.css'); $this->assignRef('filters', $this->get('Filters')); $this->assign('showFilters', JRequest::getInt('showfilters', $params->get('show_filters')) === 1 ? 1 : 0); $this->assign('filterFormURL', $this->get('FilterFormURL')); $this->assign('sidebarPosition', $params->get('fb_gm_use_overlays_sidebar')); if ($this->get('ShowSideBar')) { $this->assign('showSidebar', 1); $this->assign('overlayUrls', (array) $params->get('fb_gm_overlay_urls')); $this->assign('overlayLabels', (array) $params->get('fb_gm_overlay_labels')); } else { $this->assign('showSidebar', 0); } $this->_setPath('template', $tmplpath); $this->assign('containerId', $this->get('ContainerId')); $this->assignRef('grouptemplates', $this->get('GroupTemplates')); echo parent::display($template); }
protected function getManagementJS($data = array()) { $app = JFactory::getApplication(); $Itemid = $app->getMenu('site')->getActive()->id; $model = $this->getModel(); $table = $model->getTable(); FabrikHelperHTML::slimbox(); FabrikHelperHTML::mocha(); FabrikHelperHTML::script('media/com_fabrik/js/list.js', true); $tmpl = JRequest::getVar('layout', $table->template); // check for a custom css file and include it if it exists $ab_css_file = JPATH_SITE.DS."components".DS."com_fabrik".DS."views".DS."list".DS."tmpl".DS.$tmpl.DS."template.css"; if (file_exists($ab_css_file)) { JHTML::stylesheet('template.css', 'components/com_fabrik/views/table/tmpl/'.$tmpl . '/'); } // check for a custom js file and include it if it exists $aJsPath = JPATH_SITE.DS."components".DS."com_fabrik".DS."views".DS."list".DS."tmpl".DS.$tmpl.DS."javascript.js"; if (file_exists($aJsPath)) { FabrikHelperHTML::script('components/com_fabrik/views/table/tmpl/'.$tmpl . '/javascript.js', true); } // temporarily set data to load requierd info for js templates $origRows = $this->rows; $this->rows = array(array()); $tmpItemid = (!isset($Itemid)) ? 0 : $Itemid; $this->_c = 0; $this->_row = new stdClass(); $script = ''; $opts = new stdClass(); $opts->admin = $app->isAdmin(); $opts->ajax = $model->isAjax(); $opts->filterMethod = $this->filter_action; $opts->form = 'listform_' . $model->getId(); $opts->headings = $model->_jsonHeadings(); $opts->labels = $this->headings; $opts->primaryKey = $table->db_primary_key; $opts->data = $data; $opts->Itemid = $tmpItemid; $opts->formid = $model->_oForm->getId(); $opts->canEdit = $model->canEdit() ? "1" : "0"; $opts->canView = $model->canView() ? "1" : "0"; $opts->page = JRoute::_('index.php'); $opts = json_encode($opts); $lang = new stdClass(); $lang->select_rows = JText::_('COM_FABRIK_SELECT_ROWS_FOR_DELETION'); $lang = json_encode($lang); //$inpackage = $model->_inPackage ? 1 : 0; $script .= "\n" . "var list = new FbList(".$model->getId().","; $script .= $opts.",".$lang; $script .= "\n" . ");"; //$script .= "\n" . "list.addListenTo('form_".$model->_oForm->getId()."');"; //$script .= "\n" . "list.addListenTo('list_".$model->getId()."');"; $script .= "\n" . "Fabrik.addBlock('list_".$model->getId()."', list);"; //add in plugin objects $params = $model->getParams(); $activePlugins = $params->get('plugin', array(), '_default', 'array'); $pluginManager = JModel::getInstance('Pluginmanager', 'FabrikModel'); $plugins = $pluginManager->getPlugInGroup('list'); FabrikHelperHTML::addScriptDeclaration($script); //reset data back to original settings $this->rows = $origRows; }
/** * get the guess type link target property * @return string */ protected function guessLinkTarget() { $params = $this->getParams(); $target = $params->get('link_target_options', 'default'); switch ($target) { default: $str = ' target="' . $target . '"'; break; case 'default': $str = ''; break; case 'lightbox': FabrikHelperHTML::slimbox(); $str = ' rel="lightbox[]"'; break; } return $str; }
/** * 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 = 'default') { $app = JFactory::getApplication(); $input = $app->input; $j3 = FabrikWorker::j3(); $srcs = FabrikHelperHTML::framework(); FabrikHelperHTML::slimbox(); $document = JFactory::getDocument(); $usersConfig = JComponentHelper::getParams('com_fabrik'); $model = $this->getModel(); $model->setId($input->getInt('id', $usersConfig->get('visualizationid', $input->getInt('visualizationid', 0)))); $this->row = $model->getVisualization(); $js = $model->getJs(); $this->txt = $model->getText(); $params = $model->getParams(); $this->params = $params; $tpl = $j3 ? 'bootstrap' : 'default'; $tpl = $params->get('fb_gm_layout', $tpl); $tmplpath = JPATH_ROOT . '/plugins/fabrik_visualization/googlemap/views/googlemap/tmpl/' . $tpl; $srcs[] = 'media/com_fabrik/js/list-plugin.js'; $srcs[] = 'media/com_fabrik/js/listfilter.js'; $uri = JURI::getInstance(); if ($params->get('fb_gm_center') == 'userslocation') { $srcs[] = 'components/com_fabrik/libs/geo-location/geo.js'; } $model->getPluginJsClasses($srcs); global $ispda; if ($ispda == 1) { // Pdabot $template = 'static'; $this->staticmap = $model->getStaticMap(); } else { if (FabrikHelperHTML::isDebug()) { $srcs[] = 'plugins/fabrik_visualization/googlemap/googlemap.js'; } else { $srcs[] = 'plugins/fabrik_visualization/googlemap/googlemap-min.js'; } if ((int) $this->params->get('fb_gm_clustering', '0') == 1) { if (FabrikHelperHTML::isDebug()) { $srcs[] = 'components/com_fabrik/libs/googlemaps/markerclustererplus/src/markerclusterer.js'; } else { $srcs[] = 'components/com_fabrik/libs/googlemaps/markerclustererplus/src/markerclusterer_packed.js'; } } else { // Doesn't work in v3 // FabrikHelperHTML::script('components/com_fabrik/libs/googlemaps/markermanager.js'); } $template = null; } $js .= $model->getPluginJsObjects(); $js .= $model->getFilterJs(); FabrikHelperHTML::iniRequireJs($model->getShim()); FabrikHelperHTML::script($srcs, $js); FabrikHelperHTML::stylesheetFromPath('plugins/fabrik_visualization/googlemap/views/googlemap/tmpl/' . $tpl . '/template.css'); // Check and add a general fabrik custom css file overrides template css and generic table css FabrikHelperHTML::stylesheetFromPath('media/com_fabrik/css/custom.css'); // Check and add a specific viz template css file overrides template css generic table css and generic custom css FabrikHelperHTML::stylesheetFromPath('plugins/fabrik_visualization/googlemap/views/googlemap/tmpl/' . $tpl . '/custom.css'); $this->filters = $model->getFilters(); $this->showFilters = $model->showFilters(); $this->filterFormURL = $model->getFilterFormURL(); $this->sidebarPosition = $params->get('fb_gm_use_overlays_sidebar'); $this->showOverLays = (bool) $params->get('fb_gm_use_overlays'); if ($model->getShowSideBar()) { $this->showSidebar = 1; $this->overlayUrls = (array) $params->get('fb_gm_overlay_urls'); $this->overlayLabels = (array) $params->get('fb_gm_overlay_labels'); } else { $this->showSidebar = 0; } $this->_setPath('template', $tmplpath); $this->containerId = $model->getContainerId(); $this->groupTemplates = $model->getGroupTemplates(); echo parent::display($template); }
/** * Get JS objects * * @param array $data list data * * @return void */ protected function getManagementJS($data = array()) { $app = JFactory::getApplication(); $input = $app->input; $Itemid = FabrikWorker::itemId(); $model = $this->getModel(); $params = $model->getParams(); $item = $model->getTable(); $listref = $model->getRenderContext(); $listid = $model->getId(); $formModel = $model->getFormModel(); $elementsNotInTable = $formModel->getElementsNotInTable(); $toggleCols = (bool) $params->get('toggle_cols', false); if ($model->requiresSlimbox()) { FabrikHelperHTML::slimbox(); } if ($model->requiresSlideshow()) { FabrikHelperHTML::slideshow(); } $src = FabrikHelperHTML::framework(); $shim = array(); $dep = new stdClass(); $dep->deps = array('fab/fabrik', 'fab/listfilter', 'fab/advanced-search', 'fab/encoder'); if ($toggleCols) { $dep->deps[] = 'fab/list-toggle'; } $shim['fab/list'] = $dep; $src = $model->getPluginJsClasses($src, $shim); FabrikHelperHTML::addToFrameWork($src, 'media/com_fabrik/js/list'); $model->getCustomJsAction($src); $tmpl = $model->getTmpl(); $this->tmpl = $tmpl; $model->getListCss(); // Check for a custom js file and include it if it exists $aJsPath = JPATH_SITE . '/components/com_fabrik/views/list/tmpl/' . $tmpl . '/javascript.js'; if (JFile::exists($aJsPath)) { $src[] = 'components/com_fabrik/views/list/tmpl/' . $tmpl . '/javascript.js'; } $origRows = $this->rows; $this->rows = array(array()); $tmpItemid = !isset($Itemid) ? 0 : $Itemid; $this->_row = new stdClass(); $script = array(); $params = $model->getParams(); $opts = new stdClass(); $opts->admin = $app->isAdmin(); $opts->ajax = (int) $model->isAjax(); $opts->ajax_links = (bool) $params->get('list_ajax_links', $opts->ajax); $opts->links = array('detail' => $params->get('detailurl', ''), 'edit' => $params->get('editurl', ''), 'add' => $params->get('addurl', '')); $opts->filterMethod = $this->filter_action; $opts->advancedFilters = $model->getAdvancedFilterValues(); $opts->form = 'listform_' . $listref; $this->listref = $listref; $opts->headings = $model->jsonHeadings(); $labels = $this->headings; foreach ($labels as &$l) { $l = strip_tags($l); } $opts->labels = $labels; $opts->primaryKey = $item->db_primary_key; $opts->Itemid = $tmpItemid; $opts->listRef = $listref; $opts->formid = $model->getFormModel()->getId(); $opts->canEdit = $model->canEdit() ? "1" : "0"; $opts->canView = $model->canView() ? "1" : "0"; $opts->page = JRoute::_('index.php'); $opts->isGrouped = $this->isGrouped; $opts->toggleCols = $toggleCols; $opts->j3 = FabrikWorker::j3(); $opts->singleOrdering = (bool) $model->singleOrdering(); $formEls = array(); foreach ($elementsNotInTable as $tmpElement) { $oo = new stdClass(); $oo->name = $tmpElement->name; $oo->label = $tmpElement->label; $formEls[] = $oo; } $opts->formels = $formEls; $opts->fabrik_show_in_list = $input->get('fabrik_show_in_list', array(), 'array'); $opts->csvChoose = (bool) $params->get('csv_frontend_selection'); $opts->popup_width = $params->get('popup_width', ''); $opts->popup_height = $params->get('popup_height', ''); $xOffset = $params->get('popup_offset_x', ''); $yOffset = $params->get('popup_offset_y', ''); if ($xOffset !== '') { $opts->popup_offset_x = (int) $xOffset; } if ($yOffset !== '') { $opts->popup_offset_y = (int) $yOffset; } $opts->popup_edit_label = $model->editLabel(); $opts->popup_view_label = $model->viewLabel(); $opts->popup_add_label = $model->addLabel(); $opts->limitLength = $model->limitLength; $opts->limitStart = $model->limitStart; $opts->tmpl = $tmpl; $csvOpts = new stdClass(); $csvOpts->excel = (int) $params->get('csv_format'); $csvOpts->inctabledata = (int) $params->get('csv_include_data'); $csvOpts->incraw = (int) $params->get('csv_include_raw_data'); $csvOpts->inccalcs = (int) $params->get('csv_include_calculations'); $csvOpts->custom_qs = $params->get('csv_custom_qs', ''); $opts->csvOpts = $csvOpts; $opts->csvFields = $model->getCsvFields(); $csvOpts->incfilters = (int) $params->get('incfilters'); $opts->data = $data; $opts->groupByOpts = new stdClass(); $opts->groupByOpts->isGrouped = (bool) $this->isGrouped; $opts->groupByOpts->collapseOthers = (bool) $params->get('group_by_collapse_others', false); $opts->groupByOpts->startCollapsed = (bool) $params->get('group_by_start_collapsed', false); $opts->groupByOpts->bootstrap = FabrikWorker::j3(); // If table data starts as empty then we need the html from the row // template otherwise we can't add a row to the table ob_start(); $this->_row = new stdClass(); $this->_row->id = ''; $this->_row->class = 'fabrik_row'; echo $this->loadTemplate('row'); $opts->rowtemplate = ob_get_contents(); ob_end_clean(); // $$$rob if you are loading a table in a window from a form db join select record option // then we want to know the id of the window so we can set its showSpinner() method $opts->winid = $input->get('winid', ''); $opts = json_encode($opts); JText::script('COM_FABRIK_PREV'); JText::script('COM_FABRIK_SELECT_ROWS_FOR_DELETION'); JText::script('JYES'); JText::script('JNO'); JText::script('COM_FABRIK_SELECT_COLUMNS_TO_EXPORT'); JText::script('COM_FABRIK_INCLUDE_FILTERS'); JText::script('COM_FABRIK_INCLUDE_DATA'); JText::script('COM_FABRIK_INCLUDE_RAW_DATA'); JText::script('COM_FABRIK_INCLUDE_CALCULATIONS'); JText::script('COM_FABRIK_EXPORT'); JText::script('COM_FABRIK_START'); JText::script('COM_FABRIK_NEXT'); JText::script('COM_FABRIK_END'); JText::script('COM_FABRIK_PAGE'); JText::script('COM_FABRIK_OF'); JText::script('COM_FABRIK_LOADING'); JText::script('COM_FABRIK_RECORDS'); JText::script('COM_FABRIK_SAVING_TO'); JText::script('COM_FABRIK_CONFIRM_DROP'); JText::script('COM_FABRIK_CONFIRM_DELETE_1'); JText::script('COM_FABRIK_NO_RECORDS'); JText::script('COM_FABRIK_CSV_COMPLETE'); JText::script('COM_FABRIK_CSV_DOWNLOAD_HERE'); JText::script('COM_FABRIK_CONFIRM_DELETE'); JText::script('COM_FABRIK_CSV_DOWNLOADING'); JText::script('COM_FABRIK_FILE_TYPE'); JText::script('COM_FABRIK_ADVANCED_SEARCH'); JText::script('COM_FABRIK_FORM_FIELDS'); JText::script('COM_FABRIK_VIEW'); // Keyboard short cuts JText::script('COM_FABRIK_LIST_SHORTCUTS_ADD'); JText::script('COM_FABRIK_LIST_SHORTCUTS_EDIT'); JText::script('COM_FABRIK_LIST_SHORTCUTS_DELETE'); JText::script('COM_FABRIK_LIST_SHORTCUTS_FILTER'); $script[] = "window.addEvent('domready', function () {"; $script[] = "\tvar list = new FbList('{$listid}',"; $script[] = "\t" . $opts; $script[] = "\t);"; $script[] = "\tFabrik.addBlock('list_{$listref}', list);"; // Add in plugin objects $params = $model->getParams(); $pluginManager = FabrikWorker::getPluginManager(); $c = 0; $pluginManager->runPlugins('onLoadJavascriptInstance', $model, 'list'); $aObjs = $pluginManager->data; if (!empty($aObjs)) { $script[] = "list.addPlugins([\n"; $script[] = "\t" . implode(",\n ", $aObjs); $script[] = "]);"; } // @since 3.0 inserts content before the start of the list render (currently on f3 tmpl only) $pluginManager->runPlugins('onGetContentBeforeList', $model, 'list'); $this->pluginBeforeList = $pluginManager->data; $script[] = $model->filterJs; // Was separate but should now load in with the rest of the require js code $model = $this->getModel(); $script[] = $model->getElementJs($src); // End domready wrapper $script[] = '})'; $script = implode("\n", $script); FabrikHelperHTML::iniRequireJS($shim); FabrikHelperHTML::script($src, $script); // Reset data back to original settings $this->rows = $origRows; }
defined('_JEXEC') or die('Restricted access'); ?> <div id="tableform_19"> <div class="gallery" id="<?php echo $this->containerId; ?> "><?php echo $this->loadTemplate('filter'); ?> <?php $border = "<div style='margin-bottom:15px;clear:left;border-top:1px solid #9da4a9'></div>"; if (empty($this->images)) { echo "<div class='empty'>" . JText::_('There are no images in this gallery') . "</div>"; } else { FabrikHelperHTML::slimbox(); reset($this->images); $i = current($this->images[0]); $ratings = array(); foreach ($this->ratings as $r) { $ratings[$r->rowid]['html'] = $r->html; $ratings[$r->rowid]['id'] = $r->id; } //$t = strstr(JURI::base(), 'devplay') ? 'table_18' : 'table_19'; $t = 'table_19'; $filters = JArrayHelper::getValue($_POST, 'fabrik_filter', array()); $fvals = empty($filters) ? array() : $filters[$t]['value']; if (is_array($fvals) && !empty($fvals)) { if (@$fvals[0][0] == '' && @$fvals[0][1] == '' && @$fvals[2] == '' && @$fvals[1] == '') { $nofilter = true; } else {