Spade
Mini Shell
| Directory:~$ /home/lmsyaran/public_html/joomla4/ |
| [Home] [System Details] [Kill Me] |
helper.php000064400000012001151160371470006533 0ustar00<?php
/**
* @package Gantry 5
* @author RocketTheme http://www.rockettheme.com
* @copyright Copyright (C) 2007 - 2017 RocketTheme, LLC
* @license GNU/GPLv2 and later
*
* http://www.gnu.org/licenses/gpl-2.0.html
*/
defined('_JEXEC') or die;
class ModGantry5ParticleHelper
{
/**
* Serve module AJAX requests in
'index.php?option=com_ajax&module=gantry5_particle&format=json'.
*
* @return array|null|string
*/
public static function getAjax()
{
$input = JFactory::getApplication()->input;
$format = $input->getCmd('format', 'html');
$id = $input->getInt('id');
$props = $_GET;
unset($props['option'], $props['module'],
$props['format'], $props['id']);
return static::ajax($id, $props, $format);
}
/**
* @param $id
* @param array $props
* @param string $format
* @return array|null|string
*/
public static function ajax($id, $props = [], $format =
'raw')
{
if (!in_array($format, ['json', 'raw',
'debug'])) {
throw new
RuntimeException(JText::_('JERROR_PAGE_NOT_FOUND'), 404);
}
$gantry = \Gantry\Framework\Gantry::instance();
$module = $gantry['platform']->getModule($id);
// Make sure that module really exists.
if (!is_object($module) || strpos($module->module,
'gantry5') === false) {
throw new
RuntimeException(JText::_('JERROR_PAGE_NOT_FOUND'), 404);
}
$attribs = ['style' => 'gantry'];
// Trigger the onRenderModule event.
$dispatcher = \JEventDispatcher::getInstance();
$dispatcher->trigger('onRenderModule',
['module' => &$module, 'attribs' =>
&$attribs]);
$params = new JRegistry($module->params);
$params->set('ajax', $props);
$block = static::render($module, $params);
$data = json_decode($params->get('particle'), true);
$type = $data['type'] . '.' .
$data['particle'];
$identifier = static::getIdentifier($data['particle'],
$module->id);
$html = (string) $block;
if ($format === 'raw') {
return $html;
}
return ['code' => 200, 'type' => $type,
'id' => $identifier, 'props' => (object) $props,
'html' => $html];
}
/**
* @param object $module
* @param object $params
* @return Gantry\Component\Content\Block\ContentBlockInterface
*/
public static function render($module, $params)
{
GANTRY_DEBUGGER &&
\Gantry\Debugger::addMessage("Particle Module #{$module->id} was
not cached");
$data = json_decode($params->get('particle'), true);
$type = $data['type'];
$particle = $data['particle'];
$gantry = \Gantry\Framework\Gantry::instance();
if ($gantry->debug()) {
$enabled_outline =
$gantry['config']->get("particles.{$particle}.enabled",
true);
$enabled =
isset($data['options']['particle']['enabled'])
? $data['options']['particle']['enabled'] :
true;
$location = (!$enabled_outline ? 'Outline' :
(!$enabled ? 'Module' : null));
if ($location) {
$block =
\Gantry\Component\Content\Block\HtmlBlock::create();
$block->setContent(sprintf('<div
class="alert alert-error">The Particle has been disabled from
the %s and won\'t render.</div>', $location));
return $block;
}
}
$id = static::getIdentifier($particle, $module->id);
$object = (object) array(
'id' => $id,
'type' => $type,
'subtype' => $particle,
'attributes' =>
$data['options']['particle'],
);
$context = array(
'gantry' => $gantry,
'inContent' => true,
'ajax' => $params->get('ajax'),
);
/** @var Gantry\Framework\Theme $theme */
$theme = $gantry['theme'];
$block = $theme->getContent($object, $context);
// Create outer block with the particle ID for AJAX calls.
$outer = \Gantry\Component\Content\Block\HtmlBlock::create();
$outer->setContent('<div id="' . $id .
'-particle" class="g-particle">' .
$block->getToken() . '</div>');
$outer->addBlock($block);
return $outer;
}
/**
* @param $module
* @param $params
* @return array
*/
public static function cache($module, $params)
{
return static::render($module, $params)->toArray();
}
/**
* @param $module
* @param $params
* @param $cacheparams
* @return \Gantry\Component\Content\Block\ContentBlockInterface|null
*/
public static function moduleCache($module, $params, $cacheparams)
{
$block = (array) JModuleHelper::moduleCache($module, $params,
$cacheparams);
try {
return $block ?
\Gantry\Component\Content\Block\HtmlBlock::fromArray($block) : null;
} catch (Exception $e) {
return null;
}
}
public static function getIdentifier($particle, $id)
{
return "module-{$particle}-{$id}";
}
}
language/en-GB/en-GB.mod_gantry5_particle.ini000064400000000637151160371470014735
0ustar00MOD_GANTRY5_PARTICLE="Gantry 5 Particle"
MOD_GANTRY5_PARTICLE_DESCRIPTION="This module allows you to add
particles to module positions."
MOD_GANTRY5_PARTICLE_NOT_INITIALIZED="%s: Cannot display content; not
in Gantry 5 template!"
MOD_GANTRY5_PARTICLE_FIELD_PARTICLE_LABEL="Particle"
MOD_GANTRY5_PARTICLE_FIELD_PARTICLE_DESC="Select and configure Gantry
5 particle."
GANTRY5_PLATFORM_EDIT_PARTICLE="Edit Particle"
language/en-GB/en-GB.mod_gantry5_particle.sys.ini000064400000000211151160371470015536
0ustar00MOD_GANTRY5_PARTICLE="Gantry 5 Particle"
MOD_GANTRY5_PARTICLE_DESCRIPTION="This module allows you to add
particles to module positions."
MD5SUMS000064400000000553151160371470005574
0ustar00mod_gantry5_particle.xml 639b1bdab8b4de8de4ca2133c70bb53e
language/en-GB/en-GB.mod_gantry5_particle.ini 36768f6c44ba3fe3f5fea7e9d68b7ad7
language/en-GB/en-GB.mod_gantry5_particle.sys.ini ac2c79d2f58a93ff1e39cb596e1ef2ad
mod_gantry5_particle.php a3335aebeb6109cb024acc75a2bd0267
MD5SUMS d41d8cd98f00b204e9800998ecf8427e
helper.php 4565baa8bfc942afd80139cbce27e8f9
mod_gantry5_particle.php000064400000002653151160371470011403
0ustar00<?php
/**
* @package Gantry 5
* @author RocketTheme http://www.rockettheme.com
* @copyright Copyright (C) 2007 - 2017 RocketTheme, LLC
* @license GNU/GPLv2 and later
*
* http://www.gnu.org/licenses/gpl-2.0.html
*/
defined('_JEXEC') or die;
// Detect Gantry Framework or fail gracefully.
if (!class_exists('Gantry\Framework\Gantry')) {
$lang = JFactory::getLanguage();
JFactory::getApplication()->enqueueMessage(
JText::sprintf('MOD_GANTRY5_PARTICLE_NOT_INITIALIZED',
JText::_('MOD_GANTRY5_PARTICLE')),
'warning'
);
return;
}
include_once dirname(__FILE__) . '/helper.php';
/** @var object $params */
$gantry = \Gantry\Framework\Gantry::instance();
GANTRY_DEBUGGER &&
\Gantry\Debugger::startTimer("module-{$module->id}",
"Rendering Particle Module #{$module->id}");
// Set up caching.
$cacheid = md5($module->id);
$cacheparams = (object) [
'cachemode' => 'id',
'class' => 'ModGantry5ParticleHelper',
'method' => 'cache',
'methodparams' => [$module, $params],
'modeparams' => $cacheid
];
$block = ModGantry5ParticleHelper::moduleCache($module, $params,
$cacheparams);
if (!$block) {
$block = ModGantry5ParticleHelper::render($module, $params);
}
/** @var \Gantry\Framework\Document $document */
$document = $gantry['document'];
$document->addBlock($block);
echo $block->toString();
GANTRY_DEBUGGER &&
\Gantry\Debugger::stopTimer("module-{$module->id}");
mod_gantry5_particle.xml000064400000004435151160371470011414
0ustar00<?xml version="1.0" encoding="UTF-8"
standalone="no"?>
<extension version="3.4" type="module"
client="site" method="upgrade">
<name>mod_gantry5_particle</name>
<version>5.4.37</version>
<creationDate>January 25, 2021</creationDate>
<author>RocketTheme, LLC</author>
<authorEmail>support@rockettheme.com</authorEmail>
<authorUrl>http://www.rockettheme.com</authorUrl>
<copyright>(C) 2005 - 2019 RocketTheme, LLC. All rights
reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html
GNU/GPLv2</license>
<description>MOD_GANTRY5_PARTICLE_DESCRIPTION</description>
<files>
<filename
module="mod_gantry5_particle">mod_gantry5_particle.php</filename>
<filename>helper.php</filename>
<folder>language</folder>
</files>
<config>
<fields name="params">
<fieldset name="basic"
addfieldpath="/components/com_gantry5/fields">
<field
name="particle"
type="particle"
filter="raw"
label="MOD_GANTRY5_PARTICLE_FIELD_PARTICLE_LABEL"
description="MOD_GANTRY5_PARTICLE_FIELD_PARTICLE_DESC" />
</fieldset>
<fieldset name="advanced">
<field
name="moduleclass_sfx"
type="text"
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
description="COM_MODULES_FIELD_MODULECLASS_SFX_DESC" />
<field
name="owncache"
type="list"
label="COM_MODULES_FIELD_CACHING_LABEL"
description="COM_MODULES_FIELD_CACHING_DESC"
default="0"
>
<option
value="1">JGLOBAL_USE_GLOBAL</option>
<option
value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
</field>
<field
name="cache_time"
type="text"
default="900"
label="COM_MODULES_FIELD_CACHE_TIME_LABEL"
description="COM_MODULES_FIELD_CACHE_TIME_DESC" />
</fieldset>
</fields>
</config>
</extension>