function fetchElement($name, $value, &$node, $control_name)
 {
     $id = ElementHelper::getId($this, $control_name, $name);
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     $iframeid = $id . '_iframe';
     $cid = JRequest::getVar('cid', array(), 'array');
     // $$$ hugh - when creating a new form, no 'cid' ... not sure what to do, so just set it to 0.  Should
     // prolly just return something like 'available after save' ?
     if (!empty($cid)) {
         $cid = (int) $cid[0];
     } else {
         $cid = 0;
     }
     $c = (int) $this->getRepeatCounter();
     $href = COM_FABRIK_LIVESITE . 'index.php?option=com_fabrik&controller=plugin&task=pluginAjax&plugin=fabriktwitter&g=form&method=authenticateAdmin&tmpl=component&formid=' . $cid . '&repeatCounter=' . $c;
     $clearjs = '$(\'paramstwitter_oauth_token-' . $c . '\').value = \'\';';
     $clearjs .= '$(\'paramstwitter_oauth_token_secret-' . $c . '\').value = \'\';';
     $clearjs .= '$(\'paramstwitter_oauth_user-' . $c . '\').value = \'\';';
     $clearjs .= "return false;";
     $js = "window.open('{$href}', 'twitterwins', 'width=800,height=460,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');return false;";
     $str = '<a href="#" onclick="' . $js . '"><img src="' . COM_FABRIK_LIVESITE . 'components/com_fabrik/libs/abraham-twitteroauth/images/lighter.png" alt="Sign in with Twitter"/></a>';
     $str .= " | <a href=\"#\" onclick=\"{$clearjs}\">" . JText::_('PLG_FORM_TWITTER_CLEAR_CREDENTIALS') . "</a><br/>";
     $str .= "<br /><input type=\"text\" readonly=\"readonly\" name=\"{$fullName}\" id=\"{$id}\" value=\"{$value}\" />";
     return $str;
 }
 function fetchElement($name, $value, &$node, $control_name)
 {
     jimport('joomla.filesystem.folder');
     // path to images directory
     $path = JPATH_ROOT . DS . $node->attributes('directory');
     $filter = $node->attributes('filter');
     $exclude = $node->attributes('exclude');
     $recursive = $node->attributes('recursive') == 1 ? true : false;
     $folders = JFolder::folders($path, $filter, $recursive);
     $folders = $this->recursive_listdir($path, $node);
     $options = array();
     foreach ($folders as $key => $folder) {
         if ($exclude) {
             if (preg_match(chr(1) . $exclude . chr(1), $folder)) {
                 continue;
             }
         }
         $options[] = JHTML::_('select.option', $key, $folder);
     }
     if (!$node->attributes('hide_none')) {
         array_unshift($options, JHTML::_('select.option', '-1', '- ' . JText::_('Do not use') . ' -'));
     }
     if (!$node->attributes('hide_default')) {
         array_unshift($options, JHTML::_('select.option', '', '- ' . JText::_('Use default') . ' -'));
     }
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     return JHTML::_('select.genericlist', $options, $fullName, 'class="inputbox"', 'value', 'text', $value, "params{$name}");
 }
 function fetchElement($name, $value, &$node, $control_name)
 {
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     $opts[] = JHTML::_('select.option', "ASC", JText::_('ASCENDING'));
     $opts[] = JHTML::_('select.option', "DESC", JText::_('DESCENDING'));
     return JHTML::_('select.genericlist', $opts, $fullName, 'class="inputbox" size="1"', 'value', 'text', $value);
 }
Beispiel #4
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $js = "onclick=\"setAllCheckBoxes('details[hidden]', this.checked);\"";
     $chk = $value == '1' ? ' checked="checked"' : '';
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     return "<input {$js} id=\"{$control_name}{$name}\" type=\"checkbox\" name=\"" . $fullName . "\" value=\"1\" {$chk} />";
 }
