Exemple #1
0
 /**
  * Display the view
  *
  * @param   string  $tpl  Template
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     // Initialise variables.
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     $this->pluginFields = $this->get('PluginHTML');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         throw new RuntimeException(implode("\n", $errors), 500);
     }
     $this->addToolbar();
     FabrikAdminHelper::setViewLayout($this);
     $srcs = FabrikHelperHTML::framework();
     $srcs[] = 'media/com_fabrik/js/fabrik.js';
     $srcs[] = 'administrator/components/com_fabrik/views/namespace.js';
     $srcs[] = 'administrator/components/com_fabrik/views/pluginmanager.js';
     $srcs[] = 'administrator/components/com_fabrik/views/visualization/adminvisualization.js';
     $shim = array();
     $dep = new stdClass();
     $dep->deps = array('admin/pluginmanager');
     $shim['admin/visualization/adminvisualization'] = $dep;
     FabrikHelperHTML::iniRequireJS($shim);
     $opts = new stdClass();
     $opts->plugin = $this->item->plugin;
     $js = "\n\tvar options = " . json_encode($opts) . ";\n\t\tFabrik.controller = new AdminVisualization(options);\n";
     FabrikHelperHTML::script($srcs, $js);
     parent::display($tpl);
 }
Exemple #2
0
 /**
  * Display the view
  *
  * @param   string  $tpl  template
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     // Initialise variables.
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     $this->js = $this->get('Js');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         throw new RuntimeException(implode("\n", $errors), 500);
     }
     $this->addToolbar();
     FabrikAdminHelper::setViewLayout($this);
     // Set up the script shim
     $shim = array();
     $dep = new stdClass();
     $dep->deps = array('fab/fabrik');
     $shim['admin/pluginmanager'] = $dep;
     FabrikHelperHTML::iniRequireJS($shim);
     $srcs = FabrikHelperHTML::framework();
     $srcs[] = 'administrator/components/com_fabrik/views/namespace.js';
     $srcs[] = 'administrator/components/com_fabrik/views/pluginmanager.js';
     FabrikHelperHTML::script($srcs, $this->js);
     parent::display($tpl);
 }
Exemple #3
0
 /**
  * Display the view
  *
  * @param   string  $tpl  Template name
  *
  * @return void
  */
 public function display($tpl = null)
 {
     switch ($this->getLayout()) {
         case 'confirmdelete':
             $this->confirmdelete();
             return;
             break;
         case 'import':
             $this->import($tpl);
             return;
             break;
     }
     // Initialise variables.
     $app = JFactory::getApplication();
     $input = $app->input;
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     $this->packageOptions = $this->get('PackageOptions');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         throw new RuntimeException(implode("\n", $errors), 500);
         return false;
     }
     $this->table_groups = $this->get('TableGroups');
     FabrikAdminHelper::setViewLayout($this);
     $this->addToolbar();
     FabrikAdminHelper::addSubmenu($input->getWord('view', 'lists'));
     if (FabrikWorker::j3()) {
         $this->sidebar = JHtmlSidebar::render();
     }
     FabrikHelperHTML::iniRequireJS();
     parent::display($tpl);
 }
Exemple #4
0
 /**
  * Display the view
  *
  * @param   string  $tpl  Template
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     // Initialiase variables.
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     $this->pluginFields = $this->get('PluginHTML');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         throw new RuntimeException(implode("\n", $errors), 500);
     }
     $this->addToolbar();
     FabrikAdminHelper::setViewLayout($this);
     $srcs = FabrikHelperHTML::framework();
     $srcs['Fabrik'] = FabrikHelperHTML::mediaFile('fabrik.js');
     $srcs['Namespace'] = 'administrator/components/com_fabrik/views/namespace.js';
     $srcs['PluginManager'] = 'administrator/components/com_fabrik/views/pluginmanager.js';
     $srcs['CronAdmin'] = 'administrator/components/com_fabrik/views/cron/admincron.js';
     $shim = array();
     $dep = new stdClass();
     $dep->deps = array('admin/pluginmanager');
     $shim['admin/cron/admincron'] = $dep;
     $opts = new stdClass();
     $opts->plugin = $this->item->plugin;
     $js = array();
     $js[] = "\twindow.addEvent('domready', function () {";
     $js[] = "\t\tFabrik.controller = new CronAdmin(" . json_encode($opts) . ");";
     $js[] = "\t})";
     FabrikHelperHTML::iniRequireJS($shim);
     FabrikHelperHTML::script($srcs, implode("\n", $js));
     parent::display($tpl);
 }
Exemple #5
0
 /**
  * Ini the Fabrik requirejs framework files
  *
  * @return  void
  */
 protected function shim()
 {
     $shim = array();
     $dep = new stdClass();
     $dep->deps = array('fab/fabrik', 'fab/listfilter', 'fab/advanced-search', 'fab/encoder');
     $shim['fab/list'] = $dep;
     FabrikHelperHTML::iniRequireJS($shim);
 }
Exemple #6
0
 /**
  * Method to get the field input markup.
  *
  * @return  string	The field input markup.
  */
 protected function getInput()
 {
     $j3 = FabrikWorker::j3();
     $from = $this->id . '-from';
     $add = $this->id . '-add';
     $remove = $this->id . '-remove';
     $up = $this->id . '-up';
     $down = $this->id . '-down';
     $script[] = "window.addEvent('domready', function () {";
     $script[] = "\tswaplist = new SwapList('{$from}', '{$this->id}','{$add}', '{$remove}', '{$up}', '{$down}');";
     $script[] = "});";
     FabrikHelperHTML::framework();
     FabrikHelperHTML::iniRequireJS();
     FabrikHelperHTML::script('administrator/components/com_fabrik/models/fields/swaplist.js', implode("\n", $script));
     list($this->currentGroups, $this->currentGroupList) = $this->getCurrentGroupList();
     list($this->groups, $this->groupList) = $this->getGroupList();
     $str = '';
     $checked = empty($this->current_groups) ? 'checked="checked"' : '';
     if (empty($this->groups) && empty($this->currentGroups)) {
         return JText::_('COM_FABRIK_NO_GROUPS_AVAILABLE');
     } else {
         if ($j3) {
             $str = JText::_('COM_FABRIK_AVAILABLE_GROUPS');
             $str .= '<br />' . $this->groupList;
             $str .= '<button class="button btn btn-success btn-small" type="button" id="' . $this->id . '-add">';
             $str .= '<i class="icon-new"></i>' . JText::_('COM_FABRIK_ADD') . '</button>';
             $str .= '<br />' . JText::_('COM_FABRIK_CURRENT_GROUPS');
             $str .= '<br />' . $this->currentGroupList;
             $str .= '<button class="button btn btn-small" type="button" id="' . $this->id . '-up" >';
             $str .= '<i class="icon-arrow-up"></i> ' . JText::_('COM_FABRIK_UP') . '</button> ';
             $str .= '<button class="button btn btn-small" type="button" id="' . $this->id . '-down" >';
             $str .= '<i class="icon-arrow-down"></i> ' . JText::_('COM_FABRIK_DOWN') . '</button> ';
             $str .= '<button class="button btn btn-danger btn-small" type="button" id="' . $this->id . '-remove">';
             $str .= '<i class="icon-delete"></i> ' . JText::_('COM_FABRIK_REMOVE');
             $str .= '</button>';
         } else {
             $str .= '<input type="text" readonly="readonly" class="readonly" style="clear:left" size="44" value="' . JText::_('COM_FABRIK_AVAILABLE_GROUPS') . ':" />';
             $str .= $this->groupList;
             $str .= '<input class="button btn" type="button" id="' . $this->id . '-add" value="' . JText::_('COM_FABRIK_ADD') . '" />';
             $str .= '<input type="text" readonly="readonly" class="readonly" style="clear:left" size="44" value="' . JText::_('COM_FABRIK_CURRENT_GROUPS') . ':" />';
             $str .= $this->currentGroupList;
             $str .= '<input class="button" type="button" value="' . JText::_('COM_FABRIK_UP') . '" id="' . $this->id . '-up" />';
             $str .= '<input class="button" type="button" value="' . JText::_('COM_FABRIK_DOWN') . '" id="' . $this->id . '-down" />';
             $str .= '<input class="button" type="button" value="' . JText::_('COM_FABRIK_REMOVE') . '" id="' . $this->id . '-remove"/>';
         }
         return $str;
     }
 }
