/** * Method to get the field input markup. * * @return string The field input markup. */ protected function getInput() { $app = JFactory::getApplication(); $format = $app->input->get('format', 'html'); $connectionDd = $this->element['observe']; if ((int) $this->form->getValue('id') != 0 && $this->element['readonlyonedit']) { return '<input type="text" value="' . $this->value . '" class="readonly" name="' . $this->name . '" readonly="true" />'; } $c = FabrikAdminElementHelper::getRepeatCounter($this); $readOnlyOnEdit = $this->element['readonlyonedit']; if ($connectionDd != '') { $connectionDd = $c === false ? $connectionDd : $connectionDd . '-' . $c; $opts = new stdClass(); $opts->livesite = COM_FABRIK_LIVESITE; $opts->conn = 'jform_' . $connectionDd; $opts->value = $this->value; $opts = json_encode($opts); $script[] = "FabrikAdmin.model.fields.fabriktable['{$this->id}'] = new tablesElement('{$this->id}', {$opts});\n"; $src = array('Fabrik' => 'media/com_fabrik/js/fabrik.js', 'Namespace' => 'administrator/components/com_fabrik/views/namespace.js', 'Tables' => 'administrator/components/com_fabrik/models/fields/tables.js'); FabrikHelperHTML::script($src, implode("\n", $script)); $this->value = ''; } $html = parent::getInput(); $html .= "<img style='margin-left:10px;display:none' id='" . $this->id . "_loader' src='components/com_fabrik/images/ajax-loader.gif' alt='" . FText::_('LOADING') . "' />"; FabrikHelperHTML::framework(); FabrikHelperHTML::iniRequireJS(); return $html; }
/** * Get JS * * @param array $res */ private function js($res = array()) { $at = (string) $this->getAttribute('at', 'false'); if ($at === 'true') { FabrikHelperHTML::atWHo('textarea[data-at]', ArrayHelper::getColumn($res, 'value')); } $connection = $this->getAttribute('connection'); $repeat = FabrikWorker::toBoolean($this->getAttribute('repeat', false), false); $repeat = FabrikAdminElementHelper::getRepeat($this) || $repeat; $c = (int) FabrikAdminElementHelper::getRepeatCounter($this); $mode = $this->getAttribute('mode'); $connectionDd = $repeat ? $connection . '-' . $c : $connection; $highlightPk = FabrikWorker::toBoolean($this->getAttribute('highlightpk', false), false); $tableDd = $this->getAttribute('table'); $opts = new stdClass(); $opts->table = $repeat ? 'jform_' . $tableDd . '-' . $c : 'jform_' . $tableDd; $opts->conn = 'jform_' . $connectionDd; $opts->value = $this->value; $opts->repeat = $repeat; $opts->showAll = (int) $this->getAttribute('showall', '1'); $opts->highlightpk = (int) $highlightPk; $opts->mode = $mode; $opts->defaultOpts = $res; $opts->addBrackets = FabrikWorker::toBoolean($this->getAttribute('addbrackets', false), false); $opts = json_encode($opts); $script = array(); $script[] = "if (typeOf(FabrikAdmin.model.fields.listfields) === 'null') {"; $script[] = "FabrikAdmin.model.fields.listfields = {};"; $script[] = "}"; $script[] = "if (FabrikAdmin.model.fields.listfields['{$this->id}'] === undefined) {"; $script[] = "FabrikAdmin.model.fields.listfields['{$this->id}'] = new ListFieldsElement('{$this->id}', {$opts});"; $script[] = "}"; $script = implode("\n", $script); $srcs = array('Fabrik' => 'media/com_fabrik/js/fabrik.js', 'ListFields' => 'administrator/components/com_fabrik/models/fields/listfields.js'); FabrikHelperHTML::script($srcs, $script); }
private function js($res = array()) { $connection = $this->element['connection']; $repeat = FabrikAdminElementHelper::getRepeat($this) || $this->element['repeat']; $c = (int) FabrikAdminElementHelper::getRepeatCounter($this); $mode = (string) JArrayHelper::getValue($this->element, 'mode', false); $connectionDd = $repeat ? $connection . '-' . $c : $connection; $highlightpk = (bool) JArrayHelper::getValue($this->element, 'highlightpk', false); $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 = $repeat; $opts->showAll = (int) JArrayHelper::getValue($this->element, 'showall', '1'); $opts->highlightpk = (int) $highlightpk; $opts->mode = $mode; $opts->defaultOpts = $res; $opts->addBrackets = (bool) JArrayHelper::getValue($this->element, 'addbrackets', false); $opts = json_encode($opts); $script = array(); $script[] = "if (typeOf(FabrikAdmin.model.fields.listfields) === 'null') {"; $script[] = "FabrikAdmin.model.fields.listfields = {};"; $script[] = "}"; $script[] = "FabrikAdmin.model.fields.listfields['{$this->id}'] = new ListFieldsElement('{$this->id}', {$opts});"; $script = implode("\n", $script); $srcs = array(); $srcs[] = 'media/com_fabrik/js/fabrik.js'; $srcs[] = 'administrator/components/com_fabrik/models/fields/listfields.js'; FabrikHelperHTML::script($srcs, $script); }