コード例 #1
0
ファイル: textarea.php プロジェクト: nikshade/fabrik21
 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>';
 }
コード例 #2
0
ファイル: element.php プロジェクト: nikshade/fabrik21
 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;
 }
コード例 #3
0
ファイル: fabriktables.php プロジェクト: nikshade/fabrik21
 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;
 }
コード例 #4
0
ファイル: tables.php プロジェクト: nikshade/fabrik21
 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;
 }
コード例 #5
0
ファイル: listfields.php プロジェクト: romuland/khparts
 function getInput()
 {
     if (is_null($this->results)) {
         $this->results = array();
     }
     $controller = JRequest::getVar('view', JRequest::getVar('task'));
     $aEls = array();
     $pluginFilters = trim($this->element['filter']) == '' ? array() : explode("|", $this->element['filter']);
     $bits = array();
     $c = ElementHelper::getRepeatCounter($this);
     $connection = $this->element['connection'];
     // 27/08/2011 - changed from default tableelement to id - for juser form plugin - might cause havock
     //else where but loading elements by id as default seems more robust (and is the default behaviour in f2.1
     $valueformat = JArrayHelper::getValue($this->element, 'valueformat', 'id');
     $onlylistfields = (int) JArrayHelper::getValue($this->element, 'onlylistfields', 0);
     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 = $c === false ? $connection : $connection . '-' . $c;
             if ($connection == '') {
                 $groupModel = JModel::getInstance('Group', 'FabrikFEModel');
                 $groupId = isset($this->form->rawData) ? JArrayHelper::getValue($this->form->rawData, 'group_id', 0) : $this->form->getValue('group_id');
                 $groupModel->setId($groupId);
                 $optskey = $valueformat == 'tableelement' ? 'name' : 'id';
                 $res = $groupModel->getForm()->getElementOptions(false, $optskey, $onlylistfields, 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 = $this->element['table'];
                 $opts = new stdClass();
                 $opts->table = $repeat ? 'jform_' . $tableDd . "-" . $c : 'jform_' . $tableDd;
                 $opts->conn = 'jform_' . $connectionDd;
                 $opts->value = $this->value;
                 $opts->repeat = $this->value;
                 $opts = json_encode($opts);
                 $script = "new ListFieldsElement('{$this->id}', {$opts});\n";
                 FabrikHelperHTML::script('administrator/components/com_fabrik/models/fields/listfields.js', $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::_('COM_FABRIK_SELECT_A_TABLE_FIRST');
                 $res[] = $o;
                 //****************************//
             }
             break;
         case 'listform':
         case 'list':
         case 'module':
         case 'item':
             //menu item
             if ($controller === 'item') {
                 $id = $this->form->getValue('request.listid');
             } else {
                 $id = $this->form->getValue('id');
             }
             if (!isset($this->form->model)) {
                 echo "not set ";
                 if (!in_array($controller, array('item', 'module'))) {
                     //seems to work anyway in the admin module page - so lets not raise notice
                     JError::raiseNotice(500, 'Model not set in listfields field ' . $this->id);
                 }
                 echo "form model no set";
                 return;
             }
             $listModel = $this->form->model;
             if ($id !== 0) {
                 $formModel = $listModel->getFormModel();
                 $valfield = $valueformat == 'tableelement' ? 'name' : 'id';
                 $res = $formModel->getElementOptions(false, $valfield, $onlylistfields, false, $pluginFilters);
             } else {
                 $res = array();
             }
             break;
         case 'form':
             if (!isset($this->form->model)) {
                 JError::raiseNotice(500, 'Model not set in listfields field ' . $this->id);
                 return;
             }
             $formModel = $this->form->model;
             $valfield = $valueformat == 'tableelement' ? 'name' : 'id';
             $res = $formModel->getElementOptions(false, $valfield, $onlylistfields, false, $pluginFilters);
             break;
         default:
             return JText::_('THE LISTFIELDS ELEMENT IS ONLY USABLE BY LISTS 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 = $valueformat == '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;
         }
         $aEls[] = JHTML::_('select.option', '', '-');
         // for pk fields - we are no longer storing the key with '`' as thats mySQL specific
         $this->value = str_replace('`', '', $this->value);
         $return = JHTML::_('select.genericlist', $aEls, $this->name, 'class="inputbox" size="1" ', 'value', 'text', $this->value, $this->id);
         $return .= "<img style=\"margin-left:10px;display:none\" id=\"" . $this->id . "_loader\" src=\"components/com_fabrik/images/ajax-loader.gif\" alt=\"" . JText::_('LOADING') . "\" />";
     }
     return $return;
 }
コード例 #6
0
ファイル: tablefields.php プロジェクト: nikshade/fabrik21
 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;
 }