Exemple #1
0
 /**
  * return the javascript to create an instance of the class defined in formJavascriptClass
  * @param object parameters
  * @param object table model
  * @param array [0] => string table's form id to contain plugin
  * @return bool
  */
 function loadJavascriptInstance($params, $model, $args)
 {
     $form_id = $args[0];
     FabrikHelperHTML::script('element.js', 'media/com_fabrik/js/');
     $tableModel =& JModel::getInstance('table', 'FabrikModel');
     $tableModel->setId(JRequest::getVar('tableid'));
     $elements =& $tableModel->getElements('filtername');
     $pels = $params->get('inline_editable_elements');
     $use = trim($pels) == '' ? array() : explode(",", $pels);
     $els = array();
     foreach ($elements as $key => $val) {
         $key = FabrikString::safeColNameToArrayKey($key);
         if (empty($use) || in_array($key, $use)) {
             $els[$key] = new stdClass();
             $els[$key]->elid = $val->_id;
             $els[$key]->plugin = $val->getElement()->plugin;
             //load in all element js classes
             $val->formJavascriptClass();
         }
     }
     $opts = new stdClass();
     $opts->mooversion = FabrikWorker::getMooVersion() == 1 ? 1.2 : 1.1;
     $opts->elements = $els;
     $opts->tableid = $tableModel->_id;
     $opts->focusClass = 'focusClass';
     $opts->liveSite = COM_FABRIK_LIVESITE;
     $opts->editEvent = $params->get('inline_edit_event', 'dblclick');
     $opts->tabSave = $params->get('inline_tab_save', false);
     $opts->showCancel = $params->get('inline_show_cancel', true);
     $opts->showSave = $params->get('inline_show_save', true);
     $opts->loadFirst = (bool) $params->get('inline_load_first', false);
     $opts = json_encode($opts);
     $lang = $this->_getLang();
     $lang = json_encode($lang);
     $this->jsInstance = "new FbTableInlineEdit('{$form_id}', {$opts}, {$lang})";
     return true;
 }
Exemple #2
0
 /**
  * return tehe javascript to create an instance of the class defined in formJavascriptClass
  * @return string javascript to create instance. Instance name must be 'el'
  */
 function elementJavascript($repeatCounter)
 {
     $id = $this->getHTMLId($repeatCounter);
     $element =& $this->getElement();
     $data =& $this->_form->_data;
     $arVals = explode(GROUPSPLITTER2, $element->sub_values);
     $arTxt = explode(GROUPSPLITTER2, $element->sub_labels);
     $params =& $this->getParams();
     $opts =& $this->getElementJSOptions($repeatCounter);
     $opts->mooversion = FabrikWorker::getMooVersion() == 1 ? 1.2 : 1.1;
     $opts->allowadd = $params->get('allowadd', false);
     $opts->defaultVal = $this->getValue($data, $repeatCounter);
     $opts->data = array_combine($arVals, $arTxt);
     $opts->splitter = GROUPSPLITTER2;
     $opts->hovercolour = $params->get('picklist-hovercolour', '#AFFFFD');
     $opts->bghovercolour = $params->get('picklist-bghovercolour', '#FFFFDF');
     $opts = json_encode($opts);
     $lang = new stdClass();
     $lang->dropstuff = JText::_('Drag items from other list and drop here');
     $lang = json_encode($lang);
     return "new fbPicklist('{$id}', {$opts}, {$lang})";
 }
Exemple #3
0
 /**
  * return the javascript to create an instance of the class defined in formJavascriptClass
  * @param object parameters
  * @param object table model
  * @param array [0] => string table's form id to contain plugin
  * @return bool
  */
 function loadJavascriptInstance($params, $model, $args)
 {
     $form_id = $args[0];
     $opts = new stdClass();
     $opts->liveSite = COM_FABRIK_LIVESITE;
     $opts->name = $this->_getButtonName();
     $opts->mooversion = FabrikWorker::getMooVersion() == 1 ? 1.2 : 1.1;
     $opts->renderOrder = $this->renderOrder;
     $opts = json_encode($opts);
     $lang = $this->_getLang();
     $lang = json_encode($lang);
     $this->jsInstance = "new fbTableEmail('{$form_id}', {$opts}, {$lang})";
     return true;
 }
Exemple #4
0
 function getAdminJS()
 {
     $element =& $this->getElement();
     $mooversion = FabrikWorker::getMooVersion() == 1 ? 1.2 : 1.1;
     $sub_values = explode("|", $element->sub_values);
     $sub_texts = explode("|", $element->sub_labels);
     $sub_intial_selections = explode("|", $element->sub_intial_selection);
     $script = "\tvar fabrikcheckbox = new fabrikAdminCheckbox({'mooversion':'{$mooversion}'});\n" . "\tpluginControllers.push({element:'fabrikcheckbox', controller:fabrikcheckbox});\n";
     $json = array();
     for ($ii = 0; $ii < count($sub_values) && $ii < count($sub_texts); $ii++) {
         $bits = array(html_entity_decode($sub_values[$ii], ENT_QUOTES), html_entity_decode($sub_texts[$ii], ENT_QUOTES));
         if (in_array($sub_values[$ii], $sub_intial_selections)) {
             $bits[] = 'checked';
         }
         $json[] = $bits;
     }
     $script .= "\tfabrikcheckbox.addSubElements(" . json_encode($json) . ");\n";
     return $script;
 }
