encode() 공개 메소드

FastJSON::encode(params:*):String
public encode ( $decode ) : String
리턴 String JSON genric object rappresentation or empty string if param is not compatible.
예제 #1
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     static $fabrikelements;
     if (!isset($fabrikelements)) {
         $fabrikelements = array();
     }
     FabrikHelperHTML::script('element.js', 'administrator/components/com_fabrik/elements/', true);
     $document =& JFactory::getDocument();
     $c = ElementHelper::getRepeatCounter($this);
     $conn = $c === false || $node->attributes('connection_in_repeat') == 'false' ? $node->attributes('connection') : $node->attributes('connection') . '-' . $c;
     $table = $node->attributes('table');
     $include_calculations = (int) $node->attributes('include_calculations', 0);
     $published = (int) $node->attributes('published', 0);
     $showintable = (int) $node->attributes('showintable', 0);
     if ($include_calculations != 1) {
         $include_calculations = 0;
     }
     $cnns = array(JHTML::_('select.option', '-1', JText::_('COM_FABRIK_PLEASE_SELECT')));
     $id = ElementHelper::getId($this, $control_name, $name);
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     $repeat = ElementHelper::getRepeat($this);
     if (!array_key_exists($id, $fabrikelements)) {
         $script = "window.addEvent('domready', function() {\n";
         $opts = new stdClass();
         $opts->table = $c === false ? 'params' . $table : 'params' . $table . "-" . $c;
         $opts->published = $published;
         $opts->showintable = $showintable;
         $opts->excludejoined = (int) $node->attributes('excludejoined', 0);
         $opts->livesite = COM_FABRIK_LIVESITE;
         $opts->conn = 'params' . $conn;
         $opts->value = $value;
         $opts->include_calculations = $include_calculations;
         $opts = FastJSON::encode($opts);
         $script .= "var p = new elementElement('{$id}', {$opts});\n";
         $script .= "Fabrik.adminElements.set('{$id}', p);\n";
         $script .= "});\n";
         $document->addScriptDeclaration($script);
         $fabrikelements[$id] = true;
     }
     FabrikHelperHTML::cleanMootools();
     $return = JHTML::_('select.genericlist', $cnns, $fullName, 'class="inputbox element"', 'value', 'text', $value, $id);
     $return .= '<img style="margin-left:10px;display:none" id="' . $id . '_loader" src="components/com_fabrik/images/ajax-loader.gif" alt="' . JText::_('LOADING') . '" />';
     return $return;
 }
예제 #2
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     static $fabriktables;
     if (!isset($fabriktables)) {
         $fabriktables = array();
     }
     FabrikHelperHTML::script('fabriktables.js', 'administrator/components/com_fabrik/elements/', true);
     $connectionDd = $node->attributes('observe', '');
     $db =& JFactory::getDBO();
     $document =& JFactory::getDocument();
     $c = ElementHelper::getRepeatCounter($this);
     $repeat = ElementHelper::getRepeat($this);
     $id = ElementHelper::getId($this, $control_name, $name);
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     if ($connectionDd == '') {
         //we are not monitoring a connection drop down so load in all tables
         $query = "SELECT id AS value, label AS `{$name}` FROM #__fabrik_tables order by label ASC";
         $db->setQuery($query);
         $rows = $db->loadObjectList();
     } else {
         $rows = array(JHTML::_('select.option', '', JText::_('SELECT A CONNECTION FIRST'), 'value', $name));
     }
     if ($connectionDd != '' && !array_key_exists($id, $fabriktables)) {
         $connectionDd = $c === false || $node->attributes('connection_in_repeat') == 'false' ? $connectionDd : $connectionDd . '-' . $c;
         $opts = new stdClass();
         $opts->livesite = COM_FABRIK_LIVESITE;
         $opts->conn = 'params' . $connectionDd;
         $opts->value = $value;
         $opts->connInRepeat = $node->attributes('connection_in_repeat');
         $opts = FastJSON::encode($opts);
         $script = "window.addEvent('domready', function() {\n";
         $script .= "var p = new fabriktablesElement('{$id}', {$opts});\n";
         $script .= "tableElements.set('{$id}', p);\n";
         $script .= "Fabrik.adminElements.set('{$id}', p);\n";
         $script .= "});\n";
         $document->addScriptDeclaration($script);
         $fabriktables[$id] = true;
     }
     FabrikHelperHTML::cleanMootools();
     $str = JHTML::_('select.genericlist', $rows, $fullName, 'class="inputbox fabriktables"', 'value', $name, $value, $id);
     $str .= "<img style=\"margin-left:10px;display:none\" id=\"" . $id . "_loader\" src=\"components/com_fabrik/images/ajax-loader.gif\" alt=\"" . JText::_('LOADING') . "\" />";
     return $str;
 }
