forked from pollen8/fabrik
/
mod_fabrik_form_boot.php
98 lines (76 loc) · 2.87 KB
/
mod_fabrik_form_boot.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
* @package Joomla
* @subpackage Fabrik
* @copyright Copyright (C) 2005-2016 Media A-Team, Inc. - All rights reserved.
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/
// No direct access
defined('_JEXEC') or die('Restricted access');
jimport('joomla.filesystem.file');
// Load front end language file as well
$lang = JFactory::getLanguage();
$lang->load('com_fabrik', JPATH_BASE . '/components/com_fabrik');
if (!defined('COM_FABRIK_FRONTEND'))
{
JError::raiseError(400, JText::_('COM_FABRIK_SYSTEM_PLUGIN_NOT_ACTIVE'));
}
$app = JFactory::getApplication();
$input = $app->input;
$origLayout = $input->get('layout');
$origView = $input->get('view');
$origAjax = $input->get('ajax');
$origFormid = $input->getInt('formid');
$input->set('orig_formid', $origFormid);
$origRowid = $input->getInt('rowid');
$input->set('orig_rowid', $origRowid);
FabrikHelperHTML::framework();
// $$$rob looks like including the view does something to the layout variable
require_once COM_FABRIK_FRONTEND . '/views/form/view.html.php';
require_once COM_FABRIK_FRONTEND . '/views/package/view.html.php';
require_once COM_FABRIK_FRONTEND . '/views/list/view.html.php';
$input->set('layout', $origLayout);
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_fabrik/tables');
JModelLegacy::addIncludePath(COM_FABRIK_FRONTEND . '/models', 'FabrikFEModel');
$formId = (int) $params->get('formid');
if (empty($formId))
{
throw new \InvalidArgumentException('No form selected in Fabrik form module!');
}
$readonly = $params->get('readonly', '0');
if ($readonly == 1) {
require_once COM_FABRIK_FRONTEND . '/controllers/details.php';
$controller = new FabrikControllerDetails;
$input->set('view', 'details');
} else {
require_once COM_FABRIK_FRONTEND . '/controllers/form.php';
$controller = new FabrikControllerForm;
$input->set('view', 'form');
}
$layout = $params->get('template', 'default');
$usersConfig = JComponentHelper::getParams('com_fabrik');
$rowid = (string) $params->get('row_id', '');
$usersConfig->set('rowid', $rowid);
$usekey = $params->get('usekey', '');
if (!empty($usekey))
{
$input->set('usekey', $usekey);
}
$moduleclass_sfx = $params->get('moduleclass_sfx', '');
$moduleAjax = $params->get('formmodule_useajax', true);
/* $$$rob for table views in category blog layouts when no layout specified in {} the blog layout
* was being used to render the table - which was not found which gave a 500 error
*/
$input->set('layout', $layout);
// Display the view
$controller->isMambot = true;
$controller->cacheId = $formId . '-' . $rowid;
$input->set('formid', $formId);
$input->set('ajax', $moduleAjax);
echo $controller->display();
// Reset the layout and view etc for when the component needs them
$input->set('formid', $origFormid);
$input->set('rowid', $origRowid);
$input->set('ajax', $origAjax);
$input->set('layout', $origLayout);
$input->set('view', $origView);