Exemple #5
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');
 }
Exemple #6
0
 /**
  * @param object element model
  * @param object element params
  * @param string row data for this element
  */
 function render(&$model, &$params, $file)
 {
     $fbConfig =& JComponentHelper::getParams('com_fabrik');
     ini_set('display_errors', true);
     require_once COM_FABRIK_FRONTEND . DS . 'libs' . DS . 'getid3' . DS . 'getid3' . DS . 'getid3.php';
     require_once COM_FABRIK_FRONTEND . DS . 'libs' . DS . 'getid3' . DS . 'getid3' . DS . 'getid3.lib.php';
     getid3_lib::IncludeDependency(COM_FABRIK_FRONTEND . DS . 'libs' . DS . 'getid3' . DS . 'getid3' . DS . 'extension.cache.mysql.php', __FILE__, true);
     $config =& JFactory::getConfig();
     $host = $config->getValue('host');
     $database = $config->getValue('db');
     $username = $config->getValue('user');
     $password = $config->getValue('password');
     $getID3 = new getID3_cached_mysql($host, $database, $username, $password);
     // Analyze file and store returned data in $ThisFileInfo
     $relPath = str_replace("\\", "/", JPATH_SITE . $file);
     $thisFileInfo = $getID3->analyze($relPath);
     //var_dump($relPath, $thisFileInfo);
     $w = $params->get('fu_main_max_width', 0);
     $h = $params->get('fu_main_max_height', 0);
     if (is_array($thisFileInfo)) {
         if (array_key_exists('swf', $thisFileInfo)) {
             if ($thisFileInfo['swf']['header']['frame_width'] < $w || $thisFileInfo['swf']['header']['frame_height'] < $h) {
                 $w = $thisFileInfo['swf']['header']['frame_width'];
                 $h = $thisFileInfo['swf']['header']['frame_height'];
             }
         }
     }
     if ($w <= 0 || $h <= 0) {
         $w = 800;
         $h = 600;
     }
     // $$$ hugh - if they've enabled thumbnails, for Flash content we'll take that to mean they don't
     // want to play the content inline in the table, and use mediabox (if available) to open it instead.
     if (!$model->_inDetailedView && $fbConfig->get('use_mediabox', true) && FabrikWorker::getMooVersion() == 1 && $params->get('make_thumbnail', false)) {
         $element =& $model->getElement();
         // @TODO - work out how to do thumbnails
         // $$$ hugh - thought about using thumbed-down embedded Flash as
         // thumbnail, but really need to avoid having to download every flash in
         // the table on page load!  But just doesn't seem to be a way of getting
         // a thumbnail from a Flash.  For now, just use a default "Here Be Flash"
         // icon for the thumb.  Might be nice to add 'icon to use' option for Upload
         // element, so if it isn't an image type, you can point at another element on the form,
         // (either and Upload or an Image) and use that as the thumb for this content.
         /*
         $thumb_w = $params->get('thumb_max_width');
         $thumb_h = $params->get('thumb_max_height');
         $file = str_replace("\\", "/", COM_FABRIK_LIVESITE  . $file);
         $this->output = "<object width=\"$w\" height=\"$h\">
         <param name=\"movie\" value=\"$file\">
         <embed src=\"$file\" width=\"$thumb_w\" height=\"$thumb_h\">
         </embed>
         </object>";
         */
         $thumb_dir = $params->get('thumb_dir');
         if (!empty($thumb_dir)) {
             $file = str_replace("\\", "/", $file);
             $pathinfo = pathinfo($file);
             // $$$ hugh - apparently filename ocnstant only added in PHP 5.2
             if (!isset($pathinfo['filename'])) {
                 $pathinfo['filename'] = explode('.', $pathinfo['basename']);
                 $pathinfo['filename'] = $pathinfo['filename'][0];
             }
             $thumb_path = COM_FABRIK_BASE . DS . $thumb_dir . DS . $pathinfo['filename'] . '.png';
             if (JFile::exists($thumb_path)) {
                 $thumb_file = COM_FABRIK_LIVESITE . $thumb_dir . '/' . $pathinfo['filename'] . '.png';
             } else {
                 $thumb_file = COM_FABRIK_LIVESITE . "media/com_fabrik/images/flash.jpg";
             }
         } else {
             $thumb_file = COM_FABRIK_LIVESITE . "media/com_fabrik/images/flash.jpg";
         }
         $file = str_replace("\\", "/", COM_FABRIK_LIVESITE . $file);
         $this->output .= "<a href=\"{$file}\" rel=\"lightbox[flash {$w} {$h}]\"><img src=\"{$thumb_file}\" alt=\"Full Size\" /></a>";
     } else {
         if ($model->_inDetailedView) {
             $file = str_replace("\\", "/", COM_FABRIK_LIVESITE . $file);
             $this->output .= "<object width=\"{$w}\" height=\"{$h}\">\n\t\t\t\t<param name=\"movie\" value=\"{$file}\">\n\t\t\t\t<embed src=\"{$file}\" width=\"{$w}\" height=\"{$h}\">\n\t\t\t\t</embed>\n\t\t\t\t</object>";
         } else {
             $file = str_replace("\\", "/", COM_FABRIK_LIVESITE . $file);
             $this->output .= "<object width=\"{$w}\" height=\"{$h}\">\n\t\t\t\t<param name=\"movie\" value=\"{$file}\">\n\t\t\t\t<embed src=\"{$file}\" width=\"{$w}\" height=\"{$h}\">\n\t\t\t\t</embed>\n\t\t\t\t</object>";
         }
     }
     //}
 }
