Ejemplo n.º 1
0
 function display($tmpl = 'default')
 {
     JHTML::_('behavior.calendar');
     FabrikHelperHTML::script('media/com_fabrik/js/list.js', true);
     require_once COM_FABRIK_FRONTEND . DS . 'helpers' . DS . 'html.php';
     FabrikHelperHTML::mocha();
     FabrikHelperHTML::loadCalendar();
     $model =& $this->getModel();
     $usersConfig = JComponentHelper::getParams('com_fabrik');
     $model->setId(JRequest::getVar('id', $usersConfig->get('visualizationid', JRequest::getInt('visualizationid', 0))));
     $this->row =& $model->getVisualization();
     $model->setListIds();
     if ($this->row->published == 0) {
         JError::raiseWarning(500, JText::_('ALERTNOTAUTH'));
         return '';
     }
     $calendar =& $model->_row;
     $this->media = $model->getMedia();
     $viewName = $this->getName();
     $pluginManager =& JModel::getInstance('Pluginmanager', 'FabrikFEModel');
     $plugin =& $pluginManager->getPlugIn('calendar', 'visualization');
     $this->assign('containerId', $this->get('ContainerId'));
     $this->assign('showFilters', JRequest::getInt('showfilters', 1) === 1 ? 1 : 0);
     $this->assignRef('filters', $this->get('Filters'));
     $pluginParams =& $model->getPluginParams();
     $tmpl = $pluginParams->get('media_layout', $tmpl);
     $tmplpath = JPATH_ROOT . DS . 'plugins' . DS . 'fabrik_visualization' . DS . 'media' . DS . 'views' . DS . 'media' . DS . 'tmpl' . DS . $tmpl;
     $this->_setPath('template', $tmplpath);
     $ab_css_file = $tmplpath . DS . "template.css";
     if (JFile::exists($ab_css_file)) {
         JHTML::stylesheet('plugins/fabrik_visualization/media/views/media/tmpl/' . $tmpl . '/template.css');
     }
     echo parent::display();
 }
Ejemplo n.º 2
0
 function display($tmpl = 'default')
 {
     JHTML::_('behavior.calendar');
     require_once COM_FABRIK_FRONTEND . DS . 'helpers' . DS . 'html.php';
     FabrikHelperHTML::mocha();
     FabrikHelperHTML::loadCalendar();
     $model =& $this->getModel();
     $usersConfig =& JComponentHelper::getParams('com_fabrik');
     $model->setId(JRequest::getVar('id', $usersConfig->get('visualizationid', JRequest::getInt('visualizationid', 0))));
     echo $model->getEvents();
 }
Ejemplo n.º 3
0
 function display($tmpl = 'default')
 {
     JHTML::_('behavior.calendar');
     FabrikHelperHTML::packageJS();
     FabrikHelperHTML::script('table.js', 'media/com_fabrik/js/');
     FabrikHelperHTML::script('advanced-search.js', 'media/com_fabrik/js/');
     require_once COM_FABRIK_FRONTEND . DS . 'helpers' . DS . 'html.php';
     FabrikHelperHTML::mocha();
     FabrikHelperHTML::loadCalendar();
     $model =& $this->getModel();
     $usersConfig =& JComponentHelper::getParams('com_fabrik');
     $model->setId(JRequest::getVar('id', $usersConfig->get('visualizationid', JRequest::getInt('visualizationid', 0))));
     $this->row =& $model->getVisualization();
     $model->setTableIds();
     if ($this->row->state == 0) {
         JError::raiseWarning(500, JText::_('ALERTNOTAUTH'));
         return '';
     }
     $calendar =& $model->_row;
     $this->assign('requiredFiltersFound', $this->get('RequiredFiltersFound'));
     if ($this->requiredFiltersFound) {
         $this->assign('chart', $this->get('Chart'));
     } else {
         $this->assign('chart', '');
     }
     $viewName = $this->getName();
     $pluginManager =& JModel::getInstance('Pluginmanager', 'FabrikModel');
     $plugin =& $pluginManager->getPlugIn('calendar', 'visualization');
     $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'));
     $pluginParams =& $model->getPluginParams();
     $this->assignRef('params', $pluginParams);
     JHTML::stylesheet('table.css', 'media/com_fabrik/css/');
     $tmpl = $pluginParams->get('chart_layout', $tmpl);
     $tmplpath = COM_FABRIK_FRONTEND . DS . 'plugins' . DS . 'visualization' . DS . 'chart' . DS . 'views' . DS . 'chart' . 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/chart/views/chart/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 . "chart" . DS . "views" . DS . "chart" . DS . "tmpl" . DS . $tmpl . DS . "custom.css");
     //assign something to oPackage to ensure we can clear filters
     $str = "window.addEvent('domready', function(){\n\t\t\tfabrikChart{$this->row->id} = {};";
     $str .= "\n" . "oPackage.addBlock('vizualization_{$this->row->id}', fabrikChart{$this->row->id});\n\t\t});";
     FabrikHelperHTML::addScriptDeclaration($str);
     //ensure we don't have an incorrect version of mootools loaded
     FabrikHelperHTML::cleanMootools();
     echo parent::display();
 }
