Skip to content
This repository
Newer
Older
100644 556 lines (477 sloc) 16.694 kb
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
1 <?php
2 /**
89e3d3a3 » LouisLandry
2011-02-08 Fixed up file headers.
3 * @package Joomla.Platform
4 * @subpackage Installer
0a72863a » LouisLandry
2011-03-20 Fixing file headers for both unit test and library files.
5 *
6 * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
8 */
9
fc5a10c5 » realityking
2011-11-09 Unify the style of the JPATH_PLATFORM check.
10 defined('JPATH_PLATFORM') or die;
eefdefd2 » eddieajau
2009-06-24 Code formatting.
11
78828a16 » pasamio
2009-06-21 Updates to installer subsystem
12 jimport('joomla.installer.extension');
13 jimport('joomla.base.adapterinstance');
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
14
15 /**
16 * Template installer
17 *
53daea85 » eddieajau
2011-05-10 Code cleaning.
18 * @package Joomla.Platform
19 * @subpackage Installer
20 * @since 11.1
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
21 */
78828a16 » pasamio
2009-06-21 Updates to installer subsystem
22 class JInstallerTemplate extends JAdapterInstance
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
23 {
78828a16 » pasamio
2009-06-21 Updates to installer subsystem
24 protected $name = null;
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
25
78828a16 » pasamio
2009-06-21 Updates to installer subsystem
26 protected $element = null;
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
27
d5b0bdff » dextercowley
2010-12-07 [#22957] Upgrading a template that uses method="upgrade" removes manu…
28 protected $route = 'install';
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
29
30 /**
34b5d64e » chdemko
2010-02-08 Changing the way languages are loaded at install and update phase
31 * Custom loadLanguage method
32 *
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
33 * @param string $path The path where to find language files.
34 *
35 * @return JInstallerTemplate
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
36 *
53daea85 » eddieajau
2011-05-10 Code cleaning.
37 * @since 11.1
34b5d64e » chdemko
2010-02-08 Changing the way languages are loaded at install and update phase
38 */
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
39 public function loadLanguage($path = null)
34b5d64e » chdemko
2010-02-08 Changing the way languages are loaded at install and update phase
40 {
fcbb17a6 » chdemko
2010-03-30 Merging the admintranslate branch back to the trunk
41 $source = $this->parent->getPath('source');
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
42
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
43 if (!$source)
44 {
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
45 $this->parent
46 ->setPath(
54509a72 » realityking
2011-11-02 Use an autoformatter for the indentation.
47 'source',
48 ($this->parent->extension->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/templates/' . $this->parent->extension->element
49 );
fcbb17a6 » chdemko
2010-03-30 Merging the admintranslate branch back to the trunk
50 }
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
51
d5b0bdff » dextercowley
2010-12-07 [#22957] Upgrading a template that uses method="upgrade" removes manu…
52 $clientId = isset($this->parent->extension) ? $this->parent->extension->client_id : 0;
aa5891a8 » eddieajau
2010-06-23 Fixed issue [#20907] Making Joomla more compliant to PHP strict standard
53 $this->manifest = $this->parent->getManifest();
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
54 $name = strtolower(JFilterInput::getInstance()->clean((string) $this->manifest->name, 'cmd'));
55 $client = (string) $this->manifest->attributes()->client;
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
56
c2a49520 » pasamio
2010-05-27 # Applied [#20263] E_WARNING Error in JInstallerTemplate::loadLanguag…
57 // Load administrator language if not set.
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
58 if (!$client)
59 {
c2a49520 » pasamio
2010-05-27 # Applied [#20263] E_WARNING Error in JInstallerTemplate::loadLanguag…
60 $client = 'ADMINISTRATOR';
61 }
62
34b5d64e » chdemko
2010-02-08 Changing the way languages are loaded at install and update phase
63 $extension = "tpl_$name";
aa5891a8 » eddieajau
2010-06-23 Fixed issue [#20907] Making Joomla more compliant to PHP strict standard
64 $lang = JFactory::getLanguage();
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
65 $source = $path ? $path : ($this->parent->extension->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/templates/' . $name;
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
66 $lang->load($extension . '.sys', $source, null, false, false)
67 || $lang->load($extension . '.sys', constant('JPATH_' . strtoupper($client)), null, false, false)
68 || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false)
69 || $lang->load($extension . '.sys', constant('JPATH_' . strtoupper($client)), $lang->getDefault(), false, false);
34b5d64e » chdemko
2010-02-08 Changing the way languages are loaded at install and update phase
70 }
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
71
34b5d64e » chdemko
2010-02-08 Changing the way languages are loaded at install and update phase
72 /**
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
73 * Custom install method
74 *
53daea85 » eddieajau
2011-05-10 Code cleaning.
75 * @return boolean True on success
ccb71cac » LouisLandry
2011-07-30 Code cleaning.
76 *
53daea85 » eddieajau
2011-05-10 Code cleaning.
77 * @since 11.1
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
78 */
78828a16 » pasamio
2009-06-21 Updates to installer subsystem
79 public function install()
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
80 {
a028a77d » chdemko
2010-11-05 $ Storing the default style name without ** when language debug is on…
81 $lang = JFactory::getLanguage();
9d3bd0a1 » Hackwar
2010-01-13 ^ Using PHPs built in SimpleXML instead of JSimpleXML to read XML fil…
82 $xml = $this->parent->getManifest();
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
83
84 // Get the client application target
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
85 if ($cname = (string) $xml->attributes()->client)
86 {
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
87 // Attempt to map the client to a base path
88 jimport('joomla.application.helper');
aa5891a8 » eddieajau
2010-06-23 Fixed issue [#20907] Making Joomla more compliant to PHP strict standard
89 $client = JApplicationHelper::getClientInfo($cname, true);
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
90 if ($client === false)
91 {
6f82ea61 » Jean-Marie Simonet
2010-04-22 $ Refactoring ini/keys in libraries/J/Installer/template + helper
92 $this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_TPL_INSTALL_UNKNOWN_CLIENT', $cname));
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
93 return false;
94 }
95 $basePath = $client->path;
96 $clientId = $client->id;
eefdefd2 » eddieajau
2009-06-24 Code formatting.
97 }
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
98 else
99 {
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
100 // No client attribute was found so we assume the site as the client
101 $cname = 'site';
102 $basePath = JPATH_SITE;
103 $clientId = 0;
104 }
105
703224ed » elinw
2011-04-20 installer
106 // Set the extension's name
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
107 $name = JFilterInput::getInstance()->clean((string) $xml->name, 'cmd');
eefdefd2 » eddieajau
2009-06-24 Code formatting.
108
78828a16 » pasamio
2009-06-21 Updates to installer subsystem
109 $element = strtolower(str_replace(" ", "_", $name));
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
110 $this->set('name', $name);
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
111 $this->set('element', $element);
eefdefd2 » eddieajau
2009-06-24 Code formatting.
112
aa5891a8 » eddieajau
2010-06-23 Fixed issue [#20907] Making Joomla more compliant to PHP strict standard
113 $db = $this->parent->getDbo();
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
114 $db->setQuery('SELECT extension_id FROM #__extensions WHERE type="template" AND element = "' . $element . '"');
d5b0bdff » dextercowley
2010-12-07 [#22957] Upgrading a template that uses method="upgrade" removes manu…
115 $id = $db->loadResult();
89e3d3a3 » LouisLandry
2011-02-08 Fixed up file headers.
116
d5b0bdff » dextercowley
2010-12-07 [#22957] Upgrading a template that uses method="upgrade" removes manu…
117 // Set the template root path
a5a8f755 » eddieajau
2011-07-25 Merging uncaught changes from Joomla SVN trunk.
118 $this->parent->setPath('extension_root', $basePath . '/templates/' . $element);
d5b0bdff » dextercowley
2010-12-07 [#22957] Upgrading a template that uses method="upgrade" removes manu…
119
703224ed » elinw
2011-04-20 installer
120 // if it's on the fs...
d5b0bdff » dextercowley
2010-12-07 [#22957] Upgrading a template that uses method="upgrade" removes manu…
121 if (file_exists($this->parent->getPath('extension_root')) && (!$this->parent->getOverwrite() || $this->parent->getUpgrade()))
122 {
123 $updateElement = $xml->update;
703224ed » elinw
2011-04-20 installer
124 // Upgrade manually set or
125 // Update function available or
126 // Update tag detected
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
127 if ($this->parent->getUpgrade() || ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'update'))
672e6a5b » elkuku
2011-10-16 Closing parenthesis of a multi-line IF statement must be on the same …
128 || is_a($updateElement, 'JXMLElement'))
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
129 {
130 // Force this one
131 $this->parent->setOverwrite(true);
132 $this->parent->setUpgrade(true);
133 if ($id)
7515b815 » realityking
2011-11-02 Fix stuff the autoformatter didn't do nicely.
134 {
135 // if there is a matching extension mark this as an update; semantics really
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
136 $this->route = 'update';
d5b0bdff » dextercowley
2010-12-07 [#22957] Upgrading a template that uses method="upgrade" removes manu…
137 }
eefdefd2 » eddieajau
2009-06-24 Code formatting.
138 }
e972e1ba » realityking
2011-10-02 Use elseif instead else if.
139 elseif (!$this->parent->getOverwrite())
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
140 {
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
141 // Overwrite is not set
311faf55 » mbabker
2011-10-24 Spelling & doc block
142 // If we didn't have overwrite set, find an update function or find an update tag so let's call it safe
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
143 $this->parent
144 ->abort(
54509a72 » realityking
2011-11-02 Use an autoformatter for the indentation.
145 JText::sprintf(
146 'JLIB_INSTALLER_ABORT_PLG_INSTALL_DIRECTORY', JText::_('JLIB_INSTALLER_' . $this->route),
147 $this->parent->getPath('extension_root')
148 )
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
149 );
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
150 return false;
151 }
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
152 }
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
153
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
154 /*
155 * If the template directory already exists, then we will assume that the template is already
156 * installed or another template is using that directory.
157 */
158 if (file_exists($this->parent->getPath('extension_root')) && !$this->parent->getOverwrite())
159 {
160 JError::raiseWarning(
161 100,
162 JText::sprintf('JLIB_INSTALLER_ABORT_TPL_INSTALL_ANOTHER_TEMPLATE_USING_DIRECTORY', $this->parent->getPath('extension_root'))
163 );
164 return false;
165 }
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
166
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
167 // If the template directory does not exist, let's create it
168 $created = false;
169 if (!file_exists($this->parent->getPath('extension_root')))
170 {
171 if (!$created = JFolder::create($this->parent->getPath('extension_root')))
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
172 {
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
173 $this->parent
174 ->abort(JText::sprintf('JLIB_INSTALLER_ABORT_TPL_INSTALL_FAILED_CREATE_DIRECTORY', $this->parent->getPath('extension_root')));
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
175
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
176 return false;
177 }
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
178 }
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
179
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
180 // If we created the template directory and will want to remove it if we have to roll back
181 // the installation, let's add it to the installation step stack
182 if ($created)
183 {
184 $this->parent->pushStep(array('type' => 'folder', 'path' => $this->parent->getPath('extension_root')));
185 }
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
186
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
187 // Copy all the necessary files
188 if ($this->parent->parseFiles($xml->files, -1) === false)
189 {
190 // Install failed, rollback changes
191 $this->parent->abort();
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
192
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
193 return false;
194 }
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
195
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
196 if ($this->parent->parseFiles($xml->images, -1) === false)
197 {
198 // Install failed, rollback changes
199 $this->parent->abort();
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
200
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
201 return false;
202 }
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
203
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
204 if ($this->parent->parseFiles($xml->css, -1) === false)
205 {
206 // Install failed, rollback changes
207 $this->parent->abort();
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
208
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
209 return false;
210 }
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
211
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
212 // Parse optional tags
213 $this->parent->parseMedia($xml->media);
214 $this->parent->parseLanguages($xml->languages, $clientId);
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
215
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
216 // Get the template description
217 $this->parent->set('message', JText::_((string) $xml->description));
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
218
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
219 // Lastly, we will copy the manifest file to its appropriate place.
220 if (!$this->parent->copyManifest(-1))
221 {
222 // Install failed, rollback changes
223 $this->parent->abort(JText::_('JLIB_INSTALLER_ABORT_TPL_INSTALL_COPY_SETUP'));
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
224
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
225 return false;
226 }
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
227
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
228 // Extension Registration
703224ed » elinw
2011-04-20 installer
229
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
230 $row = JTable::getInstance('extension');
d5b0bdff » dextercowley
2010-12-07 [#22957] Upgrading a template that uses method="upgrade" removes manu…
231
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
232 if ($this->route == 'update' && $id)
233 {
234 $row->load($id);
78828a16 » pasamio
2009-06-21 Updates to installer subsystem
235 }
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
236 else
d5b0bdff » dextercowley
2010-12-07 [#22957] Upgrading a template that uses method="upgrade" removes manu…
237 {
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
238 $row->type = 'template';
239 $row->element = $this->get('element');
240 // There is no folder for templates
241 $row->folder = '';
242 $row->enabled = 1;
243 $row->protected = 0;
244 $row->access = 1;
245 $row->client_id = $clientId;
246 $row->params = $this->parent->getParams();
247 $row->custom_data = ''; // custom data
d5b0bdff » dextercowley
2010-12-07 [#22957] Upgrading a template that uses method="upgrade" removes manu…
248 }
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
249 $row->name = $this->get('name'); // name might change in an update
250 $row->manifest_cache = $this->parent->generateManifestCache();
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
251
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
252 if (!$row->store())
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
253 {
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
254 // Install failed, roll back changes
255 $this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_TPL_INSTALL_ROLLBACK', $db->stderr(true)));
89e3d3a3 » LouisLandry
2011-02-08 Fixed up file headers.
256
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
257 return false;
258 }
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
259
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
260 if ($this->route == 'install')
261 {
262 //insert record in #__template_styles
263 $query = $db->getQuery(true);
264 $query->insert('#__template_styles');
265 $query->set('template=' . $db->Quote($row->element));
266 $query->set('client_id=' . $db->Quote($clientId));
267 $query->set('home=0');
268 $debug = $lang->setDebug(false);
269 $query->set('title=' . $db->Quote(JText::sprintf('JLIB_INSTALLER_DEFAULT_STYLE', JText::_($this->get('name')))));
270 $lang->setDebug($debug);
271 $query->set('params=' . $db->Quote($row->params));
272 $db->setQuery($query);
273 // There is a chance this could fail but we don't care...
274 $db->query();
275 }
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
276
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
277 return $row->get('extension_id');
278 }
78828a16 » pasamio
2009-06-21 Updates to installer subsystem
279
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
280 /**
281 * Custom update method for components
282 *
283 * @return boolean True on success
284 *
285 * @since 11.1
286 */
287 public function update()
288 {
289 return $this->install();
290 }
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
291
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
292 /**
293 * Custom uninstall method
294 *
295 * @param integer $id The extension ID
296 *
297 * @return boolean True on success
298 *
299 * @since 11.1
300 */
301 public function uninstall($id)
302 {
303 // Initialise variables.
304 $retval = true;
78828a16 » pasamio
2009-06-21 Updates to installer subsystem
305
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
306 // First order of business will be to load the template object table from the database.
307 // This should give us the necessary information to proceed.
308 $row = JTable::getInstance('extension');
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
309
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
310 if (!$row->load((int) $id) || !strlen($row->element))
311 {
312 JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_TPL_UNINSTALL_ERRORUNKOWNEXTENSION'));
313 return false;
314 }
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
315
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
316 // Is the template we are trying to uninstall a core one?
317 // Because that is not a good idea...
318 if ($row->protected)
319 {
320 JError::raiseWarning(100, JText::sprintf('JLIB_INSTALLER_ERROR_TPL_UNINSTALL_WARNCORETEMPLATE', $row->name));
321 return false;
322 }
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
323
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
324 $name = $row->element;
325 $clientId = $row->client_id;
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
326
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
327 // For a template the id will be the template name which represents the subfolder of the templates folder that the template resides in.
328 if (!$name)
329 {
330 JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_TPL_UNINSTALL_TEMPLATE_ID_EMPTY'));
eefdefd2 » eddieajau
2009-06-24 Code formatting.
331
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
332 return false;
333 }
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
334
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
335 // Deny remove default template
336 $db = $this->parent->getDbo();
337 $query = 'SELECT COUNT(*) FROM #__template_styles' . ' WHERE home = 1 AND template = ' . $db->Quote($name);
338 $db->setQuery($query);
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
339
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
340 if ($db->loadResult() != 0)
341 {
342 JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_TPL_UNINSTALL_TEMPLATE_DEFAULT'));
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
343
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
344 return false;
345 }
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
346
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
347 // Get the template root path
348 $client = JApplicationHelper::getClientInfo($clientId);
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
349
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
350 if (!$client)
351 {
352 JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_TPL_UNINSTALL_INVALID_CLIENT'));
353 return false;
354 }
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
355
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
356 $this->parent->setPath('extension_root', $client->path . '/templates/' . strtolower($name));
357 $this->parent->setPath('source', $this->parent->getPath('extension_root'));
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
358
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
359 // We do findManifest to avoid problem when uninstalling a list of extensions: getManifest cache its manifest file
360 $this->parent->findManifest();
361 $manifest = $this->parent->getManifest();
362 if (!($manifest instanceof JXMLElement))
363 {
364 // Kill the extension entry
78828a16 » pasamio
2009-06-21 Updates to installer subsystem
365 $row->delete($row->extension_id);
366 unset($row);
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
367 // Make sure we delete the folders
368 JFolder::delete($this->parent->getPath('extension_root'));
369 JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_TPL_UNINSTALL_INVALID_NOTFOUND_MANIFEST'));
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
370
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
371 return false;
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
372 }
373
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
374 // Remove files
375 $this->parent->removeFiles($manifest->media);
376 $this->parent->removeFiles($manifest->languages, $clientId);
377
378 // Delete the template directory
379 if (JFolder::exists($this->parent->getPath('extension_root')))
380 {
381 $retval = JFolder::delete($this->parent->getPath('extension_root'));
382 }
383 else
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
384 {
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
385 JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_TPL_UNINSTALL_TEMPLATE_DIRECTORY'));
386 $retval = false;
387 }
388
389 // Set menu that assigned to the template back to default template
390 $query = 'UPDATE #__menu INNER JOIN #__template_styles' . ' ON #__template_styles.id = #__menu.template_style_id'
391 . ' SET #__menu.template_style_id = 0' . ' WHERE #__template_styles.template = ' . $db->Quote(strtolower($name))
392 . ' AND #__template_styles.client_id = ' . $db->Quote($clientId);
393 $db->setQuery($query);
394 $db->Query();
f73b6591 » Rob Schley
2009-05-27 Imported the new trunk.
395
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
396 $query = 'DELETE FROM #__template_styles' . ' WHERE template = ' . $db->Quote($name) . ' AND client_id = ' . $db->Quote($clientId);
397 $db->setQuery($query);
398 $db->Query();
399
400 $row->delete($row->extension_id);
401 unset($row);
402
403 return $retval;
404 }
405
406 /**
407 * Discover existing but uninstalled templates
408 *
409 * @return array JExtensionTable list
410 */
f7db9753 » eddieajau
2011-12-02 Fix up missing method scope declarations.
411 public function discover()
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
412 {
9f10f394 » realityking
2011-10-01 Make all PHP keywords (but not built-in functions) lowercase.
413 $results = array();
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
414 $site_list = JFolder::folders(JPATH_SITE . '/templates');
415 $admin_list = JFolder::folders(JPATH_ADMINISTRATOR . '/templates');
416 $site_info = JApplicationHelper::getClientInfo('site', true);
417 $admin_info = JApplicationHelper::getClientInfo('administrator', true);
418
419 foreach ($site_list as $template)
420 {
421 if ($template == 'system')
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
422 {
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
423 continue;
eefdefd2 » eddieajau
2009-06-24 Code formatting.
424
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
425 // Ignore special system template
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
426 }
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
427 $manifest_details = JApplicationHelper::parseXMLInstallFile(JPATH_SITE . "/templates/$template/templateDetails.xml");
428 $extension = JTable::getInstance('extension');
429 $extension->set('type', 'template');
430 $extension->set('client_id', $site_info->id);
431 $extension->set('element', $template);
432 $extension->set('name', $template);
433 $extension->set('state', -1);
434 $extension->set('manifest_cache', json_encode($manifest_details));
435 $results[] = $extension;
436 }
78828a16 » pasamio
2009-06-21 Updates to installer subsystem
437
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
438 foreach ($admin_list as $template)
439 {
440 if ($template == 'system')
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
441 {
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
442 continue;
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
443
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
444 // Ignore special system template
eefdefd2 » eddieajau
2009-06-24 Code formatting.
445 }
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
446
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
447 $manifest_details = JApplicationHelper::parseXMLInstallFile(JPATH_ADMINISTRATOR . "/templates/$template/templateDetails.xml");
448 $extension = JTable::getInstance('extension');
449 $extension->set('type', 'template');
450 $extension->set('client_id', $admin_info->id);
451 $extension->set('element', $template);
452 $extension->set('name', $template);
453 $extension->set('state', -1);
454 $extension->set('manifest_cache', json_encode($manifest_details));
455 $results[] = $extension;
78828a16 » pasamio
2009-06-21 Updates to installer subsystem
456 }
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
457
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
458 return $results;
459 }
460
461 /**
462 * Discover_install
463 * Perform an install for a discovered extension
464 *
465 * @return boolean
466 *
467 * @since 11.1
468 */
f7db9753 » eddieajau
2011-12-02 Fix up missing method scope declarations.
469 public function discover_install()
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
470 {
471 // Templates are one of the easiest
472 // If its not in the extensions table we just add it
473 $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
474 $manifestPath = $client->path . '/templates/' . $this->parent->extension->element . '/templateDetails.xml';
475 $this->parent->manifest = $this->parent->isManifest($manifestPath);
476 $description = (string) $this->parent->manifest->description;
477
478 if ($description)
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
479 {
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
480 $this->parent->set('message', JText::_($description));
481 }
482 else
483 {
484 $this->parent->set('message', '');
485 }
4b7445ff » LouisLandry
2011-07-29 Code cleanup.
486
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
487 $this->parent->setPath('manifest', $manifestPath);
488 $manifest_details = JApplicationHelper::parseXMLInstallFile($this->parent->getPath('manifest'));
489 $this->parent->extension->manifest_cache = json_encode($manifest_details);
490 $this->parent->extension->state = 0;
491 $this->parent->extension->name = $manifest_details['name'];
492 $this->parent->extension->enabled = 1;
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
493
9005bd1c » elkuku
2011-08-29 Removing unnecessary empty braces when instancing classes
494 $data = new JObject;
668b9a56 » chdemko
2010-04-29 Fixed [#20232] Discovery method of installing templates doesn't inser…
495
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
496 foreach ($manifest_details as $key => $value)
497 {
498 $data->set($key, $value);
499 }
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
500
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
501 $this->parent->extension->params = $this->parent->getParams();
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
502
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
503 if ($this->parent->extension->store())
504 {
505 //insert record in #__template_styles
506 $db = $this->parent->getDbo();
507 $query = $db->getQuery(true);
508 $query->insert('#__template_styles');
8e643101 » chdemko
2011-11-05 Update libraries/joomla/installer/adapters/template.php
509 $query->set('template=' . $db->Quote($this->parent->extension->element));
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
510 $query->set('client_id=' . $db->Quote($this->parent->extension->client_id));
511 $query->set('home=0');
512 $query->set('title=' . $db->Quote(JText::sprintf('JLIB_INSTALLER_DEFAULT_STYLE', $this->parent->extension->name)));
513 $query->set('params=' . $db->Quote($this->parent->extension->params));
514 $db->setQuery($query);
515 $db->query();
eefdefd2 » eddieajau
2009-06-24 Code formatting.
516
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
517 return $this->parent->extension->get('extension_id');
518 }
519 else
520 {
521 JError::raiseWarning(101, JText::_('JLIB_INSTALLER_ERROR_TPL_DISCOVER_STORE_DETAILS'));
668b9a56 » chdemko
2010-04-29 Fixed [#20232] Discovery method of installing templates doesn't inser…
522
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
523 return false;
eefdefd2 » eddieajau
2009-06-24 Code formatting.
524 }
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
525 }
18c45a50 » eddieajau
2010-10-28 Fixed issue [#23041] Incorrect testing for variable is an instance of…
526
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
527 /**
528 * Refreshes the extension table cache
529 *
530 * @return boolean Result of operation, true if updated, false on failure
531 *
532 * @since 11.1
533 */
534 public function refreshManifestCache()
535 {
536 // Need to find to find where the XML file is since we don't store this normally.
537 $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
538 $manifestPath = $client->path . '/templates/' . $this->parent->extension->element . '/templateDetails.xml';
539 $this->parent->manifest = $this->parent->isManifest($manifestPath);
540 $this->parent->setPath('manifest', $manifestPath);
89e3d3a3 » LouisLandry
2011-02-08 Fixed up file headers.
541
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
542 $manifest_details = JApplicationHelper::parseXMLInstallFile($this->parent->getPath('manifest'));
543 $this->parent->extension->manifest_cache = json_encode($manifest_details);
544 $this->parent->extension->name = $manifest_details['name'];
9589e504 » chdemko
2010-12-30 [#23837] *Installation unexpectedly terminated: Method not supported …
545
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
546 try
547 {
548 return $this->parent->extension->store();
9589e504 » chdemko
2010-12-30 [#23837] *Installation unexpectedly terminated: Method not supported …
549 }
a820fcd5 » eddieajau
2011-07-31 Code cleaning.
550 catch (JException $e)
551 {
552 JError::raiseWarning(101, JText::_('JLIB_INSTALLER_ERROR_TPL_REFRESH_MANIFEST_CACHE'));
553 return false;
554 }
555 }
556 }
Something went wrong with that request. Please try again.