Beispiel #5
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     if ($value == '0' || $value == '') {
         $value = '255';
     }
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     return "<input onblur=\"setAll(this.value, '{$fullName}');\" class=\"inputbox\" type=\"text\" name=\"{$fullName}\" size=\"3\" value=\"{$value}\" />";
 }
Beispiel #6
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $db =& JFactory::getDBO();
     $db->setQuery("SELECT id AS value, label AS `text` FROM #__fabrik_forms order by value DESC");
     $rows = $db->loadObjectList();
     $id = ElementHelper::getId($this, $control_name, $name);
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     return JHTML::_('select.genericlist', $rows, $fullName, 'class="inputbox"  size="1"', 'value', 'text', $value);
 }
Beispiel #7
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     if ($value == '') {
         $user = JFactory::getUser();
         $value = $user->get('id');
     }
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     return JHTML::_('list.users', $fullName, $value);
 }
Beispiel #8
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     require_once COM_FABRIK_FRONTEND . DS . 'helpers' . DS . 'image.php';
     $imageLibs = imageHelper::getLibs();
     if (empty($imageLibs)) {
         return JText::_('NO MAGE LIBRARY FOUND');
     }
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     return JHTML::_('select.genericlist', $imageLibs, $fullName, 'class="inputbox" size="1" ', 'value', 'text', $value);
 }
 function fetchElement($name, $value, &$node, $control_name)
 {
     $a = array(JHTML::_('select.option', '', JText::_('COM_FABRIK_PLEASE_SELECT')));
     $db =& JFactory::getDBO();
     $group = $node->attributes('plugin');
     $db->setQuery("SELECT id AS value, label AS text FROM #__fabrik_visualizations WHERE state ='1' ORDER BY text");
     $elementstypes = $db->loadObjectList();
     $elementstypes = array_merge($a, $elementstypes);
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     return JHTML::_('select.genericlist', $elementstypes, $fullName, 'class="inputbox elementtype"  size="1"', 'value', 'text', $value);
 }
Beispiel #10
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $version = new JVersion();
     if ($version->RELEASE == '1.6') {
         $acl =& JFactory::getACL();
         // @TODO for Joomla 1.6
         $gtree = JHTML::_('select.option', "-2", 'TODO FOR JOOMLA 1.6');
         return JHTML::_('select.genericlist', array($gtree), $control_name . '[' . $name . ']', 'class="inputbox" size="1"', 'value', 'text', $value);
     } else {
         if (defined('_JACL')) {
             $_JACL =& JACLPlus::getJACL();
             $where = "\n WHERE id IN (0,1,2)";
             $db =& JFactory::getDBO();
             if ($_JACL->enable_jaclplus) {
                 $user =& JFactory::getUser();
                 if (is_numeric($value)) {
                     $where = " OR id = '" . (int) $value . "'";
                 } else {
                     $where = "";
                 }
                 switch ($_JACL->publish_alstype) {
                     case "1":
                         $where = $user->get('gid') == 25 ? "" : "\n WHERE id IN (" . $user->get('jaclplus', '0') . ")" . $where;
                         break;
                     case "2":
                         $where = $user->get('gid') == 25 ? "" : "\n WHERE id NOT IN (0,1,2)" . $where;
                         break;
                     case "3":
                         $where = $user->get('gid') == 25 ? "" : "\n WHERE id IN (" . $user->get('jaclplus', '0') . ") AND id NOT IN (0,1,2)" . $where;
                         break;
                     case "4":
                         $where = $user->get('gid') == 25 ? "" : "\n WHERE id IN (" . $db->getEscaped($_JACL->publish_jaclplus) . ")" . $where;
                         break;
                     case "0":
                     default:
                         $where = "";
                         break;
                 }
             }
             $query = 'SELECT id AS value, name AS text' . ' FROM #__groups' . $where . ' ORDER BY id';
             $db->setQuery($query);
             $gtree = $db->loadObjectList();
         } else {
             $acl =& JFactory::getACL();
             $gtree = $acl->get_group_children_tree(null, 'USERS', false);
             $optAll = array(JHTML::_('select.option', '0', ' - Everyone'), JHTML::_('select.option', "26", 'Nobody'));
             $gtree = array_merge($optAll, $gtree);
         }
         $fullName = ElementHelper::getFullName($this, $control_name, $name);
         $id = ElementHelper::getId($this, $control_name, $name);
         return JHTML::_('select.genericlist', $gtree, $fullName, 'class="inputbox fullaccesslevel" size="1"', 'value', 'text', $value, $id);
     }
 }