예제 #3
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     FabrikHelperHTML::script('tables.js', 'administrator/components/com_fabrik/elements/', true);
     $connectionDd = $node->attributes('observe', '');
     $db =& JFactory::getDBO();
     $document =& JFactory::getDocument();
     $repeat = ElementHelper::getRepeat($this);
     $id = ElementHelper::getId($this, $control_name, $name);
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     $c = ElementHelper::getRepeatCounter($this);
     if ($connectionDd == '') {
         //we are not monitoring a connection drop down so load in all tables
         $query = "SHOW TABLES";
         $db->setQuery($query);
         $list = $db->loadResultArray();
         foreach ($list as $l) {
             $rows[] = JHTML::_('select.option', $l, $l);
         }
     } else {
         $rows = array(JHTML::_('select.option', '', JText::_('SELECT A CONNECTION FIRST')));
     }
     if ($connectionDd != '') {
         $connectionDd = $c === false ? $connectionDd : $connectionDd . '-' . $c;
         $opts = new stdClass();
         $opts->livesite = COM_FABRIK_LIVESITE;
         $opts->conn = 'params' . $connectionDd;
         $opts->value = $value;
         $opts = FastJSON::encode($opts);
         $script = "window.addEvent('domready', function() {\n";
         $script .= "if(typeof(tableElements) === 'undefined') {\n\t\t\ttableElements = \$H();\n}\n";
         $script .= "tableElements.set('{$id}', new tablesElement('{$id}', {$opts}));\n";
         $script .= "});\n";
         if ($script != '') {
             $document->addScriptDeclaration($script);
         }
     }
     FabrikHelperHTML::cleanMootools();
     $str = JHTML::_('select.genericlist', $rows, $fullName, 'class="repeattable inputbox"', 'value', 'text', $value, $id);
     $str .= "<img style='margin-left:10px;display:none' id='" . $id . "_loader' src='components/com_fabrik/images/ajax-loader.gif' alt='" . JText::_('LOADING') . "' />";
     return $str;
 }
예제 #4
0
 /**
  * Make the most basic decision about what to do in the backend.
  */
 public final function handleRequest()
 {
     $right = $this->right();
     if ($this->s->area == "form") {
         // check if form submitted
         if (empty(Error::$messages)) {
             // execute requested action
             $result = $this->handleForm();
         }
         // error occured while processing the form data?
         if ($result === false || !empty(Error::$messages)) {
             if ($this->s->post['call'] == 'ajax') {
                 // form submitted via ajax -> return JSON object
                 $ret['messages'] = !empty(Error::$messages) ? Error::$messages : array('error' => array('Unbekannter Fehler'));
                 if (count($this->form['errors']) > 0) {
                     $ret['fields'] = $this->form['errors'];
                 }
                 if (count($this->form['reload']) > 0) {
                     $ret['reload'] = $this->form['reload'];
                 }
                 if (count($this->form['dialog']) > 0) {
                     $ret['dialog'] = $this->form['dialog'];
                 }
                 echo FastJSON::encode($ret);
             } elseif ($this->s->post['call'] == 'load') {
                 // ajax load() -> return string with messages
                 if (!empty(Error::$messages)) {
                     foreach (Error::$messages as $texts) {
                         foreach ($texts as $msg) {
                             $message .= '<p>' . $msg . '</p>';
                         }
                     }
                     echo $message;
                 }
             } elseif ($this->s->post['call'] == 'load_text') {
                 // ajax load() for form field -> return string with messages
                 if (!empty(Error::$messages)) {
                     $message = "Fehler:\r\n";
                     foreach (Error::$messages as $texts) {
                         foreach ($texts as $msg) {
                             $message .= '– ' . $msg . "\r\n";
                         }
                     }
                     echo $message;
                 }
             } else {
                 // form submitted normal -> display form + error message(s)
                 $this->s->resetParams();
                 $this->buildSite();
             }
         } else {
             if ($this->s->post['call'] == 'ajax') {
                 // form submitted via ajax -> return JSON object
                 $ret = array();
                 if (count($this->form['reload']) > 0) {
                     $ret['reload'] = $this->form['reload'];
                 }
                 if (count($this->form['autocomplete']) > 0) {
                     $ret = $this->form['autocomplete'];
                 }
                 if (count($this->form['dialog']) > 0) {
                     $ret['dialog'] = $this->form['dialog'];
                 }
                 echo FastJSON::encode($ret);
             } elseif ($this->s->post['call'] != 'load' && $this->s->post['call'] != 'load_text') {
                 // form submitted normal -> display target site
                 $this->s->resetParams();
                 $this->buildSite();
             }
         }
     } elseif (!$this->s->auth()) {
         // check if user is logged in
         BackendController::buildSite();
     } elseif (!$this->s->user->hasRights($this->s->controller . ':' . $right) && array_key_exists($right, $this->registerRights())) {
         // check if action is allowed for the user
         Error::addError('Du besitzt nicht die erforderlichen Rechte, um die Aktion ' . $action . ' auszuführen!');
         BackendController::buildSite();
     } else {
         // normal behaviour: generate the requested backend site
         $this->buildSite();
     }
 }