Exemple #7
0
 /**
  * Display the view
  *
  * @param   string  $tpl  Template
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     // Initialise variables.
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         throw new RuntimeException(implode("\n", $errors), 500);
     }
     $this->addToolbar();
     FabrikAdminHelper::setViewLayout($this);
     $srcs = FabrikHelperHTML::framework();
     FabrikHelperHTML::iniRequireJS();
     FabrikHelperHTML::script($srcs);
     parent::display($tpl);
 }
Exemple #8
0
 /**
  * Display
  *
  * @param   string $tpl Template
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     FabrikHelperHTML::framework();
     FabrikHelperHTML::iniRequireJS();
     $input = $this->app->input;
     $model = $this->getModel('form');
     $filter = JFilterInput::getInstance();
     $post = $filter->clean($_POST, 'array');
     if (!array_key_exists('youremail', $post)) {
         FabrikHelperHTML::emailForm($model);
     } else {
         $to = $input->getString('email', '');
         if ($this->sendMail($to)) {
             $this->app->enqueueMessage(FText::_('COM_FABRIK_THIS_ITEM_HAS_BEEN_SENT_TO') . ' ' . $to, 'success');
         }
         FabrikHelperHTML::emailSent();
     }
 }
Exemple #9
0
 /**
  * Display the view
  *
  * @param   string  $tpl  template
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     $srcs = FabrikHelperHTML::framework();
     FabrikHelperHTML::script($srcs);
     $db = FabrikWorker::getDbo(true);
     $query = $db->getQuery(true);
     $query->select('*')->from('#__{package}_log')->where('message_type != ""')->order('timedate_created DESC');
     $db->setQuery($query, 0, 10);
     $this->logs = $db->loadObjectList();
     $this->feed = $this->get('RSSFeed');
     $this->addToolbar();
     FabrikAdminHelper::addSubmenu('home');
     FabrikAdminHelper::setViewLayout($this);
     if (FabrikWorker::j3()) {
         $this->sidebar = JHtmlSidebar::render();
     }
     FabrikHelperHTML::iniRequireJS();
     parent::display($tpl);
 }
Exemple #10
0
 /**
  * Display the view
  *
  * @param   string  $tpl  Template
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     $input = $app->input;
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         throw new RuntimeException(implode("\n", $errors), 500);
     }
     FabrikAdminHelper::setViewLayout($this);
     $this->addToolbar();
     FabrikAdminHelper::addSubmenu($input->getWord('view', 'lists'));
     if (FabrikWorker::j3()) {
         $this->sidebar = JHtmlSidebar::render();
     }
     FabrikHelperHTML::iniRequireJS();
     parent::display($tpl);
 }
Exemple #11
0
 /**
  * Display the view
  *
  * @param   string  $tpl  template
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     // Initialiase variables.
     $model = $this->getModel();
     $this->item = $this->get('Item');
     $model->checkDefault($this->item);
     $this->form = $this->get('Form');
     $this->form->bind($this->item);
     $this->state = $this->get('State');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         throw new RuntimeException(implode("\n", $errors), 500);
     }
     $this->addToolbar();
     FabrikAdminHelper::setViewLayout($this);
     $srcs = FabrikHelperHTML::framework();
     $srcs['Fabrik'] = 'media/com_fabrik/js/fabrik.js';
     FabrikHelperHTML::iniRequireJS();
     FabrikHelperHTML::script($srcs);
     parent::display($tpl);
 }
Exemple #12
0
 /**
  * Method to get the field input markup.
  *
  * @return  string    The field input markup.
  */
 protected function getInput()
 {
     if (is_null($this->results)) {
         $this->results = array();
     }
     $app = JFactory::getApplication();
     $input = $app->input;
     $controller = $input->get('view', $input->get('task'));
     $formModel = false;
     $filter = $this->getAttribute('filter');
     $pluginFilters = trim($filter) == '' ? array() : explode('|', $filter);
     $connection = $this->getAttribute('connection');
     /*
      * 27/08/2011 - changed from default table-element to id - for juser form plugin - might cause havoc
      * else where but loading elements by id as default seems more robust (and is the default behaviour in f2.1
      */
     $valueFormat = (string) $this->getAttribute('valueformat', 'id');
     $onlyListFields = (int) $this->getAttribute('onlylistfields', 0);
     $showRaw = FabrikWorker::toBoolean($this->getAttribute('raw', false), false);
     $labelMethod = (string) $this->getAttribute('label_method');
     $noJoins = FabrikWorker::toBoolean($this->getAttribute('nojoins', false), false);
     $mode = (string) $this->getAttribute('mode', false);
     $useStep = FabrikWorker::toBoolean($this->getAttribute('usestep', false), false);
     switch ($controller) {
         case 'validationrule':
             $res = $this->_validationOptions();
             break;
         case 'visualization':
         case 'element':
             $res = $this->_elementOptions($connection);
             break;
         case 'listform':
         case 'list':
         case 'module':
         case 'item':
             // Menu item
             $res = $this->_listOptions($controller, $valueFormat, $useStep, $onlyListFields, $showRaw, $pluginFilters, $labelMethod, $noJoins);
             break;
         case 'form':
             $res = $this->_formOptions($valueFormat, $useStep, $onlyListFields, $showRaw, $pluginFilters, $labelMethod, $noJoins);
             break;
         case 'group':
             $res = $this->_groupOptions($useStep, $valueFormat, $onlyListFields, $showRaw, $pluginFilters, $labelMethod, $noJoins);
             break;
         default:
             return FText::_('The ListFields element is only usable by lists and elements');
             break;
     }
     $return = '';
     if (is_array($res)) {
         $aEls = $this->_formatOptions($res, $valueFormat);
         // For pk fields - we are no longer storing the key with '`' as that's mySQL specific
         $this->value = str_replace('`', '', $this->value);
         // Some elements were stored as names but subsequently changed to ids (need to check for old values an substitute with correct ones)
         if ($valueFormat == 'id' && !is_numeric($this->value) && $this->value != '') {
             if ($formModel) {
                 $elementModel = $formModel->getElement($this->value);
                 $this->value = $elementModel ? $elementModel->getId() : $this->value;
             }
         }
         if ($mode === 'gui') {
             $this->js($aEls);
             $return = $this->gui();
         } else {
             $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="' . FText::_('LOADING') . '" />';
         }
     }
     FabrikHelperHTML::framework();
     FabrikHelperHTML::iniRequireJS();
     return $return;
 }
Exemple #13
0
 /**
  * Method to get the field input markup.
  *
  * @return  string	The field input markup.
  */
 protected function getInput()
 {
     static $fabrikelements;
     if (!isset($fabrikelements)) {
         $fabrikelements = array();
     }
     $src[] = 'administrator/components/com_fabrik/views/namespace.js';
     $c = (int) @$this->form->repeatCounter;
     $table = $this->element['table'];
     if ($table == '') {
         $table = $this->form->getValue('params.list_id');
     }
     $include_calculations = (int) $this->element['include_calculations'];
     $published = (int) $this->element['published'];
     $showintable = (int) $this->element['showintable'];
     $highlightpk = (bool) JArrayHelper::getValue($this->element, 'highlightpk', false);
     $mode = (string) $this->element['mode'];
     if ($include_calculations != 1) {
         $include_calculations = 0;
     }
     /*
      * $$$ hugh - don't know what's going on here, except that this method is getting called twice for every element
      * but first time round, $this->value is not set, so if we cache it, setting loses it's value.
      * if (!array_key_exists($this->id, $fabrikelements)) {
      */
     $opts = new stdClass();
     if ($this->form->repeat) {
         // In repeat fieldset/group
         $conn = $this->element['connection'] . '-' . $this->form->repeatCounter;
         $opts->table = 'jform_' . $table . '-' . $this->form->repeatCounter;
     } else {
         $conn = $c === false || $this->element['connection_in_repeat'] == 'false' ? $this->element['connection'] : $this->element['connection'] . '-' . $c;
         $opts->table = $c === false || $this->element['connection_in_repeat'] == 'false' ? 'jform_' . $table : 'jform_' . $table . '-' . $c;
     }
     $opts->published = $published;
     $opts->showintable = $showintable;
     $opts->excludejoined = (int) $this->element['excludejoined'];
     $opts->livesite = COM_FABRIK_LIVESITE;
     $opts->conn = 'jform_' . $conn;
     $opts->value = $this->value;
     $opts->include_calculations = $include_calculations;
     $opts->highlightpk = (int) $highlightpk;
     $opts = json_encode($opts);
     $script = array();
     $script[] = "var p = new elementElement('{$this->id}', {$opts});";
     $script[] = "FabrikAdmin.model.fields.element['{$this->id}'] = p;";
     $script = implode("\n", $script);
     $fabrikelements[$this->id] = true;
     $src[] = 'administrator/components/com_fabrik/models/fields/element.js';
     FabrikHelperHTML::script($src, $script);
     if ($mode === 'gui') {
         $return = $this->gui();
     } else {
         $return = parent::getInput();
         $return .= '<img style="margin-left:10px;display:none" id="' . $this->id . '_loader" src="components/com_fabrik/images/ajax-loader.gif" alt="' . JText::_('COM_FABRIK_LOADING') . '" />';
     }
     FabrikHelperHTML::framework();
     FabrikHelperHTML::iniRequireJS();
     return $return;
 }