Ejemplo n.º 4
0
	function display($tmpl = 'default')
	{
		JHTML::_('behavior.calendar');
		FabrikHelperHTML::script('media/com_fabrik/js/list.js');
		FabrikHelperHTML::script('media/com_fabrik/js/advanced-search.js');
		require_once(COM_FABRIK_FRONTEND.DS.'helpers'.DS.'html.php');
		FabrikHelperHTML::mocha();
		FabrikHelperHTML::loadCalendar();
		$model = &$this->getModel();
		$usersConfig = JComponentHelper::getParams('com_fabrik');
		$model->setId(JRequest::getVar('id', $usersConfig->get('visualizationid', JRequest::getInt('visualizationid', 0))));
		$this->row = $model->getVisualization();
		$model->setListIds();

		if ($this->row->published == 0) {
			JError::raiseWarning(500, JText::_('ALERTNOTAUTH'));
			return '';
		}
		$calendar = $model->_row;
		$this->assign('requiredFiltersFound', $this->get('RequiredFiltersFound'));
		if ($this->requiredFiltersFound) {
			$this->assign('chart', $this->get('Chart'));
		} else {
			$this->assign('chart', '');
		}
		$viewName = $this->getName();
		$pluginManager = JModel::getInstance('Pluginmanager', 'FabrikFEModel');
		$plugin = $pluginManager->getPlugIn('calendar', 'visualization');
		$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'));

		$pluginParams = $model->getPluginParams();
		$this->assignRef('params', $pluginParams);
		$tmpl = $pluginParams->get('chart_layout', $tmpl);
		$tmplpath = JPATH_ROOT.DS.'plugins'.DS.'fabrik_visualization'.DS.'chart'.DS.'views'.DS.'chart'.DS.'tmpl'.DS.$tmpl;
		$this->_setPath('template', $tmplpath);

		$ab_css_file = $tmplpath.DS."template.css";

		if (JFile::exists($ab_css_file))
		{
			JHTML::stylesheet('plugins/fabrik_visualization/chart/views/chart/tmpl/'.$tmpl.'/template.css', true);
		}

		//assign something to Fabrik.blocks to ensure we can clear filters
		$str = "head.ready(function() {
			fabrikChart{$this->row->id} = {};";
		$str .= "\n" . "Fabrik.addBlock('vizualization_{$this->row->id}', fabrikChart{$this->row->id});
		});";
		FabrikHelperHTML::addScriptDeclaration($str);
		echo parent::display();
	}
Ejemplo n.º 5
0
 /**
  * load the javascript class that manages interaction with the form element
  * should only be called once
  * @return string javascript class file
  */
 function loadJavascriptClass()
 {
     FabrikHelperHTML::mocha();
     FabrikHelperHTML::script('javascript.js', 'components/com_fabrik/plugins/table/emailtable/', false);
 }
Ejemplo n.º 6
0
 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');
 }
Ejemplo n.º 7
0
 /**
  * build the advanced search link
  * @return string <a href...> link
  */
 function getAdvancedSearchLink()
 {
     FabrikHelperHTML::mocha('a.popupwin');
     $table =& $this->getTable();
     $url = COM_FABRIK_LIVESITE . "index.php?option=com_fabrik&amp;view=list&amp;layout=_advancedsearch&amp;tmpl=component&amp;listid=" . $table->id . "&amp;nextview=" . JRequest::getVar('view');
     return "<a rel=\"{id:'advanced-search-win',width:690,loadMethod:'xhr',title:'" . JText::_('COM_FABRIK_ADVANCED_SEARCH') . "',maximizable:1}\" href=\"{$url}\" class=\"popupwin\">" . JText::_('COM_FABRIK_ADVANCED_SEARCH') . "</a>";
 }
