Exemple #1
0
 /**
  * Create the form bottom hidden fields
  *
  * @param   object &$form Object containing form view properties
  *
  * @return  void
  */
 protected function _loadTmplBottom(&$form)
 {
     $input = $this->app->input;
     $itemId = FabrikWorker::itemId();
     /** @var FabrikFEModelForm $model */
     $model = $this->getModel();
     $listModel = $model->getListModel();
     $row = JArrayHelper::toObject($model->data);
     $canDelete = $listModel->canDelete($row);
     $params = $model->getParams();
     $task = 'form.process';
     $refer = $input->server->get('HTTP_REFERER', '', 'string');
     // $$$rob - if returning from a failed validation then we should use the fabrik_referrer post var
     $refer = str_replace('&', '&', $input->get('fabrik_referrer', $refer, 'string'));
     $thisRowId = is_array($model->getRowId()) ? implode('|', $model->getRowId()) : $model->getRowId();
     $fields = array();
     $fields[] = '<input type="hidden" name="listid" value="' . $listModel->getId() . '" />';
     $fields[] = '<input type="hidden" name="listref" value="' . $listModel->getId() . '" />';
     $fields[] = '<input type="hidden" name="rowid" value="' . $thisRowId . '" />';
     $fields[] = '<input type="hidden" name="Itemid" value="' . $itemId . '" />';
     $fields[] = '<input type="hidden" name="option" value="com_' . $this->package . '" />';
     $fields[] = '<input type="hidden" name="task" value="' . $task . '" />';
     $fields[] = '<input type="hidden" name="isMambot" value="' . $this->isMambot . '" />';
     $fields[] = '<input type="hidden" name="formid" value="' . $model->get('id') . '" />';
     $fields[] = '<input type="hidden" name="returntoform" value="0" />';
     $fields[] = '<input type="hidden" name="fabrik_referrer" value="' . $refer . '" />';
     $fields[] = '<input type="hidden" name="fabrik_ajax" value="' . (int) $model->isAjax() . '" />';
     $fields[] = '<input type="hidden" name="package" value="' . $this->app->getUserState('com_fabrik.package', 'fabrik') . '" />';
     $fields[] = '<input type="hidden" name="packageId" value="' . $model->packageId . '" />';
     if ($useKey = FabrikWorker::getMenuOrRequestVar('usekey', '')) {
         // $$$rob v's been set from -1 to the actual row id - so ignore usekey not sure if we should comment this out
         // see http://fabrikar.com/forums/showthread.php?t=10297&page=5
         $fields[] = '<input type="hidden" name="usekey" value="' . $useKey . '" />';
         $pk_val = FArrayHelper::getValue($model->data, $listModel->getPrimaryKey(true));
         if (empty($pk_val)) {
             $fields[] = '<input type="hidden" name="usekey_newrecord" value="1" />';
         }
     }
     /** $$$ hugh - testing a fix for pagination issue when submitting a 'search form'.
      * If this is a search form, we need to clear 'limitstart', otherwise ... say we
      * were last on page 4 of the (unfiltered) target table, and the search yields less than 4 pages,
      * we end up with a blank table 'cos the wrong LIMIT's are applied to the query
      */
     $saveInSessions = $params->get('save_insession', '');
     if (is_array($saveInSessions)) {
         foreach ($saveInSessions as $saveInSession) {
             if ($saveInSession == '1') {
                 $fields[] = '<input type="hidden" name="limitstart" value="0" />';
                 break;
             }
         }
     }
     $fields[] = JHTML::_('form.token');
     $resetLabel = FText::_($params->get('reset_button_label'));
     $resetIcon = $params->get('reset_icon', '');
     $copyLabel = FText::_($params->get('copy_button_label'));
     $copyIcon = $params->get('copy_icon', '');
     $applyLabel = FText::_($params->get('apply_button_label'));
     $applyIcon = $params->get('apply_icon', '');
     $deleteLabel = FText::_($params->get('delete_button_label', 'Delete'));
     $deleteIcon = $params->get('delete_icon', '');
     $goBackLabel = FText::_($params->get('goback_button_label'));
     $goBackIcon = $params->get('goback_icon', '');
     $btnLayout = FabrikHelperHTML::getLayout('fabrik-button');
     if ($resetIcon !== '') {
         $resetIcon = FabrikHelperHTML::icon($resetIcon);
         $before = $params->get('reset_icon_location', 'before') == 'before';
         $resetLabel = $before ? $resetIcon . '&nbsp;' . $resetLabel : $resetLabel . '&nbsp;' . $resetIcon;
     }
     $layoutData = (object) array('type' => 'reset', 'class' => 'btn-warning button', 'name' => 'Reset', 'label' => $resetLabel);
     $form->resetButton = $params->get('reset_button', 0) && $this->editable == '1' ? $btnLayout->render($layoutData) : '';
     if ($copyIcon !== '') {
         $copyIcon = FabrikHelperHTML::icon($copyIcon);
         $copyLabel = $params->get('copy_icon_location', 'before') == 'before' ? $copyIcon . '&nbsp;' . $copyLabel : $copyLabel . '&nbsp;' . $copyIcon;
     }
     $layoutData = (object) array('type' => 'submit', 'class' => 'button', 'name' => 'Copy', 'label' => $copyLabel);
     $form->copyButton = $params->get('copy_button', 0) && $this->editable && $model->getRowId() != '' ? $btnLayout->render($layoutData) : '';
     if ($applyIcon !== '') {
         $applyIcon = FabrikHelperHTML::icon($applyIcon);
         $before = $params->get('apply_icon_location', 'before') == 'before';
         $applyLabel = $before ? $applyIcon . '&nbsp;' . $applyLabel : $applyLabel . '&nbsp;' . $applyIcon;
     }
     $layoutData = (object) array('type' => $model->isAjax() ? 'button' : 'submit', 'class' => 'button', 'name' => 'apply', 'label' => $applyLabel);
     $form->applyButton = $params->get('apply_button', 0) && $this->editable ? $btnLayout->render($layoutData) : '';
     if ($deleteIcon !== '') {
         $deleteIcon = FabrikHelperHTML::icon($deleteIcon);
         $before = $params->get('delete_icon_location', 'before') == 'before';
         $deleteLabel = $before ? $deleteIcon . '&nbsp;' . $deleteLabel : $deleteLabel . '&nbsp;' . $deleteIcon;
     }
     $layoutData = (object) array('type' => 'submit', 'class' => 'btn-danger button', 'name' => 'delete', 'label' => $deleteLabel);
     $form->deleteButton = $params->get('delete_button', 0) && $canDelete && $this->editable && $thisRowId != '' ? $btnLayout->render($layoutData) : '';
     if ($goBackIcon !== '') {
         $goBackIcon = FabrikHelperHTML::icon($goBackIcon);
         $before = $params->get('goback_icon_location', 'before') == 'before';
         $goBackLabel = $before ? $goBackIcon . '&nbsp;' . $goBackLabel : $goBackLabel . '&nbsp;' . $goBackIcon;
     }
     $layoutData = (object) array('type' => 'button', 'class' => 'button', 'name' => 'Goback', 'label' => $goBackLabel, 'attributes' => $model->isAjax() ? '' : FabrikWorker::goBackAction());
     $form->gobackButton = $params->get('goback_button', 0) ? $btnLayout->render($layoutData) : '';
     if ($model->isEditable() && $params->get('submit_button', 1)) {
         $submitClass = FabrikString::clean($form->submit_button_label);
         $submitIcon = $params->get('save_icon', '');
         $submitLabel = FText::_($form->submit_button_label);
         if ($submitIcon !== '') {
             $submitIcon = FabrikHelperHTML::icon($submitIcon);
             $before = $params->get('save_icon_location', 'before') == 'before';
             $submitLabel = $before ? $submitIcon . '&nbsp;' . $submitLabel : $submitLabel . '&nbsp;' . $submitIcon;
         }
         $layoutData = (object) array('type' => $model->isAjax() ? 'button' : 'submit', 'class' => 'btn-primary button ' . $submitClass, 'name' => 'Submit', 'label' => $submitLabel);
         $form->submitButton = $btnLayout->render($layoutData);
     } else {
         $form->submitButton = '';
     }
     if ($this->isMultiPage) {
         $layoutData = (object) array('type' => 'button', 'class' => 'fabrikPagePrevious button', 'name' => 'fabrikPagePrevious', 'label' => FabrikHelperHTML::icon('icon-previous', FText::_('COM_FABRIK_PREV')));
         $form->prevButton = $btnLayout->render($layoutData);
         $layoutData = (object) array('type' => 'button', 'class' => 'fabrikPageNext button', 'name' => 'fabrikPageNext', 'label' => FText::_('COM_FABRIK_NEXT') . '&nbsp;' . FabrikHelperHTML::icon('icon-next'));
         $form->nextButton = $btnLayout->render($layoutData);
     } else {
         $form->nextButton = '';
         $form->prevButton = '';
     }
     // $$$ hugh - hide actions section is we're printing, or if not actions selected
     $noButtons = empty($form->nextButton) && empty($form->prevButton) && empty($form->submitButton) && empty($form->gobackButton) && empty($form->deleteButton) && empty($form->applyButton) && empty($form->copyButton) && empty($form->resetButton);
     $this->hasActions = $input->get('print', '0') == '1' || $noButtons ? false : true;
     $format = $model->isAjax() ? 'raw' : 'html';
     $fields[] = '<input type="hidden" name="format" value="' . $format . '" />';
     $groups = $model->getGroupsHiarachy();
     foreach ($groups as $groupModel) {
         if ($groupModel->isJoin()) {
             $groupPk = $groupModel->getJoinModel()->getForeignId();
             // Use raw otherwise we inject the actual <input> into the hidden field's value
             $groupPk .= '_raw';
             $groupRowIds = (array) FArrayHelper::getValue($this->data, $groupPk, array());
             $groupRowIds = htmlentities(json_encode($groupRowIds));
             // Used to check against in group process(), when deleting removed repeat groups
             $fields[] = '<input type="hidden" name="fabrik_group_rowids[' . $groupModel->getId() . ']" value="' . $groupRowIds . '" />';
         }
         $group = $groupModel->getGroup();
         $c = $groupModel->repeatTotal;
         // Used for validations
         $fields[] = '<input type="hidden" name="fabrik_repeat_group[' . $group->id . ']" value="' . $c . '" id="fabrik_repeat_group_' . $group->id . '_counter" />';
     }
     // $$$ hugh - testing social_profile_hash stuff
     if ($input->get('fabrik_social_profile_hash', '') != '') {
         $fields[] = '<input type="hidden" name="fabrik_social_profile_hash" value="' . $input->get('fabrik_social_profile_hash', '') . '" id="fabrik_social_profile_hash" />';
     }
     $this->_cryptQueryString($fields);
     $this->_cryptViewOnlyElements($fields);
     $this->hiddenFields = implode("\n", $fields);
 }
