Esempio n. 1
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');
    }
Esempio n. 2
0
    /**
     * Display the form to add or edit a package
     * @param object package
     * @param object parameters from attributes
     * @param array lists
     */
    function edit($row, $tables, $lists)
    {
        FabrikHelperHTML::mootools();
        JHTML::stylesheet('fabrikadmin.css', 'administrator/components/com_fabrik/views/');
        JRequest::setVar('hidemainmenu', 1);
        jimport('joomla.html.pane');
        $pane =& JPane::getInstance();
        FabrikViewPackage::setPackageToolbar();
        FabrikHelperHTML::script('adminpackage.js', 'administrator/components/com_fabrik/views/', true);
        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="30" value="<?php 
        echo $row->label;
        ?>
" /></td>
					</tr>
					<tr>
						<td class="key" valign="top"  style="text-align:right">
						<label for="state"><?php 
        echo JText::_('PUBLISHED');
        ?>
</label>
						</td>
						<td>
						<input type="checkbox" id="state" name="state" value="1" <?php 
        echo $row->state ? 'checked="checked"' : '';
        ?>
 />
						</td>
					</tr>
					<tr>
						<td class="key" valign="top"  style="text-align:right">
							<label for="template"><?php 
        echo JText::_('TEMPLATE');
        ?>
</label>
						</td>
						<td>
						<?php 
        echo $lists['template'];
        ?>
						</td>
					</tr>
				</table>
				</fieldset>
				<fieldset class="adminform">
				<legend><?php 
        echo JText::_('TABLES');
        ?>
</legend>
				
				<table class="admintable"> 
					
					<?php 
        foreach ($tables as $table) {
            ?>
					<tr class="packageTable" >
						<td><?php 
            echo $table;
            ?>
</td>
						<td style="width:5em"><a href="#" class="addButton"><?php 
            echo JText::_('ADD');
            ?>
</a></td>
						<td><a href="#" class="removeButton"><?php 
            echo JText::_('DELETE');
            ?>
</a></td>
					</tr> 
					<?php 
        }
        ?>
				</table>
				</fieldset>
				</td>
				<td style="width:50%;"  valign="top">
			
				<?php 
        echo $pane->endPanel();
        echo $pane->endPane();
        ?>
				</td>
			</tr>
		</table>
		<input type="hidden" name="option" value="com_fabrik" /> 
		<input type="hidden" name="c" value="package" />
		<input type="hidden" name="task" value="savePackage" /> 
		<input type="hidden" name="id" value="<?php 
        echo $row->id;
        ?>
" /> 	
		<input type="hidden" name="cid[]" value="<?php 
        echo $row->id;
        ?>
" />
		<?php 
        echo JHTML::_('form.token');
        echo JHTML::_('behavior.keepalive');
        ?>
	</form>
	<?php 
    }