Ejemplo n.º 8
0
/*
 * @package Joomla.Administrator
 * @subpackage Fabrik
 * @since		1.6
 * @copyright Copyright (C) 2005 Rob Clayburn. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
// no direct access
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT . DS . 'helpers' . DS . 'html');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
JHtml::_('behavior.keepalive');
$fbConfig = JComponentHelper::getParams('com_fabrik');
FabrikHelperHTML::mocha();
FabrikHelperHTML::script('media/com_fabrik/js/lib/art.js');
FabrikHelperHTML::script('media/com_fabrik/js/icons.js');
FabrikHelperHTML::script('media/com_fabrik/js/icongen.js');
FabrikHelperHTML::script('media/com_fabrik/js/canvas.js');
FabrikHelperHTML::script('media/com_fabrik/js/history.js');
FabrikHelperHTML::script('media/com_fabrik/js/keynav.js');
FabrikHelperHTML::script('media/com_fabrik/js/tabs.js');
FabrikHelperHTML::script('media/com_fabrik/js/pages.js');
FabrikHelperHTML::script('administrator/components/com_fabrik/views/package/adminpackage.js');
JHTML::stylesheet('media/com_fabrik/css/package.css');
?>

<script type="text/javascript">
Joomla.submitbutton = function(task)
{
Ejemplo n.º 9
0
 function display($tpl = null)
 {
     $config =& JFactory::getConfig();
     $user =& JFactory::getUser();
     $model =& $this->getModel();
     $formModel =& $this->_formView->getModel();
     //Get the active menu item
     $usersConfig =& JComponentHelper::getParams('com_fabrik');
     $model->setId($usersConfig->get('packageid', JRequest::getInt('packageid', 0)));
     $package =& $model->getPackage();
     $model->_lastTask = JRequest::getVar('task', '');
     $model->_senderBlock = JRequest::getVar('fabrik_senderBlock', '');
     //@TODO: not sure if this is used?
     $model->_lastTaskStatus = JRequest::getVar('taskstatus', '');
     /** @var string any data created by the lasttask - e.g. data to create a new table row with */
     $model->_lastTaskData = JRequest::getVar('taskData', '');
     // TODO: query table/forms to find out which blocks are releated to the block that has updated itself
     $model->_updateBlocks = JRequest::getVar('fbUpdateBlocks', array());
     $model->loadTables();
     $package =& $model->getPackage();
     $usedForms = array();
     if ($package->tables != '') {
         $tableids = explode(",", $package->tables);
         foreach ($tableids as $i) {
             if ($i === '') {
                 continue;
             }
             //in PHP5 objects are assigned by reference as default -
             //cloning object doesnt deep clone other oject references either??
             //this copy method might be intensive
             $tableView = clone $this->_tableView;
             $tableView->setId($i);
             $tableView->_isMambot = true;
             $tableModel =& $tableView->getModel();
             $tableModel->setId($i);
             $tableModel->_packageId = $this->_id;
             $tableModel->_postMethod = 'ajax';
             $table =& $tableModel->getTable();
             $this->blocks[$table->label] = $tableView->display();
             $table = $tableModel->getTable();
             $formModel =& $tableModel->getForm();
             $formModel->_editable = 1;
             $formView = clone $this->_formView;
             //used to buffer output
             $formView->_isMambot = true;
             $formView->setId($table->form_id);
             $formModel->_postMethod = 'ajax';
             $formModel->_packageId = $this->_id;
             $usedForms[] = $formModel->_id;
             $formView->setModel($formModel, true);
             $this->blocks['form_' . $formModel->_id] = $formView->display();
             //creating a read only view
             $formModel->_editable = 0;
             $formView->setModel($formModel, true);
             $orgiView = JRequest::getVar('view', 'form');
             $view = JRequest::setVar('view', 'details');
             $this->blocks[$table->label . ' details'] = $formView->display();
             JRequest::setVar('view', $orgiView);
         }
     }
     // see if we have any forms that dont record to the database that need to be added to blocks[]
     // can occur when redering a form in a module with use ajax turned on
     if ($package->forms != '') {
         $formids = explode(",", $package->forms);
         foreach ($formids as $fid) {
             if (!array_key_exists('form_' . $fid, $this->blocks)) {
                 $formModel->_editable = 1;
                 $formView = clone $this->_formView;
                 //used to buffer output
                 $formView->_isMambot = true;
                 $formView->setId($fid);
                 $formModel->_postMethod = 'ajax';
                 $formModel->_packageId = $this->_id;
                 $usedForms[] = $formModel->_id;
                 $formView->setModel($formModel, true);
                 $this->blocks['form_' . $formModel->_id] = $formView->display();
             }
         }
     }
     $model->render();
     $this->_basePath = COM_FABRIK_FRONTEND . DS . 'views';
     $tmpl = JRequest::getVar('layout', 'default');
     //$this->blocks = $model->_blocks;
     $this->_setPath('template', $this->_basePath . DS . 'package' . DS . 'tmpl' . DS . $tmpl);
     if (!isset($package->template)) {
         $package->template = 'default';
         $tmpl = JRequest::getVar('layout', $package->template);
     } else {
         //set by table module in ajax mode
         $tmpl = $package->template;
     }
     $this->_includeCSS($tmpl);
     $this->_basePath = COM_FABRIK_FRONTEND . DS . 'views';
     $this->_setPath('template', $this->_basePath . DS . 'package' . DS . 'tmpl' . DS . $tmpl);
     $liveTmplPath = JURI::root() . '/components/com_fabrik/views/package/tmpl/' . $tmpl . '/';
     FabrikHelperHTML::mootools();
     FabrikHelperHTML::mocha();
     // check for a custom js file and include it if it exists
     $aJsPath = JPATH_SITE . DS . "components" . DS . "com_fabrik" . DS . "views" . DS . "package" . DS . "tmpl" . DS . $tmpl . DS . "javascript.js";
     if (file_exists($aJsPath)) {
         FabrikHelperHTML::script("javascript.js", 'components/com_fabrik/views/package/tmpl/' . $tmpl . '/', true);
     }
     //ensure we don't have an incorrect version of mootools loaded
     FabrikHelperHTML::cleanMootools();
     if ($this->_isMambot) {
         $res = $this->loadTemplate();
         if (JError::isError($res)) {
             print_r(JError::getErrors());
         } else {
             return $res;
         }
     } else {
         parent::display();
     }
 }