Exemple #2
0
 /**
  * Create the fom bottom hidden fields
  *
  * @param   object  &$form  object containg form view properties
  *
  * @return  void
  */
 protected function _loadTmplBottom(&$form)
 {
     $app = JFactory::getApplication();
     $menuItem = $app->getMenu('site')->getActive();
     $Itemid = $menuItem ? $menuItem->id : 0;
     $model = $this->getModel();
     $listModel = $model->getListModel();
     $canDelete = $listModel->canDelete($model->_data);
     $params = $model->getParams();
     $task = 'form.process';
     $reffer = JRequest::getVar('HTTP_REFERER', '', 'server');
     // $$$rob - if returning from a failed validation then we should use the fabrik_referrer post var
     $reffer = str_replace('&', '&amp;', JRequest::getVar('fabrik_referrer', $reffer));
     $this_rowid = is_array($model->_rowId) ? implode('|', $model->_rowId) : $model->_rowId;
     $fields = array('<input type="hidden" name="listid" value="' . $listModel->getId() . '" />', '<input type="hidden" name="listref" value="' . $listModel->getId() . '" />', '<input type="hidden" name="rowid" value="' . $this_rowid . '" />', '<input type="hidden" name="Itemid" value="' . $Itemid . '" />', '<input type="hidden" name="option" value="com_fabrik" />', '<input type="hidden" name="task" value="' . $task . '" />', '<input type="hidden" name="isMambot" value="' . $this->isMambot . '" />', '<input type="hidden" name="formid" value="' . $model->get('id') . '" />', '<input type="hidden" name="returntoform" value="0" />', '<input type="hidden" name="fabrik_referrer" value="' . $reffer . '" />', '<input type="hidden" name="fabrik_ajax" value="' . (int) $model->isAjax() . '" />');
     $fields[] = '<input type="hidden" name="_packageId" value="' . $model->packageId . '" />';
     if ($usekey = FabrikWorker::getMenuOrRequestVar('usekey', '')) {
         // $$$rob v's been set from -1 to the actual row id - so ignore usekyey not sure if we should comment this out
         // see http://fabrikar.com/forums/showthread.php?t=10297&page=5
         $fields[] = '<input type="hidden" name="usekey" value="' . $usekey . '" />';
         $pk_val = JArrayHelper::getValue($model->_data, FabrikString::safeColNameToArrayKey($listModel->getTable()->db_primary_key));
         if (empty($pk_val)) {
             $fields[] = '<input type="hidden" name="usekey_newrecord" value="1" />';
         }
     }
     /* $$$ hugh - testing a fix for pagination issue when submitting a 'search form'.
      * If this is a search form, we need to clear 'limitstart', otherwise ... say we
      * were last on page 4 of the (unfiltered) target table, and the search yields less than 4 pages,
      * we end up with a blank table 'cos the wrong LIMIT's are applied to the query
      */
     $save_insessions = $params->get('save_insession', '');
     if (is_array($save_insessions)) {
         foreach ($save_insessions as $save_insession) {
             if ($save_insession == '1') {
                 $fields[] = '<input type="hidden" name="limitstart" value="0" />';
                 break;
             }
         }
     }
     $fields[] = JHTML::_('form.token');
     $form->resetButton = $params->get('reset_button', 0) && $this->editable == "1" ? '<input type="reset" class="button btn" name="Reset" value="' . $params->get('reset_button_label') . '" />' : '';
     $form->copyButton = $params->get('copy_button', 0) && $this->editable && $model->_rowId != '' ? '<input type="submit" class="button btn" name="Copy" value="' . $params->get('copy_button_label') . '" />' : '';
     $applyButtonType = $model->isAjax() ? 'button' : 'submit';
     $form->applyButton = $params->get('apply_button', 0) && $this->editable ? '<input type="' . $applyButtonType . '" class="button btn" name="apply" value="' . $params->get('apply_button_label') . '" />' : '';
     $form->deleteButton = $params->get('delete_button', 0) && $canDelete && $this->editable && $this_rowid != 0 ? '<input type="submit" value="' . $params->get('delete_button_label', 'Delete') . '" class="button btn" name="delete" />' : '';
     $form->gobackButton = $params->get('goback_button', 0) == "1" ? '<input type="button" class="button btn" name="Goback" ' . FabrikWorker::goBackAction() . ' value="' . $params->get('goback_button_label') . '" />' : '';
     if ($model->isEditable() && $params->get('submit_button', 1)) {
         $button = $model->isAjax() ? "button" : "submit";
         $submitClass = FabrikString::clean($form->submit_button_label);
         $form->submitButton = '<input type="' . $button . '" class="button ' . $submitClass . ' btn" name="submit" value="' . $form->submit_button_label . '" />';
     } else {
         $form->submitButton = '';
     }
     if ($this->isMultiPage) {
         $form->prevButton = '<input type="button" class="fabrikPagePrevious button" name="fabrikPagePrevious" value="' . JText::_('COM_FABRIK_PREVIOUS') . '" />';
         $form->nextButton = '<input type="button" class="fabrikPageNext button" name="fabrikPageNext" value="' . JText::_('COM_FABRIK_NEXT') . '" />';
     } else {
         $form->nextButton = '';
         $form->prevButton = '';
     }
     // $$$ hugh - hide actions section is we're printing, or if not actions selected
     $noButtons = empty($form->nextButton) && empty($form->prevButton) && empty($form->submitButton) && empty($form->gobackButton) && empty($form->deleteButton) && empty($form->applyButton) && empty($form->copyButton) && empty($form->resetButton);
     if (JRequest::getVar('print', '0') == '1' || $noButtons) {
         $this->hasActions = false;
     } else {
         $this->hasActions = true;
     }
     $format = $model->isAjax() ? 'raw' : 'html';
     $fields[] = '<input type="hidden" name="format" value="' . $format . '" />';
     $groups = $model->getGroupsHiarachy();
     foreach ($groups as $groupModel) {
         $group = $groupModel->getGroup();
         $c = $groupModel->repeatTotal;
         // Used for validations
         $fields[] = '<input type="hidden" name="fabrik_repeat_group[' . $group->id . ']" value="' . $c . '" id="fabrik_repeat_group_' . $group->id . '_counter" />';
     }
     // $$$ hugh - testing social_profile_hash stuff
     if (JRequest::getVar('fabrik_social_profile_hash', '') != '') {
         $fields[] = '<input type="hidden" name="fabrik_social_profile_hash" value="' . JRequest::getCmd('fabrik_social_profile_hash', '') . '" id="fabrik_social_profile_hash" />';
     }
     $this->_cryptQueryString($fields);
     $this->_cryptViewOnlyElements($fields);
     $this->hiddenFields = implode("\n", $fields);
 }