Esempio n. 3
0
    /**
     * Display the form to add or edit an form
     * @param object form table
     * @param object plugin manager
     * @param array lists
     * @param object parameters from attributes
     * @param object form - used to render xml form cdoe
     */
    function edit($row, $pluginManager, $lists, $params, &$form)
    {
        FabrikHelperHTML::mootools();
        JHTML::stylesheet('fabrikadmin.css', 'administrator/components/com_fabrik/views/');
        jimport('joomla.html.pane');
        JRequest::setVar('hidemainmenu', 1);
        $pane =& JPane::getInstance();
        FabrikHelperHTML::tips();
        FabrikViewForm::setFormToolbar();
        $editor =& JFactory::getEditor();
        $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('adminform.js', 'administrator/components/com_fabrik/views/', true);
        JFilterOutput::objectHTMLSafe($row);
        $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->front_end = JText::_('FRONT END');
        $lang->back_end = JText::_('BACK END');
        $lang->both = JText::_('BOTH');
        $lang->new = JText::_('NEW');
        $lang->edit = JText::_('EDIT');
        $lang = FastJSON::encode($lang);
        $js = "\n  window.addEvent('load', function() {\n  \tvar lang = {$lang};\n";
        $js .= $pluginManager->getAdminPluginJs('form', $row, $lists);
        $js .= "controller = new fabrikAdminForm(aPlugins, lang);\n";
        $js .= $pluginManager->getAdminSelectedPluginJS('form', $row, $lists, $params);
        jimport('joomla.html.editor');
        $js .= "\n});\n\nfunction submitbutton(pressbutton) {\n\n\tvar form = document.adminForm;" . $editor->save('intro') . "\n\tif (pressbutton == 'cancel') {\n\t\tsubmitform( pressbutton);\n\t\treturn;\n\t}\n\n\t/* do field validation */\n\tvar err = '';\n\n\tif (form.label.value == '') {\n\t\terr = err + '" . JText::_('PLEASE ENTER A FORM LABEL', true) . '\\n' . "';\n\t}\n\n\tif(form.record_in_database.checked == true && form._database_name.value == '') {\n\t\terr = err + '" . JText::_('PLEASE ENTER A DATABASE TABLE NAME', true) . "';\n\t}\n\tif (err == '') {\n\t\t/* assemble the form groups back into one field */\n\t\tmergeFormGroups()\n\t\tsubmitform( pressbutton);\n\t}else{\n\t\talert (err);\n\t}\n}\n\nfunction mergeFormGroups() {\n\t/* assemble the form groups back into one field */\n\tvar tmp = [];\n\tif(\$('current_groups')) {\n\t\tvar opts = \$('current_groups').options;\n\t\tfor (var i=0, n=opts.length; i < n; i++) {\n\t\t\ttmp.push(opts[i].value);\n\t\t}\n\t\t\$('current_groups_str').value = tmp.join(',');\n\t}\n}\n";
        $document->addScriptDeclaration($js);
        FabrikHelperHTML::cleanMootools();
        ?>
		<form action="index.php" method="post" name="adminForm" id="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" width="30%">
							<?php 
        echo JHTML::_('tooltip', JText::_('FROM LABEL DESC'), JText::_('LABEL'), 'tooltip.png', JText::_('LABEL'));
        ?>
							</td>
							<td width="70%">
								<input class="inputbox" type="text" name="label" id="label" size="50" value="<?php 
        echo $row->label;
        ?>
" />
							</td>
						</tr>
						<tr>
							<td class="key"><?php 
        echo JText::_('INTRODUCTION');
        ?>
</td>
							<td><?php 
        echo $editor->display('intro', $row->intro, '100%', '200', '50', '5', false);
        ?>
							</td>
						</tr>
						<tr>
							<td class="key">
								<label for="error">
								<?php 
        echo JHTML::_('tooltip', JText::_('FROM ERROR MESSAGE DESC'), JText::_('ERROR MESSAGE'), 'tooltip.png', JText::_('ERROR MESSAGE', true));
        ?>
								</label>
							</td>
							<td>
								<input class="inputbox" type="text" name="error" id="error" size="50" value="<?php 
        echo $row->error;
        ?>
" />
							</td>
						</tr>
					</table>
				</fieldset>
				<fieldset class="adminform">
				<legend><?php 
        echo JText::_('BUTTONS');
        ?>
</legend>
						<?php 
        echo $form->render('params', 'buttons');
        ?>
						<table class="admintable">
						<tr>
							<td class="key">
								<label for="submit_button_label">
								<?php 
        echo JText::_('SUBMIT LABEL');
        ?>
								</label>
							</td>
							<td>
								<input type="text" class="inputbox" id="submit_button_label" name="submit_button_label" value="<?php 
        echo $row->submit_button_label;
        ?>
" />
							</td>
						</tr>
					</table>
				</fieldset>
				<fieldset class="adminform">
				<legend><?php 
        echo JText::_('FORM PROCESSING');
        ?>
</legend>
					<table class="admintable">
						<tr>
							<td class="key">
							<label for="record_in_database">
							<?php 
        echo JText::_('RECORD IN DATABASE');
        ?>
							</label>
							</td>
							<td>
							<input type="checkbox" id="record_in_database" name="record_in_database" value="1" <?php 
        if ($row->record_in_database == '1') {
            echo " checked=\"checked\"";
        }
        ?>
 />
							</td>
						</tr>
						<tr>
							<td class="key">
							<label for="database_name">
							<?php 
        echo JText::_('TABLE NAME');
        ?>
							</label>
							</td>
							<td>
							<?php 
        if ($row->record_in_database != '1') {
            ?>
								<input id="database_name" name="_database_name" value="" size="40" />
							<?php 
        } else {
            ?>
									<?php 
            echo $row->_database_name;
            ?>
									<input type="hidden" id="database_name" name="_database_name" value="<?php 
            echo $row->_database_name;
            ?>
"  />
									<input type="hidden" id="_connection_id" name="_connection_id" value="<?php 
            echo $row->_connection_id;
            ?>
"  />
							<?php 
        }
        ?>
							</td>
						</tr>
				</table>
				<?php 
        echo $form->render('params', 'processing');
        ?>
			</fieldset>
			<fieldset>
				<legend><?php 
        echo JText::_('Notes');
        ?>
</legend>
					<?php 
        echo $form->render('params', 'notes');
        ?>
			</fieldset>
					</td>
					<td valign="top">
					<?php 
        echo $pane->startPane("content-pane");
        echo $pane->startPanel('Publishing', "publish-page");
        echo $form->render('details');
        echo $pane->endPanel();
        echo $pane->startPanel(JText::_('GROUPS'), "formgroups-page");
        ?>
		<table class="adminform">
			<tr>
				<th colspan="2"><?php 
        echo JText::_('GROUPS');
        ?>
</th>
			</tr>
			<tr>
				<td colspan="2"><label>
				<?php 
        $checked = empty($lists['current_groups']) ? 'checked="checked"' : '';
        ?>
				<input type="checkbox" <?php 
        echo $checked;
        ?>
 name="_createGroup" id="_createGroup" value="1" />
				<?php 
        echo JText::_('CREATE A GROUP WITH THE SAME NAME AS THIS FORM');
        ?>
				</label></td>
			</tr>
			<?php 
        if (empty($lists['groups']) && empty($lists['current_groups'])) {
            ?>
			<tr>
				<td>
				<?php 
            echo JText::_('NO GROUPS AVAILABLE');
            ?>
				<input type="hidden" name="_createGroup" id="_createGroup" value="1" />
				</td>
			</tr>
			<?php 
        } else {
            ?>

			<tr>
				<td colspan="2"><p><?php 
            echo JText::_('AVAILABLE GROUPS');
            ?>
: </p>
				<?php 
            echo $lists['grouplist'];
            ?>
</td>
			</tr>
			<tr>
				<td colspan="2">
					<input class="button" type="button" value="<?php 
            echo JText::_('ADD');
            ?>
"
					onclick="$('_createGroup').checked = false;addSelectedToList('adminForm','groups','current_groups');delSelectedFromList('adminForm','groups');" />
				</td>
			</tr>
			<tr>
				<td colspan="2"><p><?php 
            echo JText::_('CURRENT GROUPS');
            ?>
: </p>
				<?php 
            echo $lists['current_grouplist'];
            ?>
</td>
			</tr>
			<tr>
				<td colspan="2"><input class="button" type="button"
					value="<?php 
            echo JText::_('UP');
            ?>
"
					onclick="moveInList('adminForm','current_groups',adminForm.current_groups.selectedIndex,-1)" />
				<input class="button" type="button" value="<?php 
            echo JText::_('DOWN');
            ?>
"
					onclick="moveInList('adminForm','current_groups',adminForm.current_groups.selectedIndex,+1)" />
				<input class="button" type="button" value="<?php 
            echo JText::_('REMOVE');
            ?>
"
					onclick="addSelectedToList('adminForm', 'current_groups', 'groups');delSelectedFromList('adminForm','current_groups');" />
				</td>
			</tr>
			<?php 
        }
        ?>
		</table>
		<?php 
        echo $form->render('params', 'groups');
        echo $pane->endPanel();
        echo $pane->startPanel(JText::_('TEMPLATES'), "template-page");
        ?>
		<table class="paramlist admintable">
			<tr>
				<td class="paramlist_key"><?php 
        echo JText::_('DETAILED VIEW TEMPLATE');
        ?>
</td>
				<td class="paramlist_value"><?php 
        echo $lists['viewOnlyTemplates'];
        ?>
</td>
			</tr>
			<tr>
				<td class="paramlist_key"><?php 
        echo JText::_('FORM TEMPLATE');
        ?>
</td>
				<td class="paramlist_value"><?php 
        echo $lists['formTemplates'];
        ?>
</td>
			</tr>
		</table>
		<?php 
        echo $form->render('params', 'templates');
        echo $pane->endPanel();
        echo $pane->startPanel(JText::_('OPTIONS'), "menu-page");
        echo $form->render('params', 'options');
        ?>
		<fieldset>
		<legend><?php 
        echo JText::_('CCK');
        ?>
</legend>
		<?php 
        echo $form->render('params', 'cck');
        ?>
		</fieldset>
		<?php 
        echo $pane->endPanel();
        echo $pane->startPanel('Submission plug-ins', "actions-page");
        ?>
			<div id="plugins"></div>
			<a href="#" class="addButton" id="addPlugin"><?php 
        echo JText::_('ADD');
        ?>
</a>
		<?php 
        echo $pane->endPanel();
        echo $pane->endPane();
        ?>
			</td>
		</tr>
	</table>
	<input type="hidden" name="task" id="task" value="" />
	<input type="hidden" name="option" value="com_fabrik" />
	<input type="hidden" name="c" value="form" />
	<input type="hidden" name="id" value="<?php 
        echo $row->id;
        ?>
" />
	<input type="hidden" name="boxchecked" value="" />
	<input type="hidden" name="current_groups_str" id="current_groups_str" value="" />
	<?php 
        echo JHTML::_('form.token');
        echo JHTML::_('behavior.keepalive');
        ?>
</form>
	<?php 
    }
