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'); }
function display($tmpl = 'default') { global $Itemid; $app =& JFactory::getApplication(); JHTML::_('behavior.calendar'); require_once COM_FABRIK_FRONTEND . DS . 'helpers' . DS . 'html.php'; $pluginManager =& JModel::getInstance('Pluginmanager', 'FabrikModel'); $plugin =& $pluginManager->getPlugIn('calendar', 'visualization'); if (FabrikWorker::nativeMootools12()) { FabrikHelperHTML::script('Mootools.Lang.js', 'components/com_fabrik/libs/mootools1.2/', true); FabrikHelperHTML::script('date.js', 'components/com_fabrik/plugins/element/fabrikdate/', false); FabrikHelperHTML::addScriptDeclaration("Date.defineParsers('%d([-./]%m([-./]%Y((T| )%X)?)?)?');"); } FabrikHelperHTML::mocha(); FabrikHelperHTML::loadCalendar(); $model =& $this->getModel(); $usersConfig =& JComponentHelper::getParams('com_fabrik'); $id = JRequest::getVar('id', $usersConfig->get('visualizationid', JRequest::getInt('visualizationid', 0))); $model->setId($id); $this->row =& $model->getVisualization(); $model->setTableIds(); $this->assign('containerId', $this->get('ContainerId')); $this->assignRef('filters', $this->get('Filters')); $this->assign('showFilters', JRequest::getInt('showfilters', 1) === 1 ? 1 : 0); $this->assign('filterFormURL', $this->get('FilterFormURL')); $calendar =& $model->_row; $this->calName = $model->getCalName(); $config =& JFactory::getConfig(); $document =& JFactory::getDocument(); $canAdd = $this->get('CanAdd'); $this->assign('requiredFiltersFound', $this->get('RequiredFiltersFound')); if ($canAdd && $this->requiredFiltersFound) { $app->enqueueMessage(JText::_('COM_FABRIK_DOUBLE_CLICK_TO_ADD_EVENT')); } $this->assign('canAdd', $canAdd); //FabrikHelperHTML::mocha(); FabrikHelperHTML::packageJS(); $fbConfig =& JComponentHelper::getParams('com_fabrik'); JHTML::stylesheet('table.css', 'media/com_fabrik/css/'); FabrikHelperHTML::script('element.js', 'media/com_fabrik/js/', true); FabrikHelperHTML::script('form.js', 'media/com_fabrik/js/', true); FabrikHelperHTML::script('table.js', 'media/com_fabrik/js/', true); FabrikHelperHTML::script('calendar.js', 'components/com_fabrik/plugins/visualization/calendar/', true); $params =& $model->getParams(); //Get the active menu item $usersConfig =& JComponentHelper::getParams('com_fabrik'); $urlfilters = JRequest::get('get'); unset($urlfilters['option']); unset($urlfilters['view']); unset($urlfilters['controller']); unset($urlfilters['Itemid']); unset($urlfilters['visualizationid']); unset($urlfilters['format']); if (empty($urlfilters)) { $urlfilters = new stdClass(); } $urls = new stdClass(); //dont JRoute as its wont load with sef? $urls->del = 'index.php?option=com_fabrik&controller=visualization.calendar&view=visualization&task=deleteEvent&format=raw&Itemid=' . $Itemid . '&id=' . $id; $urls->add = 'index.php?option=com_fabrik&view=visualization&controller=visualization.calendar&format=raw&Itemid=' . $Itemid . '&id=' . $id; $user =& JFactory::getUser(); $legend = $params->get('show_calendar_legend', 0) ? $model->getLegend() : ''; $tmpl = $params->get('calendar_layout', 'default'); $pluginManager->loadJS(); $options = new stdClass(); $options->url = $urls; $options->eventTables =& $model->getEventTables(); $options->calendarId = $calendar->id; $options->popwiny = $params->get('yoffset', 0); $options->urlfilters = $urlfilters; $options->canAdd = $canAdd; $options->tmpl = $tmpl; $formView =& $this->_formView; $formView->_isMambot = true; $o = $model->getAddStandardEventFormInfo(); if ($o != null) { $options->tableid = $o->id; $formView->setId($o->form_id); $options->formid = $o->form_id; } $formModel =& $formView->getModel(); $form =& $formModel->getForm(); $options->mooversion = FabrikWorker::getMooVersion() == 1 ? 1.2 : 1.1; $model->setRequestFilters(); $options->filters =& $model->filters; // end not sure $options->Itemid = $Itemid; $options->standard_event_form = $params->get('use_standard_event_table', 0) == 1 ? true : false; $options->show_day = $params->get('show_day', true); $options->show_week = $params->get('show_week', true); $options->days = array(JText::_('Sunday'), JText::_('Monday'), JText::_('Tuesday'), JText::_('Wednesday'), JText::_('Thursday'), JText::_('Friday'), JText::_('Saturday')); $options->shortDays = array(JText::_('Sun'), JText::_('Mon'), JText::_('Tue'), JText::_('Wed'), JText::_('Thu'), JText::_('Fri'), JText::_('Sat')); $options->months = array(JText::_('January'), JText::_('February'), JText::_('March'), JText::_('April'), JText::_('May'), JText::_('June'), JText::_('July'), JText::_('August'), JText::_('September'), JText::_('October'), JText::_('November'), JText::_('December')); $options->shortMonths = array(JText::_('Jan'), JText::_('Feb'), JText::_('Mar'), JText::_('Apr'), JText::_('May'), JText::_('Jun'), JText::_('Jul'), JText::_('Aug'), JText::_('Sept'), JText::_('Oct'), JText::_('Nov'), JText::_('Dec')); $options->first_week_day = (int) $params->get('first_week_day', 0); $options->monthday = new stdClass(); $options->monthday->width = (int) $params->get('calendar-monthday-width', 90); $options->monthday->height = (int) $params->get('calendar-monthday-height', 90); $options->greyscaledweekend = $params->get('greyscaled-week-end', 0); $options->viewType = $params->get('calendar_default_view', 'month'); $json = json_encode($options); $lang = new stdClass(); $lang->next = htmlspecialchars(JText::_('Next')); $lang->previous = JText::_('Previous'); $lang->day = JText::_('Day'); $lang->week = JText::_('Week'); $lang->month = JText::_('Month'); $lang->key = htmlspecialchars(JText::_('Key')); $lang->today = JText::_('Today'); $lang->start = JText::_('Start'); $lang->end = JText::_('End'); $lang->deleteConf = JText::_('Are you sure you want to delete this?'); $lang->del = JText::_('delete'); $lang->view = JText::_('view'); $lang->edit = JText::_('edit'); $lang->windowtitle = JText::_('add/edit event'); $lang = json_encode($lang); //$$$ rob - was assigning 'calendar_x' to oPackage.blocks, // but now assigning as 'visualization_x' to enable filter clear link $str = "window.addEvent('domready', function(e) {\n" . " //var m = new MochaUI.Modal();\n" . " {$this->calName} = new fabrikCalendar('calendar_{$calendar->id}');\n" . " {$this->calName}.render({}, {$json}, {$lang});\n" . " oPackage.addBlock('vizualization_" . $calendar->id . "', {$this->calName});\n"; if ($o != null) { $str .= " {$this->calName}.addListenTo('form_{$o->form_id}');\n"; } $fids =& $model->getLinkedFormIds(); foreach ($fids as $fid) { $str .= " {$this->calName}.addListenTo('form_{$fid}');\n"; } $str .= $legend . "\n});\n"; FabrikHelperHTML::addScriptDeclaration($str); $viewName = $this->getName(); $pluginParams =& $model->getPluginParams(); $this->assignRef('params', $pluginParams); $tmpl = $pluginParams->get('calendar_layout', $tmpl); $tmplpath = COM_FABRIK_FRONTEND . DS . 'plugins' . DS . 'visualization' . DS . 'calendar' . DS . 'views' . DS . 'calendar' . DS . 'tmpl' . DS . $tmpl; $this->_setPath('template', $tmplpath); $ab_css_file = $tmplpath . DS . "template.css"; if (JFile::exists($ab_css_file)) { JHTML::stylesheet('template.css', 'components/com_fabrik/plugins/visualization/calendar/views/calendar/tmpl/' . $tmpl . '/', true); } //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 biz template css file overrides template css generic table css and generic custom css FabrikHelperHTML::stylesheetFromPath("components" . DS . "com_fabrik" . DS . "plugins" . DS . "visualization" . DS . "calendar" . DS . "views" . DS . "calendar" . DS . "tmpl" . DS . $tmpl . DS . "custom.css"); //ensure we don't have an incorrect version of mootools loaded FabrikHelperHTML::cleanMootools(); echo parent::display(); }
/** * get the version of mootools to be used * -1 = none * 0 = v1.1 * 1 = v1.2 * @return unknown_type */ public function getMooVersion() { if (FabrikWorker::nativeMootools12()) { return 1; } else { $fbConfig =& JComponentHelper::getParams('com_fabrik'); return $fbConfig->get('usefabrik_mootools', 1); } }
function slimbox() { $mooversion = FabrikWorker::getMooVersion(); $fbConfig =& JComponentHelper::getParams('com_fabrik'); if ($fbConfig->get('include_lightbox_js', 1) == 0) { return; } if ($fbConfig->get('use_mediabox', false) && FabrikWorker::nativeMootools12()) { // $$$ hugh - 4/24/2011 - upgraded Mediabox to (almost) latest, needs Moo >= 1.2.4 // So only include latest (mediaboxAdv) if Moo Upgrade $folder = 'components/com_fabrik/libs/mediabox_advanced/'; JHTML::stylesheet('mediaboxAdvBlack.css', $folder . 'css/'); FabrikHelperHTML::script('mediaboxAdv.js', $folder, true); } else { if ($fbConfig->get('use_mediabox', false) && $mooversion == 1) { $folder = 'components/com_fabrik/libs/mediabox/'; JHTML::stylesheet('mediabox.css', $folder . 'css/'); FabrikHelperHTML::script('mediabox.js', $folder, true); } else { if ($mooversion == 1) { //$folder = 'components/com_fabrik/libs/slimbox1.64/js/'; $folder = 'components/com_fabrik/libs/slimbox1.71a/'; $folder .= JDEBUG ? 'src/' : 'js/'; JHTML::stylesheet('slimbox.css', 'components/com_fabrik/libs/slimbox1.71a/css/'); } else { JHTML::stylesheet('slimbox.css', 'components/com_fabrik/css/slimbox/'); $folder = 'components/com_fabrik/libs/'; } FabrikHelperHTML::script('slimbox.js', $folder, true); } } }
/** *create the js code to observe the elements js actions * @param array all javascript events for the form key'd on element id * @param string either form_ or _details * @param int repeat counter * @return string js events */ function getFormattedJSActions($allJsActions, $jsControllerKey, $repeatCount) { $jsStr = ''; // $$$ 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 =& $this->getParent(); if (FabrikWorker::nativeMootools12() == true || FabrikWorker::getMooVersion() == 1) { $jsControllerKey = "oPackage.blocks['" . $jsControllerKey . "']"; } else { $jsControllerKey = "oPackage.blocks.get('" . $jsControllerKey . "')"; } $element =& $this->getElement(); $form =& $this->_form->getForm(); $w = new FabrikWorker(); if (array_key_exists($element->id, $allJsActions)) { $fxadded = array(); $elId = $this->getHTMLId($repeatCount); foreach ($allJsActions[$element->id] as $jsAct) { $js = addslashes($jsAct->code); $js = str_replace(array("\n", "\r"), "", $js); if ($jsAct->action == 'load') { $js = preg_replace('#\\bthis\\b#', "\$(\\'{$elId}\\')", $js); } if ($jsAct->action != '' && $js !== '') { $jsStr .= $jsControllerKey . ".dispatchEvent('{$element->plugin}', '{$elId}', '{$jsAct->action}', '{$js}');\n"; } //build wysiwyg code if ($jsAct->js_e_event != '') { // $$$ rob get the correct element id based on the repeat counter $triggerEl = $this->getForm()->getElement(str_replace('fabrik_trigger_element_', '', $jsAct->js_e_trigger)); if (is_object($triggerEl)) { $triggerid = 'element_' . $triggerEl->getHTMLId($repeatCount); } else { $triggerid = $jsAct->js_e_trigger; } if (!array_key_exists($jsAct->js_e_trigger, $fxadded)) { $jsStr .= $jsControllerKey . ".addElementFX('{$triggerid}', '{$jsAct->js_e_event}');\n"; $fxadded[$jsAct->js_e_trigger] = true; } $jsAct->js_e_value = $w->parseMessageForPlaceHolder($jsAct->js_e_value, JRequest::get('post')); $js = 'var v = $type(this) == "element" ? this.get("value") : this.getValue();'; $js .= "if(v {$jsAct->js_e_condition} '{$jsAct->js_e_value}') {"; $js .= $jsControllerKey . ".doElementFX('{$triggerid}', '{$jsAct->js_e_event}')"; $js .= "}"; $js = addslashes($js); $js = str_replace(array("\n", "\r"), "", $js); $jsStr .= $jsControllerKey . ".dispatchEvent('{$element->plugin}', '{$elId}', '{$jsAct->action}', '{$js}');\n"; } } } return $jsStr; }
/** * load the javascript class that manages interaction with the form element * should only be called once * @return string javascript class file */ function formJavascriptClass() { if (FabrikWorker::nativeMootools12()) { FabrikHelperHTML::script('Mootools.Lang.js', 'components/com_fabrik/libs/mootools1.2/', true); FabrikHelperHTML::script('date.js', 'components/com_fabrik/plugins/element/fabrikdate/', false); FabrikHelperHTML::addScriptDeclaration("Date.defineParsers('%d([-./]%m([-./]%Y((T| )%X)?)?)?');"); } FabrikHelperHTML::script('javascript.js', 'components/com_fabrik/plugins/element/fabrikdate/', false); }