예제 #5
0
    $formModel =& $controller->getModel('Form');
    $view->_formView->setModel($formModel, true);
    // Push a model into the view
    $model =& $controller->getModel($viewName);
    $package =& $model->getPackage();
    $package->tables = $tableId;
    $package->template = 'module';
    if (!JError::isError($model)) {
        $view->setModel($model, true);
    }
    $view->_isMambot = true;
    // Display the view
    $view->assign('error', $this->getError());
    //force the module layout for the package
    //push some data into the model
    $divid = "fabrikModule_table_{$tableId}";
    echo "<div id=\"{$divid}\">";
    echo $view->display();
    echo "</div>";
    FabrikHelperHTML::script('tablemodule.js', 'modules/mod_fabrik_table/', true);
    $fbConfig =& JComponentHelper::getParams('com_fabrik');
    $opts = new stdClass();
    $opts->mooversion = $fbConfig->get('usefabrik_mootools', false) ? 1.2 : 1.1;
    $opts->tableid = $tableId;
    $opts = FastJSON::encode($opts);
    $script = "var oFabrikTableModule = new fabrikTableModule('{$divid}', {$opts});\n";
    $script .= "oPackage.addBlock('{$divid}', oFabrikTableModule);\n";
    $document->addScriptDeclaration($script);
}
JRequest::setVar('layout', $origLayout);
JRequest::setVar('incfilters', $origIncFilters);
예제 #6
0
파일: table.php 프로젝트: nikshade/fabrik21
    /**
     * 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');
    }
예제 #7
0
파일: paypal.php 프로젝트: Jobar87/fabrik
	/**
	 * called from paypal at the end of the transaction
	 */

	function ipn()
	{
		$config = JFactory::getConfig();
		JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_fabrik'.DS.'tables');
		$log = JTable::getInstance('log', 'Table');
		$log->referring_url = $_SERVER['REQUEST_URI'];
		$log->message_type = 'fabrik.ipn.start';
		$log->message = FastJSON::encode($_REQUEST);
		$log->store();

		//lets try to load in the custom returned value so we can load up the form and its parameters
		$custom = JRequest::getVar('custom');
		list($formid, $rowid, $ipn_value) = explode(":", $custom);

		//pretty sure they are added but double add
		JModel::addIncludePath(COM_FABRIK_FRONTEND.DS.'models');
		$formModel = JModel::getInstance('Form', 'FabrikModel');
		$formModel->setId($formid);
		$listModel = $formModel->getlistModel();
		$params = $formModel->getParams();
		$table = $listModel->getTable();
		$db = $listModel->getDb();

		// $$$ hugh
		// @TODO shortColName won't handle joined data, need to fix this to use safeColName
		// (don't forget to change nameQuote stuff later on as well)
		$renderOrder = JRequest::getInt('renderOrder');
		$ipn_txn_field = $params->get('paypal_ipn_txn_id_element', array(), '_default', 'array');
		$ipn_txn_field = FabrikString::shortColName($ipn_txn_field[$renderOrder]);

		$ipn_payment_field = $params->get('paypal_ipn_payment_element', array(), '_default', 'array');
		$ipn_payment_field = FabrikString::shortColName($ipn_payment_field[$renderOrder]);

		$ipn_field = $params->get('paypal_ipn_element', array(), '_default', 'array');
		$ipn_field = FabrikString::shortColName($ipn_field[$renderOrder]);

		$ipn_status_field = $params->get('paypal_ipn_status_element', array(), '_default', 'array');
		$ipn_status_field = FabrikString::shortColName($ipn_status_field[$renderOrder]);

		$ipn_address_field = $params->get('paypal_ipn_address_element', array(), '_default', 'array');
		$ipn_address_field = FabrikString::shortColName($ipn_address_field[$renderOrder]);


		$w = new FabrikWorker();
		$ipn_value = str_replace('[','{',$ipn_value);
		$ipn_value = str_replace(']','}',$ipn_value);
		$ipn_value = $w->parseMessageForPlaceHolder($ipn_value, $_POST);

		$email_from = $admin_email = $config->getValue('mailfrom');



		// read the post from PayPal system and add 'cmd'
		$req = 'cmd=_notify-validate';

		foreach ($_POST as $key => $value) {
			$value = urlencode(stripslashes($value));
			$req .= "&$key=$value";
		}

		// post back to PayPal system to validate
		$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
		$header .= "Host: www.paypal.com:443\r\n";
		$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
		$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

		if ($_POST['test_ipn'] == 1) {
			$paypalurl = 'ssl://www.sandbox.paypal.com';
		} else {
			$paypalurl = 'ssl://www.paypal.com';
		}

		// assign posted variables to local variables
		$item_name 			= JRequest::getVar('item_name');
		$item_number 		= JRequest::getVar('item_number');
		$payment_status 	= JRequest::getVar('payment_status');
		$payment_amount 	= JRequest::getVar('mc_gross');
		$payment_currency 	= JRequest::getVar('mc_currency');
		$txn_id 			= JRequest::getVar('txn_id');
		$txn_type			= JRequest::getVar('txn_type');
		$receiver_email 	= JRequest::getVar('receiver_email');
		$payer_email 		= JRequest::getVar('payer_email');
		$buyer_address		= JRequest::getVar('address_status')
		.' - '.JRequest::getVar('address_street')
		.' '.JRequest::getVar('address_zip')
		.' '.JRequest::getVar('address_state')
		.' '.JRequest::getVar('address_city')
		.' '.JRequest::getVar('address_country_code');

		$status = 'ok';
		$err_msg = '';



		if (empty($formid) || empty($rowid)) {
			$status = 'form.paypal.ipnfailure.custom_error';
			$err_msg = "formid or rowid empty in custom: $custom";
		}
		else {
			//@TODO implement a curl alternative as fsockopen is not always available
			$fp = fsockopen ($paypalurl, 443, $errno, $errstr, 30);
			if (!$fp) {
				$status = 'form.paypal.ipnfailure.fsock_error';
				$err_msg = "fsock error: $errno;$errstr";
			} else {
				fputs ($fp, $header . $req);
				while (!feof($fp)) {
					$res = fgets ($fp, 1024);
					// paypal steps (from their docs):
					// check the payment_status is Completed
					// check that txn_id has not been previously processed
					// check that receiver_email is your Primary PayPal email
					// check that payment_amount/payment_currency are correct
					// process payment
					if (strcmp ($res, "VERIFIED") == 0) {

						//$$tom This block Paypal from updating the IPN field if the payment status evolves (e.g. from Pending to Completed)
						// $$$ hugh - added check of status, so only barf if there is a status field, and it is Completed for this txn_id
						if (!empty($ipn_txn_field) && !empty($ipn_status_field)) {
							$db->setQuery("SELECT $ipn_status_field FROM $table->db_table_name WHERE ".$db->nameQuote($ipn_txn_field)." = ".$db->Quote($txn_id));
							$txn_result = $db->loadResult();
							if (!empty($txn_result)) {
								if ($txn_result == 'Completed') {
									if ($payment_status != 'Reversed' && $payment_status != 'Refunded') {
										$status = 'form.paypal.ipnfailure.txn_seen';
										$err_msg = "transaction id already seen as Completed, new payment status makes no sense: $txn_id, $payment_status";
									}
								}
								else if ($txn_result == 'Reversed') {
									if ($payment_status != 'Canceled_Reversal') {
										$status = 'form.paypal.ipnfailure.txn_seen';
										$err_msg = "transaction id already seen as Reversed, new payment status makes no sense: $txn_id, $payment_status";
									}
								}
							}
						}
						if ($status == 'ok') {
							$set_list = array();
							if (!empty($ipn_field)) {
								if (empty($ipn_value)) {
									$ipn_value = $txn_id;
								}
								$set_list[$ipn_field] = $ipn_value;
							}
							if (!empty($ipn_txn_field)) {
								$set_list[$ipn_txn_field] = $txn_id;
							}
							if (!empty($ipn_payment_field)) {
								$set_list[$ipn_payment_field] = $payment_amount;
							}
							if (!empty($ipn_status_field)) {
								$set_list[$ipn_status_field] = $payment_status;
							}
							if (!empty($ipn_address_field)) {
								$set_list[$ipn_address_field] = $buyer_address;
							}
							$ipn = $this->getIPNHandler($params, $renderOrder);
							/*$php_file = $params->get('paypal_run_php_file', array(), '_default', 'array');
							 $php_file = JFilterInput::clean($php_file[$renderOrder], 'CMD');
							 $php_file = empty($php_file) ? '' : COM_FABRIK_FRONTEND.DS.'plugins'.DS.'form'.DS.'fabrikpaypal'.DS.'scripts'.DS.$php_file;
							 if (!empty($php_file) && file_exists($php_file)) {*/
							if ($ipn !== false) {
								$request = $_REQUEST;
								//require_once($php_file);
								//$ipn = new fabrikPayPalIPN();
								$ipn_function = 'payment_status_' . $payment_status;
								if (method_exists($ipn, $ipn_function)) {
									$status = $ipn->$ipn_function($listModel, $request, $set_list, $err_msg);
									if ($status != 'ok') {
										break;
									}
								}
								$txn_type_function = "txn_type_" . $txn_type;
								if (method_exists($ipn, $txn_type_function)) {
									$status = $ipn->$txn_type_function($listModel, $request, $set_list, $err_msg);
									if ($status != 'ok') {
										break;
									}
								}
							}

							if (!empty($set_list)) {
								$set_array = array();
								foreach ($set_list as $set_field => $set_value) {
									$set_value = $db->Quote($set_value);
									$set_field = $db->nameQuote($set_field);
									$set_array[] = "$set_field = $set_value";
								}
								$db->setQuery("UPDATE $table->db_table_name SET " . implode(',', $set_array) . " WHERE $table->db_primary_key = ".$db->Quote($rowid));
								if (!$db->query()) {
									$status = 'form.paypal.ipnfailure.query_error';
									$err_msg = 'sql query error: ' . $db->getErrorMsg();
								}
							}
						}
					}
					else if (strcmp ($res, "INVALID") == 0) {
						$status = 'form.paypal.ipnfailure.invalid';
						$err_msg = 'paypal postback failed with INVALID';
					}
				}
				fclose ($fp);
			}
		}

		$receive_debug_emails = $params->get('paypal_receive_debug_emails', array(), '_default', 'array');
		$receive_debug_emails = $receive_debug_emails[$renderOrder];
		$send_default_email = $params->get('paypal_send_default_email', array(), '_default', 'array');
		$send_default_email = $send_default_email[$renderOrder];
		if ($status != 'ok') {
			foreach ($_POST as $key => $value) {
				$emailtext .= $key . " = " .$value ."\n\n";
			}

			if ($receive_debug_emails == '1') {
				$subject = $config->getValue('sitename').": Error with PayPal IPN from Fabrik";
				JUtility::sendMail( $email_from, $email_from, $admin_email, $subject, $emailtext, false);
			}
			$log->message_type = $status;
			$log->message = $emailtext ."\n//////////////\n" . $res ."\n//////////////\n". $req .  "\n//////////////\n".$err_msg;
			if ($send_default_email == '1') {
				$payer_emailtext = "There was an error processing your PayPal payment.  The administrator of this site has been informed.";
				JUtility::sendMail( $email_from, $email_from, $payer_email, $subject, $payer_emailtext, false);
			}
		}
		else {
			foreach ($_POST as $key => $value) {
				$emailtext .= $key . " = " .$value ."\n\n";
			}

			if ($receive_debug_emails == '1') {
				$subject = $config->getValue('sitename').": IPN $payment_status";
				JUtility::sendMail( $email_from, $email_from, $admin_email, $subject, $emailtext, false);
			}
			$log->message_type = 'form.paypal.ipn.'.$payment_status;
			$query = $db->getQuery();
			$log->message = $emailtext ."\n//////////////\n" . $res ."\n//////////////\n". $req .  "\n//////////////\n".$query;

			if ($send_default_email == '1') {
				$payer_subject = "PayPal success";
				$payer_emailtext = "Your PayPal payment was succesfully processed.  The PayPal transaction id was $txn_id";
				JUtility::sendMail( $email_from, $email_from, $payer_email, $payer_subject, $payer_emailtext, false);
			}
		}
		$log->message .= "\n IPN custom function = $ipn_function";
		$log->message .= "\n IPN custom transaction function = $txn_type_function";
		$log->store();
		jexit();
	}
