Пример #1
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 
    }
Пример #2
0
 /**
  * Display the list of forms
  */
 function display()
 {
     $app =& JFactory::getApplication();
     $db =& JFactory::getDBO();
     $user =& JFactory::getUser();
     // get the total number of records
     $context = 'com_fabrik.form.list.';
     $filter_order = $app->getUserStateFromRequest($context . 'filter_order', 'filter_order', 'f.label', 'cmd');
     $filter_order_Dir = $app->getUserStateFromRequest($context . 'filter_order_Dir', 'filter_order_Dir', '', 'word');
     $limit = $app->getUserStateFromRequest($context . 'limit', 'limit', $app->getCfg('list_limit'), 'int');
     $limitstart = $app->getUserStateFromRequest($context . 'limitstart', 'limitstart', 0, 'int');
     $filter_form = $app->getUserStateFromRequest($context . "filter_form", 'filter_form', '');
     // table ordering
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     $where = array();
     if ($filter_form != '') {
         $where[] = " f.label LIKE '%{$filter_form}%' ";
     }
     /*if ($user->gid <= 24) {
     		$where[] = " f.private = '0'";
     		}*/
     $where = count($where) ? ' WHERE ' . implode(' AND ', $where) : '';
     $orderby = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir;
     $db->setQuery("SELECT count(*) FROM #__fabrik_forms AS f {$where}");
     $total = $db->loadResult();
     jimport('joomla.html.pagination');
     $pageNav = new JPagination($total, $limitstart, $limit);
     $sql = "SELECT *, u.name AS editor, f.id AS id, t.id as _table_id, f.state AS state\n\t\t, f.label, f.attribs AS attribs FROM #__fabrik_forms AS f" . "\n LEFT JOIN #__users AS u ON u.id = f.checked_out " . "\n LEFT JOIN #__fabrik_tables as t ON f.id = t.form_id" . "\n {$where} {$orderby}";
     $db->setQuery($sql, $pageNav->limitstart, $pageNav->limit);
     $rows = $db->loadObjectList();
     if ($db->getErrorMsg() != '') {
         JError::raiseError(500, $db->getErrorMsg());
     }
     $lists['filter_form'] = '<input type="text" value="' . $filter_form . '" name="filter_form" onblur="document.adminForm.submit();" />';
     require_once JPATH_COMPONENT . DS . 'views' . DS . 'form.php';
     FabrikViewForm::show($rows, $pageNav, $lists);
 }