Exemple #14
0
 /**
  * Display the view
  *
  * @param   string  $tpl  Template
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     if ($this->getLayout() == 'confirmupdate') {
         $this->confirmupdate();
         return;
     }
     // Initialiase variables.
     $model = $this->getModel();
     $this->form = $model->getForm();
     $this->item = $model->getItem();
     $this->state = $model->getState();
     $this->pluginFields = $model->getPluginHTML();
     $this->js = $model->getJs();
     // Check for errors.
     if (count($errors = $model->getErrors())) {
         throw new RuntimeException(implode("\n", $errors), 500);
     }
     $this->addToolbar();
     $this->parent = $model->getParent();
     FabrikAdminHelper::setViewLayout($this);
     JText::script('COM_FABRIK_ERR_ELEMENT_JS_ACTION_NOT_DEFINED');
     $srcs = FabrikHelperHTML::framework();
     $srcs[] = 'media/com_fabrik/js/fabrik.js';
     $srcs[] = 'administrator/components/com_fabrik/views/namespace.js';
     $srcs[] = 'administrator/components/com_fabrik/views/pluginmanager.js';
     $srcs[] = 'administrator/components/com_fabrik/views/element/tmpl/adminelement.js';
     $shim = array();
     $dep = new stdClass();
     $dep->deps = array('admin/pluginmanager');
     $shim['admin/element/tmpl/adminelement'] = $dep;
     $shim['adminfields/tables'] = $dep;
     $plugManagerDeps = new stdClass();
     $plugManagerDeps->deps = array('admin/namespace');
     $shim['admin/pluginmanager'] = $plugManagerDeps;
     FabrikHelperHTML::iniRequireJS($shim);
     FabrikHelperHTML::script($srcs, $this->js);
     parent::display($tpl);
 }
Exemple #15
0
 /**
  * Method to get the field input markup.
  *
  * @return  string	The field input markup.
  */
 protected function getInput()
 {
     if (is_null($this->results)) {
         $this->results = array();
     }
     $app = JFactory::getApplication();
     $input = $app->input;
     $controller = $input->get('view', $input->get('task'));
     $formModel = false;
     $aEls = array();
     $pluginFilters = trim($this->element['filter']) == '' ? array() : explode('|', $this->element['filter']);
     $c = (int) FabrikAdminElementHelper::getRepeatCounter($this);
     $connection = $this->element['connection'];
     /*
      * 27/08/2011 - changed from default table-element to id - for juser form plugin - might cause havoc
      * else where but loading elements by id as default seems more robust (and is the default behaviour in f2.1
      */
     $valueformat = (string) JArrayHelper::getValue($this->element, 'valueformat', 'id');
     $onlylistfields = (int) JArrayHelper::getValue($this->element, 'onlylistfields', 0);
     $showRaw = (bool) JArrayHelper::getValue($this->element, 'raw', false);
     $labelMethod = (string) JArrayHelper::getValue($this->element, 'label_method');
     $nojoins = (bool) JArrayHelper::getValue($this->element, 'nojoins', false);
     $mode = (string) JArrayHelper::getValue($this->element, 'mode', false);
     $useStep = (bool) JArrayHelper::getValue($this->element, 'usestep', false);
     switch ($controller) {
         case 'validationrule':
             $id = $input->getInt('id');
             $pluginManager = FabrikWorker::getPluginManager();
             $elementModel = $pluginManager->getElementPlugin($id);
             $element = $elementModel->getElement();
             $res = $this->loadFromGroupId($element->group_id);
             break;
         case 'visualization':
         case 'element':
             $repeat = FabrikAdminElementHelper::getRepeat($this) || $this->element['repeat'];
             // @TODO this seems like we could re-factor it to use the formModel class as per the table and form switches below?
             // $connectionDd = ($c === false) ? $connection : $connection . '-' . $c;
             $connectionDd = $repeat ? $connection . '-' . $c : $connection;
             if ($connection == '') {
                 $groupId = isset($this->form->rawData) ? JArrayHelper::getValue($this->form->rawData, 'group_id', 0) : $this->form->getValue('group_id');
                 $res = $this->loadFromGroupId($groupId);
             } else {
                 $this->js();
                 $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)) {
                 if (!in_array($controller, array('item', 'module'))) {
                     // Seems to work anyway in the admin module page - so lets not raise notice
                     $app->enqueueMessage('Model not set in listfields field ' . $this->id, 'notice');
                 }
                 return;
             }
             $listModel = $this->form->model;
             if ($id !== 0) {
                 $formModel = $listModel->getFormModel();
                 $valfield = $valueformat == 'tableelement' ? 'name' : 'id';
                 $res = $formModel->getElementOptions($useStep, $valfield, $onlylistfields, $showRaw, $pluginFilters, $labelMethod, $nojoins);
             } else {
                 $res = array();
             }
             break;
         case 'form':
             if (!isset($this->form->model)) {
                 throw new RuntimeException('Model not set in listfields field ' . $this->id);
                 return;
             }
             $formModel = $this->form->model;
             $valfield = $valueformat == 'tableelement' ? 'name' : 'id';
             $res = $formModel->getElementOptions($useStep, $valfield, $onlylistfields, $showRaw, $pluginFilters, $labelMethod, $nojoins);
             $jsres = $formModel->getElementOptions($useStep, $valfield, $onlylistfields, $showRaw, $pluginFilters, $labelMethod, $nojoins);
             array_unshift($jsres, JHTML::_('select.option', '', JText::_('COM_FABRIK_PLEASE_SELECT')));
             $this->js($jsres);
             break;
         case 'group':
             $valfield = $valueformat == 'tableelement' ? 'name' : 'id';
             $id = $this->form->getValue('id');
             $groupModel = JModelLegacy::getInstance('Group', 'FabrikFEModel');
             $groupModel->setId($id);
             $formModel = $groupModel->getFormModel();
             $res = $formModel->getElementOptions($useStep, $valfield, $onlylistfields, $showRaw, $pluginFilters, $labelMethod, $nojoins);
             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;
         }
         // Paul - Prepend rather than append "none" option.
         array_unshift($aEls, JHTML::_('select.option', '', '-'));
         // For pk fields - we are no longer storing the key with '`' as that's mySQL specific
         $this->value = str_replace('`', '', $this->value);
         // Some elements were stored as names but subsequently changed to ids (need to check for old values an substitute with correct ones)
         if ($valueformat == 'id' && !is_numeric($this->value) && $this->value != '') {
             if ($formModel) {
                 $elementModel = $formModel->getElement($this->value);
                 $this->value = $elementModel ? $elementModel->getId() : $this->value;
             }
         }
         if ($mode === 'gui') {
             $this->js($aEls);
             $return = $this->gui();
         } else {
             $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') . '" />';
         }
     }
     FabrikHelperHTML::framework();
     FabrikHelperHTML::iniRequireJS();
     return $return;
 }
 /**
  * Method to get the field input markup.
  *
  * @since	1.6
  *
  * @return	string	The field input markup.
  */
 protected function getInput()
 {
     // Initialize variables.
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $options = array();
     JHTML::stylesheet('administrator/components/com_fabrik/views/fabrikadmin.css');
     $subForm = new JForm($this->name, array('control' => 'jform'));
     $xml = $this->element->children()->asXML();
     $subForm->load($xml);
     $j3 = FabrikWorker::j3();
     // Needed for repeating modals in gmaps viz
     $subForm->repeatCounter = (int) @$this->form->repeatCounter;
     /**
      * f3 hack
      */
     $input = $app->input;
     $view = $input->get('view', 'list');
     switch ($view) {
         case 'item':
             $view = 'list';
             $id = (int) $this->form->getValue('request.listid');
             break;
         case 'module':
             $view = 'list';
             $id = (int) $this->form->getValue('params.list_id');
             break;
         default:
             $id = $input->getInt('id');
             break;
     }
     if ($view === 'element') {
         $pluginManager = FabrikWorker::getPluginManager();
         $feModel = $pluginManager->getPluginFromId($id);
     } else {
         $feModel = JModelLegacy::getInstance($view, 'FabrikFEModel');
         $feModel->setId($id);
     }
     $subForm->model = $feModel;
     // Hack for order by elements which we now want to store as ids
     $v = json_decode($this->value);
     if (isset($v->order_by)) {
         $formModel = $feModel->getFormModel();
         foreach ($v->order_by as &$orderBy) {
             $elementModel = $formModel->getElement($orderBy, true);
             $orderBy = $elementModel ? $elementModel->getId() : $orderBy;
         }
     }
     $this->value = json_encode($v);
     /*
      * end
      */
     $children = $this->element->children();
     // $$$ rob 19/07/2012 not sure y but this fires a strict standard warning deep in JForm, suppress error for now
     @$subForm->setFields($children);
     $str = array();
     $version = new JVersion();
     $j32 = version_compare($version->RELEASE, '3.2') >= 0 ? true : false;
     $modalid = $j32 ? 'attrib-' . $this->id . '_modal' : $this->id . '_modal';
     // As JForm will render child fieldsets we have to hide it via CSS
     $fieldSetId = str_replace('jform_params_', '', $modalid);
     $css = '#' . $fieldSetId . ' { display: none; }';
     $document->addStyleDeclaration($css);
     $path = 'templates/' . $app->getTemplate() . '/images/menu/';
     $str[] = '<div id="' . $modalid . '" style="display:none">';
     $str[] = '<table class="adminlist ' . $this->element['class'] . ' table table-striped">';
     $str[] = '<thead><tr class="row0">';
     $names = array();
     $attributes = $this->element->attributes();
     foreach ($subForm->getFieldset($attributes->name . '_modal') as $field) {
         $names[] = (string) $field->element->attributes()->name;
         $str[] = '<th>' . strip_tags($field->getLabel($field->name));
         $str[] = '<br /><small style="font-weight:normal">' . JText::_($field->description) . '</small>';
         $str[] = '</th>';
     }
     if ($j3) {
         $str[] = '<th><a href="#" class="add btn button btn-success"><i class="icon-plus"></i> </a></th>';
     } else {
         $str[] = '<th><a href="#" class="add"><img src="' . $path . '/icon-16-new.png" alt="' . JText::_('ADD') . '" /></a></th>';
     }
     $str[] = '</tr></thead>';
     $str[] = '<tbody><tr>';
     foreach ($subForm->getFieldset($attributes->name . '_modal') as $field) {
         $str[] = '<td>' . $field->getInput() . '</td>';
     }
     $str[] = '<td>';
     if ($j3) {
         $str[] = '<div class="btn-group"><a class="add btn button btn-success"><i class="icon-plus"></i> </a>';
         $str[] = '<a class="remove btn button btn-danger"><i class="icon-minus"></i> </a></div>';
     } else {
         $str[] = '<a href="#" class="add"><img src="' . $path . '/icon-16-new.png" alt="' . JText::_('ADD') . '" /></a>';
         $str[] = '<a href="#" class="remove"><img src="' . $path . '/icon-16-delete.png" alt="' . JText::_('REMOVE') . '" /></a>';
     }
     $str[] = '</td>';
     $str[] = '</tr></tbody>';
     $str[] = '</table>';
     $str[] = '</div>';
     $form = implode("\n", $str);
     static $modalrepeat;
     if (!isset($modalrepeat)) {
         $modalrepeat = array();
     }
     if (!array_key_exists($modalid, $modalrepeat)) {
         $modalrepeat[$modalid] = array();
     }
     if (!isset($this->form->repeatCounter)) {
         $this->form->repeatCounter = 0;
     }
     if (!array_key_exists($this->form->repeatCounter, $modalrepeat[$modalid])) {
         // If loaded as js template then we don't want to repeat this again. (fabrik)
         $names = json_encode($names);
         $pane = str_replace('jform_params_', '', $modalid) . '-options';
         $modalrepeat[$modalid][$this->form->repeatCounter] = true;
         $opts = new stdClass();
         $opts->j3 = $j3;
         $opts = json_encode($opts);
         $script = str_replace('-', '', $modalid) . " = new FabrikModalRepeat('{$modalid}', {$names}, '{$this->id}', {$opts});";
         $option = $input->get('option');
         if ($option === 'com_fabrik') {
             FabrikHelperHTML::script('administrator/components/com_fabrik/models/fields/fabrikmodalrepeat.js', $script);
         } else {
             if ($j3) {
                 $context = strtoupper($option);
                 if ($context === 'COM_ADVANCEDMODULES') {
                     $context = 'COM_MODULES';
                 }
                 $j3pane = $context . '_' . str_replace('jform_params_', '', $modalid) . '_FIELDSET_LABEL';
                 if ($j32) {
                     $j3pane = strtoupper(str_replace('attrib-', '', $j3pane));
                 }
                 $script = "window.addEvent('domready', function() {\n\t\t\t\tvar a = jQuery(\"a:contains('{$j3pane}')\");\n\t\t\t\t\t\tif (a.length > 0) {\n\t\t\t\t\t\t\ta = a[0];\n\t\t\t\t\t\t\tvar href= a.get('href');\n\t\t\t\t\t\t\tjQuery(href)[0].destroy();\n\n\t\t\t\t\t\t\tvar accord = a.getParent('.accordion-group');\n\t\t\t\t\t\t\tif (typeOf(accord) !== 'null') {\n\t\t\t\t\t\t\t\taccord.destroy();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\ta.destroy();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t" . $script . "\n\t\t\t\t\t\t}\n\t\t\t\t\t});";
             } else {
                 $script = "window.addEvent('domready', function() {\n\t\t\t" . $script . "\n\t\t\tif (typeOf(\$('{$pane}')) !== 'null') {\n\t\t\t  \$('{$pane}').getParent().hide();\n\t\t\t}\n\t\t\t});";
             }
             // Wont work when rendering in admin module page
             // @TODO test this now that the list and form pages are loading plugins via ajax (18/08/2012)
             FabrikHelperHTML::script('administrator/components/com_fabrik/models/fields/fabrikmodalrepeat.js', $script);
         }
     }
     if (is_array($this->value)) {
         $this->value = array_shift($this->value);
     }
     $value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
     if ($j3) {
         $icon = $this->element['icon'] ? '<i class="icon-' . $this->element['icon'] . '"></i> ' : '';
         $icon .= JText::_('JLIB_FORM_BUTTON_SELECT');
         $str[] = '<button class="btn" id="' . $modalid . '_button" data-modal="' . $modalid . '">' . $icon . '</button>';
         $str[] = '<input type="hidden" name="' . $this->name . '" id="' . $this->id . '" value="' . $value . '" />';
     } else {
         $str[] = '<div class="button2-left">';
         $str[] = '	<div class="blank">';
         $str[] = '		<a id="' . $modalid . '_button" data-modal="' . $modalid . '">' . JText::_('JLIB_FORM_BUTTON_SELECT') . '</a>';
         $str[] = '		<input type="hidden" name="' . $this->name . '" id="' . $this->id . '" value="' . $value . '" />';
         $str[] = '	</div>';
         $str[] = '</div>';
     }
     FabrikHelperHTML::framework();
     FabrikHelperHTML::iniRequireJS();
     return implode("\n", $str);
 }