Esempio n. 4
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();
     }
 }
Esempio n. 5
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();
 }
Esempio n. 6
0
 function editJs($row, $pluginManager, $lists, $params)
 {
     FabrikHelperHTML::mootools();
     FabrikHelperHTML::tips();
     $fbConfig =& JComponentHelper::getParams('com_fabrik');
     FabrikHelperHTML::script('namespace.js', 'administrator/components/com_fabrik/views/', true);
     //FabrikHelperHTML::script('element.js', 'components/com_fabrik/views/form/', true);
     FabrikHelperHTML::script('adminelement.js', 'administrator/components/com_fabrik/views/', true);
     $document =& JFactory::getDocument();
     $js = "/* <![CDATA[ */\n\n\tfunction submitbutton(pressbutton) {\n\t\tvar adminform = document.adminForm;\n\t\t/*  do field validation */\n\t\tif (pressbutton == 'cancel') {\n\t\t\tsubmitform( pressbutton);\n\t\t\treturn;\n   \t}\n   \tif(\$('javascriptActions').getElements('select[name^=js_action]').get('value').contains('')) {\n   \t\talert('" . JText::_('ENSURE_JS_EVENT_SELECTED', true) . "');\n   \t\treturn;\n   \t}\n\n   \tvar empty = \$('javascriptActions').getElements('select[name^=js_e_condition]').some(function(s) {\n   \t\tvar c = s.findClassUp('adminform');\n   \t\treturn (c.getElement('textarea').get('value') == '' && s.get('value') == '');\n   \t});\n   \tif(empty) {\n   \t\talert('" . JText::_('ENSURE_JS_CONDITION_SELECTED', true) . "');\n   \t\treturn;\n   \t}\n\n   \tvar myRegxp = /^([a-zA-Z0-9_]+)\$/;\n\n\t\tif(myRegxp.test(adminform.name.value)==false || adminform.name.value.indexOf('___') != -1) {\n\t\t\talert( '" . JText::_('PLEASE_ENTER_A_VALID_ELEMENTNAME', true) . "');\n\t\t} else {\n\t\t\tsubmitbutton2( pressbutton);\n\t\t}\n\t}\n\n\tfunction submitbutton2(pressbutton) {";
     if ($fbConfig->get('fbConf_wysiwyg_label', false)) {
         $editor =& FabrikHelperHTML::getEditor();
         $js .= $editor->save('label');
     }
     $js .= "//iternate through the plugin controllers to match selected plugin\n\t\tvar adminform = document.adminForm;\n\t\tvar er = false;\n\n\t\t\$A(pluginControllers).each(function(plugin) {\n\t\t\tif(\$('detailsplugin').value == plugin.element) {\n\t\t\t\tvar r = plugin.controller.onSave();\n\t\t\t\tif(r == false) {\n\t\t\t\t\ter = true;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tif(er === false) {\n\t\t\tsubmitform( pressbutton);\n\t\t}\n\t\treturn false;\n\t}\n\twindow.addEvent('domready', function() {\n";
     $opts = new stdClass();
     $opts->plugin = $row->plugin;
     $opts->parentid = $row->parent_id;
     $opts->jsevents = $lists['jsActions'];
     $opts->elements = $lists['elements'];
     $js .= "\tvar options = " . FastJSON::encode($opts) . ";\n";
     $js .= "\tvar lang = {'jsaction':'" . JText::_('ACTION') . "','code':'" . JText::_('CODE') . "'};\n" . "var aPlugins = [];\n";
     $c = 0;
     //	set up the template code for creating validation plugin interfaces
     foreach ($pluginManager->_plugIns['validationrule'] as $usedPlugin => $oPlugin) {
         $pluginParams = new fabrikParams('', $oPlugin->_xmlPath, 'fabrikplugin');
         $oPlugin->_pluginParams =& $pluginParams;
         $pluginParams->_duplicate = true;
         $oPlugin->_adminVisible = false;
         $o = new stdClass();
         $o->{$usedPlugin} = $oPlugin->_pluginLabel;
         $o->value = $usedPlugin;
         $o->label = $oPlugin->_pluginLabel;
         $o->html = $oPlugin->renderAdminSettings($usedPlugin, $row, $pluginParams, 0);
         $o = FastJSON::encode($o);
         $js .= "aPlugins.push({$o});\n";
         $c++;
     }
     $js .= "\tvar controller = new fabrikAdminElement(aPlugins, options, lang);\n";
     //add in active validations
     $usedPlugins = $params->get('validation-plugin', '', '_default', 'array');
     $c = 0;
     foreach ($usedPlugins as $usedPlugin) {
         $plugin =& $pluginManager->_plugIns['validationrule'][$usedPlugin];
         $plugin->renderOrder = $c;
         unset($plugin->pluginParams);
         $pluginParams = $plugin->setParams($params);
         $pluginParams->_duplicate = true;
         $names = $pluginParams->_getParamNames();
         $plugin->_adminVisible = true;
         $plugin->_counter = $c;
         //@TODO isnt this the same as renderOrder?
         $data = $oPlugin->renderAdminSettings($usedPlugin, $row, $pluginParams, $lists, 0);
         $data = addslashes(str_replace("\n", "", $data));
         $js .= "controller.addValidation('" . $data . "', '" . $usedPlugins[$c] . "');\n";
         $c++;
     }
     foreach ($pluginManager->_plugIns['element'] as $key => $tmp) {
         $oPlugin =& $pluginManager->_plugIns['element'][$key];
         //do this to reduce the number of queries
         $oPlugin->_element =& $row;
         if (is_a($oPlugin, 'FabrikModelElement')) {
             $oPlugin->setId($row->id);
         } else {
             JError::raiseError(500, "could not load {$key}");
             jexit();
         }
         $js .= $oPlugin->getAdminJS();
     }
     $js .= "});\n\t\t/* ]]> */";
     $document->addScriptDeclaration($js);
 }