Beispiel #11
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $id = ElementHelper::getId($this, $control_name, $name);
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     $size = $node->attributes('size') ? 'size="' . $node->attributes('size') . '"' : '';
     $class = $node->attributes('class') ? 'class="' . $node->attributes('class') . '"' : 'class="text_area"';
     $value = htmlspecialchars(html_entity_decode($value, ENT_QUOTES), ENT_QUOTES);
     if ($value == '') {
         $value = $this->getMax();
     }
     return '<input type="text" name="' . $fullName . '" id="' . $id . '" value="' . $value . '" ' . $class . ' ' . $size . ' />';
 }
Beispiel #12
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $app =& JFactory::getApplication();
     if ($value == '') {
         $value = $app->getUserStateFromRequest('com_fabrik.element.list.filter_groupId', 'filter_groupId', $value);
     }
     $db =& JFactory::getDBO();
     $db->setQuery("SELECT id AS value, name AS `group_id` FROM #__fabrik_groups ORDER BY name");
     $select = JHTML::_('select.option', '', JText::_('COM_FABRIK_PLEASE_SELECT'), 'value', 'group_id');
     $rows = array_merge(array($select), $db->loadObjectList());
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     return JHTML::_('select.genericlist', $rows, $fullName, 'class="inputbox" size="1"', 'value', 'group_id', $value);
 }
Beispiel #13
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $repeat = ElementHelper::getRepeat($this);
     $id = ElementHelper::getId($this, $control_name, $name);
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     //orig J stuff
     $rows = $node->attributes('rows');
     $cols = $node->attributes('cols');
     $class = $node->attributes('class') ? 'class="' . $node->attributes('class') . '"' : 'class="text_area"';
     // convert <br /> tags so they are not visible when editing
     $value = str_replace('<br />', "\n", $value);
     return '<textarea name="' . $fullName . '" cols="' . $cols . '" rows="' . $rows . '" ' . $class . ' id="' . $id . '" >' . $value . '</textarea>';
 }
Beispiel #14
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $db =& JFactory::getDBO();
     if ($value == '') {
         $db->setQuery("SELECT id FROM #__fabrik_connections WHERE `default` = 1");
         $value = $db->loadResult();
     }
     $db->setQuery("SELECT id AS value, description AS text FROM #__fabrik_connections WHERE state = '1'");
     $cnns = array_merge(array(JHTML::_('select.option', '-1', JText::_('COM_FABRIK_PLEASE_SELECT'))), $db->loadObjectList());
     $js = "onchange=\"" . $node->attributes('js') . "\"";
     $id = ElementHelper::getId($this, $control_name, $name);
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     $return = JHTML::_('select.genericlist', $cnns, '' . $fullName, 'class="inputbox" ' . $js, '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;
 }
Beispiel #15
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $db =& JFactory::getDBO();
     $db->setQuery($node->attributes('query'));
     $key = $node->attributes('key_field') ? $node->attributes('key_field') : 'value';
     $val = $node->attributes('value_field') ? $node->attributes('value_field') : $name;
     if ($node->attributes('add_select')) {
         $rows = array(JHTML::_('select.option', '', '- ' . JText::_('Do not use') . ' -', $key, $val));
         $rows = array_merge($rows, $db->loadObjectList());
     } else {
         $rows = $db->loadObjectList();
     }
     $id = ElementHelper::getId($this, $control_name, $name);
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     return JHTML::_('select.genericlist', $rows, $fullName, 'class="inputbox"', $key, $val, $value, $id);
 }