Ejemplo n.º 10
0
Archivo: list.php Proyecto: rw1/fabrik
 /**
  * build the link (<a href..>) for viewing table data
  *
  * @param bol $popUp is the link to generated a popup to show
  * @param obj element  27/06/2011
  * @param object $row
  * @param string $key 28/06/2011 - do longer passed in with _raw appended (done in this method)
  * @param string $val
  * @param int number of related records
  * @param int ref to related data admin info 27/16/2011
  * @return string
  */
 function viewDataLink($popUp = false, $element, $row = null, $key = '', $val = '', $count = 0, $f)
 {
     $elKey = $element->list_id . '-' . $element->form_id . '-' . $element->element_id;
     $listid = $element->list_id;
     $app = JFactory::getApplication();
     $params = $this->getParams();
     $factedLinks = $params->get('factedlinks');
     // $$$ hugh - we are getting element keys that aren't in the linkedlisttext.
     // not sure why, so added this defensive code.  Should probably find out
     // why though!  I just needed to make this error go away NAO!
     $linkedListText = isset($factedLinks->linkedlisttext->{$elKey}) ? $factedLinks->linkedlisttext->{$elKey} : '';
     $label = $this->parseMessageForRowHolder($linkedListText, JArrayHelper::fromObject($row));
     $Itemid = $app->isAdmin() ? 0 : @$app->getMenu('site')->getActive()->id;
     $action = $app->isAdmin() ? "task" : "view";
     $url = "index.php?option=com_fabrik&";
     if (is_null($listid)) {
         $list = $this->getTable();
         $listid = $list->id;
     }
     $facetTable = $this->_facetedTable($listid);
     if (!$facetTable->canView()) {
         return '<div style="text-align:center"><a title="' . JText::_('Insufficient access rights. Please login') . '"><img src="media/com_fabrik/images/login.png" alt="' . JText::_('iInsufficient access rights. Please login') . '" /></a></div>';
     }
     $tlabel = $label === '' ? JText::_('COM_FABRIK_NO_RECORDS') : '(0) ' . $label;
     if ($count === 0) {
         $aExisitngLinkedForms = $params->get('linkedform', '', '_default', 'array');
         $linkedForm = JArrayHelper::getValue($aExisitngLinkedForms, $f, false);
         $addLink = $linkedForm == '0' ? $this->viewFormLink($popUp, $element, $row, $key, $val, false, $f) : '';
         return '<div style="text-align:center" class="related_data_norecords">' . $tlabel . '</div>' . $addLink;
     }
     $key .= '_raw';
     if ($label === '') {
         $label = JText::_('COM_FABRIK_VIEW');
     }
     $label = '(' . $count . ') ' . $label;
     if ($app->isAdmin()) {
         $bits[] = "task=list.view";
         $bits[] = "cid={$listid}";
     } else {
         $bits[] = "view=list";
         $bits[] = "listid={$listid}";
         $tableLinks = $this->getTableLinks();
         // $$$ rob 01/03/2011 find at matching itemid in another menu item for the related data link
         foreach ($tableLinks as $tlink) {
             if (strstr($tlink->link, 'index.php?option=com_fabrik&view=list&listid=' . $listid)) {
                 $bits[] = "Itemid=" . $tlink->id;
                 $Itemid = $tlink->id;
                 break;
             }
         }
         $bits[] = "Itemid={$Itemid}";
     }
     if ($key != '') {
         $bits[] = "{$key}={$val}";
     }
     $bits[] = 'limitstart' . $listid . '=0';
     if ($popUp) {
         $bits[] = "tmpl=component";
         $bits[] = "ajax=1";
     }
     $bits[] = "&resetfilters=1";
     //$bits[] = "clearfilters=1"; //nope stops url filter form workin on related data :(
     $bits[] = '&fabrik_incsessionfilters=0';
     //test for releated data, filter once, go backt o main list re-filter -
     $url .= implode("&", $bits);
     $url = JRoute::_($url);
     if ($popUp) {
         FabrikHelperHTML::mocha('a.popupwin');
         $opts = new stdClass();
         $opts->maximizable = 1;
         $opts->title = JText::_('COM_FABRIK_VIEW');
         $opts->evalScripts = 1;
         $opts = str_replace('"', "'", json_encode($opts));
         $url = '<a rel="' . $opts . '" href="' . $url . '" class="popupwin">' . $label . '</a>';
     } else {
         $url = '<a class="related_data" href="' . $url . '">' . $label . "</a>";
     }
     return $url;
 }
