PageRenderTime 55ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/components/com_fabrik/views/form/view.html.php

https://github.com/chrisinammo/arthurmcneil
PHP | 659 lines | 526 code | 67 blank | 66 comment | 104 complexity | b9d8290877b8bce0e4ff0846649a6259 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
  1. <?php
  2. /**
  3. * @package Joomla
  4. * @subpackage Fabrik
  5. * @copyright Copyright (C) 2005 Rob Clayburn. All rights reserved.
  6. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
  7. */
  8. // Check to ensure this file is included in Joomla!
  9. defined('_JEXEC') or die();
  10. jimport('joomla.application.component.view');
  11. class fabrikViewForm extends JView
  12. {
  13. var $_template = null;
  14. var $_errors = null;
  15. var $_data = null;
  16. var $_rowId = null;
  17. var $_params = null;
  18. var $_isMambot = null;
  19. var $_id = null;
  20. function copy()
  21. {
  22. $serialized_contents = serialize( $this );
  23. return unserialize( $serialized_contents );
  24. }
  25. function setId($id)
  26. {
  27. $this->_id = $id;
  28. }
  29. function getGroupProperties( &$groupModel )
  30. {
  31. $group = new stdClass();
  32. $model =& $this->getModel();
  33. $groupTable =& $groupModel->getGroup();
  34. $groupParams =& $groupModel->getParams();
  35. $group->canRepeat = ($model->_editable) ? $groupParams->get( 'repeat_group_button', '0' ) : 0;
  36. $addJs = str_replace( '"', "'", $groupParams->get( 'repeat_group_js_add' ) );
  37. $group->addJs = str_replace( array("\n", "\r"), "", $addJs );
  38. $delJs = str_replace('"', "'", $groupParams->get( 'repeat_group_js_delete' ) );
  39. $group->delJs = str_replace( array("\n", "\r"), "", $delJs );
  40. $showGroup = $groupParams->def( 'repeat_group_show_first', '1' );
  41. $pages =& $model->getPages();
  42. $startpage = isset($model->sessionModel->last_page) ? $model->sessionModel->last_page: 0;
  43. if (!in_array($groupTable->id, $pages[$startpage]) || $showGroup == 0) {
  44. $groupTable->css .= ";display:none;";
  45. }
  46. $rubbish = array ("<br />", "<br>");
  47. $group->css = trim( str_replace( $rubbish, "", $groupTable->css ) );
  48. $group->id = $groupTable->id;
  49. $group->title = $groupTable->label;
  50. $group->name = $groupTable->name;
  51. if ( $group->canRepeat == 1 && $model->_editable ) {
  52. $group->delId = "delGroup_" . $groupTable->id ;
  53. $group->addId = "addGroup_" . $groupTable->id;
  54. $group->displaystate = '1';
  55. } else {
  56. $group->delId = '';
  57. $group->addId = '';
  58. $group->displaystate = '0';
  59. }
  60. return $group;
  61. }
  62. /**
  63. * query all active form plugins to see if they inject cutsom html into the top
  64. * or bottom of the formr
  65. *
  66. * @param object $model
  67. */
  68. function _getFormPluginHTML( &$model )
  69. {
  70. $pluginManager =& JModel::getInstance( 'Pluginmanager', 'FabrikModel' );
  71. $formPlugins =& $pluginManager->getPlugInGroup( 'form' );
  72. $form =& $model->getForm();
  73. $top = array();
  74. $bottom = array();
  75. foreach ($formPlugins as $plugin) {
  76. $plugin->attribs = $form->attribs;
  77. $top[] = $plugin->getTopContent();
  78. $bottom[] = $plugin->getBottomContent();
  79. }
  80. $this->plugintop = implode( "<br />", $top );
  81. $this->pluginbottom = implode( "<br />", $bottom );
  82. }
  83. /**
  84. * main setup routine for displaying the form/detail view
  85. * @param string template
  86. */
  87. function display( $tpl = null )
  88. {
  89. global $mainframe, $_SESSION;
  90. $w = new FabrikWorker();
  91. $config =& JFactory::getConfig();
  92. $model =& $this->getModel();
  93. $document =& JFactory::getDocument();
  94. //Get the active menu item
  95. $usersConfig = &JComponentHelper::getParams( 'com_fabrik' );
  96. if (!isset( $this->_id )) {
  97. $model->setId( $usersConfig->get( 'fabrik', JRequest::getInt( 'fabrik' ) ) );
  98. } else {
  99. //when in a package the id is set from the package view
  100. $model->setId( $this->_id );
  101. }
  102. $form =& $model->getForm();
  103. $model->render();
  104. $this->isMultiPage = $model->isMultiPage();
  105. $this->_getFormPluginHTML($model);
  106. $tableModel =& $model->_table;
  107. $table = is_object( $tableModel ) ? $tableModel->getTable() : null;
  108. if (!$model->canPublish( )) {
  109. if (!$model->_admin) {
  110. echo JText::_( 'Sorry this form is not published' );
  111. return false;
  112. }
  113. }
  114. if ($model->_isModule) {
  115. if (!defined( '_FABRIK_SESSIONSTART' )) {
  116. define( '_FABRIK_SESSIONSTART', '1' );
  117. session_start();
  118. }
  119. if (array_key_exists( 'fabrik', $_SESSION ) && array_key_exists( 'moduleErrors', $_SESSION['fabrik'] )) {
  120. $this->_arErrors = $_SESSION['fabrik']['moduleErrors'];
  121. unset( $_SESSION['fabrik']['moduleErrors'] );
  122. }
  123. }
  124. $access = $model->checkAccessFromTableSettings( );
  125. if ($access == 0) {
  126. return JError::raiseWarning( 500, JText::_( 'ALERTNOTAUTH' ) );
  127. }
  128. $model->_editable = ($access == 1 && $model->_editable == '1') ? false : true;
  129. if (is_object( $tableModel )) {
  130. $joins = $tableModel->getJoins( );
  131. $model->getJoinGroupIds( $joins );
  132. }
  133. if (!$this->_isMambot) {
  134. $title = $model->getPageTitle( );
  135. $document->setTitle( $w->parseMessageForPlaceHolder( $title, $_REQUEST ) );
  136. }
  137. $params =& $model->getParams();
  138. $params->def( 'icons', $mainframe->getCfg( 'icons' ) );
  139. $pop = (JRequest::getVar('tmpl') == 'component') ? 1 : 0;
  140. $params->set( 'popup', $pop );
  141. $view = JRequest::getVar( 'view', 'form' );
  142. if ($view == 'details') {
  143. $model->_editable = false;
  144. }
  145. if ($model->_editable) {
  146. foreach ($model->_data as $key=>$val) {
  147. if (is_string( $val )) {
  148. $data[$key] = htmlspecialchars( $val, ENT_QUOTES );
  149. }
  150. }
  151. }
  152. $model->addCustomFiles( );
  153. if (stristr( "{Add/Edit}", $form->label )) {
  154. $replace = ($model->_rowId == '') ? JText::_('Add') : JText::_('Edit');
  155. $form->label = str_replace( "{Add/Edit}", $replace, $form->label );
  156. }
  157. $namedData = array();
  158. $this->form = $form;
  159. if ($model->_admin) {
  160. $model->_rootPath = JURI::base() ."/administrator/index.php";
  161. $this->form->action = JURI::base() . "/index.php";
  162. $this->form->formid = "adminForm";
  163. $this->form->name = "adminForm";
  164. } else {
  165. $model->_rootPath = JURI::base()."/index.php?" ;
  166. $this->form->action = $model->_rootPath."&amp;option=com_fabrik";
  167. if ($model->_postMethod == 'ajax') {
  168. $this->form->action .= "&format=raw";
  169. }
  170. $this->form->formid = "form_".$model->_id;
  171. $this->form->name = "form_".$model->_id;
  172. }
  173. $this->form->encType = $model->getFormEncType();;
  174. $this->form->origerror = $this->form->error;
  175. $this->form->error = (count( $model->_arErrors ) > 0) ? $form->error : '';
  176. $aGroups = array();
  177. $jsActions = array();
  178. $allJsActions = $model->getJsActions();
  179. $this->_addButtons();
  180. $model->loadValidationRuleClasses( );
  181. foreach ($model->_groups as $groupModel) {
  182. $activeData = $model->_data;
  183. $groupTable =& $groupModel->getGroup();
  184. if ($groupTable->state != 0) {
  185. $group = $this->getGroupProperties( $groupModel );
  186. $aElements = array();
  187. //check if group is acutally a table join
  188. if (array_key_exists( $groupTable->id, $model->_aJoinGroupIds )) {
  189. $joinId = $model->_aJoinGroupIds[$groupTable->id];
  190. $element = new stdClass();
  191. //add in row id for join data
  192. $element->label = '';
  193. $element->error = '';
  194. $element->className = '';
  195. //something wrong with this bit below i think - oform->_table might be incorrect???
  196. foreach ($tableModel->_aJoins as $oJoin) {
  197. if ($oJoin->id == $joinId) {
  198. $key = $oJoin->table_join . $model->_joinTableElementStep . $oJoin->table_join_key;
  199. if (array_key_exists( 'join', $model->_data )) {
  200. $val = $this->_data['join'][$joinId][$key];
  201. } else {
  202. $val = '';
  203. }
  204. $element->element = '<input type="hidden" id="join.' . $joinId . '.rowid" name="join[' . $joinId . '][rowid]" value="' . $val . '" />';
  205. }
  206. }
  207. $aElements[] = $element;
  208. }
  209. if ($groupModel->canRepeat() || array_key_exists( $groupTable->id, $model->_aJoinGroupIds )) {
  210. $repeatGroup = 1;
  211. $activeData = $model->_data;
  212. $joinModel = Jmodel::getInstance( 'Join', 'FabrikModel');
  213. $tableId = (is_object( $table )) ? $table->id : '';
  214. $joinTable = $joinModel->loadFromGroupId( $groupTable->id, $tableId );
  215. $foreignKey = '';
  216. if (is_object( $joinTable )) {
  217. $foreignKey = $joinTable->table_join_key;
  218. //need to duplicate this perhaps per the number of times that a repeat group occurs in the default data?
  219. if (is_array( $model->_joinDefaultData )) {
  220. if (array_key_exists( $joinTable->id, $model->_joinDefaultData )) {
  221. $activeData = $model->_joinDefaultData[$joinTable->id];
  222. reset( $groupModel->_aElements );
  223. $tmpElement = current( $groupModel->_aElements );
  224. $smallerElHTMLName = $tmpElement->getFullName( false, true, false );
  225. $repeatGroup = count( $activeData[$smallerElHTMLName] );
  226. } else {
  227. //guess at how many repeated groups were posted
  228. $tmpElement = current( $groupModel->_aElements );
  229. foreach ($groupModel->_aElements as $tmpElement) {
  230. $smallerElHTMLName = $tmpElement->getFullName( false, true, false );
  231. if (array_key_exists( $smallerElHTMLName, $activeData )) {
  232. $c = count($activeData[$smallerElHTMLName]);
  233. if ( $c > $repeatGroup ) { $repeatGroup = $c;}
  234. }
  235. }
  236. }
  237. }
  238. } else {
  239. //get the number of repeat groups for non join repeat groups when editing a record
  240. $repeatGroup = 1;
  241. foreach ($groupModel->_aElements as $tmpElement) {
  242. $smallerElHTMLName = $tmpElement->getFullName( false, true, false );
  243. $d = @$model->_data[$smallerElHTMLName];
  244. if (is_string($d) && strstr( $d, $tmpElement->_groupSplitter )) {
  245. $d = explode( $tmpElement->_groupSplitter, $d );
  246. }
  247. $c = count($d);
  248. if ( $c > $repeatGroup ) { $repeatGroup = $c;}
  249. }
  250. }
  251. } else {
  252. $foreignKey = null;
  253. $activeData = $model->_data;
  254. $repeatGroup = 1;
  255. }
  256. $aSubGroups = array();
  257. for ($c = 0; $c < $repeatGroup; $c++) {
  258. $aSubGroupElements = array();
  259. foreach ($groupModel->_aElements as $elementModel) {
  260. $elementTable =& $elementModel->getElement();
  261. $element = new stdClass( );
  262. if ($elementModel->isHidden() && !$model->_editable) {
  263. continue;
  264. }
  265. $elementModel->loadLanguage( );
  266. $elHTMLName = $elementModel->getFullName( true, true );
  267. $elementHTMLId = $elementModel->getHTMLId( );
  268. $jsActions[] = $elementModel->getFormattedJSActions( $allJsActions );
  269. //if the element is in a join AND is the join's foreign key then we don't show the element
  270. if ($elementTable->name == $foreignKey) {
  271. $element->label = '';
  272. $element->error = '';
  273. $elementModel->_element->hidden = true;
  274. } else {
  275. $element->label = $elementModel->getLabel( );
  276. $element->error = $this->_getErrorMsg( $elHTMLName, $model->_arErrors, $elementTable->plugin, $c );
  277. }
  278. $element->hidden = $elementModel->isHidden();
  279. $element->id = $elementModel->getHTMLId();
  280. $element->className = "fb_el_" . $element->id;
  281. $element->element = $this->_getElement( $elementModel, $activeData, $c );
  282. $editable = $model->_editable;
  283. if (!$elementModel->canUse()) {
  284. $editable = false;
  285. }
  286. $element->element_ro = $this->_getROElement( $elementModel, $activeData, $c );
  287. $aElements[$elementTable->name] = $element;
  288. $namedData[$elHTMLName] = $element;
  289. if ($elHTMLName)
  290. $aSubGroupElements[] = $element;
  291. }
  292. //if its a repeatable group put in subgroup
  293. if ($groupModel->canRepeat()) {
  294. $aSubGroups[] = $aSubGroupElements;
  295. }
  296. }
  297. $group->elements = $aElements;
  298. $group->subgroups = $aSubGroups;
  299. $aGroups[$group->name] = $group;
  300. }
  301. }
  302. $this->groups = $aGroups;
  303. $this->data = $namedData;
  304. //add in the javascript element observers
  305. $actions = trim(implode("\n", $jsActions));
  306. $this->jsActions = '';
  307. $model->getFormManagementJS( $actions );
  308. $this->_addJavascript( $tableModel->_id, $actions );
  309. $this->_loadTmplBottom( );
  310. //force front end templates
  311. $this->_basePath = COM_FABRIK_FRONTEND . DS . 'views' ;
  312. $t = ($model->_editable)? $form->form_template : $form->view_only_template;
  313. $form->form_template = JRequest::getVar( 'layout', $t );
  314. $tmpl = JRequest::getVar( 'layout', $form->form_template );
  315. $this->_includeTemplateCSSFile( $tmpl );
  316. $this->message = @$model->sessionModel->status;
  317. $this->_setPath( 'template', $this->_basePath.DS.$this->_name.DS.'tmpl'.DS.$tmpl );
  318. if ($this->_isMambot) {
  319. return $this->loadTemplate();
  320. } else {
  321. parent::display( );
  322. }
  323. }
  324. /**
  325. * add buttons to the view e.g. print, pdf
  326. */
  327. function _addButtons()
  328. {
  329. $model =& $this->getModel();
  330. $params =& $model->getParams();
  331. $this->showEmail = $params->get( 'email', 0 );
  332. if (JRequest::getVar('tmpl') != 'component') {
  333. if ($this->showEmail) {
  334. $this->emailLink = FabrikHelperHTML::emailIcon( $model, $params );
  335. }
  336. $this->showPrint = $params->get( 'print', 0 );
  337. if ($this->showPrint) {
  338. $this->printLink = FabrikHelperHTML::printIcon( $model, $params, $model->_rowId );
  339. }
  340. $this->showPDF = $params->get( 'pdf', 0 );
  341. if ($this->showPDF) {
  342. $this->pdfLink = FabrikHelperHTML::pdfIcon( $model, $params, $model->_rowId );
  343. }
  344. } else {
  345. $this->showPDF = $this->showPrint = false;
  346. }
  347. }
  348. /**
  349. * get any html errror messages for form element
  350. * @param string parsed element name
  351. * @param array error messages
  352. * @param int group element type
  353. * @param int repeat count
  354. * @return string error messages
  355. */
  356. function _getErrorMsg( $parsed_name, &$arErrors, $groupeltype, $repeatCount = 0 )
  357. {
  358. $err_msg = '';
  359. $parsed_name = rtrim( $parsed_name, "[]" );
  360. if (isset( $arErrors[$parsed_name] )) {
  361. if (array_key_exists( $repeatCount, $arErrors[$parsed_name] )) {
  362. if (is_array( $arErrors[$parsed_name][$repeatCount] )) {
  363. foreach ($arErrors[$parsed_name][$repeatCount] as $el_err_msg) {
  364. $err_msg .= "$el_err_msg<br/>";
  365. }
  366. } else {
  367. $err_msg .= $arErrors[$parsed_name][$repeatCount];
  368. }
  369. }
  370. }
  371. return $err_msg;
  372. }
  373. /**
  374. * @access private
  375. * @param object element model
  376. * @param array data
  377. * @param int repeat group counter
  378. */
  379. function _getElement( &$elementModel, $data, $repeatCounter = 0 )
  380. {
  381. $model =& $this->getModel();
  382. $editable = $model->_editable;
  383. if (!$elementModel->canView( ) && !$elementModel->canUse()) {
  384. return '';
  385. }
  386. if (!$elementModel->canUse()) {
  387. $editable = false;
  388. }
  389. $elementModel->_shortHTMLName = $elementModel->getFullName( false, true, false );
  390. $elementModel->_editable = $editable;
  391. $elementModel->getDefaultValue( $data, true, $repeatCounter );
  392. $htmlid = $elementModel->getHTMLId( );
  393. $e = $elementModel->render( $data, $repeatCounter );
  394. if ($editable) {
  395. return $e;
  396. } else {
  397. if ($model->_postMethod == 'ajax') {
  398. return "<div id='$htmlid'>" . $this->_getROElement( $elementModel, $data, $repeatCounter ) . "</div>"; //placeholder to be updated by ajax code
  399. } else {
  400. return $this->_getROElement( $elementModel, $data, $repeatCounter );
  401. }
  402. }
  403. }
  404. /**
  405. * @access private
  406. * @param object element model
  407. * @param array data
  408. * @param int repeat group counter
  409. */
  410. function _getROElement( &$elementModel, $data, $repeatCounter = 0 )
  411. {
  412. if (!$elementModel->canView( ) && !$elementModel->canUse()) {
  413. return '';
  414. }
  415. $elementModel->_editable = false;
  416. return $elementModel->render( $data, $repeatCounter );
  417. }
  418. /**
  419. * include the template css files
  420. *
  421. * @param string template name
  422. */
  423. function _includeTemplateCSSFile( $formTemplate )
  424. {
  425. $config =& JFactory::getConfig();
  426. $document =& JFactory::getDocument();
  427. $ab_css_file = JPATH_SITE.DS."components".DS."com_fabrik".DS."views".DS."form".DS."tmpl".DS."$formTemplate".DS."template.css";
  428. $live_css_file = COM_FABRIK_LIVESITE . "/components/com_fabrik/views/form/tmpl/$formTemplate/template.css";
  429. if (file_exists( $ab_css_file )) {
  430. $document->addStyleSheet($live_css_file);
  431. }
  432. }
  433. /**
  434. * append the form javascript into the document head
  435. * @param int table id
  436. * @param string extra js code to add
  437. */
  438. function _addJavascript( $tableId, $actions )
  439. {
  440. $model =& $this->getModel();
  441. $aWYSIWYGNames = array();
  442. foreach ($model->_groups as $groupModel) {
  443. foreach ($groupModel->_aElements as $elementModel) {
  444. $res = $elementModel->useEditor();
  445. if ($res !== false) {
  446. $aWYSIWYGNames[] = $res;
  447. }
  448. }
  449. }
  450. $params =& $model->getParams();
  451. FabrikHelperHTML::packageJS();
  452. $tableModel =& $model->getTableModel();
  453. $table =& $tableModel->getTable();
  454. $document =& JFactory::getDocument();
  455. $form =& $model->getForm();
  456. FabrikHelperHTML::mocha( );
  457. FabrikHelperHTML::script( 'package.js', 'components/com_fabrik/views/package/', true );
  458. JHTML::_('behavior.tooltip');
  459. $key = str_replace( ".", "___", $table->db_primary_key );
  460. $key = str_replace( "`", "", $key );
  461. //tmp = component when the form is loaded in a pop up window - presumes the doc body has
  462. //already been loaded
  463. //can't be domready as it gets fired when wysiwyg editor gets loaded
  464. if (JRequest::getVar('tmpl') == 'component') {
  465. $startJs = '';
  466. $endJs = '';
  467. } else {
  468. $startJs = "window.addEvent('load', function(){";
  469. $endJs = "});\n";
  470. }
  471. $ajaxValidation = ($this->isMultiPage) ? true : $params->get('ajax_validations');
  472. $start_page = isset($model->sessionModel->last_page) ? $model->sessionModel->last_page : 0;
  473. $str ="$startJs
  474. var ofabrik = new fabrikForm( ".$model->_id.", {
  475. 'admin': '".$model->_admin."',
  476. 'postMethod': '".$model->_postMethod."',
  477. 'ajaxValidation': '".$ajaxValidation."',
  478. 'primaryKey': '$key',
  479. 'liveSite': '" . COM_FABRIK_LIVESITE . "',
  480. 'error':'".@$form->origerror."',
  481. 'pages':" . FastJSON::encode($model->getPages()) . ",
  482. 'page_save_groups':".FastJSON::encode($model->getPageSaveGroups()) . ",
  483. 'start_page':" . $start_page . "
  484. });\n";
  485. $str .= "ofabrik.addListenTo('table_" . $tableModel->_id . "');\n";
  486. $str .= "ofabrik.addListenTo('form_" . $model->_id . "');\n";
  487. $str .= "oPackage.addBlock('form_". $model->_id."', ofabrik);\n";
  488. //instantaite js objects for each element
  489. $groupstr = '';
  490. $vstr = '';
  491. $aObjs = array();
  492. $str .= "ofabrik.addElements([\n";
  493. foreach ($model->_groups as $groupModel) {
  494. foreach ($groupModel->_aElements as $elementModel) {
  495. $fullName = $elementModel->getFullName( );
  496. $id = $elementModel->getHTMLId( );
  497. $elementModel->_editable = ($model->_editable);
  498. if ($js = $elementModel->elementJavascript( )) {
  499. $aObjs[] = $js;
  500. }
  501. if(!empty($elementModel->_aValidations)){
  502. $element =& $elementModel->getElement();
  503. $elName = $elementModel->getHTMLName( );
  504. $id = $elementModel->getHTMLId( );
  505. $vstr .= "ofabrik.watchValidation('$elName', '$id');\n";
  506. }
  507. }
  508. $groupParams = $groupModel->getParams();
  509. $addJs = str_replace( '"', "'", $groupParams->get( 'repeat_group_js_add' ) );
  510. $addJs = str_replace( array("\n", "\r"), "", $addJs );
  511. $delJs = str_replace('"', "'", $groupParams->get( 'repeat_group_js_delete' ) );
  512. $gdelJs = str_replace( array("\n", "\r"), "", $delJs );
  513. $groupstr .= "ofabrik.addGroupJS($groupModel->_id, 'delete', \"$delJs\");\n";
  514. $groupstr .= "ofabrik.addGroupJS($groupModel->_id, 'add', \"$addJs\");\n";
  515. }
  516. $str .= implode(",\n", $aObjs);
  517. $str .= "]\n);\n";
  518. $str .= $groupstr;
  519. $str .= $actions;
  520. $str .= $vstr;
  521. $str .= $endJs;
  522. $str .= "function submit_form(){";
  523. if (!empty( $aWYSIWYGNames )) {
  524. jimport( 'joomla.html.editor' );
  525. $editor =& JFactory::getEditor();
  526. $str .= $editor->save( 'label' );
  527. foreach ($aWYSIWYGNames as $parsedName) {
  528. $str .= $editor->save( $parsedName );
  529. }
  530. }
  531. $str .="
  532. return false;
  533. }
  534. function submitbutton(button){
  535. if(button==\"cancel\"){
  536. document.location = '".JRoute::_('index.php?option=com_fabrik&task=viewTable&cid='.$tableId). "';
  537. }
  538. if(button == \"cancelShowForm\"){
  539. return false;
  540. }
  541. }
  542. ";
  543. $document->addScriptDeclaration( $str );
  544. }
  545. function _loadTmplBottom( )
  546. {
  547. global $Itemid, $_SERVER;
  548. $model =& $this->getModel();
  549. $params =& $model->getParams();
  550. $form =& $model->getForm();
  551. $cursor = JRequest::getInt( 'fabrik_cursor', '' );
  552. $total = JRequest::getInt( 'fabrik_total', '' );
  553. $reffer = '';
  554. if (array_key_exists( 'HTTP_REFERER', $_SERVER ) ){
  555. $reffer = $_SERVER['HTTP_REFERER'];
  556. }
  557. $aHiddenFields = "<input type='hidden' name='tableid' value='" . $model->_table->_id . "' id = 'tableid' />\n
  558. <input type='hidden' name='fabrik' value='" . $model->_id . "' id = 'fabrik' />\n
  559. <input type='hidden' name='task' value='processForm' id = 'task' />\n
  560. <input type='hidden' name='rowid' value='" . $model->_rowId . "' id = 'rowid' />\n
  561. <input type='hidden' name='Itemid' value='" . $Itemid . "' id = 'Itemid' />\n
  562. <input type='hidden' name='option' value='com_fabrik' id = 'option' />\n
  563. <input type='hidden' name='c' value='form' id = 'c' />\n
  564. <input type='hidden' name='form_id' value='" . $model->_id . "' id = 'form_id' />\n
  565. <input type='hidden' name='fabrik_frommodule' value='" . $model->_isModule . "' id = 'fabrik_frommodule' />\n
  566. <input type='hidden' name='fabrik_cursor' value='" . $cursor . "' id = 'fabrik_cursor' />\n
  567. <input type='hidden' name='fabrik_total' value='" . $total . "' id = 'fabrik_total' />\n
  568. <input type='hidden' name='returntoform' value='0' id='returntoform' />\n
  569. <input type='hidden' name='fabrik_referrer' value='" . $reffer . "' id='fabrik_referrer' />\n
  570. <input type='hidden' name='fabrik_postMethod' value='" . $model->_postMethod . "' id='fabrik_postMethod' />";
  571. $aHiddenFields .= JHTML::_( 'form.token' );
  572. $this->form->resetButton = $params->get('reset_button', 0) == "1" ? "<input type=\"reset\" class=\"button\" name=\"Reset\" value=\"" . $params->get('reset_button_label') . "\" />\n" : '';
  573. $this->form->copyButton = $params->get('copy_button', 0) == "1" ? "<input type=\"submit\" class=\"button\" name=\"Copy\" value=\"" . $params->get('copy_button_label') . "\" />\n" : '';
  574. $this->form->gobackButton = $params->get('goback_button', 0) == "1" ? "<input type=\"button\" class=\"button\" name=\"Goback\" onclick=\"history.back()\" value=\"" . $params->get('goback_button_label') . "\" />\n" : '';
  575. if ($model->_editable) {
  576. $button = ( $model->_postMethod == 'post') ? "submit" : "button";
  577. $this->form->submitButton = '';
  578. if ($this->isMultiPage) {
  579. $this->form->submitButton .= "<input type='button' class='fabrikPagePrevious button' name='fabrikPagePrevious' value='" . JText::_('Previous') ."' />\n";
  580. $this->form->submitButton .= "<input type='button' class='fabrikPageNext button' name='fabrikPageNext' value='" . JText::_('Next') ."' />\n";
  581. }
  582. $this->form->submitButton .= "<input type=\"$button\" id=\"fabrikSubmit" . $model->_id . "\" class=\"button\" name=\"Submit\" value=\"" . $form->submit_button_label ."\" />\n " ;
  583. } else {
  584. $this->form->submitButton = '';
  585. }
  586. $format = ( $model->_postMethod == 'post' ) ? 'html' : 'raw';
  587. $aHiddenFields .= "<input type='hidden' name='format' value='$format' />";
  588. $aHiddenFields .= "<input type='hidden' name='_senderBlock' id='_senderBlock' value='form_" .$form->id . "' />";
  589. $this->hiddenFields = $aHiddenFields;
  590. }
  591. }
  592. ?>