Beispiel #16
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $id = ElementHelper::getId($this, $control_name, $name);
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     //orig J stuff
     $size = $node->attributes('size') ? 'size="' . $node->attributes('size') . '"' : '';
     $class = $node->attributes('class') ? 'class="' . $node->attributes('class') . '"' : 'class="text_area"';
     /*
      * Required to avoid a cycle of encoding &
      * html_entity_decode was used in place of htmlspecialchars_decode because
      * htmlspecialchars_decode is not compatible with PHP 4
      */
     if (is_string($value)) {
         $value = htmlspecialchars(html_entity_decode($value, ENT_QUOTES), ENT_QUOTES);
     }
     return '<input type="text" name="' . $fullName . '" id="' . $id . '" value="' . $value . '" ' . $class . ' ' . $size . ' />';
 }
Beispiel #17
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;
 }
Beispiel #18
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;
 }
Beispiel #19
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;
 }
Beispiel #20
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     //ONLY WORKS INSIDE ELEMENT :(
     $group_id = $this->_parent->get('group_id');
     $query = "SELECT ordering AS value, name AS text" . "\n FROM #__fabrik_elements " . "\n WHERE group_id = '{$group_id}'" . "\n AND state >= 0" . "\n ORDER BY ordering";
     $id = $this->_parent->get('id');
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     $neworder = 0;
     if ($id) {
         $order = JHTML::_('list.genericordering', $query);
         $ordering = JHTML::_('select.genericlist', $order, $fullName, 'class="inputbox" size="1"', 'value', 'text', $value);
     } else {
         if ($neworder) {
             $text = JText::_('descNewItemsFirst');
         } else {
             $text = JText::_('descNewItemsLast');
         }
         $ordering = '<input type="hidden" name="' . $fullName . '" value="' . $value . '" />' . $text;
     }
     return $ordering;
 }
Beispiel #21
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $db =& JFactory::getDBO();
     $document =& JFactory::getDocument();
     $query = "SELECT id AS value, label AS `{$name}` FROM #__fabrik_tables ORDER BY value DESC";
     $db->setQuery($query);
     $newname = trim($name, "[]");
     $id = ElementHelper::getId($this, $control_name, $name);
     $fullName = ElementHelper::getFullName($this, $control_name, $name);
     $list = JHTML::_('select.genericlist', $db->loadObjectList(), $fullName, 'class="repeattable inputbox"', 'value', $name, $value, $id);
     $list = "<div id='" . $control_name . $name . "_container'>" . $list . "</div>";
     if ($this->_array_counter == 0) {
         $link = "<a id='{$newname}" . "_link' onclick='return duplicateRepeatTable(this);' href='#'>" . JText::_('ADD') . "</a><br />";
         $list = $link . $list;
         $script = "\n\tfunction duplicateRepeatTable(a) {\n\t\tvar id = a.id.replace('_link', '');\n\t\tvar container =  \$('" . $control_name . $name . "_container');\n\t\tvar dd  = container.getElement('select');\n\t\tvar html = new Element('div').adopt([\n\t\t\tdd.clone(),\n\t\t\tnew Element('a', {'href':'#','class':'removeButton', 'onclick':'return removeRepeatTableRow(this)'}).appendText('[-]')\n\t\t]);\n\t\thtml.injectInside(container);\n\t\treturn false;\n\t}\n\t\n\tfunction removeRepeatTableRow(a) {\n\t\ta.getParent().remove();\n\t\treturn false;\n\t}\n\t";
         $document->addScriptDeclaration($script);
     }
     if ($this->_array_counter != 0) {
         $list .= "<a href='#' class='removeButton' onclick='return removeRepeatTableRow(this)'>[-]</a>";
     }
     return $list;
 }
Beispiel #22
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;
 }