| Server IP : 104.21.84.107 / Your IP : 104.23.243.197 Web Server : Apache/2.4.63 (Ubuntu) System : Linux adminpruebas-Virtual-Machine 6.14.0-37-generic #37-Ubuntu SMP PREEMPT_DYNAMIC Fri Nov 14 22:10:32 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 8.4.5 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/idiomas/libraries/gantry5/src/classes/Gantry/Joomla/ |
Upload File : |
<?php
/**
* @package Gantry5
* @author Tiger12 http://tiger12.com
* @originalCreator RocketTheme (Gantry Framework)
* @currentDeveloper Tiger12, LLC
* @copyright Copyright (C) 2007 - 2021 Tiger12, LLC
* @license GNU/GPLv2 and later
*
* http://www.gnu.org/licenses/gpl-2.0.html
*/
namespace Gantry\Joomla;
/**
* Joomla manifest file modifier.
*/
class Manifest
{
/** @var string */
protected $theme;
/** @var string */
protected $path;
/** @var \SimpleXMLElement */
protected $xml;
/**
* @param string $theme
* @param \SimpleXMLElement $manifest
* @throws \RuntimeException
*/
public function __construct($theme, \SimpleXMLElement $manifest = null)
{
$this->theme = $theme;
$this->path = JPATH_SITE . "/templates/{$theme}/templateDetails.xml";
if (!is_file($this->path)) {
throw new \RuntimeException(sprintf('Template %s does not exist.', $theme));
}
$this->xml = $manifest ?: simplexml_load_string(file_get_contents($this->path));
}
/**
* @param string $variable
* @return string
*/
public function get($variable)
{
return (string) $this->xml->{$variable};
}
/**
* @return \SimpleXMLElement
*/
public function getXml()
{
return $this->xml;
}
/**
* @return string
*/
public function getScriptFile()
{
return (string) $this->xml->scriptfile;
}
/**
* @param array $positions
*/
public function setPositions(array $positions)
{
sort($positions);
// Get the positions.
$target = current($this->xml->xpath('//positions'));
$xml = "<positions>\n <position>" . implode("</position>\n <position>", $positions) . "</position>\n </positions>";
$insert = new \SimpleXMLElement($xml);
// Replace all positions.
$targetDom = dom_import_simplexml($target);
$insertDom = $targetDom->ownerDocument->importNode(dom_import_simplexml($insert), true);
$targetDom->parentNode->replaceChild($insertDom, $targetDom);
}
public function save()
{
// Do not save manifest if template has been symbolically linked.
if (is_link(dirname($this->path))) {
return;
}
if (!$this->xml->asXML($this->path)) {
throw new \RuntimeException(sprintf('Saving manifest for %s template failed', $this->theme));
}
}
}