31
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-06-01 05:00:48 +00:00
This commit is contained in:
Daniel Dimitrov 2013-11-11 10:23:05 +01:00
parent 0d8590e092
commit 9771aef7db

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @author Daniel Dimitrov - compojoom.com * @author Daniel Dimitrov <daniel@compojoom.com>
* @date: 02.06.12 * @date 02.06.12
* *
* @copyright Copyright (C) 2008 - 2012 compojoom.com . All rights reserved. * @copyright Copyright (C) 2008 - 2012 compojoom.com . All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE * @license GNU General Public License version 2 or later; see LICENSE
@ -9,79 +9,104 @@
defined('_JEXEC') or die('Restricted access'); 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 preflight( $type, $parent ) { /**
$this->parent = $parent; * Function executed before the the installation
if (version_compare(PHP_VERSION, '5.3.1', '<')) { *
$this->loadLanguage(); * @param string $type - the installation type
Jerror::raiseWarning(null, JText::sprintf('COM_JEDCHECKER_PHP_VERSION_INCOMPATIBLE', PHP_VERSION, '5.3.6')); * @param JInstallerComponent $parent - the parent class
return false; *
} * @return bool
} */
public function preflight($type, $parent)
{
$this->parent = $parent;
/** if (version_compare(PHP_VERSION, '5.3.1', '<'))
* Update cleans out any old rules. {
* $this->loadLanguage();
* @param JInstallerComponent $parent Is the class calling this method. Jerror::raiseWarning(null, JText::sprintf('COM_JEDCHECKER_PHP_VERSION_INCOMPATIBLE', PHP_VERSION, '5.3.6'));
*
* @return bool|null If this returns false, Joomla will abort the update and undo everything already done.
*/
public function update($parent)
{
$this->loadLanguage();
// Doing it this way in case there are other old rules to be deleted return false;
$oldRules = array('htmlindexes'); }
foreach ($oldRules as $rule) return true;
{ }
$rulePhpFile = JPATH_ADMINISTRATOR . '/components/' . $this->extension . '/libraries/rules/' . $rule . '.php';
$ruleIniFile = JPATH_ADMINISTRATOR . '/components/' . $this->extension . '/libraries/rules/' . $rule . '.ini';
// Remove the rule's php file /**
if(file_exists($rulePhpFile)) * Update cleans out any old rules.
{ *
if(JFile::delete($rulePhpFile)) * @param JInstallerComponent $parent Is the class calling this method.
{ *
$msg = JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_PHP_FILE_REMOVED', $rule); * @return bool|null If this returns false, Joomla will abort the update and undo everything already done.
} */
else public function update($parent)
{ {
$msg = JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_PHP_FILE_NOT_REMOVED', $rule); $this->loadLanguage();
}
echo "<p>$msg</p>";
}
// Remove the rule's ini file // Doing it this way in case there are other old rules to be deleted
if(file_exists($ruleIniFile)) $oldRules = array('htmlindexes');
{
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>";
}
}
}
public function loadLanguage() foreach ($oldRules as $rule)
{ {
$extension = $this->extension; $rulePhpFile = JPATH_ADMINISTRATOR . '/components/' . $this->extension . '/libraries/rules/' . $rule . '.php';
$jlang = JFactory::getLanguage(); $ruleIniFile = JPATH_ADMINISTRATOR . '/components/' . $this->extension . '/libraries/rules/' . $rule . '.ini';
$path = $this->parent->getParent()->getPath('source') . '/administrator';
$jlang->load($extension, $path, 'en-GB', true); // Remove the rule's php file
$jlang->load($extension, $path, $jlang->getDefault(), true); if (file_exists($rulePhpFile))
$jlang->load($extension, $path, null, true); {
$jlang->load($extension . '.sys', $path, 'en-GB', true); if (JFile::delete($rulePhpFile))
$jlang->load($extension . '.sys', $path, $jlang->getDefault(), true); {
$jlang->load($extension . '.sys', $path, null, true); $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);
}
echo "<p>$msg</p>";
}
}
}
/**
* 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);
}
}