Exemple #17
0
 /**
  * Show a view for selecting which group the element should be copied to
  *
  * @param   string  $tpl  Template
  *
  * @return  void
  */
 public function copySelectGroup($tpl = null)
 {
     JSession::checkToken() or die('Invalid Token');
     $model = $this->getModel();
     $app = JFactory::getApplication();
     $input = $app->input;
     $model->setState('filter.cid', $input->get('cid', array(), 'array'));
     $this->items = $this->get('Items');
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('id, name')->from('#__fabrik_groups')->order('name');
     $db->setQuery($query);
     $this->groups = $db->loadObjectList();
     $this->addConfirmCopyToolbar();
     FabrikHelperHTML::iniRequireJS();
     parent::display($tpl);
 }
Exemple #18
0
 /**
  * Append the form javascript into the document head
  *
  * @param   int $listId table id
  *
  * @return  void|boolean
  */
 protected function _addJavascript($listId)
 {
     $pluginManager = FabrikWorker::getPluginManager();
     /** @var FabrikFEModelForm $model */
     $model = $this->getModel();
     $aLoadedElementPlugins = array();
     $jsActions = array();
     $bKey = $model->jsKey();
     $srcs = FabrikHelperHTML::framework();
     $shim = array();
     if (!defined('_JOS_FABRIK_FORMJS_INCLUDED')) {
         define('_JOS_FABRIK_FORMJS_INCLUDED', 1);
         FabrikHelperHTML::slimbox();
         $dep = new stdClass();
         $dep->deps = array('fab/element', 'lib/form_placeholder/Form.Placeholder', 'fab/encoder');
         $shim['fabrik/form'] = $dep;
         $deps = new stdClass();
         $deps->deps = array('fab/fabrik', 'fab/element', 'fab/form-submit');
         $framework['fab/elementlist'] = $deps;
         $srcs[] = 'media/com_fabrik/js/lib/form_placeholder/Form.Placeholder.js';
         FabrikHelperHTML::addToFrameWork($srcs, 'media/com_fabrik/js/form');
         FabrikHelperHTML::addToFrameWork($srcs, 'media/com_fabrik/js/form-submit');
         FabrikHelperHTML::addToFrameWork($srcs, 'media/com_fabrik/js/element');
     }
     $aWYSIWYGNames = array();
     // $$$ hugh - yet another one where if we =, the $groups array pointer get buggered up and it
     // skips a group
     $groups = $model->getGroupsHiarachy();
     foreach ($groups as $groupModel) {
         $elementModels = $groupModel->getPublishedElements();
         foreach ($elementModels as $elementModel) {
             $res = $elementModel->useEditor();
             if ($res !== false && $elementModel->canUse() && $model->isEditable()) {
                 $aWYSIWYGNames[] = $res;
             }
             // Load in once the element js class files
             $element = $elementModel->getElement();
             if (!in_array($element->plugin, $aLoadedElementPlugins)) {
                 /* $$$ hugh - certain elements, like file-upload, need to load different JS files
                  * on a per-element basis, so as a test fix, I modified the file-upload's formJavaScriptClass to return false,
                  * and test for that here, so as to not add it to aLoadedElementPlugins[].  The existing 'static' tests in
                  * formJavascriptClass() should still prevent scripts being added twice.
                  */
                 if ($elementModel->formJavascriptClass($srcs, '', $shim) !== false) {
                     $aLoadedElementPlugins[] = $element->plugin;
                 }
             }
             $eventMax = $groupModel->repeatTotal == 0 ? 1 : $groupModel->repeatTotal;
             for ($c = 0; $c < $eventMax; $c++) {
                 $jsAct = $elementModel->getFormattedJSActions($bKey, $c);
                 if (!empty($jsAct)) {
                     $jsActions[] = $jsAct;
                 }
             }
         }
     }
     FabrikHelperHTML::iniRequireJS($shim);
     $actions = trim(implode("\n", $jsActions));
     FabrikHelperHTML::windows('a.fabrikWin');
     FabrikHelperHTML::tips('.hasTip', array(), "\$('{$bKey}')");
     $model->getFormCss();
     $opts = $this->jsOpts();
     $model->jsOpts = $opts;
     $pluginManager->runPlugins('onJSOpts', $model);
     $opts = json_encode($model->jsOpts);
     if (!FabrikHelperHTML::inAjaxLoadedPage()) {
         JText::script('COM_FABRIK_VALIDATING');
         JText::script('COM_FABRIK_SUCCESS');
         JText::script('COM_FABRIK_NO_REPEAT_GROUP_DATA');
         JText::script('COM_FABRIK_VALIDATION_ERROR');
         JText::script('COM_FABRIK_CONFIRM_DELETE_1');
     }
     JText::script('COM_FABRIK_FORM_SAVED');
     // $$$ rob don't declare as var $bKey, but rather assign to window, as if loaded via ajax window the function is wrapped
     // inside an anonymous function, and therefore $bKey wont be available as a global var in window
     $script = array();
     $script[] = "\t\tvar {$bKey} = Fabrik.form('{$bKey}', " . $model->getId() . ", {$opts});";
     // Instantiate js objects for each element
     $vstr = "\n";
     $groups = $model->getGroupsHiarachy();
     $script[] = "\tFabrik.blocks['{$bKey}'].addElements(";
     $groupedJs = new stdClass();
     foreach ($groups as $groupModel) {
         $groupId = $groupModel->getGroup()->id;
         $groupedJs->{$groupId} = array();
         if (!$groupModel->canView('form')) {
             continue;
         }
         $elementJs = array();
         $elementModels = $groupModel->getPublishedElements();
         // $$$ rob if repeatTotal is 0 we still want to add the js objects as the els are only hidden
         $max = $groupModel->repeatTotal > 0 ? $groupModel->repeatTotal : 1;
         foreach ($elementModels as $elementModel) {
             $element = $elementModel->getElement();
             if ($element->published == 0) {
                 continue;
             }
             // If the view is a form then we should always add the js as long as the element is editable or viewable
             // if the view is details then we should only add the js if the element is viewable.
             if ($elementModel->canUse() && $model->isEditable() || $elementModel->canView()) {
                 for ($c = 0; $c < $max; $c++) {
                     $ref = $elementModel->elementJavascript($c);
                     if (!empty($ref)) {
                         $elementJs[] = $ref;
                     }
                     $validations = $elementModel->validator->findAll();
                     if (!empty($validations) && $elementModel->isEditable()) {
                         $watchElements = $elementModel->getValidationWatchElements($c);
                         foreach ($watchElements as $watchElement) {
                             $vstr .= "\tFabrik.blocks['{$bKey}'].watchValidation('" . $watchElement['id'] . "', '" . $watchElement['triggerEvent'] . "');\n";
                         }
                     }
                 }
             }
         }
         $groupedJs->{$groupId} = $elementJs;
     }
     $script[] = json_encode($groupedJs);
     $script[] = "\t);";
     $script[] = $actions;
     $script[] = $vstr;
     // Placeholder
     $script[] = "\tnew Form.Placeholder('.fabrikForm input');";
     $this->_addJavascriptSumbit($script, $listId, $aWYSIWYGNames);
     if (FabrikHelperHTML::inAjaxLoadedPage()) {
         $tipOpts = FabrikHelperHTML::tipOpts();
         $script[] = "new FloatingTips('#" . $bKey . " .fabrikTip', " . json_encode($tipOpts) . ");";
     }
     $res = $pluginManager->runPlugins('onJSReady', $model);
     if (in_array(false, $res)) {
         return false;
     }
     $str = implode("\n", $script);
     $model->getCustomJsAction($srcs);
     $pluginManager->runPlugins('onAfterJSLoad', $model);
     // 3.1 call form js plugin code within main require method
     $srcs = array_merge($srcs, $model->formPluginShim);
     $str .= $model->formPluginJS;
     FabrikHelperHTML::script($srcs, $str);
 }
