| Current Path : /home/wuectly/www/03cbe/ |
| Current File : /home/wuectly/www/03cbe/Configuration.tar |
Configuration.php 0000604 00000012201 15245562522 0010064 0 ustar 00 <?php
/**
* @package FOF
* @copyright Copyright (c)2010-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace FOF40\Configuration;
use FOF40\Container\Container;
defined('_JEXEC') || die;
/**
* Reads and parses the fof.xml file in the back-end of a FOF-powered component,
* provisioning the data to the rest of the FOF framework
*
* @since 2.1
*/
class Configuration
{
/**
* Cache of FOF components' configuration variables
*
* @var array
*/
public static $configurations = [];
/**
* The component's container
*
* @var Container
*/
protected $container;
private $domains = null;
function __construct(Container $c)
{
$this->container = $c;
$this->parseComponent();
}
/**
* Returns the value of a variable. Variables use a dot notation, e.g.
* view.config.whatever where the first part is the domain, the rest of the
* parts specify the path to the variable.
*
* @param string $variable The variable name
* @param mixed $default The default value, or null if not specified
*
* @return mixed The value of the variable
*/
public function get(string $variable, $default = null)
{
$domains = $this->getDomains();
[$domain, $var] = explode('.', $variable, 2);
if (!in_array(ucfirst($domain), $domains))
{
return $default;
}
$class = '\\FOF40\\Configuration\\Domain\\' . ucfirst($domain);
/** @var \FOF40\Configuration\Domain\DomainInterface $o */
$o = new $class;
return $o->get(self::$configurations[$this->container->componentName], $var, $default);
}
/**
* Gets a list of the available configuration domain adapters
*
* @return array A list of the available domains
*/
protected function getDomains(): array
{
if (is_null($this->domains))
{
$filesystem = $this->container->filesystem;
$files = $filesystem->folderFiles(__DIR__ . '/Domain', '.php');
if (!empty($files))
{
foreach ($files as $file)
{
$domain = basename($file, '.php');
if ($domain == 'DomainInterface')
{
continue;
}
$domain = preg_replace('/[^A-Za-z0-9]/', '', $domain);
$this->domains[] = $domain;
}
$this->domains = array_unique($this->domains);
}
}
return $this->domains;
}
/**
* Parses the configuration of the specified component
*
* @return void
*/
protected function parseComponent(): void
{
if ($this->container->platform->isCli())
{
$order = ['cli', 'backend'];
}
elseif ($this->container->platform->isBackend())
{
$order = ['backend'];
}
else
{
$order = ['frontend'];
}
$order[] = 'common';
$order = array_reverse($order);
self::$configurations[$this->container->componentName] = [];
foreach ([false, true] as $userConfig)
{
foreach ($order as $area)
{
$config = $this->parseComponentArea($area, $userConfig);
self::$configurations[$this->container->componentName] = array_replace_recursive(self::$configurations[$this->container->componentName], $config);
}
}
}
/**
* Parses the configuration options of a specific component area
*
* @param string $area Which area to parse (frontend, backend, cli)
* @param bool $userConfig When true the user configuration (fof.user.xml) file will be read
*
* @return array A hash array with the configuration data
*/
protected function parseComponentArea(string $area, bool $userConfig = false): array
{
$component = $this->container->componentName;
// Initialise the return array
$ret = [];
// Get the folders of the component
$componentPaths = $this->container->platform->getComponentBaseDirs($component);
$filesystem = $this->container->filesystem;
$path = $componentPaths['admin'];
if (isset($this->container['backEndPath']))
{
$path = $this->container['backEndPath'];
}
// This line unfortunately doesn't work with Unit Tests because JPath depends on the JPATH_SITE constant :(
// $path = $filesystem->pathCheck($path);
// Check that the path exists
if (!$filesystem->folderExists($path))
{
return $ret;
}
// Read the filename if it exists
$filename = $path . '/fof.xml';
if ($userConfig)
{
$filename = $path . '/fof.user.xml';
}
if (!$filesystem->fileExists($filename) && !file_exists($filename))
{
return $ret;
}
$data = file_get_contents($filename);
// Load the XML data in a SimpleXMLElement object
$xml = simplexml_load_string($data);
if (!($xml instanceof \SimpleXMLElement))
{
return $ret;
}
// Get this area's data
$areaData = $xml->xpath('//' . $area);
if (empty($areaData))
{
return $ret;
}
$xml = array_shift($areaData);
// Parse individual configuration domains
$domains = $this->getDomains();
foreach ($domains as $dom)
{
$class = '\\FOF40\\Configuration\\Domain\\' . ucfirst($dom);
if (class_exists($class, true))
{
/** @var \FOF40\Configuration\Domain\DomainInterface $o */
$o = new $class;
$o->parseDomain($xml, $ret);
}
}
// Finally, return the result
return $ret;
}
}
Domain/Models.php 0000604 00000023102 15245562522 0007711 0 ustar 00 <?php
/**
* @package FOF
* @copyright Copyright (c)2010-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace FOF40\Configuration\Domain;
use SimpleXMLElement;
defined('_JEXEC') || die;
/**
* Configuration parser for the models-specific settings
*
* @since 2.1
*/
class Models implements DomainInterface
{
/**
* Parse the XML data, adding them to the $ret array
*
* @param SimpleXMLElement $xml The XML data of the component's configuration area
* @param array &$ret The parsed data, in the form of a hash array
*
* @return void
*/
public function parseDomain(SimpleXMLElement $xml, array &$ret): void
{
// Initialise
$ret['models'] = [];
// Parse model configuration
$modelsData = $xml->xpath('model');
// Sanity check
if (empty($modelsData))
{
return;
}
foreach ($modelsData as $aModel)
{
$key = (string) $aModel['name'];
$ret['models'][$key]['behaviors'] = [];
$ret['models'][$key]['behaviorsMerge'] = false;
$ret['models'][$key]['tablealias'] = $aModel->xpath('tablealias');
$ret['models'][$key]['fields'] = [];
$ret['models'][$key]['relations'] = [];
$ret['models'][$key]['config'] = [];
// Parse configuration
$optionData = $aModel->xpath('config/option');
foreach ($optionData as $option)
{
$k = (string) $option['name'];
$ret['models'][$key]['config'][$k] = (string) $option;
}
// Parse field aliases
$fieldData = $aModel->xpath('field');
foreach ($fieldData as $field)
{
$k = (string) $field['name'];
$ret['models'][$key]['fields'][$k] = (string) $field;
}
// Parse behaviours
$behaviorsData = (string) $aModel->behaviors;
$behaviorsMerge = (string) $aModel->behaviors['merge'];
if (!empty($behaviorsMerge))
{
$behaviorsMerge = trim($behaviorsMerge);
$behaviorsMerge = strtoupper($behaviorsMerge);
if (in_array($behaviorsMerge, ['1', 'YES', 'ON', 'TRUE']))
{
$ret['models'][$key]['behaviorsMerge'] = true;
}
}
if (!empty($behaviorsData))
{
$behaviorsData = explode(',', $behaviorsData);
foreach ($behaviorsData as $behavior)
{
$behavior = trim($behavior);
if (empty($behavior))
{
continue;
}
$ret['models'][$key]['behaviors'][] = $behavior;
}
}
// Parse relations
$relationsData = $aModel->xpath('relation');
foreach ($relationsData as $relationData)
{
$type = (string) $relationData['type'];
$itemName = (string) $relationData['name'];
if (empty($type) || empty($itemName))
{
continue;
}
$modelClass = (string) $relationData['foreignModelClass'];
$localKey = (string) $relationData['localKey'];
$foreignKey = (string) $relationData['foreignKey'];
$pivotTable = (string) $relationData['pivotTable'];
$ourPivotKey = (string) $relationData['pivotLocalKey'];
$theirPivotKey = (string) $relationData['pivotForeignKey'];
$relation = [
'type' => $type,
'itemName' => $itemName,
'foreignModelClass' => empty($modelClass) ? null : $modelClass,
'localKey' => empty($localKey) ? null : $localKey,
'foreignKey' => empty($foreignKey) ? null : $foreignKey,
];
if (!empty($ourPivotKey) || !empty($theirPivotKey) || !empty($pivotTable))
{
$relation['pivotLocalKey'] = empty($ourPivotKey) ? null : $ourPivotKey;
$relation['pivotForeignKey'] = empty($theirPivotKey) ? null : $theirPivotKey;
$relation['pivotTable'] = empty($pivotTable) ? null : $pivotTable;
}
$ret['models'][$key]['relations'][] = $relation;
}
}
}
/**
* Return a configuration variable
*
* @param string &$configuration Configuration variables (hashed array)
* @param string $var The variable we want to fetch
* @param mixed $default Default value
*
* @return mixed The variable's value
*/
public function get(array &$configuration, string $var, $default = null)
{
$parts = explode('.', $var);
$view = $parts[0];
$method = 'get' . ucfirst($parts[1]);
if (!method_exists($this, $method))
{
return $default;
}
array_shift($parts);
array_shift($parts);
return $this->$method($view, $configuration, $parts, $default);
}
/**
* Internal method to return the magic field mapping
*
* @param string $model The model for which we will be fetching a field map
* @param array & $configuration The configuration parameters hash array
* @param array $params Extra options
* @param string|array|null $default Default magic field mapping; empty if not defined
*
* @return string|array|null Field map
*/
protected function getField(string $model, array &$configuration, array $params, $default = '')
{
$fieldmap = [];
if (isset($configuration['models']['*']) && isset($configuration['models']['*']['fields']))
{
$fieldmap = $configuration['models']['*']['fields'];
}
if (isset($configuration['models'][$model]) && isset($configuration['models'][$model]['fields']))
{
$fieldmap = array_merge($fieldmap, $configuration['models'][$model]['fields']);
}
$map = $default;
if (empty($params[0]) || ($params[0] == '*'))
{
$map = $fieldmap;
}
elseif (isset($fieldmap[$params[0]]))
{
$map = $fieldmap[$params[0]];
}
return $map;
}
/**
* Internal method to get model alias
*
* @param string $model The model for which we will be fetching table alias
* @param array $configuration [IN/OUT] The configuration parameters hash array
* @param array $params Ignored
* @param string|null $default Default table alias
*
* @return string|null Table alias
*/
protected function getTablealias(string $model, array &$configuration, array $params = [], ?string $default = null): ?string
{
$tableMap = [];
if (isset($configuration['models']['*']['tablealias']))
{
$tableMap = $configuration['models']['*']['tablealias'];
}
if (isset($configuration['models'][$model]['tablealias']))
{
$tableMap = array_merge($tableMap, $configuration['models'][$model]['tablealias']);
}
if (empty($tableMap))
{
return null;
}
return $tableMap[0];
}
/**
* Internal method to get model behaviours
*
* @param string $model The model for which we will be fetching behaviours
* @param array & $configuration The configuration parameters hash array
* @param array $params Unused
* @param array|null $default Default behaviour
*
* @return array|null Model behaviours
*/
protected function getBehaviors(string $model, array &$configuration, array $params = [], ?array $default = []): ?array
{
$behaviors = $default;
if (isset($configuration['models']['*'])
&& isset($configuration['models']['*']['behaviors'])
)
{
$behaviors = $configuration['models']['*']['behaviors'];
}
if (isset($configuration['models'][$model])
&& isset($configuration['models'][$model]['behaviors'])
)
{
$merge = false;
if (isset($configuration['models'][$model])
&& isset($configuration['models'][$model]['behaviorsMerge'])
)
{
$merge = (bool) $configuration['models'][$model]['behaviorsMerge'];
}
if ($merge)
{
$behaviors = array_merge($behaviors, $configuration['models'][$model]['behaviors']);
}
else
{
$behaviors = $configuration['models'][$model]['behaviors'];
}
}
return $behaviors;
}
/**
* Internal method to get model relations
*
* @param string $model The model for which we will be fetching relations
* @param array & $configuration The configuration parameters hash array
* @param array $params Unused
* @param array|null $default Default relations
*
* @return array|null Model relations
*/
protected function getRelations(string $model, array &$configuration, array $params = [], ?array $default = []): ?array
{
$relations = $default;
if (isset($configuration['models']['*'])
&& isset($configuration['models']['*']['relations'])
)
{
$relations = $configuration['models']['*']['relations'];
}
if (isset($configuration['models'][$model])
&& isset($configuration['models'][$model]['relations'])
)
{
$relations = $configuration['models'][$model]['relations'];
}
return $relations;
}
/**
* Internal method to return the a configuration option for the Model.
*
* @param string $model The view for which we will be fetching a task map
* @param array & $configuration The configuration parameters hash array
* @param array $params Extra options; key 0 defines the option variable we want to fetch
* @param string|array|null $default Default option; null if not defined
*
* @return string|array|null The setting for the requested option
*/
protected function getConfig(string $model, array &$configuration, array $params = [], $default = null)
{
$ret = $default;
$config = [];
if (isset($configuration['models']['*']['config']))
{
$config = $configuration['models']['*']['config'];
}
if (isset($configuration['models'][$model]['config']))
{
$config = array_merge($config, $configuration['models'][$model]['config']);
}
if (empty($params) || empty($params[0]))
{
return $config;
}
if (isset($config[$params[0]]))
{
$ret = $config[$params[0]];
}
return $ret;
}
}
Domain/Authentication.php 0000604 00000003322 15245562522 0011447 0 ustar 00 <?php
/**
* @package FOF
* @copyright Copyright (c)2010-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace FOF40\Configuration\Domain;
use SimpleXMLElement;
defined('_JEXEC') || die;
/**
* Configuration parser for the authentication-specific settings
*
* @since 2.1
*/
class Authentication implements DomainInterface
{
/**
* Parse the XML data, adding them to the $ret array
*
* @param SimpleXMLElement $xml The XML data of the component's configuration area
* @param array &$ret The parsed data, in the form of a hash array
*
* @return void
*/
public function parseDomain(SimpleXMLElement $xml, array &$ret): void
{
// Initialise
$ret['authentication'] = [];
// Parse the dispatcher configuration
$authenticationData = $xml->authentication;
// Sanity check
if (empty($authenticationData))
{
return;
}
$options = $xml->xpath('authentication/option');
foreach ($options as $option)
{
$key = (string) $option['name'];
$ret['authentication'][$key] = (string) $option;
}
}
/**
* Return a configuration variable
*
* @param string &$configuration Configuration variables (hashed array)
* @param string $var The variable we want to fetch
* @param mixed $default Default value
*
* @return mixed The variable's value
*/
public function get(array &$configuration, string $var, $default = null)
{
if ($var == '*')
{
return $configuration['authentication'];
}
if (isset($configuration['authentication'][$var]))
{
return $configuration['authentication'][$var];
}
else
{
return $default;
}
}
}
Domain/DomainInterface.php 0000604 00000002311 15245562522 0011515 0 ustar 00 <?php
/**
* @package FOF
* @copyright Copyright (c)2010-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace FOF40\Configuration\Domain;
use SimpleXMLElement;
defined('_JEXEC') || die;
/**
* The Interface of a FOF configuration domain class. The methods are used to parse and
* provision sensible information to consumers. The Configuration class acts as an
* adapter to the domain classes.
*
* @since 2.1
*/
interface DomainInterface
{
/**
* Parse the XML data, adding them to the $ret array
*
* @param SimpleXMLElement $xml The XML data of the component's configuration area
* @param array &$ret The parsed data, in the form of a hash array
*
* @return void
*/
public function parseDomain(SimpleXMLElement $xml, array &$ret): void;
/**
* Return a configuration variable
*
* @param array &$configuration Configuration variables (hashed array)
* @param string $var The variable we want to fetch
* @param mixed $default Default value
*
* @return mixed The variable's value
*/
public function get(array &$configuration, string $var, $default = null);
}
Domain/Container.php 0000604 00000003226 15245562522 0010415 0 ustar 00 <?php
/**
* @package FOF
* @copyright Copyright (c)2010-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace FOF40\Configuration\Domain;
use SimpleXMLElement;
defined('_JEXEC') || die;
/**
* Configuration parser for the Container-specific settings
*
* @since 2.1
*/
class Container implements DomainInterface
{
/**
* Parse the XML data, adding them to the $ret array
*
* @param SimpleXMLElement $xml The XML data of the component's configuration area
* @param array &$ret The parsed data, in the form of a hash array
*
* @return void
*/
public function parseDomain(SimpleXMLElement $xml, array &$ret): void
{
// Initialise
$ret['container'] = [];
// Parse the dispatcher configuration
$containerData = $xml->container;
// Sanity check
if (empty($containerData))
{
return;
}
$options = $xml->xpath('container/option');
foreach ($options as $option)
{
$key = (string) $option['name'];
$ret['container'][$key] = (string) $option;
}
}
/**
* Return a configuration variable
*
* @param string &$configuration Configuration variables (hashed array)
* @param string $var The variable we want to fetch
* @param mixed $default Default value
*
* @return mixed The variable's value
*/
public function get(array &$configuration, string $var, $default = null)
{
if ($var == '*')
{
return $configuration['container'];
}
if (isset($configuration['container'][$var]))
{
return $configuration['container'][$var];
}
else
{
return $default;
}
}
}
Domain/Dispatcher.php 0000604 00000003242 15245562522 0010557 0 ustar 00 <?php
/**
* @package FOF
* @copyright Copyright (c)2010-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace FOF40\Configuration\Domain;
use SimpleXMLElement;
defined('_JEXEC') || die;
/**
* Configuration parser for the dispatcher-specific settings
*
* @since 2.1
*/
class Dispatcher implements DomainInterface
{
/**
* Parse the XML data, adding them to the $ret array
*
* @param SimpleXMLElement $xml The XML data of the component's configuration area
* @param array &$ret The parsed data, in the form of a hash array
*
* @return void
*/
public function parseDomain(SimpleXMLElement $xml, array &$ret): void
{
// Initialise
$ret['dispatcher'] = [];
// Parse the dispatcher configuration
$dispatcherData = $xml->dispatcher;
// Sanity check
if (empty($dispatcherData))
{
return;
}
$options = $xml->xpath('dispatcher/option');
foreach ($options as $option)
{
$key = (string) $option['name'];
$ret['dispatcher'][$key] = (string) $option;
}
}
/**
* Return a configuration variable
*
* @param string &$configuration Configuration variables (hashed array)
* @param string $var The variable we want to fetch
* @param mixed $default Default value
*
* @return mixed The variable's value
*/
public function get(array &$configuration, string $var, $default = null)
{
if ($var == '*')
{
return $configuration['dispatcher'];
}
if (isset($configuration['dispatcher'][$var]))
{
return $configuration['dispatcher'][$var];
}
else
{
return $default;
}
}
}
Domain/Views.php 0000604 00000020406 15245562522 0007567 0 ustar 00 <?php
/**
* @package FOF
* @copyright Copyright (c)2010-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace FOF40\Configuration\Domain;
use SimpleXMLElement;
defined('_JEXEC') || die;
/**
* Configuration parser for the view-specific settings
*
* @since 2.1
*/
class Views implements DomainInterface
{
/**
* Parse the XML data, adding them to the $ret array
*
* @param SimpleXMLElement $xml The XML data of the component's configuration area
* @param array &$ret The parsed data, in the form of a hash array
*
* @return void
*/
public function parseDomain(SimpleXMLElement $xml, array &$ret): void
{
// Initialise
$ret['views'] = [];
// Parse view configuration
$viewData = $xml->xpath('view');
// Sanity check
if (empty($viewData))
{
return;
}
foreach ($viewData as $aView)
{
$key = (string) $aView['name'];
// Parse ACL options
$ret['views'][$key]['acl'] = [];
$aclData = $aView->xpath('acl/task');
foreach ($aclData as $acl)
{
$k = (string) $acl['name'];
$ret['views'][$key]['acl'][$k] = (string) $acl;
}
// Parse taskmap
$ret['views'][$key]['taskmap'] = [];
$taskmapData = $aView->xpath('taskmap/task');
foreach ($taskmapData as $map)
{
$k = (string) $map['name'];
$ret['views'][$key]['taskmap'][$k] = (string) $map;
}
// Parse controller configuration
$ret['views'][$key]['config'] = [];
$optionData = $aView->xpath('config/option');
foreach ($optionData as $option)
{
$k = (string) $option['name'];
$ret['views'][$key]['config'][$k] = (string) $option;
}
// Parse the toolbar
$ret['views'][$key]['toolbar'] = [];
$toolBars = $aView->xpath('toolbar');
foreach ($toolBars as $toolBar)
{
$taskName = isset($toolBar['task']) ? (string) $toolBar['task'] : '*';
// If a toolbar title is specified, create a title element.
if (isset($toolBar['title']))
{
$ret['views'][$key]['toolbar'][$taskName]['title'] = [
'value' => (string) $toolBar['title'],
];
}
// Parse the toolbar buttons data
$toolbarData = $toolBar->xpath('button');
foreach ($toolbarData as $button)
{
$k = (string) $button['type'];
$ret['views'][$key]['toolbar'][$taskName][$k] = current($button->attributes());
$ret['views'][$key]['toolbar'][$taskName][$k]['value'] = (string) $button;
}
}
}
}
/**
* Return a configuration variable
*
* @param string &$configuration Configuration variables (hashed array)
* @param string $var The variable we want to fetch
* @param mixed $default Default value
*
* @return mixed The variable's value
*/
public function get(array &$configuration, string $var, $default = null)
{
$parts = explode('.', $var);
$view = $parts[0];
$method = 'get' . ucfirst($parts[1]);
if (!method_exists($this, $method))
{
return $default;
}
array_shift($parts);
array_shift($parts);
return $this->$method($view, $configuration, $parts, $default);
}
/**
* Internal function to return the task map for a view
*
* @param string $view The view for which we will be fetching a task map
* @param array &$configuration The configuration parameters hash array
* @param array $params Extra options (not used)
* @param array $default ßDefault task map; empty array if not provided
*
* @return array The task map as a hash array in the format task => method
*/
protected function getTaskmap(string $view, array &$configuration, array $params = [], ?array $default = []): ?array
{
$taskmap = [];
if (isset($configuration['views']['*']) && isset($configuration['views']['*']['taskmap']))
{
$taskmap = $configuration['views']['*']['taskmap'];
}
if (isset($configuration['views'][$view]) && isset($configuration['views'][$view]['taskmap']))
{
$taskmap = array_merge($taskmap, $configuration['views'][$view]['taskmap']);
}
if (empty($taskmap))
{
return $default;
}
return $taskmap;
}
/**
* Internal method to return the ACL mapping (privilege required to access
* a specific task) for the given view's tasks
*
* @param string $view The view for which we will be fetching a task map
* @param array &$configuration The configuration parameters hash array
* @param array $params Extra options; key 0 defines the task we want to fetch
* @param string $default Default ACL option; empty (no ACL check) if not defined
*
* @return string|array The privilege required to access this view
*/
protected function getAcl(string $view, array &$configuration, array $params = [], ?string $default = '')
{
$aclmap = [];
if (isset($configuration['views']['*']) && isset($configuration['views']['*']['acl']))
{
$aclmap = $configuration['views']['*']['acl'];
}
if (isset($configuration['views'][$view]) && isset($configuration['views'][$view]['acl']))
{
$aclmap = array_merge($aclmap, $configuration['views'][$view]['acl']);
}
$acl = $default;
if (empty($params) || empty($params[0]))
{
return $aclmap;
}
if (isset($aclmap['*']))
{
$acl = $aclmap['*'];
}
if (isset($aclmap[$params[0]]))
{
$acl = $aclmap[$params[0]];
}
return $acl;
}
/**
* Internal method to return the a configuration option for the view. These
* are equivalent to $config array options passed to the Controller
*
* @param string $view The view for which we will be fetching a task map
* @param array & $configuration The configuration parameters hash array
* @param array $params Extra options; key 0 defines the option variable we want to fetch
* @param string|array|null $default Default option; null if not defined
*
* @return string|array|null The setting for the requested option
*/
protected function getConfig(string $view, array &$configuration, array $params = [], $default = null)
{
$ret = $default;
$config = [];
if (isset($configuration['views']['*']['config']))
{
$config = $configuration['views']['*']['config'];
}
if (isset($configuration['views'][$view]['config']))
{
$config = array_merge($config, $configuration['views'][$view]['config']);
}
if (empty($params) || empty($params[0]))
{
return $config;
}
if (isset($config[$params[0]]))
{
$ret = $config[$params[0]];
}
return $ret;
}
/**
* Internal method to return the toolbar infos.
*
* @param string $view The view for which we will be fetching buttons
* @param array & $configuration The configuration parameters hash array
* @param array $params Extra options
* @param array|null $default Default option
*
* @return array|null The toolbar data for this view
*/
protected function getToolbar(string $view, array &$configuration, array $params = [], ?array $default = []): ?array
{
$toolbar = [];
if (isset($configuration['views']['*'])
&& isset($configuration['views']['*']['toolbar'])
&& isset($configuration['views']['*']['toolbar']['*']))
{
$toolbar = $configuration['views']['*']['toolbar']['*'];
}
if (isset($configuration['views']['*'])
&& isset($configuration['views']['*']['toolbar'])
&& isset($configuration['views']['*']['toolbar'][$params[0]]))
{
$toolbar = array_merge($toolbar, $configuration['views']['*']['toolbar'][$params[0]]);
}
if (isset($configuration['views'][$view])
&& isset($configuration['views'][$view]['toolbar'])
&& isset($configuration['views'][$view]['toolbar']['*']))
{
$toolbar = array_merge($toolbar, $configuration['views'][$view]['toolbar']['*']);
}
if (isset($configuration['views'][$view])
&& isset($configuration['views'][$view]['toolbar'])
&& isset($configuration['views'][$view]['toolbar'][$params[0]]))
{
$toolbar = array_merge($toolbar, $configuration['views'][$view]['toolbar'][$params[0]]);
}
if (empty($toolbar))
{
return $default;
}
return $toolbar;
}
}
default.xml 0000604 00000000575 15245613420 0006717 0 ustar 00 <?xml version="1.0" encoding="utf-8"?>
<!--~
~ @package akeebabackup
~ @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
~ @license GNU General Public License version 3, or later
-->
<metadata>
<layout title="COM_AKEEBA_VIEW_CONFIGURATION_TITLE">
<message>
<![CDATA[COM_AKEEBA_VIEW_CONFIGURATION_DESC]]>
</message>
</layout>
</metadata>
confwiz_modal.blade.php 0000604 00000004136 15245613420 0011160 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
// Protect from unauthorized access
defined('_JEXEC') || die();
/** @var \FOF40\View\DataView\Html $this */
// Make sure we only ever add this HTML and JS once per page
if (defined('AKEEBA_VIEW_JAVASCRIPT_CONFWIZ_MODAL'))
{
return;
}
define('AKEEBA_VIEW_JAVASCRIPT_CONFWIZ_MODAL', 1);
$js = <<< JS
akeeba.Loader.add('akeeba.System', function(){
akeeba.System.documentReady(function(){
akeeba.System.addEventListener('comAkeebaConfigurationWizardModalClose', 'click', function() {
akeeba.System.configurationWizardModal.close();
});
setTimeout(function() {
akeeba.System.configurationWizardModal = akeeba.Modal.open({
inherit: '#akeeba-config-confwiz-bubble',
width: '80%'
});
}, 500);
});
});
JS;
$this->container->template->addJSInline($js);
?>
<div id="akeeba-config-confwiz-bubble" class="modal fade" role="dialog"
aria-labelledby="DialogLabel" aria-hidden="true" style="display: none;">
<div class="akeeba-renderer-fef">
<h4>
@lang('COM_AKEEBA_CONFIG_HEADER_CONFWIZ')
</h4>
<div>
<p>
@lang('COM_AKEEBA_CONFIG_LBL_CONFWIZ_INTRO')
</p>
<p>
<a href="index.php?option=com_akeeba&view=ConfigurationWizard"
class="akeeba-btn--green akeeba-btn--big">
<span class="akion-flash"></span>
@lang('COM_AKEEBA_CONFWIZ')
</a>
</p>
<p>
@lang('COM_AKEEBA_CONFIG_LBL_CONFWIZ_AFTER')
</p>
</div>
<div>
<a href="#" class="akeeba-btn--ghost akeeba-btn--small" id="comAkeebaConfigurationWizardModalClose"
onclick="akeeba.System.configurationWizardModal.close();">
<span class="akion-close"></span>
@lang('JCANCEL')
</a>
</div>
</div>
</div>
default.blade.php 0000604 00000006133 15245613420 0007750 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
// Protect from unauthorized access
defined('_JEXEC') || die();
/** @var \Akeeba\Backup\Admin\View\Configuration\Html $this */
\AkeebaFEFHelper::loadFEFScript('Tooltip');
\Joomla\CMS\HTML\HTMLHelper::_('jquery.framework');
\Joomla\CMS\HTML\HTMLHelper::_('script', 'jui/cms.js', array('version' => 'auto', 'relative' => true));
?>
{{-- Configuration Wizard pop-up --}}
@if($this->promptForConfigurationWizard)
@include('admin:com_akeeba/Configuration/confwiz_modal')
@endif
{{-- Modal dialog prototypes --}}
@include('admin:com_akeeba/CommonTemplates/FTPBrowser')
@include('admin:com_akeeba/CommonTemplates/SFTPBrowser')
@include('admin:com_akeeba/CommonTemplates/FTPConnectionTest')
@include('admin:com_akeeba/CommonTemplates/ErrorModal')
@include('admin:com_akeeba/CommonTemplates/FolderBrowser')
@if($this->secureSettings == 1)
<div class="akeeba-block--success">
@lang('COM_AKEEBA_CONFIG_UI_SETTINGS_SECURED')
</div>
@elseif($this->secureSettings == 0)
<div class="akeeba-block--failure">
@lang('COM_AKEEBA_CONFIG_UI_SETTINGS_NOTSECURED')
</div>
@endif
@include('admin:com_akeeba/CommonTemplates/ProfileName')
<div class="akeeba-block--info">
@lang('COM_AKEEBA_CONFIG_WHERE_ARE_THE_FILTERS')
</div>
<form name="adminForm" id="adminForm" method="post" action="index.php?option=com_akeeba&view=configuration"
class="akeeba-form--horizontal akeeba-form--with-hidden akeeba-form--configuration">
<div class="akeeba-panel--info" style="margin-bottom: -1em">
<header class="akeeba-block-header">
<h5>
@lang('COM_AKEEBA_PROFILES_LABEL_DESCRIPTION')
</h5>
</header>
<div class="akeeba-form-group">
<label for="profilename" rel="popover"
data-original-title="@lang('COM_AKEEBA_PROFILES_LABEL_DESCRIPTION')"
data-content="@lang('COM_AKEEBA_PROFILES_LABEL_DESCRIPTION_TOOLTIP')">
@lang('COM_AKEEBA_PROFILES_LABEL_DESCRIPTION')
</label>
<input type="text" name="profilename" id="profilename"
value="{{{ $this->profileName }}}"/>
</div>
<div class="akeeba-form-group">
<label class="control-label" for="quickicon" rel="popover"
data-original-title="@lang('COM_AKEEBA_CONFIG_QUICKICON_LABEL')"
data-content="@lang('COM_AKEEBA_CONFIG_QUICKICON_DESC')">
@lang('COM_AKEEBA_CONFIG_QUICKICON_LABEL')
</label>
<div>
<input type="checkbox" name="quickicon"
id="quickicon" {{ $this->quickIcon ? 'checked="checked"' : '' }}/>
</div>
</div>
</div>
<!-- This div contains dynamically generated user interface elements -->
<div id="akeebagui">
</div>
<div class="akeeba-hidden-fields-container">
<input type="hidden" name="task" value=""/>
<input type="hidden" name="@token(true)" value="1"/>
</div>
</form>
Html.php 0000604 00000007237 15245662526 0006203 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Admin\View\Configuration;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Akeeba\Backup\Admin\View\ViewTraits\ProfileIdAndName;
use Akeeba\Engine\Factory;
use Akeeba\Engine\Platform;
use FOF40\View\DataView\Html as BaseView;
use Joomla\CMS\Language\Text as JText;
class Html extends BaseView
{
use ProfileIdAndName;
/**
* Status of the settings encryption: -1 disabled by user, 0 not available, 1 enabled and active
*
* @var int
*/
public $secureSettings = 0;
/**
* Should I show the Configuration Wizard popup prompt?
*
* @var bool
*/
public $promptForConfigurationWizard = false;
/**
* Executes when displaying the page
*/
public function onBeforeMain()
{
$this->container->template->addJS('media://com_akeeba/js/Configuration.min.js', true, false, $this->container->mediaVersion);
$this->getProfileIdAndName();
// Are the settings secured?
$this->secureSettings = $this->getSecureSettingsOption();
// Should I show the Configuration Wizard popup prompt?
$this->promptForConfigurationWizard = Factory::getConfiguration()->get('akeeba.flag.confwiz', 0) != 1;
// Push script options
$urls = array(
'browser' => addslashes('index.php?option=com_akeeba&view=Browser&processfolder=1&tmpl=component&folder='),
'ftpBrowser' => addslashes('index.php?option=com_akeeba&view=FTPBrowser'),
'sftpBrowser' => addslashes('index.php?option=com_akeeba&view=SFTPBrowser'),
'testFtp' => addslashes('index.php?option=com_akeeba&view=Configuration&task=testftp'),
'testSftp' => addslashes('index.php?option=com_akeeba&view=Configuration&task=testsftp'),
'dpeauthopen' => addslashes('index.php?option=com_akeeba&view=Configuration&task=dpeoauthopen&format=raw'),
'dpecustomapi' => addslashes('index.php?option=com_akeeba&view=Configuration&task=dpecustomapi&format=raw'),
);
// Push script options
$platform = $this->container->platform;
$platform->addScriptOptions('akeeba.Configuration.URLs', $urls);
$platform->addScriptOptions('akeeba.Configuration.GUIData', json_decode(Factory::getEngineParamsProvider()->getJsonGuiDefinition(), true));
// Push translations
JText::script('COM_AKEEBA_CONFIG_UI_BROWSE');
JText::script('COM_AKEEBA_CONFIG_UI_CONFIG');
JText::script('COM_AKEEBA_CONFIG_UI_REFRESH');
JText::script('COM_AKEEBA_FILEFILTERS_LABEL_UIROOT');
JText::script('COM_AKEEBA_CONFIG_UI_FTPBROWSER_TITLE');
JText::script('COM_AKEEBA_CONFIG_DIRECTFTP_TEST_OK');
JText::script('COM_AKEEBA_CONFIG_DIRECTFTP_TEST_FAIL');
JText::script('COM_AKEEBA_CONFIG_DIRECTSFTP_TEST_OK');
JText::script('COM_AKEEBA_CONFIG_DIRECTSFTP_TEST_FAIL');
}
/**
* Returns the support status of settings encryption. The possible values are:
* -1 Disabled by the user
* 0 Enabled by inactive (not supported by the server)
* 1 Enabled and active
*
* @return int
*/
private function getSecureSettingsOption()
{
// Encryption is disabled by the user
if (Platform::getInstance()->get_platform_configuration_option('useencryption', -1) == 0)
{
return -1;
}
// Encryption is not supported by this server
if (!Factory::getSecureSettings()->supportsEncryption())
{
return 0;
}
$filename = JPATH_COMPONENT_ADMINISTRATOR . '/BackupEngine/serverkey.php';
// Encryption enabled, supported and a key file is present: encryption enabled
if (is_file($filename))
{
return 1;
}
// Encryption enabled, supported but and a key file is NOT present: encryption not available
return 0;
}
}