Esempio n. 7
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();
 }
Esempio n. 8
0
 /**
  *
  * @param $selector string class name of tips
  * @param $params array paramters
  * @param $selectorPrefix limit the tips selection to those contained within an id
  * @return unknown_type
  */
 function tips($selector = '.hasTip', $params = array(), $selectorPrefix = 'document')
 {
     static $tips;
     if (!isset($tips)) {
         $tips = array();
     }
     // Include mootools framework
     FabrikHelperHTML::mootools();
     $sig = md5(serialize(array($selector, $params)));
     if (isset($tips[$sig]) && $tips[$sig]) {
         return;
     }
     // Setup options object
     $opt['maxTitleChars'] = isset($params['maxTitleChars']) && $params['maxTitleChars'] ? (int) $params['maxTitleChars'] : 50;
     if (isset($params['offsets'])) {
         $opt['offsets'] = (int) $params['offsets'];
     }
     if (isset($params['showDelay'])) {
         $opt['showDelay'] = (int) $params['showDelay'];
     }
     if (isset($params['hideDelay'])) {
         $opt['hideDelay'] = (int) $params['hideDelay'];
     }
     if (isset($params['className'])) {
         $opt['className'] = $params['className'];
     }
     $opt['fixed'] = isset($params['fixed']) && $params['fixed'] ? true : false;
     if (isset($params['onShow'])) {
         $opt['onShow'] = $params['onShow'];
     }
     if (isset($params['onHide'])) {
         $opt['onHide'] = $params['onHide'];
     }
     $options = json_encode($opt);
     // Attach tooltips to document
     $document =& JFactory::getDocument();
     //force the zindex to 9999 so that it appears above the popup window.
     $event = JRequest::getVar('tmpl') == 'component' ? 'load' : 'domready';
     $tooltipInit = '		window.addEvent(\'' . $event . '\', function() {if($type(' . $selectorPrefix . ') !== false && ' . $selectorPrefix . '.getElements(\'' . $selector . '\').length !== 0) {window.JTooltips = new Tips(' . $selectorPrefix . '.getElements(\'' . $selector . '\'), ' . $options . ');$$(".tool-tip").setStyle("z-index", 999999);}});';
     FabrikHelperHTML::addScriptDeclaration($tooltipInit);
     // Set static array
     $tips[$sig] = true;
     return;
 }
