Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

phpcs

  • Loading branch information...
commit 9771aef7db17a13e6cdb38ce9945d6d9416ff744 1 parent 0d8590e
@compojoom authored
Showing with 95 additions and 70 deletions.
  1. +95 −70 source/administrator/components/com_jedchecker/script.php
View
165 source/administrator/components/com_jedchecker/script.php
@@ -1,7 +1,7 @@
<?php
/**
- * @author Daniel Dimitrov - compojoom.com
- * @date: 02.06.12
+ * @author Daniel Dimitrov <daniel@compojoom.com>
+ * @date 02.06.12
*
* @copyright Copyright (C) 2008 - 2012 compojoom.com . All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
@@ -9,79 +9,104 @@
defined('_JEXEC') or die('Restricted access');
-
-class com_jedcheckerInstallerScript
+/**
+ * Class Com_JedcheckerInstallerScript
+ *
+ * @since 1.5
+ */
+class Com_JedcheckerInstallerScript
{
- protected $extension = 'com_jedchecker';
+ protected $extension = 'com_jedchecker';
+
+ /**
+ * Function executed before the the installation
+ *
+ * @param string $type - the installation type
+ * @param JInstallerComponent $parent - the parent class
+ *
+ * @return bool
+ */
+ public function preflight($type, $parent)
+ {
+ $this->parent = $parent;
+
+ if (version_compare(PHP_VERSION, '5.3.1', '<'))
+ {
+ $this->loadLanguage();
+ Jerror::raiseWarning(null, JText::sprintf('COM_JEDCHECKER_PHP_VERSION_INCOMPATIBLE', PHP_VERSION, '5.3.6'));
+
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Update cleans out any old rules.
+ *
+ * @param JInstallerComponent $parent Is the class calling this method.
+ *
+ * @return bool|null If this returns false, Joomla will abort the update and undo everything already done.
+ */
+ public function update($parent)
+ {
+ $this->loadLanguage();
- function preflight( $type, $parent ) {
- $this->parent = $parent;
- if (version_compare(PHP_VERSION, '5.3.1', '<')) {
- $this->loadLanguage();
- Jerror::raiseWarning(null, JText::sprintf('COM_JEDCHECKER_PHP_VERSION_INCOMPATIBLE', PHP_VERSION, '5.3.6'));
- return false;
- }
- }
+ // Doing it this way in case there are other old rules to be deleted
+ $oldRules = array('htmlindexes');
- /**
- * Update cleans out any old rules.
- *
- * @param JInstallerComponent $parent Is the class calling this method.
- *
- * @return bool|null If this returns false, Joomla will abort the update and undo everything already done.
- */
- public function update($parent)
- {
- $this->loadLanguage();
+ foreach ($oldRules as $rule)
+ {
+ $rulePhpFile = JPATH_ADMINISTRATOR . '/components/' . $this->extension . '/libraries/rules/' . $rule . '.php';
+ $ruleIniFile = JPATH_ADMINISTRATOR . '/components/' . $this->extension . '/libraries/rules/' . $rule . '.ini';
- // Doing it this way in case there are other old rules to be deleted
- $oldRules = array('htmlindexes');
+ // Remove the rule's php file
+ if (file_exists($rulePhpFile))
+ {
+ if (JFile::delete($rulePhpFile))
+ {
+ $msg = JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_PHP_FILE_REMOVED', $rule);
+ }
+ else
+ {
+ $msg = JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_PHP_FILE_NOT_REMOVED', $rule);
+ }
- foreach ($oldRules as $rule)
- {
- $rulePhpFile = JPATH_ADMINISTRATOR . '/components/' . $this->extension . '/libraries/rules/' . $rule . '.php';
- $ruleIniFile = JPATH_ADMINISTRATOR . '/components/' . $this->extension . '/libraries/rules/' . $rule . '.ini';
+ echo "<p>$msg</p>";
+ }
- // Remove the rule's php file
- if(file_exists($rulePhpFile))
- {
- if(JFile::delete($rulePhpFile))
- {
- $msg = JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_PHP_FILE_REMOVED', $rule);
- }
- else
- {
- $msg = JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_PHP_FILE_NOT_REMOVED', $rule);
- }
- echo "<p>$msg</p>";
- }
+ // Remove the rule's ini file
+ if (file_exists($ruleIniFile))
+ {
+ if (JFile::delete($ruleIniFile))
+ {
+ $msg = JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_INI_FILE_REMOVED', $rule);
+ }
+ else
+ {
+ $msg = JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_INI_FILE_NOT_REMOVED', $rule);
+ }
- // Remove the rule's ini file
- if(file_exists($ruleIniFile))
- {
- if(JFile::delete($ruleIniFile))
- {
- $msg = JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_INI_FILE_REMOVED', $rule);
- }
- else
- {
- $msg = JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_INI_FILE_NOT_REMOVED', $rule);
- }
- echo "<p>$msg</p>";
- }
- }
- }
+ echo "<p>$msg</p>";
+ }
+ }
+ }
- public function loadLanguage()
- {
- $extension = $this->extension;
- $jlang = JFactory::getLanguage();
- $path = $this->parent->getParent()->getPath('source') . '/administrator';
- $jlang->load($extension, $path, 'en-GB', true);
- $jlang->load($extension, $path, $jlang->getDefault(), true);
- $jlang->load($extension, $path, null, true);
- $jlang->load($extension . '.sys', $path, 'en-GB', true);
- $jlang->load($extension . '.sys', $path, $jlang->getDefault(), true);
- $jlang->load($extension . '.sys', $path, null, true);
- }
-}
+ * Load language necessary during the installation
+ *
+ * @return void
+ */
+ public function loadLanguage()
+ {
+ $extension = $this->extension;
+ $jlang = JFactory::getLanguage();
+ $path = $this->parent->getParent()->getPath('source') . '/administrator';
+ $jlang->load($extension, $path, 'en-GB', true);
+ $jlang->load($extension, $path, $jlang->getDefault(), true);
+ $jlang->load($extension, $path, null, true);
+ $jlang->load($extension . '.sys', $path, 'en-GB', true);
+ $jlang->load($extension . '.sys', $path, $jlang->getDefault(), true);
+ $jlang->load($extension . '.sys', $path, null, true);
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.