Exemple #19
0
 /**
  * Method to get the field input markup.
  *
  * @return  string    The field input markup.
  */
 protected function getInput()
 {
     static $fabrikElements;
     if (!isset($fabrikElements)) {
         $fabrikElements = array();
     }
     $src[] = 'administrator/components/com_fabrik/views/namespace.js';
     $c = (int) @$this->form->repeatCounter;
     $table = $this->getAttribute('table');
     if ($table == '') {
         $table = $this->form->getValue('params.list_id');
     }
     $includeCalculations = (int) $this->getAttribute('include_calculations');
     $published = (int) $this->getAttribute('published');
     $showInTable = (int) $this->getAttribute('showintable');
     $highlightPk = FabrikWorker::toBoolean($this->getAttribute('highlightpk', false), false);
     $mode = $this->getAttribute('mode');
     $connection = $this->getAttribute('connection');
     $connectionInRepeat = FabrikWorker::toBoolean($this->getAttribute('connection_in_repeat', true), true);
     $excludeJoined = (int) $this->getAttribute('excludejoined');
     if ($includeCalculations != 1) {
         $includeCalculations = 0;
     }
     $opts = new stdClass();
     if ($this->form->repeat) {
         // In repeat fieldset/group
         $conn = $connection . '-' . $this->form->repeatCounter;
         $opts->table = 'jform_' . $table . '-' . $this->form->repeatCounter;
     } else {
         $conn = $c === false || !$connectionInRepeat ? $connection : $connection . '-' . $c;
         $opts->table = $c === false || !$connectionInRepeat ? 'jform_' . $table : 'jform_' . $table . '-' . $c;
     }
     $opts->published = $published;
     $opts->showintable = $showInTable;
     $opts->excludejoined = $excludeJoined;
     $opts->livesite = COM_FABRIK_LIVESITE;
     $opts->conn = 'jform_' . $conn;
     $opts->value = $this->value;
     $opts->include_calculations = $includeCalculations;
     $opts->highlightpk = (int) $highlightPk;
     $opts = json_encode($opts);
     $script = array();
     $script[] = "var p = new elementElement('{$this->id}', {$opts});";
     $script[] = "FabrikAdmin.model.fields.element['{$this->id}'] = p;";
     $script = implode("\n", $script);
     $fabrikElements[$this->id] = true;
     $src[] = 'administrator/components/com_fabrik/models/fields/element.js';
     FabrikHelperHTML::script($src, $script);
     if ($mode === 'gui') {
         $return = $this->gui();
     } else {
         $return = parent::getInput();
         $return .= '<img style="margin-left:10px;display:none" id="' . $this->id . '_loader" src="components/com_fabrik/images/ajax-loader.gif" alt="' . FText::_('COM_FABRIK_LOADING') . '" />';
     }
     FabrikHelperHTML::framework();
     FabrikHelperHTML::iniRequireJS();
     return $return;
 }
Exemple #20
0
    /**
     * Method to get the field input markup for the editor area
     *
     * @return  string  The field input markup.
     *
     * @since   1.6
     */
    protected function getInput()
    {
        // Initialize some field attributes.
        $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
        $disabled = (string) $this->element['disabled'] == 'true' ? ' disabled="disabled"' : '';
        $columns = $this->element['cols'] ? ' cols="' . (int) $this->element['cols'] . '"' : '';
        $rows = $this->element['rows'] ? ' rows="' . (int) $this->element['rows'] . '"' : '';
        $required = $this->required ? ' required="required" aria-required="true"' : '';
        // JS events are saved as encoded html - so we don't want to double encode them
        $encoded = JArrayHelper::getValue($this->element, 'encoded', false);
        if (!$encoded) {
            $this->value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
        }
        $onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
        $editor = '<textarea name="' . $this->name . '" id="' . $this->id . '"' . $columns . $rows . $class . $disabled . $onchange . $required . '>' . $this->value . '</textarea>';
        $version = new JVersion();
        if ($version->RELEASE == 2.5) {
            return $editor;
        }
        // Joomla 3 version
        $mode = $this->element['mode'] ? (string) $this->element['mode'] : 'html';
        $theme = $this->element['theme'] ? (string) $this->element['theme'] : 'github';
        $height = $this->element['height'] ? (string) $this->element['height'] : '200px';
        $maxHeight = $this->element['max-height'] ? (string) $this->element['max-height'] : str_ireplace('px', '', $height) * 2 . 'px';
        $width = $this->element['width'] ? (string) $this->element['width'] : '100';
        FabrikHelperHTML::framework();
        FabrikHelperHTML::iniRequireJS();
        if ($mode === 'php') {
            $aceMode = '{path:"ace/mode/php", inline:true}';
        } else {
            $aceMode = '"ace/mode/' . $mode . '"';
        }
        $minHeight = str_ireplace('px', '', $height);
        $maxHeight = str_ireplace('px', '', $maxHeight);
        /**
         * In code below...
         *   the +/- 2 is to account for the top/bottom border of 1px each
         *
         *   pluginmanager.js renames names/ids when you delete a preceding plugin which breaks ace
         *   so we need to keep ace-ids intact and avoid issues with duplicate ids by:
         *       adding a random string to the id where ace needs id to be kept the same; and
         *       save dom object for textarea so that change of id doesn't break it.
         **/
        $aceid = $this->id . '_' . sprintf("%06x", mt_rand(0, 0xffffff));
        $script = '
window.addEvent(\'domready\', function () {
	if (Fabrik.debug) {
		fconsole("Fabrik editor initialising: ' . $this->id . '");
	}
	var field = document.id("' . $this->id . '");
	var FbEditor = ace.edit("' . $aceid . '-ace");
	FbEditor.setTheme("ace/theme/' . $theme . '");
	FbEditor.getSession().setMode(' . $aceMode . ');
	FbEditor.setValue(field.value);
	FbEditor.navigateFileStart();
	FbEditor.setAnimatedScroll(true);
	FbEditor.setBehavioursEnabled(true);
	FbEditor.setDisplayIndentGuides(true);
	FbEditor.setHighlightGutterLine(true);
	FbEditor.setHighlightSelectedWord(true);
	FbEditor.setShowFoldWidgets(true);
	FbEditor.setWrapBehavioursEnabled(true);
	FbEditor.getSession().setUseWrapMode(true);
	FbEditor.getSession().setTabSize(2);
	FbEditor.on("blur", function () {
		if (field.value !== FbEditor.getValue()) {
			field.value = FbEditor.getValue();
			field.fireEvent("change", field);
		}
		field.fireEvent("blur", field);
	});
	var maxlines = Math.floor((' . $maxHeight . ' - 2) / FbEditor.renderer.lineHeight);
	var updateHeight = function () {
		var s = FbEditor.getSession();
		var r = FbEditor.renderer;
		var l = s.getScreenLength();
		var h = (l > maxlines ? maxlines : l)
		      * r.lineHeight
		      + (r.$horizScroll ? r.scrollBar.getWidth() : 0)
		      + 2;
		h = h < ' . $minHeight . ' ? ' . $minHeight . ' : h;
		c = document.id("' . $aceid . '-aceContainer").getStyle("height").toInt();
		if (c !== h) {
			document.id("' . $aceid . '-aceContainer").setStyle("height", h.toString() + "px");
			FbEditor.resize();
		}
	}
	updateHeight();
	FbEditor.getSession().on("change", updateHeight);
});
		';
        $src = array('media/com_fabrik/js/lib/ace/src-min-noconflict/ace.js', 'media/com_fabrik/js/fabrik.js');
        FabrikHelperHTML::script($src, $script);
        echo '<style type="text/css" media="screen">
	#' . $aceid . '-ace {
		position: absolute;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		border: 1px solid #c0c0c0;
		border-radius: 3px;
	}

	#' . $aceid . '-aceContainer {
		position: relative;
		width: ' . $width . ';
		height: ' . $height . ';
	}
</style>';
        $this->element['cols'] = 1;
        $this->element['rows'] = 1;
        // For element js event code.
        return '<div id="' . $aceid . '-aceContainer"><div id="' . $aceid . '-ace"></div>' . $editor . '</div>';
    }