Ejemplo n.º 11
0
 function display($tmpl = 'default')
 {
     FabrikHelperHTML::framework();
     $app = JFactory::getApplication();
     $Itemid = (int) @$app->getMenu('site')->getActive()->id;
     JHTML::_('behavior.calendar');
     require_once COM_FABRIK_FRONTEND . DS . 'helpers' . DS . 'html.php';
     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->setListIds();
     $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();
     $canAdd = $this->get('CanAdd');
     $this->assign('requiredFiltersFound', $this->get('RequiredFiltersFound'));
     if ($canAdd && $this->requiredFiltersFound) {
         $app->enqueueMessage(JText::_('PLG_VISUALIZATION_CALENDAR_DOUBLE_CLICK_TO_ADD'));
     }
     $this->assign('canAdd', $canAdd);
     $fbConfig =& JComponentHelper::getParams('com_fabrik');
     JHTML::stylesheet('media/com_fabrik/css/list.css');
     FabrikHelperHTML::script('media/com_fabrik/js/element.js', true);
     FabrikHelperHTML::script('media/com_fabrik/js/form.js', true);
     FabrikHelperHTML::script('media/com_fabrik/js/list.js', true);
     FabrikHelperHTML::script('plugins/fabrik_visualization/calendar/calendar.js', true);
     $params =& $model->getParams();
     //Get the active menu item
     $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->eventLists = $this->get('eventLists');
     $options->calendarId = $calendar->id;
     $options->popwiny = $params->get('yoffset', 0);
     $options->urlfilters = $urlfilters;
     $options->canAdd = $canAdd;
     $options->tmpl = $tmpl;
     //$formView =& $this->_formView;
     $o = $model->getAddStandardEventFormInfo();
     if ($o != null) {
         $options->listid = $o->id;
         //$formView->setId($o->form_id);
         //$options->formid = $o->form_id;
     }
     //$formModel =& $formView->getModel();
     //$form =& $formModel->getForm();
     //$$$rob @TODO not sure this is need - it isnt in the timeline viz
     $model->setRequestFilters();
     $options->filters =& $model->filters;
     // end not sure
     $options->Itemid = $Itemid;
     $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::_('JANUARY_SHORT'), JText::_('FEBRUARY_SHORT'), JText::_('MARCH_SHORT'), JText::_('APRIL_SHORT'), JText::_('MAY_SHORT'), JText::_('JUNE_SHORT'), JText::_('JULY_SHORT'), JText::_('AUGUST_SHORT'), JText::_('SEPTEMBER_SHORT'), JText::_('OCTOBER_SHORT'), JText::_('NOVEMBER_SHORT'), JText::_('DECEMBER_SHORT'));
     $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);
     JText::script('PLG_VISUALIZATION_CALENDAR_NEXT');
     JText::script('PLG_VISUALIZATION_CALENDAR_PREVIOUS');
     JText::script('PLG_VISUALIZATION_CALENDAR_DAY');
     JText::script('PLG_VISUALIZATION_CALENDAR_WEEK');
     JText::script('PLG_VISUALIZATION_CALENDAR_MONTH');
     JText::script('PLG_VISUALIZATION_CALENDAR_KEY');
     JText::script('PLG_VISUALIZATION_CALENDAR_TODAY');
     JText::script('PLG_VISUALIZATION_CALENDAR_CONF_DELETE');
     JText::script('PLG_VISUALIZATION_CALENDAR_DELETE');
     JText::script('PLG_VISUALIZATION_CALENDAR_VIEW');
     JText::script('PLG_VISUALIZATION_CALENDAR_EDIT');
     JText::script('PLG_VISUALIZATION_CALENDAR_ADD_EDIT_EVENT');
     $str = "head.ready(function() {\n" . "  {$this->calName} = new fabrikCalendar('calendar_{$calendar->id}');\n" . "  {$this->calName}.render({$json});\n" . "  Fabrik.addBlock('calendar_" . $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 = JPATH_ROOT . DS . 'plugins' . DS . 'fabrik_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('plugins/fabrik_visualization/calendar/views/calendar/tmpl/' . $tmpl . '/template.css');
     }
     return parent::display();
 }
