/
easycreator.php
167 lines (134 loc) · 3.96 KB
/
easycreator.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php defined('_JEXEC') || die('=;)');
/**
* @package EasyCreator
* @subpackage Base
* @author Nikolai Plath (elkuku)
* @author Created on 06-Mar-2008
* @license GNU/GPL, see JROOT/LICENSE.php
*/
// When changing Joomla! versions look for:
// @Joomla!-version-check
// @Joomla!-compat XXXX
// Dev mode - internal use =;)
// @@DEBUG
define('ECR_DEV_MODE', 1);
JDEBUG ? JProfiler::getInstance('Application')->mark('com_easycreator starting') : null;
//@todo legacy imports...
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
JHtml::_('behavior.framework');
JHTML::_('behavior.tooltip');
// Global constants
require JPATH_COMPONENT.'/includes/defines.php';
try
{
// Global functions
require JPATH_COMPONENT.'/includes/loader.php';
}
catch(Exception $e)
{
JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
return;
}
/**
* EasyCreator Version
*/
define('ECR_VERSION', EcrProjectHelper::parseXMLInstallFile(
JPATH_COMPONENT_ADMINISTRATOR.DS.'easycreator.xml')->version);
/**
* Check the Joomla! version
*
* @Joomla!-version-check
*/
switch(ECR_JVERSION)
{
case '1.5' :
case '1.6' :
case '1.7' :
JFactory::getApplication()->enqueueMessage(sprintf(
jgettext('EasyCreator %1$s is not compatible with Joomla! %2$s - Sorry.')
, ECR_VERSION, ECR_JVERSION)
, 'error');
return;
break;
case '2.5':
//-- @Joomla!-compat 2.5
ecrStylesheet('bootstrap');
break;
case '3.0':
case '3.1':
case '3.2': // @joomla blabla
case '3.3': // @todo huhu
case '3.4': // Current
if (version_compare(JVERSION, '3.2.2-dev', '<'))
{
JFactory::getApplication()->JComponentTitle = 'EasyCreator';
}
break;
case '4': // Get prepared
$application = JFactory::getApplication();
$application->JComponentTitle = 'EasyCreator';
$application->enqueueMessage(sprintf(
jgettext(
'EasyCreator %1$s is in testing stage with Joomla! %2$s'
)
, ECR_VERSION, ECR_JVERSION)
, 'warning'
);
break;
default:
JFactory::getApplication()->enqueueMessage(sprintf(
jgettext('EasyCreator version %s may not work well with your Joomla! version %s')
, ECR_VERSION, ECR_JVERSION), 'error');
break;
}
// Add CSS
ecrStylesheet('default', 'toolbar', 'icon');
// Add JavaScript
ecrScript('global_vars', 'easycreator');
JFactory::getDocument()->addScriptDeclaration("var ECR_VERSION = '".ECR_VERSION."';".NL);
JFactory::getDocument()->addScriptDeclaration("var ECR_JVERSION = '".ECR_JVERSION."';".NL);
$prevErrorReporting = error_reporting(- 1);
try
{
$controller = EcrEasycreator::getController();
$input = JFactory::getApplication()->input;
if('component' == $input->get('tmpl'))
{
// Perform the Request task only - raw view
$controller->execute($input->get('task'));
}
else
{
// Display the menu
EcrHtmlMenu::main();
// Perform the Request task
$controller->execute($input->get('task'));
if(ECR_DEV_MODE && ECR_DEBUG_LANG
&& class_exists('g11n')
)
{
g11n::debugPrintTranslateds(true);
g11n::debugPrintTranslateds();
}
// Display the footer
EcrHtml::footer();
JDEBUG ? JProfiler::getInstance('Application')->mark('com_easycreator finished') : null;
}
// Restore error_reporting
error_reporting($prevErrorReporting);
// Redirect if set by the controller
// We don't do this very often =;)
$controller->redirect();
}
catch(Exception $e)
{
EcrHtml::message($e);
JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
if(ECR_DEBUG)
{
echo '<pre>'.$e->getTraceAsString().'</pre>';
}
}
// Restore error_reporting
error_reporting($prevErrorReporting);