Exemple #21
0
 /**
  * Display the view
  *
  * @param   string  $tpl  Template
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     // Initialise variables.
     JHtml::_('behavior.modal', 'a.modal');
     $model = $this->getModel();
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     $this->listform = $this->get('PackageListForm');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         throw new RuntimeException(implode("\n", $errors), 500);
     }
     $this->addToolbar();
     $canvas = FArrayHelper::getValue($this->item->params, 'canvas', array());
     $blocks = new stdClass();
     $b = FArrayHelper::getValue($canvas, 'blocks', array());
     $blocks->form = FArrayHelper::getValue($b, 'form', array());
     $blocks->list = FArrayHelper::getValue($b, 'list', array());
     $blocks->visualization = FArrayHelper::getValue($b, 'visualization', array());
     $opts = JArrayHelper::getvalue($canvas, 'options', array());
     $d = new stdClass();
     $layout = FArrayHelper::getValue($canvas, 'layout', $d);
     $document = JFactory::getDocument();
     $opts = new stdClass();
     $opts->blocks = $blocks;
     $opts->layout = $layout;
     $opts = json_encode($opts);
     $this->js = "PackageCanvas = new AdminPackage({$opts});";
     $srcs[] = 'administrator/components/com_fabrik/views/package/adminpackage.js';
     FabrikHelperHTML::iniRequireJS();
     FabrikHelperHTML::script($srcs, $this->js);
     // Simple layout
     $this->listOpts = $model->getListOpts();
     $this->formOpts = $model->getFormOpts();
     $this->selFormOpts = $model->getSelFormOpts();
     $this->selListOpts = $model->getSelListOpts();
     FabrikAdminHelper::setViewLayout($this);
     parent::display($tpl);
 }
Exemple #22
0
 /**
  * Get JS objects
  *
  * @param   array $data list data
  *
  * @return  void
  */
 protected function getManagementJS($data = array())
 {
     $input = $this->app->input;
     $itemId = FabrikWorker::itemId();
     /** @var FabrikFEModelList $model */
     $model = $this->getModel();
     $params = $model->getParams();
     $item = $model->getTable();
     $listRef = $model->getRenderContext();
     $listId = $model->getId();
     $formModel = $model->getFormModel();
     $elementsNotInTable = $formModel->getElementsNotInTable();
     $toggleCols = (bool) $params->get('toggle_cols', false);
     $ajax = (int) $model->isAjax();
     $ajaxLinks = (bool) $params->get('list_ajax_links', $ajax);
     $opts = new stdClass();
     $pluginManager = FabrikWorker::getPluginManager();
     if ($ajaxLinks) {
         $modalTitle = 'test';
         $modalOpts = array('content' => '', 'id' => 'ajax_links', 'title' => JText::_($modalTitle), 'modal' => false, 'expandable' => true);
         FabrikHelperHTML::jLayoutJs('ajax_links', 'fabrik-modal', (object) $modalOpts);
     }
     // Advanced search
     if ($params->get('advanced-filter')) {
         $modalOpts = array('content' => '', 'id' => 'advanced-filter', 'title' => JText::_('COM_FABRIK_FIELD_ADVANCED_SEARCH_LABEL'), 'modal' => false, 'expandable' => true);
         FabrikHelperHTML::jLayoutJs('advanced-filter', 'fabrik-modal', (object) $modalOpts);
     }
     FabrikHelperHTML::jLayoutJs('modal-state-label', 'list.fabrik-filters-modal-state-label', $layoutData = (object) array('label' => '', 'displayValue' => '', 'key' => ''));
     $this->csvJS($opts, $model);
     if ($model->requiresSlimbox()) {
         FabrikHelperHTML::slimbox();
     }
     if ($model->requiresSlideshow()) {
         FabrikHelperHTML::slideshow();
     }
     $src = FabrikHelperHTML::framework();
     $shim = array();
     $dep = new stdClass();
     $dep->deps = array();
     $shim['fab/list'] = $dep;
     $src['FbList'] = FabrikHelperHTML::mediaFile('list.js');
     $src['FbListFilter'] = FabrikHelperHTML::mediaFile('listfilter.js');
     $src['ListPlugin'] = FabrikHelperHTML::mediaFile('list-plugin.js');
     $src = $model->getPluginJsClasses($src, $shim);
     $pluginManager->runPlugins('loadJavascriptClassName', $model, 'list');
     $pluginManager->data = array_filter($pluginManager->data, function ($v) {
         return $v !== '';
     });
     $model->getCustomJsAction($src);
     $tmpl = $model->getTmpl();
     $this->tmpl = $tmpl;
     $model->getListCss();
     // Check for a custom js file and include it if it exists
     $aJsPath = JPATH_SITE . '/components/com_fabrik/views/list/tmpl/' . $tmpl . '/javascript.js';
     if (JFile::exists($aJsPath)) {
         $src['CustomJs'] = 'components/com_fabrik/views/list/tmpl/' . $tmpl . '/javascript.js';
     }
     $origRows = $this->rows;
     $this->rows = array(array());
     $tmpItemid = !isset($itemId) ? 0 : $itemId;
     $this->_row = new stdClass();
     $script = array();
     $params = $model->getParams();
     $opts->admin = $this->app->isAdmin();
     $opts->ajax = $ajax;
     $opts->ajax_links = $ajaxLinks;
     $opts->links = array('detail' => $params->get('detailurl', ''), 'edit' => $params->get('editurl', ''), 'add' => $params->get('addurl', ''));
     $opts->filterMethod = $this->filter_action;
     $opts->advancedFilters = $model->getAdvancedFilterValues();
     $opts->resetFilters = (bool) FabrikWorker::getMenuOrRequestVar('resetfilters', 0, false, 'request');
     $opts->form = 'listform_' . $listRef;
     $this->listref = $listRef;
     $opts->headings = $model->jsonHeadings();
     $labels = $this->headings;
     foreach ($labels as &$l) {
         $l = strip_tags($l);
     }
     $opts->labels = $labels;
     $opts->primaryKey = $item->db_primary_key;
     $opts->Itemid = $tmpItemid;
     $opts->listRef = $listRef;
     $opts->formid = $model->getFormModel()->getId();
     $opts->canEdit = $model->canEdit() ? '1' : '0';
     $opts->canView = $model->canView() ? '1' : '0';
     $opts->page = JRoute::_('index.php');
     $opts->isGrouped = $this->isGrouped;
     $opts->toggleCols = $toggleCols;
     $opts->j3 = FabrikWorker::j3();
     $opts->singleOrdering = (bool) $model->singleOrdering();
     // Reset data back to original settings
     $this->rows = $origRows;
     $formEls = array();
     foreach ($elementsNotInTable as $tmpElement) {
         $oo = new stdClass();
         $oo->name = $tmpElement->name;
         $oo->label = $tmpElement->label;
         $formEls[] = $oo;
     }
     $opts->formels = $formEls;
     $opts->fabrik_show_in_list = $input->get('fabrik_show_in_list', array(), 'array');
     $opts->popup_width = $params->get('popup_width', '');
     $opts->popup_height = $params->get('popup_height', '');
     $xOffset = $params->get('popup_offset_x', '');
     $yOffset = $params->get('popup_offset_y', '');
     if ($xOffset !== '') {
         $opts->popup_offset_x = (int) $xOffset;
     }
     if ($yOffset !== '') {
         $opts->popup_offset_y = (int) $yOffset;
     }
     /**
      * Added the $nodata object as we now weed something to pass in just to keep editLabel
      * and viewLabel happy, after adding placeholder replacement to the labels for a Pro user,
      * because the tooltips said we did that, which we never actually did.
      *
      * http://fabrikar.com/forums/index.php?threads/placeholders-in-list-links-and-labels.37726/#post-191081
      *
      * However, this means that using placeholders will yield funky labels for the popups, as
      * this isn't per row.  So we may need to not use editLabel / viewLabel here any more,
      * and just use the default COM_FABRIK_VIEW/EDIT.  Or add YAFO's, ::sigh::.
      *
      * But for now, it's too corner case to worry about!
      */
     $nodata = new stdClass();
     $opts->popup_edit_label = $model->editLabel($nodata);
     $opts->popup_view_label = $model->viewLabel($nodata);
     $opts->popup_add_label = $model->addLabel();
     $opts->limitLength = $model->limitLength;
     $opts->limitStart = $model->limitStart;
     $opts->tmpl = $tmpl;
     $opts->data = $data;
     $opts->groupByOpts = new stdClass();
     $opts->groupByOpts->isGrouped = (bool) $this->isGrouped;
     $opts->groupByOpts->collapseOthers = (bool) $params->get('group_by_collapse_others', false);
     $opts->groupByOpts->startCollapsed = (bool) $params->get('group_by_start_collapsed', false);
     $opts->groupByOpts->bootstrap = FabrikWorker::j3();
     // If table data starts as empty then we need the html from the row
     // template otherwise we can't add a row to the table
     ob_start();
     $this->_row = new stdClass();
     $this->_row->id = '';
     $this->_row->class = 'fabrik_row';
     echo $this->loadTemplate('row');
     $opts->itemTemplate = ob_get_contents();
     ob_end_clean();
     // $$$rob if you are loading a table in a window from a form db join select record option
     // then we want to know the id of the window so we can set its showSpinner() method
     $opts->winid = $input->get('winid', '');
     $this->jsText();
     $script[] = "window.addEvent('domready', function () {";
     $script[] = "\tvar list = new FbList('{$listId}',";
     $script[] = "\t" . json_encode($opts);
     $script[] = "\t);";
     $script[] = "\tFabrik.addBlock('list_{$listRef}', list);";
     // Add in plugin objects
     $pluginManager->runPlugins('onLoadJavascriptInstance', $model, 'list');
     $aObjs = $pluginManager->data;
     if (!empty($aObjs)) {
         $script[] = "list.addPlugins([\n";
         $script[] = "\t" . implode(",\n  ", $aObjs);
         $script[] = "]);";
     }
     // @since 3.0 inserts content before the start of the list render (currently on f3 tmpl only)
     $pluginManager->runPlugins('onGetContentBeforeList', $model, 'list');
     $this->pluginBeforeList = $pluginManager->data;
     $script[] = $model->filterJs;
     $script[] = $this->getModel()->getElementJs($src);
     // End domready wrapper
     $script[] = '})';
     $script = implode("\n", $script);
     FabrikHelperHTML::iniRequireJS($shim);
     FabrikHelperHTML::script($src, $script);
 }