Ejemplo n.º 12
0
 /**
  * load the required plupload runtime engines
  * @param string $runtimes
  */
 protected function pluploadLRuntimes($runtimes)
 {
     FabrikHelperHTML::mocha();
     $config =& JFactory::getConfig();
     $debug = $config->getValue('config.debug');
     // $$$ hugh - plupload have changed their build script so it no longer
     // adds the .min. on the minified script names
     //$ex = !$debug ? '.min' : '';
     $ex = '';
     $path = $debug ? 'components/com_fabrik/plugins/element/fabrikfileupload/plupload/src/javascript/' : 'components/com_fabrik/plugins/element/fabrikfileupload/plupload/js/';
     FabrikHelperHTML::script('plupload' . $ex . '.js', $path, true);
     if (strstr($runtimes, 'html5')) {
         FabrikHelperHTML::script('plupload.html5' . $ex . '.js', $path, true);
     }
     if (strstr($runtimes, 'html4')) {
         FabrikHelperHTML::script('plupload.html4' . $ex . '.js', $path, true);
     }
     if (strstr($runtimes, 'gears')) {
         FabrikHelperHTML::script('gears_init.js', $path, true);
         FabrikHelperHTML::script('plupload.gears' . $ex . '.js', $path, true);
     }
     if (strstr($runtimes, 'flash')) {
         FabrikHelperHTML::script('plupload.flash' . $ex . '.js', $path, true);
     }
     if (strstr($runtimes, 'silverlight')) {
         FabrikHelperHTML::script('plupload.silverlight' . $ex . '.js', $path, true);
     }
     if (strstr($runtimes, 'browserplus')) {
         FabrikHelperHTML::script('plupload.browserplus' . $ex . '.js', $path, true);
     }
 }