예제 #8
0
파일: form.php 프로젝트: nikshade/fabrik21
    /**
     * 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 
    }
예제 #9
0
파일: form.php 프로젝트: nikshade/fabrik21
 function processForm()
 {
     $document =& JFactory::getDocument();
     $viewName = JRequest::getVar('view', 'form', 'default', 'cmd');
     $viewType = $document->getType();
     $view =& $this->getView($viewName, $viewType);
     $model =& $this->getModel('form');
     if (!JError::isError($model)) {
         $view->setModel($model, true);
     }
     $model->setId(JRequest::getInt('form_id', 0));
     $model->getPostMethod();
     $this->_isMambot = JRequest::getVar('_isMambot', 0);
     $model->getForm();
     $model->_rowId = JRequest::getVar('rowid', '');
     // Check for request forgeries
     $fbConfig =& JComponentHelper::getParams('com_fabrik');
     if ($model->getParams()->get('spoof_check', $fbConfig->get('spoofcheck_on_formsubmission', true)) == true) {
         JRequest::checkToken() or die('Invalid Token');
     }
     if (JRequest::getVar('fabrik_ignorevalidation', 0) != 1) {
         //put in when saving page of form
         if (!$model->validate()) {
             //if its in a module with ajax or in a package
             if (JRequest::getInt('_packageId') !== 0) {
                 $data = array('modified' => $model->_modifiedValidationData);
                 //validating entire group when navigating form pages
                 $data['errors'] = $model->_arErrors;
                 echo FastJSON::encode($data);
                 return;
             }
             if ($this->_isMambot) {
                 //store errors in session
                 $_SESSION['fabrik']['mambot_errors'][$model->_id] = $model->_arErrors;
                 JRequest::setVar('fabrik_referrer', JArrayHelper::getValue($_SERVER, 'HTTP_REFERER', ''), 'post');
                 // $$$ hugh - testing way of preserving form values after validation fails with form plugin
                 // might as well use the 'savepage' mechanism, as it's already there!
                 $this->savepage();
                 $this->makeRedirect('', $model);
             } else {
                 $view->display();
             }
             return;
         }
     }
     //reset errors as validate() now returns ok validations as empty arrays
     $model->_arErrors = array();
     $defaultAction = $model->process();
     //check if any plugin has created a new validation error
     if (!empty($model->_arErrors)) {
         $pluginManager =& $model->getPluginManager();
         $pluginManager->runPlugins('onError', $model);
         $view->display();
         return;
     }
     // $$$ rob 31/01/2011
     // Now redirect always occurs even with redirect thx message, $this->setRedirect
     // will look up any redirect url specified in the session by a plugin and use that or
     // fall back to the url defined in $this->makeRedirect()
     //one of the plugins returned false stopping the default redirect
     // action from taking place
     /*
     if (!$defaultAction) {
       return;
     }
     */
     $tableModel =& $model->getTableModel();
     $tid = $tableModel->getTable()->id;
     $tableModel->_table = null;
     $msg = $model->getParams()->get('submit-success-msg', JText::_('RECORD ADDED/UPDATED'));
     if (JRequest::getInt('_packageId') !== 0) {
         $rowid = JRequest::getInt('rowid');
         echo FastJSON::encode(array('msg' => $msg, 'rowid' => $rowid));
         return;
     }
     if (JRequest::getVar('format') == 'raw') {
         $url = COM_FABRIK_LIVESITE . '/index.php?option=com_fabrik&view=table&format=raw&tableid=' . $tid;
         $this->setRedirect($url, $msg);
     } else {
         $this->makeRedirect($msg, $model);
     }
 }