Exemple #7
0
    /**
     * Display the form to add or edit a table
     * @param object table
     * @param array the drop down lists used on the form
     * @param array connection tables
     * @param object menus
     * @param string compoent action
     * @param int form id that the table links to?
     * @param object parameters
     * @param object plugin mangager
     * @param object table model
     */
    function edit($row, $lists, $connectionTables, $menus, $fabrikid, $params, $pluginManager, $model, $form)
    {
        JHTML::stylesheet('fabrikadmin.css', 'administrator/components/com_fabrik/views/');
        FabrikViewTable::setTableToolbar();
        JRequest::setVar('hidemainmenu', 1);
        $document =& JFactory::getDocument();
        FabrikHelperHTML::script('namespace.js', 'administrator/components/com_fabrik/views/', true);
        FabrikHelperHTML::script('pluginmanager.js', 'administrator/components/com_fabrik/views/', true);
        FabrikHelperHTML::script('admintable.js', 'administrator/components/com_fabrik/views/', true);
        JFilterOutput::objectHTMLSafe($row);
        jimport('joomla.html.editor');
        //just until joomla uses mootools 1.2
        FabrikHelperHTML::mootools();
        require_once COM_FABRIK_FRONTEND . DS . 'helpers' . DS . 'editor.php';
        jimport('joomla.html.pane');
        FabrikHelperHTML::tips();
        $editor =& FabrikHelperHTML::getEditor();
        $pane =& JPane::getInstance();
        $fbConfig =& JComponentHelper::getParams('com_fabrik');
        $opts = new stdClass();
        $opts->mooversion = FabrikWorker::getMooVersion() == 1 ? 1.2 : 1.1;
        $opts = FastJSON::encode($opts);
        $lang = new stdClass();
        $lang->action = JText::_('ACTION');
        $lang->do = JText::_('DO');
        $lang->del = JText::_('DELETE');
        $lang->in = JText::_('IN');
        $lang->on = JText::_('ON');
        $lang->options = JText::_('OPTIONS');
        $lang->please_select = JText::_('COM_FABRIK_PLEASE_SELECT');
        $lang = FastJSON::encode($lang);
        $js = "window.addEvent('domready', function() {\n  \t\tvar aPlugins = [];\n";
        $js .= $pluginManager->getAdminPluginJs('table', $row, $lists);
        $js .= "controller = new TablePluginManager(aPlugins, {$lang}, {$opts});\n";
        $usedPlugins = $params->get('plugin', '', '_default', 'array');
        $js .= $pluginManager->getAdminSelectedPluginJS('table', $row, $lists, $params);
        $js .= "});\n";
        $js .= "var connectiontables = new Array;\n";
        $i = 0;
        if (is_array($connectionTables)) {
            foreach ($connectionTables as $k => $items) {
                foreach ($items as $v) {
                    $js .= "connectiontables[" . $i++ . "] = new Array('{$k}','" . addslashes($v->value) . "','" . addslashes($v->text) . "');\n\t\t";
                }
            }
        }
        $js .= "\n\t\t\tfunction submitbutton(pressbutton) {\n\t\t\t\tif (pressbutton == 'cancel') {\n\t\t\t\t\tsubmitform( pressbutton);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tvar err = '';";
        $js .= $editor->save('introduction');
        $js .= "if(\$('label').value == '') {\n\t\t\t\t\terr = err +'" . JText::_('PLEASE ENTER A TABLE LABEL', true) . '\\n' . "';\n\t\t\t\t}\n\n\t\t\t\tif(\$('database_name')) {\n\t\t\t\t\tif(\$('database_name').value == '') {\n\t\t\t\t\t\tif(\$('connection_id')) {\n\t\t\t\t\t\t\tif(\$('connection_id').value == '-1') {\n\t\t\t\t\t\t\t\terr = err +'" . JText::_('PLEASE SELECT A CONNECTION', true) . '\\n' . "';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif(\$('tablename')) {\n\t\t\t\t\t\t\tif(\$('tablename').value == '' || \$('tablename').value == '-1') {\n\t\t\t\t\t\t\t\terr = err + '" . JText::_('PLEASE SELECT A DATABASE TABLE', true) . '\\n' . "';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (err == '') {\n\t\t\t\t\tsubmitform( pressbutton);\n\t\t\t\t}else{\n\t\t\t\t\talert (err);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar joinCounter = 0;";
        $document->addScriptDeclaration($js);
        FabrikHelperHTML::cleanMootools();
        ?>
<form action="index.php" method="post" name="adminForm">
<table style="width: 100%">
	<tr>
		<td style="width: 50%" valign="top">
		<fieldset class="adminform"><legend><?php 
        echo JText::_('DETAILS');
        ?>
</legend>
		<table class="admintable">
			<tr>
				<td class="key"><label for="label"><?php 
        echo JText::_('LABEL');
        ?>
</label></td>
				<td><input class="inputbox" type="text" id="label" name="label"
					size="50" value="<?php 
        echo $row->label;
        ?>
" /></td>
			</tr>
			<tr>
				<td class="key"><?php 
        echo JText::_('INTRODUCTION');
        ?>
</td>
				<td><?php 
        echo $editor->display('introduction', $row->introduction, '100%', '200', '45', '25', false);
        ?>
				</td>
			</tr>
		</table>
		</fieldset>

		<fieldset><legend><?php 
        echo JText::_('FILTERS');
        ?>
</legend>
			<table class="admintable">
				<tr>
					<td class="key"><?php 
        echo JText::_('FILTER TRIGGER');
        ?>
</td>
					<td><?php 
        echo $lists['filter_action'];
        ?>
</td>
				</tr>
			</table>
			<?php 
        echo $form->render('params', 'filters');
        ?>
		</fieldset>

		<fieldset><legend><?php 
        echo JText::_('NAVIGATION');
        ?>
</legend>
			<table class="admintable">
			<tr>
				<td class="key"><label for="rows_per_page"><?php 
        echo JText::_('ROWS PER PAGE');
        ?>
</label>
				</td>
				<td><input type="text" name="rows_per_page" id="rows_per_page"
					class="inputbox"
					value="<?php 
        echo $row->rows_per_page != '' ? $row->rows_per_page : 10;
        ?>
"
					size="3" /></td>
			</tr>
			</table>
			<?php 
        echo $form->render('params', 'navigation');
        ?>
		</fieldset>

		<fieldset><legend><?php 
        echo JText::_('LAYOUT');
        ?>
</legend>
			<table class="admintable">
			<tr>
				<td class="key"><?php 
        echo JText::_('TEMPLATE');
        ?>
</td>
				<td><?php 
        print_r($lists['tableTemplates']);
        ?>
</td>
			</tr>
			</table>
			<?php 
        echo $form->render('params', 'layout');
        ?>
		</fieldset>

		<fieldset><legend><?php 
        echo JText::_('COM_FABRIK_DETAIL_LINKS');
        ?>
</legend>
			<?php 
        echo $form->render('params', 'detaillinks');
        ?>
		</fieldset>

		<fieldset><legend><?php 
        echo JText::_('COM_FABRIK_EDIT_LINKS');
        ?>
</legend>
			<?php 
        echo $form->render('params', 'editlinks');
        ?>
		</fieldset>

		<fieldset><legend><?php 
        echo JText::_('COM_FABRIK_ADD_LINK');
        ?>
</legend>
			<?php 
        echo $form->render('params', 'addlink');
        ?>
		</fieldset>

		<fieldset><legend><?php 
        echo JText::_('Notes');
        ?>
</legend> <?php 
        echo $form->render('params', 'notes');
        ?>
		</fieldset>

		<fieldset><legend><?php 
        echo JText::_('Advanced');
        ?>
</legend> <?php 
        echo $form->render('params', 'advanced');
        ?>
		</fieldset>
    <?php 
        if ($fbConfig->get('use_wip')) {
            ?>
		<fieldset><legend><?php 
            echo JText::_('WORK IN PROGRESS');
            ?>
</legend> <?php 
            echo $form->render('params', 'wip');
            ?>
		<?php 
        }
        ?>


		</td>
		<td valign="top"><?php 
        echo $pane->startPane("content-pane");
        echo $pane->startPanel(JText::_('PUBLISHING'), "publish-page");
        echo $form->render('details');
        ?>
		<fieldset><legend><?php 
        echo JText::_('RSS OPTIONS');
        ?>
</legend> <?php 
        echo $form->render('params', 'rss');
        ?>
</fieldset>
		<fieldset><legend><?php 
        echo JText::_('CSV OPTIONS');
        ?>
</legend> <?php 
        echo $form->render('params', 'csv');
        ?>
		</fieldset>
		<fieldset><legend><?php 
        echo JText::_('SEARCH');
        ?>
</legend> <?php 
        echo $form->render('params', 'search');
        ?>
		</fieldset>
		<?php 
        echo $pane->endPanel();
        echo $pane->startPanel(JText::_('ACCESS'), "access-page");
        ?>
		<fieldset><legend><?php 
        echo JText::_('ACCESS');
        ?>
</legend> <?php 
        echo $form->render('params', 'access');
        ?>
		</fieldset>
		<?php 
        echo $pane->endPanel();
        echo $pane->startPanel(JText::_('DATA'), "tabledata-page");
        ?>
		<fieldset><legend><?php 
        echo JText::_('DATA');
        ?>
</legend>
		<table class="admintable">
			<tr>
				<td class="key"><?php 
        echo JText::_('CONNECTION');
        ?>
</td>
				<td><?php 
        echo $lists['connections'];
        ?>
</td>
			</tr>
			<?php 
        if ($row->id == 0) {
            ?>
			<tr>
				<td class="key"><?php 
            echo JText::_('CREATE NEW TABLE');
            ?>
</td>
				<td><input id="database_name" name="_database_name" size="40" /></td>
			</tr>
			<tr>
				<td colspan="2"><?php 
            echo JText::_('OR');
            ?>
</td>
			</tr>
			<?php 
        }
        ?>

			<tr>
				<td class="key"><?php 
        echo JText::_('LINK TO TABLE');
        ?>
</td>
				<td><?php 
        echo $lists['tablename'];
        ?>
</td>
			</tr>
			<?php 
        if ($row->id != '') {
            ?>
			<tr>
				<td class="key"><label for="db_primary_key"> <?php 
            echo JHTML::_('tooltip', JText::_("PRIMARY KEY DESC"), JText::_('PRIMARY KEY'), 'tooltip.png', JText::_('PRIMARY KEY'));
            ?>
				</label></td>
				<td><?php 
            echo $lists['db_primary_key'];
            ?>
</td>
			</tr>
			<tr>
				<td class="key"><?php 
            echo JText::_('AUTO INCREMENT');
            ?>
</td>
				<td>
				<label>
					<input type="radio" name="auto_inc" value="0" <?php 
            echo $row->auto_inc ? '' : 'checked="checked"';
            ?>
 />
					<?php 
            echo JText::_('No');
            ?>
				</label>
				<label>
					<input type="radio" name="auto_inc" value="1" <?php 
            echo $row->auto_inc ? 'checked="checked"' : '';
            ?>
 />
					<?php 
            echo JText::_('YES');
            ?>
				</label>
				</td>
			</tr>
			<?php 
        }
        ?>
			<tr>
				<td class="key"><label for="order_by"><?php 
        echo JText::_('ORDER BY');
        ?>
</label></td>
				<td id="orderByTd"><?php 
        for ($o = 0; $o < count($lists['order_by']); $o++) {
            ?>
				<div class="orderby_container" style="margin-bottom:3px">
				<?php 
            echo $lists['order_by'][$o];
            ?>
				<?php 
            if ($row->id !== 0) {
                echo JArrayHelper::getValue($lists['order_dir'], $o, $lists['order_dir'][0]);
                ?>
					<a class="addOrder" href="#"><img src="components/com_fabrik/images/add.png" label="<?php 
                echo JText::_('ADD');
                ?>
" alt="<?php 
                echo JText::_('ADD');
                ?>
" /></a>
					<a class="deleteOrder" href="#"><img src="components/com_fabrik/images/remove.png" label="<?php 
                echo JText::_('REMOVE');
                ?>
" alt="<?php 
                echo JText::_('REMOVE');
                ?>
" /></a>
					<?php 
            }
            ?>
				</div>
				<?php 
        }
        ?>
				</td>
			</tr>
		</table>
		</fieldset>

		<fieldset><legend><?php 
        echo JText::_('GROUP BY');
        ?>
</legend>
		<table class="admintable">
			<tr>
				<td class="key"><label for="group_by"><?php 
        echo JText::_('GROUP BY');
        ?>
</label>
				</td>
				<td id="groupByTd"><?php 
        echo $lists['group_by'];
        ?>
</td>
			</tr>
		</table>
		<?php 
        echo $form->render('params', 'grouping');
        ?>
</fieldset>

		<fieldset><legend><?php 
        echo JHTML::_('tooltip', JText::_('PREFILTER DESC'), JText::_('PREFILTER'), 'tooltip.png', JText::_('PREFILTER'));
        ?>
</legend>
		<a class="addButton" href="#"
			onclick="oAdminFilters.addFilterOption(); return false;"><?php 
        echo JText::_('ADD');
        ?>
</a>
			<?php 
        echo $form->render('params', 'prefilter');
        ?>
		<table class="adminform" width="100%">
			<tbody id="filterContainer">
			</tbody>
		</table>
		</fieldset>

		<fieldset><legend> <?php 
        echo JHTML::_('tooltip', JText::_('JOIN DESC'), JText::_('JOINS'), 'tooltip.png', JText::_('JOINS'));
        ?>
		</legend> <?php 
        if ($row->id != 0) {
            ?>
 <a href="#" id="addAJoin"
			class="addButton"><?php 
            echo JText::_('ADD');
            ?>
</a>
		<div id="joindtd"></div>
		<?php 
            echo $form->render('params', 'joins');
            ?>
		<?php 
        } else {
            echo JText::_('Available once saved');
        }
        ?>
</fieldset>
		<fieldset><legend> <?php 
        echo JHTML::_('tooltip', JText::_('RELATED DATA DESC'), JText::_('RELATED DATA'), 'tooltip.png', JText::_('RELATED DATA'));
        ?>
		</legend> <?php 
        if (empty($lists['linkedtables'])) {
            echo "<i>" . JText::_('No other tables link here') . "</i>";
        } else {
            ?>
				<table class="adminlist linkedTables">
					<thead>
					<tr>
					<th></th>
						<th><?php 
            echo JText::_('TABLE');
            ?>
</th>
						<th><?php 
            echo JText::_('LINK TO TABLE');
            ?>
</th>
						<th><?php 
            echo JText::_('HEADING');
            ?>
</th>
						<th><?php 
            echo JText::_('BUTTON_TEXT');
            ?>
</th>
						<th><?php 
            echo JText::_('POPUP');
            ?>
</th>
					</tr>
				</thead>
				<tbody>
				<?php 
            $i = 0;
            foreach ($lists['linkedtables'] as $linkedTable) {
                ?>
			<tr class="row<?php 
                echo $i % 2;
                ?>
">
				<td class="handle"></td>
				<td><?php 
                echo JHTML::_('tooltip', $linkedTable[1], $linkedTable[0], 'tooltip.png', $linkedTable[0]);
                ?>
				<td><?php 
                echo $linkedTable[2];
                ?>
</td>
				<td><?php 
                echo $linkedTable[3];
                ?>
</td>
				<td><?php 
                echo $linkedTable[5];
                ?>
</td>
				<td><?php 
                echo $linkedTable[4];
                ?>
</td>
			</tr>
			<?php 
                $i++;
            }
            ?>
				</tbody>
			</table>
		<table class="adminlist linkedForms" style="margin-toip:20px">
			<thead>
				<tr>
					<th></th>
					<th><?php 
            echo JText::_('TABLE');
            ?>
</th>
					<th><?php 
            echo JText::_('LINK TO FORM');
            ?>
</th>
					<th><?php 
            echo JText::_('HEADING');
            ?>
</th>
					<th><?php 
            echo JText::_('BUTTON_TEXT');
            ?>
</th>
					<th><?php 
            echo JText::_('POPUP');
            ?>
</th>
				</tr>
			</thead>
			<tbody>
			<?php 
            $i = 0;
            foreach ($lists['linkedforms'] as $linkedForm) {
                ?>
			<tr class="row<?php 
                echo $i % 2;
                ?>
">
				<td class="handle"></td>
				<td><?php 
                echo JHTML::_('tooltip', $linkedForm['formhover'], $linkedForm[0], 'tooltip.png', $linkedForm[0]);
                ?>
				<td><?php 
                echo $linkedForm[1];
                ?>
</td>
				<td><?php 
                echo $linkedForm[2];
                ?>
</td>
				<td><?php 
                echo $linkedForm[4];
                ?>
</td>
				<td><?php 
                echo $linkedForm[3];
                ?>
</td>
			</tr>
			<?php 
                $i++;
            }
            ?>
			</tbody>
		</table>
		<?php 
        }
        ?>
</fieldset>

		<?php 
        echo $pane->startPanel(JText::_('PLUGINS'), "plugins-page");
        ?>
		<div id="plugins"></div>
		<a href="#" id="addPlugin" class="addButton"><?php 
        echo JText::_('ADD');
        ?>
</a>

		<?php 
        echo $pane->endPanel();
        echo $pane->endPane();
        ?>
</td>
	</tr>
</table>
	<input type="hidden" name="params[isview]" value="<?php 
        echo $params->get('isview', -1);
        ?>
" />
	<input type="hidden" name="option" value="com_fabrik" />
	<input type="hidden" name="task" value="saveTable" />
	<input type="hidden" name="c" value="table" />
	<input type="hidden" name="id" value="<?php 
        echo $row->id;
        ?>
" />
	<input type="hidden" name="fabrikid" value="<?php 
        echo $fabrikid;
        ?>
" />
	<?php 
        echo JHTML::_('form.token');
        echo JHTML::_('behavior.keepalive');
        ?>
	</form>

<?php 
        //$joinTypeOpts = "[['inner', '" . JText::_('INNER JOIN') ."'], ['left', '" . JText::_('LEFT JOIN') ."'], ['right', '" . JText::_('RIGHT JOIN') ."']]";
        $joinTypeOpts = array();
        $joinTypeOpts[] = array('inner', JText::_('INNER JOIN'));
        $joinTypeOpts[] = array('left', JText::_('LEFT JOIN'));
        $joinTypeOpts[] = array('right', JText::_('RIGHT JOIN'));
        $activetableOpts[] = "";
        $activetableOpts[] = $row->db_table_name;
        if (array_key_exists('joins', $lists)) {
            for ($i = 0; $i < count($lists['joins']); $i++) {
                $j = $lists['joins'][$i];
                $activetableOpts[] = $j->table_join;
                $activetableOpts[] = $j->join_from_table;
            }
        }
        $activetableOpts = array_unique($activetableOpts);
        $activetableOpts = array_values($activetableOpts);
        $joinLang = new stdClass();
        $joinLang->joinType = JText::_('JOIN TYPE');
        $joinLang->joinFromTable = JText::_('FROM');
        $joinLang->joinToTable = JText::_('TO');
        $joinLang->thisTablesIdCol = JText::_('FROM COLUMN');
        $joinLang->joinTablesIdCol = JText::_('TO COLUMN');
        $joinLang->del = JText::_('DELETE');
        $joinLang = FastJSON::encode($joinLang);
        $opts = new stdClass();
        $opts->joinOpts = $joinTypeOpts;
        $opts->tableOpts = $lists['defaultJoinTables'];
        $opts->activetableOpts = $activetableOpts;
        $opts = FastJSON::encode($opts);
        $filterOpts = new stdClass();
        $filterOpts->filterJoinDd = $model->getFilterJoinDd(false, 'params[filter-join][]');
        $filterOpts->filterCondDd = $model->getFilterConditionDd(false, 'params[filter-conditions][]', 2);
        //$filterOpts->filterAccess = addslashes(str_replace(array("\n", "\r"), '', $lists['filter-access']));
        $filterOpts->filterAccess = str_replace(array("\n", "\r"), '', $lists['filter-access']);
        $filterOpts = FastJSON::encode($filterOpts);
        $applyFilterText = defined('_JACL') ? 'APPLY FILTER TO' : 'APPLY FILTER BENEATH';
        $filterLang = new stdClass();
        $filterLang->join = JText::_('JOIN');
        $filterLang->field = JText::_('FIELD');
        $filterLang->condition = JText::_('CONDITION');
        $filterLang->value = JText::_('VALUE');
        $filterLang->eval = JText::_('EVAL');
        $filterLang->applyFilterTo = JText::_($applyFilterText);
        $filterLang->del = JText::_('DELETE');
        $filterLang->yes = JText::_('YES');
        $filterLang->no = JText::_('NO');
        $filterLang->query = JText::_('QUERY');
        $filterLang->noquotes = JTEXT::_('NOQUOTES');
        $filterLang->text = JText::_('TEXT');
        $filterLang->type = JText::_('TYPE');
        $filterLang->please_select = JText::_('COM_FABRIK_PLEASE_SELECT');
        $filterLang->grouped = JText::_('GROUPED');
        $filterLang = FastJSON::encode($filterLang);
        $script = "window.addEvent('domready', function() {\n\toAdminTable = new tableForm({$opts}, {$joinLang});\n\toAdminTable.watchJoins();\n";
        if (array_key_exists('joins', $lists)) {
            for ($i = 0; $i < count($lists['joins']); $i++) {
                $j = $lists['joins'][$i];
                $joinFormFields = FastJSON::encode($j->joinFormFields);
                $joinToFields = FastJSON::encode($j->joinToFields);
                $script .= "\toAdminTable.addJoin('{$j->group_id}','{$j->id}','{$j->join_type}','{$j->table_join}',";
                $script .= "'{$j->table_key}','{$j->table_join_key}','{$j->join_from_table}', {$joinFormFields}, {$joinToFields});\n";
            }
        }
        $filterfields = addslashes(str_replace(array("\n", "\r"), '', $lists['filter-fields']));
        $script .= "\toAdminFilters = new adminFilters('filterContainer', '{$filterfields}', {$filterOpts}, {$filterLang});\n";
        $afilterJoins = $params->get('filter-join', '', '_default', 'array');
        $afilterFields = $params->get('filter-fields', '', '_default', 'array');
        $afilterConditions = $params->get('filter-conditions', '', '_default', 'array');
        $afilterEval = $params->get('filter-eval', '', '_default', 'array');
        $afilterValues = $params->get('filter-value', '', '_default', 'array');
        $afilterAccess = $params->get('filter-access', '', '_default', 'array');
        $aGrouped = $params->get('filter-grouped', '', '_default', 'array');
        for ($i = 0; $i < count($afilterFields); $i++) {
            $selJoin = JArrayHelper::getValue($afilterJoins, $i, 'and');
            $selFilter = $afilterFields[$i];
            $grouped = $aGrouped[$i];
            $selCondition = $afilterConditions[$i];
            $filerEval = JArrayHelper::getValue($afilterEval, $i, '1');
            if ($selCondition == '&gt;') {
                $selCondition = '>';
            }
            if ($selCondition == '&lt;') {
                $selCondition = '<';
            }
            $selValue = JArrayHelper::getValue($afilterValues, $i, '');
            $selAccess = $afilterAccess[$i];
            //alow for multiline js variables ?
            $selValue = htmlspecialchars_decode($selValue, ENT_QUOTES);
            $selValue = FastJSON::encode($selValue);
            if ($selFilter != '') {
                $script .= "\toAdminFilters.addFilterOption('{$selJoin}', '{$selFilter}', '{$selCondition}', {$selValue}, '{$selAccess}', '{$filerEval}', '{$grouped}');\n";
            }
        }
        $script .= "\n});";
        $document->addScriptDeclaration($script);
        $session =& JFactory::getSession();
        $session->clear('com_fabrik.admin.table.edit.model');
    }
