{% extends "partials/page.html.twig" %}
{% block content %}
{{ gantry.platform.displayContent(content)|raw }}
{% endblock %}
/**
* @param string $content
* @param array $params
* @return string
*/
public function displayContent($content, $params = [])
{
/** @var CMSApplication $application */
$application = Factory::getApplication();
$document = $application->getDocument();
if (!$document instanceof HtmlDocument) {
return $content;
}
$renderer = $document->loadRenderer('component');
$html = trim($renderer->render(null, $params, $content ?: $document->getBuffer('component')));
$isGantry = \strpos($application->input->getCmd('option'), 'gantry5') !== false;
if ($html && !$isGantry) {
/** @var Theme $theme */
$theme = $this->container['theme'];
$theme->joomla(true);
return sprintf($this->component_wrapper, $html);
}
return $html;
}
/**
* @param string $id
* @return mixed|null
*/
public function getModule($id)
{
$modules = $this->getModuleList();
return $id && isset($modules[$id]) ? $modules[$id] : null;
}
/**
* @param string $content
* @param array $params
* @return string
*/
public function displayContent($content, $params = [])
{
/** @var CMSApplication $application */
$application = Factory::getApplication();
$document = $application->getDocument();
if (!$document instanceof HtmlDocument) {
return $content;
}
$renderer = $document->loadRenderer('component');
$html = trim($renderer->render(null, $params, $content ?: $document->getBuffer('component')));
$isGantry = \strpos($application->input->getCmd('option'), 'gantry5') !== false;
if ($html && !$isGantry) {
/** @var Theme $theme */
$theme = $this->container['theme'];
$theme->joomla(true);
return sprintf($this->component_wrapper, $html);
}
return $html;
}
/**
* @param string $id
* @return mixed|null
*/
public function getModule($id)
{
$modules = $this->getModuleList();
return $id && isset($modules[$id]) ? $modules[$id] : null;
}
}
throw new RuntimeError(sprintf('Neither the property "%1$s" nor one of the methods "%1$s()", "get%1$s()"/"is%1$s()" or "__call()" exist and have public access in class "%2$s".', $item, $class), -1, $this->getSourceContext());
}
if ($isDefinedTest) {
return true;
}
if ($this->env->hasExtension('\Twig\Extension\SandboxExtension')) {
$this->env->getExtension('\Twig\Extension\SandboxExtension')->checkMethodAllowed($object, $method);
}
// Some objects throw exceptions when they have __call, and the method we try
// to call is not supported. If ignoreStrictCheck is true, we should return null.
try {
if (!$arguments) {
$ret = $object->$method();
} else {
$ret = \call_user_func_array([$object, $method], $arguments);
}
} catch (\BadMethodCallException $e) {
if ($call && ($ignoreStrictCheck || !$this->env->isStrictVariables())) {
return;
}
throw $e;
}
// @deprecated in 1.28
if ($object instanceof \Twig_TemplateInterface) {
$self = $object->getTemplateName() === $this->getTemplateName();
$message = sprintf('Calling "%s" on template "%s" from template "%s" is deprecated since version 1.28 and won\'t be supported anymore in 2.0.', $item, $object->getTemplateName(), $this->getTemplateName());
if ('renderBlock' === $method || 'displayBlock' === $method) {
$message .= sprintf(' Use block("%s"%s) instead).', $arguments[0], $self ? '' : ', template');
} elseif ('hasBlock' === $method) {
$message .= sprintf(' Use "block("%s"%s) is defined" instead).', $arguments[0], $self ? '' : ', template');
} elseif ('render' === $method || 'display' === $method) {
$message .= sprintf(' Use include("%s") instead).', $object->getTemplateName());
}
@trigger_error($message, \E_USER_DEPRECATED);
}
protected function doGetParent(array $context)
{
// line 1
return "partials/page.html.twig";
}
protected function doDisplay(array $context, array $blocks = [])
{
$this->parent = $this->loadTemplate("partials/page.html.twig", "index.html.twig", 1);
$this->parent->display($context, array_merge($this->blocks, $blocks));
}
// line 3
public function block_content($context, array $blocks = [])
{
// line 4
echo " ";
echo $this->getAttribute($this->getAttribute(($context["gantry"] ?? null), "platform", []), "displayContent", [0 => ($context["content"] ?? null)], "method");
echo "
";
}
public function getTemplateName()
{
return "index.html.twig";
}
public function isTraitable()
{
return false;
}
public function getDebugInfo()
{
return array ( 42 => 4, 39 => 3, 29 => 1,);
}
/** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */
if ($useBlocks && isset($blocks[$name])) {
$template = $blocks[$name][0];
$block = $blocks[$name][1];
} elseif (isset($this->blocks[$name])) {
$template = $this->blocks[$name][0];
$block = $this->blocks[$name][1];
} else {
$template = null;
$block = null;
}
// avoid RCEs when sandbox is enabled
if (null !== $template && !$template instanceof self) {
throw new \LogicException('A block must be a method on a \Twig\Template instance.');
}
if (null !== $template) {
try {
$template->$block($context, $blocks);
} catch (Error $e) {
if (!$e->getSourceContext()) {
$e->setSourceContext($template->getSourceContext());
}
// this is mostly useful for \Twig\Error\LoaderError exceptions
// see \Twig\Error\LoaderError
if (-1 === $e->getTemplateLine()) {
$e->guess();
}
throw $e;
} catch (\Exception $e) {
$e = new RuntimeError(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $template->getSourceContext(), $e);
$e->guess();
throw $e;
}
} elseif (false !== $parent = $this->getParent($context)) {
$parent->displayBlock($name, $context, array_merge($this->blocks, $blocks), false);
}
protected function doDisplay(array $context, array $blocks = [])
{
// line 1
$this->getAttribute($this->getAttribute(($context["gantry"] ?? null), "debugger", []), "startTimer", [0 => "render", 1 => "Rendering page"], "method");
// line 2
$this->getAttribute($this->getAttribute(($context["gantry"] ?? null), "theme", []), "setLayout", [], "method");
// line 3
$this->getAttribute($this->getAttribute(($context["gantry"] ?? null), "theme", []), "loadAtoms", [], "method");
// line 4
$context["segments"] = $this->getAttribute($this->getAttribute(($context["gantry"] ?? null), "theme", []), "segments", [], "method");
// line 6
ob_start(function () { return ''; });
// line 7
echo " ";
if ($this->getAttribute($this->getAttribute(($context["gantry"] ?? null), "theme", []), "hasContent", [], "method")) {
// line 8
echo " ";
$this->displayBlock('content', $context, $blocks);
// line 10
echo " ";
}
$context["content"] = ('' === $tmp = ob_get_clean()) ? '' : new Markup($tmp, $this->env->getCharset());
// line 13
$context["offcanvas"] = null;
// line 14
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable(($context["segments"] ?? null));
foreach ($context['_seq'] as $context["_key"] => $context["segment"]) {
// line 15
echo " ";
if (($this->getAttribute($context["segment"], "type", []) == "offcanvas")) {
// line 16
$context["offcanvas"] = $context["segment"];
}
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['segment'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
}
return ob_get_clean();
}
protected function displayWithErrorHandling(array $context, array $blocks = [])
{
try {
$this->doDisplay($context, $blocks);
} catch (Error $e) {
if (!$e->getSourceContext()) {
$e->setSourceContext($this->getSourceContext());
}
// this is mostly useful for \Twig\Error\LoaderError exceptions
// see \Twig\Error\LoaderError
if (-1 === $e->getTemplateLine()) {
$e->guess();
}
throw $e;
} catch (\Exception $e) {
$e = new RuntimeError(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $this->getSourceContext(), $e);
$e->guess();
throw $e;
}
}
{
return $this;
}
/**
* Returns all blocks.
*
* This method is for internal use only and should never be called
* directly.
*
* @return array An array of blocks
*/
public function getBlocks()
{
return $this->blocks;
}
public function display(array $context, array $blocks = [])
{
$this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
}
public function render(array $context)
{
$level = ob_get_level();
if ($this->env->isDebug()) {
ob_start();
} else {
ob_start(function () { return ''; });
}
try {
$this->display($context);
} catch (\Exception $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
{
public function __construct(Environment $env)
{
parent::__construct($env);
$this->blocks = [
'page_footer' => [$this, 'block_page_footer'],
];
}
protected function doGetParent(array $context)
{
// line 1
return "@nucleus/page.html.twig";
}
protected function doDisplay(array $context, array $blocks = [])
{
$this->parent = $this->loadTemplate("@nucleus/page.html.twig", "partials/page.html.twig", 1);
$this->parent->display($context, array_merge($this->blocks, $blocks));
}
// line 3
public function block_page_footer($context, array $blocks = [])
{
// line 4
echo " ";
$this->displayParentBlock("page_footer", $context, $blocks);
echo "
<jdoc:include type=\"modules\" name=\"debug\" />
";
}
public function getTemplateName()
{
return "partials/page.html.twig";
}
public function isTraitable()
{
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
}
return ob_get_clean();
}
protected function displayWithErrorHandling(array $context, array $blocks = [])
{
try {
$this->doDisplay($context, $blocks);
} catch (Error $e) {
if (!$e->getSourceContext()) {
$e->setSourceContext($this->getSourceContext());
}
// this is mostly useful for \Twig\Error\LoaderError exceptions
// see \Twig\Error\LoaderError
if (-1 === $e->getTemplateLine()) {
$e->guess();
}
throw $e;
} catch (\Exception $e) {
$e = new RuntimeError(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $this->getSourceContext(), $e);
$e->guess();
throw $e;
}
}
{
return $this;
}
/**
* Returns all blocks.
*
* This method is for internal use only and should never be called
* directly.
*
* @return array An array of blocks
*/
public function getBlocks()
{
return $this->blocks;
}
public function display(array $context, array $blocks = [])
{
$this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
}
public function render(array $context)
{
$level = ob_get_level();
if ($this->env->isDebug()) {
ob_start();
} else {
ob_start(function () { return ''; });
}
try {
$this->display($context);
} catch (\Exception $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
{
public function __construct(Environment $env)
{
parent::__construct($env);
$this->blocks = [
'content' => [$this, 'block_content'],
];
}
protected function doGetParent(array $context)
{
// line 1
return "partials/page.html.twig";
}
protected function doDisplay(array $context, array $blocks = [])
{
$this->parent = $this->loadTemplate("partials/page.html.twig", "index.html.twig", 1);
$this->parent->display($context, array_merge($this->blocks, $blocks));
}
// line 3
public function block_content($context, array $blocks = [])
{
// line 4
echo " ";
echo $this->getAttribute($this->getAttribute(($context["gantry"] ?? null), "platform", []), "displayContent", [0 => ($context["content"] ?? null)], "method");
echo "
";
}
public function getTemplateName()
{
return "index.html.twig";
}
public function isTraitable()
{
return false;
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
}
return ob_get_clean();
}
protected function displayWithErrorHandling(array $context, array $blocks = [])
{
try {
$this->doDisplay($context, $blocks);
} catch (Error $e) {
if (!$e->getSourceContext()) {
$e->setSourceContext($this->getSourceContext());
}
// this is mostly useful for \Twig\Error\LoaderError exceptions
// see \Twig\Error\LoaderError
if (-1 === $e->getTemplateLine()) {
$e->guess();
}
throw $e;
} catch (\Exception $e) {
$e = new RuntimeError(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $this->getSourceContext(), $e);
$e->guess();
throw $e;
}
}
{
return $this;
}
/**
* Returns all blocks.
*
* This method is for internal use only and should never be called
* directly.
*
* @return array An array of blocks
*/
public function getBlocks()
{
return $this->blocks;
}
public function display(array $context, array $blocks = [])
{
$this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
}
public function render(array $context)
{
$level = ob_get_level();
if ($this->env->isDebug()) {
ob_start();
} else {
ob_start(function () { return ''; });
}
try {
$this->display($context);
} catch (\Exception $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
public function getBlocks()
{
return $this->blocks;
}
public function display(array $context, array $blocks = [])
{
$this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
}
public function render(array $context)
{
$level = ob_get_level();
if ($this->env->isDebug()) {
ob_start();
} else {
ob_start(function () { return ''; });
}
try {
$this->display($context);
} catch (\Exception $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
} catch (\Throwable $e) {
while (ob_get_level() > $level) {
ob_end_clean();
}
throw $e;
}
return ob_get_clean();
}
protected function displayWithErrorHandling(array $context, array $blocks = [])
{
try {
* @internal
*/
public function __construct(Environment $env, Template $template)
{
$this->env = $env;
$this->template = $template;
}
/**
* Renders the template.
*
* @param array $context An array of parameters to pass to the template
*
* @return string The rendered template
*/
public function render($context = [])
{
// using func_get_args() allows to not expose the blocks argument
// as it should only be used by internal code
return $this->template->render($context, \func_num_args() > 1 ? func_get_arg(1) : []);
}
/**
* Displays the template.
*
* @param array $context An array of parameters to pass to the template
*/
public function display($context = [])
{
// using func_get_args() allows to not expose the blocks argument
// as it should only be used by internal code
$this->template->display($context, \func_num_args() > 1 ? func_get_arg(1) : []);
}
/**
* Checks if a block is defined.
*
* @param string $name The block name
* @param array $context An array of parameters to pass to the template
*
@trigger_error(sprintf('The %s method is deprecated since version 1.22 and will be removed in Twig 2.0.', __METHOD__), \E_USER_DEPRECATED);
return $this->templateClassPrefix;
}
/**
* Renders a template.
*
* @param string|TemplateWrapper $name The template name
* @param array $context An array of parameters to pass to the template
*
* @return string The rendered template
*
* @throws LoaderError When the template cannot be found
* @throws SyntaxError When an error occurred during compilation
* @throws RuntimeError When an error occurred during rendering
*/
public function render($name, array $context = [])
{
return $this->load($name)->render($context);
}
/**
* Displays a template.
*
* @param string|TemplateWrapper $name The template name
* @param array $context An array of parameters to pass to the template
*
* @throws LoaderError When the template cannot be found
* @throws SyntaxError When an error occurred during compilation
* @throws RuntimeError When an error occurred during rendering
*/
public function display($name, array $context = [])
{
$this->load($name)->display($context);
}
/**
* Loads a template.
*
$this->renderer = $this->extendTwig($twig, $loader);
}
return $this->renderer;
}
/**
* Render a template file by using given context.
*
* @param string $file
* @param array $context
* @return string
*/
public function render($file, array $context = [])
{
// Include Gantry specific things to the context.
$context = $this->getContext($context);
return $this->renderer()->render($file, $context);
}
/**
* Compile and render twig string.
*
* @param string $string
* @param array $context
* @return string
*/
public function compile($string, array $context = [])
{
$renderer = $this->renderer();
$template = $renderer->createTemplate($string);
// Include Gantry specific things to the context.
$context = $this->getContext($context);
return $template->render($context);
}
// Bootstrap Gantry framework or fail gracefully (inside included file).
$className = __DIR__ . '/custom/includes/gantry.php';
if (!is_file($className)) {
$className = __DIR__ . '/includes/gantry.php';
}
$gantry = include $className;
/** @var Platform $joomla */
$joomla = $gantry['platform'];
$joomla->document = $this;
/** @var Theme $theme */
$theme = $gantry['theme'];
// All the custom twig variables can be defined in here:
$context = array();
// Render the page.
echo $theme->render('index.html.twig', $context);
* @param string $directory The name of the template
* @param string $filename The actual filename
*
* @return string The contents of the template
*
* @since 1.7.0
*/
protected function _loadTemplate($directory, $filename)
{
$contents = '';
// Check to see if we have a valid template file
if (file_exists($directory . '/' . $filename))
{
// Store the file path
$this->_file = $directory . '/' . $filename;
// Get the file content
ob_start();
require $directory . '/' . $filename;
$contents = ob_get_contents();
ob_end_clean();
}
// Try to find a favicon by checking the template and root folder
$icon = '/favicon.ico';
foreach (array($directory, JPATH_BASE) as $dir)
{
if (file_exists($dir . $icon))
{
$path = str_replace(JPATH_BASE, '', $dir);
$path = str_replace('\\', '/', $path);
$this->addFavicon(Uri::base(true) . $path . $icon);
break;
}
}
return $contents;
}
if (!file_exists($directory . '/' . $template . '/' . $file))
{
$file = 'index.php';
}
// Load the language file for the template
$lang = \JFactory::getLanguage();
// 1.5 or core then 1.6
$lang->load('tpl_' . $template, JPATH_BASE, null, false, true)
|| $lang->load('tpl_' . $template, $directory . '/' . $template, null, false, true);
// Assign the variables
$this->template = $template;
$this->baseurl = Uri::base(true);
$this->params = isset($params['params']) ? $params['params'] : new Registry;
// Load
$this->_template = $this->_loadTemplate($directory . '/' . $template, $file);
return $this;
}
/**
* Parse a document template
*
* @return HtmlDocument instance of $this to allow chaining
*
* @since 1.7.0
*/
protected function _parseTemplate()
{
$matches = array();
if (preg_match_all('#<jdoc:include\ type="([^"]+)"(.*)\/>#iU', $this->_template, $matches))
{
$template_tags_first = array();
$template_tags_last = array();
$options['title'] = (isset($args[3])) ? $args[3] : null;
}
parent::$_buffer[$options['type']][$options['name']][$options['title']] = $content;
return $this;
}
/**
* Parses the template and populates the buffer
*
* @param array $params Parameters for fetching the template
*
* @return HtmlDocument instance of $this to allow chaining
*
* @since 1.7.0
*/
public function parse($params = array())
{
return $this->_fetchTemplate($params)->_parseTemplate();
}
/**
* Outputs the template to the browser.
*
* @param boolean $caching If true, cache the output
* @param array $params Associative array of attributes
*
* @return string The rendered data
*
* @since 1.7.0
*/
public function render($caching = false, $params = array())
{
$this->_caching = $caching;
if (empty($this->_template))
{
$this->parse($params);
}
)
);
$this->setPathway();
$this->safeTriggerEvent('onAfterDispatch');
$docOptions['template'] = $template->template;
$docOptions['file'] = 'index.php';
$docOptions['params'] = $this->app->get('themeParams');
if ($this->app->get('themes.base'))
{
$docOptions['directory'] = $this->app->get('themes.base');
}
else
{
$docOptions['directory'] = defined('JPATH_THEMES') ? JPATH_THEMES : (defined('JPATH_BASE') ? JPATH_BASE : __DIR__) . '/themes';
}
$document->parse($docOptions);
$this->safeTriggerEvent('onBeforeCompileHead');
// Render the document.
$data = $document->render(
false,
$docOptions
);
$this->app->setHeader('Content-Type', 'text/html; charset=utf-8', true);
$this->app->setHeader('Cache-Control', 'no-store, no-cache, no-transform', true);
$this->app->setHeader('X-4seo-generator', '4SEO', true);
// Failsafe to get the error displayed.
if (empty($data))
{
$this->safeEcho(
$error->getMessage()
);
}
$error->getCode()
);
}
if (!defined('JPATH_COMPONENT'))
{
define('JPATH_COMPONENT', JPATH_BASE . '/components/com_4seo');
}
if (!defined('JPATH_COMPONENT_SITE'))
{
define('JPATH_COMPONENT_SITE', JPATH_SITE . '/components/com_4seo');
}
if (!defined('JPATH_COMPONENT_ADMINISTRATOR'))
{
define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/com_4seo');
}
$this->renderDocument(
$rule,
$error,
$this->getSuggested(
$rule,
$page
)
);
}
/**
* Finds pages simlar to the current request and builds an array
* of titles indexed on URL.
*
* @param Data\Rule $rule
* @param Data\Page $page
* @return array
* @throws \Exception
*
*/
protected function getSuggested($rule, $page)
if (empty($applicableRule))
{
return;
}
$applicableRule->timestamp('last_hit')
->increment('hits')
->store();
$platformType = $this->platform->majorVersion() < 4
? 'J3'
: 'J4';
$renderer = $this->factory->getA(
'Weeblr\Forseo\Platform\Helpers\Errorpages\\' . $platformType . 'renderer'
);
$renderer->render(
$applicableRule,
$error,
$page
);
die();
}
/**
* Figure out if the rule applies to the current error
* based on the error code.
*
* @param Data\Rule $rule
* @param \Throwable $error
*
* @return bool
*/
private function ruleAppliesToError($rule, $error)
{
$ruleDef = $rule->getRule();
$this->forceRecrawlIfExisting(
Data\Page::class
);
$this->logIncoming404s(
$error,
$errorCode
);
// If an error page display rule has been created, run it
$rules = $this->factory
->getA(Rules::class)
->getRulesPerType(
Data\Rule::TYPE_ERROR_PAGE
);
if (!empty($rules))
{
$this->factory->getA(Helper\Errorpage::class)
->render(
$rules,
$error,
$this->currentPage
);
}
}
/**
* If this is a known page, link or error, we may need to update our records:
*
* - demote from page to error
* - remove from sitemap
* - update back from error to page
*
* To find out, we put the page back up for re-crawl.
*
* @return $this;
*/
private function forceRecrawlIfExisting($class)
{
}
// already running. We don't allow nesting
self::$hooksStack[] = $id;
// increase run counter
self::$hooksRuns[$id] = isset(self::$hooksRuns[$id]) ? self::$hooksRuns[$id]++ : 1;
// iterate over registered hook handlers
foreach (self::$hooks[$id] as $priority => $callbackList)
{
foreach ($callbackList as $callbackRecord)
{
if ($filter)
{
$params[0] = call_user_func_array($callbackRecord['callback'], $params);
}
else
{
call_user_func_array($callbackRecord['callback'], $params);
}
}
}
$newValue = null;
if ($filter)
{
$newValue = isset($params[0]) ? $params[0] : null;
}
array_pop(self::$hooksStack);
return $newValue;
}
public function hasHook($id)
{
$hasHook = false;
if (!empty($id) && is_string($id))
{
}
// already running. We don't allow nesting
self::$hooksStack[] = $id;
// increase run counter
self::$hooksRuns[$id] = isset(self::$hooksRuns[$id]) ? self::$hooksRuns[$id]++ : 1;
// iterate over registered hook handlers
foreach (self::$hooks[$id] as $priority => $callbackList)
{
foreach ($callbackList as $callbackRecord)
{
if ($filter)
{
$params[0] = call_user_func_array($callbackRecord['callback'], $params);
}
else
{
call_user_func_array($callbackRecord['callback'], $params);
}
}
}
$newValue = null;
if ($filter)
{
$newValue = isset($params[0]) ? $params[0] : null;
}
array_pop(self::$hooksStack);
return $newValue;
}
public function hasHook($id)
{
$hasHook = false;
if (!empty($id) && is_string($id))
{
/**
* Execute all callbacks registered for a hook id
* in order of priority
* A value must be returned, which will normally be assigned
* by caller to replace current value
*
* @param $filter
* @param array $params
*
* @return mixed
*/
private function execute($filter, $params)
{
if ($filter)
{
return Factory::get()->getThe('platform')->executeHook($filter, $params);
}
else
{
Factory::get()->getThe('platform')->executeHook($filter, $params);
}
}
/**
* Whether a given hook has callbacks registered.
*
* @param string $id
*
* @return bool
*/
public function hasHook($id)
{
return Factory::get()->getThe('platform')->hasHook($id);
}
}
* @return bool True if hook was removed
**/
public function remove($id, $callback, $priority = null)
{
return Factory::get()->getThe('platform')->removeHook($id, $callback, $priority);
return $removed;
}
/**
* Execute all callbacks registered for a hook id
* in order of priority
* Params can be modified by the callback, if so defined
* Execution can return values
*
* @return mixed|null
*/
public function run(...$args)
{
$this->execute(false, $args);
}
/**
* Execute all callbacks registered for a hook id
* in order of priority, only on first call.
* Params can be modified by the callback, if so defined
* Execution can return values
*
* @return mixed|null
*/
public function runOnce(...$args)
{
static $ran = [];
$id = Wb\arrayGet($args, 0);
if (in_array($id, $ran))
{
return;
}
$rulesController->executeWaf();
$rulesController->executeRedirects();
switch ($errorCode)
{
case 404:
/**
* Run hook with the 404 error to allow actions by other parties.
*
* @api forseo
* @package 4SEO\action\error
* @var forseo_on_404_error
* @since 1.0.0
*
* @param \Exception $error
*
* @return void
*
*/
$this->factory->getThe('hook')->run(
'forseo_on_404_error',
$error
);
// die to end processing for now. Display custom 404 error page in the future.
// remember to run Replacers, Analytics and any other relevant rules.
// can only be done if we have a real Document so not on default CMS rendering.
//die(sprintf('Received error: %d:%s', $error->getCode(), $error->getMessage()));
break;
case 500:
// possibly log 500 and other errors in the future
default:
// returning to the platform handlers will cause them
// to pass the error to normal error processing chain.
/**
* Run hook with the error to allow actions by other parties.
*
* @api forseo
* @package 4SEO\action\error
* @var forseo_on_error
throw new InvalidArgumentException(
sprintf('The error handler requires an Exception or Throwable object, a "%s" object was given instead.', get_class($exception))
);
}
$this->handleError($exception);
}
/**
* Joomla 3 wrapper around error handling. Calls 4SEO error handler
* and pass-thru to previous Joomla error handler if 4SEO should not handle.
*
* @param \Throwable| \Exception $error
*
* @throws \Throwable
*/
public function handleError($error)
{
// pass on to 4SEO: if handled, it won't return.
call_user_func_array(
$this->appHandler,
[$error]
);
// Proxy to the previous exception handler if available, otherwise just render the error page
if ($this->platformExceptionHandler)
{
call_user_func_array(
$this->platformExceptionHandler,
[$error]
);
}
else
{
Exception\ExceptionHandler::render($error);
}
}
}
throw new InvalidArgumentException(
sprintf('The error handler requires an Exception or Throwable object, a "%s" object was given instead.', get_class($exception))
);
}
$this->handleError($exception);
}
/**
* Joomla 3 wrapper around error handling. Calls 4SEO error handler
* and pass-thru to previous Joomla error handler if 4SEO should not handle.
*
* @param \Throwable| \Exception $error
*
* @throws \Throwable
*/
public function handleError($error)
{
// pass on to 4SEO: if handled, it won't return.
call_user_func_array(
$this->appHandler,
[$error]
);
// Proxy to the previous exception handler if available, otherwise just render the error page
if ($this->platformExceptionHandler)
{
call_user_func_array(
$this->platformExceptionHandler,
[$error]
);
}
else
{
Exception\ExceptionHandler::render($error);
}
}
}
}
/**
* Callback error handler
* - Send the error object to a callback method for error handling
*
* @param JException &$error Exception object to handle
* @param array $options Handler options
*
* @return JException The exception object
*
* @since 1.5
* @deprecated 4.0
* @see JError::raise()
*/
public static function handleCallback(&$error, $options)
{
JLog::add('JError::handleCallback() is deprecated.', JLog::WARNING, 'deprecated');
return call_user_func_array($options, array(&$error));
}
/**
* Display a custom error page and exit gracefully
*
* @param JException $error Exception object
*
* @return void
*
* @since 1.5
* @deprecated 4.0 Use \Joomla\CMS\Exception\ExceptionHandler::render() instead
*/
public static function customErrorPage($error)
{
JLog::add('JError::customErrorPage() is deprecated, use JErrorPage::render() instead.', JLog::WARNING, 'deprecated');
\Joomla\CMS\Exception\ExceptionHandler::render($error);
}
/**
// If thrown is hit again, we've come back to JError in the middle of throwing another JError, so die!
if ($thrown)
{
self::handleEcho($exception, array());
// Inifite loop.
jexit();
}
$thrown = true;
$level = $exception->get('level');
// See what to do with this kind of error
$handler = self::getErrorHandling($level);
$function = 'handle' . ucfirst($handler['mode']);
if (is_callable(array('JError', $function)))
{
$reference = call_user_func_array(array('JError', $function), array(&$exception, isset($handler['options']) ? $handler['options'] : array()));
}
else
{
// This is required to prevent a very unhelpful white-screen-of-death
jexit(
'JError::raise -> Static method JError::' . $function . ' does not exist. Contact a developer to debug' .
'<br /><strong>Error was</strong> <br />' . $exception->getMessage()
);
}
// We don't need to store the error, since JException already does that for us!
// Remove loop check
$thrown = false;
return $reference;
}
/**
* Wrapper method for the raise() method with predefined error level of E_ERROR and backtrace set to true.
*
* @param string $code The application-internal error code for this error
* @param string $msg The error message, which may also be shown the user if need be.
* @param mixed $info Optional: Additional error information (usually only
* developer-relevant information that the user should never see,
* like a database DSN).
* @param boolean $backtrace Add a stack backtrace to the exception.
*
* @return JException
*
* @since 1.5
* @deprecated 4.0
* @see JException
*/
public static function raise($level, $code, $msg, $info = null, $backtrace = false)
{
JLog::add('JError::raise() is deprecated.', JLog::WARNING, 'deprecated');
// Build error object
$exception = new JException($msg, $code, $level, $info, $backtrace);
return self::throwError($exception);
}
/**
* Throw an error
*
* @param JException &$exception An exception to throw.
*
* @return JException A reference to the handled JException object
*
* @since 1.6
* @deprecated 4.0 Just throw an Exception
* @see JException
*/
public static function throwError(&$exception)
{
JLog::add('JError::throwError() is deprecated.', JLog::WARNING, 'deprecated');
static $thrown = false;
// If thrown is hit again, we've come back to JError in the middle of throwing another JError, so die!
/**
* Wrapper method for the raise() method with predefined error level of E_ERROR and backtrace set to true.
*
* @param string $code The application-internal error code for this error
* @param string $msg The error message, which may also be shown the user if need be.
* @param mixed $info Optional: Additional error information (usually only
* developer-relevant information that the user should
* never see, like a database DSN).
*
* @return JException $error The thrown JException object
*
* @since 1.5
* @deprecated 4.0 Just throw an Exception
* @see JError::raise()
*/
public static function raiseError($code, $msg, $info = null)
{
JLog::add('JError::raiseError() is deprecated.', JLog::WARNING, 'deprecated');
return self::raise(E_ERROR, $code, $msg, $info, true);
}
/**
* Wrapper method for the {@link raise()} method with predefined error level of E_WARNING and backtrace set to false.
*
* @param string $code The application-internal error code for this error
* @param string $msg The error message, which may also be shown the user if need be.
* @param mixed $info Optional: Additional error information (usually only
* developer-relevant information that
* the user should never see, like a database DSN).
*
* @return JException $error The thrown JException object
*
* @since 1.5
* @deprecated 4.0 Use \Joomla\CMS\Factory::getApplication()->enqueueMessage($msg, 'warning') when wou want to notify the UI
* @see JError::raise()
*/
public static function raiseWarning($code, $msg, $info = null)
{
JLog::add('JError::raiseWarning() is deprecated.', JLog::WARNING, 'deprecated');
$vars['category_id'] = $category_id;
$vars['product_id'] = $product_id;
$dispatcher->trigger('onAfterParseRoute', array(&$vars, &$segments));
return $vars;
}
}
if (!$category_id && $segments[1]==""){
$manalias = JSFactory::getAliasManufacturer();
$manufacturer_id = array_search($segments[0], $manalias, true);
if ($manufacturer_id){
$vars['controller'] = "manufacturer";
$vars['task'] = "view";
$vars['manufacturer_id'] = $manufacturer_id;
$dispatcher->trigger('onAfterParseRoute', array(&$vars, &$segments));
return $vars;
}
}
JError::raiseError(404, _JSHOP_PAGE_NOT_FOUND);
}else{
$vars['controller'] = $segments[0];
$vars['task'] = $segments[1];
if ($vars['controller']=="category" && $vars['task']=="view"){
$vars['category_id'] = $segments[2];
}
if ($vars['controller']=="product" && $vars['task']=="view"){
$vars['category_id'] = $segments[2];
$vars['product_id'] = $segments[3];
}
if ($vars['controller']=="product" && $vars['task']=="ajax_attrib_select_and_price"){
$vars['product_id'] = $segments[2];
}
if ($vars['controller']=="manufacturer" && isset($segments[2])){
$vars['manufacturer_id'] = $segments[2];
* @param array &$segments The segments of the URL to parse.
*
* @return array The URL attributes to be used by the application.
*
* @since 3.3
*/
public function parse(&$segments)
{
$function = $this->component . 'ParseRoute';
if (function_exists($function))
{
$total = count($segments);
for ($i = 0; $i < $total; $i++)
{
$segments[$i] = preg_replace('/-/', ':', $segments[$i], 1);
}
return $function($segments);
}
return array();
}
}
// Set the variables
$this->setVars($vars);
// Parse the component route
if (!empty($route) && isset($this->_vars['option']))
{
$segments = explode('/', $route);
if (empty($segments[0]))
{
array_shift($segments);
}
// Handle component route
$component = preg_replace('/[^A-Z0-9_\.-]/i', '', $this->_vars['option']);
if (count($segments))
{
$crouter = $this->getComponentRouter($component);
$vars = $crouter->parse($segments);
$this->setVars($vars);
}
$route = implode('/', $segments);
}
else
{
// Set active menu item
if ($item = $this->menu->getActive())
{
$vars = $item->query;
}
}
$uri->setPath($route);
return $vars;
}
* @deprecated 4.0 Attach your logic as rule to the main parse stage
*/
protected function parseRawRoute(&$uri)
{
return array();
}
/**
* Function to convert a sef route to an internal URI
*
* @param \JUri &$uri The sef URI
*
* @return string Internal URI
*
* @since 1.5
* @deprecated 4.0 Attach your logic as rule to the main parse stage
*/
protected function _parseSefRoute(&$uri)
{
return $this->parseSefRoute($uri);
}
/**
* Function to convert a sef route to an internal URI
*
* @param \JUri &$uri The sef URI
*
* @return array Array of variables
*
* @since 3.2
* @deprecated 4.0 Attach your logic as rule to the main parse stage
*/
protected function parseSefRoute(&$uri)
{
return array();
}
/**
* Function to build a raw route
*
*/
public function parse(&$uri)
{
// Do the preprocess stage of the URL build process
$vars = $this->processParseRules($uri, self::PROCESS_BEFORE);
// Process the parsed variables based on custom defined rules
// This is the main parse stage
$vars += $this->_processParseRules($uri);
// Parse RAW URL
if ($this->_mode == JROUTER_MODE_RAW)
{
$vars += $this->_parseRawRoute($uri);
}
// Parse SEF URL
if ($this->_mode == JROUTER_MODE_SEF)
{
$vars += $this->_parseSefRoute($uri);
}
// Do the postprocess stage of the URL build process
$vars += $this->processParseRules($uri, self::PROCESS_AFTER);
// Check if all parts of the URL have been parsed.
// Otherwise we have an invalid URL
if (strlen($uri->getPath()) > 0 && array_key_exists('option', $vars)
&& ComponentHelper::getParams($vars['option'])->get('sef_advanced', 0))
{
throw new RouteNotFoundException(\JText::_('JERROR_PAGE_NOT_FOUND'));
}
return array_merge($this->getVars(), $vars);
}
/**
* Function to convert an internal URI to a route
*
* @param string $url The internal URL or an associative array
}
}
// Set the route
$uri->setPath(trim($path, '/'));
// Set the parsepreprocess components methods
$components = ComponentHelper::getComponents();
foreach ($components as $component)
{
$componentRouter = $this->getComponentRouter($component->option);
if (method_exists($componentRouter, 'parsepreprocess'))
{
$this->attachParseRule(array($componentRouter, 'parsepreprocess'), static::PROCESS_BEFORE);
}
}
$vars += parent::parse($uri);
return $vars;
}
/**
* Function to convert an internal URI to a route
*
* @param string $url The internal URL
*
* @return string The absolute search engine friendly URL
*
* @since 1.5
*/
public function build($url)
{
$uri = parent::build($url);
// Get the path data
$route = $uri->getPath();
/**
* Route the application.
*
* Routing is the process of examining the request environment to determine which
* component should receive the request. The component optional parameters
* are then set in the request object to be processed when the application is being
* dispatched.
*
* @return void
*
* @since 3.2
*/
protected function route()
{
// Get the full request URI.
$uri = clone \JUri::getInstance();
$router = static::getRouter();
$result = $router->parse($uri);
$active = $this->getMenu()->getActive();
if ($active !== null
&& $active->type === 'alias'
&& $active->params->get('alias_redirect')
&& in_array($this->input->getMethod(), array('GET', 'HEAD'), true))
{
$item = $this->getMenu()->getItem($active->params->get('aliasoptions'));
if ($item !== null)
{
$oldUri = clone \JUri::getInstance();
if ($oldUri->getVar('Itemid') == $active->id)
{
$oldUri->setVar('Itemid', $item->id);
}
$base = \JUri::base(true);
parent::render();
}
/**
* Route the application.
*
* Routing is the process of examining the request environment to determine which
* component should receive the request. The component optional parameters
* are then set in the request object to be processed when the application is being
* dispatched.
*
* @return void
*
* @since 3.2
*/
protected function route()
{
// Execute the parent method
parent::route();
$Itemid = $this->input->getInt('Itemid', null);
$this->authorise($Itemid);
}
/**
* Set the current state of the detect browser option.
*
* @param boolean $state The new state of the detect browser option
*
* @return boolean The previous state
*
* @since 3.2
*/
public function setDetectBrowser($state = false)
{
$old = $this->_detect_browser;
$this->_detect_browser = $state;
return $old;
$this->triggerEvent('onAfterDispatch');
}
/**
* Method to run the Web application routines.
*
* @return void
*
* @since 3.2
*/
protected function doExecute()
{
// Initialise the application
$this->initialiseApp();
// Mark afterInitialise in the profiler.
JDEBUG ? $this->profiler->mark('afterInitialise') : null;
// Route the application
$this->route();
// Mark afterRoute in the profiler.
JDEBUG ? $this->profiler->mark('afterRoute') : null;
/*
* Check if the user is required to reset their password
*
* Before $this->route(); "option" and "view" can't be safely read using:
* $this->input->getCmd('option'); or $this->input->getCmd('view');
* ex: due of the sef urls
*/
$this->checkUserRequireReset('com_users', 'profile', 'edit', 'com_users/profile.save,com_users/profile.apply,com_users/user.logout');
// Dispatch the application
$this->dispatch();
// Mark afterDispatch in the profiler.
JDEBUG ? $this->profiler->mark('afterDispatch') : null;
}
array('option', 'view', 'format', 'lang', 'Itemid', 'template', 'templateStyle', 'task'),
function($systemVariable) use ($input) {
return $input->exists($systemVariable) && is_array($input->getRaw($systemVariable));
}
);
// Unset invalid system variables
foreach ($invalidInputVariables as $systemVariable)
{
$input->set($systemVariable, null);
}
// Abort when there are invalid variables
if ($invalidInputVariables)
{
throw new \RuntimeException('Invalid input, aborting application.');
}
// Perform application routines.
$this->doExecute();
// If we have an application document object, render it.
if ($this->document instanceof \JDocument)
{
// Render the application output.
$this->render();
}
// If gzip compression is enabled in configuration and the server is compliant, compress the output.
if ($this->get('gzip') && !ini_get('zlib.output_compression') && ini_get('output_handler') !== 'ob_gzhandler')
{
$this->compress();
// Trigger the onAfterCompress event.
$this->triggerEvent('onAfterCompress');
}
// Send the application response.
$this->respond();
{
include_once __DIR__ . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', __DIR__);
require_once JPATH_BASE . '/includes/defines.php';
}
require_once JPATH_BASE . '/includes/framework.php';
// Set profiler start time and memory usage and mark afterLoad in the profiler.
JDEBUG ? JProfiler::getInstance('Application')->setStart($startTime, $startMem)->mark('afterLoad') : null;
// Instantiate the application.
$app = JFactory::getApplication('site');
// Execute the application.
$app->execute();