include 'setup.php';
require 'FastJSON.class.php';
$uid = $_SESSION['UID'];
//www.tritonetech.com/php_uploads/porsche/webservice/evaluate_writing_score.php?qid=&score=&group_content_id=
$score = $_REQUEST['score'];
$qid = $_REQUEST['qid'];
if ($score == '' || $qid == '') {
    $dataDB['Result']['Data'][] = array('Status' => "parameters missing");
    echo FastJSON::encode($dataDB);
    exit;
}
$time = time();
$query = $_DB->Execute("update jos_porsche_group_writing_task set score='{$score}',eval_time='{$time}' where id='{$qid}'");
if ($query == true) {
    /*$query=$_DB->Query("SELECT a.qid, b.id, b.q_s_id, b.group_content_id, c.module_id, c.id, c.task
    FROM jos_porsche_group_writing_track AS a
    LEFT JOIN jos_porsche_group_writing_task AS b ON a.qid = b.id
    LEFT JOIN jos_porsche_group AS c ON b.group_content_id = c.id
    WHERE a.qid = '$qid'
    AND c.task = 'group_write'");*/
    $query = $_DB->Query("SELECT a.id , a.group_content_id, a.q_s_id, b.id, b.module_id, b.task\nFROM jos_porsche_group_writing_task AS a\nLEFT JOIN jos_porsche_group b ON a.group_content_id = b.id\nWHERE a.id = '{$qid}'\nAND b.task = 'group_write'");
    $student_id = $_DB->GetResultValue($query, 0, 'q_s_id');
    $module_id = $_DB->GetResultValue($query, 0, 'module_id');
    //$_DB->Execute("UPDATE jos_porsche_student_module SET group_writing =case when group_writing IS NULL THEN $score ELSE group_writing +'$score' END WHERE student_id = '$student_id' AND module_id = '$module_id' ");
    $_DB->Execute("UPDATE jos_porsche_student_module SET group_writing =group_writing+'{$score}' WHERE student_id = '{$student_id}' AND module_id = '{$module_id}' ");
    $dataDB['Result']['Data'][0] = array('Status' => "successful in assigning score");
} else {
    $dataDB['Result']['Data'][0] = array('Status' => "not assigned");
}
echo FastJSON::encode($dataDB);
예제 #11
0
 /**
  * log  to table jos_fabrik_logs
  * @param string $type e.g. 'fabrik.fileupload.download'
  * @param mixed $msg array/object/string
  * @param bool $jsonEncode
  */
 public function log($type, $msg, $jsonEncode = true)
 {
     if ($jsonEncode) {
         $msg = FastJSON::encode($msg);
     }
     $log =& JTable::getInstance('log', 'Table');
     $log->message_type = $type;
     $log->message = $msg;
     $log->store();
 }
 public function Json_result($dataDB1)
 {
     echo FastJSON::encode($dataDB1);
     //echo json_encode($dataDB1);
 }