Exemple #8
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();
 }
Exemple #9
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();
 }
 function elementJavascriptOpts($repeatCounter)
 {
     $id = $this->getHTMLId($repeatCounter);
     $params =& $this->getParams();
     $element =& $this->getElement();
     //$opts = $this->_getOptionVals();
     $data =& $this->_form->_data;
     $arSelected = $this->getValue($data, $repeatCounter);
     $arVals = explode("|", $element->sub_values);
     $arTxt = explode("|", $element->sub_labels);
     $table = $params->get('join_db_name');
     $opts =& $this->getElementJSOptions($repeatCounter);
     $forms =& $this->getLinkedForms();
     $popupform = $params->get('fabrikdatabasejoin_popupform');
     $popuptableid = empty($popupform) || !isset($forms[$popupform]) ? '' : $forms[$popupform]->tableid;
     $opts->mooversion = FabrikWorker::getMooVersion() == 1 ? 1.2 : 1.1;
     $opts->liveSite = COM_FABRIK_LIVESITE;
     $opts->id = $this->_id;
     $opts->key = $table . "___" . $params->get('join_key_column');
     $opts->label = $table . "___" . $params->get('join_val_column');
     $opts->formid = $this->getForm()->getForm()->id;
     $opts->tableid = $popuptableid;
     $opts->value = $arSelected;
     $opts->defaultVal = $this->getDefaultValue($data);
     $opts->popupform = $popupform;
     $opts->popwiny = $params->get('yoffset', 0);
     $opts->display_type = $params->get('database_join_display_type', 'dropdown');
     $opts->windowwidth = $params->get('join_popupwidth', 360);
     $opts->displayType = $params->get('database_join_display_type', 'dropdown');
     $opts->show_please_select = $params->get('database_join_show_please_select');
     $opts->showDesc = $params->get('join_desc_column') === '' ? false : true;
     $opts->autoCompleteOpts = $opts->display_type == 'auto-complete' ? FabrikHelperHTML::autoCompletOptions($id, $this->getElement()->id, 'fabrikdatabasejoin') : null;
     $opts->allowadd = $params->get('fabrikdatabasejoin_frontend_add', 0) == 0 ? false : true;
     if ($this->isJoin()) {
         $join =& $this->getJoin();
         $opts->elementName = $join->table_join;
         $opts->elementShortName = $element->name;
     }
     $opts = json_encode($opts);
     return $opts;
 }
