primo commit

This commit is contained in:
2024-12-17 17:34:10 +01:00
commit e650f8df99
16435 changed files with 2451012 additions and 0 deletions

View File

@ -0,0 +1,101 @@
<?php
/**
* @package Regular Labs Library
* @version 24.11.1459
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
namespace RegularLabs\Plugin\System\RegularLabs;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use RegularLabs\Library\RegEx as RL_RegEx;
class AdminMenu
{
public static function combine(): void
{
$params = Params::get();
if ( ! $params->combine_admin_menu)
{
return;
}
$html = JFactory::getApplication()->getBody();
if ($html == '')
{
return;
}
if (
! str_contains($html, '<nav class="main-nav-container"')
|| ! str_contains($html, '">Regular Labs - ')
)
{
return;
}
if ( ! RL_RegEx::matchAll(
'<li class="item item-level-2"><a class="no-dropdown"[^>]*"Regular Labs - .*?</a></li>',
$html,
$matches,
null,
PREG_PATTERN_ORDER
)
)
{
return;
}
$menu_items = $matches[0];
if (count($menu_items) < 2)
{
return;
}
$manager = null;
foreach ($menu_items as $i => &$menu_item)
{
$menu_item = str_replace('item-level-2', 'item-level-3', $menu_item);
$menu_item = str_replace('Regular Labs - ', '', $menu_item);
if (str_contains($menu_item, 'index.php?option=com_regularlabsmanager'))
{
$manager = $menu_item;
unset($menu_items[$i]);
}
}
$main_link = '#';
if ( ! is_null($manager))
{
array_unshift($menu_items, $manager);
$main_link = 'href="index.php?option=com_regularlabsmanager"';
}
$new_menu_item =
'<li class="item parent item-level-2">'
. '<a class="has-arrow" href=" ' . $main_link . '" aria-label="Regular Labs"><span class="sidebar-item-title">Regular Labs</span></a>'
. "\n" . '<ul id="menu-regularlabs" class="mm-collapse collapse-level-2">'
. "\n" . implode("\n", $menu_items)
. "\n" . '</ul>'
. '</li>';
$first = array_shift($matches[0]);
$html = str_replace($first, $new_menu_item, $html);
$html = str_replace($matches[0], '', $html);
JFactory::getApplication()->setBody($html);
}
}

View File

@ -0,0 +1,101 @@
<?php
/**
* @package Regular Labs Library
* @version 24.11.1459
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
namespace RegularLabs\Plugin\System\RegularLabs;
defined('_JEXEC') or die;
use Joomla\CMS\Event\AbstractEvent;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Plugin\PluginHelper as JPluginHelper;
use RegularLabs\Library\Document as RL_Document;
use RegularLabs\Library\Input as RL_Input;
class Application
{
static function getThemesDirectory()
{
if (JFactory::getApplication()->get('themes.base'))
{
return JFactory::getApplication()->get('themes.base');
}
if (defined('JPATH_THEMES'))
{
return JPATH_THEMES;
}
if (defined('JPATH_BASE'))
{
return JPATH_BASE . '/themes';
}
return __DIR__ . '/themes';
}
public function render()
{
$app = JFactory::getApplication();
$document = RL_Document::get();
$user = $app->getIdentity() ?: JFactory::getUser();
$template = $app->getTemplate(true);
$clientId = (int) $app->getClientId();
$document->getWebAssetManager()->getRegistry()->addTemplateRegistryFile($template->template, $clientId);
$app->loadDocument($document);
$template_file = RL_Input::getCmd('tmpl', 'index');
$params = [
'template' => $app->get('theme', $template->template),
'file' => $app->get('themeFile', $template_file . '.php'),
'params' => $template->params,
'csp_nonce' => $app->get('csp_nonce'),
'templateInherits' => $app->get('themeInherits'),
'directory' => self::getThemesDirectory(),
];
// Parse the document.
$document->parse($params);
// Trigger the onBeforeRender event.
JPluginHelper::importPlugin('system');
$event = AbstractEvent::create(
'onBeforeRender',
['subject' => $app,]
);
$app->getDispatcher()->dispatch('onBeforeRender', $event);
$caching = false;
if ($app->isClient('site') && $app->get('caching') && $app->get('caching', 2) == 2 && ! $user->get('id'))
{
$caching = true;
}
// Render the document.
$data = $document->render($caching, $params);
// Set the application output data.
$app->setBody($data);
// Trigger the onAfterRender event.
$event = AbstractEvent::create(
'onAfterRender',
['subject' => $app,]
);
$app->getDispatcher()->dispatch('onBeforeRender', $event);
// Mark afterRender in the profiler.
// Causes issues, so commented out.
// JDEBUG ? $app->profiler->mark('afterRender') : null;
}
}

View File

@ -0,0 +1,83 @@
<?php
/**
* @package Regular Labs Library
* @version 23.9.3039
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
namespace RegularLabs\Plugin\System\RegularLabs;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use RegularLabs\Library\Document as RL_Document;
use RegularLabs\Library\RegEx as RL_RegEx;
class DownloadKey
{
public static function cloak()
{
// Save the download key from the Regular Labs Extension Manager config to the update sites
if (
RL_Document::isClient('site')
|| JFactory::getApplication()->input->get('option') != 'com_installer'
|| JFactory::getApplication()->input->get('view') != 'updatesites'
)
{
return;
}
$html = JFactory::getApplication()->getBody();
RL_RegEx::matchAll('(regularlabs\.com[^<]*</a>\s*<br/?>\s*<pre>k=)(.*?)([A-Z0-9]{4}</pre>)', $html, $matches);
foreach ($matches as $match)
{
$cloaked_key = str_repeat('*', strlen($match[2]));
$html = str_replace(
$match[0],
$match[1] . $cloaked_key . $match[3],
$html
);
}
JFactory::getApplication()->setBody($html);
}
public static function update()
{
// Save the download key from the Regular Labs Extension Manager config to the update sites
if (
RL_Document::isClient('site')
|| JFactory::getApplication()->input->get('option') != 'com_config'
|| JFactory::getApplication()->input->get('task') != 'config.save.component.apply'
|| JFactory::getApplication()->input->get('component') != 'com_regularlabsmanager'
)
{
return;
}
$form = JFactory::getApplication()->input->post->get('jform', [], 'array');
if ( ! isset($form['key']))
{
return;
}
$key = $form['key'];
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->update('#__update_sites')
->set($db->quoteName('extra_query') . ' = ' . $db->quote('k=' . $key))
->where($db->quoteName('location') . ' LIKE ' . $db->quote('%download.regularlabs.com%'));
$db->setQuery($query);
$db->execute();
}
}

View File

@ -0,0 +1,33 @@
<?php
/**
* @package Regular Labs Library
* @version 24.11.1459
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
namespace RegularLabs\Plugin\System\RegularLabs;
defined('_JEXEC') or die;
use RegularLabs\Library\Parameters as RL_Parameters;
class Params
{
protected static $params = null;
public static function get()
{
if ( ! is_null(self::$params))
{
return self::$params;
}
self::$params = RL_Parameters::getPlugin('regularlabs');
return self::$params;
}
}

View File

@ -0,0 +1,146 @@
<?php
/**
* @package Regular Labs Library
* @version 24.11.1459
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
namespace RegularLabs\Plugin\System\RegularLabs;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use RegularLabs\Library\Document as JDocument;
use RegularLabs\Library\Document as RL_Document;
use RegularLabs\Library\Http as RL_Http;
use RegularLabs\Library\Input as RL_Input;
use RegularLabs\Library\RegEx as RL_RegEx;
class QuickPage
{
public static function render()
{
if ( ! RL_Input::getInt('rl_qp', 0))
{
return;
}
$url = RL_Input::getString('url', '');
if ($url)
{
echo RL_Http::getFromServer($url, RL_Input::getInt('timeout', ''));
die;
}
if ( ! self::passClassCheck())
{
die;
}
self::setRequestOptionToContent();
self::setHeaderContentType();
self::loadTemplateAssets();
echo self::getHtml();
die;
}
private static function getHtml()
{
$class = RL_Input::getString('class', '');
$method = RL_Input::getString('method', 'render');
$class = '\\RegularLabs\\' . str_replace('.', '\\', $class);
ob_start();
(new $class)->$method();
$html = ob_get_contents();
ob_end_clean();
RL_Document::setComponentBuffer($html);
$app = new Application;
$app->render();
$html = JFactory::getApplication()->getBody();
$html = RL_RegEx::replace('\s*<link [^>]*href="[^"]*templates/system/[^"]*\.css[^"]*"[^>]*( /)?>', '', $html);
$html = RL_RegEx::replace('(<body [^>]*class=")', '\1rl-popup ', $html);
$html = str_replace('<body>', '<body class="rl-popup"', $html);
return $html;
}
private static function loadTemplateAssets()
{
$app = JFactory::getApplication();
$asset_manager = JDocument::getAssetManager();
$template = $app->getTemplate(true);
$clientId = (int) $app->getClientId();
if ( ! empty($template->parent))
{
$asset_manager->getRegistry()->addTemplateRegistryFile($template->parent, $clientId);
}
$asset_manager->getRegistry()->addTemplateRegistryFile($template->template, $clientId);
}
private static function passClassCheck()
{
$class = RL_Input::getString('class', '');
if ( ! $class)
{
return false;
}
$allowed = [
'Plugin.EditorButton.ArticlesAnywhere.Popup',
'Plugin.EditorButton.ConditionalContent.Popup',
'Plugin.EditorButton.ContentTemplater.Data',
'Plugin.EditorButton.ContentTemplater.Popup',
'Plugin.EditorButton.DummyContent.Popup',
'Plugin.EditorButton.Modals.Popup',
'Plugin.EditorButton.ModulesAnywhere.Popup',
'Plugin.EditorButton.Sliders.data.php',
'Plugin.EditorButton.Sliders.Popup',
'Plugin.EditorButton.Snippets.Popup',
'Plugin.EditorButton.Sourcerer.Popup',
'Plugin.EditorButton.TabsAccordions.Popup',
'Plugin.EditorButton.Tooltips.Popup',
];
return in_array($class, $allowed) !== false;
}
private static function setHeaderContentType()
{
switch (RL_Input::getCmd('format', 'html'))
{
case 'json' :
$format = 'application/json';
break;
default:
case 'html' :
$format = 'text/html';
break;
}
header('Content-Type: ' . $format . '; charset=utf-8');
}
private static function setRequestOptionToContent()
{
$_REQUEST['tmpl'] = 'component';
RL_Input::set('option', 'com_content');
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* @package Regular Labs Library
* @version 24.11.1459
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
namespace RegularLabs\Plugin\System\RegularLabs;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use RegularLabs\Library\Document as RL_Document;
use RegularLabs\Library\Input as RL_Input;
class SearchHelper
{
public static function load()
{
// Only in frontend search component view
if ( ! RL_Document::isClient('site') || RL_Input::getCmd('option') != 'com_search')
{
return;
}
$classes = get_declared_classes();
if (in_array('SearchModelSearch', $classes) || in_array('searchmodelsearch', $classes))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/helpers/search.php';
}
}