예제 #13
0
파일: html.php 프로젝트: nikshade/fabrik21
 /**
  * Add autocomplete JS code to head
  * @param string $htmlid of element to turn into autocomplete
  * @param int $elementid
  * @param string $plugin
  * @param array $opts (currently only takes 'onSelection')
  */
 public function autoComplete($htmlid, $elementid, $plugin = 'fabrikfield', $opts = array())
 {
     FabrikHelperHTML::autoCompleteScript();
     $json = FabrikHelperHTML::autoCompletOptions($htmlid, $elementid, $plugin, $opts);
     $str = FastJSON::encode($json);
     FabrikHelperHTML::addScriptDeclaration("window.addEvent('domready', function() { new FabAutocomplete('{$htmlid}', {$str}); });");
 }
예제 #14
0
 static function encode($array) {
     return FastJSON::encode($array);
 }
예제 #15
0
 function json_encode($value)
 {
     require_once "lib/FastJSON.class.php";
     return FastJSON::encode($value);
 }
예제 #16
0
 function json_encode($json)
 {
     return FastJSON::encode($json);
 }
예제 #17
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);
 }
예제 #18
0
 /**
  * public method
  *
  *	FastJSON::encode(params:*):String
  *
  * @param	*		Array, Boolean, Float, Int, Object, String or NULL variable.
  * @return	String		JSON genric object rappresentation
  *				or empty string if param is not compatible.
  *
  * @example
  *		FastJSON::encode(array(1,"two")); // '[1,"two"]'
  *
  *		$obj = new MyClass();
  *		obj->param = "value";
  *		obj->param2 = "value2";
  *		FastJSON::encode(obj); // '{"param":"value","param2":"value2"}'
  */
 function encode($decode)
 {
     $result = '';
     switch (gettype($decode)) {
         case 'array':
             if (!count($decode) || array_keys($decode) === range(0, count($decode) - 1)) {
                 $keys = array();
                 foreach ($decode as $value) {
                     if (($value = FastJSON::encode($value)) !== '') {
                         array_push($keys, $value);
                     }
                 }
                 $result = '[' . implode(',', $keys) . ']';
             } else {
                 $result = FastJSON::convert($decode);
             }
             break;
         case 'string':
             $replacement = FastJSON::__getStaticReplacement();
             $result = '"' . str_replace($replacement['find'], $replacement['replace'], $decode) . '"';
             break;
         default:
             if (!is_callable($decode)) {
                 $result = FastJSON::convert($decode);
             }
             break;
     }
     return $result;
 }