Exemple #11
0
 /**
  * add a debug out put section
  * @param mixed string/object $content
  * @param string $title
  */
 function debug($content, $title = 'output:')
 {
     $config =& JComponentHelper::getParams('com_fabrik');
     if ($config->get('use_fabrikdebug') == 0) {
         return;
     }
     if (FabrikWorker::getMooVersion() == -1) {
         return;
     }
     if (JRequest::getBool('fabrikdebug', 0, 'request') != 1) {
         return;
     }
     if (JRequest::getVar('format') == 'raw') {
         return;
     }
     echo "<div class=\"fabrikDebugOutputTitle\">{$title}</div>";
     echo "<div class=\"fabrikDebugOutput fabrikDebugHidden\">";
     if (is_object($content) || is_array($content)) {
         echo "<pre>";
         print_r($content);
         echo "</pre>";
     } else {
         echo $content;
     }
     echo "</div>";
     static $debug;
     if (!isset($debug)) {
         $debug = true;
         $document =& JFactory::getDocument();
         $style = ".fabrikDebugOutputTitle{padding:5px;background:#efefef;color:#333;border:1px solid #999;cursor:pointer}";
         $style .= ".fabrikDebugOutput{padding:5px;background:#efefef;color:#999;}";
         $style .= ".fabrikDebugOutput pre{padding:5px;background:#efefef;color:#999;}";
         $style .= ".fabrikDebugHidden{display:none}";
         $document->addStyleDeclaration($style);
         $script = "window.addEvent('domready', function() {\n\t\t\t\$\$('.fabrikDebugOutputTitle').each(function(title) {\n\t\t\t\ttitle.addEvent('click', function(e) {\n\t\t\t\t\ttitle.getNext().toggleClass('fabrikDebugHidden');\n\t\t\t\t});\n\t\t\t});\n\t\t\t})";
         FabrikHelperHTML::addScriptDeclaration($script);
     }
 }