Ejemplo n.º 13
0
 /**
  * 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();
 }
Ejemplo n.º 14
0
 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();
 }
Ejemplo n.º 15
0
 /**
  * Creates the html <a> link allowing you to edit other forms from the table
  * E.g. Faceted browsing: those specified in the table's "Form's whose primary keys link to this table"
  *
  * @param   bool    $popUp    is popup link
  * @param   object  $element  27/06/2011 - changed to passing in element
  * @param   object  $row      current list row
  * @param   string  $key      key
  * @param   string  $val      value
  * @param   bool    $usekey   use the key
  * @param   int     $f        repeat value 27/11/2011
  *
  * @return  string	<a> html part
  */
 public function viewFormLink($popUp = false, $element = null, $row = null, $key = '', $val = '', $usekey = false, $f = 0)
 {
     $elKey = $element->list_id . '-' . $element->form_id . '-' . $element->element_id;
     $params = $this->getParams();
     $listid = $element->list_id;
     $formid = $element->form_id;
     $linkedFormText = $params->get('linkedformtext');
     $factedlinks = $params->get('factedlinks');
     $linkedFormText = JArrayHelper::fromObject($factedlinks->linkedformtext);
     $label = $this->parseMessageForRowHolder(JArrayHelper::getValue($linkedFormText, $elKey), JArrayHelper::fromObject($row));
     $app = JFactory::getApplication();
     if (!$app->isAdmin()) {
         $Itemid = (int) @$app->getMenu('site')->getActive()->id;
     }
     if (is_null($listid)) {
         $list = $this->getTable();
         $listid = $list->id;
     }
     if (is_null($formid)) {
         $form = $this->getFormModel()->getForm();
         $formid = $form->id;
     }
     $facetTable = $this->_facetedTable($listid);
     if (!$facetTable->canAdd()) {
         return '<div style="text-align:center"><a title="' . JText::_('JERROR_ALERTNOAUTHOR') . '"><img src="media/com_fabrik/images/login.png" alt="' . JText::_('JERROR_ALERTNOAUTHOR') . '" /></a></div>';
     }
     if ($app->isAdmin()) {
         $bits[] = 'task=form.view';
         $bits[] = 'cid=' . $formid;
     } else {
         $bits[] = 'view=form';
         $bits[] = 'Itemid=' . $Itemid;
     }
     $bits[] = 'formid=' . $formid;
     $bits[] = 'referring_table=' . $this->getTable()->id;
     // $$$ hugh - change in fabrikdatabasejoin getValue() means we have to append _raw to key name
     if ($key != '') {
         $bits[] = $key . '_raw=' . $val;
     }
     if ($popUp) {
         $bits[] = "tmpl=component";
         $bits[] = "ajax=1";
     }
     if ($usekey and $key != '' and !is_null($row)) {
         $bits[] = 'usekey=' . FabrikString::shortColName($key);
         $bits[] = 'rowid=' . $row->slug;
     } else {
         $bits[] = 'rowid=0';
     }
     $url = 'index.php?option=com_fabrik&' . implode('&', $bits);
     $url = JRoute::_($url);
     if (is_null($label) || $label == '') {
         $label = JText::_('COM_FABRIK_LINKED_FORM_ADD');
     }
     if ($popUp) {
         FabrikHelperHTML::mocha('a.popupwin');
         $opts = new stdClass();
         $opts->maximizable = 1;
         $opts->title = JText::_('COM_FABRIK_ADD');
         $opts->evalScripts = 1;
         $opts = json_encode($opts);
         $link = "<a rel='{$opts}' href=\"{$url}\" class=\"popupwin\" title=\"{$label}\">" . $label . "</a>";
     } else {
         $link = '<a href="' . $url . '" title="' . $label . '">' . $label . '</a>';
     }
     $url = '<span class="addbutton">' . $link . '</span></a>';
     return $url;
 }
Ejemplo n.º 16
0
 /**
  * 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();
 }
Ejemplo n.º 17
0
 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;
 }
Ejemplo n.º 18
0
	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;
	}
Ejemplo n.º 19
0
	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;
	}
Ejemplo n.º 20
0
 /**
  * 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);
 }