primo commit
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,221 @@
|
||||
<?php
|
||||
/**
|
||||
* @package ShackInstaller
|
||||
* @contact www.joomlashack.com, help@joomlashack.com
|
||||
* @copyright 2016-2023 Joomlashack.com. All rights reserved
|
||||
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
|
||||
*
|
||||
* This file is part of ShackInstaller.
|
||||
*
|
||||
* ShackInstaller is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ShackInstaller is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ShackInstaller. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Alledia\Installer;
|
||||
|
||||
defined('_JEXEC') or die();
|
||||
|
||||
class AutoLoader
|
||||
{
|
||||
/**
|
||||
* Associative array where the key is a namespace prefix and the value
|
||||
* is an array of base directories for classes in that namespace.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $prefixes = [];
|
||||
|
||||
/**
|
||||
* Associative array of prefixes for loading specialized camelCase classes
|
||||
* where Uppercase letters in the class name indicate directory structure
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $camelPrefixes = [];
|
||||
|
||||
/**
|
||||
* @var AutoLoader
|
||||
*/
|
||||
protected static $instance = null;
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
*/
|
||||
protected static function registerLoader($method)
|
||||
{
|
||||
if (static::$instance === null) {
|
||||
static::$instance = new static();
|
||||
}
|
||||
|
||||
spl_autoload_register([static::$instance, $method]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a psr4 namespace
|
||||
*
|
||||
* @param string $prefix The namespace prefix.
|
||||
* @param string $baseDir A base directory for class files in the
|
||||
* namespace.
|
||||
* @param ?bool $prepend If true, prepend the base directory to the stack
|
||||
* instead of appending it; this causes it to be searched first rather
|
||||
* than last.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function register(string $prefix, string $baseDir, ?bool $prepend = false)
|
||||
{
|
||||
if (count(self::$prefixes) == 0) {
|
||||
static::registerLoader('loadClass');
|
||||
}
|
||||
|
||||
// normalize namespace prefix
|
||||
$prefix = trim($prefix, '\\') . '\\';
|
||||
|
||||
// normalize the base directory with a trailing separator
|
||||
$baseDir = rtrim($baseDir, '\\/') . '/';
|
||||
|
||||
// initialise the namespace prefix array
|
||||
if (empty(self::$prefixes[$prefix])) {
|
||||
self::$prefixes[$prefix] = [];
|
||||
}
|
||||
|
||||
// retain the base directory for the namespace prefix
|
||||
if ($prepend) {
|
||||
array_unshift(self::$prefixes[$prefix], $baseDir);
|
||||
} else {
|
||||
array_push(self::$prefixes[$prefix], $baseDir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the class file for a given class name.
|
||||
*
|
||||
* @param string $class The fully-qualified class name.
|
||||
*
|
||||
* @return ?string The mapped file name on success
|
||||
*/
|
||||
protected function loadClass(string $class): ?string
|
||||
{
|
||||
$prefixes = explode('\\', $class);
|
||||
$className = '';
|
||||
while ($prefixes) {
|
||||
$className = array_pop($prefixes) . $className;
|
||||
$prefix = join('\\', $prefixes) . '\\';
|
||||
|
||||
if ($filePath = $this->loadMappedFile($prefix, $className)) {
|
||||
return $filePath;
|
||||
}
|
||||
|
||||
$className = '\\' . $className;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the mapped file for a namespace prefix and class.
|
||||
*
|
||||
* @param string $prefix The namespace prefix.
|
||||
* @param string $className The relative class name.
|
||||
*
|
||||
* @return ?string path that was loaded
|
||||
*/
|
||||
protected function loadMappedFile(string $prefix, string $className): ?string
|
||||
{
|
||||
// are there any base directories for this namespace prefix?
|
||||
if (isset(self::$prefixes[$prefix]) === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// look through base directories for this namespace prefix
|
||||
foreach (self::$prefixes[$prefix] as $baseDir) {
|
||||
$path = $baseDir . str_replace('\\', '/', $className) . '.php';
|
||||
|
||||
if (is_file($path)) {
|
||||
require_once $path;
|
||||
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a base directory for classes organized using camelCase.
|
||||
* Class names beginning with the prefix will be automatically loaded
|
||||
* if there is a matching file in the directory tree starting with $baseDir.
|
||||
* File names and directory names are all expected to be lower case.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* $prefix = 'Simplerenew'
|
||||
* $baseDir = '/library/joomla'
|
||||
*
|
||||
* A class name of: SimplerenewViewAdmin
|
||||
* Would be in : /library/joomla/view/admin.php
|
||||
*
|
||||
* This system is intended for situations where full name spacing is either
|
||||
* unavailable or impractical due to integration with other systems.
|
||||
*
|
||||
* @param string $prefix
|
||||
* @param string $baseDir
|
||||
*
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function registerCamelBase(string $prefix, string $baseDir)
|
||||
{
|
||||
if (!is_dir($baseDir)) {
|
||||
throw new \Exception("Cannot register '{$prefix}'. The requested base directory does not exist!'");
|
||||
}
|
||||
|
||||
if (count(self::$camelPrefixes) == 0) {
|
||||
// Register function on first call
|
||||
static::registerLoader('loadCamelClass');
|
||||
}
|
||||
|
||||
if (empty(self::$camelPrefixes[$prefix])) {
|
||||
self::$camelPrefixes[$prefix] = $baseDir;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoload a class using the camelCase structure
|
||||
*
|
||||
* @param string $class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function loadCamelClass(string $class): ?string
|
||||
{
|
||||
if (!class_exists($class)) {
|
||||
foreach (self::$camelPrefixes as $prefix => $baseDir) {
|
||||
if (strpos($class, $prefix) === 0) {
|
||||
$parts = preg_split('/(?<=[a-z])(?=[A-Z])/x', substr($class, strlen($prefix)));
|
||||
|
||||
$file = strtolower(join('/', $parts));
|
||||
$filePath = $baseDir . '/' . $file . '.php';
|
||||
|
||||
if (is_file($filePath)) {
|
||||
require_once $filePath;
|
||||
|
||||
return $filePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,435 @@
|
||||
<?php
|
||||
/**
|
||||
* @package ShackInstaller
|
||||
* @contact www.joomlashack.com, help@joomlashack.com
|
||||
* @copyright 2016-2023 Joomlashack.com. All rights reserved
|
||||
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
|
||||
*
|
||||
* This file is part of ShackInstaller.
|
||||
*
|
||||
* ShackInstaller is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ShackInstaller is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ShackInstaller. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Alledia\Installer\Extension;
|
||||
|
||||
defined('_JEXEC') or die();
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
/**
|
||||
* Generic extension class
|
||||
*/
|
||||
class Generic
|
||||
{
|
||||
/**
|
||||
* The extension namespace
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = null;
|
||||
|
||||
/**
|
||||
* The extension type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = null;
|
||||
|
||||
/**
|
||||
* The extension id
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $id = null;
|
||||
|
||||
/**
|
||||
* The extension name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = null;
|
||||
|
||||
/**
|
||||
* The extension params
|
||||
*
|
||||
* @var Registry
|
||||
*/
|
||||
public $params = null;
|
||||
|
||||
/**
|
||||
* The extension enable state
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $enabled = null;
|
||||
|
||||
/**
|
||||
* The element of the extension
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $element = null;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $folder = null;
|
||||
|
||||
/**
|
||||
* Base path
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $basePath = null;
|
||||
|
||||
/**
|
||||
* The manifest information
|
||||
*
|
||||
* @var \SimpleXMLElement
|
||||
*/
|
||||
public $manifest = null;
|
||||
|
||||
/**
|
||||
* The config.xml information
|
||||
*
|
||||
* @var \SimpleXMLElement
|
||||
*/
|
||||
public $config = null;
|
||||
|
||||
/**
|
||||
* Class constructor, set the extension type.
|
||||
*
|
||||
* @param string $namespace The element of the extension
|
||||
* @param string $type The type of extension
|
||||
* @param ?string $folder The folder for plugins (only)
|
||||
* @param string $basePath
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(string $namespace, string $type, ?string $folder = '', string $basePath = JPATH_SITE)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->element = strtolower($namespace);
|
||||
$this->folder = $folder;
|
||||
$this->basePath = $basePath;
|
||||
$this->namespace = $namespace;
|
||||
|
||||
$this->getManifest();
|
||||
|
||||
$this->getDataFromDatabase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about this extension from the database
|
||||
* NOTE: This is duplicated code from the corresponding class in
|
||||
* \Alledia\Framework\Joomla\Extension\Generic
|
||||
*/
|
||||
protected function getDataFromDatabase()
|
||||
{
|
||||
$element = $this->getElementToDb();
|
||||
|
||||
// Load the extension info from database
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select([
|
||||
$db->quoteName('extension_id'),
|
||||
$db->quoteName('name'),
|
||||
$db->quoteName('enabled'),
|
||||
$db->quoteName('params')
|
||||
])
|
||||
->from('#__extensions')
|
||||
->where($db->quoteName('type') . ' = ' . $db->quote($this->type))
|
||||
->where($db->quoteName('element') . ' = ' . $db->quote($element));
|
||||
|
||||
if ($this->type === 'plugin') {
|
||||
$query->where($db->quoteName('folder') . ' = ' . $db->quote($this->folder));
|
||||
}
|
||||
|
||||
$db->setQuery($query);
|
||||
$row = $db->loadObject();
|
||||
|
||||
if (is_object($row)) {
|
||||
$this->id = $row->extension_id;
|
||||
$this->name = $row->name;
|
||||
$this->enabled = (bool)$row->enabled;
|
||||
$this->params = new Registry($row->params);
|
||||
|
||||
} else {
|
||||
$this->id = null;
|
||||
$this->name = null;
|
||||
$this->enabled = false;
|
||||
$this->params = new Registry();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the extension is enabled
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return (bool)$this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path for the extension
|
||||
*
|
||||
* @return string The path
|
||||
*/
|
||||
public function getExtensionPath(): string
|
||||
{
|
||||
$folders = [
|
||||
'component' => 'administrator/components/',
|
||||
'plugin' => 'plugins/',
|
||||
'template' => 'templates/',
|
||||
'library' => 'libraries/',
|
||||
'cli' => 'cli/',
|
||||
'module' => 'modules/'
|
||||
];
|
||||
|
||||
$basePath = $this->basePath . '/' . $folders[$this->type];
|
||||
|
||||
switch ($this->type) {
|
||||
case 'plugin':
|
||||
$basePath .= $this->folder . '/';
|
||||
break;
|
||||
|
||||
case 'module':
|
||||
if (!preg_match('/^mod_/', $this->element)) {
|
||||
$basePath .= 'mod_';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'component':
|
||||
if (!preg_match('/^com_/', $this->element)) {
|
||||
$basePath .= 'com_';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$basePath .= $this->element;
|
||||
|
||||
return $basePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFullElement(): string
|
||||
{
|
||||
$prefixes = [
|
||||
'component' => 'com',
|
||||
'plugin' => 'plg',
|
||||
'template' => 'tpl',
|
||||
'library' => 'lib',
|
||||
'cli' => 'cli',
|
||||
'module' => 'mod'
|
||||
];
|
||||
|
||||
$fullElement = $prefixes[$this->type];
|
||||
|
||||
if ($this->type === 'plugin') {
|
||||
$fullElement .= '_' . $this->folder;
|
||||
}
|
||||
|
||||
$fullElement .= '_' . $this->element;
|
||||
|
||||
return $fullElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the element to match the database records.
|
||||
* Only components and modules have the prefix.
|
||||
*
|
||||
* @return string The element
|
||||
*/
|
||||
public function getElementToDb(): string
|
||||
{
|
||||
$prefixes = [
|
||||
'component' => 'com_',
|
||||
'module' => 'mod_'
|
||||
];
|
||||
|
||||
$fullElement = '';
|
||||
if (array_key_exists($this->type, $prefixes)) {
|
||||
if (!preg_match('/^' . $prefixes[$this->type] . '/', $this->element)) {
|
||||
$fullElement = $prefixes[$this->type];
|
||||
}
|
||||
}
|
||||
|
||||
$fullElement .= $this->element;
|
||||
|
||||
return $fullElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get manifest path for this extension
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getManifestPath(): string
|
||||
{
|
||||
$extensionPath = $this->getExtensionPath();
|
||||
|
||||
switch ($this->type) {
|
||||
case 'template':
|
||||
$fileName = 'templateDetails.xml';
|
||||
break;
|
||||
|
||||
case 'library':
|
||||
$fileName = $this->element . '.xml';
|
||||
if (!is_file($extensionPath . '/' . $fileName)) {
|
||||
$extensionPath = JPATH_MANIFESTS . '/libraries';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'module':
|
||||
$fileName = 'mod_' . $this->element . '.xml';
|
||||
break;
|
||||
|
||||
case 'pkg':
|
||||
$extensionPath = JPATH_MANIFESTS . '/packages';
|
||||
$fileName = 'pkg_' . $this->element . '.xml';
|
||||
break;
|
||||
|
||||
case 'file':
|
||||
$extensionPath = JPATH_MANIFESTS . '/files';
|
||||
$fileName = 'file_' . $this->element . '.xml';
|
||||
break;
|
||||
|
||||
default:
|
||||
$fileName = $this->element . '.xml';
|
||||
break;
|
||||
}
|
||||
|
||||
return $extensionPath . '/' . $fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get extension information
|
||||
*
|
||||
* @param bool $force If true, force to load the manifest, ignoring the cached one
|
||||
*
|
||||
* @return ?\SimpleXMLElement
|
||||
*/
|
||||
public function getManifest(bool $force = false): ?\SimpleXMLElement
|
||||
{
|
||||
if ($this->manifest === null || $force) {
|
||||
$this->manifest = false;
|
||||
|
||||
$path = $this->getManifestPath();
|
||||
if (is_file($path)) {
|
||||
$this->manifest = simplexml_load_file($path);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->manifest ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get extension config file
|
||||
*
|
||||
* @param bool $force Force to reload the config file
|
||||
*
|
||||
* @return \SimpleXMLElement
|
||||
*/
|
||||
public function getConfig(bool $force = false)
|
||||
{
|
||||
if ($this->config === null || $force) {
|
||||
$path = $this->getExtensionPath() . '/config.xml';
|
||||
|
||||
$this->config = is_file($path) ? simplexml_load_file($path) : false;
|
||||
}
|
||||
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the update URL from database
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUpdateURL(): string
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('sites.location')
|
||||
->from('#__update_sites AS sites')
|
||||
->leftJoin('#__update_sites_extensions AS extensions ON (sites.update_site_id = extensions.update_site_id)')
|
||||
->where('extensions.extension_id = ' . $this->id);
|
||||
|
||||
return $db->setQuery($query)->loadResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the update URL
|
||||
*
|
||||
* @param string $url
|
||||
*/
|
||||
public function setUpdateURL(string $url)
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
|
||||
// Get the update site id
|
||||
$join = $db->quoteName('#__update_sites_extensions') . ' AS extensions '
|
||||
. 'ON (sites.update_site_id = extensions.update_site_id)';
|
||||
$query = $db->getQuery(true)
|
||||
->select('sites.update_site_id')
|
||||
->from($db->quoteName('#__update_sites') . ' AS sites')
|
||||
->leftJoin($join)
|
||||
->where('extensions.extension_id = ' . $this->id);
|
||||
$db->setQuery($query);
|
||||
$siteId = (int)$db->loadResult();
|
||||
|
||||
if (!empty($siteId)) {
|
||||
$query = $db->getQuery(true)
|
||||
->update($db->quoteName('#__update_sites'))
|
||||
->set($db->quoteName('location') . ' = ' . $db->quote($url))
|
||||
->where($db->quoteName('update_site_id') . ' = ' . $siteId);
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the params on the database
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function storeParams()
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$params = $db->quote($this->params->toString());
|
||||
$id = $db->quote($this->id);
|
||||
|
||||
$query = "UPDATE `#__extensions` SET params = {$params} WHERE extension_id = {$id}";
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get extension name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,147 @@
|
||||
<?php
|
||||
/**
|
||||
* @package ShackInstaller
|
||||
* @contact www.joomlashack.com, help@joomlashack.com
|
||||
* @copyright 2016-2023 Joomlashack.com. All rights reserved
|
||||
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
|
||||
*
|
||||
* This file is part of ShackInstaller.
|
||||
*
|
||||
* ShackInstaller is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ShackInstaller is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ShackInstaller. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Alledia\Installer\Extension;
|
||||
|
||||
defined('_JEXEC') or die();
|
||||
|
||||
use Alledia\Installer\AutoLoader;
|
||||
|
||||
/**
|
||||
* Licensed class, for extensions with Free and Pro versions
|
||||
*/
|
||||
class Licensed extends Generic
|
||||
{
|
||||
/**
|
||||
* License type: free or pro
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $license = null;
|
||||
|
||||
/**
|
||||
* The path for the pro library
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $proLibraryPath = null;
|
||||
|
||||
/**
|
||||
* The path for the free library
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $libraryPath = null;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function __construct(string $namespace, string $type, ?string $folder = '', string $basePath = JPATH_SITE)
|
||||
{
|
||||
parent::__construct($namespace, $type, $folder, $basePath);
|
||||
|
||||
$this->license = $this->manifest ? strtolower($this->manifest->alledia->license) : 'free';
|
||||
|
||||
$this->getLibraryPath();
|
||||
$this->getProLibraryPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the license is pro
|
||||
*
|
||||
* @return bool True for pro license
|
||||
*/
|
||||
public function isPro(): bool
|
||||
{
|
||||
return $this->license === 'pro';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the license is free
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isFree(): bool
|
||||
{
|
||||
return !$this->isPro();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path for the free library, based on the extension type
|
||||
*
|
||||
* @return string The path for pro
|
||||
*/
|
||||
public function getLibraryPath(): string
|
||||
{
|
||||
if (empty($this->libraryPath)) {
|
||||
$basePath = $this->getExtensionPath();
|
||||
|
||||
$this->libraryPath = $basePath . '/library';
|
||||
}
|
||||
|
||||
return $this->libraryPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get path for the pro library, based on the extension type
|
||||
*
|
||||
* @return string The path for pro
|
||||
*/
|
||||
public function getProLibraryPath(): string
|
||||
{
|
||||
if ($this->proLibraryPath === null) {
|
||||
$basePath = $this->getLibraryPath();
|
||||
|
||||
$this->proLibraryPath = $basePath . '/Pro';
|
||||
}
|
||||
|
||||
return $this->proLibraryPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the library, if existent (including the Pro Library)
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function loadLibrary(): bool
|
||||
{
|
||||
$libraryPath = $this->getLibraryPath();
|
||||
|
||||
// If we have a library path, lets load it
|
||||
if (is_dir($libraryPath)) {
|
||||
if ($this->isPro()) {
|
||||
// Check if the pro library exists
|
||||
if (!is_dir($this->getProLibraryPath())) {
|
||||
throw new \Exception("Pro library not found: {$this->type}, {$this->element}");
|
||||
}
|
||||
}
|
||||
|
||||
AutoLoader::register('Alledia\\' . $this->namespace, $libraryPath);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
101
administrator/components/com_osmap/library/Installer/Loader.php
Normal file
101
administrator/components/com_osmap/library/Installer/Loader.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* @package ShackInstaller
|
||||
* @contact www.joomlashack.com, help@joomlashack.com
|
||||
* @copyright 2016-2023 Joomlashack.com. All rights reserved
|
||||
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
|
||||
*
|
||||
* This file is part of ShackInstaller.
|
||||
*
|
||||
* ShackInstaller is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ShackInstaller is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ShackInstaller. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Alledia\Installer;
|
||||
|
||||
use Alledia\Framework\Factory;
|
||||
use Joomla\CMS\Log\Log;
|
||||
|
||||
defined('_JEXEC') or die();
|
||||
|
||||
abstract class Loader
|
||||
{
|
||||
protected static $logRegistered = false;
|
||||
|
||||
/**
|
||||
* Safely include a PHP file, making sure it exists before import.
|
||||
*
|
||||
* This method will register a log message and display a warning for admins
|
||||
* in case the file is missed.
|
||||
*
|
||||
* @param string $path The file path you want to include
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function includeFile(string $path): bool
|
||||
{
|
||||
if (!static::$logRegistered) {
|
||||
Log::addLogger(
|
||||
['text_file' => 'shackframework.loader.errors.php'],
|
||||
Log::ALL,
|
||||
['allediaframework']
|
||||
);
|
||||
|
||||
static::$logRegistered = true;
|
||||
}
|
||||
|
||||
// Check if the file doesn't exist
|
||||
if (!is_file($path)) {
|
||||
$logMsg = 'Required file is missed: ' . $path;
|
||||
|
||||
// Generate a backtrace to know from where the request cames
|
||||
if (version_compare(phpversion(), '5.4', '<')) {
|
||||
$backtrace = debug_backtrace();
|
||||
} else {
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
}
|
||||
|
||||
if (!empty($backtrace)) {
|
||||
$logMsg .= sprintf(
|
||||
' (%s:%s)',
|
||||
$backtrace[0]['file'],
|
||||
$backtrace[0]['line']
|
||||
);
|
||||
}
|
||||
|
||||
// Register the log
|
||||
Log::add($logMsg, Log::ERROR, 'allediaframework');
|
||||
|
||||
// Warn admin users
|
||||
$app = Factory::getApplication();
|
||||
if ($app->getName() == 'administrator') {
|
||||
$app->enqueueMessage(
|
||||
'ShackInstaller Loader detected that a required file was not found! Please, check the logs.',
|
||||
'error'
|
||||
);
|
||||
}
|
||||
|
||||
// Stand up a flag to warn a required file is missed
|
||||
if (!defined('SHACK_INSTALLER_MISSED_FILE')) {
|
||||
define('SHACK_INSTALLER_MISSED_FILE', true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
include_once $path;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,536 @@
|
||||
<?php
|
||||
/**
|
||||
* @package OSMap
|
||||
* @contact www.joomlashack.com, help@joomlashack.com
|
||||
* @copyright 2007-2014 XMap - Joomla! Vargas - Guillermo Vargas. All rights reserved.
|
||||
* @copyright 2016-2024 Joomlashack.com. All rights reserved.
|
||||
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
|
||||
*
|
||||
* This file is part of OSMap.
|
||||
*
|
||||
* OSMap is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OSMap is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OSMap. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Alledia\Installer\OSMap\Free;
|
||||
|
||||
use Alledia\Installer\OSMap\XmapConverter;
|
||||
use Joomla\CMS\Application\SiteApplication;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Filesystem\File;
|
||||
use Joomla\CMS\Filesystem\Folder;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Installer\InstallerAdapter;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Table\Table;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('_JEXEC') or die();
|
||||
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
class AbstractScript extends \Alledia\Installer\AbstractScript
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $isXmapDataFound = false;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function customPostFlight(string $type, InstallerAdapter $parent): void
|
||||
{
|
||||
if ($type == 'uninstall') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if XMap is installed, to start a migration
|
||||
$xmapConverter = new XmapConverter();
|
||||
|
||||
// This attribute will be used by the custom template to display the option to migrate legacy sitemaps
|
||||
$this->isXmapDataFound = $this->findTable('#__xmap_sitemap') && $xmapConverter->checkXmapDataExists();
|
||||
|
||||
// If Xmap plugins are still available, and we don't have the OSMap plugins yet,
|
||||
// save Xmap plugins params to re-apply after install OSMap plugins
|
||||
$xmapConverter->saveXmapPluginParamsIfExists();
|
||||
|
||||
// Load Alledia Framework
|
||||
require_once JPATH_ADMINISTRATOR . '/components/com_osmap/include.php';
|
||||
|
||||
switch ($type) {
|
||||
case 'install':
|
||||
case 'discover_install':
|
||||
$this->createDefaultSitemap();
|
||||
|
||||
$link = HTMLHelper::_(
|
||||
'link',
|
||||
'index.php?option=com_plugins&view=plugins&filter.search=OSMap',
|
||||
Text::_('COM_OSMAP_INSTALLER_PLUGINS_PAGE')
|
||||
);
|
||||
$this->sendMessage(Text::sprintf('COM_OSMAP_INSTALLER_GOTOPLUGINS', $link), 'warning');
|
||||
break;
|
||||
|
||||
case 'update':
|
||||
$this->checkDatabase();
|
||||
$this->fixXMLMenus();
|
||||
$this->clearLanguageFiles();
|
||||
break;
|
||||
}
|
||||
|
||||
$xmapConverter->moveXmapPluginsParamsToOSMapPlugins();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default sitemap if no one is found.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function createDefaultSitemap(): void
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
|
||||
// Check if we have any sitemaps, otherwise let's create a default one
|
||||
$query = $db->getQuery(true)
|
||||
->select('COUNT(*)')
|
||||
->from('#__osmap_sitemaps');
|
||||
$noSitemaps = ((int)$db->setQuery($query)->loadResult()) === 0;
|
||||
|
||||
if ($noSitemaps) {
|
||||
// Get all menus
|
||||
|
||||
// Search for home menu and language if exists
|
||||
$subQuery = $db->getQuery(true)
|
||||
->select('b.menutype, b.home, b.language, l.image, l.sef, l.title_native')
|
||||
->from('#__menu AS b')
|
||||
->leftJoin('#__languages AS l ON l.lang_code = b.language')
|
||||
->where('b.home != 0')
|
||||
->where('(b.client_id = 0 OR b.client_id IS NULL)');
|
||||
|
||||
// Get all menu types with optional home menu and language
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.id, a.asset_id, a.menutype, a.title, a.description, a.client_id')
|
||||
->select('c.home, c.language, c.image, c.sef, c.title_native')
|
||||
->from('#__menu_types AS a')
|
||||
->leftJoin('(' . $subQuery . ') c ON c.menutype = a.menutype')
|
||||
->order('a.id');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
$menus = $db->loadObjectList();
|
||||
|
||||
if (!empty($menus)) {
|
||||
$data = [
|
||||
'name' => 'Default Sitemap',
|
||||
'is_default' => 1,
|
||||
'published' => 1,
|
||||
];
|
||||
|
||||
// Create the sitemap
|
||||
Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_osmap/tables');
|
||||
$row = Table::getInstance('Sitemap', 'OSMapTable');
|
||||
$row->save($data);
|
||||
|
||||
$i = 0;
|
||||
foreach ($menus as $menu) {
|
||||
$menuTypeId = $this->getMenuTypeId($menu->menutype);
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->set('sitemap_id = ' . $db->quote($row->id))
|
||||
->set('menutype_id = ' . $db->quote($menuTypeId))
|
||||
->set('priority = ' . $db->quote('0.5'))
|
||||
->set('changefreq = ' . $db->quote('weekly'))
|
||||
->set('ordering = ' . $db->quote($i++))
|
||||
->insert('#__osmap_sitemap_menus');
|
||||
$db->setQuery($query)->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there are sitemaps in the old table. After migrate, remove
|
||||
* the table.
|
||||
*
|
||||
* On updates, verify current schema
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function checkDatabase(): void
|
||||
{
|
||||
$this->sendDebugMessage(__METHOD__);
|
||||
|
||||
if ($this->findTable('#__osmap_sitemap')) {
|
||||
$this->migrateLegacyDatabase();
|
||||
|
||||
} else {
|
||||
$this->checkDatabaseSchema();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function migrateLegacyDatabase(): void
|
||||
{
|
||||
$this->sendDebugMessage('Migrating legacy database');
|
||||
|
||||
try {
|
||||
$db = $this->dbo;
|
||||
|
||||
$db->transactionStart();
|
||||
|
||||
// For the migration, as we only have new tables, make sure to have a clean start
|
||||
$db->setQuery('DELETE FROM ' . $db->quoteName('#__osmap_items_settings'))->execute();
|
||||
$db->setQuery('DELETE FROM ' . $db->quoteName('#__osmap_sitemap_menus'))->execute();
|
||||
$db->setQuery('DELETE FROM ' . $db->quoteName('#__osmap_sitemaps'))->execute();
|
||||
|
||||
// Get legacy sitemaps
|
||||
$query = $db->getQuery(true)
|
||||
->select([
|
||||
'id',
|
||||
'title',
|
||||
'is_default',
|
||||
'state',
|
||||
'created',
|
||||
'selections',
|
||||
'excluded_items',
|
||||
])
|
||||
->from('#__osmap_sitemap');
|
||||
$sitemaps = $db->setQuery($query)->loadObjectList();
|
||||
|
||||
// Move the legacy sitemaps to the new table
|
||||
if ($sitemaps) {
|
||||
foreach ($sitemaps as $sitemap) {
|
||||
if ($sitemap->created === $db->getNullDate()) {
|
||||
$sitemap->created = Factory::getDate()->toSql();
|
||||
}
|
||||
|
||||
$insertObject = (object)[
|
||||
'id' => $sitemap->id,
|
||||
'name' => $sitemap->title,
|
||||
'is_default' => $sitemap->is_default,
|
||||
'published' => $sitemap->state,
|
||||
'created_on' => $sitemap->created,
|
||||
];
|
||||
$db->insertObject('#__osmap_sitemaps', $insertObject);
|
||||
|
||||
// Add the selected menus
|
||||
$menus = json_decode($sitemap->selections, true);
|
||||
if (is_array($menus)) {
|
||||
foreach ($menus as $menuType => $menu) {
|
||||
$menuTypeId = $this->getMenuTypeId($menuType);
|
||||
|
||||
if ($menuTypeId) {
|
||||
// Menu type still exists
|
||||
$insertObject = (object)[
|
||||
'sitemap_id' => $sitemap->id,
|
||||
'menutype_id' => $menuTypeId,
|
||||
'priority' => $menu['priority'],
|
||||
'changefreq' => $menu['changefreq'],
|
||||
'ordering' => $menu['ordering'],
|
||||
];
|
||||
$db->insertObject('#__osmap_sitemap_menus', $insertObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$excludedItems = json_decode($sitemap->excluded_items ?? '', true);
|
||||
if (is_array($excludedItems)) {
|
||||
// Convert settings for excluded items
|
||||
foreach ($excludedItems as $item) {
|
||||
$uid = $this->convertItemUID($item[0]);
|
||||
|
||||
// Check if the item was already registered
|
||||
$query = $db->getQuery(true)
|
||||
->select('COUNT(*)')
|
||||
->from('#__osmap_items_settings')
|
||||
->where([
|
||||
'sitemap_id = ' . $db->quote($sitemap->id),
|
||||
'uid = ' . $db->quote($uid),
|
||||
]);
|
||||
$count = $db->setQuery($query)->loadResult();
|
||||
|
||||
if ($count == 0) {
|
||||
$insertObject = (object)[
|
||||
'sitemap_id' => $sitemap->id,
|
||||
'uid' => $uid,
|
||||
'published' => 0,
|
||||
'changefreq' => 'weekly',
|
||||
'priority' => '0.5',
|
||||
];
|
||||
$db->insertObject('#__osmap_items_settings', $insertObject);
|
||||
|
||||
} else {
|
||||
// Update the setting
|
||||
$query = $db->getQuery(true)
|
||||
->update('#__osmap_items_settings')
|
||||
->set('published = 0')
|
||||
->where([
|
||||
'sitemap_id = ' . $db->quote($sitemap->id),
|
||||
'uid = ' . $db->quote($uid),
|
||||
]);
|
||||
$db->setQuery($query)->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Convert custom settings for items
|
||||
if ($this->findTable('#__osmap_items')) {
|
||||
$query = $db->getQuery(true)
|
||||
->select([
|
||||
'uid',
|
||||
'properties',
|
||||
])
|
||||
->from('#__osmap_items')
|
||||
->where('sitemap_id = ' . $db->quote($sitemap->id))
|
||||
->where('view = ' . $db->quote('xml'));
|
||||
$modifiedItems = $db->setQuery($query)->loadObjectList();
|
||||
|
||||
if ($modifiedItems) {
|
||||
foreach ($modifiedItems as $item) {
|
||||
$item->properties = str_replace(';', '&', $item->properties);
|
||||
parse_str($item->properties, $properties);
|
||||
|
||||
$item->uid = $this->convertItemUID($item->uid);
|
||||
|
||||
// Check if the item already exists to update, or insert
|
||||
$query = $db->getQuery(true)
|
||||
->select('COUNT(*)')
|
||||
->from('#__osmap_items_settings')
|
||||
->where([
|
||||
'sitemap_id = ' . $db->quote($sitemap->id),
|
||||
'uid = ' . $db->quote($item->uid),
|
||||
]);
|
||||
$exists = (bool)$db->setQuery($query)->loadResult();
|
||||
|
||||
if ($exists) {
|
||||
$fields = [];
|
||||
|
||||
// Check if the changefreq is set and set to update
|
||||
if (isset($properties['changefreq'])) {
|
||||
$fields = 'changefreq = ' . $db->quote($properties['changefreq']);
|
||||
}
|
||||
|
||||
// Check if the priority is set and set to update
|
||||
if (isset($properties['priority'])) {
|
||||
$fields = 'priority = ' . $db->quote($properties['priority']);
|
||||
}
|
||||
|
||||
// Update the item
|
||||
$query = $db->getQuery(true)
|
||||
->update('#__osmap_items_settings')
|
||||
->set($fields)
|
||||
->where([
|
||||
'sitemap_id = ' . $db->quote($sitemap->id),
|
||||
'uid = ' . $db->quote($item->uid),
|
||||
]);
|
||||
$db->setQuery($query)->execute();
|
||||
|
||||
} else {
|
||||
$insertObject = (object)[
|
||||
'sitemap_id' => $sitemap->id,
|
||||
'uid' => $item->uid,
|
||||
'published' => 1,
|
||||
'changefreq' => $properties['changefreq'] ?? 'weekly',
|
||||
'priority' => $properties['priority'] ?? '0.5',
|
||||
];
|
||||
|
||||
$db->insertObject('#__osmap_items_settings', $insertObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the old table
|
||||
$query = 'DROP TABLE IF EXISTS ' . $db->quoteName('#__osmap_items');
|
||||
$db->setQuery($query)->execute();
|
||||
|
||||
// Remove the old table
|
||||
$query = 'DROP TABLE IF EXISTS ' . $db->quoteName('#__osmap_sitemap');
|
||||
$db->setQuery($query)->execute();
|
||||
|
||||
$db->transactionCommit();
|
||||
|
||||
} catch (\Throwable $error) {
|
||||
$this->sendErrorMessage($error);
|
||||
$db->transactionRollback();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the id of the menutype.
|
||||
*
|
||||
* @param string $menuType
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getMenuTypeId(string $menuType): int
|
||||
{
|
||||
$db = $this->dbo;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('id')
|
||||
->from('#__menu_types')
|
||||
->where('menutype = ' . $db->quote($menuType));
|
||||
|
||||
return (int)$db->setQuery($query)->loadResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a legacy UID to the new pattern. Instead of "com_contenta25",
|
||||
* "joomla.article.25". Returns the new UID
|
||||
*
|
||||
* @param string $uid
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function convertItemUID(string $uid): string
|
||||
{
|
||||
// Joomla articles in categories
|
||||
if (preg_match('#com_contentc[0-9]+a([0-9]+)#', $uid, $matches)) {
|
||||
return 'joomla.article.' . $matches[1];
|
||||
}
|
||||
|
||||
// Joomla categories
|
||||
if (preg_match('#com_contentc([0-9]+)#', $uid, $matches)) {
|
||||
return 'joomla.category.' . $matches[1];
|
||||
}
|
||||
|
||||
// Joomla articles
|
||||
if (preg_match('#com_contenta([0-9]+)#', $uid, $matches)) {
|
||||
return 'joomla.article.' . $matches[1];
|
||||
}
|
||||
|
||||
// Joomla featured
|
||||
if (preg_match('#com_contentfeatureda([0-9]+)#', $uid, $matches)) {
|
||||
return 'joomla.featured.' . $matches[1];
|
||||
}
|
||||
|
||||
// Menu items
|
||||
if (preg_match('#itemid([0-9]*)#', $uid, $matches)) {
|
||||
return 'menuitem.' . $matches[1];
|
||||
}
|
||||
|
||||
return $uid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function checkDatabaseSchema(): void
|
||||
{
|
||||
if (version_compare($this->schemaVersion, '5', 'ge')) {
|
||||
$this->sendDebugMessage('No DB Schema updates');
|
||||
return;
|
||||
}
|
||||
|
||||
$db = $this->dbo;
|
||||
|
||||
$this->sendDebugMessage('Checking database schema updates: v' . $this->schemaVersion);
|
||||
|
||||
if ($this->findColumn('#__osmap_items_settings.format')) {
|
||||
$this->sendDebugMessage('UPDATE: items_settings.format');
|
||||
|
||||
$db->setQuery(join(' ', [
|
||||
'ALTER TABLE `#__osmap_items_settings`',
|
||||
"MODIFY `format` TINYINT(1) UNSIGNED NULL DEFAULT '2'",
|
||||
"COMMENT 'Format of the setting: 1) Legacy Mode - UID Only; 2) Based on menu ID and UID'",
|
||||
]))
|
||||
->execute();
|
||||
}
|
||||
|
||||
if ($this->findColumn('#__osmap_items_settings.url_hash')) {
|
||||
$this->sendDebugMessage('UPDATE: items_settings.url_hash');
|
||||
|
||||
$db->setQuery(
|
||||
sprintf(
|
||||
'ALTER TABLE %s CHANGE %s %s CHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT %s',
|
||||
$db->quoteName('#__osmap_items_settings'),
|
||||
$db->quoteName('url_hash'),
|
||||
$db->quoteName('settings_hash'),
|
||||
$db->quote('')
|
||||
)
|
||||
)
|
||||
->execute();
|
||||
}
|
||||
|
||||
$this->dropConstraints([
|
||||
'#__osmap_sitemap_menus.fk_sitemaps',
|
||||
'#__osmap_sitemap_menus.fk_sitemaps_menus',
|
||||
]);
|
||||
|
||||
$this->addIndexes([
|
||||
'#__osmap_sitemaps.idx_default' => ['is_default ASC', 'id ASC'],
|
||||
'#__osmap_items_settings.idx_sitemap_id' => ['sitemap_id ASC'],
|
||||
'#__osmap_sitemap_menus.idx_menutype_id' => ['menutype_id ASC'],
|
||||
'#__osmap_sitemap_menus.idx_sitemaps_id' => ['sitemap_id ASC'],
|
||||
]);
|
||||
|
||||
$this->dropIndexes([
|
||||
'#__osmap_sitemaps.default_idx',
|
||||
'#__osmap_sitemap_menus.idx_sitemap_menus',
|
||||
'#__osmap_sitemap_menus.fk_sitemaps_idx',
|
||||
'#__osmap_sitemap_menus.ordering_idx',
|
||||
'#__osmap_sitemap_menus.idx_ordering',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds new format=xml to existing xml menus
|
||||
*
|
||||
* @since v4.2.25
|
||||
*/
|
||||
protected function fixXMLMenus()
|
||||
{
|
||||
$db = $this->dbo;
|
||||
$siteApp = SiteApplication::getInstance('site');
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('id, link')
|
||||
->from('#__menu')
|
||||
->where([
|
||||
'client_id = ' . $siteApp->getClientId(),
|
||||
sprintf('link LIKE %s', $db->quote('%com_osmap%')),
|
||||
sprintf('link LIKE %s', $db->quote('%view=xml%')),
|
||||
sprintf('link NOT LIKE %s', $db->quote('%format=xml%')),
|
||||
]);
|
||||
|
||||
$menus = $db->setQuery($query)->loadObjectList();
|
||||
foreach ($menus as $menu) {
|
||||
$menu->link .= '&format=xml';
|
||||
$db->updateObject('#__menu', $menu, ['id']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear localized language files from core folders
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function clearLanguageFiles()
|
||||
{
|
||||
$files = array_merge(
|
||||
Folder::files(JPATH_ADMINISTRATOR . '/language', '_osmap', true, true),
|
||||
Folder::files(JPATH_SITE . '/language', '_osmap', true, true)
|
||||
);
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (is_file($file)) {
|
||||
File::delete($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,513 @@
|
||||
<?php
|
||||
/**
|
||||
* @package OSMap
|
||||
* @contact www.joomlashack.com, help@joomlashack.com
|
||||
* @copyright 2007-2014 XMap - Joomla! Vargas - Guillermo Vargas. All rights reserved.
|
||||
* @copyright 2016-2024 Joomlashack.com. All rights reserved.
|
||||
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
|
||||
*
|
||||
* This file is part of OSMap.
|
||||
*
|
||||
* OSMap is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OSMap is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OSMap. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Alledia\Installer\OSMap;
|
||||
|
||||
use Alledia\Framework\Joomla\Extension\Generic;
|
||||
use Joomla\CMS\Factory;
|
||||
|
||||
defined('_JEXEC') or die();
|
||||
|
||||
class XmapConverter
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $xmapPluginsParams = [];
|
||||
|
||||
/**
|
||||
* List of refactored Xmap plugins to migrate the settings
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $refactoredXmapPlugins = ['com_content' => 'joomla'];
|
||||
|
||||
/**
|
||||
* Look for the Xmap data to suggest a data migration
|
||||
*
|
||||
* @return bool True if Xmap data was found
|
||||
*/
|
||||
public function checkXmapDataExists(): bool
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
|
||||
// Do we have any Xmap sitemap?
|
||||
$query = $db->getQuery(true)
|
||||
->select('COUNT(*)')
|
||||
->from('#__xmap_sitemap');
|
||||
|
||||
$total = (int)$db->setQuery($query)->loadResult();
|
||||
|
||||
return $total > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the Xmap plugins params into the new plugins. Receives a list of
|
||||
* plugin names to look for params.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function saveXmapPluginParamsIfExists()
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select([
|
||||
'element',
|
||||
'params'
|
||||
])
|
||||
->from('#__extensions')
|
||||
->where([
|
||||
'type = "plugin"',
|
||||
'folder = "xmap"',
|
||||
'element IN ("' . implode('","', array_keys($this->refactoredXmapPlugins)) . '")'
|
||||
]);
|
||||
$legacyPlugins = $db->setQuery($query)->loadObjectList();
|
||||
|
||||
// Check if the respective OSMap plugin is already installed. If so, do not save its params to not override.
|
||||
if ($legacyPlugins) {
|
||||
foreach ($legacyPlugins as $plugin) {
|
||||
$query = $db->getQuery(true)
|
||||
->select('extension_id')
|
||||
->from('#__extensions')
|
||||
->where([
|
||||
'type = "plugin"',
|
||||
'folder = "osmap"',
|
||||
'element = "' . $plugin->element . '"'
|
||||
]);
|
||||
$osmapPluginID = $db->setQuery($query)->loadResult();
|
||||
|
||||
if (empty($osmapPluginID)) {
|
||||
$this->xmapPluginsParams[] = $plugin;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method move the Xmap plugins' params to the OSMap plugins.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function moveXmapPluginsParamsToOSMapPlugins()
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
|
||||
if (!empty($this->xmapPluginsParams)) {
|
||||
foreach ($this->xmapPluginsParams as $plugin) {
|
||||
// Look for the OSMap plugin
|
||||
$query = $db->getQuery(true)
|
||||
->select('extension_id')
|
||||
->from('#__extensions')
|
||||
->where([
|
||||
'type = "plugin"',
|
||||
'folder = "osmap"',
|
||||
'element = ' . $db->quote($this->refactoredXmapPlugins[$plugin->element] ?? '')
|
||||
]);
|
||||
$osmapPluginID = $db->setQuery($query)->loadResult();
|
||||
|
||||
if (!empty($osmapPluginID)) {
|
||||
$query = $db->getQuery(true)
|
||||
->update('#__extensions')
|
||||
->set('params = ' . $db->quote(addslashes($plugin->params)))
|
||||
->where('extension_id = ' . $osmapPluginID);
|
||||
$db->setQuery($query)->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrates data from Xmap to OSMap.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function migrateData()
|
||||
{
|
||||
$result = (object)[
|
||||
'success' => false
|
||||
];
|
||||
|
||||
$db = Factory::getDbo();
|
||||
$db->transactionStart();
|
||||
|
||||
try {
|
||||
// Do we have any Xmap sitemap?
|
||||
$sitemapFailedIds = [];
|
||||
$itemFailedIds = [];
|
||||
$query = $db->getQuery(true)
|
||||
->select('*')
|
||||
->from('#__xmap_sitemap');
|
||||
$sitemaps = $db->setQuery($query)->loadObjectList();
|
||||
|
||||
if ($sitemaps) {
|
||||
// Cleanup the db tables
|
||||
$tables = [
|
||||
'#__osmap_items_settings',
|
||||
'#__osmap_sitemap_menus',
|
||||
'#__osmap_sitemaps'
|
||||
];
|
||||
foreach ($tables as $table) {
|
||||
$db->setQuery(
|
||||
$db->getQuery(true)->delete($db->quoteName($table))
|
||||
)->execute();
|
||||
}
|
||||
|
||||
// Import the sitemaps
|
||||
foreach ($sitemaps as $sitemap) {
|
||||
$query = $db->getQuery(true)
|
||||
->set([
|
||||
$db->quoteName('id') . '=' . $db->quote($sitemap->id),
|
||||
$db->quoteName('name') . '=' . $db->quote($sitemap->title),
|
||||
$db->quoteName('is_default') . '=' . $db->quote($sitemap->is_default),
|
||||
$db->quoteName('published') . '=' . $db->quote($sitemap->state),
|
||||
$db->quoteName('created_on') . '=' . $db->quote($sitemap->created)
|
||||
])
|
||||
->insert('#__osmap_sitemaps');
|
||||
|
||||
if ($db->setQuery($query)->execute()) {
|
||||
// Add the selected menus to the correct table
|
||||
if ($menus = json_decode($sitemap->selections, true)) {
|
||||
foreach ($menus as $menuType => $menu) {
|
||||
if ($menuTypeId = $this->getMenuTypeId($menuType)) {
|
||||
// Convert the selection of menus into a row
|
||||
$query = $db->getQuery(true)
|
||||
->insert('#__osmap_sitemap_menus')
|
||||
->columns([
|
||||
'sitemap_id',
|
||||
'menutype_id',
|
||||
'priority',
|
||||
'changefreq',
|
||||
'ordering'
|
||||
])
|
||||
->values(
|
||||
implode(
|
||||
',',
|
||||
[
|
||||
$db->quote($sitemap->id),
|
||||
$db->quote($menuTypeId),
|
||||
$db->quote($menu['priority']),
|
||||
$db->quote($menu['changefreq']),
|
||||
$db->quote($menu['ordering'])
|
||||
]
|
||||
)
|
||||
);
|
||||
$db->setQuery($query)->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Convert settings about excluded items
|
||||
if ($sitemap->excluded_items ?? null) {
|
||||
if ($excludedItems = json_decode($sitemap->excluded_items, true)) {
|
||||
foreach ($excludedItems as $item) {
|
||||
$uid = $this->convertItemUID($item[0]);
|
||||
|
||||
// Check if the item was already registered
|
||||
$query = $db->getQuery(true)
|
||||
->select('COUNT(*)')
|
||||
->from('#__osmap_items_settings')
|
||||
->where([
|
||||
'sitemap_id = ' . $db->quote($sitemap->id),
|
||||
'uid = ' . $db->quote($uid)
|
||||
]);
|
||||
$count = $db->setQuery($query)->loadResult();
|
||||
|
||||
if ($count == 0) {
|
||||
// Insert the settings
|
||||
$query = $db->getQuery(true)
|
||||
->insert('#__osmap_items_settings')
|
||||
->columns([
|
||||
'sitemap_id',
|
||||
'uid',
|
||||
'published',
|
||||
'changefreq',
|
||||
'priority'
|
||||
])
|
||||
->values(
|
||||
implode(
|
||||
',',
|
||||
[
|
||||
$sitemap->id,
|
||||
$db->quote($uid),
|
||||
0,
|
||||
$db->quote('weekly'),
|
||||
$db->quote('0.5')
|
||||
]
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// Update the setting
|
||||
$query = $db->getQuery(true)
|
||||
->update('#__osmap_items_settings')
|
||||
->set('published = 0')
|
||||
->where([
|
||||
'sitemap_id = ' . $db->quote($sitemap->id),
|
||||
'uid = ' . $db->quote($uid)
|
||||
]);
|
||||
}
|
||||
$db->setQuery($query)->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Convert custom settings for items
|
||||
$query = $db->getQuery(true)
|
||||
->select([
|
||||
'uid',
|
||||
'properties'
|
||||
])
|
||||
->from('#__xmap_items')
|
||||
->where('sitemap_id = ' . $db->quote($sitemap->id))
|
||||
->where('view = ' . $db->quote('xml'));
|
||||
|
||||
if ($modifiedItems = $db->setQuery($query)->loadObjectList()) {
|
||||
foreach ($modifiedItems as $item) {
|
||||
$item->properties = str_replace(';', '&', $item->properties);
|
||||
parse_str($item->properties, $properties);
|
||||
|
||||
$item->uid = $this->convertItemUID($item->uid);
|
||||
|
||||
// Check if the item already exists to update, or insert
|
||||
$query = $db->getQuery(true)
|
||||
->select('COUNT(*)')
|
||||
->from('#__osmap_items_settings')
|
||||
->where([
|
||||
'sitemap_id = ' . $db->quote($sitemap->id),
|
||||
'uid = ' . $db->quote($item->uid)
|
||||
]);
|
||||
|
||||
$exists = (bool)$db->setQuery($query)->loadResult();
|
||||
if ($exists) {
|
||||
$fields = [];
|
||||
|
||||
// Check if the changefreq is set and set to update
|
||||
if (isset($properties['changefreq'])) {
|
||||
$fields = 'changefreq = ' . $db->quote($properties['changefreq']);
|
||||
}
|
||||
|
||||
// Check if the priority is set and set to update
|
||||
if (isset($properties['priority'])) {
|
||||
$fields = 'priority = ' . $db->quote($properties['priority']);
|
||||
}
|
||||
|
||||
// Update the item
|
||||
$query = $db->getQuery(true)
|
||||
->update('#__osmap_items_settings')
|
||||
->set($fields)
|
||||
->where([
|
||||
'sitemap_id = ' . $db->quote($sitemap->id),
|
||||
'uid = ' . $db->quote($item->uid)
|
||||
]);
|
||||
|
||||
} else {
|
||||
$columns = [
|
||||
'sitemap_id',
|
||||
'uid',
|
||||
'published'
|
||||
];
|
||||
|
||||
$values = [
|
||||
$db->quote($sitemap->id),
|
||||
$db->quote($item->uid),
|
||||
1
|
||||
];
|
||||
|
||||
// Check if the changefreq is set and set to update
|
||||
if (isset($properties['changefreq'])) {
|
||||
$columns[] = 'changefreq';
|
||||
$values[] = 'changefreq = ' . $db->quote($properties['changefreq']);
|
||||
}
|
||||
|
||||
// Check if the priority is set and set to update
|
||||
if (isset($properties['priority'])) {
|
||||
$columns[] = 'priority';
|
||||
$values[] = 'priority = ' . $db->quote($properties['priority']);
|
||||
}
|
||||
|
||||
// Insert a new item
|
||||
$query = $db->getQuery(true)
|
||||
->insert('#__osmap_items_settings')
|
||||
->columns($columns)
|
||||
->values(implode(',', $values));
|
||||
}
|
||||
$db->setQuery($query)->execute();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sitemapFailedIds = $sitemap->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($sitemapFailedIds || $itemFailedIds) {
|
||||
throw new \Exception('Failed the sitemap or item migration');
|
||||
}
|
||||
|
||||
/*
|
||||
* Menu Migration
|
||||
*/
|
||||
$xmap = new Generic('Xmap', 'component');
|
||||
$osmap = new Generic('OSMap', 'component');
|
||||
|
||||
// Remove OSMap menus
|
||||
$query = $db->getQuery(true)
|
||||
->delete('#__menu')
|
||||
->where('type = ' . $db->quote('component'))
|
||||
->where('component_id = ' . $db->quote($osmap->getId()));
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// Get the Xmap menus
|
||||
$query = $db->getQuery(true)
|
||||
->select('*')
|
||||
->from('#__menu')
|
||||
->where('type = ' . $db->quote('component'))
|
||||
->where('component_id = ' . $db->quote($xmap->getId()));
|
||||
$db->setQuery($query);
|
||||
$xmapMenus = $db->loadObjectList();
|
||||
|
||||
if (!empty($xmapMenus)) {
|
||||
// Convert each menu to OSMap
|
||||
foreach ($xmapMenus as $menu) {
|
||||
$query = $db->getQuery(true)
|
||||
->set('title = ' . $db->quote($this->replaceXmapByOSMap($menu->title)))
|
||||
->set('alias = ' . $db->quote($this->replaceXmapByOSMap($menu->alias)))
|
||||
->set('path = ' . $db->quote($this->replaceXmapByOSMap($menu->path)))
|
||||
->set('link = ' . $db->quote($this->replaceXmapByOSMap($menu->link)))
|
||||
->set('img = ' . $db->quote($this->replaceXmapByOSMap($menu->img)))
|
||||
->set('component_id = ' . $db->quote($osmap->getId()))
|
||||
->update('#__menu')
|
||||
->where('id = ' . $db->quote($menu->id));
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
}
|
||||
}
|
||||
|
||||
// Disable Xmap
|
||||
$query = $db->getQuery(true)
|
||||
->set('enabled = 0')
|
||||
->update('#__extensions')
|
||||
->where('extension_id = ' . $db->quote($xmap->getId()));
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// Clean up Xmap db tables
|
||||
$db->setQuery('DELETE FROM ' . $db->quoteName('#__xmap_sitemap'));
|
||||
$db->execute();
|
||||
|
||||
$db->setQuery('DELETE FROM ' . $db->quoteName('#__xmap_items'));
|
||||
$db->execute();
|
||||
|
||||
$db->transactionCommit();
|
||||
|
||||
$result->success = true;
|
||||
} catch (\Exception $e) {
|
||||
$db->transactionRollback();
|
||||
var_dump($e);
|
||||
}
|
||||
|
||||
echo json_encode($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the Xmap strings in multiple formats, changing to OSMap.
|
||||
*
|
||||
* @param string $str
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function replaceXmapByOSMap(string $str): string
|
||||
{
|
||||
$replacements = [
|
||||
'XMAP' => 'OSMAP',
|
||||
'XMap' => 'OSMap',
|
||||
'xMap' => 'OSMap',
|
||||
'xmap' => 'osmap',
|
||||
];
|
||||
|
||||
return str_replace(
|
||||
array_keys($replacements),
|
||||
$replacements,
|
||||
$str
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the id of the menutype.
|
||||
*
|
||||
* @param string $menuType
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getMenuTypeId(string $menuType): int
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('id')
|
||||
->from('#__menu_types')
|
||||
->where('menutype = ' . $db->quote($menuType));
|
||||
|
||||
return (int)$db->setQuery($query)->loadResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a legacy UID to the new pattern. Instead of "com_contenta25",
|
||||
* "joomla.article.25". Returns the new UID
|
||||
*
|
||||
* @param string $uid
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function convertItemUID(string $uid): string
|
||||
{
|
||||
// Joomla articles in categories
|
||||
if (preg_match('#com_contentc[0-9]+a([0-9]+)#', $uid, $matches)) {
|
||||
return 'joomla.article.' . $matches[1];
|
||||
}
|
||||
|
||||
// Joomla categories
|
||||
if (preg_match('#com_contentc([0-9]+)#', $uid, $matches)) {
|
||||
return 'joomla.category.' . $matches[1];
|
||||
}
|
||||
|
||||
// Joomla articles
|
||||
if (preg_match('#com_contenta([0-9]+)#', $uid, $matches)) {
|
||||
return 'joomla.article.' . $matches[1];
|
||||
}
|
||||
|
||||
// Joomla featured
|
||||
if (preg_match('#com_contentfeatureda([0-9]+)#', $uid, $matches)) {
|
||||
return 'joomla.featured.' . $matches[1];
|
||||
}
|
||||
|
||||
// Menu items
|
||||
if (preg_match('#itemid([0-9]*)#', $uid, $matches)) {
|
||||
return 'menuitem.' . $matches[1];
|
||||
}
|
||||
|
||||
return $uid;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* @package ShackInstaller
|
||||
* @contact www.joomlashack.com, help@joomlashack.com
|
||||
* @copyright 2016-2023 Joomlashack.com. All rights reserved
|
||||
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
|
||||
*
|
||||
* This file is part of ShackInstaller.
|
||||
*
|
||||
* ShackInstaller is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ShackInstaller is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ShackInstaller. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use Alledia\Installer\AutoLoader;
|
||||
use Joomla\CMS\Version;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
defined('_JEXEC') or die();
|
||||
|
||||
if (defined('SHACK_INSTALLER_BASE') == false) {
|
||||
define('SHACK_INSTALLER_BASE', __DIR__);
|
||||
|
||||
require_once SHACK_INSTALLER_BASE . '/AutoLoader.php';
|
||||
}
|
||||
|
||||
AutoLoader::register('Alledia\\Installer', __DIR__, true);
|
||||
|
||||
if (defined('SHACK_INSTALLER_VERSION') == false) {
|
||||
define('SHACK_INSTALLER_VERSION', '2.4.4');
|
||||
define('SHACK_INSTALLER_COMPATIBLE', '2.4.0');
|
||||
|
||||
if (isset($reportErrors) == false) {
|
||||
$reportErrors = E_ALL ^ E_DEPRECATED ^ E_USER_DEPRECATED;
|
||||
if (Version::MAJOR_VERSION == 4) {
|
||||
// There is a bad line of code in Joomla 4 that runs during extension install/update
|
||||
$reportErrors = $reportErrors ^ E_NOTICE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($reportErrors) {
|
||||
set_error_handler('\\Alledia\\Installer\\AbstractScript::errorHandler', $reportErrors);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user