Exemple #23
0
 /**
  * Once a list is saved - we need to display the select content type form.
  *
  * @param null $tpl
  *
  * @return void
  */
 public function selectContentType($tpl = null)
 {
     $model = $this->getModel();
     $this->form = $model->getContentTypeForm();
     $input = JFactory::getApplication()->input;
     $this->data = $input->post->get('jform', array(), 'array');
     $this->addSelectSaveToolBar();
     FabrikHelperHTML::framework();
     FabrikHelperHTML::iniRequireJS();
     parent::display($tpl);
 }
Exemple #24
0
 /**
  * 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;
 }
Exemple #25
0
 /**
  * Display the list
  *
  * @param   string  $tpl  template
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     // Initialise variables.
     $model = $this->getModel();
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $formModel = $this->get('FormModel');
     $formModel->setId($this->item->form_id);
     $this->state = $this->get('State');
     $this->js = $model->getJs();
     $this->addToolbar();
     if ($this->item->id == 0) {
         $this->order_by = array(JText::_('COM_FABRIK_AVAILABLE_AFTER_SAVE'));
         $this->group_by = JText::_('COM_FABRIK_AVAILABLE_AFTER_SAVE');
     } else {
         $this->order_by = array();
         $feListModel = $formModel->getListModel();
         $orderbys = $feListModel->getOrderBys();
         foreach ($orderbys as $orderby) {
             $this->order_by[] = $formModel->getElementList('order_by[]', $orderby, true, false, false, 'id');
         }
         if (empty($this->order_by)) {
             $this->order_by[] = $formModel->getElementList('order_by[]', '', true, false, false, 'id');
         }
         $orderDir[] = JHTML::_('select.option', 'ASC', JText::_('COM_FABRIK_ASCENDING'));
         $orderDir[] = JHTML::_('select.option', 'DESC', JText::_('COM_FABRIK_DESCENDING'));
         $orderdirs = FabrikWorker::JSONtoData($this->item->order_dir, true);
         $this->order_dir = array();
         $attribs = 'class="inputbox" size="1" ';
         foreach ($orderdirs as $orderdir) {
             $this->order_dir[] = JHTML::_('select.genericlist', $orderDir, 'order_dir[]', $attribs, 'value', 'text', $orderdir);
         }
         if (empty($this->order_dir)) {
             $this->order_dir[] = JHTML::_('select.genericlist', $orderDir, 'order_dir[]', $attribs, 'value', 'text', '');
         }
         $this->group_by = $formModel->getElementList('group_by', $this->item->group_by, true, false, false);
     }
     FabrikAdminHelper::setViewLayout($this);
     $srcs = FabrikHelperHTML::framework();
     $srcs[] = 'media/com_fabrik/js/fabrik.js';
     $srcs[] = 'administrator/components/com_fabrik/views/namespace.js';
     $srcs[] = 'administrator/components/com_fabrik/views/pluginmanager.js';
     $srcs[] = 'administrator/components/com_fabrik/views/list/tmpl/adminlist.js';
     $shim = array();
     $dep = new stdClass();
     $dep->deps = array('admin/pluginmanager');
     $shim['admin/list/tmpl/adminlist'] = $dep;
     $shim['adminfields/tables'] = $dep;
     FabrikHelperHTML::iniRequireJS($shim);
     FabrikHelperHTML::script($srcs, $this->js);
     parent::display($tpl);
 }
Exemple #26
0
 /**
  * Get JS objects
  *
  * @param   array  $data  list data
  *
  * @return  void
  */
 protected function getManagementJS($data = array())
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $Itemid = FabrikWorker::itemId();
     $model = $this->getModel();
     $params = $model->getParams();
     $item = $model->getTable();
     $listref = $model->getRenderContext();
     $listid = $model->getId();
     $formModel = $model->getFormModel();
     $elementsNotInTable = $formModel->getElementsNotInTable();
     $toggleCols = (bool) $params->get('toggle_cols', false);
     if ($model->requiresSlimbox()) {
         FabrikHelperHTML::slimbox();
     }
     if ($model->requiresSlideshow()) {
         FabrikHelperHTML::slideshow();
     }
     $src = FabrikHelperHTML::framework();
     $shim = array();
     $dep = new stdClass();
     $dep->deps = array('fab/fabrik', 'fab/listfilter', 'fab/advanced-search', 'fab/encoder');
     if ($toggleCols) {
         $dep->deps[] = 'fab/list-toggle';
     }
     $shim['fab/list'] = $dep;
     $src = $model->getPluginJsClasses($src, $shim);
     FabrikHelperHTML::addToFrameWork($src, 'media/com_fabrik/js/list');
     $model->getCustomJsAction($src);
     $tmpl = $model->getTmpl();
     $this->tmpl = $tmpl;
     $model->getListCss();
     // Check for a custom js file and include it if it exists
     $aJsPath = JPATH_SITE . '/components/com_fabrik/views/list/tmpl/' . $tmpl . '/javascript.js';
     if (JFile::exists($aJsPath)) {
         $src[] = 'components/com_fabrik/views/list/tmpl/' . $tmpl . '/javascript.js';
     }
     $origRows = $this->rows;
     $this->rows = array(array());
     $tmpItemid = !isset($Itemid) ? 0 : $Itemid;
     $this->_row = new stdClass();
     $script = array();
     $params = $model->getParams();
     $opts = new stdClass();
     $opts->admin = $app->isAdmin();
     $opts->ajax = (int) $model->isAjax();
     $opts->ajax_links = (bool) $params->get('list_ajax_links', $opts->ajax);
     $opts->links = array('detail' => $params->get('detailurl', ''), 'edit' => $params->get('editurl', ''), 'add' => $params->get('addurl', ''));
     $opts->filterMethod = $this->filter_action;
     $opts->advancedFilters = $model->getAdvancedFilterValues();
     $opts->form = 'listform_' . $listref;
     $this->listref = $listref;
     $opts->headings = $model->jsonHeadings();
     $labels = $this->headings;
     foreach ($labels as &$l) {
         $l = strip_tags($l);
     }
     $opts->labels = $labels;
     $opts->primaryKey = $item->db_primary_key;
     $opts->Itemid = $tmpItemid;
     $opts->listRef = $listref;
     $opts->formid = $model->getFormModel()->getId();
     $opts->canEdit = $model->canEdit() ? "1" : "0";
     $opts->canView = $model->canView() ? "1" : "0";
     $opts->page = JRoute::_('index.php');
     $opts->isGrouped = $this->isGrouped;
     $opts->toggleCols = $toggleCols;
     $opts->j3 = FabrikWorker::j3();
     $opts->singleOrdering = (bool) $model->singleOrdering();
     $formEls = array();
     foreach ($elementsNotInTable as $tmpElement) {
         $oo = new stdClass();
         $oo->name = $tmpElement->name;
         $oo->label = $tmpElement->label;
         $formEls[] = $oo;
     }
     $opts->formels = $formEls;
     $opts->fabrik_show_in_list = $input->get('fabrik_show_in_list', array(), 'array');
     $opts->csvChoose = (bool) $params->get('csv_frontend_selection');
     $opts->popup_width = $params->get('popup_width', '');
     $opts->popup_height = $params->get('popup_height', '');
     $xOffset = $params->get('popup_offset_x', '');
     $yOffset = $params->get('popup_offset_y', '');
     if ($xOffset !== '') {
         $opts->popup_offset_x = (int) $xOffset;
     }
     if ($yOffset !== '') {
         $opts->popup_offset_y = (int) $yOffset;
     }
     $opts->popup_edit_label = $model->editLabel();
     $opts->popup_view_label = $model->viewLabel();
     $opts->popup_add_label = $model->addLabel();
     $opts->limitLength = $model->limitLength;
     $opts->limitStart = $model->limitStart;
     $opts->tmpl = $tmpl;
     $csvOpts = new stdClass();
     $csvOpts->excel = (int) $params->get('csv_format');
     $csvOpts->inctabledata = (int) $params->get('csv_include_data');
     $csvOpts->incraw = (int) $params->get('csv_include_raw_data');
     $csvOpts->inccalcs = (int) $params->get('csv_include_calculations');
     $csvOpts->custom_qs = $params->get('csv_custom_qs', '');
     $opts->csvOpts = $csvOpts;
     $opts->csvFields = $model->getCsvFields();
     $csvOpts->incfilters = (int) $params->get('incfilters');
     $opts->data = $data;
     $opts->groupByOpts = new stdClass();
     $opts->groupByOpts->isGrouped = (bool) $this->isGrouped;
     $opts->groupByOpts->collapseOthers = (bool) $params->get('group_by_collapse_others', false);
     $opts->groupByOpts->startCollapsed = (bool) $params->get('group_by_start_collapsed', false);
     $opts->groupByOpts->bootstrap = FabrikWorker::j3();
     // If table data starts as empty then we need the html from the row
     // template otherwise we can't add a row to the table
     ob_start();
     $this->_row = new stdClass();
     $this->_row->id = '';
     $this->_row->class = 'fabrik_row';
     echo $this->loadTemplate('row');
     $opts->rowtemplate = ob_get_contents();
     ob_end_clean();
     // $$$rob if you are loading a table in a window from a form db join select record option
     // then we want to know the id of the window so we can set its showSpinner() method
     $opts->winid = $input->get('winid', '');
     $opts = json_encode($opts);
     JText::script('COM_FABRIK_PREV');
     JText::script('COM_FABRIK_SELECT_ROWS_FOR_DELETION');
     JText::script('JYES');
     JText::script('JNO');
     JText::script('COM_FABRIK_SELECT_COLUMNS_TO_EXPORT');
     JText::script('COM_FABRIK_INCLUDE_FILTERS');
     JText::script('COM_FABRIK_INCLUDE_DATA');
     JText::script('COM_FABRIK_INCLUDE_RAW_DATA');
     JText::script('COM_FABRIK_INCLUDE_CALCULATIONS');
     JText::script('COM_FABRIK_EXPORT');
     JText::script('COM_FABRIK_START');
     JText::script('COM_FABRIK_NEXT');
     JText::script('COM_FABRIK_END');
     JText::script('COM_FABRIK_PAGE');
     JText::script('COM_FABRIK_OF');
     JText::script('COM_FABRIK_LOADING');
     JText::script('COM_FABRIK_RECORDS');
     JText::script('COM_FABRIK_SAVING_TO');
     JText::script('COM_FABRIK_CONFIRM_DROP');
     JText::script('COM_FABRIK_CONFIRM_DELETE_1');
     JText::script('COM_FABRIK_NO_RECORDS');
     JText::script('COM_FABRIK_CSV_COMPLETE');
     JText::script('COM_FABRIK_CSV_DOWNLOAD_HERE');
     JText::script('COM_FABRIK_CONFIRM_DELETE');
     JText::script('COM_FABRIK_CSV_DOWNLOADING');
     JText::script('COM_FABRIK_FILE_TYPE');
     JText::script('COM_FABRIK_ADVANCED_SEARCH');
     JText::script('COM_FABRIK_FORM_FIELDS');
     JText::script('COM_FABRIK_VIEW');
     // Keyboard short cuts
     JText::script('COM_FABRIK_LIST_SHORTCUTS_ADD');
     JText::script('COM_FABRIK_LIST_SHORTCUTS_EDIT');
     JText::script('COM_FABRIK_LIST_SHORTCUTS_DELETE');
     JText::script('COM_FABRIK_LIST_SHORTCUTS_FILTER');
     $script[] = "window.addEvent('domready', function () {";
     $script[] = "\tvar list = new FbList('{$listid}',";
     $script[] = "\t" . $opts;
     $script[] = "\t);";
     $script[] = "\tFabrik.addBlock('list_{$listref}', list);";
     // Add in plugin objects
     $params = $model->getParams();
     $pluginManager = FabrikWorker::getPluginManager();
     $c = 0;
     $pluginManager->runPlugins('onLoadJavascriptInstance', $model, 'list');
     $aObjs = $pluginManager->data;
     if (!empty($aObjs)) {
         $script[] = "list.addPlugins([\n";
         $script[] = "\t" . implode(",\n  ", $aObjs);
         $script[] = "]);";
     }
     // @since 3.0 inserts content before the start of the list render (currently on f3 tmpl only)
     $pluginManager->runPlugins('onGetContentBeforeList', $model, 'list');
     $this->pluginBeforeList = $pluginManager->data;
     $script[] = $model->filterJs;
     // Was separate but should now load in with the rest of the require js code
     $model = $this->getModel();
     $script[] = $model->getElementJs($src);
     // End domready wrapper
     $script[] = '})';
     $script = implode("\n", $script);
     FabrikHelperHTML::iniRequireJS($shim);
     FabrikHelperHTML::script($src, $script);
     // Reset data back to original settings
     $this->rows = $origRows;
 }