Exemple #12
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;
 }
Exemple #13
0
 /**
  * create a class for the elements default javascript options
  * @param int repeat group counter
  *	@return object options
  */
 function getElementJSOptions($repeatCounter)
 {
     $element =& $this->getElement();
     $opts = new stdClass();
     $opts->splitter = GROUPSPLITTER2;
     $data =& $this->_form->_data;
     $opts->repeatCounter = $repeatCounter;
     $opts->editable = $this->canView() && !$this->canUse() ? false : $this->_editable;
     $opts->value = $this->getValue($data, $repeatCounter);
     $opts->defaultVal = $this->getDefaultValue($data);
     $opts->mooversion = FabrikWorker::getMooVersion() == 1 ? 1.2 : 1.1;
     $validationEls = array();
     $validations =& $this->getValidations();
     if (!empty($validations) && $this->_editable) {
         $watchElements = $this->getValidationWatchElements($repeatCounter);
         foreach ($watchElements as $watchElement) {
             $o = new stdClass();
             $o->id = $watchElement['id'];
             $o->triggerEvent = $watchElement['triggerEvent'];
             $validationEls[] = $o;
         }
     }
     $opts->watchElements = $validationEls;
     $groupModel = $this->getGroup();
     $opts->canRepeat = $groupModel->canRepeat() == '1';
     $opts->isGroupJoin = $groupModel->isJoin() == '1';
     if ($this->isJoin()) {
         $opts->joinid = (int) $this->getJoinModel()->getJoin()->id;
     } else {
         $opts->joinid = (int) $groupModel->getGroup()->join_id;
     }
     return $opts;
 }