Esempio n. 9
0
    /** 
     * edits a database connection
     * @param object connection
     */
    function edit($row)
    {
        FabrikHelperHTML::mootools();
        FabrikViewConenction::setConnectionToolbar();
        JRequest::setVar('hidemainmenu', 1);
        $app =& JFactory::getApplication();
        $config =& JFactory::getConfig();
        if ($row->id == 1) {
            $app->enqueueMessage(JText::_('THIS IS THE ORIGINAL CONNECTION'));
            if (!($config->getValue('host') == $row->host && $config->getValue('user') == $row->user && $config->getValue('password') == $row->password && $config->getValue('db') == $row->database)) {
                JError::raiseWarning(E_WARNING, JText::_('YOUMUSTSAVETHISCNN'));
            }
            $row->host = $config->getValue('host');
            $row->user = $config->getValue('user');
            $row->password = $config->getValue('password');
            $row->database = $config->getValue('db');
        }
        FabrikHelperHTML::cleanMootools();
        ?>
		<form action="index.php" method="post" name="adminForm"> 
		<div class="col100">
			<fieldset class="adminform">
				<legend><?php 
        echo JText::_('DETAILS');
        ?>
</legend>
		<table class="admintable">
		<tbody>
			<tr>
				<td valign="top" class="key">
					<label for="description"><?php 
        echo JText::_('DESCRIPTION');
        ?>
</label>
				</td>
				<td><input class="inputbox" type="text" id="description" name="description" size="75" value="<?php 
        echo $row->description;
        ?>
" /></td>
			</tr>
			<tr>
				<td valign="top" class="key">
					<label for="host"><?php 
        echo JText::_('HOST');
        ?>
</label>
				</td>
				<td><input class="inputbox" type="text" id="host" name="host" size="75" value="<?php 
        echo $row->host;
        ?>
" /></td>
			</tr>
			<tr>
		<td valign="top" class="key">
			<label for="database"><?php 
        echo JText::_('DATABASE');
        ?>
</label>
		</td>
		<td><input class="inputbox" type="text" id="database" name="database" size="75" value="<?php 
        echo $row->database;
        ?>
" /></td>
			</tr> 
			<tr>
				<td valign="top" class="key">
					<label for="user"><?php 
        echo JText::_('USER');
        ?>
</label>
				</td>
				<td><input class="inputbox" type="text" name="user" id="user" size="75" value="<?php 
        echo $row->user;
        ?>
" /></td>
			</tr>
			<?php 
        if ($row->host != "") {
            ?>
				<tr>
				<td valign="top" class="key"><?php 
            echo JText::_('ENTER PASSWORD OR LEAVE AS IS');
            ?>
</td>
				<td></td>
			</tr>	
			<?php 
        }
        ?>
		
			<tr>
				<td valign="top" class="key">
					<label for="password"><?php 
        echo JText::_('PASSWORD');
        ?>
</label>
				</td>
				<td><input class="inputbox" type="password" id="password" name="password" size="20" value="<?php 
        echo $row->password;
        ?>
" /></td>
			</tr>
			<tr>
				<td valign="top" class="key">
					<label for="passwordConf"><?php 
        echo JText::_('CONFIRM PASSWORD');
        ?>
</label>
				</td>
				<td><input class="inputbox" type="password" id="passwordConf" name="passwordConf" size="20" value="<?php 
        echo $row->password;
        ?>
" /></td>
			</tr>			
			<tr>
				<td valign="top" class="key"><label for="state"><?php 
        echo JText::_('PUBLISHED');
        ?>
</label></td>
				<td>
					<input type="checkbox" id="state" name="state" value="1" <?php 
        echo $row->state ? 'checked="checked"' : '';
        ?>
 />
				</td>
			</tr>
			<tbody>					
		</table>
		<input type="hidden" name="option" value="com_fabrik" /> 
		<input type="hidden" name="task" value="save" />
		<input type="hidden" name="c" value="connection" /> 
		<input type="hidden" name="id" value="<?php 
        echo $row->id;
        ?>
" />
		</fieldset>
		</div>
		<?php 
        echo JHTML::_('form.token');
        echo JHTML::_('behavior.keepalive');
        ?>
	</form>
<?php 
    }