Conditions | 35 |
Paths | 6485 |
Total Lines | 135 |
Code Lines | 71 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
241 | public function onBeforeCompileHead() |
||
242 | { |
||
243 | if (!$this->isRedcoreComponent()) |
||
244 | { |
||
245 | return; |
||
246 | } |
||
247 | |||
248 | // Only set media settings for Extensions that are redCORE supported Extension in administration |
||
249 | $isRedcoreExtension = $this->isRedcoreExtension(); |
||
250 | |||
251 | $doc = JFactory::getDocument(); |
||
252 | $isAdmin = (version_compare(JVERSION, '3.7', '<') ? |
||
253 | JFactory::getApplication()->isAdmin() : JFactory::getApplication()->isClient('administrator')); |
||
254 | |||
255 | if (!$isAdmin || $isRedcoreExtension) |
||
256 | { |
||
257 | RHtmlMedia::loadFrameworkJs(); |
||
258 | } |
||
259 | |||
260 | if ($doc->_scripts) |
||
261 | { |
||
262 | $template = JFactory::getApplication()->getTemplate(); |
||
263 | |||
264 | // Remove Mootools if asked by view, or if it's a site view and it has been asked via plugin parameters |
||
265 | if ($this->disableMootools() || (!$isAdmin && RBootstrap::$disableFrontendMootools)) |
||
266 | { |
||
267 | $doc->addScriptDeclaration("function do_nothing() { return; }"); |
||
268 | unset($doc->_scripts[JURI::root(true) . '/media/system/js/mootools-core.js']); |
||
269 | unset($doc->_scripts[JURI::root(true) . '/media/system/js/mootools-more.js']); |
||
270 | unset($doc->_scripts[JURI::root(true) . '/media/system/js/caption.js']); |
||
271 | unset($doc->_scripts[JURI::root(true) . '/media/system/js/modal.js']); |
||
272 | unset($doc->_scripts[JURI::root(true) . '/media/system/js/mootools.js']); |
||
273 | unset($doc->_scripts[JURI::root(true) . '/plugins/system/mtupgrade/mootools.js']); |
||
274 | unset($doc->_scripts[JURI::root(true) . '/media/system/js/mootools-core-uncompressed.js']); |
||
275 | unset($doc->_scripts[JURI::root(true) . '/media/system/js/caption-uncompressed.js']); |
||
276 | unset($doc->_scripts[JURI::root(true) . '/media/system/js/modal-uncompressed.js']); |
||
277 | unset($doc->_scripts[JURI::root(true) . '/media/system/js/mootools-more-uncompressed.js']); |
||
278 | |||
279 | if ($doc->_styleSheets) |
||
280 | { |
||
281 | unset($doc->_styleSheets[JURI::root(true) . '/media/system/css/modal.css']); |
||
282 | } |
||
283 | |||
284 | if (!$isAdmin && version_compare(JVERSION, '3.4', '<')) |
||
285 | { |
||
286 | unset($doc->_scripts[JURI::root(true) . '/media/system/js/core.js']); |
||
287 | unset($doc->_scripts[JURI::root(true) . '/media/system/js/core-uncompressed.js']); |
||
288 | } |
||
289 | } |
||
290 | |||
291 | // Remove jQuery in administration, or if it's frontend site and it has been asked via plugin parameters |
||
292 | if (($isAdmin && $isRedcoreExtension) || (!$isAdmin && RBootstrap::$loadFrontendjQuery)) |
||
293 | { |
||
294 | unset($doc->_scripts[JURI::root(true) . '/media/jui/js/jquery.min.js']); |
||
295 | unset($doc->_scripts[JURI::root(true) . '/media/jui/js/jquery.js']); |
||
296 | unset($doc->_scripts[JURI::root(true) . '/media/jui/js/jquery-noconflict.js']); |
||
297 | |||
298 | $jQueryChosen = false; |
||
299 | |||
300 | if (isset($doc->_scripts[JURI::root(true) . '/media/jui/js/chosen.jquery.js']) |
||
301 | || isset($doc->_scripts[JURI::root(true) . '/media/jui/js/chosen.jquery.min.js'])) |
||
302 | { |
||
303 | $jQueryChosen = true; |
||
304 | unset($doc->_scripts[JURI::root(true) . '/media/jui/js/chosen.jquery.js']); |
||
305 | unset($doc->_scripts[JURI::root(true) . '/media/jui/js/chosen.jquery.min.js']); |
||
306 | unset($doc->_styleSheets[JURI::root(true) . '/media/jui/css/chosen.css']); |
||
307 | unset($doc->_styleSheets[JURI::root(true) . '/media/jui/css/chosen.min.css']); |
||
308 | } |
||
309 | |||
310 | // Template specific overrides for jQuery files (valid in Joomla 3.x) |
||
311 | unset($doc->_scripts[JURI::root(true) . '/templates/' . $template . '/js/jui/jquery.min.js']); |
||
312 | unset($doc->_scripts[JURI::root(true) . '/templates/' . $template . '/js/jui/jquery.js']); |
||
313 | unset($doc->_scripts[JURI::root(true) . '/templates/' . $template . '/js/jui/jquery-noconflict.js']); |
||
314 | |||
315 | if (isset($doc->_scripts[JURI::root(true) . '/templates/' . $template . '/js/jui/chosen.jquery.js']) |
||
316 | || isset($doc->_scripts[JURI::root(true) . '/templates/' . $template . '/js/jui/chosen.jquery.min.js'])) |
||
317 | { |
||
318 | $jQueryChosen = true; |
||
319 | unset($doc->_scripts[JURI::root(true) . '/templates/' . $template . '/js/jui/chosen.jquery.js']); |
||
320 | unset($doc->_scripts[JURI::root(true) . '/templates/' . $template . '/js/jui/chosen.jquery.min.js']); |
||
321 | unset($doc->_styleSheets[JURI::root(true) . '/templates/' . $template . '/css/jui/chosen.css']); |
||
322 | unset($doc->_styleSheets[JURI::root(true) . '/templates/' . $template . '/css/jui/chosen.min.css']); |
||
323 | } |
||
324 | |||
325 | // Enables chosen when it was removed |
||
326 | if ($jQueryChosen) |
||
327 | { |
||
328 | RHtml::_('rjquery.chosen', 'select'); |
||
329 | } |
||
330 | } |
||
331 | |||
332 | // Remove jQuery Migrate in administration, or if it's frontend site and it has been asked via plugin parameters |
||
333 | if (($isAdmin && $isRedcoreExtension) || (!$isAdmin && RBootstrap::$loadFrontendjQueryMigrate)) |
||
334 | { |
||
335 | unset($doc->_scripts[JURI::root(true) . '/media/jui/js/jquery-migrate.min.js']); |
||
336 | unset($doc->_scripts[JURI::root(true) . '/media/jui/js/jquery-migrate.js']); |
||
337 | |||
338 | // Template specific overrides for jQuery files (valid in Joomla 3.x) |
||
339 | unset($doc->_scripts[JURI::root(true) . '/templates/' . $template . '/js/jui/jquery-migrate.min.js']); |
||
340 | unset($doc->_scripts[JURI::root(true) . '/templates/' . $template . '/js/jui/jquery-migrate.js']); |
||
341 | } |
||
342 | |||
343 | // Remove Bootstrap in administration, or if it's frontend site and it has been asked via plugin parameters |
||
344 | if (($isAdmin && $isRedcoreExtension) || (!$isAdmin && RBootstrap::$loadFrontendCSS)) |
||
345 | { |
||
346 | unset($doc->_scripts[JURI::root(true) . '/media/jui/js/bootstrap.js']); |
||
347 | unset($doc->_scripts[JURI::root(true) . '/media/jui/js/bootstrap.min.js']); |
||
348 | |||
349 | // Template specific overrides for jQuery files (valid in Joomla 3.x) |
||
350 | unset($doc->_scripts[JURI::root(true) . '/templates/' . $template . '/js/jui/bootstrap.js']); |
||
351 | unset($doc->_scripts[JURI::root(true) . '/templates/' . $template . '/js/jui/bootstrap.min.js']); |
||
352 | } |
||
353 | |||
354 | // Remove permission.js. Specially for Joomla 3.6 and make sure run only on redCORE's base extensions |
||
355 | if ($isAdmin && version_compare(JVERSION, '3.6.0', '>=') && $isRedcoreExtension) |
||
356 | { |
||
357 | $usePermission = false; |
||
358 | |||
359 | if (isset($doc->_scripts[JUri::root(true) . '/media/system/js/permissions.js'])) |
||
360 | { |
||
361 | unset($doc->_scripts[JUri::root(true) . '/media/system/js/permissions.js']); |
||
362 | |||
363 | $usePermission = true; |
||
364 | } |
||
365 | |||
366 | if (isset($doc->_scripts[JUri::root(true) . '/media/system/js/permissions-uncompressed.js'])) |
||
367 | { |
||
368 | unset($doc->_scripts[JUri::root(true) . '/media/system/js/permissions-uncompressed.js']); |
||
369 | |||
370 | $usePermission = true; |
||
371 | } |
||
372 | |||
373 | if ($usePermission) |
||
374 | { |
||
375 | RHelperAsset::load('permission.min.js', 'redcore'); |
||
376 | } |
||
475 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.