/** * Inline edit show the edited element * * @return string */ public function showResults() { $input = $this->app->input; $listModel = $this->formModel->getListModel(); $listId = $listModel->getId(); $listModel->clearCalculations(); $listModel->doCalculations(); $elementId = $input->getInt('elid'); if ($elementId === 0) { return; } $elementModel = $this->formModel->getElement($elementId, true); if (!$elementModel) { return; } $rowId = $input->get('rowid'); $listModel->setId($listId); // If the inline edit stored a element join we need to reset back the table $listModel->clearTable(); $listModel->getTable(); $data = $listModel->getRow($rowId); // For a change in the element which means its no longer shown in the list due to pre-filter. We may want to remove the row from the list as well? if (!is_object($data)) { $data = new stdClass(); } $key = $input->get('element'); $html = ''; $html .= $elementModel->renderListData($data->{$key}, $data); $listRef = 'list_' . $input->get('listref'); $doCalcs = "\nFabrik.blocks['" . $listRef . "'].updateCals(" . json_encode($listModel->getCalculations()) . ")"; $html .= '<script type="text/javascript">'; $html .= $doCalcs; $html .= "</script>\n"; return $html; }
/** * If not loaded this loads in the table's form model * also binds a reference of the table to the form. * * @return FabrikFEModelForm form model with form table loaded */ public function &getFormModel() { if (!isset($this->formModel)) { $this->formModel = JModelLegacy::getInstance('Form', 'FabrikFEModel'); $table = $this->getTable(); $this->formModel->setId($table->form_id); $this->formModel->getForm(); $this->formModel->setListModel($this); } return $this->formModel; }
/** * Get the groups form model * * @return FabrikFEModelForm form model */ public function getFormModel() { if (!isset($this->form)) { $formIds = $this->getFormsIamIn(); $formId = empty($formIds) ? 0 : $formIds[0]; $this->form = JModelLegacy::getInstance('Form', 'FabrikFEModel'); $this->form->setId($formId); $this->form->getForm(); $this->form->getlistModel(); } return $this->form; }
/** * Find the element associated with a key. * Loose lookup to find join element from any key related to the join (e.g. _id & __params). * Used in csv import/export * * @param FabrikFEModelForm $model Form model * @param string $key Key - full element name or full element name with _id / ___params appended * * @return PlgFabrik_Element|boolean */ public static function findElementFromJoinKeys($model, $key) { // Search on fullname fullname_id and fullname___params $lookups = array($key, substr($key, 0, JString::strlen($key) - 3), substr($key, 0, JString::strlen($key) - 9)); foreach ($lookups as $lookup) { $elementModel = $model->getElement($lookup); if ($elementModel) { return $elementModel; } } return false; }
/** * Get redirect URL * * @param FabrikFEModelForm $model Form model * @param bool $incSession Set url in session? * * @since 3.0 * * @deprecated - use form model getRedirectUrl() instead * * @return string redirect url */ protected function getRedirectURL($model, $incSession = true) { $res = $model->getRedirectURL($incSession, $this->isMambot); $this->baseRedirect = $res['baseRedirect']; return $res['url']; }
/** * Download the content type * * @param FabrikFEModelForm $formModel * * @throws Exception */ public function download($formModel) { $params = $formModel->getParams(); $file = $params->get('content_type_path'); $label = 'content-type-' . $formModel->getForm()->get('label'); $label = JFile::makeSafe($label); $zip = new ZipArchive(); $zipFile = $this->config->get('tmp_path') . '/' . $label . '.zip'; $zipRes = $zip->open($zipFile, ZipArchive::CREATE); if (!$zipRes) { throw new Exception('unable to create ZIP'); } if (!JFile::exists($file)) { throw new Exception('Content type file not found'); } if (!$zip->addFile($file, basename($file))) { throw new Exception('unable to add file ' . $file . ' to zip'); } $zip->close(); header('Content-Type: application/zip'); header('Content-Length: ' . filesize($zipFile)); header('Content-Disposition: attachment; filename="' . basename($zipFile) . '"'); echo file_get_contents($zipFile); // Must exit to produce valid Zip download exit; }