예제 #19
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     if (is_null($this->results)) {
         $this->results = array();
     }
     $db =& JFactory::getDBO();
     $controller = JRequest::getVar('c');
     $session =& JFactory::getSession();
     $aEls = array();
     $onlytablefields = (int) $node->attributes('onlytablefields', 1);
     $onlytablefields = $onlytablefields === 1 ? "show_in_table_summary = 1" : "";
     $pluginFilters = trim($node->attributes('filter')) == '' ? array() : explode("|", $node->attributes('filter'));
     $bits = array();
     $id = ElementHelper::getId($this, $control_name, $name);
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     $c = ElementHelper::getRepeatCounter($this);
     switch ($controller) {
         case 'element':
             //@TODO this seems like we could refractor it to use the formModel class as per the table and form switches below?
             //$connectionDd = $node->attributes( 'connection', '');
             $connectionDd = $c === false ? $node->attributes('connection') : $node->attributes('connection') . '-' . $c;
             if ($node->attributes('connection', '') == '') {
                 $oGroup =& JModel::getInstance('Group', 'FabrikModel');
                 $groupid = $this->_parent->get('group_id');
                 if ($groupid == '') {
                     $cid = JRequest::getVar('cid');
                     if (is_array($cid)) {
                         $cid = $cid[0];
                     }
                     $db->setQuery("select group_id from #__fabrik_elements where id = " . (int) $cid);
                     $groupid = $db->loadResult();
                 }
                 $oGroup->setId($groupid);
                 $formModel =& $oGroup->getForm();
                 $optskey = $node->attributes('valueformat', 'tableelement') == 'tableelement' ? 'name' : 'id';
                 $onlytablefields = (int) $node->attributes('onlytablefields', 0);
                 $res = $formModel->getElementOptions(false, $optskey, $onlytablefields, false, $pluginFilters);
                 $hash = "{$controller}." . implode('.', $bits);
                 if (array_key_exists($hash, $this->results)) {
                     $res = $this->results[$hash];
                 } else {
                     $this->results[$hash] =& $res;
                 }
             } else {
                 //****************************//
                 $repeat = ElementHelper::getRepeat($this);
                 $tableDd = $node->attributes('table', '');
                 FabrikHelperHTML::script('tablefields.js', 'administrator/components/com_fabrik/elements/', true);
                 $opts = new stdClass();
                 $opts->table = $repeat ? 'params' . $tableDd . "-" . $c : 'params' . $tableDd;
                 $opts->livesite = COM_FABRIK_LIVESITE;
                 $opts->conn = 'params' . $connectionDd;
                 $opts->value = $value;
                 $opts->repeat = $value;
                 $opts = FastJSON::encode($opts);
                 $script = "window.addEvent('domready', function() {\n";
                 $script .= "new tablefieldsElement('{$id}', {$opts});\n";
                 $script .= "});\n";
                 $document =& JFactory::getDocument();
                 $document->addScriptDeclaration($script);
                 $rows = array(JHTML::_('select.option', '', JText::_('SELECT A CONNECTION FIRST')), 'value', 'text');
                 $o = new stdClass();
                 $o->table_name = '';
                 $o->name = '';
                 $o->value = '';
                 $o->text = JText::_('SELECT A TABLE FIRST');
                 $res[] = $o;
                 //****************************//
             }
             break;
         case 'table':
             $id = $this->_parent->get('id', false);
             if ($id === false) {
                 $id = JRequest::getVar('cid', array(0));
                 if (is_array($id)) {
                     $id = $id[0];
                 }
             }
             $tableModel =& $session->get('com_fabrik.admin.table.edit.model');
             $formModel =& $tableModel->getForm();
             $valfield = $node->attributes('valueformat', 'tableelement') == 'tableelement' ? 'name' : 'id';
             $onlytablefields = (int) $node->attributes('onlytablefields', 1);
             $incraw = $node->attributes('incraw', 0) == 1 ? true : false;
             $res = $formModel->getElementOptions(false, $valfield, $onlytablefields, $incraw, $pluginFilters);
             break;
         case 'form':
             $id = $this->_parent->get('id');
             $id = JRequest::getVar('cid', array(0));
             if (is_array($id)) {
                 $id = $id[0];
             }
             $formModel =& $session->get('com_fabrik.admin.form.edit.model');
             $valfield = $node->attributes('valueformat', 'tableelement') == 'tableelement' ? 'name' : 'id';
             $onlytablefields = (int) $node->attributes('onlytablefields', 1);
             $incraw = $node->attributes('incraw', 0) == 1 ? true : false;
             $res = $formModel->getElementOptions(false, $valfield, $onlytablefields, $incraw, $pluginFilters);
             break;
         default:
             return JText::_('THE TABLEFIELDS ELEMENT IS ONLY USABLE BY TABLES AND ELEMENTS');
             break;
     }
     $return = '';
     if (is_array($res)) {
         if ($controller == 'element') {
             foreach ($res as $o) {
                 $s = new stdClass();
                 //element already contains correct key
                 if ($controller != 'element') {
                     $s->value = $node->attributes('valueformat', 'tableelement') == 'tableelement' ? $o->table_name . '.' . $o->text : $o->value;
                 } else {
                     $s->value = $o->value;
                 }
                 $s->text = FabrikString::getShortDdLabel($o->text);
                 $aEls[] = $s;
             }
         } else {
             foreach ($res as &$o) {
                 $o->text = FabrikString::getShortDdLabel($o->text);
             }
             $aEls = $res;
         }
         $id = ElementHelper::getId($this, $control_name, $name);
         $aEls[] = JHTML::_('select.option', '', '-');
         $return = JHTML::_('select.genericlist', $aEls, $fullName, 'class="inputbox" size="1" ', 'value', 'text', $value, $id);
         $return .= "<img style='margin-left:10px;display:none' id='" . $id . "_loader' src='components/com_fabrik/images/ajax-loader.gif' alt='" . JText::_('LOADING') . "' />";
     }
     return $return;
 }