Skip to content

Commit 42a5e02

Browse files
Override Handler
1 parent ed68791 commit 42a5e02

File tree

2 files changed

+68
-6
lines changed

2 files changed

+68
-6
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
/**
4+
* @package Astroid Framework
5+
* @author JoomDev https://www.joomdev.com
6+
* @copyright Copyright (C) 2009 - 2020 JoomDev.
7+
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or Later
8+
*/
9+
10+
namespace Astroid\Helper;
11+
12+
use Astroid\Framework;
13+
use Joomla\CMS\Filesystem\Folder;
14+
use Joomla\Filesystem\File;
15+
16+
defined('_JEXEC') or die;
17+
18+
class Overrides
19+
{
20+
public static $rename = [
21+
'2.5.0' => [
22+
'com_content/form',
23+
'layouts/joomla/form',
24+
'layouts/joomla/content/icons/email.php',
25+
'layouts/joomla/content/icons/print_popup.php',
26+
'layouts/joomla/content/icons/print_screen.php'
27+
]
28+
];
29+
30+
public static function fix()
31+
{
32+
$version = Framework::getVersion();
33+
34+
if (isset(self::$rename[$version])) self::rename(self::$rename[$version]);
35+
}
36+
37+
public static function rename($files)
38+
{
39+
$templates = Template::getAstroidTemplates(true);
40+
$templates = array_unique(array_column($templates, 'template'));
41+
42+
foreach ($templates as $template) {
43+
$path = JPATH_ROOT . '/templates/' . $template . '/html/';
44+
foreach ($files as $file) {
45+
if (is_dir($path . $file)) {
46+
Folder::move($path . $file, $path . (str_replace(basename($file), basename($file) . '-' . date('Y-m-d'), $file)));
47+
} else if (file_exists($path . $file)) {
48+
File::move($path . $file, $path . (str_replace(basename($file), basename($file, '.php') . '-' . date('Y-m-d') . '.php', $file)));
49+
}
50+
}
51+
}
52+
}
53+
}

astroid/astroid-framework/script.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@
66
* @copyright Copyright (C) 2009 - 2020 JoomDev.
77
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or Later
88
*/
9+
10+
use Astroid\Helper\Overrides;
11+
912
// no direct access
1013
defined('_JEXEC') or die;
1114
jimport('joomla.filesystem.file');
1215

13-
class astroidInstallerScript {
16+
class astroidInstallerScript
17+
{
1418

1519
/**
1620
*
1721
* Function to run before installing the component
1822
*/
19-
public function preflight($type, $parent) {
23+
public function preflight($type, $parent)
24+
{
2025
$plugin_dir = JPATH_LIBRARIES . '/' . 'astroid' . '/' . 'plugins' . '/';
2126
$plugins = array_filter(glob($plugin_dir . '*'), 'is_dir');
2227
foreach ($plugins as $plugin) {
@@ -30,17 +35,21 @@ public function preflight($type, $parent) {
3035
*
3136
* Function to run after installing the component
3237
*/
33-
public function postflight($type, $parent) {
38+
public function postflight($type, $parent)
39+
{
3440
$plugin_dir = JPATH_LIBRARIES . '/' . 'astroid' . '/' . 'plugins' . '/';
3541
$plugins = array_filter(glob($plugin_dir . '*'), 'is_dir');
3642
foreach ($plugins as $plugin) {
3743
if ($type == "install" || $type == "update") {
3844
$this->installPlugin($plugin, $plugin_dir);
3945
}
4046
}
47+
48+
Overrides::fix();
4149
}
4250

43-
public function installPlugin($plugin, $plugin_dir) {
51+
public function installPlugin($plugin, $plugin_dir)
52+
{
4453
$db = JFactory::getDbo();
4554
$plugin_name = str_replace($plugin_dir, '', $plugin);
4655

@@ -57,7 +66,8 @@ public function installPlugin($plugin, $plugin_dir) {
5766
return true;
5867
}
5968

60-
public function uninstallPlugin($plugin, $plugin_dir) {
69+
public function uninstallPlugin($plugin, $plugin_dir)
70+
{
6171
$db = JFactory::getDbo();
6272
$plugin_name = str_replace($plugin_dir, '', $plugin);
6373
$query = $db->getQuery(true);
@@ -69,5 +79,4 @@ public function uninstallPlugin($plugin, $plugin_dir) {
6979
$db->execute();
7080
return true;
7181
}
72-
7382
}

0 commit comments

Comments
 (0)