Exemple #27
0
 /**
  * See if the user wants to rename the list/form/groups
  *
  * @param   string  $tpl  template
  *
  * @return  void
  */
 public function confirmCopy($tpl = null)
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $cid = $input->get('cid', array(0), 'array');
     $lists = array();
     $model = $this->getModel();
     foreach ($cid as $id) {
         $model->setId($id);
         $table = $model->getTable();
         $formModel = $model->getFormModel();
         $row = new stdClass();
         $row->id = $id;
         $row->formid = $table->form_id;
         $row->label = $table->label;
         $row->formlabel = $formModel->getForm()->label;
         $groups = $formModel->getGroupsHiarachy();
         $row->groups = array();
         foreach ($groups as $group) {
             $grouprow = new stdClass();
             $g = $group->getGroup();
             $grouprow->id = $g->id;
             $grouprow->name = $g->name;
             $row->groups[] = $grouprow;
         }
         $lists[] = $row;
     }
     $this->lists = $lists;
     $this->addConfirmCopyToolbar();
     FabrikHelperHTML::iniRequireJS();
     parent::display($tpl);
 }
Exemple #28
0
 /**
  * Method to get the field input markup.
  *
  * @return	string	The field input markup.
  */
 protected function getInput()
 {
     JText::script('COM_FABRIK_SUBOPTS_VALUES_ERROR');
     $default = new stdClass();
     $default->sub_values = array();
     $default->sub_labels = array();
     $default->sub_initial_selection = array();
     $opts = $this->value == '' ? $default : JArrayHelper::toObject($this->value);
     $j3 = FabrikWorker::j3();
     if ($j3) {
         $delButton = '<div class="btn-group">';
         $delButton .= '<a class="btn btn-success" href="#" data-button="addSuboption"><i class="icon-plus"></i> </a>';
         $delButton .= '<a class="btn btn-danger" href="#" data-button="deleteSuboption"><i class="icon-minus"></i> </a>';
         $delButton .= '</div>';
     } else {
         $delButton = '<a class="removeButton" href="#"><i class="icon-minus"></i> ' . JText::_('COM_FABRIK_DELETE') . '</a>';
     }
     if (is_array($opts)) {
         $opts['delButton'] = $delButton;
     } else {
         $opts->delButton = $delButton;
     }
     $opts->id = $this->id;
     $opts->j3 = $j3;
     $opts = json_encode($opts);
     $script[] = "window.addEvent('domready', function () {";
     $script[] = "\tnew Suboptions('{$this->name}', {$opts});";
     $script[] = "});";
     FabrikHelperHTML::script('administrator/components/com_fabrik/models/fields/suboptions.js', implode("\n", $script));
     $html = array();
     if (!$j3) {
         $html[] = '<div style="float:left;width:100%">';
     }
     $html[] = '<table class="table table-striped" style="width: 100%" id="' . $this->id . '">';
     $html[] = '<thead>';
     $html[] = '<tr style="text-align:left">';
     $html[] = '<th style="width: 5%"></th>';
     $html[] = '<th style="width: 30%">' . JText::_('COM_FABRIK_VALUE') . '</th>';
     $html[] = '<th style="width: 30%">' . JText::_('COM_FABRIK_LABEL') . '</th>';
     $html[] = '<th style="width: 10%">' . JText::_('COM_FABRIK_DEFAULT') . '</th>';
     if ($j3) {
         $html[] = '<th style="width: 20%"><a class="btn btn-success" href="#" data-button="addSuboption"><i class="icon-plus"></i> </a></th>';
     }
     $html[] = '</tr>';
     $html[] = '</thead>';
     $html[] = '<tbody></tbody>';
     $html[] = '</table>';
     if (!$j3) {
         $html[] = '<ul id="sub_subElementBody" class="subelements">';
         $html[] = '<li></li>';
         $html[] = '</ul>';
         $html[] = '<a class="addButton" href="#" id="addSuboption"><i class="icon-plus"></i> ' . JText::_('COM_FABRIK_ADD') . '</a></div>';
     }
     FabrikHelperHTML::framework();
     FabrikHelperHTML::iniRequireJS();
     return implode("\n", $html);
 }
Exemple #29
0
 /**
  * Method to get the field input markup.
  *
  * @return  string    The field input markup.
  */
 protected function getInput()
 {
     $c = isset($this->form->repeatCounter) ? (int) $this->form->repeatCounter : 0;
     $connectionDd = $this->getAttribute('observe');
     $connectionInRepeat = FabrikWorker::toBoolean($this->getAttribute('connection_in_repeat', 'true'), true);
     $script = array();
     if (!isset($fabrikTables)) {
         $fabrikTables = array();
     }
     if ($connectionDd != '' && !array_key_exists($this->id, $fabrikTables)) {
         $repeatCounter = empty($this->form->repeatCounter) ? 0 : $this->form->repeatCounter;
         if ($this->form->repeat) {
             // In repeat fieldset/group
             $connectionDd = $connectionDd . '-' . $repeatCounter;
         } else {
             $connectionDd = $c === false || !$connectionInRepeat ? $connectionDd : $connectionDd . '-' . $c;
         }
         $opts = new stdClass();
         $opts->livesite = COM_FABRIK_LIVESITE;
         $opts->conn = 'jform_' . $connectionDd;
         $opts->value = $this->value;
         $opts->connInRepeat = $connectionInRepeat;
         $opts->inRepeatGroup = $this->form->repeat;
         $opts->repeatCounter = $repeatCounter;
         $opts->container = 'test';
         $opts = json_encode($opts);
         $script[] = "var p = new fabriktablesElement('{$this->id}', {$opts});";
         $script[] = "FabrikAdmin.model.fields.fabriktable['{$this->id}'] = p;";
         $fabrikTables[$this->id] = true;
         $src['Fabrik'] = 'media/com_fabrik/js/fabrik.js';
         $src['Namespace'] = 'administrator/components/com_fabrik/views/namespace.js';
         $src['FabrikTables'] = 'administrator/components/com_fabrik/models/fields/fabriktables.js';
         FabrikHelperHTML::script($src, $script);
     }
     $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;
 }