Release of v3.2.1-alpha4

Add Joomla powers for namespace dynamic management.
This commit is contained in:
Robot 2024-04-16 19:05:17 +02:00
parent 0be0df5cec
commit 3a48b5596c
Signed by untrusted user: Robot
GPG Key ID: 14DECD44E7E1BB95
101 changed files with 6844 additions and 140 deletions

View File

@ -1,3 +1,7 @@
# v3.2.1-alpha4
- Add Joomla powers for namespace dynamic management.
# v3.2.1-alpha3 # v3.2.1-alpha3
- Fix plugin code display when methods and properties are missing. - Fix plugin code display when methods and properties are missing.

View File

@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have! Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have!
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.2.1-alpha3) with **ALL** its features and **ALL** concepts totally open-source and free! You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.2.1-alpha4) with **ALL** its features and **ALL** concepts totally open-source and free!
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45) > Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
@ -144,14 +144,14 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder) + *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 9th April, 2024 + *Last Build*: 16th April, 2024
+ *Version*: 3.2.1-alpha3 + *Version*: 3.2.1-alpha4
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **739813** + *Line count*: **752849**
+ *Field count*: **2080** + *Field count*: **2095**
+ *File count*: **5214** + *File count*: **5361**
+ *Folder count*: **459** + *Folder count*: **470**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com). > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).
> Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io) > Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io)

View File

@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have! Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have!
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.2.1-alpha3) with **ALL** its features and **ALL** concepts totally open-source and free! You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.2.1-alpha4) with **ALL** its features and **ALL** concepts totally open-source and free!
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45) > Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
@ -144,14 +144,14 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder) + *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 9th April, 2024 + *Last Build*: 16th April, 2024
+ *Version*: 3.2.1-alpha3 + *Version*: 3.2.1-alpha4
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **739813** + *Line count*: **752849**
+ *Field count*: **2080** + *Field count*: **2095**
+ *File count*: **5214** + *File count*: **5361**
+ *Folder count*: **459** + *Folder count*: **470**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com). > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).
> Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io) > Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io)

View File

@ -418,6 +418,19 @@
<action name="joomla_plugin_updates.edit.own" title="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_OWN" description="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_OWN_DESC" /> <action name="joomla_plugin_updates.edit.own" title="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_OWN" description="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_OWN_DESC" />
<action name="joomla_plugin_updates.edit.state" title="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_STATE" description="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_STATE_DESC" /> <action name="joomla_plugin_updates.edit.state" title="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_STATE" description="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_STATE_DESC" />
<action name="joomla_plugin_updates.version" title="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_VERSION" description="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_VERSION_DESC" /> <action name="joomla_plugin_updates.version" title="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_VERSION" description="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_VERSION_DESC" />
<action name="joomla_power.init" title="COM_COMPONENTBUILDER_JOOMLA_POWER_INIT_BUTTON_ACCESS" description="COM_COMPONENTBUILDER_JOOMLA_POWER_INIT_BUTTON_ACCESS_DESC" />
<action name="joomla_power.reset" title="COM_COMPONENTBUILDER_JOOMLA_POWER_RESET_BUTTON_ACCESS" description="COM_COMPONENTBUILDER_JOOMLA_POWER_RESET_BUTTON_ACCESS_DESC" />
<action name="joomla_power.access" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_ACCESS" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_ACCESS_DESC" />
<action name="joomla_power.batch" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_BATCH_USE" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_BATCH_USE_DESC" />
<action name="joomla_power.create" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_CREATE" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_CREATE_DESC" />
<action name="joomla_power.delete" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_DELETE" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_DELETE_DESC" />
<action name="joomla_power.edit" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_DESC" />
<action name="joomla_power.edit.created_by" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_CREATED_BY" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_CREATED_BY_DESC" />
<action name="joomla_power.edit.created" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_CREATED_DATE" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_CREATED_DATE_DESC" />
<action name="joomla_power.edit.own" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_OWN" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_OWN_DESC" />
<action name="joomla_power.edit.state" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_STATE" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_STATE_DESC" />
<action name="joomla_power.version" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_VERSION" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_VERSION_DESC" />
<action name="joomla_power.submenu" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_SUBMENU" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_SUBMENU_DESC" />
<action name="language.build" title="COM_COMPONENTBUILDER_LANGUAGE_BUILD_BUTTON_ACCESS" description="COM_COMPONENTBUILDER_LANGUAGE_BUILD_BUTTON_ACCESS_DESC" /> <action name="language.build" title="COM_COMPONENTBUILDER_LANGUAGE_BUILD_BUTTON_ACCESS" description="COM_COMPONENTBUILDER_LANGUAGE_BUILD_BUTTON_ACCESS_DESC" />
<action name="language_translation.access" title="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_ACCESS" description="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_ACCESS_DESC" /> <action name="language_translation.access" title="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_ACCESS" description="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_ACCESS_DESC" />
<action name="language_translation.batch" title="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_BATCH_USE" description="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_BATCH_USE_DESC" /> <action name="language_translation.batch" title="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_BATCH_USE" description="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_BATCH_USE_DESC" />
@ -607,6 +620,17 @@
<action name="joomla_plugin.access" title="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_ACCESS" description="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_ACCESS_DESC" /> <action name="joomla_plugin.access" title="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_ACCESS" description="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_ACCESS_DESC" />
<action name="joomla_plugin.version" title="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_EDIT_VERSION" description="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_EDIT_VERSION_DESC" /> <action name="joomla_plugin.version" title="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_EDIT_VERSION" description="COM_COMPONENTBUILDER_JOOMLA_PLUGINS_EDIT_VERSION_DESC" />
</section> </section>
<section name="joomla_power">
<action name="joomla_power.edit" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_DESC" />
<action name="joomla_power.edit.own" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_OWN" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_OWN_DESC" />
<action name="joomla_power.edit.state" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_STATE" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_STATE_DESC" />
<action name="joomla_power.edit.created_by" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_CREATED_BY" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_CREATED_BY_DESC" />
<action name="joomla_power.edit.created" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_CREATED_DATE" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_CREATED_DATE_DESC" />
<action name="joomla_power.create" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_CREATE" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_CREATE_DESC" />
<action name="joomla_power.delete" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_DELETE" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_DELETE_DESC" />
<action name="joomla_power.access" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_ACCESS" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_ACCESS_DESC" />
<action name="joomla_power.version" title="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_VERSION" description="COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_VERSION_DESC" />
</section>
<section name="power"> <section name="power">
<action name="power.edit" title="COM_COMPONENTBUILDER_POWERS_EDIT" description="COM_COMPONENTBUILDER_POWERS_EDIT_DESC" /> <action name="power.edit" title="COM_COMPONENTBUILDER_POWERS_EDIT" description="COM_COMPONENTBUILDER_POWERS_EDIT_DESC" />
<action name="power.edit.own" title="COM_COMPONENTBUILDER_POWERS_EDIT_OWN" description="COM_COMPONENTBUILDER_POWERS_EDIT_OWN_DESC" /> <action name="power.edit.own" title="COM_COMPONENTBUILDER_POWERS_EDIT_OWN" description="COM_COMPONENTBUILDER_POWERS_EDIT_OWN_DESC" />

View File

@ -0,0 +1,13 @@
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/* CSS Document */

View File

@ -0,0 +1,13 @@
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/* CSS Document */

View File

@ -23,7 +23,60 @@ if (file_exists($composer_autoloader))
\spl_autoload_register(function ($class) { \spl_autoload_register(function ($class) {
// project-specific base directories and namespace prefix // project-specific base directories and namespace prefix
$search = [ $search = [
'libraries/vendor_jcb/VDM.Joomla.Openai' => 'VDM\\Joomla\\Openai', 'libraries/vendor_jcb/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea',
'libraries/vendor_jcb/VDM.Joomla.FOF' => 'VDM\\Joomla\\FOF',
'libraries/vendor_jcb/VDM.Joomla' => 'VDM\\Joomla',
'libraries/vendor_jcb/VDM.Minify' => 'VDM\\Minify',
'libraries/vendor_jcb/VDM.Psr' => 'VDM\\Psr'
];
// Start the search and load if found
$found = false;
$found_base_dir = "";
$found_len = 0;
foreach ($search as $base_dir => $prefix)
{
// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) === 0)
{
// we have a match so load the values
$found = true;
$found_base_dir = $base_dir;
$found_len = $len;
// done here
break;
}
}
// check if we found a match
if (!$found)
{
// not found so move to the next registered autoloader
return;
}
// get the relative class name
$relative_class = substr($class, $found_len);
// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = JPATH_ROOT . '/' . $found_base_dir . '/src' . str_replace('\\', '/', $relative_class) . '.php';
// if the file exists, require it
if (file_exists($file))
{
require $file;
}
});
// add the autoloader for the composer classes
$composer_autoloader = JPATH_LIBRARIES . '/phpseclib3/vendor/autoload.php';
if (file_exists($composer_autoloader))
{
require_once $composer_autoloader;
}
// register additional namespace
\spl_autoload_register(function ($class) {
// project-specific base directories and namespace prefix
$search = [
'libraries/vendor_jcb/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea', 'libraries/vendor_jcb/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea',
'libraries/vendor_jcb/VDM.Joomla.FOF' => 'VDM\\Joomla\\FOF', 'libraries/vendor_jcb/VDM.Joomla.FOF' => 'VDM\\Joomla\\FOF',
'libraries/vendor_jcb/VDM.Joomla' => 'VDM\\Joomla', 'libraries/vendor_jcb/VDM.Joomla' => 'VDM\\Joomla',

View File

@ -695,8 +695,6 @@
name="super_power_custom_config" name="super_power_custom_config"
label="COM_COMPONENTBUILDER_CONFIG_SUPER_POWER"> label="COM_COMPONENTBUILDER_CONFIG_SUPER_POWER">
<!-- Note_not_ready_super_powers Field. Type: Note. A None Database Field. (joomla) -->
<field type="note" name="note_not_ready_super_powers" label="COM_COMPONENTBUILDER_CONFIG_NOTE_NOT_READY_SUPER_POWERS_LABEL" heading="h2" class="alert alert-error note_not_ready_super_powers" />
<!-- Super_powers_documentation Field. Type: Radio. (joomla) --> <!-- Super_powers_documentation Field. Type: Radio. (joomla) -->
<field <field
type="radio" type="radio"

View File

@ -100,6 +100,7 @@ class ComponentbuilderController extends BaseController
'joomla_component' => 'joomla_components', 'joomla_component' => 'joomla_components',
'joomla_module' => 'joomla_modules', 'joomla_module' => 'joomla_modules',
'joomla_plugin' => 'joomla_plugins', 'joomla_plugin' => 'joomla_plugins',
'joomla_power' => 'joomla_powers',
'power' => 'powers', 'power' => 'powers',
'admin_view' => 'admin_views', 'admin_view' => 'admin_views',
'custom_admin_view' => 'custom_admin_views', 'custom_admin_view' => 'custom_admin_views',

View File

@ -0,0 +1,386 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\FormController;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Uri\Uri;
use VDM\Joomla\Componentbuilder\JoomlaPower\Factory as JoomlaPowerFactory;
/**
* Joomla_power Form Controller
*/
class ComponentbuilderControllerJoomla_power extends FormController
{
/**
* Current or most recently performed task.
*
* @var string
* @since 12.2
* @note Replaces _task.
*/
protected $task;
/**
* Class constructor.
*
* @param array $config A named array of configuration variables.
*
* @since 1.6
*/
public function __construct($config = [])
{
$this->view_list = 'Joomla_powers'; // safeguard for setting the return view listing to the main view.
parent::__construct($config);
}
public function resetPowers()
{
// Check for request forgeries
Session::checkToken() or die(Text::_('JINVALID_TOKEN'));
// get Item posted
$item = $this->input->post->get('jform', array(), 'array');
// check if user has the right
$user = Factory::getUser();
// set default error message
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_PERMISSION_DENIED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RESET_THIS_JOOMLA_POWER') . '</p>';
$status = 'error';
$success = false;
// load the ID
$id = $item['id'] ?? null;
$guid = $item['guid'] ?? null;
// check if there is any selections
if ($id === null || $guid === null)
{
// set error message
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_NOT_SAVED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_YOU_MUST_FIRST_SAVE_THE_JOOMLA_POWER_BEFORE_YOU_CAN_USE_THIS_FEATURE') . '</p>';
}
elseif($user->authorise('power.reset', 'com_componentbuilder'))
{
if (JoomlaPowerFactory::_('Joomlapower')->reset([$guid]))
{
// set success message
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_SUCCESS').'</h1>';
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_THE_JOOMLA_POWER_HAS_SUCCESSFULLY_BEEN_RESET').'</p>';
$status = 'success';
$success = true;
}
else
{
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_RESET_FAILED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THIS_JOOMLA_POWER_HAS_FAILED') . '</p>';
}
}
// set redirect
$redirect_url = Route::_(
'index.php?option=com_componentbuilder&view=joomla_power'
. $this->getRedirectToItemAppend($id), $success
);
$this->setRedirect($redirect_url, $message, $status);
return $success;
}
/**
* Method override to check if you can add a new record.
*
* @param array $data An array of input data.
*
* @return boolean
*
* @since 1.6
*/
protected function allowAdd($data = [])
{
// Get user object.
$user = Factory::getUser();
// Access check.
$access = $user->authorise('joomla_power.access', 'com_componentbuilder');
if (!$access)
{
return false;
}
// In the absence of better information, revert to the component permissions.
return $user->authorise('joomla_power.create', $this->option);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
*
* @since 1.6
*/
protected function allowEdit($data = [], $key = 'id')
{
// get user object.
$user = Factory::getUser();
// get record id.
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
// Access check.
$access = ($user->authorise('joomla_power.access', 'com_componentbuilder.joomla_power.' . (int) $recordId) && $user->authorise('joomla_power.access', 'com_componentbuilder'));
if (!$access)
{
return false;
}
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('joomla_power.edit', 'com_componentbuilder.joomla_power.' . (int) $recordId);
if (!$permission)
{
if ($user->authorise('joomla_power.edit.own', 'com_componentbuilder.joomla_power.' . $recordId))
{
// Now test the owner is the user.
$ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0;
if (empty($ownerId))
{
// Need to do a lookup from the model.
$record = $this->getModel()->getItem($recordId);
if (empty($record))
{
return false;
}
$ownerId = $record->created_by;
}
// If the owner matches 'me' then allow.
if ($ownerId == $user->id)
{
if ($user->authorise('joomla_power.edit.own', 'com_componentbuilder'))
{
return true;
}
}
}
return false;
}
}
// Since there is no permission, revert to the component permissions.
return $user->authorise('joomla_power.edit', $this->option);
}
/**
* Gets the URL arguments to append to an item redirect.
*
* @param integer $recordId The primary key id for the item.
* @param string $urlVar The name of the URL variable for the id.
*
* @return string The arguments to append to the redirect URL.
*
* @since 1.6
*/
protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id')
{
// get the referral options (old method use return instead see parent)
$ref = $this->input->get('ref', 0, 'string');
$refid = $this->input->get('refid', 0, 'int');
// get redirect info.
$append = parent::getRedirectToItemAppend($recordId, $urlVar);
// set the referral options
if ($refid && $ref)
{
$append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append;
}
elseif ($ref)
{
$append = '&ref='. (string) $ref . $append;
}
return $append;
}
/**
* Method to run batch operations.
*
* @param object $model The model.
*
* @return boolean True if successful, false otherwise and internal error is set.
*
* @since 2.5
*/
public function batch($model = null)
{
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
// Set the model
$model = $this->getModel('Joomla_power', '', []);
// Preset the redirect
$this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_powers' . $this->getRedirectToListAppend(), false));
return parent::batch($model);
}
/**
* Method to cancel an edit.
*
* @param string $key The name of the primary key of the URL variable.
*
* @return boolean True if access level checks pass, false otherwise.
*
* @since 12.2
*/
public function cancel($key = null)
{
// get the referral options
$this->ref = $this->input->get('ref', 0, 'word');
$this->refid = $this->input->get('refid', 0, 'int');
// Check if there is a return value
$return = $this->input->get('return', null, 'base64');
$cancel = parent::cancel($key);
if (!is_null($return) && Uri::isInternal(base64_decode($return)))
{
$redirect = base64_decode($return);
// Redirect to the return value.
$this->setRedirect(
Route::_(
$redirect, false
)
);
}
elseif ($this->refid && $this->ref)
{
$redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid;
// Redirect to the item screen.
$this->setRedirect(
Route::_(
'index.php?option=' . $this->option . $redirect, false
)
);
}
elseif ($this->ref)
{
$redirect = '&view='.(string)$this->ref;
// Redirect to the list screen.
$this->setRedirect(
Route::_(
'index.php?option=' . $this->option . $redirect, false
)
);
}
return $cancel;
}
/**
* Method to save a record.
*
* @param string $key The name of the primary key of the URL variable.
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
*
* @return boolean True if successful, false otherwise.
*
* @since 12.2
*/
public function save($key = null, $urlVar = null)
{
// get the referral options
$this->ref = $this->input->get('ref', 0, 'word');
$this->refid = $this->input->get('refid', 0, 'int');
// Check if there is a return value
$return = $this->input->get('return', null, 'base64');
$canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return)));
if ($this->ref || $this->refid || $canReturn)
{
// to make sure the item is checkedin on redirect
$this->task = 'save';
}
$saved = parent::save($key, $urlVar);
// This is not needed since parent save already does this
// Due to the ref and refid implementation we need to add this
if ($canReturn)
{
$redirect = base64_decode($return);
// Redirect to the return value.
$this->setRedirect(
Route::_(
$redirect, false
)
);
}
elseif ($this->refid && $this->ref)
{
$redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid;
// Redirect to the item screen.
$this->setRedirect(
Route::_(
'index.php?option=' . $this->option . $redirect, false
)
);
}
elseif ($this->ref)
{
$redirect = '&view=' . (string) $this->ref;
// Redirect to the list screen.
$this->setRedirect(
Route::_(
'index.php?option=' . $this->option . $redirect, false
)
);
}
return $saved;
}
/**
* Function that allows child controller access to model data
* after the data has been saved.
*
* @param BaseDatabaseModel &$model The data model object.
* @param array $validData The validated data.
*
* @return void
*
* @since 11.1
*/
protected function postSaveHook(BaseDatabaseModel $model, $validData = [])
{
return;
}
}

View File

@ -0,0 +1,150 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\AdminController;
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
use VDM\Joomla\Componentbuilder\JoomlaPower\Factory as JoomlaPowerFactory;
use VDM\Joomla\Utilities\GetHelper;
/**
* Joomla_powers Admin Controller
*/
class ComponentbuilderControllerJoomla_powers extends AdminController
{
/**
* The prefix to use with controller messages.
*
* @var string
* @since 1.6
*/
protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_POWERS';
/**
* Method to get a model object, loading it if required.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JModelLegacy The model.
*
* @since 1.6
*/
public function getModel($name = 'Joomla_power', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true))
{
return parent::getModel($name, $prefix, $config);
}
public function initPowers()
{
// Check for request forgeries
Session::checkToken() or die(Text::_('JINVALID_TOKEN'));
// check if user has the right
$user = Factory::getUser();
// set default error message
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_PERMISSION_DENIED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_INITIALIZE_JOOMLA_POWERS') . '</p>';
$status = 'error';
$success = false;
if($user->authorise('power.init', 'com_componentbuilder'))
{
if (JoomlaPowerFactory::_('Joomlapower')->init())
{
// set success message
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_SUCCESSFULLY_INITIALIZED_ALL_REMOTE_JOOMLA_POWERS') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_LOCAL_DATABASE_JOOMLA_POWERS_HAS_SUCCESSFULLY_BEEN_SYNCED_WITH_THE_REMOTE_REPOSITORIES') . '</p>';
$status = 'success';
$success = true;
}
else
{
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_INITIALIZATION_FAILED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_INITIALIZATION_OF_THIS_JOOMLA_POWERS_HAS_FAILED') . '</p>';
}
}
// set redirect
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=joomla_powers', $success);
$this->setRedirect($redirect_url, $message, $status);
return $success;
}
public function resetPowers()
{
// Check for request forgeries
Session::checkToken() or die(Text::_('JINVALID_TOKEN'));
// get IDS of the selected powers
$pks = $this->input->post->get('cid', [], 'array');
// Sanitize the input
ArrayHelper::toInteger($pks);
// check if there is any selections
if ($pks === [])
{
// set error message
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_NO_SELECTION_DETECTED').'</h1>';
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_PLEASE_FIRST_MAKE_A_SELECTION_FROM_THE_LIST').'</p>';
// set redirect
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=joomla_powers', false);
$this->setRedirect($redirect_url, $message, 'error');
return false;
}
$status = 'error';
$success = false;
// check if user has the right
$user = Factory::getUser();
if($user->authorise('power.reset', 'com_componentbuilder'))
{
$guids = GetHelper::vars('joomla_power', $pks, 'id', 'guid');
if (JoomlaPowerFactory::_('Joomlapower')->reset($guids))
{
// set success message
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_SUCCESS').'</h1>';
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_THESE_JOOMLA_POWERS_HAVE_SUCCESSFULLY_BEEN_RESET').'</p>';
$status = 'success';
$success = true;
}
else
{
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_RESET_FAILED') . '</h1>';
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THESE_JOOMLA_POWERS_HAS_FAILED') . '</p>';
}
// set redirect
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=joomla_powers', $success);
$this->setRedirect($redirect_url, $message, $status);
return $success;
}
// set redirect
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=joomla_powers', false);
$this->setRedirect($redirect_url);
return $success;
}
}

View File

@ -23,7 +23,60 @@ if (file_exists($composer_autoloader))
\spl_autoload_register(function ($class) { \spl_autoload_register(function ($class) {
// project-specific base directories and namespace prefix // project-specific base directories and namespace prefix
$search = [ $search = [
'libraries/vendor_jcb/VDM.Joomla.Openai' => 'VDM\\Joomla\\Openai', 'libraries/vendor_jcb/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea',
'libraries/vendor_jcb/VDM.Joomla.FOF' => 'VDM\\Joomla\\FOF',
'libraries/vendor_jcb/VDM.Joomla' => 'VDM\\Joomla',
'libraries/vendor_jcb/VDM.Minify' => 'VDM\\Minify',
'libraries/vendor_jcb/VDM.Psr' => 'VDM\\Psr'
];
// Start the search and load if found
$found = false;
$found_base_dir = "";
$found_len = 0;
foreach ($search as $base_dir => $prefix)
{
// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) === 0)
{
// we have a match so load the values
$found = true;
$found_base_dir = $base_dir;
$found_len = $len;
// done here
break;
}
}
// check if we found a match
if (!$found)
{
// not found so move to the next registered autoloader
return;
}
// get the relative class name
$relative_class = substr($class, $found_len);
// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = JPATH_ROOT . '/' . $found_base_dir . '/src' . str_replace('\\', '/', $relative_class) . '.php';
// if the file exists, require it
if (file_exists($file))
{
require $file;
}
});
// add the autoloader for the composer classes
$composer_autoloader = JPATH_LIBRARIES . '/phpseclib3/vendor/autoload.php';
if (file_exists($composer_autoloader))
{
require_once $composer_autoloader;
}
// register additional namespace
\spl_autoload_register(function ($class) {
// project-specific base directories and namespace prefix
$search = [
'libraries/vendor_jcb/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea', 'libraries/vendor_jcb/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea',
'libraries/vendor_jcb/VDM.Joomla.FOF' => 'VDM\\Joomla\\FOF', 'libraries/vendor_jcb/VDM.Joomla.FOF' => 'VDM\\Joomla\\FOF',
'libraries/vendor_jcb/VDM.Joomla' => 'VDM\\Joomla', 'libraries/vendor_jcb/VDM.Joomla' => 'VDM\\Joomla',
@ -6136,6 +6189,10 @@ abstract class ComponentbuilderHelper
{ {
\JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_JOOMLA_PLUGINS'), 'index.php?option=com_componentbuilder&view=joomla_plugins', $submenu === 'joomla_plugins'); \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_JOOMLA_PLUGINS'), 'index.php?option=com_componentbuilder&view=joomla_plugins', $submenu === 'joomla_plugins');
} }
if ($user->authorise('joomla_power.access', 'com_componentbuilder') && $user->authorise('joomla_power.submenu', 'com_componentbuilder'))
{
\JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_JOOMLA_POWERS'), 'index.php?option=com_componentbuilder&view=joomla_powers', $submenu === 'joomla_powers');
}
if ($user->authorise('power.access', 'com_componentbuilder') && $user->authorise('power.submenu', 'com_componentbuilder')) if ($user->authorise('power.access', 'com_componentbuilder') && $user->authorise('power.submenu', 'com_componentbuilder'))
{ {
\JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_POWERS'), 'index.php?option=com_componentbuilder&view=powers', $submenu === 'powers'); \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_POWERS'), 'index.php?option=com_componentbuilder&view=powers', $submenu === 'powers');

File diff suppressed because one or more lines are too long

View File

@ -826,6 +826,32 @@ COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PROPERTIES_BUTTON_ACCESS="Joomla Plugin Prope
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PROPERTIES_BUTTON_ACCESS_DESC="Allows the users in this group to access the properties button." COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PROPERTIES_BUTTON_ACCESS_DESC="Allows the users in this group to access the properties button."
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_RUN_EXPANSION_BUTTON_ACCESS="Joomla Plugin Run Expansion Button Access" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_RUN_EXPANSION_BUTTON_ACCESS="Joomla Plugin Run Expansion Button Access"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_RUN_EXPANSION_BUTTON_ACCESS_DESC="Allows the users in this group to access the run expansion button." COM_COMPONENTBUILDER_JOOMLA_PLUGIN_RUN_EXPANSION_BUTTON_ACCESS_DESC="Allows the users in this group to access the run expansion button."
COM_COMPONENTBUILDER_JOOMLA_POWERS_ACCESS="Joomla Powers Access"
COM_COMPONENTBUILDER_JOOMLA_POWERS_ACCESS_DESC="Allows the users in this group to access access joomla powers"
COM_COMPONENTBUILDER_JOOMLA_POWERS_BATCH_USE="Joomla Powers Batch Use"
COM_COMPONENTBUILDER_JOOMLA_POWERS_BATCH_USE_DESC="Allows the users in this group to use batch copy/update method of batch joomla powers"
COM_COMPONENTBUILDER_JOOMLA_POWERS_CREATE="Joomla Powers Create"
COM_COMPONENTBUILDER_JOOMLA_POWERS_CREATE_DESC="Allows the users in this group to create create joomla powers"
COM_COMPONENTBUILDER_JOOMLA_POWERS_DELETE="Joomla Powers Delete"
COM_COMPONENTBUILDER_JOOMLA_POWERS_DELETE_DESC="Allows the users in this group to delete delete joomla powers"
COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT="Joomla Powers Edit"
COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_CREATED_BY="Joomla Powers Edit Created By"
COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by joomla powers"
COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_CREATED_DATE="Joomla Powers Edit Created Date"
COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created joomla powers"
COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_DESC="Allows the users in this group to edit the joomla power"
COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_OWN="Joomla Powers Edit Own"
COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_OWN_DESC="Allows the users in this group to edit edit own joomla powers created by them"
COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_STATE="Joomla Powers Edit State"
COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_STATE_DESC="Allows the users in this group to update the state of the joomla power"
COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_VERSION="Joomla Powers Edit Version"
COM_COMPONENTBUILDER_JOOMLA_POWERS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version joomla powers"
COM_COMPONENTBUILDER_JOOMLA_POWERS_SUBMENU="Joomla Powers Submenu"
COM_COMPONENTBUILDER_JOOMLA_POWERS_SUBMENU_DESC="Allows the users in this group to submenu of joomla power"
COM_COMPONENTBUILDER_JOOMLA_POWER_INIT_BUTTON_ACCESS="Joomla Power Init Button Access"
COM_COMPONENTBUILDER_JOOMLA_POWER_INIT_BUTTON_ACCESS_DESC="Allows the users in this group to access the init button."
COM_COMPONENTBUILDER_JOOMLA_POWER_RESET_BUTTON_ACCESS="Joomla Power Reset Button Access"
COM_COMPONENTBUILDER_JOOMLA_POWER_RESET_BUTTON_ACCESS_DESC="Allows the users in this group to access the reset button."
COM_COMPONENTBUILDER_LANGUAGES_ACCESS="Languages Access" COM_COMPONENTBUILDER_LANGUAGES_ACCESS="Languages Access"
COM_COMPONENTBUILDER_LANGUAGES_ACCESS_DESC="Allows the users in this group to access access languages" COM_COMPONENTBUILDER_LANGUAGES_ACCESS_DESC="Allows the users in this group to access access languages"
COM_COMPONENTBUILDER_LANGUAGES_BATCH_USE="Languages Batch Use" COM_COMPONENTBUILDER_LANGUAGES_BATCH_USE="Languages Batch Use"
@ -974,6 +1000,7 @@ COM_COMPONENTBUILDER_MENU_HELP_DOCUMENTS="Help Documents"
COM_COMPONENTBUILDER_MENU_JOOMLA_COMPONENTS="Joomla Components" COM_COMPONENTBUILDER_MENU_JOOMLA_COMPONENTS="Joomla Components"
COM_COMPONENTBUILDER_MENU_JOOMLA_MODULES="Joomla Modules" COM_COMPONENTBUILDER_MENU_JOOMLA_MODULES="Joomla Modules"
COM_COMPONENTBUILDER_MENU_JOOMLA_PLUGINS="Joomla Plugins" COM_COMPONENTBUILDER_MENU_JOOMLA_PLUGINS="Joomla Plugins"
COM_COMPONENTBUILDER_MENU_JOOMLA_POWERS="Joomla Powers"
COM_COMPONENTBUILDER_MENU_LANGUAGE_TRANSLATIONS="Language Translations" COM_COMPONENTBUILDER_MENU_LANGUAGE_TRANSLATIONS="Language Translations"
COM_COMPONENTBUILDER_MENU_LAYOUTS="Layouts" COM_COMPONENTBUILDER_MENU_LAYOUTS="Layouts"
COM_COMPONENTBUILDER_MENU_LIBRARIES="Libraries" COM_COMPONENTBUILDER_MENU_LIBRARIES="Libraries"

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,44 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// get the form
$form = $displayData->getForm();
// get the layout fields override method name (from layout path/ID)
$layout_path_array = explode('.', $this->getLayoutId());
// Since we cannot pass the layout and tab names as parameters to the model method
// this name combination of tab and layout in the method name is the only work around
// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name.
// example of layout name: details_left.php
// example of method name: getFields_details_left()
$fields_tab_layout = 'fields_' . $layout_path_array[1];
// get the fields
$fields = $displayData->get($fields_tab_layout) ?: array(
'system_name'
);
$hiddenFields = $displayData->get('hidden_fields') ?: [];
?>
<?php if ($fields && count((array) $fields)) :?>
<div class="form-inline form-inline-header">
<?php foreach($fields as $field): ?>
<?php if (in_array($field, $hiddenFields)) : ?>
<?php $form->setFieldAttribute($field, 'type', 'hidden'); ?>
<?php endif; ?>
<?php echo $form->renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
<?php endforeach; ?>
</div>
<?php endif; ?>

View File

@ -0,0 +1,45 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// get the form
$form = $displayData->getForm();
// get the layout fields override method name (from layout path/ID)
$layout_path_array = explode('.', $this->getLayoutId());
// Since we cannot pass the layout and tab names as parameters to the model method
// this name combination of tab and layout in the method name is the only work around
// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name.
// example of layout name: details_left.php
// example of method name: getFields_details_left()
$fields_tab_layout = 'fields_' . $layout_path_array[1];
// get the fields
$fields = $displayData->get($fields_tab_layout) ?: array(
'description',
'settings'
);
$hiddenFields = $displayData->get('hidden_fields') ?: [];
?>
<?php if ($fields && count((array) $fields)) :?>
<div class="form-vertical">
<?php foreach($fields as $field): ?>
<?php if (in_array($field, $hiddenFields)) : ?>
<?php $form->setFieldAttribute($field, 'type', 'hidden'); ?>
<?php endif; ?>
<?php echo $form->renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
<?php endforeach; ?>
</div>
<?php endif; ?>

View File

@ -0,0 +1,47 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// get the form
$form = $displayData->getForm();
// get the layout fields override method name (from layout path/ID)
$layout_path_array = explode('.', $this->getLayoutId());
// Since we cannot pass the layout and tab names as parameters to the model method
// this name combination of tab and layout in the method name is the only work around
// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name.
// example of layout name: details_left.php
// example of method name: getFields_details_left()
$fields_tab_layout = 'fields_' . $layout_path_array[1];
// get the fields
$fields = $displayData->get($fields_tab_layout) ?: array(
'guid',
'title',
'created',
'created_by',
'modified',
'modified_by'
);
$hiddenFields = $displayData->get('hidden_fields') ?: [];
?>
<?php if ($fields && count((array) $fields)) :?>
<?php foreach($fields as $field): ?>
<?php if (in_array($field, $hiddenFields)) : ?>
<?php $form->setFieldAttribute($field, 'type', 'hidden'); ?>
<?php endif; ?>
<?php echo $form->renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
<?php endforeach; ?>
<?php endif; ?>

View File

@ -0,0 +1,47 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// get the form
$form = $displayData->getForm();
// get the layout fields override method name (from layout path/ID)
$layout_path_array = explode('.', $this->getLayoutId());
// Since we cannot pass the layout and tab names as parameters to the model method
// this name combination of tab and layout in the method name is the only work around
// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name.
// example of layout name: details_left.php
// example of method name: getFields_details_left()
$fields_tab_layout = 'fields_' . $layout_path_array[1];
// get the fields
$fields = $displayData->get($fields_tab_layout) ?: array(
'published',
'ordering',
'access',
'version',
'hits',
'id'
);
$hiddenFields = $displayData->get('hidden_fields') ?: [];
?>
<?php if ($fields && count((array) $fields)) :?>
<?php foreach($fields as $field): ?>
<?php if (in_array($field, $hiddenFields)) : ?>
<?php $form->setFieldAttribute($field, 'type', 'hidden'); ?>
<?php endif; ?>
<?php echo $form->renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
<?php endforeach; ?>
<?php endif; ?>

View File

@ -314,34 +314,47 @@ class ComponentbuilderModelAjax extends ListModel
// do we have tags returned // do we have tags returned
if (isset($tags[0]) && isset($tags[0]->name)) if (isset($tags[0]) && isset($tags[0]->name))
{ {
// get the version // get the local version
$manifest = ComponentbuilderHelper::manifest(); $manifest = ComponentbuilderHelper::manifest();
$local_version = (string) $manifest->version; $local_version = (string) $manifest->version;
$current_version = trim($tags[0]->name, 'vV'); $latest_version = '1.0.0';
$download_link = "https://git.vdm.dev/api/v1/joomla/Component-Builder";
// Filter tags by major version matching the local version's major number
$major_version = explode('.', $local_version)[0];
$filtered_tags = array_filter($tags, function($tag) use ($major_version) {
return strpos($tag->name, "v$major_version") === 0;
});
if (!empty($filtered_tags))
{
// Sort versions to find the latest one
usort($filtered_tags, function($a, $b) {
return \version_compare($b->name, $a->name);
});
$latest_version = trim($filtered_tags[0]->name, 'vV');
// download link of the latest version
$download_link = $filtered_tags[0]->zipball_url;
}
// now check if this version is out dated // now check if this version is out dated
if ($current_version === $local_version) if (\version_compare($local_version, $latest_version) === 0)
{ {
return ['notice' => '<small><span style="color:green;"><span class="icon-shield"></span>&nbsp;' . Text::_('COM_COMPONENTBUILDER_UP_TO_DATE') . '</span></small>']; return ['notice' => '<small><span style="color:green;"><span class="icon-shield"></span>&nbsp;' . Text::_('COM_COMPONENTBUILDER_UP_TO_DATE') . '</span></small>'];
} }
else else
{ {
// check if this is beta version // check if this is beta version
$current_array = array_map(function ($v) { return (int) $v; }, (array) explode('.', $current_version)); if (\version_compare($local_version, $latest_version) > 0)
$local_array = array_map(function ($v) { return (int) $v; }, (array) explode('.', $local_version));
if (($local_array[0] > $current_array[0]) ||
($local_array[0] == $current_array[0] && $local_array[1] > $current_array[1]) ||
($local_array[0] == $current_array[0] && $local_array[1] == $current_array[1] && $local_array[2] > $current_array[2]))
{ {
return ['notice' => '<small><span style="color:#F7B033;"><span class="icon-wrench"></span>&nbsp;' . Text::_('COM_COMPONENTBUILDER_PRE_RELEASE') . '</span></small>']; return ['notice' => '<small><span style="color:#F7B033;"><span class="icon-wrench"></span>&nbsp;' . Text::_('COM_COMPONENTBUILDER_PRE_RELEASE') . '</span></small>'];
} }
else else
{ {
// download link of the latest version
$download = "https://git.vdm.dev/api/v1/repos/joomla/Component-Builder/archive/" . $tags[0]->name . ".zip";
return ['notice' => '<small><span style="color:red;"><span class="icon-warning-circle"></span>&nbsp;' . Text::_('COM_COMPONENTBUILDER_OUT_OF_DATE') . '!</span> <a style="color:green;" href="' . return ['notice' => '<small><span style="color:red;"><span class="icon-warning-circle"></span>&nbsp;' . Text::_('COM_COMPONENTBUILDER_OUT_OF_DATE') . '!</span> <a style="color:green;" href="' .
$download . '" title="' . Text::_('COM_COMPONENTBUILDER_YOU_CAN_DIRECTLY_DOWNLOAD_THE_LATEST_UPDATE_OR_USE_THE_JOOMLA_UPDATE_AREA') . '">' . Text::_('COM_COMPONENTBUILDER_DOWNLOAD_UPDATE') . '!</a></small>']; $download_link . '" title="' . Text::_('COM_COMPONENTBUILDER_YOU_CAN_DIRECTLY_DOWNLOAD_THE_LATEST_UPDATE_OR_USE_THE_JOOMLA_UPDATE_AREA') . '">' . Text::_('COM_COMPONENTBUILDER_DOWNLOAD_UPDATE') . '!</a></small>'];
} }
} }
} }

View File

@ -63,6 +63,10 @@ class ComponentbuilderModelComponentbuilder extends ListModel
'joomla_plugin.access' => 'joomla_plugin.access', 'joomla_plugin.access' => 'joomla_plugin.access',
'joomla_plugins.submenu' => 'joomla_plugin.submenu', 'joomla_plugins.submenu' => 'joomla_plugin.submenu',
'joomla_plugins.dashboard_list' => 'joomla_plugin.dashboard_list', 'joomla_plugins.dashboard_list' => 'joomla_plugin.dashboard_list',
'joomla_power.create' => 'joomla_power.create',
'joomla_powers.access' => 'joomla_power.access',
'joomla_power.access' => 'joomla_power.access',
'joomla_powers.submenu' => 'joomla_power.submenu',
'power.create' => 'power.create', 'power.create' => 'power.create',
'powers.access' => 'power.access', 'powers.access' => 'power.access',
'power.access' => 'power.access', 'power.access' => 'power.access',

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_componentbuilder/models/rules"
addfieldpath="/administrator/components/com_componentbuilder/models/fields"
>
<fields name="filter">
<field
type="text"
name="search"
inputmode="search"
label="COM_COMPONENTBUILDER_FILTER_SEARCH"
description="COM_COMPONENTBUILDER_FILTER_SEARCH_JOOMLA_POWERS"
hint="JSEARCH_FILTER"
/>
<field
type="status"
name="published"
label="COM_COMPONENTBUILDER_FILTER_PUBLISHED"
description="COM_COMPONENTBUILDER_FILTER_PUBLISHED_JOOMLA_POWERS"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
type="accesslevel"
name="access"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
multiple="true"
class="multipleAccessLevels"
onchange="this.form.submit();"
/>
<input type="hidden" name="form_submited" value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id desc"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published ASC">JSTATUS_ASC</option>
<option value="a.published DESC">JSTATUS_DESC</option>
<option value="a.system_name ASC">COM_COMPONENTBUILDER_FILTER_SYSTEM_NAME_ASCENDING</option>
<option value="a.system_name DESC">COM_COMPONENTBUILDER_FILTER_SYSTEM_NAME_DESCENDING</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>

View File

@ -0,0 +1,210 @@
<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_componentbuilder/models/rules"
addfieldpath="/administrator/components/com_componentbuilder/models/fields"
>
<fieldset name="details">
<!-- Default Fields. -->
<!-- Id Field. Type: Text (joomla) -->
<field
name="id"
type="text" class="readonly" label="JGLOBAL_FIELD_ID_LABEL"
description ="JGLOBAL_FIELD_ID_DESC" size="10" default="0"
readonly="true"
/>
<!-- Date Created Field. Type: Calendar (joomla) -->
<field
name="created"
type="calendar"
label="COM_COMPONENTBUILDER_JOOMLA_POWER_CREATED_DATE_LABEL"
description="COM_COMPONENTBUILDER_JOOMLA_POWER_CREATED_DATE_DESC"
size="22"
format="%Y-%m-%d %H:%M:%S"
filter="user_utc"
/>
<!-- User Created Field. Type: User (joomla) -->
<field
name="created_by"
type="user"
label="COM_COMPONENTBUILDER_JOOMLA_POWER_CREATED_BY_LABEL"
description="COM_COMPONENTBUILDER_JOOMLA_POWER_CREATED_BY_DESC"
/>
<!-- Published Field. Type: List (joomla) -->
<field name="published" type="list" label="JSTATUS"
description="JFIELD_PUBLISHED_DESC" class="chzn-color-state"
filter="intval" size="1" default="1" >
<option value="1">
JPUBLISHED</option>
<option value="0">
JUNPUBLISHED</option>
<option value="2">
JARCHIVED</option>
<option value="-2">
JTRASHED</option>
</field>
<!-- Date Modified Field. Type: Calendar (joomla) -->
<field name="modified" type="calendar" class="readonly"
label="COM_COMPONENTBUILDER_JOOMLA_POWER_MODIFIED_DATE_LABEL" description="COM_COMPONENTBUILDER_JOOMLA_POWER_MODIFIED_DATE_DESC"
size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />
<!-- User Modified Field. Type: User (joomla) -->
<field name="modified_by" type="user"
label="COM_COMPONENTBUILDER_JOOMLA_POWER_MODIFIED_BY_LABEL"
description="COM_COMPONENTBUILDER_JOOMLA_POWER_MODIFIED_BY_DESC"
class="readonly"
readonly="true"
filter="unset"
/>
<!-- Access Field. Type: Accesslevel (joomla) -->
<field name="access"
type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
default="1"
required="false"
/>
<!-- Ordering Field. Type: Numbers (joomla) -->
<field
name="ordering"
type="number"
class="inputbox validate-ordering"
label="COM_COMPONENTBUILDER_JOOMLA_POWER_ORDERING_LABEL"
description=""
default="0"
size="6"
required="false"
/>
<!-- Version Field. Type: Text (joomla) -->
<field
name="version"
type="text"
class="readonly"
label="COM_COMPONENTBUILDER_JOOMLA_POWER_VERSION_LABEL"
description="COM_COMPONENTBUILDER_JOOMLA_POWER_VERSION_DESC"
size="6"
default="1"
readonly="true"
filter="unset"
/>
<!-- Was added due to Permissions JS needing a Title field -->
<!-- Let us know at gh-629 should this change -->
<!-- https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235 -->
<field
name="title"
type="hidden"
default="componentbuilder joomla_power"
/>
<!-- Dynamic Fields. -->
<!-- System_name Field. Type: Text. (joomla) -->
<field
type="text"
name="system_name"
label="COM_COMPONENTBUILDER_JOOMLA_POWER_SYSTEM_NAME_LABEL"
size="10"
maxlength="50"
default=""
description="COM_COMPONENTBUILDER_JOOMLA_POWER_SYSTEM_NAME_DESCRIPTION"
class="text_area"
filter="STRING"
message="COM_COMPONENTBUILDER_JOOMLA_POWER_SYSTEM_NAME_MESSAGE"
hint="COM_COMPONENTBUILDER_JOOMLA_POWER_SYSTEM_NAME_HINT"
/>
<!-- Settings Field. Type: Subform. (joomla) -->
<field
type="subform"
name="settings"
label="COM_COMPONENTBUILDER_JOOMLA_POWER_SETTINGS_LABEL"
layout="joomla.form.field.subform.repeatable-table"
multiple="true"
buttons="add,remove,move"
icon="list"
max="10"
min="1">
<form hidden="true" name="list_settings_modal" repeat="true">
<!-- Namespace Field. Type: Text. (joomla) -->
<field
type="text"
name="namespace"
label="COM_COMPONENTBUILDER_JOOMLA_POWER_NAMESPACE_LABEL"
size="250"
maxlength="250"
description="COM_COMPONENTBUILDER_JOOMLA_POWER_NAMESPACE_DESCRIPTION"
class="text_area span12"
required="true"
filter="STRING"
message="COM_COMPONENTBUILDER_JOOMLA_POWER_NAMESPACE_MESSAGE"
hint="COM_COMPONENTBUILDER_JOOMLA_POWER_NAMESPACE_HINT"
autocomplete="on"
/>
<!-- Joomla_version Field. Type: List. (joomla) -->
<field
type="list"
name="joomla_version"
label="COM_COMPONENTBUILDER_JOOMLA_POWER_JOOMLA_VERSION_LABEL"
description="COM_COMPONENTBUILDER_JOOMLA_POWER_JOOMLA_VERSION_DESCRIPTION"
class="list_class"
layout="joomla.form.field.list-fancy-select"
multiple="false"
required="true"
default="0">
<!-- Option Set. -->
<option value="0">
COM_COMPONENTBUILDER_JOOMLA_POWER_ALL</option>
<option value="3">
COM_COMPONENTBUILDER_JOOMLA_POWER_JOOMLA_3</option>
<option value="4">
COM_COMPONENTBUILDER_JOOMLA_POWER_JOOMLA_4</option>
<option value="5">
COM_COMPONENTBUILDER_JOOMLA_POWER_JOOMLA_5</option>
</field>
</form>
</field>
<!-- Guid Field. Type: Text. (joomla) -->
<field
type="text"
name="guid"
label="COM_COMPONENTBUILDER_JOOMLA_POWER_GUID_LABEL"
size="40"
maxlength="40"
description="COM_COMPONENTBUILDER_JOOMLA_POWER_GUID_DESCRIPTION"
class="text_area"
readonly="true"
filter="CMD"
validate="guid"
hint="COM_COMPONENTBUILDER_JOOMLA_POWER_GUID_HINT"
/>
<!-- Description Field. Type: Textarea. (joomla) -->
<field
type="textarea"
name="description"
label="COM_COMPONENTBUILDER_JOOMLA_POWER_DESCRIPTION_LABEL"
rows="11"
cols="10"
description="COM_COMPONENTBUILDER_JOOMLA_POWER_DESCRIPTION_DESCRIPTION"
class="text_area span12"
filter="HTML"
hint="COM_COMPONENTBUILDER_JOOMLA_POWER_DESCRIPTION_HINT"
/>
</fieldset>
<!-- Access Control Fields. -->
<fieldset name="accesscontrol">
<!-- Asset Id Field. Type: Hidden (joomla) -->
<field
name="asset_id"
type="hidden"
filter="unset"
/>
<!-- Rules Field. Type: Rules (joomla) -->
<field
name="rules"
type="rules"
label="Permissions in relation to this joomla_power"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_componentbuilder"
section="joomla_power"
/>
</fieldset>
</form>

View File

@ -1408,9 +1408,11 @@ class ComponentbuilderModelJoomla_component extends AdminModel
{ {
$data['system_name'] = $data['name']; $data['system_name'] = $data['name'];
} }
// make sure that the component code name is safe. // make sure that the component code name is safe.
$data['name_code'] = ComponentCodeNameHelper::safe($data['name_code']); if (isset($data['name_code']) && is_string($data['name_code']))
{
$data['name_code'] = ComponentCodeNameHelper::safe($data['name_code']);
}
// Set the GUID if empty or not valid // Set the GUID if empty or not valid
if (empty($data['guid']) && $data['id'] > 0) if (empty($data['guid']) && $data['id'] > 0)

View File

@ -0,0 +1,927 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Filter\InputFilter;
use Joomla\CMS\Filter\OutputFilter;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Table\Table;
use Joomla\CMS\UCM\UCMType;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Helper\TagsHelper;
use VDM\Joomla\Utilities\GuidHelper;
use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper;
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
use VDM\Joomla\Utilities\GetHelper;
/**
* Componentbuilder Joomla_power Admin Model
*/
class ComponentbuilderModelJoomla_power extends AdminModel
{
/**
* The tab layout fields array.
*
* @var array
*/
protected $tabLayoutFields = array(
'joomla_power' => array(
'fullwidth' => array(
'description',
'settings'
),
'above' => array(
'system_name'
)
)
);
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_COMPONENTBUILDER';
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_componentbuilder.joomla_power';
/**
* Returns a Table object, always creating it
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return Table A database object
*
* @since 1.6
*/
public function getTable($type = 'joomla_power', $prefix = 'ComponentbuilderTable', $config = [])
{
// add table path for when model gets used from other component
$this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_componentbuilder/tables');
// get instance of the table
return Table::getInstance($type, $prefix, $config);
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
if (!empty($item->params) && !is_array($item->params))
{
// Convert the params field to an array.
$registry = new Registry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata))
{
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
if (!empty($item->settings))
{
// Convert the settings field to an array.
$settings = new Registry;
$settings->loadString($item->settings);
$item->settings = $settings->toArray();
}
}
return $item;
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
* @param array $options Optional array of options for the form creation.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = [], $loadData = true, $options = array('control' => 'jform'))
{
// set load data option
$options['load_data'] = $loadData;
// check if xpath was set in options
$xpath = false;
if (isset($options['xpath']))
{
$xpath = $options['xpath'];
unset($options['xpath']);
}
// check if clear form was set in options
$clear = false;
if (isset($options['clear']))
{
$clear = $options['clear'];
unset($options['clear']);
}
// Get the form.
$form = $this->loadForm('com_componentbuilder.joomla_power', 'joomla_power', $options, $clear, $xpath);
if (empty($form))
{
return false;
}
$jinput = Factory::getApplication()->input;
// The front end calls this model and uses a_id to avoid id clashes so we need to check for that first.
if ($jinput->get('a_id'))
{
$id = $jinput->get('a_id', 0, 'INT');
}
// The back end uses id so we use that the rest of the time and set it to 0 by default.
else
{
$id = $jinput->get('id', 0, 'INT');
}
$user = Factory::getUser();
// Check for existing item.
// Modify the form based on Edit State access controls.
if ($id != 0 && (!$user->authorise('joomla_power.edit.state', 'com_componentbuilder.joomla_power.' . (int) $id))
|| ($id == 0 && !$user->authorise('joomla_power.edit.state', 'com_componentbuilder')))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled', 'true');
$form->setFieldAttribute('published', 'disabled', 'true');
// Disable fields while saving.
$form->setFieldAttribute('ordering', 'filter', 'unset');
$form->setFieldAttribute('published', 'filter', 'unset');
}
// If this is a new item insure the greated by is set.
if (0 == $id)
{
// Set the created_by to this user
$form->setValue('created_by', null, $user->id);
}
// Modify the form based on Edit Creaded By access controls.
if ($id != 0 && (!$user->authorise('joomla_power.edit.created_by', 'com_componentbuilder.joomla_power.' . (int) $id))
|| ($id == 0 && !$user->authorise('joomla_power.edit.created_by', 'com_componentbuilder')))
{
// Disable fields for display.
$form->setFieldAttribute('created_by', 'disabled', 'true');
// Disable fields for display.
$form->setFieldAttribute('created_by', 'readonly', 'true');
// Disable fields while saving.
$form->setFieldAttribute('created_by', 'filter', 'unset');
}
// Modify the form based on Edit Creaded Date access controls.
if ($id != 0 && (!$user->authorise('joomla_power.edit.created', 'com_componentbuilder.joomla_power.' . (int) $id))
|| ($id == 0 && !$user->authorise('joomla_power.edit.created', 'com_componentbuilder')))
{
// Disable fields for display.
$form->setFieldAttribute('created', 'disabled', 'true');
// Disable fields while saving.
$form->setFieldAttribute('created', 'filter', 'unset');
}
// Only load these values if no id is found
if (0 == $id)
{
// Set redirected view name
$redirectedView = $jinput->get('ref', null, 'STRING');
// Set field name (or fall back to view name)
$redirectedField = $jinput->get('field', $redirectedView, 'STRING');
// Set redirected view id
$redirectedId = $jinput->get('refid', 0, 'INT');
// Set field id (or fall back to redirected view id)
$redirectedValue = $jinput->get('field_id', $redirectedId, 'INT');
if (0 != $redirectedValue && $redirectedField)
{
// Now set the local-redirected field default value
$form->setValue($redirectedField, null, $redirectedValue);
}
}
// Only load the GUID if new item (or empty)
if (0 == $id || !($val = $form->getValue('guid')))
{
$form->setValue('guid', null, GuidHelper::get());
}
return $form;
}
/**
* Method to get the script that have to be included on the form
*
* @return string script files
*/
public function getScript()
{
return 'media/com_componentbuilder/js/joomla_power.js';
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->published != -2)
{
return;
}
$user = Factory::getUser();
// The record has been set. Check the record permissions.
return $user->authorise('joomla_power.delete', 'com_componentbuilder.joomla_power.' . (int) $record->id);
}
return false;
}
/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = Factory::getUser();
$recordId = $record->id ?? 0;
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('joomla_power.edit.state', 'com_componentbuilder.joomla_power.' . (int) $recordId);
if (!$permission && !is_null($permission))
{
return false;
}
}
// In the absence of better information, revert to the component permissions.
return $user->authorise('joomla_power.edit.state', 'com_componentbuilder');
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 2.5
*/
protected function allowEdit($data = [], $key = 'id')
{
// Check specific edit permission then general edit permission.
$user = Factory::getUser();
return $user->authorise('joomla_power.edit', 'com_componentbuilder.joomla_power.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('joomla_power.edit', 'com_componentbuilder');
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param Table $table A Table object.
*
* @return void
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = Factory::getDate();
$user = Factory::getUser();
if (isset($table->name))
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
if (isset($table->alias) && empty($table->alias))
{
$table->generateAlias();
}
if (empty($table->id))
{
$table->created = $date->toSql();
// set the user
if ($table->created_by == 0 || empty($table->created_by))
{
$table->created_by = $user->id;
}
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__componentbuilder_joomla_power'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
if (!empty($table->id))
{
// Increment the items version number.
$table->version++;
}
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = Factory::getApplication()->getUserState('com_componentbuilder.edit.joomla_power.data', []);
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.joomla_power', $data);
}
return $data;
}
/**
* Method to get the unique fields of this table.
*
* @return mixed An array of field names, boolean false if none is set.
*
* @since 3.0
*/
protected function getUniqueFields()
{
return array('guid');
}
/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 12.2
*/
public function delete(&$pks)
{
if (!parent::delete($pks))
{
return false;
}
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 12.2
*/
public function publish(&$pks, $value = 1)
{
if (!parent::publish($pks, $value))
{
return false;
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 12.2
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize ids.
$pks = array_unique($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = Factory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new UCMType;
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = ComponentbuilderHelper::getActions('joomla_power');
$this->batchSet = true;
if (!$this->canDo->get('core.batch'))
{
$this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
if ($this->type == false)
{
$type = new UCMType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
$this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['move_copy']))
{
$cmd = ArrayHelper::getValue($commands, 'move_copy', 'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands, $pks, $contexts);
if (is_array($result))
{
foreach ($result as $old => $new)
{
$contexts[$new] = $contexts[$old];
}
$pks = array_values($result);
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch copy items to a new category or current.
*
* @param integer $values The new values.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on failure.
*
* @since 12.2
*/
protected function batchCopy($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = Factory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = ComponentbuilderHelper::getActions('joomla_power');
}
if (!$this->canDo->get('joomla_power.create') && !$this->canDo->get('joomla_power.batch'))
{
return false;
}
// get list of unique fields
$uniqueFields = $this->getUniqueFields();
// remove move_copy from array
unset($values['move_copy']);
// make sure published is set
if (!isset($values['published']))
{
$values['published'] = 0;
}
elseif (isset($values['published']) && !$this->canDo->get('joomla_power.edit.state'))
{
$values['published'] = 0;
}
$newIds = [];
// Parent exists so let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$this->table->reset();
// only allow copy if user may edit this item.
if (!$this->user->authorise('joomla_power.edit', $contexts[$pk]))
{
// Not fatal error
$this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
continue;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
continue;
}
}
// Only for strings
if (UtilitiesStringHelper::check($this->table->system_name) && !is_numeric($this->table->system_name))
{
$this->table->system_name = $this->generateUnique('system_name',$this->table->system_name);
}
// insert all set values
if (UtilitiesArrayHelper::check($values))
{
foreach ($values as $key => $value)
{
if (strlen($value) > 0 && isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// update all unique fields
if (UtilitiesArrayHelper::check($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField);
}
}
// Reset the ID because we are making a copy
$this->table->id = 0;
// TODO: Deal with ordering?
// $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
// Get the new item ID
$newId = $this->table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move items to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal error is set.
*
* @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = Factory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->canDo = ComponentbuilderHelper::getActions('joomla_power');
}
if (!$this->canDo->get('joomla_power.edit') && !$this->canDo->get('joomla_power.batch'))
{
$this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// make sure published only updates if user has the permission.
if (isset($values['published']) && !$this->canDo->get('joomla_power.edit.state'))
{
unset($values['published']);
}
// remove move_copy from array
unset($values['move_copy']);
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('joomla_power.edit', $contexts[$pk]))
{
$this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
continue;
}
}
// insert all set values.
if (UtilitiesArrayHelper::check($values))
{
foreach ($values as $key => $value)
{
// Do special action for access.
if ('access' === $key && strlen($value) > 0)
{
$this->table->$key = $value;
}
elseif (strlen($value) > 0 && isset($this->table->$key))
{
$this->table->$key = $value;
}
}
}
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table);
}
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = Factory::getApplication()->input;
$filter = InputFilter::getInstance();
// set the metadata to the Item Data
if (isset($data['metadata']) && isset($data['metadata']['author']))
{
$data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM');
$metadata = new Registry;
$metadata->loadArray($data['metadata']);
$data['metadata'] = (string) $metadata;
}
// Set the GUID if empty or not valid
if (empty($data['guid']) && $data['id'] > 0)
{
// get the existing one
$data['guid'] = (string) GetHelper::var('joomla_power', $data['id'], 'id', 'guid');
}
// Set the GUID if empty or not valid
while (!GuidHelper::valid($data['guid'], "joomla_power", $data['id']))
{
// must always be set
$data['guid'] = (string) GuidHelper::get();
}
// Set the settings items to data.
if (isset($data['settings']) && is_array($data['settings']))
{
$settings = new Registry;
$settings->loadArray($data['settings']);
$data['settings'] = (string) $settings;
}
elseif (!isset($data['settings']))
{
// Set the empty settings to data
$data['settings'] = '';
}
// Set the Params Items to data
if (isset($data['params']) && is_array($data['params']))
{
$params = new Registry;
$params->loadArray($data['params']);
$data['params'] = (string) $params;
}
// Alter the unique field for save as copy
if ($input->get('task') === 'save2copy')
{
// Automatic handling of other unique fields
$uniqueFields = $this->getUniqueFields();
if (UtilitiesArrayHelper::check($uniqueFields))
{
foreach ($uniqueFields as $uniqueField)
{
$data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]);
}
}
}
if (parent::save($data))
{
return true;
}
return false;
}
/**
* Method to generate a unique value.
*
* @param string $field name.
* @param string $value data.
*
* @return string New value.
*
* @since 3.0
*/
protected function generateUnique($field,$value)
{
// set field value unique
$table = $this->getTable();
while ($table->load(array($field => $value)))
{
$value = StringHelper::increment($value);
}
return $value;
}
/**
* Method to change the title
*
* @param string $title The title.
*
* @return array Contains the modified title and alias.
*
*/
protected function _generateNewTitle($title)
{
// Alter the title
$table = $this->getTable();
while ($table->load(['title' => $title]))
{
$title = StringHelper::increment($title);
}
return $title;
}
}

View File

@ -0,0 +1,312 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Helper\TagsHelper;
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Joomla_powers List Model
*/
class ComponentbuilderModelJoomla_powers extends ListModel
{
public function __construct($config = [])
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.id','id',
'a.published','published',
'a.access','access',
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
'a.system_name','system_name'
);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
*/
protected function populateState($ordering = null, $direction = null)
{
$app = Factory::getApplication();
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout'))
{
$this->context .= '.' . $layout;
}
// Check if the form was submitted
$formSubmited = $app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
$published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', '');
$this->setState('filter.created_by', $created_by);
$created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created');
$this->setState('filter.created', $created);
$sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int');
$this->setState('filter.sorting', $sorting);
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$system_name = $this->getUserStateFromRequest($this->context . '.filter.system_name', 'filter_system_name');
if ($formSubmited)
{
$system_name = $app->input->post->get('system_name');
$this->setState('filter.system_name', $system_name);
}
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
// Check in items
$this->checkInNow();
// load parent items
$items = parent::getItems();
// Set values to display correctly.
if (UtilitiesArrayHelper::check($items))
{
// Get the user object if not set.
if (!isset($user) || !ObjectHelper::check($user))
{
$user = Factory::getUser();
}
foreach ($items as $nr => &$item)
{
// Remove items the user can't access.
$access = ($user->authorise('joomla_power.access', 'com_componentbuilder.joomla_power.' . (int) $item->id) && $user->authorise('joomla_power.access', 'com_componentbuilder'));
if (!$access)
{
unset($items[$nr]);
continue;
}
// create the GUID placeholder key
$item->joomla_power_key = 'Joomla_'.'_'.'_' . str_replace('-', '_', $item->guid) . '_'.'_'.'_Power';
}
}
// return items
return $items;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Get the user object.
$user = Factory::getUser();
// Create a new query object.
$db = Factory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the componentbuilder_item table
$query->from($db->quoteName('#__componentbuilder_joomla_power', 'a'));
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.published = 0 OR a.published = 1)');
}
// Join over the asset groups.
$query->select('ag.title AS access_level');
$query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
// Filter by access level.
$_access = $this->getState('filter.access');
if ($_access && is_numeric($_access))
{
$query->where('a.access = ' . (int) $_access);
}
elseif (UtilitiesArrayHelper::check($_access))
{
// Secure the array for the query
$_access = ArrayHelper::toInteger($_access);
// Filter by the Access Array.
$query->where('a.access IN (' . implode(',', $_access) . ')');
}
// Implement View Level Access
if (!$user->authorise('core.options', 'com_componentbuilder'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
// Filter by search.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search) . '%');
$query->where('(a.system_name LIKE '.$search.' OR a.guid LIKE '.$search.' OR a.description LIKE '.$search.')');
}
}
// Add the list ordering clause.
$orderCol = $this->getState('list.ordering', 'a.id');
$orderDirn = $this->getState('list.direction', 'desc');
if ($orderCol != '')
{
// Check that the order direction is valid encase we have a field called direction as part of filers.
$orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc';
$query->order($db->escape($orderCol . ' ' . $orderDirn));
}
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
// Check if the value is an array
$_access = $this->getState('filter.access');
if (UtilitiesArrayHelper::check($_access))
{
$id .= ':' . implode(':', $_access);
}
// Check if this is only an number or string
elseif (is_numeric($_access)
|| StringHelper::check($_access))
{
$id .= ':' . $_access;
}
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' . $this->getState('filter.modified_by');
$id .= ':' . $this->getState('filter.system_name');
return parent::getStoreId($id);
}
/**
* Build an SQL query to checkin all items left checked out longer then a set time.
*
* @return bool
* @since 3.2.0
*/
protected function checkInNow(): bool
{
// Get set check in time
$time = ComponentHelper::getParams('com_componentbuilder')->get('check_in');
if ($time)
{
// Get a db connection.
$db = Factory::getDbo();
// Reset query.
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__componentbuilder_joomla_power'));
// Only select items that are checked out.
$query->where($db->quoteName('checked_out') . '!=0');
$db->setQuery($query, 0, 1);
$db->execute();
if ($db->getNumRows())
{
// Get Yesterdays date.
$date = Factory::getDate()->modify($time)->toSql();
// Reset query.
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
$db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'',
$db->quoteName('checked_out') . '=0'
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') . '<\''.$date.'\''
);
// Check table.
$query->update($db->quoteName('#__componentbuilder_joomla_power'))->set($fields)->where($conditions);
$db->setQuery($query);
return $db->execute();
}
}
return false;
}
}

View File

@ -323,6 +323,35 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_joomla_plugin` (
KEY `idx_state` (`published`) KEY `idx_state` (`published`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS `#__componentbuilder_joomla_power` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.',
`description` TEXT NULL,
`guid` VARCHAR(36) NOT NULL DEFAULT '',
`settings` TEXT NOT NULL,
`system_name` VARCHAR(255) NOT NULL DEFAULT '',
`params` text NULL,
`published` TINYINT(3) NOT NULL DEFAULT 1,
`created_by` INT(10) unsigned NOT NULL DEFAULT 0,
`modified_by` INT(10) unsigned NOT NULL DEFAULT 0,
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`checked_out` int(11) unsigned NOT NULL DEFAULT 0,
`checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`version` INT(10) unsigned NOT NULL DEFAULT 1,
`hits` INT(10) unsigned NOT NULL DEFAULT 0,
`access` INT(10) unsigned NOT NULL DEFAULT 0,
`ordering` INT(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY `idx_system_name` (`system_name`),
KEY `idx_guid` (`guid`),
KEY `idx_access` (`access`),
KEY `idx_checkout` (`checked_out`),
KEY `idx_createdby` (`created_by`),
KEY `idx_modifiedby` (`modified_by`),
KEY `idx_state` (`published`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS `#__componentbuilder_power` ( CREATE TABLE IF NOT EXISTS `#__componentbuilder_power` (
`id` INT(11) NOT NULL AUTO_INCREMENT, `id` INT(11) NOT NULL AUTO_INCREMENT,
`asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.', `asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.',
@ -2268,7 +2297,7 @@ INSERT INTO `#__componentbuilder_fieldtype` (`id`, `description`, `name`, `prope
(26, 'The timezones form field type provides a drop down list of time zones. If the field has a value saved, this value is displayed when the page is first loaded. If not, the default value (if any) is selected.', 'Timezone', '{\"properties0\":{\"name\":\"type\",\"example\":\"timezone\",\"mandatory\":\"1\",\"description\":\"(mandatory) must be timezone.\"},\"properties1\":{\"name\":\"name\",\"example\":\"timezone\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"description\":\"(mandatory) is the unique name of the field.\"},\"properties2\":{\"name\":\"label\",\"example\":\"Timezone\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"translatable\":\"1\",\"description\":\"(mandatory) (translatable) is the descriptive title of the field.\"},\"properties3\":{\"name\":\"default\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is the default time zone. For example, use \'-10\' for \'(UTC -10:00) Hawaii\'.\"},\"properties4\":{\"name\":\"description\",\"example\":\"\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.\"},\"properties5\":{\"name\":\"showon\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) show this field on the bases of the value in another field. https:\\/\\/joomla.stackexchange.com\\/a\\/17682\\/2166\"}}', 'provides a drop down list of time zones.', '', 1, 3, '', '', 'ed8d8cf4-cb05-49cc-95ef-4ef275f539f9'), (26, 'The timezones form field type provides a drop down list of time zones. If the field has a value saved, this value is displayed when the page is first loaded. If not, the default value (if any) is selected.', 'Timezone', '{\"properties0\":{\"name\":\"type\",\"example\":\"timezone\",\"mandatory\":\"1\",\"description\":\"(mandatory) must be timezone.\"},\"properties1\":{\"name\":\"name\",\"example\":\"timezone\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"description\":\"(mandatory) is the unique name of the field.\"},\"properties2\":{\"name\":\"label\",\"example\":\"Timezone\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"translatable\":\"1\",\"description\":\"(mandatory) (translatable) is the descriptive title of the field.\"},\"properties3\":{\"name\":\"default\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is the default time zone. For example, use \'-10\' for \'(UTC -10:00) Hawaii\'.\"},\"properties4\":{\"name\":\"description\",\"example\":\"\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.\"},\"properties5\":{\"name\":\"showon\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) show this field on the bases of the value in another field. https:\\/\\/joomla.stackexchange.com\\/a\\/17682\\/2166\"}}', 'provides a drop down list of time zones.', '', 1, 3, '', '', 'ed8d8cf4-cb05-49cc-95ef-4ef275f539f9'),
(27, 'This field essentially is a text field with the type of url. If a fully qualified url (that is one with a scheme and domain such as http://example.com) is entered and it uses idn (that is uses characters that are non ascii such as ê or Ψ) it will translat', 'URL', '{\"properties0\":{\"name\":\"type\",\"example\":\"url\",\"mandatory\":\"1\",\"description\":\"(mandatory) must be url.\"},\"properties1\":{\"name\":\"name\",\"example\":\"website\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"description\":\"(mandatory) is the unique name of the field.\"},\"properties2\":{\"name\":\"label\",\"example\":\"Website\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"translatable\":\"1\",\"description\":\"(mandatory) (translatable) is the descriptive title of the field.\"},\"properties3\":{\"name\":\"size\",\"example\":\"10\",\"adjustable\":\"1\",\"description\":\"(optional) is the width of the text box in characters. If omitted the width is determined by the browser. The value of size does not limit the number of characters that may be entered.\"},\"properties4\":{\"name\":\"maxlength\",\"example\":\"50\",\"adjustable\":\"1\",\"description\":\"(optional) limits the number of characters that may be entered.\"},\"properties5\":{\"name\":\"default\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) (not translatable) is the default value.\"},\"properties6\":{\"name\":\"description\",\"example\":\"Enter website address\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.\"},\"properties7\":{\"name\":\"class\",\"example\":\"text_area\",\"adjustable\":\"1\",\"description\":\"(optional) is a CSS class name for the HTML form field. If omitted this will default to \'text_area\'.\"},\"properties8\":{\"name\":\"readonly\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) The field cannot be changed and will automatically inherit the default value\"},\"properties9\":{\"name\":\"disabled\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) The field cannot be changed and will automatically inherit the default value - it will also not submit\"},\"properties10\":{\"name\":\"required\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) The field must be filled before submitting the form.\"},\"properties11\":{\"name\":\"relative\",\"example\":\"false\",\"adjustable\":\"1\",\"description\":\"(optional) set to true for relative URLs\"},\"properties12\":{\"name\":\"filter\",\"example\":\"url\",\"adjustable\":\"1\",\"description\":\"(optional) allow the system to save certain html tags or raw data.\"},\"properties13\":{\"name\":\"validated\",\"example\":\"url\",\"adjustable\":\"1\",\"description\":\"(optional) The validation method for the form field. This value will determine which method is used to validate the value for a field.\"},\"properties14\":{\"name\":\"scheme\",\"example\":\"http,https,mailto\",\"adjustable\":\"1\",\"description\":\"(optional) Validates that the value is a URL with a valid scheme (which can be restricted by the optional comma-separated field \'scheme\'), and passes a basic syntax check.\"},\"properties15\":{\"name\":\"message\",\"example\":\"Error! Please add website here.\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) (translatable) is text that will be shown as error on validation.\"},\"properties16\":{\"name\":\"hint\",\"example\":\"Your Website Here\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) The placeholder to display inside the text box.\"},\"properties19\":{\"name\":\"autocomplete\",\"example\":\"on\",\"adjustable\":\"1\",\"description\":\"(optional) The autocomplete state for the form field. If \'off\' element will not be automatically completed by browser.\"},\"properties17\":{\"name\":\"showon\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) Allows you to hide the field based on the value(s) of another field; for Joomla 3.2.4+ https:\\/\\/joomla.stackexchange.com\\/a\\/17682\\/2166\"},\"properties18\":{\"name\":\"onchange\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) HTML equivalent attribute (javascript use)\"}}', 'provides a URL text input field.', '', 1, 10, '', '', '8df6e07e-2b16-43ed-a18d-2059fa44cdf1'), (27, 'This field essentially is a text field with the type of url. If a fully qualified url (that is one with a scheme and domain such as http://example.com) is entered and it uses idn (that is uses characters that are non ascii such as ê or Ψ) it will translat', 'URL', '{\"properties0\":{\"name\":\"type\",\"example\":\"url\",\"mandatory\":\"1\",\"description\":\"(mandatory) must be url.\"},\"properties1\":{\"name\":\"name\",\"example\":\"website\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"description\":\"(mandatory) is the unique name of the field.\"},\"properties2\":{\"name\":\"label\",\"example\":\"Website\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"translatable\":\"1\",\"description\":\"(mandatory) (translatable) is the descriptive title of the field.\"},\"properties3\":{\"name\":\"size\",\"example\":\"10\",\"adjustable\":\"1\",\"description\":\"(optional) is the width of the text box in characters. If omitted the width is determined by the browser. The value of size does not limit the number of characters that may be entered.\"},\"properties4\":{\"name\":\"maxlength\",\"example\":\"50\",\"adjustable\":\"1\",\"description\":\"(optional) limits the number of characters that may be entered.\"},\"properties5\":{\"name\":\"default\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) (not translatable) is the default value.\"},\"properties6\":{\"name\":\"description\",\"example\":\"Enter website address\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.\"},\"properties7\":{\"name\":\"class\",\"example\":\"text_area\",\"adjustable\":\"1\",\"description\":\"(optional) is a CSS class name for the HTML form field. If omitted this will default to \'text_area\'.\"},\"properties8\":{\"name\":\"readonly\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) The field cannot be changed and will automatically inherit the default value\"},\"properties9\":{\"name\":\"disabled\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) The field cannot be changed and will automatically inherit the default value - it will also not submit\"},\"properties10\":{\"name\":\"required\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) The field must be filled before submitting the form.\"},\"properties11\":{\"name\":\"relative\",\"example\":\"false\",\"adjustable\":\"1\",\"description\":\"(optional) set to true for relative URLs\"},\"properties12\":{\"name\":\"filter\",\"example\":\"url\",\"adjustable\":\"1\",\"description\":\"(optional) allow the system to save certain html tags or raw data.\"},\"properties13\":{\"name\":\"validated\",\"example\":\"url\",\"adjustable\":\"1\",\"description\":\"(optional) The validation method for the form field. This value will determine which method is used to validate the value for a field.\"},\"properties14\":{\"name\":\"scheme\",\"example\":\"http,https,mailto\",\"adjustable\":\"1\",\"description\":\"(optional) Validates that the value is a URL with a valid scheme (which can be restricted by the optional comma-separated field \'scheme\'), and passes a basic syntax check.\"},\"properties15\":{\"name\":\"message\",\"example\":\"Error! Please add website here.\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) (translatable) is text that will be shown as error on validation.\"},\"properties16\":{\"name\":\"hint\",\"example\":\"Your Website Here\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) The placeholder to display inside the text box.\"},\"properties19\":{\"name\":\"autocomplete\",\"example\":\"on\",\"adjustable\":\"1\",\"description\":\"(optional) The autocomplete state for the form field. If \'off\' element will not be automatically completed by browser.\"},\"properties17\":{\"name\":\"showon\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) Allows you to hide the field based on the value(s) of another field; for Joomla 3.2.4+ https:\\/\\/joomla.stackexchange.com\\/a\\/17682\\/2166\"},\"properties18\":{\"name\":\"onchange\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) HTML equivalent attribute (javascript use)\"}}', 'provides a URL text input field.', '', 1, 10, '', '', '8df6e07e-2b16-43ed-a18d-2059fa44cdf1'),
(28, 'The user form field type provides a modal select box of users.', 'User', '{\"properties0\":{\"name\":\"type\",\"example\":\"user\",\"mandatory\":\"1\",\"description\":\"(mandatory) must be user.\"},\"properties1\":{\"name\":\"name\",\"example\":\"user\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"description\":\"(mandatory) is the unique name of the field. This must match the name of the query results column that contains the values that will be shown to the user in the drop-down list, unless a different name is specified in the value_field attribute.\"},\"properties2\":{\"name\":\"label\",\"example\":\"User\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"translatable\":\"1\",\"description\":\"(mandatory) (translatable) is the descriptive title of the field.\"},\"properties3\":{\"name\":\"description\",\"example\":\"\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.\"},\"properties4\":{\"name\":\"class\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a CSS class name for the HTML form field.\"},\"properties5\":{\"name\":\"size\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is the width of the text box in characters. If omitted the width is determined by the browser. The value of size does not limit the number of characters that may be entered.\"},\"properties6\":{\"name\":\"required\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) The field must be filled before submitting the form.\"},\"properties7\":{\"name\":\"showon\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) show this field on the bases of the value in another field. https:\\/\\/joomla.stackexchange.com\\/a\\/17682\\/2166\"}}', 'provides a modal list of users.', '', 1, 4, '', '', 'b0641980-5e78-42f6-972f-86aa607db23e'), (28, 'The user form field type provides a modal select box of users.', 'User', '{\"properties0\":{\"name\":\"type\",\"example\":\"user\",\"mandatory\":\"1\",\"description\":\"(mandatory) must be user.\"},\"properties1\":{\"name\":\"name\",\"example\":\"user\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"description\":\"(mandatory) is the unique name of the field. This must match the name of the query results column that contains the values that will be shown to the user in the drop-down list, unless a different name is specified in the value_field attribute.\"},\"properties2\":{\"name\":\"label\",\"example\":\"User\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"translatable\":\"1\",\"description\":\"(mandatory) (translatable) is the descriptive title of the field.\"},\"properties3\":{\"name\":\"description\",\"example\":\"\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.\"},\"properties4\":{\"name\":\"class\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a CSS class name for the HTML form field.\"},\"properties5\":{\"name\":\"size\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is the width of the text box in characters. If omitted the width is determined by the browser. The value of size does not limit the number of characters that may be entered.\"},\"properties6\":{\"name\":\"required\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) The field must be filled before submitting the form.\"},\"properties7\":{\"name\":\"showon\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) show this field on the bases of the value in another field. https:\\/\\/joomla.stackexchange.com\\/a\\/17682\\/2166\"}}', 'provides a modal list of users.', '', 1, 4, '', '', 'b0641980-5e78-42f6-972f-86aa607db23e'),
(29, 'The usergroup form field type provides a modal select box of user groups.', 'Usergrouplist', '{\"properties0\":{\"name\":\"type\",\"example\":\"usergrouplist\",\"mandatory\":\"1\",\"description\":\"(mandatory) must be usergroup.\"},\"properties1\":{\"name\":\"name\",\"example\":\"usergroup\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"description\":\"(mandatory) is the unique name of the field. This must match the name of the query results column that contains the values that will be shown to the user in the drop-down list, unless a different name is specified in the value_field attribute.\"},\"properties2\":{\"name\":\"label\",\"example\":\"Group\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"translatable\":\"1\",\"description\":\"(mandatory) (translatable) is the descriptive title of the field.\"},\"properties3\":{\"name\":\"description\",\"example\":\"Select a group\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.\"},\"properties4\":{\"name\":\"class\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a CSS class name for the HTML form field.\"},\"properties5\":{\"name\":\"size\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is the width of the text box in characters. If omitted the width is determined by the browser. The value of size does not limit the number of characters that may be entered.\"},\"properties6\":{\"name\":\"required\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is the field required true if yes.\"},\"properties7\":{\"name\":\"multiple\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) If set to multiple then allows more than one usergroup to be selected.\"},\"properties8\":{\"name\":\"showon\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) show this field on the bases of the value in another field. https:\\/\\/joomla.stackexchange.com\\/a\\/17682\\/2166\"}}', 'provides a drop down list of user groups.', '', 1, 4, '', '', 'e2f31181-fbb3-4c3a-859d-72b6b0cff308'), (29, 'The usergroup form field type provides a modal select box of user groups.', 'Usergrouplist', '{\"properties0\":{\"name\":\"type\",\"example\":\"usergrouplist\",\"mandatory\":\"1\",\"description\":\"(mandatory) must be usergroup.\"},\"properties1\":{\"name\":\"name\",\"example\":\"usergroup\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"description\":\"(mandatory) is the unique name of the field. This must match the name of the query results column that contains the values that will be shown to the user in the drop-down list, unless a different name is specified in the value_field attribute.\"},\"properties2\":{\"name\":\"label\",\"example\":\"Group\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"translatable\":\"1\",\"description\":\"(mandatory) (translatable) is the descriptive title of the field.\"},\"properties3\":{\"name\":\"description\",\"example\":\"Select a group\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.\"},\"properties4\":{\"name\":\"class\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a CSS class name for the HTML form field.\"},\"properties9\":{\"name\":\"layout\",\"example\":\"joomla.form.field.list-fancy-select\",\"adjustable\":\"1\",\"description\":\"(optional) (translatable) is the layout, for example joomla.form.field.list-fancy-select.\"},\"properties5\":{\"name\":\"size\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is the width of the text box in characters. If omitted the width is determined by the browser. The value of size does not limit the number of characters that may be entered.\"},\"properties6\":{\"name\":\"required\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is the field required true if yes.\"},\"properties10\":{\"name\":\"checksuperusergroup\",\"example\":\"1\",\"adjustable\":\"1\",\"description\":\"(optional) is boolean to omit Super User groups. Values 1 or 0.\"},\"properties7\":{\"name\":\"multiple\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) If set to multiple then allows more than one usergroup to be selected.\"},\"properties8\":{\"name\":\"showon\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) show this field on the bases of the value in another field. https:\\/\\/joomla.stackexchange.com\\/a\\/17682\\/2166\"}}', 'provides a drop down list of user groups.', '', 1, 5, '', '', 'e2f31181-fbb3-4c3a-859d-72b6b0cff308'),
(30, 'The filelist form field type provides a drop down list of files from a specified directory. If the field has a saved value this is selected when the page is first loaded. If not, the default value (if any) is selected.\r\n\r\nBy default, the first item on the', 'Filelist', '{\"properties0\":{\"name\":\"type\",\"example\":\"filelist\",\"mandatory\":\"1\",\"description\":\"(mandatory) must be filelist.\"},\"properties1\":{\"name\":\"name\",\"example\":\"myfile\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"description\":\"(mandatory) is the unique name of the field.\"},\"properties2\":{\"name\":\"label\",\"example\":\"Select a file\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"translatable\":\"1\",\"description\":\"(mandatory) (translatable) is the descriptive title of the field.\"},\"properties3\":{\"name\":\"directory\",\"example\":\"images\\/stories\",\"adjustable\":\"1\",\"description\":\"(optional) is the filesystem path to the directory containing the files to be listed. If omitted the directory given by JPATH_ROOT is assumed.\"},\"properties4\":{\"name\":\"default\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is the default file name.\"},\"properties5\":{\"name\":\"description\",\"example\":\"\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.\"},\"properties6\":{\"name\":\"filter\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a regular expression string which is used to filter the list of files selected for inclusion in the drop-down list. If omitted, all files in the directory are included. The filter argument expression is applied before the exclude argument expression. For information on constructing regular expressions see Regular expressions in parameter arguments.\"},\"properties7\":{\"name\":\"exclude\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a regular expression string which is used to exclude files from the list. The exclude argument expression is applied after the filter argument expression. For information on constructing regular expressions see Regular expressions in parameter arguments.\"},\"properties8\":{\"name\":\"stripext\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a Boolean argument. If true then file name extensions will be stripped from the file names listed. Also note that the file name will be saved without the extension too.\"},\"properties9\":{\"name\":\"hide_none\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a Boolean argument. If true, the \'- Do not use -\' item is omitted from the drop-down list.\"},\"properties10\":{\"name\":\"hide_default\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a Boolean argument. If true, the \'- Use default -\' item is omitted from the drop-down list.\"},\"properties11\":{\"name\":\"showon\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) show this field on the bases of the value in another field. https:\\/\\/joomla.stackexchange.com\\/a\\/17682\\/2166\"}}', 'Provides a drop down list of files from a specified directory.', '', 1, 4, '', 1, '0c80df15-52c6-4647-983b-4bb4888a2edf'), (30, 'The filelist form field type provides a drop down list of files from a specified directory. If the field has a saved value this is selected when the page is first loaded. If not, the default value (if any) is selected.\r\n\r\nBy default, the first item on the', 'Filelist', '{\"properties0\":{\"name\":\"type\",\"example\":\"filelist\",\"mandatory\":\"1\",\"description\":\"(mandatory) must be filelist.\"},\"properties1\":{\"name\":\"name\",\"example\":\"myfile\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"description\":\"(mandatory) is the unique name of the field.\"},\"properties2\":{\"name\":\"label\",\"example\":\"Select a file\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"translatable\":\"1\",\"description\":\"(mandatory) (translatable) is the descriptive title of the field.\"},\"properties3\":{\"name\":\"directory\",\"example\":\"images\\/stories\",\"adjustable\":\"1\",\"description\":\"(optional) is the filesystem path to the directory containing the files to be listed. If omitted the directory given by JPATH_ROOT is assumed.\"},\"properties4\":{\"name\":\"default\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is the default file name.\"},\"properties5\":{\"name\":\"description\",\"example\":\"\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.\"},\"properties6\":{\"name\":\"filter\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a regular expression string which is used to filter the list of files selected for inclusion in the drop-down list. If omitted, all files in the directory are included. The filter argument expression is applied before the exclude argument expression. For information on constructing regular expressions see Regular expressions in parameter arguments.\"},\"properties7\":{\"name\":\"exclude\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a regular expression string which is used to exclude files from the list. The exclude argument expression is applied after the filter argument expression. For information on constructing regular expressions see Regular expressions in parameter arguments.\"},\"properties8\":{\"name\":\"stripext\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a Boolean argument. If true then file name extensions will be stripped from the file names listed. Also note that the file name will be saved without the extension too.\"},\"properties9\":{\"name\":\"hide_none\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a Boolean argument. If true, the \'- Do not use -\' item is omitted from the drop-down list.\"},\"properties10\":{\"name\":\"hide_default\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a Boolean argument. If true, the \'- Use default -\' item is omitted from the drop-down list.\"},\"properties11\":{\"name\":\"showon\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) show this field on the bases of the value in another field. https:\\/\\/joomla.stackexchange.com\\/a\\/17682\\/2166\"}}', 'Provides a drop down list of files from a specified directory.', '', 1, 4, '', 1, '0c80df15-52c6-4647-983b-4bb4888a2edf'),
(31, 'The folderlist form field type provides a drop down list of folders from a specfied directory. If the field has a saved value this is selected when the page is first loaded. If not, the default value (if any) is selected.\r\n\r\nBy default, the first item on ', 'Folderlist', '{\"properties0\":{\"name\":\"type\",\"example\":\"folderlist\",\"mandatory\":\"1\",\"description\":\"(mandatory) must be folderlist.\"},\"properties1\":{\"name\":\"name\",\"example\":\"myfolder\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"description\":\"(mandatory) is the unique name of the field.\"},\"properties2\":{\"name\":\"label\",\"example\":\"Select a folder\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"translatable\":\"1\",\"description\":\"(mandatory) (translatable) is the descriptive title of the field.\"},\"properties3\":{\"name\":\"directory\",\"example\":\"images\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"description\":\"(mandatory) is the filesystem path to the directory containing the folders to be listed.\"},\"properties4\":{\"name\":\"default\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is the default folder name.\"},\"properties5\":{\"name\":\"description\",\"example\":\"\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.\"},\"properties6\":{\"name\":\"filter\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a regular expression string which is used to filter the list of folders selected for inclusion in the drop-down list. If omitted, all folders in the directory are included. The filter argument expression is applied before the exclude argument expression. For information on constructing regular expressions see Regular expressions in parameter arguments.\"},\"properties7\":{\"name\":\"exclude\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a regular expression string which is used to exclude folders from the list. The exclude argument expression is applied after the filter argument expression. For information on constructing regular expressions see Regular expressions in parameter arguments.\"},\"properties8\":{\"name\":\"hide_none\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a Boolean argument. If true, the \'- Do not use -\' item is omitted from the drop-down list.\"},\"properties9\":{\"name\":\"hide_default\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a Boolean argument. If true, the \'- Use default -\' item is omitted from the drop-down list.\"},\"properties10\":{\"name\":\"showon\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) show this field on the bases of the value in another field. https:\\/\\/joomla.stackexchange.com\\/a\\/17682\\/2166\"}}', 'Provides a drop down list of folders from a specified directory.', '', 1, 4, '', 2, 'd3ab2ae4-9370-4497-ae6d-dee2e0b74b7a'), (31, 'The folderlist form field type provides a drop down list of folders from a specfied directory. If the field has a saved value this is selected when the page is first loaded. If not, the default value (if any) is selected.\r\n\r\nBy default, the first item on ', 'Folderlist', '{\"properties0\":{\"name\":\"type\",\"example\":\"folderlist\",\"mandatory\":\"1\",\"description\":\"(mandatory) must be folderlist.\"},\"properties1\":{\"name\":\"name\",\"example\":\"myfolder\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"description\":\"(mandatory) is the unique name of the field.\"},\"properties2\":{\"name\":\"label\",\"example\":\"Select a folder\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"translatable\":\"1\",\"description\":\"(mandatory) (translatable) is the descriptive title of the field.\"},\"properties3\":{\"name\":\"directory\",\"example\":\"images\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"description\":\"(mandatory) is the filesystem path to the directory containing the folders to be listed.\"},\"properties4\":{\"name\":\"default\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is the default folder name.\"},\"properties5\":{\"name\":\"description\",\"example\":\"\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.\"},\"properties6\":{\"name\":\"filter\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a regular expression string which is used to filter the list of folders selected for inclusion in the drop-down list. If omitted, all folders in the directory are included. The filter argument expression is applied before the exclude argument expression. For information on constructing regular expressions see Regular expressions in parameter arguments.\"},\"properties7\":{\"name\":\"exclude\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a regular expression string which is used to exclude folders from the list. The exclude argument expression is applied after the filter argument expression. For information on constructing regular expressions see Regular expressions in parameter arguments.\"},\"properties8\":{\"name\":\"hide_none\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a Boolean argument. If true, the \'- Do not use -\' item is omitted from the drop-down list.\"},\"properties9\":{\"name\":\"hide_default\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a Boolean argument. If true, the \'- Use default -\' item is omitted from the drop-down list.\"},\"properties10\":{\"name\":\"showon\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) show this field on the bases of the value in another field. https:\\/\\/joomla.stackexchange.com\\/a\\/17682\\/2166\"}}', 'Provides a drop down list of folders from a specified directory.', '', 1, 4, '', 2, 'd3ab2ae4-9370-4497-ae6d-dee2e0b74b7a'),
(32, 'Note: When using the file input type you should always add the attribute enctype=\"multipart/form-data\" to your form tag. Otherwise, the uploaded files will not be attached correctly.\r\n\r\nNote 2: You can put a soft limit file size by adding a hidden field with name=\"MAX_FILE_SIZE\" and value the maximum allowed bytes which is handled by php, but you must also handle it in your code with or without it.', 'File', '{\"properties0\":{\"name\":\"type\",\"example\":\"file\",\"mandatory\":\"1\",\"description\":\"(mandatory) must be file.\"},\"properties1\":{\"name\":\"name\",\"example\":\"myfilevalue\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"description\":\"(mandatory) is the unique name of the field.\"},\"properties2\":{\"name\":\"label\",\"example\":\"Enter some text\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"translatable\":\"1\",\"description\":\"(mandatory) (translatable) is the descriptive title of the field.\"},\"properties3\":{\"name\":\"description\",\"example\":\"Choose an image from your computer with maximum 100KB\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.\"},\"properties4\":{\"name\":\"default\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) (not translatable) is the default value, but doesn\'t mean much for a file.\"},\"properties5\":{\"name\":\"size\",\"example\":\"10\",\"adjustable\":\"1\",\"description\":\"(optional) is the width of the file box in characters.\"},\"properties6\":{\"name\":\"accept\",\"example\":\"image\\/*\",\"adjustable\":\"1\",\"description\":\"(optional) Tells the browser what MIME types your form will allow to be uploaded.\"},\"properties7\":{\"name\":\"class\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a CSS class name for the HTML form field.\"},\"properties8\":{\"name\":\"labelclass\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) adds a CSS class for form field\'s label; for Joomla 2.5.4+\"},\"properties9\":{\"name\":\"disabled\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) HTML equivalent attribute\"},\"properties10\":{\"name\":\"onchange\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) HTML equivalent attribute (javascript use)\"},\"properties11\":{\"name\":\"required\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) For Joomla form validating it to be filled in\"},\"properties12\":{\"name\":\"validate\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) Whether to Joomla validate the field according to rules\"},\"properties13\":{\"name\":\"showon\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) Allows you to hide the field based on the value(s) of another field; for Joomla 3.2.4+ https:\\/\\/joomla.stackexchange.com\\/a\\/17682\\/2166\"}}', 'Provides an input field for files', '', 1, 9, '', 3, '6da71c1e-119c-4e0d-a309-f3e52ecfa1d1'), (32, 'Note: When using the file input type you should always add the attribute enctype=\"multipart/form-data\" to your form tag. Otherwise, the uploaded files will not be attached correctly.\r\n\r\nNote 2: You can put a soft limit file size by adding a hidden field with name=\"MAX_FILE_SIZE\" and value the maximum allowed bytes which is handled by php, but you must also handle it in your code with or without it.', 'File', '{\"properties0\":{\"name\":\"type\",\"example\":\"file\",\"mandatory\":\"1\",\"description\":\"(mandatory) must be file.\"},\"properties1\":{\"name\":\"name\",\"example\":\"myfilevalue\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"description\":\"(mandatory) is the unique name of the field.\"},\"properties2\":{\"name\":\"label\",\"example\":\"Enter some text\",\"adjustable\":\"1\",\"mandatory\":\"1\",\"translatable\":\"1\",\"description\":\"(mandatory) (translatable) is the descriptive title of the field.\"},\"properties3\":{\"name\":\"description\",\"example\":\"Choose an image from your computer with maximum 100KB\",\"adjustable\":\"1\",\"translatable\":\"1\",\"description\":\"(optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.\"},\"properties4\":{\"name\":\"default\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) (not translatable) is the default value, but doesn\'t mean much for a file.\"},\"properties5\":{\"name\":\"size\",\"example\":\"10\",\"adjustable\":\"1\",\"description\":\"(optional) is the width of the file box in characters.\"},\"properties6\":{\"name\":\"accept\",\"example\":\"image\\/*\",\"adjustable\":\"1\",\"description\":\"(optional) Tells the browser what MIME types your form will allow to be uploaded.\"},\"properties7\":{\"name\":\"class\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) is a CSS class name for the HTML form field.\"},\"properties8\":{\"name\":\"labelclass\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) adds a CSS class for form field\'s label; for Joomla 2.5.4+\"},\"properties9\":{\"name\":\"disabled\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) HTML equivalent attribute\"},\"properties10\":{\"name\":\"onchange\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) HTML equivalent attribute (javascript use)\"},\"properties11\":{\"name\":\"required\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) For Joomla form validating it to be filled in\"},\"properties12\":{\"name\":\"validate\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) Whether to Joomla validate the field according to rules\"},\"properties13\":{\"name\":\"showon\",\"example\":\"\",\"adjustable\":\"1\",\"description\":\"(optional) Allows you to hide the field based on the value(s) of another field; for Joomla 3.2.4+ https:\\/\\/joomla.stackexchange.com\\/a\\/17682\\/2166\"}}', 'Provides an input field for files', '', 1, 9, '', 3, '6da71c1e-119c-4e0d-a309-f3e52ecfa1d1'),

View File

@ -1,6 +1,7 @@
DROP TABLE IF EXISTS `#__componentbuilder_joomla_component`; DROP TABLE IF EXISTS `#__componentbuilder_joomla_component`;
DROP TABLE IF EXISTS `#__componentbuilder_joomla_module`; DROP TABLE IF EXISTS `#__componentbuilder_joomla_module`;
DROP TABLE IF EXISTS `#__componentbuilder_joomla_plugin`; DROP TABLE IF EXISTS `#__componentbuilder_joomla_plugin`;
DROP TABLE IF EXISTS `#__componentbuilder_joomla_power`;
DROP TABLE IF EXISTS `#__componentbuilder_power`; DROP TABLE IF EXISTS `#__componentbuilder_power`;
DROP TABLE IF EXISTS `#__componentbuilder_admin_view`; DROP TABLE IF EXISTS `#__componentbuilder_admin_view`;
DROP TABLE IF EXISTS `#__componentbuilder_custom_admin_view`; DROP TABLE IF EXISTS `#__componentbuilder_custom_admin_view`;

View File

@ -0,0 +1,28 @@
CREATE TABLE IF NOT EXISTS `#__componentbuilder_joomla_power` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.',
`description` TEXT NULL,
`guid` VARCHAR(36) NOT NULL DEFAULT '',
`settings` TEXT NOT NULL,
`system_name` VARCHAR(255) NOT NULL DEFAULT '',
`params` text NULL,
`published` TINYINT(3) NOT NULL DEFAULT 1,
`created_by` INT(10) unsigned NOT NULL DEFAULT 0,
`modified_by` INT(10) unsigned NOT NULL DEFAULT 0,
`created` DATETIME DEFAULT CURRENT_TIMESTAMP,
`modified` DATETIME DEFAULT NULL,
`checked_out` int(11) unsigned NOT NULL DEFAULT 0,
`checked_out_time` DATETIME DEFAULT NULL,
`version` INT(10) unsigned NOT NULL DEFAULT 1,
`hits` INT(10) unsigned NOT NULL DEFAULT 0,
`access` INT(10) unsigned NOT NULL DEFAULT 0,
`ordering` INT(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY `idx_system_name` (`system_name`),
KEY `idx_guid` (`guid`),
KEY `idx_access` (`access`),
KEY `idx_checkout` (`checked_out`),
KEY `idx_createdby` (`created_by`),
KEY `idx_modifiedby` (`modified_by`),
KEY `idx_state` (`published`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

View File

@ -0,0 +1,336 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Access\Access as AccessRules;
use Joomla\CMS\Access\Rules;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\String\PunycodeHelper;
use Joomla\CMS\Table\Observer\Tags as TableObserverTags;
use Joomla\CMS\Table\Observer\ContentHistory as TableObserverContenthistory;
use Joomla\CMS\Application\ApplicationHelper;
/**
* Joomla_powers Table class
*/
class ComponentbuilderTableJoomla_power extends Table
{
/**
* Ensure the params and metadata in json encoded in the bind method
*
* @var array
* @since 3.3
*/
protected $_jsonEncode = array('params', 'metadata');
/**
* Constructor
*
* @param object Database connector object
*/
function __construct(&$db)
{
parent::__construct('#__componentbuilder_joomla_power', 'id', $db);
// Adding History Options
TableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.joomla_power'));
}
public function bind($array, $ignore = '')
{
if (isset($array['params']) && is_array($array['params']))
{
$registry = new Registry;
$registry->loadArray($array['params']);
$array['params'] = (string) $registry;
}
if (isset($array['metadata']) && is_array($array['metadata']))
{
$registry = new Registry;
$registry->loadArray($array['metadata']);
$array['metadata'] = (string) $registry;
}
// Bind the rules.
if (isset($array['rules']) && is_array($array['rules']))
{
$rules = new AccessRules($array['rules']);
$this->setRules($rules);
}
return parent::bind($array, $ignore);
}
/**
* Overload the store method for the Joomla_power table.
*
* @param boolean Toggle whether null values should be updated.
* @return boolean True on success, false on failure.
* @since 1.6
*/
public function store($updateNulls = false)
{
$date = Factory::getDate();
$user = Factory::getUser();
if ($this->id)
{
// Existing item
$this->modified = $date->toSql();
$this->modified_by = $user->get('id');
}
else
{
// New joomla_power. A joomla_power created and created_by field can be set by the user,
// so we don't touch either of these if they are set.
if (!(int) $this->created)
{
$this->created = $date->toSql();
}
if (empty($this->created_by))
{
$this->created_by = $user->get('id');
}
}
if (isset($this->alias))
{
// Verify that the alias is unique
$table = Table::getInstance('joomla_power', 'ComponentbuilderTable');
if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0))
{
$this->setError(Text::_('COM_COMPONENTBUILDER_JOOMLA_POWER_ERROR_UNIQUE_ALIAS'));
if ($table->published === -2)
{
$this->setError(Text::_('COM_COMPONENTBUILDER_JOOMLA_POWER_ERROR_UNIQUE_ALIAS_TRASHED'));
}
return false;
}
}
if (isset($this->url))
{
// Convert IDN urls to punycode
$this->url = PunycodeHelper::urlToPunycode($this->url);
}
if (isset($this->website))
{
// Convert IDN urls to punycode
$this->website = PunycodeHelper::urlToPunycode($this->website);
}
return parent::store($updateNulls);
}
/**
* Overloaded check method to ensure data integrity.
*
* @return boolean True on success.
*/
public function check()
{
if (isset($this->alias))
{
// Generate a valid alias
$this->generateAlias();
$table = Table::getInstance('joomla_power', 'componentbuilderTable');
while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0))
{
$this->alias = StringHelper::increment($this->alias, 'dash');
}
}
/*
* Clean up keywords -- eliminate extra spaces between phrases
* and cr (\r) and lf (\n) characters from string.
* Only process if not empty.
*/
if (!empty($this->metakey))
{
// Array of characters to remove.
$bad_characters = array("\n", "\r", "\"", "<", ">");
// Remove bad characters.
$after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey);
// Create array using commas as delimiter.
$keys = explode(',', $after_clean);
$clean_keys = [];
foreach ($keys as $key)
{
// Ignore blank keywords.
if (trim($key))
{
$clean_keys[] = trim($key);
}
}
// Put array back together delimited by ", "
$this->metakey = implode(", ", $clean_keys);
}
// Clean up description -- eliminate quotes and <> brackets
if (!empty($this->metadesc))
{
// Only process if not empty
$bad_characters = array("\"", "<", ">");
$this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc);
}
// If we don't have any access rules set at this point just use an empty AccessRules class
if (!$this->getRules())
{
$rules = $this->getDefaultAssetValues('com_componentbuilder.joomla_power.'.$this->id);
$this->setRules($rules);
}
// Set ordering
if ($this->published < 0)
{
// Set ordering to 0 if state is archived or trashed
$this->ordering = 0;
}
return true;
}
/**
* Gets the default asset values for a component.
*
* @param $string $component The component asset name to search for
*
* @return AccessRules The AccessRules object for the asset
*/
protected function getDefaultAssetValues($component, $try = true)
{
// Need to find the asset id by the name of the component.
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__assets'))
->where($db->quoteName('name') . ' = ' . $db->quote($component));
$db->setQuery($query);
$db->execute();
if ($db->loadRowList())
{
// asset already set so use saved rules
$assetId = (int) $db->loadResult();
return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed.
}
// try again
elseif ($try)
{
$try = explode('.',$component);
$result = $this->getDefaultAssetValues($try[0], false);
if ($result instanceof AccessRules)
{
if (isset($try[1]))
{
$_result = (string) $result;
$_result = json_decode($_result);
foreach ($_result as $name => &$rule)
{
$v = explode('.', $name);
if ($try[1] !== $v[0])
{
// remove since it is not part of this view
unset($_result->$name);
}
else
{
// clear the value since we inherit
$rule = [];
}
}
// check if there are any view values remaining
if (count( (array) $_result))
{
$_result = json_encode($_result);
$_result = array($_result);
// Instantiate and return the AccessRules object for the asset rules.
$rules = new AccessRules;
$rules->mergeCollection($_result);
return $rules;
}
}
return $result;
}
}
return AccessRules::getAssetRules(0);
}
/**
* Method to compute the default name of the asset.
* The default name is in the form 'table_name.id'
* where id is the value of the primary key of the table.
*
* @return string
* @since 2.5
*/
protected function _getAssetName()
{
$k = $this->_tbl_key;
return 'com_componentbuilder.joomla_power.'.(int) $this->$k;
}
/**
* Method to return the title to use for the asset table.
*
* @return string
* @since 2.5
*/
protected function _getAssetTitle()
{
if (isset($this->title))
{
return $this->title;
}
return '';
}
/**
* Get the parent asset id for the record
*
* @return int
* @since 2.5
*/
protected function _getAssetParentId(?Table $table = null, $id = null)
{
$asset = Table::getInstance('Asset');
$asset->loadByName('com_componentbuilder');
return $asset->id;
}
/**
* This view does not actually have an alias
*
* @return bool
*/
public function generateAlias()
{
return false;
}
}

View File

@ -0,0 +1,25 @@
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
Joomla.submitbutton = function(task)
{
if (task == ''){
return false;
} else {
var action = task.split('.');
if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){
Joomla.submitform(task, document.getElementById("adminForm"));
return true;
} else {
alert(Joomla.JText._('joomla_power, some values are not acceptable.','Some values are unacceptable'));
return false;
}
}
}

View File

@ -0,0 +1,104 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper as Html;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
Html::addIncludePath(JPATH_COMPONENT.'/helpers/html');
Html::_('behavior.formvalidator');
Html::_('formbehavior.chosen', 'select');
Html::_('behavior.keepalive');
$componentParams = $this->params; // will be removed just use $this->params instead
?>
<script type="text/javascript">
// waiting spinner
var outerDiv = document.querySelector('body');
var loadingDiv = document.createElement('div');
loadingDiv.id = 'loading';
loadingDiv.style.cssText = "background: rgba(255, 255, 255, .8) url('components/com_componentbuilder/assets/images/import.gif') 50% 15% no-repeat; top: " + (outerDiv.getBoundingClientRect().top + window.pageYOffset) + "px; left: " + (outerDiv.getBoundingClientRect().left + window.pageXOffset) + "px; width: " + outerDiv.offsetWidth + "px; height: " + outerDiv.offsetHeight + "px; position: fixed; opacity: 0.80; -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80); filter: alpha(opacity=80); display: none;";
outerDiv.appendChild(loadingDiv);
loadingDiv.style.display = 'block';
// when page is ready remove and show
window.addEventListener('load', function() {
var componentLoader = document.getElementById('componentbuilder_loader');
if (componentLoader) componentLoader.style.display = 'block';
loadingDiv.style.display = 'none';
});
</script>
<div id="componentbuilder_loader" style="display: none;">
<form action="<?php echo Route::_('index.php?option=com_componentbuilder&layout=edit&id='. (int) $this->item->id . $this->referral); ?>" method="post" name="adminForm" id="adminForm" class="form-validate" enctype="multipart/form-data">
<?php echo LayoutHelper::render('joomla_power.joomla_power_above', $this); ?>
<div class="form-horizontal">
<?php echo Html::_('bootstrap.startTabSet', 'joomla_powerTab', ['active' => 'joomla_power', 'recall' => true]); ?>
<?php echo Html::_('bootstrap.addTab', 'joomla_powerTab', 'joomla_power', Text::_('COM_COMPONENTBUILDER_JOOMLA_POWER_JOOMLA_POWER', true)); ?>
<div class="row-fluid form-horizontal-desktop">
</div>
<div class="row-fluid form-horizontal-desktop">
<div class="span12">
<?php echo LayoutHelper::render('joomla_power.joomla_power_fullwidth', $this); ?>
</div>
</div>
<?php echo Html::_('bootstrap.endTab'); ?>
<?php $this->ignore_fieldsets = array('details','metadata','vdmmetadata','accesscontrol'); ?>
<?php $this->tab_name = 'joomla_powerTab'; ?>
<?php echo LayoutHelper::render('joomla.edit.params', $this); ?>
<?php if ($this->canDo->get('joomla_power.edit.created_by') || $this->canDo->get('joomla_power.edit.created') || $this->canDo->get('joomla_power.edit.state') || ($this->canDo->get('joomla_power.delete') && $this->canDo->get('joomla_power.edit.state'))) : ?>
<?php echo Html::_('bootstrap.addTab', 'joomla_powerTab', 'publishing', Text::_('COM_COMPONENTBUILDER_JOOMLA_POWER_PUBLISHING', true)); ?>
<div class="row-fluid form-horizontal-desktop">
<div class="span6">
<?php echo LayoutHelper::render('joomla_power.publishing', $this); ?>
</div>
<div class="span6">
<?php echo LayoutHelper::render('joomla_power.publlshing', $this); ?>
</div>
</div>
<?php echo Html::_('bootstrap.endTab'); ?>
<?php endif; ?>
<?php if ($this->canDo->get('core.admin')) : ?>
<?php echo Html::_('bootstrap.addTab', 'joomla_powerTab', 'permissions', Text::_('COM_COMPONENTBUILDER_JOOMLA_POWER_PERMISSION', true)); ?>
<div class="row-fluid form-horizontal-desktop">
<div class="span12">
<fieldset class="adminform">
<div class="adminformlist">
<?php foreach ($this->form->getFieldset('accesscontrol') as $field): ?>
<div>
<?php echo $field->label; echo $field->input;?>
</div>
<div class="clearfix"></div>
<?php endforeach; ?>
</div>
</fieldset>
</div>
</div>
<?php echo Html::_('bootstrap.endTab'); ?>
<?php endif; ?>
<?php echo Html::_('bootstrap.endTabSet'); ?>
<div>
<input type="hidden" name="task" value="joomla_power.edit" />
<?php echo Html::_('form.token'); ?>
</div>
</div>
</form>
</div>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,220 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\HTML\HTMLHelper as Html;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Toolbar\ToolbarHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Joomla_power Html View class
*/
class ComponentbuilderViewJoomla_power extends HtmlView
{
/**
* display method of View
* @return void
*/
public function display($tpl = null)
{
// set params
$this->params = ComponentHelper::getParams('com_componentbuilder');
// Assign the variables
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->script = $this->get('Script');
$this->state = $this->get('State');
// get action permissions
$this->canDo = ComponentbuilderHelper::getActions('joomla_power', $this->item);
// get input
$jinput = Factory::getApplication()->input;
$this->ref = $jinput->get('ref', 0, 'word');
$this->refid = $jinput->get('refid', 0, 'int');
$return = $jinput->get('return', null, 'base64');
// set the referral string
$this->referral = '';
if ($this->refid && $this->ref)
{
// return to the item that referred to this item
$this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid;
}
elseif($this->ref)
{
// return to the list view that referred to this item
$this->referral = '&ref=' . (string)$this->ref;
}
// check return value
if (!is_null($return))
{
// add the return value
$this->referral .= '&return=' . (string)$return;
}
// Set the toolbar
$this->addToolBar();
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}
// Display the template
parent::display($tpl);
// Set the document
$this->setDocument();
}
/**
* Setting the toolbar
*/
protected function addToolBar()
{
Factory::getApplication()->input->set('hidemainmenu', true);
$user = Factory::getUser();
$userId = $user->id;
$isNew = $this->item->id == 0;
ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_POWER_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_POWER_EDIT'), 'pencil-2 article-add');
// Built the actions for new and existing records.
if (StringHelper::check($this->referral))
{
if ($this->canDo->get('joomla_power.create') && $isNew)
{
// We can create the record.
ToolbarHelper::save('joomla_power.save', 'JTOOLBAR_SAVE');
}
elseif ($this->canDo->get('joomla_power.edit'))
{
// We can save the record.
ToolbarHelper::save('joomla_power.save', 'JTOOLBAR_SAVE');
}
if ($isNew)
{
// Do not creat but cancel.
ToolbarHelper::cancel('joomla_power.cancel', 'JTOOLBAR_CANCEL');
}
else
{
// We can close it.
ToolbarHelper::cancel('joomla_power.cancel', 'JTOOLBAR_CLOSE');
}
}
else
{
if ($isNew)
{
// For new records, check the create permission.
if ($this->canDo->get('joomla_power.create'))
{
ToolbarHelper::apply('joomla_power.apply', 'JTOOLBAR_APPLY');
ToolbarHelper::save('joomla_power.save', 'JTOOLBAR_SAVE');
ToolbarHelper::custom('joomla_power.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
};
ToolbarHelper::cancel('joomla_power.cancel', 'JTOOLBAR_CANCEL');
}
else
{
if ($this->canDo->get('joomla_power.edit'))
{
// We can save the new record
ToolbarHelper::apply('joomla_power.apply', 'JTOOLBAR_APPLY');
ToolbarHelper::save('joomla_power.save', 'JTOOLBAR_SAVE');
// We can save this record, but check the create permission to see
// if we can return to make a new one.
if ($this->canDo->get('joomla_power.create'))
{
ToolbarHelper::custom('joomla_power.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
}
}
$canVersion = ($this->canDo->get('core.version') && $this->canDo->get('joomla_power.version'));
if ($this->state->params->get('save_history', 1) && $this->canDo->get('joomla_power.edit') && $canVersion)
{
ToolbarHelper::versions('com_componentbuilder.joomla_power', $this->item->id);
}
if ($this->canDo->get('joomla_power.create'))
{
ToolbarHelper::custom('joomla_power.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
}
if ($this->canDo->get('joomla_power.reset'))
{
// add Reset button.
ToolbarHelper::custom('joomla_power.resetPowers', 'joomla custom-button-resetpowers', '', 'COM_COMPONENTBUILDER_RESET', false);
}
ToolbarHelper::cancel('joomla_power.cancel', 'JTOOLBAR_CLOSE');
}
}
ToolbarHelper::divider();
// set help url for this view if found
$this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_power');
if (StringHelper::check($this->help_url))
{
ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url);
}
}
/**
* Escapes a value for output in a view script.
*
* @param mixed $var The output to escape.
*
* @return mixed The escaped value.
*/
public function escape($var)
{
if(strlen($var) > 30)
{
// use the helper htmlEscape method instead and shorten the string
return StringHelper::html($var, $this->_charset, true, 30);
}
// use the helper htmlEscape method instead.
return StringHelper::html($var, $this->_charset);
}
/**
* Method to set up the document properties
*
* @return void
*/
protected function setDocument()
{
$isNew = ($this->item->id < 1);
$this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_POWER_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_POWER_EDIT'));
Html::_('stylesheet', "administrator/components/com_componentbuilder/assets/css/joomla_power.css", ['version' => 'auto']);
Html::_('script', $this->script, ['version' => 'auto']);
Html::_('script', "administrator/components/com_componentbuilder/views/joomla_power/submitbutton.js", ['version' => 'auto']);
Text::script('view not acceptable. Error');
}
/**
* Get the Document (helper method toward Joomla 4 and 5)
*/
public function getDocument()
{
$this->document ??= JFactory::getDocument();
return $this->document;
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,74 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\HTML\HTMLHelper as Html;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
Html::_('behavior.multiselect');
Html::_('dropdown.init');
Html::_('formbehavior.chosen', 'select');
Html::_('formbehavior.chosen', '.multipleAccessLevels', null, ['placeholder_text_multiple' => '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -']);
if ($this->saveOrder)
{
$saveOrderingUrl = 'index.php?option=com_componentbuilder&task=joomla_powers.saveOrderAjax&tmpl=component';
Html::_('sortablelist.sortable', 'joomla_powerList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl);
}
?>
<form action="<?php echo Route::_('index.php?option=com_componentbuilder&view=joomla_powers'); ?>" method="post" name="adminForm" id="adminForm">
<?php if(!empty( $this->sidebar)): ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif; ?>
<?php
// Add the trash helper layout
echo LayoutHelper::render('trashhelper', $this);
// Add the searchtools
echo LayoutHelper::render('joomla.searchtools.default', array('view' => $this));
?>
<?php if (empty($this->items)): ?>
<div class="alert alert-no-items">
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else : ?>
<table class="table table-striped" id="joomla_powerList">
<thead><?php echo $this->loadTemplate('head');?></thead>
<tfoot><?php echo $this->loadTemplate('foot');?></tfoot>
<tbody><?php echo $this->loadTemplate('body');?></tbody>
</table>
<?php // Load the batch processing form. ?>
<?php if ($this->canCreate && $this->canEdit) : ?>
<?php echo Html::_(
'bootstrap.renderModal',
'collapseModal',
array(
'title' => Text::_('COM_COMPONENTBUILDER_JOOMLA_POWERS_BATCH_OPTIONS'),
'footer' => $this->loadTemplate('batch_footer')
),
$this->loadTemplate('batch_body')
); ?>
<?php endif; ?>
<input type="hidden" name="boxchecked" value="0" />
</div>
<?php endif; ?>
<input type="hidden" name="task" value="" />
<?php echo Html::_('form.token'); ?>
</form>

View File

@ -0,0 +1,21 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper as Html;
?>
<p><?php echo Text::_('COM_COMPONENTBUILDER_JOOMLA_POWERS_BATCH_TIP'); ?></p>
<?php echo $this->batchDisplay; ?>

View File

@ -0,0 +1,25 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Language\Text;
?>
<!-- clear the batch values if cancel -->
<button class="btn" type="button" onclick="" data-dismiss="modal">
<?php echo Text::_('JCANCEL'); ?>
</button>
<!-- post the batch values if process -->
<button class="btn btn-success" type="submit" onclick="Joomla.submitbutton('joomla_power.batch');">
<?php echo Text::_('JGLOBAL_BATCH_PROCESS'); ?>
</button>

View File

@ -0,0 +1,96 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper as Html;
$edit = "index.php?option=com_componentbuilder&view=joomla_powers&task=joomla_power.edit";
?>
<?php foreach ($this->items as $i => $item): ?>
<?php
$canCheckin = $this->user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0;
$userChkOut = Factory::getUser($item->checked_out);
$canDo = ComponentbuilderHelper::getActions('joomla_power',$item,'joomla_powers');
?>
<tr class="row<?php echo $i % 2; ?>">
<td class="order nowrap center hidden-phone">
<?php if ($canDo->get('joomla_power.edit.state')): ?>
<?php
$iconClass = '';
if (!$this->saveOrder)
{
$iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED');
}
?>
<span class="sortable-handler<?php echo $iconClass; ?>">
<i class="icon-menu"></i>
</span>
<?php if ($this->saveOrder) : ?>
<input type="text" style="display:none" name="order[]" size="5"
value="<?php echo $item->ordering; ?>" class="width-20 text-area-order " />
<?php endif; ?>
<?php else: ?>
&#8942;
<?php endif; ?>
</td>
<td class="nowrap center">
<?php if ($canDo->get('joomla_power.edit')): ?>
<?php if ($item->checked_out) : ?>
<?php if ($canCheckin) : ?>
<?php echo Html::_('grid.id', $i, $item->id); ?>
<?php else: ?>
&#9633;
<?php endif; ?>
<?php else: ?>
<?php echo Html::_('grid.id', $i, $item->id); ?>
<?php endif; ?>
<?php else: ?>
&#9633;
<?php endif; ?>
</td>
<td class="nowrap">
<div>
<?php if ($canDo->get('joomla_power.edit')): ?>
<a href="<?php echo $edit; ?>&id=<?php echo $item->id; ?>"><?php echo $this->escape($item->system_name); ?></a>
<?php if ($item->checked_out): ?>
<?php echo Html::_('jgrid.checkedout', $i, $userChkOut->name, $item->checked_out_time, 'joomla_powers.', $canCheckin); ?>
<?php endif; ?>
<?php else: ?>
<?php echo $this->escape($item->system_name); ?>
<?php endif; ?><br /><small>GUID:
<?php echo $this->escape($item->guid); ?><?php if(isset($item->joomla_power_key)): ?><br />JPK: <?php echo $item->joomla_power_key; ?><?php endif; ?></small>
</div>
</td>
<td class="center">
<?php if ($canDo->get('joomla_power.edit.state')) : ?>
<?php if ($item->checked_out) : ?>
<?php if ($canCheckin) : ?>
<?php echo Html::_('jgrid.published', $item->published, $i, 'joomla_powers.', true, 'cb'); ?>
<?php else: ?>
<?php echo Html::_('jgrid.published', $item->published, $i, 'joomla_powers.', false, 'cb'); ?>
<?php endif; ?>
<?php else: ?>
<?php echo Html::_('jgrid.published', $item->published, $i, 'joomla_powers.', true, 'cb'); ?>
<?php endif; ?>
<?php else: ?>
<?php echo Html::_('jgrid.published', $item->published, $i, 'joomla_powers.', false, 'cb'); ?>
<?php endif; ?>
</td>
<td class="nowrap center hidden-phone">
<?php echo $item->id; ?>
</td>
</tr>
<?php endforeach; ?>

View File

@ -0,0 +1,18 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
?>
<tr>
<td colspan="5"><?php echo $this->pagination->getListFooter(); ?></td>
</tr>

View File

@ -0,0 +1,50 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper as Html;
?>
<tr>
<?php if ($this->canEdit&& $this->canState): ?>
<th width="1%" class="nowrap center hidden-phone">
<?php echo Html::_('searchtools.sort', '', 'a.ordering', $this->listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?>
</th>
<th width="20" class="nowrap center">
<?php echo Html::_('grid.checkall'); ?>
</th>
<?php else: ?>
<th width="20" class="nowrap center hidden-phone">
&#9662;
</th>
<th width="20" class="nowrap center">
&#9632;
</th>
<?php endif; ?>
<th class="nowrap" >
<?php echo Html::_('searchtools.sort', 'COM_COMPONENTBUILDER_JOOMLA_POWERS_NAME', 'a.system_name', $this->listDirn, $this->listOrder); ?>
</th>
<?php if ($this->canState): ?>
<th width="10" class="nowrap center" >
<?php echo Html::_('searchtools.sort', 'COM_COMPONENTBUILDER_JOOMLA_POWER_STATUS', 'a.published', $this->listDirn, $this->listOrder); ?>
</th>
<?php else: ?>
<th width="10" class="nowrap center" >
<?php echo Text::_('COM_COMPONENTBUILDER_JOOMLA_POWER_STATUS'); ?>
</th>
<?php endif; ?>
<th width="5" class="nowrap center hidden-phone" >
<?php echo Html::_('searchtools.sort', 'COM_COMPONENTBUILDER_JOOMLA_POWER_ID', 'a.id', $this->listDirn, $this->listOrder); ?>
</th>
</tr>

View File

@ -0,0 +1,48 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper as Html;
?>
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
<label for="filter_search" class="element-invisible"><?php echo Text::_('Search');?></label>
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo Text::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo Html::tooltipText('Search Joomla_powers'); ?>" />
</div>
<div class="btn-group pull-left">
<button type="submit" class="btn hasTooltip" title="<?php echo Html::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><i class="icon-search"></i></button>
<button type="button" class="btn hasTooltip" title="<?php echo Html::tooltipText('JSEARCH_FILTER_CLEAR'); ?>" onclick="document.id('filter_search').value='';this.form.submit();"><i class="icon-remove"></i></button>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="limit" class="element-invisible"><?php echo Text::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC');?></label>
<?php echo $this->pagination->getLimitBox(); ?>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="directionTable" class="element-invisible"><?php echo Text::_('JFIELD_ORDERING_DESC');?></label>
<select name="directionTable" id="directionTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo Text::_('JFIELD_ORDERING_DESC');?></option>
<option value="asc" <?php if ($this->listDirn == 'asc') echo 'selected="selected"'; ?>><?php echo Text::_('JGLOBAL_ORDER_ASCENDING');?></option>
<option value="desc" <?php if ($this->listDirn == 'desc') echo 'selected="selected"'; ?>><?php echo Text::_('JGLOBAL_ORDER_DESCENDING');?></option>
</select>
</div>
<div class="btn-group pull-right">
<label for="sortTable" class="element-invisible"><?php echo Text::_('JGLOBAL_SORT_BY');?></label>
<select name="sortTable" id="sortTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo Text::_('JGLOBAL_SORT_BY');?></option>
<?php echo Html::_('select.options', $this->getSortFields(), 'value', 'text', $this->listOrder);?>
</select>
</div>
</div>
<div class="clearfix"> </div>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,254 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\HTML\HTMLHelper as Html;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Toolbar\ToolbarHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Componentbuilder Html View class for the Joomla_powers
*/
class ComponentbuilderViewJoomla_powers extends HtmlView
{
/**
* Joomla_powers view display method
* @return void
*/
function display($tpl = null)
{
if ($this->getLayout() !== 'modal')
{
// Include helper submenu
ComponentbuilderHelper::addSubmenu('joomla_powers');
}
// Assign data to the view
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->user = Factory::getUser();
// Load the filter form from xml.
$this->filterForm = $this->get('FilterForm');
// Load the active filters.
$this->activeFilters = $this->get('ActiveFilters');
// Add the list ordering clause.
$this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id'));
$this->listDirn = $this->escape($this->state->get('list.direction', 'desc'));
$this->saveOrder = $this->listOrder == 'a.ordering';
// set the return here value
$this->return_here = urlencode(base64_encode((string) Uri::getInstance()));
// get global action permissions
$this->canDo = ComponentbuilderHelper::getActions('joomla_power');
$this->canEdit = $this->canDo->get('joomla_power.edit');
$this->canState = $this->canDo->get('joomla_power.edit.state');
$this->canCreate = $this->canDo->get('joomla_power.create');
$this->canDelete = $this->canDo->get('joomla_power.delete');
$this->canBatch = ($this->canDo->get('joomla_power.batch') && $this->canDo->get('core.batch'));
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')
{
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
// load the batch html
if ($this->canCreate && $this->canEdit && $this->canState)
{
$this->batchDisplay = JHtmlBatch_::render();
}
}
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}
// Display the template
parent::display($tpl);
// Set the document
$this->setDocument();
}
/**
* Setting the toolbar
*/
protected function addToolBar()
{
JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=joomla_powers');
ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_JOOMLA_POWERS'), 'joomla');
FormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields');
if ($this->canCreate)
{
ToolbarHelper::addNew('joomla_power.add');
}
// Only load if there are items
if (ArrayHelper::check($this->items))
{
if ($this->canEdit)
{
ToolbarHelper::editList('joomla_power.edit');
}
if ($this->canState)
{
ToolbarHelper::publishList('joomla_powers.publish');
ToolbarHelper::unpublishList('joomla_powers.unpublish');
ToolbarHelper::archiveList('joomla_powers.archive');
if ($this->canDo->get('core.admin'))
{
ToolbarHelper::checkin('joomla_powers.checkin');
}
}
// Add a batch button
if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState)
{
// Get the toolbar object instance
$bar = Toolbar::getInstance('toolbar');
// set the batch button name
$title = Text::_('JTOOLBAR_BATCH');
// Instantiate a new JLayoutFile instance and render the batch button
$layout = new FileLayout('joomla.toolbar.batch');
// add the button to the page
$dhtml = $layout->render(array('title' => $title));
$bar->appendButton('Custom', $dhtml, 'batch');
}
if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete))
{
ToolbarHelper::deleteList('', 'joomla_powers.delete', 'JTOOLBAR_EMPTY_TRASH');
}
elseif ($this->canState && $this->canDelete)
{
ToolbarHelper::trash('joomla_powers.trash');
}
}
if ($this->user->authorise('joomla_power.init', 'com_componentbuilder'))
{
// add Init button.
ToolbarHelper::custom('joomla_powers.initPowers', 'health custom-button-initpowers', '', 'COM_COMPONENTBUILDER_INIT', false);
}
if ($this->user->authorise('joomla_power.reset', 'com_componentbuilder'))
{
// add Reset button.
ToolbarHelper::custom('joomla_powers.resetPowers', 'joomla custom-button-resetpowers', '', 'COM_COMPONENTBUILDER_RESET', false);
}
// set help url for this view if found
$this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_powers');
if (StringHelper::check($this->help_url))
{
ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url);
}
// add the options comp button
if ($this->canDo->get('core.admin') || $this->canDo->get('core.options'))
{
ToolbarHelper::preferences('com_componentbuilder');
}
// Only load published batch if state and batch is allowed
if ($this->canState && $this->canBatch)
{
JHtmlBatch_::addListSelection(
Text::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'),
'batch[published]',
Html::_('select.options', Html::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true)
);
}
// Only load access batch if create, edit and batch is allowed
if ($this->canBatch && $this->canCreate && $this->canEdit)
{
JHtmlBatch_::addListSelection(
Text::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'),
'batch[access]',
Html::_('select.options', Html::_('access.assetgroups'), 'value', 'text')
);
}
}
/**
* Method to set up the document properties
*
* @return void
*/
protected function setDocument()
{
if (!isset($this->document))
{
$this->document = Factory::getDocument();
}
$this->document->setTitle(Text::_('COM_COMPONENTBUILDER_JOOMLA_POWERS'));
Html::_('stylesheet', "administrator/components/com_componentbuilder/assets/css/joomla_powers.css", ['version' => 'auto']);
}
/**
* Escapes a value for output in a view script.
*
* @param mixed $var The output to escape.
*
* @return mixed The escaped value.
*/
public function escape($var)
{
if(strlen($var) > 50)
{
// use the helper htmlEscape method instead and shorten the string
return StringHelper::html($var, $this->_charset, true);
}
// use the helper htmlEscape method instead.
return StringHelper::html($var, $this->_charset);
}
/**
* Returns an array of fields the table can be sorted by
*
* @return array Array containing the field name to sort by as the key and display text as value
*/
protected function getSortFields()
{
return array(
'a.ordering' => Text::_('JGRID_HEADING_ORDERING'),
'a.published' => Text::_('JSTATUS'),
'a.system_name' => Text::_('COM_COMPONENTBUILDER_JOOMLA_POWER_SYSTEM_NAME_LABEL'),
'a.id' => Text::_('JGRID_HEADING_ID')
);
}
/**
* Get the Document (helper method toward Joomla 4 and 5)
*/
public function getDocument()
{
$this->document ??= JFactory::getDocument();
return $this->document;
}
}

View File

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.10" method="upgrade"> <extension type="component" version="3.10" method="upgrade">
<name>COM_COMPONENTBUILDER</name> <name>COM_COMPONENTBUILDER</name>
<creationDate>9th April, 2024</creationDate> <creationDate>16th April, 2024</creationDate>
<author>Llewellyn van der Merwe</author> <author>Llewellyn van der Merwe</author>
<authorEmail>joomla@vdm.io</authorEmail> <authorEmail>joomla@vdm.io</authorEmail>
<authorUrl>https://dev.vdm.io</authorUrl> <authorUrl>https://dev.vdm.io</authorUrl>
<copyright>Copyright (C) 2015 Vast Development Method. All rights reserved.</copyright> <copyright>Copyright (C) 2015 Vast Development Method. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license> <license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<version>3.2.1-alpha3</version> <version>3.2.1-alpha4</version>
<description><![CDATA[ <description><![CDATA[
<h1>Component Builder (v.3.2.1-alpha3)</h1> <h1>Component Builder (v.3.2.1-alpha4)</h1>
<div style="clear: both;"></div> <div style="clear: both;"></div>
<p>The Component Builder for [Joomla](https://extensions.joomla.org/extension/component-builder/) is highly advanced tool that is truly able to build extremely complex components in a fraction of the time. <p>The Component Builder for [Joomla](https://extensions.joomla.org/extension/component-builder/) is highly advanced tool that is truly able to build extremely complex components in a fraction of the time.
@ -78,6 +78,7 @@ Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/compo
<menu option="com_componentbuilder" view="joomla_components">COM_COMPONENTBUILDER_MENU_JOOMLA_COMPONENTS</menu> <menu option="com_componentbuilder" view="joomla_components">COM_COMPONENTBUILDER_MENU_JOOMLA_COMPONENTS</menu>
<menu option="com_componentbuilder" view="joomla_modules">COM_COMPONENTBUILDER_MENU_JOOMLA_MODULES</menu> <menu option="com_componentbuilder" view="joomla_modules">COM_COMPONENTBUILDER_MENU_JOOMLA_MODULES</menu>
<menu option="com_componentbuilder" view="joomla_plugins">COM_COMPONENTBUILDER_MENU_JOOMLA_PLUGINS</menu> <menu option="com_componentbuilder" view="joomla_plugins">COM_COMPONENTBUILDER_MENU_JOOMLA_PLUGINS</menu>
<menu option="com_componentbuilder" view="joomla_powers">COM_COMPONENTBUILDER_MENU_JOOMLA_POWERS</menu>
<menu option="com_componentbuilder" view="powers">COM_COMPONENTBUILDER_MENU_POWERS</menu> <menu option="com_componentbuilder" view="powers">COM_COMPONENTBUILDER_MENU_POWERS</menu>
<menu option="com_componentbuilder" view="search">COM_COMPONENTBUILDER_MENU_SEARCH</menu> <menu option="com_componentbuilder" view="search">COM_COMPONENTBUILDER_MENU_SEARCH</menu>
<menu option="com_componentbuilder" view="admin_views">COM_COMPONENTBUILDER_MENU_ADMIN_VIEWS</menu> <menu option="com_componentbuilder" view="admin_views">COM_COMPONENTBUILDER_MENU_ADMIN_VIEWS</menu>

View File

@ -1613,4 +1613,22 @@
<maintainerurl>https://dev.vdm.io</maintainerurl> <maintainerurl>https://dev.vdm.io</maintainerurl>
<targetplatform name="joomla" version="3.*"/> <targetplatform name="joomla" version="3.*"/>
</update> </update>
<update>
<name>Component Builder</name>
<description>Builds Complex Joomla Components</description>
<element>pkg_component_builder</element>
<type>package</type>
<client>site</client>
<version>3.2.1-alpha4</version>
<infourl title="Component Builder!">https://dev.vdm.io</infourl>
<downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.2.1-alpha4.zip</downloadurl>
</downloads>
<tags>
<tag>alpha</tag>
</tags>
<maintainer>Llewellyn van der Merwe</maintainer>
<maintainerurl>https://dev.vdm.io</maintainerurl>
<targetplatform name="joomla" version="3.*"/>
</update>
</updates> </updates>

View File

@ -15,9 +15,9 @@ namespace VDM\Joomla\Componentbuilder\Abstraction;
use Joomla\Registry\Registry as JoomlaRegistry; use Joomla\Registry\Registry as JoomlaRegistry;
use Joomla\CMS\Factory; use Joomla\CMS\Factory;
use Joomla\Input\Input; use Joomla\Input\Input;
use VDM\Joomla\Abstraction\BaseConfig as Config;
use VDM\Joomla\Utilities\Component\Helper; use VDM\Joomla\Utilities\Component\Helper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper; use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Abstraction\BaseConfig as ExtendingBaseConfig;
/** /**
@ -25,7 +25,7 @@ use VDM\Joomla\Utilities\String\ClassfunctionHelper;
* *
* @since 3.2.0 * @since 3.2.0
*/ */
abstract class BaseConfig extends Config abstract class BaseConfig extends ExtendingBaseConfig
{ {
/** /**
* Hold a JInput object for easier access to the input variables. * Hold a JInput object for easier access to the input variables.

View File

@ -800,6 +800,62 @@ class Config extends BaseConfig
return array_values($approved); return array_values($approved);
} }
/**
* Get super power core organisation
*
* @return string The super power core organisation
* @since 3.2.0
*/
protected function getJoomlapowerscoreorganisation(): string
{
// the VDM default organisation is [joomla]
$organisation = 'joomla';
return $this->params->get('joomla_powers_core_organisation', $organisation);
}
/**
* Get Joomla power init repos
*
* @return array The init repositories on Gitea
* @since 3.2.0
*/
protected function getJoomlapowersinitrepos(): array
{
// some defaults repos we need by JCB
$repos = [];
$repos[$this->joomla_powers_core_organisation . '.joomla-powers'] = (object) ['owner' => $this->joomla_powers_core_organisation, 'repo' => 'joomla-powers', 'branch' => 'master'];
return $repos;
}
/**
* Get local joomla super powers repository path
*
* @return string The path to the local repository
* @since 3.2.0
*/
protected function getLocaljoomlapowersrepositorypath(): string
{
$default = $this->tmp_path . '/joomla_powers';
return $this->params->get('local_joomla_powers_repository_path', $default);
}
/**
* Get joomla power approved paths
*
* @return array The paths to the repositories on Gitea
* @since 3.2.0
*/
protected function getApprovedjoomlapaths(): array
{
// some defaults repos we need by JCB
$approved = $this->joomla_powers_init_repos;
return array_values($approved);
}
/** /**
* get bom path * get bom path
* *

View File

@ -18,6 +18,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder; use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language\Extractor; use VDM\Joomla\Componentbuilder\Compiler\Language\Extractor;
use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor as Power; use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor as Power;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Extractor as JoomlaPower;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\External; use VDM\Joomla\Componentbuilder\Compiler\Customcode\External;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Utilities\StringHelper; use VDM\Joomla\Utilities\StringHelper;
@ -111,6 +112,14 @@ class Customcode implements CustomcodeInterface
**/ **/
protected Power $power; protected Power $power;
/**
* Joomla Power Extractor
*
* @var Power
* @since 3.2.0
**/
protected JoomlaPower $joomla;
/** /**
* Compiler Custom Code External * Compiler Custom Code External
* *
@ -129,23 +138,25 @@ class Customcode implements CustomcodeInterface
/** /**
* Constructor. * Constructor.
* *
* @param Config|null $config The compiler config object. * @param Config $config The compiler config object.
* @param Placeholder|null $placeholder The compiler placeholder object. * @param Placeholder $placeholder The compiler placeholder object.
* @param Extractor|null $extractor The compiler language extractor object. * @param Extractor $extractor The compiler language extractor object.
* @param Power|null $power The compiler power extractor object. * @param Power $power The compiler power extractor object.
* @param External|null $external The compiler external custom code object. * @param JoomlaPower $joomla The compiler joomla power extractor object.
* @param \JDatabaseDriver $db The Database Driver object. * @param External $external The compiler external custom code object.
* @param \JDatabaseDriver $db The Database Driver object.
* *
* @since 3.2.0 * @since 3.2.0
*/ */
public function __construct(?Config $config = null, ?Placeholder $placeholder = null, public function __construct(Config $config, Placeholder $placeholder,
?Extractor $extractor = null, ?Power $power = null, ?External $external = null) Extractor $extractor, Power $power, JoomlaPower $joomla, External $external)
{ {
$this->config = $config ?: Compiler::_('Config'); $this->config = $config;
$this->placeholder = $placeholder ?: Compiler::_('Placeholder'); $this->placeholder = $placeholder;
$this->extractor = $extractor ?: Compiler::_('Language.Extractor'); $this->extractor = $extractor;
$this->power = $power ?: Compiler::_('Power.Extractor'); $this->power = $power;
$this->external = $external ?: Compiler::_('Customcode.External'); $this->joomla = $joomla;
$this->external = $external;
$this->db = Factory::getDbo(); $this->db = Factory::getDbo();
} }
@ -170,8 +181,9 @@ class Customcode implements CustomcodeInterface
) )
); );
// extract any found super powers // extract any found powers
$this->power->search($string); $this->power->search($string);
$this->joomla->search($string);
} }
// if debug // if debug
if ($debug) if ($debug)

View File

@ -25,6 +25,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Service\Language;
use VDM\Joomla\Componentbuilder\Compiler\Service\Placeholder; use VDM\Joomla\Componentbuilder\Compiler\Service\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Service\Customcode; use VDM\Joomla\Componentbuilder\Compiler\Service\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Service\Power; use VDM\Joomla\Componentbuilder\Compiler\Service\Power;
use VDM\Joomla\Componentbuilder\Compiler\Service\JoomlaPower;
use VDM\Joomla\Componentbuilder\Compiler\Service\Component; use VDM\Joomla\Componentbuilder\Compiler\Service\Component;
use VDM\Joomla\Componentbuilder\Compiler\Service\Adminview; use VDM\Joomla\Componentbuilder\Compiler\Service\Adminview;
use VDM\Joomla\Componentbuilder\Compiler\Service\Library; use VDM\Joomla\Componentbuilder\Compiler\Service\Library;
@ -157,6 +158,7 @@ abstract class Factory implements FactoryInterface
->registerServiceProvider(new Placeholder()) ->registerServiceProvider(new Placeholder())
->registerServiceProvider(new Customcode()) ->registerServiceProvider(new Customcode())
->registerServiceProvider(new Power()) ->registerServiceProvider(new Power())
->registerServiceProvider(new JoomlaPower())
->registerServiceProvider(new Component()) ->registerServiceProvider(new Component())
->registerServiceProvider(new Adminview()) ->registerServiceProvider(new Adminview())
->registerServiceProvider(new Library()) ->registerServiceProvider(new Library())

View File

@ -405,7 +405,7 @@ class Compiler extends Infusion
{ {
CFactory::_('Power')->load($super_powers); CFactory::_('Power')->load($super_powers);
} }
// set the autoloader for Powers // set the autoloader for Powers (second time)
CFactory::_('Power.Autoloader')->set(); CFactory::_('Power.Autoloader')->set();
// get the bom file // get the bom file
$bom = FileHelper::getContent(CFactory::_('Config')->bom_path); $bom = FileHelper::getContent(CFactory::_('Config')->bom_path);
@ -739,7 +739,11 @@ class Compiler extends Infusion
); );
// inject any super powers found // inject any super powers found
$answer = CFactory::_('Power.Injector')->power($answer); $answer = CFactory::_('Joomla.Power.Injector')->power(
CFactory::_('Power.Injector')->power(
$answer
)
);
// add answer back to file // add answer back to file
CFactory::_('Utilities.File')->write($path, $answer); CFactory::_('Utilities.File')->write($path, $answer);

View File

@ -2144,6 +2144,9 @@ class Infusion extends Interpretation
); );
} }
// set the autoloader for Powers (first time)
CFactory::_('Power.Autoloader')->set();
// tweak system to set stuff to the module domain // tweak system to set stuff to the module domain
$_backup_target = CFactory::_('Config')->build_target; $_backup_target = CFactory::_('Config')->build_target;
$_backup_lang = CFactory::_('Config')->lang_target; $_backup_lang = CFactory::_('Config')->lang_target;

View File

@ -0,0 +1,61 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power;
/**
* Compiler Power Extractor
* @since 3.2.1
*/
interface ExtractorInterface
{
/**
* Get Super Powers from the code string
*
* @param string $code The code
*
* @return array|null
* @since 3.2.0
*/
public function get_(): ?array;
/**
* Get Super Powers from the code string
*
* @param string $code The code
*
* @return array|null
* @since 3.2.0
*/
public function get(string $code): ?array;
/**
* Get Super Powers from the code string
*
* @param string $code The code
*
* @return array|null
* @since 3.2.0
*/
public function reverse(string $code): ?array;
/**
* Get Super Powers from the code string and load it
*
* @param string $code The code
*
* @return void
* @since 3.2.0
*/
public function search(string $code): void;
}

View File

@ -0,0 +1,31 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power;
/**
* Compiler Power Injector
* @since 3.2.1
*/
interface InjectorInterface
{
/**
* Inject the powers found in the code
*
* @param string $code The class code
*
* @return string The updated code
* @since 3.2.0
*/
public function power(string $code): string;
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,446 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler;
use Joomla\CMS\Factory;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\GuidHelper;
use VDM\Joomla\Utilities\String\NamespaceHelper;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\JoomlaPower\Super as SuperPower;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PowerInterface;
/**
* Joomla Power
*
* @since 3.2.1
*/
final class JoomlaPower implements PowerInterface
{
/**
* All loaded powers
*
* @var array
* @since 3.2.1
**/
public array $active = [];
/**
* All power namespaces
*
* @var array
* @since 3.2.1
**/
public array $namespace = [];
/**
* All super powers of this build
*
* @var array
* @since 3.2.1
**/
public array $superpowers = [];
/**
* Old super powers found in the local repos
*
* @var array
* @since 3.2.1
**/
public array $old_superpowers = [];
/**
* The url to the power, if there is an error.
*
* @var string
* @since 3.2.1
**/
protected string $fixUrl;
/**
* The state of all loaded powers
*
* @var array
* @since 3.2.1
**/
protected array $state = [];
/**
* The state of retry to loaded powers
*
* @var array
* @since 3.2.1
**/
protected array $retry = [];
/**
* Compiler Config
*
* @var Config
* @since 3.2.1
**/
protected Config $config;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.1
**/
protected Placeholder $placeholder;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.1
**/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.1
**/
protected Gui $gui;
/**
* The JCB Superpower class
*
* @var Superpower
* @since 3.2.1
**/
protected Superpower $superpower;
/**
* Database object to query local DB
*
* @since 3.2.1
**/
protected $db;
/**
* Database object to query local DB
*
* @since 3.2.1
**/
protected $app;
/**
* Constructor.
*
* @param Config $config The compiler config object.
* @param Placeholder $placeholder The compiler placeholder object.
* @param Customcode $customcode The compiler customcode object.
* @param Gui $gui The compiler customcode gui object.
* @param Superpower $superpower The JCB superpower object.
*
* @throws \Exception
* @since 3.2.1
*/
public function __construct(Config $config, Placeholder $placeholder,
Customcode $customcode, Gui $gui, Superpower $superpower)
{
$this->config = $config;
$this->placeholder = $placeholder;
$this->customcode = $customcode;
$this->gui = $gui;
$this->superpower = $superpower;
$this->db = Factory::getDbo();
$this->app = Factory::getApplication();
}
/**
* load all the powers linked to this component
*
* @param array $guids The global unique ids of the linked powers
*
* @return void
* @since 3.2.1
*/
public function load(array $guids)
{
if (ArrayHelper::check($guids))
{
foreach ($guids as $guid => $build)
{
$this->get($guid, $build);
}
}
}
/**
* Get a power
*
* @param string $guid The global unique id of the power
* @param int $build Force build switch (to override global switch)
*
* @return object|null
* @since 3.2.1
*/
public function get(string $guid, int $build = 0): ?object
{
if (($this->config->get('add_power', true) || $build == 1) && $this->set($guid))
{
return $this->active[$guid];
}
return null;
}
/**
* Set a power
*
* @param string $guid The global unique id of the power
*
* @return bool true on successful setting of a power
* @since 3.2.1
*/
private function set(string $guid): bool
{
// check if we have been here before
if ($this->isPowerSet($guid))
{
return $this->state[$guid];
}
elseif ($this->isGuidValid($guid))
{
// get the power data
$this->active[$guid] = $this->getPowerData($guid);
if (is_object($this->active[$guid]))
{
// make sure that in recursion we
// don't try to load this power again
// since during the load of a power we also load
// all powers linked to it
$this->state[$guid] = true;
// convert settings to an array
if (JsonHelper::check($this->active[$guid]->settings))
{
$this->active[$guid]->settings = $settings
= json_decode($this->active[$guid]->settings, true);
}
// set a target version
$joomla_version = $this->config->joomla_version;
if ($joomla_version && ArrayHelper::check($settings))
{
foreach ($settings as $namespace)
{
if ($joomla_version == $namespace['joomla_version'] ||
$namespace['joomla_version'] == 0)
{
$this->active[$guid]->namespace = $namespace['namespace'];
$this->active[$guid]->type = $namespace['type'] ?? 'class';
break;
}
}
$this->active[$guid]->class_name =
$this->extractLastNameFromNamespace($this->active[$guid]->namespace);
$this->active[$guid]->_namespace =
$this->removeLastNameFromNamespace($this->active[$guid]->namespace);
// set the approved super power values
$this->setSuperPowers($guid);
return true;
}
}
}
// we failed to get the power,
// so we raise an error message
// only if guid is valid
if ($this->isGuidValid($guid))
{
// now we search for it via the super power paths
if (empty($this->retry[$guid]) && $this->superpower->load($guid, ['remote', 'local']))
{
// we found it and it was loaded into the database
unset($this->state[$guid]);
unset($this->active[$guid]);
// we make sure that this retry only happen once! (just in-case...)
$this->retry[$guid] = true;
// so we try to load it again
return $this->set($guid);
}
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_PJOOMLA_POWER_BGUIDSB_NOT_FOUNDP', $guid),
'Error'
);
}
// let's not try again
$this->state[$guid] = false;
return false;
}
/**
* Extracts the last part of a namespace string, which is typically the class name.
*
* @param string $namespace The namespace string to extract from.
*
* @return string|null The extracted class name.
* @since 3.2.1
*/
private function extractLastNameFromNamespace(string $namespace): ?string
{
$parts = explode('\\', $namespace);
$result = end($parts);
// Remove '\\' from the beginning and end of the resulting string
$result = trim($result, '\\');
// If the resulting string is empty, return null
return empty($result) ? null : $result;
}
/**
* Removes the last name from the namespace.
*
* @param string $namespace The namespace
*
* @return string The namespace shortened
* @since 3.2.1
*/
private function removeLastNameFromNamespace(string $namespace): string
{
// Remove '\\' from the beginning and end of the resulting string
$namespace = trim($namespace, '\\');
$parts = explode('\\', $namespace);
// Remove the last part (the class name)
array_pop($parts);
// Reassemble the namespace without the class name
return implode('\\', $parts);
}
/**
* Check if the power is already set
*
* @param string $guid The global unique id of the power
*
* @return bool true if the power is already set
* @since 3.2.1
*/
private function isPowerSet(string $guid): bool
{
return isset($this->state[$guid]);
}
/**
* Validate the GUID
*
* @param string $guid The global unique id of the power
*
* @return bool true if the GUID is valid
* @since 3.2.1
*/
private function isGuidValid(string $guid): bool
{
return GuidHelper::valid($guid);
}
/**
* Get the power data from the database
*
* @param string $guid The global unique id of the power
*
* @return object|null The power data
* @since 3.2.1
*/
private function getPowerData(string $guid): ?object
{
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->from('#__componentbuilder_joomla_power AS a');
$query->where($this->db->quoteName('a.guid') . ' = ' . $this->db->quote($guid));
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
return $this->db->loadObject();
}
return null;
}
/**
* Get Clean Namespace without use or ; as part of the name space
*
* @param string $namespace The actual name space
* @param bool $removeNumbers The switch to remove numbers
*
* @return string
* @since 3.2.1
*/
private function getCleanNamespace(string $namespace): string
{
// trim possible (use) or (;) or (starting or ending \) added to the namespace
return NamespaceHelper::safe(str_replace(['use ', ';'], '', $namespace));
}
/**
* Get [use Namespace\Class;]
*
* @param string $namespace The actual name space
* @param string $as The use as name (default is none)
*
* @return string
* @since 3.2.1
*/
private function getUseNamespace(string $namespace, string $as = 'default'): string
{
// check if it has an AS option
if ($as !== 'default')
{
return 'use ' . $namespace . ' as ' . $as . ';';
}
return 'use ' . $namespace . ';';
}
/**
* Set the super powers of this power
*
* @param string $guid The global unique id of the power
*
* @return void
* @since 3.2.1
*/
private function setSuperPowers(string $guid): void
{
// soon
}
}

View File

@ -0,0 +1,118 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\JoomlaPower;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\ExtractorInterface;
use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor as ExtendingExtractor;
/**
* Compiler Joomla Power Extractor
* @since 3.2.1
*/
final class Extractor extends ExtendingExtractor implements ExtractorInterface
{
/**
* The pattern to get the powers
*
* @var string
* @since 3.2.0
**/
protected string $pattern = '/Joomla_'.'_'.'_[a-zA-Z0-9_]+_'.'_'.'_Power/';
/**
* The pattern to get the Front
*
* @var string
* @since 3.2.1
**/
protected string $_pattern = 'Joomla';
/**
* The pattern to get the Back
*
* @var string
* @since 3.2.1
**/
protected string $pattern_ = 'Power';
/**
* The Table
*
* @var string
* @since 3.2.1
**/
protected string $table = 'joomla_power';
/**
* Current Joomla Version Being Build
*
* @var int
* @since 3.2.0
**/
protected $targetVersion;
/**
* Constructor.
*
* @param int $targetVersion The targeted Joomla version.
*
* @since 3.2.1
*/
public function __construct(int $targetVersion)
{
parent::__construct();
$this->targetVersion = $targetVersion;
}
/**
* Get the complete namespace strings of the guids passed as an array.
*
* @param array $guids The guids to filter the results
*
* @return array|null The result namespaces with their guids
* @since 3.2.0
**/
protected function namespaces(array $guids): ?array
{
$query = $this->db->getQuery(true);
$query->select($this->db->quoteName(['settings', 'guid']))
->from($this->db->quoteName('#__componentbuilder_' . $this->table))
->where($this->db->quoteName('guid') . ' IN (' . implode(',', array_map([$this->db, 'quote'], $guids)) . ')');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
$namespaces = [];
$items = $this->db->loadAssocList();
foreach ($items as $item)
{
if (JsonHelper::check($item->settings))
{
$item->settings = json_decode($item->settings, true);
echo '<pre>'; var_dump($item->settings, 'Joomla Version: ' . $this->targetVersion); exit;
}
}
if ($namespaces !== [])
{
return $namespaces;
}
}
return null;
}
}

View File

@ -0,0 +1,91 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\JoomlaPower;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\InjectorInterface;
use VDM\Joomla\Componentbuilder\Compiler\Power\Injector as ExtendingInjector;
/**
* Compiler Joomla Power Injector
* @since 3.2.0
*/
final class Injector extends ExtendingInjector implements InjectorInterface
{
/**
* Builds the namespace statement from the power object's namespace and class name.
*
* @param object $power The power object.
*
* @return string The constructed use statement.
* @since 3.2.0
*/
protected function buildNamespaceStatment(object $power): string
{
return $power->_namespace . '\\' . $power->class_name;
}
/**
* Ensures the name for the use statement is unique, avoiding conflicts with other classes.
*
* @param string $name The current name
* @param object $power The power object containing type, namespace, and class name.
*
* @return string The unique name
* @since 3.2.0
*/
protected function getUniqueName(string $name, object $power): string
{
// set search namespace
$namespace = ($name !== $power->class_name) ? $this->buildNamespaceStatment($power) : $power->_namespace;
// check if we need to update the name
if (isset($this->other[$name]))
{
// if the name is already used
while (isset($this->other[$name]))
{
if (($tmp = $this->extractClassNameOrAlias($namespace)) !== null)
{
$name = ucfirst($tmp) . $name;
$namespace = $this->removeLastNameFromNamespace($namespace);
}
else
{
$name = 'Unique' . $name;
}
}
}
// also loop new found use statements
if (isset($this->useStatements[$name]))
{
// if the name is already used
while (isset($this->useStatements[$name]))
{
if (($tmp = $this->extractClassNameOrAlias($namespace)) !== null)
{
$name = ucfirst($tmp) . $name;
$namespace = $this->removeLastNameFromNamespace($namespace);
}
else
{
$name = 'Unique' . $name;
}
}
}
return $name;
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -174,16 +174,18 @@ class Router
// We can only work with ID if the [main get] is a [getItem] dynamicGet for this site view. // We can only work with ID if the [main get] is a [getItem] dynamicGet for this site view.
$key = ($view['settings']->main_get->gettype == 1) ? 'id' : null; $key = ($view['settings']->main_get->gettype == 1) ? 'id' : null;
$view_selected = $selection['view'] ?? null;
$name_selected = $selection['name'] ?? null;
// Construct the enriched view object. // Construct the enriched view object.
return (object) [ return (object) [
'view' => $view['settings']->code, 'view' => $view['settings']->code,
'View' => $view['settings']->Code, 'View' => $view['settings']->Code,
'stable' => ($selection['view'] === $view['settings']->code), // sanity check 'stable' => ($view_selected === $view['settings']->code), // sanity check
'target_view' => $selection['view'], 'target_view' => $view_selected,
'table' => $selection['table'], 'table' => $selection['table'] ?? null,
'table_name' => $selection['name'], 'table_name' => $name_selected,
'alias' => $this->getSiteViewAliasKey($selection['name'] ?? null, $adminViews), 'alias' => $this->getSiteViewAliasKey($name_selected, $adminViews),
'key' => $key, 'key' => $key,
'form' => false 'form' => false
]; ];

View File

@ -21,6 +21,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language; use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Language\Extractor; use VDM\Joomla\Componentbuilder\Compiler\Language\Extractor;
use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor as Power; use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor as Power;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Extractor as JoomlaPower;
/** /**
@ -70,27 +71,36 @@ class Reverse
**/ **/
protected Power $power; protected Power $power;
/**
* Joomla Power Extractor
*
* @var Power
* @since 3.2.1
**/
protected JoomlaPower $joomla;
/** /**
* Constructor. * Constructor.
* *
* @param Config|null $config The compiler config object. * @param Config $config The compiler config object.
* @param Placeholder|null $placeholder The compiler placeholder object. * @param Placeholder $placeholder The compiler placeholder object.
* @param Language|null $language The compiler language object. * @param Language $language The compiler language object.
* @param Extractor|null $extractor The compiler language extractor object. * @param Extractor $extractor The compiler language extractor object.
* @param Power|null $power The compiler power extractor object. * @param Power $power The compiler power extractor object.
* *
* @since 3.2.0 * @since 3.2.0
*/ */
public function __construct( public function __construct(
?Config $config = null, ?Placeholder $placeholder = null, Config $config, Placeholder $placeholder,
?Language $language = null, ?Extractor $extractor = null, Language $language, Extractor $extractor,
?Power $power = null) Power $power, JoomlaPower $joomla)
{ {
$this->config = $config ?: Compiler::_('Config'); $this->config = $config;
$this->placeholder = $placeholder ?: Compiler::_('Placeholder'); $this->placeholder = $placeholder;
$this->language = $language ?: Compiler::_('Language'); $this->language = $language;
$this->extractor = $extractor ?: Compiler::_('Language.Extractor'); $this->extractor = $extractor;
$this->power = $power ?: Compiler::_('Power.Extractor'); $this->power = $power;
$this->joomla = $joomla;
} }
/** /**
@ -138,8 +148,9 @@ class Reverse
protected function setReverse(string $updateString, string $string, protected function setReverse(string $updateString, string $string,
string $target, ?array $useStatements): string string $target, ?array $useStatements): string
{ {
// we have to reverse engineer to super powers // we have to reverse engineer of powers
$updateString = $this->reverseSuperPowers($updateString, $string, $useStatements); $updateString = $this->reverseSuperPowers($updateString, $string, $useStatements);
$updateString = $this->reverseJoomlaPowers($updateString, $string, $useStatements);
// reverse engineer the language strings // reverse engineer the language strings
$updateString = $this->reverseLanguage($updateString, $string, $target); $updateString = $this->reverseLanguage($updateString, $string, $target);
@ -165,7 +176,30 @@ class Reverse
{ {
// only if we have use statements can we reverse engineer this // only if we have use statements can we reverse engineer this
if ($useStatements !== null && ($powers = $this->power->reverse($string)) !== null && if ($useStatements !== null && ($powers = $this->power->reverse($string)) !== null &&
($reverse = $this->getReversePower($powers, $useStatements)) !== null) ($reverse = $this->getReversePower($powers, $useStatements, 'Super')) !== null)
{
return $this->placeholder->update($updateString, $reverse);
}
return $updateString;
}
/**
* Set the joomla powers keys for the reveres process
*
* @param string $updateString The string to update
* @param string $string The string to use for super power update
* @param array|null $useStatements The file use statements (needed for super powers)
*
* @return string
* @since 3.2.0
*/
protected function reverseJoomlaPowers(string $updateString, string $string,
?array $useStatements): string
{
// only if we have use statements can we reverse engineer this
if ($useStatements !== null && ($powers = $this->joomla->reverse($string)) !== null &&
($reverse = $this->getReversePower($powers, $useStatements, 'Joomla')) !== null)
{ {
return $this->placeholder->update($updateString, $reverse); return $this->placeholder->update($updateString, $reverse);
} }
@ -178,11 +212,12 @@ class Reverse
* *
* @param array $powers The powers found in the database text * @param array $powers The powers found in the database text
* @param array $useStatements The file use statements * @param array $useStatements The file use statements
* @param string $target The power target type
* *
* @return array|null * @return array|null
* @since 3.2.0 * @since 3.2.0
*/ */
protected function getReversePower(array $powers, array $useStatements): ?array protected function getReversePower(array $powers, array $useStatements, string $target): ?array
{ {
$matching_statements = []; $matching_statements = [];
foreach ($useStatements as $use_statement) foreach ($useStatements as $use_statement)
@ -211,7 +246,7 @@ class Reverse
{ {
$guid = array_search($namespace, $powers); $guid = array_search($namespace, $powers);
$matching_statements[$class_name] = $matching_statements[$class_name] =
'Super_'.'_'.'_' . str_replace('-', '_', $guid) . '_'.'_'.'_Power'; $target . '_'.'_'.'_' . str_replace('-', '_', $guid) . '_'.'_'.'_Power';
} }
} }

View File

@ -303,7 +303,7 @@ class Power implements PowerInterface
$this->setImplements($guid, $use); $this->setImplements($guid, $use);
// set extend class // set extend class
$this->setExtend($guid, $use); $this->setExtend($guid, $use, $as);
// set GUI mapper // set GUI mapper
$guiMapper = [ $guiMapper = [
@ -760,11 +760,12 @@ class Power implements PowerInterface
* *
* @param string $guid The global unique id of the power * @param string $guid The global unique id of the power
* @param array $use The use array * @param array $use The use array
* @param array $as The use as array
* *
* @return void * @return void
* @since 3.2.0 * @since 3.2.0
*/ */
private function setExtend(string $guid, array &$use) private function setExtend(string $guid, array &$use, array &$as)
{ {
// does this extend something // does this extend something
$this->active[$guid]->extends_name = null; $this->active[$guid]->extends_name = null;
@ -793,6 +794,13 @@ class Power implements PowerInterface
$this->active[$guid]->extends_name = $this->get($this->active[$guid]->extends, 1)->class_name; $this->active[$guid]->extends_name = $this->get($this->active[$guid]->extends, 1)->class_name;
// add to use // add to use
$use[] = $this->active[$guid]->extends; $use[] = $this->active[$guid]->extends;
// add padding if the two names are the same
if ($this->active[$guid]->extends_name === $this->active[$guid]->class_name)
{
$this->active[$guid]->extends_name = $as[$this->active[$guid]->extends]
= 'Extending' . $this->active[$guid]->class_name;
}
} }
} }
} }

View File

@ -14,13 +14,14 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Power;
use Joomla\CMS\Factory; use Joomla\CMS\Factory;
use VDM\Joomla\Utilities\GuidHelper; use VDM\Joomla\Utilities\GuidHelper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\ExtractorInterface;
/** /**
* Compiler Power Extractor * Compiler Power Extractor
* @since 3.2.0 * @since 3.2.0
*/ */
final class Extractor class Extractor implements ExtractorInterface
{ {
/** /**
* The pattern to get the powers * The pattern to get the powers
@ -30,6 +31,30 @@ final class Extractor
**/ **/
protected string $pattern = '/Super_'.'_'.'_[a-zA-Z0-9_]+_'.'_'.'_Power/'; protected string $pattern = '/Super_'.'_'.'_[a-zA-Z0-9_]+_'.'_'.'_Power/';
/**
* The pattern to get the Front
*
* @var string
* @since 3.2.1
**/
protected string $_pattern = 'Super';
/**
* The pattern to get the Back
*
* @var string
* @since 3.2.1
**/
protected string $pattern_ = 'Power';
/**
* The Table
*
* @var string
* @since 3.2.1
**/
protected string $table = 'power';
/** /**
* Powers GUID's * Powers GUID's
* *
@ -122,7 +147,7 @@ final class Extractor
* @return void * @return void
* @since 3.2.0 * @since 3.2.0
*/ */
public function search(string $code) public function search(string $code): void
{ {
$matches = []; $matches = [];
preg_match_all($this->pattern, $code, $matches); preg_match_all($this->pattern, $code, $matches);
@ -147,7 +172,7 @@ final class Extractor
{ {
foreach ($found as $super_power) foreach ($found as $super_power)
{ {
$guid = str_replace(['Super_'.'_'.'_', '_'.'_'.'_Power'], '', $super_power); $guid = str_replace([], '', $super_power);
$guid = str_replace('_', '-', $guid); $guid = str_replace('_', '-', $guid);
if (GuidHelper::valid($guid)) if (GuidHelper::valid($guid))
@ -171,7 +196,7 @@ final class Extractor
foreach ($found as $super_power) foreach ($found as $super_power)
{ {
$guid = str_replace(['Super_'.'_'.'_', '_'.'_'.'_Power'], '', $super_power); $guid = str_replace([$this->_pattern . '___', '___' . $this->pattern_], '', $super_power);
$guid = str_replace('_', '-', $guid); $guid = str_replace('_', '-', $guid);
if (GuidHelper::valid($guid)) if (GuidHelper::valid($guid))
@ -197,7 +222,7 @@ final class Extractor
foreach ($found as $super_power) foreach ($found as $super_power)
{ {
$guid = str_replace(['Super_'.'_'.'_', '_'.'_'.'_Power'], '', $super_power); $guid = str_replace([$this->_pattern . '___', '___' . $this->pattern_], '', $super_power);
$guid = str_replace('_', '-', $guid); $guid = str_replace('_', '-', $guid);
if (GuidHelper::valid($guid)) if (GuidHelper::valid($guid))
@ -226,7 +251,7 @@ final class Extractor
. ', ".", "\\\") AS full_namespace, ' . ', ".", "\\\") AS full_namespace, '
. $this->db->quoteName('guid') . $this->db->quoteName('guid')
) )
->from($this->db->quoteName('#__componentbuilder_power')) ->from($this->db->quoteName('#__componentbuilder_' . $this->table))
->where($this->db->quoteName('guid') . ' IN (' . implode(',', array_map([$this->db, 'quote'], $guids)) . ')'); ->where($this->db->quoteName('guid') . ' IN (' . implode(',', array_map([$this->db, 'quote'], $guids)) . ')');
$this->db->setQuery($query); $this->db->setQuery($query);
$this->db->execute(); $this->db->execute();

View File

@ -12,18 +12,18 @@
namespace VDM\Joomla\Componentbuilder\Compiler\Power; namespace VDM\Joomla\Componentbuilder\Compiler\Power;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PowerInterface as Power;
use VDM\Joomla\Componentbuilder\Compiler\Power; use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\ExtractorInterface as Extractor;
use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor;
use VDM\Joomla\Componentbuilder\Compiler\Power\Parser; use VDM\Joomla\Componentbuilder\Compiler\Power\Parser;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder; use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\InjectorInterface;
/** /**
* Compiler Power Injector * Compiler Power Injector
* @since 3.2.0 * @since 3.2.0
*/ */
final class Injector class Injector implements InjectorInterface
{ {
/** /**
* Power Objects * Power Objects
@ -107,13 +107,13 @@ final class Injector
* *
* @since 3.2.0 * @since 3.2.0
*/ */
public function __construct(?Power $power = null, ?Extractor $extractor = null, public function __construct(Power $power = null, Extractor $extractor = null,
?Parser $parser = null, ?Placeholder $placeholder = null) Parser $parser = null, Placeholder $placeholder = null)
{ {
$this->power = $power ?: Compiler::_('Power'); $this->power = $power;
$this->extractor = $extractor ?: Compiler::_('Power.Extractor'); $this->extractor = $extractor;
$this->parser = $parser ?: Compiler::_('Power.Parser'); $this->parser = $parser;
$this->placeholder = $placeholder ?: Compiler::_('Placeholder'); $this->placeholder = $placeholder;
} }
/** /**

View File

@ -82,6 +82,7 @@ class Customcode implements ServiceProviderInterface
$container->get('Placeholder'), $container->get('Placeholder'),
$container->get('Language.Extractor'), $container->get('Language.Extractor'),
$container->get('Power.Extractor'), $container->get('Power.Extractor'),
$container->get('Joomla.Power.Extractor'),
$container->get('Customcode.External') $container->get('Customcode.External')
); );
} }

View File

@ -0,0 +1,202 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower as Powers;
use VDM\Joomla\Componentbuilder\JoomlaPower\Grep;
use VDM\Joomla\Componentbuilder\JoomlaPower\Super as Superpower;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Extractor;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Injector;
use VDM\Joomla\Componentbuilder\JoomlaPower\Model\Upsert;
use VDM\Joomla\Componentbuilder\JoomlaPower\Database\Insert;
use VDM\Joomla\Componentbuilder\JoomlaPower\Database\Update;
/**
* Compiler Joomla Power Service Provider
*
* @since 3.2.0
*/
class JoomlaPower implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Powers::class, 'Joomla.Power')
->share('Joomla.Power', [$this, 'getPowers'], true);
$container->alias(Superpower::class, 'Joomlapower')
->share('Joomlapower', [$this, 'getSuperpower'], true);
$container->alias(Grep::class, 'Joomla.Power.Grep')
->share('Joomla.Power.Grep', [$this, 'getGrep'], true);
$container->alias(Extractor::class, 'Joomla.Power.Extractor')
->share('Joomla.Power.Extractor', [$this, 'getExtractor'], true);
$container->alias(Injector::class, 'Joomla.Power.Injector')
->share('Joomla.Power.Injector', [$this, 'getInjector'], true);
$container->alias(Upsert::class, 'Joomla.Power.Model.Upsert')
->share('Joomla.Power.Model.Upsert', [$this, 'getModelUpsert'], true);
$container->alias(Insert::class, 'Joomla.Power.Insert')
->share('Joomla.Power.Insert', [$this, 'getInsert'], true);
$container->alias(Update::class, 'Joomla.Power.Update')
->share('Joomla.Power.Update', [$this, 'getUpdate'], true);
}
/**
* Get the Powers
*
* @param Container $container The DI container.
*
* @return Powers
* @since 3.2.0
*/
public function getPowers(Container $container): Powers
{
return new Powers(
$container->get('Config'),
$container->get('Placeholder'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Joomlapower')
);
}
/**
* Get the Superpower
*
* @param Container $container The DI container.
*
* @return Superpower
* @since 3.2.0
*/
public function getSuperpower(Container $container): Superpower
{
return new Superpower(
$container->get('Joomla.Power.Grep'),
$container->get('Joomla.Power.Insert'),
$container->get('Joomla.Power.Update')
);
}
/**
* Get the Grep
*
* @param Container $container The DI container.
*
* @return Grep
* @since 3.2.0
*/
public function getGrep(Container $container): Grep
{
return new Grep(
$container->get('Config')->local_joomla_powers_repository_path,
$container->get('Config')->approved_joomla_paths,
$container->get('Gitea.Repository.Contents')
);
}
/**
* Get the Compiler Power Extractor
*
* @param Container $container The DI container.
*
* @return Extractor
* @since 3.2.0
*/
public function getExtractor(Container $container): Extractor
{
return new Extractor(
$container->get('Config')->joomla_version
);
}
/**
* Get the Compiler Power Injector
*
* @param Container $container The DI container.
*
* @return Injector
* @since 3.2.0
*/
public function getInjector(Container $container): Injector
{
return new Injector(
$container->get('Joomla.Power'),
$container->get('Joomla.Power.Extractor'),
$container->get('Power.Parser'),
$container->get('Placeholder')
);
}
/**
* Get the Power Model Upsert
*
* @param Container $container The DI container.
*
* @return Upsert
* @since 3.2.0
*/
public function getModelUpsert(Container $container): Upsert
{
return new Upsert(
$container->get('Table')
);
}
/**
* Get the Power Insert
*
* @param Container $container The DI container.
*
* @return Insert
* @since 3.2.0
*/
public function getInsert(Container $container): Insert
{
return new Insert(
$container->get('Joomla.Power.Model.Upsert'),
$container->get('Insert')
);
}
/**
* Get the Power Update
*
* @param Container $container The DI container.
*
* @return Update
* @since 3.2.0
*/
public function getUpdate(Container $container): Update
{
return new Update(
$container->get('Joomla.Power.Model.Upsert'),
$container->get('Update')
);
}
}

View File

@ -62,7 +62,7 @@ class Placeholder implements ServiceProviderInterface
* *
* @param Container $container The DI container. * @param Container $container The DI container.
* *
* @return Worker * @return Reverse
* @since 3.2.0 * @since 3.2.0
*/ */
public function getPlaceholderReverse(Container $container): Reverse public function getPlaceholderReverse(Container $container): Reverse
@ -72,7 +72,8 @@ class Placeholder implements ServiceProviderInterface
$container->get('Placeholder'), $container->get('Placeholder'),
$container->get('Language'), $container->get('Language'),
$container->get('Language.Extractor'), $container->get('Language.Extractor'),
$container->get('Power.Extractor') $container->get('Power.Extractor'),
$container->get('Joomla.Power.Extractor')
); );
} }
} }

View File

@ -0,0 +1,81 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Interfaces\Database;
/**
* Database Insert
*
* @since 3.2.1
*/
interface InsertInterface
{
/**
* Insert a value to a given table
* Example: $this->value(Value, 'value_key', 'GUID');
*
* @param mixed $value The field value
* @param string $field The field key
* @param string $keyValue The key value
* @param string $key The key name
*
* @return bool
* @since 3.2.0
*/
public function value($value, string $field, string $keyValue, string $key = 'guid'): bool;
/**
* Insert single row with multiple values to a given table
* Example: $this->item(Array);
*
* @param array $item The item to save
*
* @return bool
* @since 3.2.0
*/
public function row(array $item): bool;
/**
* Insert multiple rows to a given table
* Example: $this->items(Array);
*
* @param array|null $items The items updated in database (array of arrays)
*
* @return bool
* @since 3.2.0
*/
public function rows(?array $items): bool;
/**
* Insert single item with multiple values to a given table
* Example: $this->item(Object);
*
* @param object $item The item to save
*
* @return bool
* @since 3.2.0
*/
public function item(object $item): bool;
/**
* Insert multiple items to a given table
* Example: $this->items(Array);
*
* @param array|null $items The items updated in database (array of objects)
*
* @return bool
* @since 3.2.0
*/
public function items(?array $items): bool;
}

View File

@ -0,0 +1,80 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Interfaces\Database;
/**
* Database Update
*
* @since 3.2.1
*/
interface UpdateInterface
{
/**
* Update a value to a given table
* Example: $this->value(Value, 'value_key', 'GUID');
*
* @param mixed $value The field value
* @param string $field The field key
* @param string $keyValue The key value
* @param string $key The key name
*
* @return bool
* @since 3.2.0
*/
public function value($value, string $field, string $keyValue, string $key = 'guid'): bool;
/**
* Update single row with multiple values to a given table
* Example: $this->item(Array);
*
* @param array $item The item to save
*
* @return bool
* @since 3.2.0
*/
public function row(array $item): bool;
/**
* Update multiple rows to a given table
* Example: $this->items(Array);
*
* @param array|null $items The items updated in database (array of arrays)
*
* @return bool
* @since 3.2.0
*/
public function rows(?array $items): bool;
/**
* Update single item with multiple values to a given table
* Example: $this->item(Object);
*
* @param object $item The item to save
*
* @return bool
* @since 3.2.0
*/
public function item(object $item): bool;
/**
* Update multiple items to a given table
* Example: $this->items(Array);
*
* @param array|null $items The items updated in database (array of objects)
*
* @return bool
* @since 3.2.0
*/
public function items(?array $items): bool;
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,41 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Interfaces;
/**
* Global Resource Empowerment Platform
*
* @since 3.2.1
*/
interface GrepInterface
{
/**
* Get all remote powers GUID's
*
* @return array|null
* @since 3.2.0
*/
public function getRemotePowersGuid(): ?array;
/**
* Get a power
*
* @param string $guid The global unique id of the power
* @param array $order The search order
*
* @return object|null
* @since 3.2.0
*/
public function get(string $guid, array $order = ['local', 'remote']): ?object;
}

View File

@ -0,0 +1,52 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Interfaces;
/**
* Superpower of JCB
*
* @since 3.2.0
*/
interface SuperInterface
{
/**
* Init all power not found in database
*
* @return bool
* @since 3.2.0
*/
public function init(): bool;
/**
* Reset the powers
*
* @param array $powers The global unique ids of the powers
*
* @return bool
* @since 3.2.0
*/
public function reset(array $powers): bool;
/**
* Load a superpower
*
* @param string $guid The global unique id of the power
* @param array $order The search order
* @param string|null $action The action to load power
*
* @return bool
* @since 3.2.0
*/
public function load(string $guid, array $order = ['remote', 'local'], ?string $action = null): bool;
}

View File

@ -0,0 +1,182 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\JoomlaPower;
use Joomla\Registry\Registry as JoomlaRegistry;
use Joomla\CMS\Factory as JoomlaFactory;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
/**
* Compiler Configurations
*
* All these functions are accessed via the direct name without the get:
* example: $this->component_code_name calls: $this->getComponentcodename()
*
* All values once called are cached, yet can be updated directly:
* example: $this->component_code_name = 'new_code_name'; // be warned!
*
* @since 3.2.0
*/
class Config extends BaseConfig
{
/**
* The Global Joomla Configuration
*
* @var JoomlaRegistry
* @since 3.2.0
*/
protected JoomlaRegistry $config;
/**
* Constructor
*
* @param Input|null $input Input
* @param Registry|null $params The component parameters
* @param Registry|null $config The Joomla configuration
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Input $input = null, ?JoomlaRegistry $params = null, ?JoomlaRegistry $config = null)
{
parent::__construct($input, $params);
$this->config = $config ?: JoomlaFactory::getConfig();
}
/**
* get Gitea Access Token
*
* @return string the access token
* @since 3.2.0
*/
protected function getGiteatoken(): ?string
{
return $this->custom_gitea_token ?? $this->params->get('gitea_token');
}
/**
* get Add Custom Gitea URL
*
* @return int the add switch
* @since 3.2.0
*/
protected function getAddcustomgiteaurl(): int
{
return $this->params->get('add_custom_gitea_url', 1);
}
/**
* get Custom Gitea URL
*
* @return string the custom gitea url
* @since 3.2.0
*/
protected function getCustomgiteaurl(): ?string
{
if ($this->add_custom_gitea_url == 2)
{
return $this->params->get('custom_gitea_url');
}
return null;
}
/**
* get Custom Gitea Access Token
*
* @return string the custom access token
* @since 3.2.0
*/
protected function getCustomgiteatoken(): ?string
{
if ($this->add_custom_gitea_url == 2)
{
return $this->params->get('custom_gitea_token');
}
return null;
}
/**
* Get super power core organisation
*
* @return string The super power core organisation
* @since 3.2.0
*/
protected function getJoomlapowerscoreorganisation(): string
{
// the VDM default organisation is [joomla]
$organisation = 'joomla';
return $this->params->get('joomla_powers_core_organisation', $organisation);
}
/**
* Get Joomla power init repos
*
* @return array The init repositories on Gitea
* @since 3.2.0
*/
protected function getJoomlapowersinitrepos(): array
{
// some defaults repos we need by JCB
$repos = [];
$repos[$this->joomla_powers_core_organisation . '.joomla-powers'] = (object) ['owner' => $this->joomla_powers_core_organisation, 'repo' => 'joomla-powers', 'branch' => 'master'];
return $repos;
}
/**
* get temporary path
*
* @return string The temporary path
* @since 3.2.0
*/
protected function getTmppath(): string
{
// get the temporary path
return $this->config->get('tmp_path');
}
/**
* Get local joomla super powers repository path
*
* @return string The path to the local repository
* @since 3.2.0
*/
protected function getLocaljoomlapowersrepositorypath(): string
{
$default = $this->tmp_path . '/joomla_powers';
return $this->params->get('local_joomla_powers_repository_path', $default);
}
/**
* Get joomla power approved paths
*
* @return array The paths to the repositories on Gitea
* @since 3.2.0
*/
protected function getApprovedjoomlapaths(): array
{
// some defaults repos we need by JCB
$approved = $this->joomla_powers_init_repos;
return array_values($approved);
}
}

View File

@ -0,0 +1,34 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\JoomlaPower\Database;
use VDM\Joomla\Componentbuilder\Interfaces\Database\InsertInterface;
use VDM\Joomla\Componentbuilder\Power\Database\Insert as ExtendingInsert;
/**
* Joomla Power Database Insert
*
* @since 3.2.1
*/
final class Insert extends ExtendingInsert implements InsertInterface
{
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'power';
}

View File

@ -0,0 +1,34 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\JoomlaPower\Database;
use VDM\Joomla\Componentbuilder\Power\Database\LoadInterface;
use VDM\Joomla\Componentbuilder\Power\Database\Load as ExtendingLoad;
/**
* Power Database Load
*
* @since 2.0.1
*/
final class Load extends ExtendingLoad implements LoadInterface
{
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'joomla_power';
}

View File

@ -0,0 +1,34 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\JoomlaPower\Database;
use VDM\Joomla\Componentbuilder\Interfaces\Database\UpdateInterface;
use VDM\Joomla\Componentbuilder\Power\Database\Update as ExtendingUpdate;
/**
* Joomla Power Database Update
*
* @since 3.2.0
*/
final class Update extends ExtendingUpdate implements UpdateInterface
{
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'joomla_power';
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,86 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\JoomlaPower;
use Joomla\DI\Container;
use VDM\Joomla\Componentbuilder\JoomlaPower\Service\JoomlaPower as Power;
use VDM\Joomla\Componentbuilder\Service\Database;
use VDM\Joomla\Componentbuilder\JoomlaPower\Service\Database as PowerDatabase;
use VDM\Joomla\Componentbuilder\Service\Gitea;
use VDM\Joomla\Componentbuilder\Power\Service\Gitea as GiteaPower;
use VDM\Joomla\Gitea\Service\Utilities as GiteaUtilities;
use VDM\Joomla\Interfaces\FactoryInterface;
/**
* Joomla Power Factory
*
* @since 3.2.0
*/
abstract class Factory implements FactoryInterface
{
/**
* Global Package Container
*
* @var Container
* @since 3.2.0
**/
protected static $container = null;
/**
* Get any class from the package container
*
* @param string $key The container class key
*
* @return Mixed
* @since 3.2.0
*/
public static function _($key)
{
return self::getContainer()->get($key);
}
/**
* Get the global package container
*
* @return Container
* @since 3.2.0
*/
public static function getContainer(): Container
{
if (!self::$container)
{
self::$container = self::createContainer();
}
return self::$container;
}
/**
* Create a container object
*
* @return Container
* @since 3.2.0
*/
protected static function createContainer(): Container
{
return (new Container())
->registerServiceProvider(new Power())
->registerServiceProvider(new Database())
->registerServiceProvider(new PowerDatabase())
->registerServiceProvider(new Gitea())
->registerServiceProvider(new GiteaPower())
->registerServiceProvider(new GiteaUtilities());
}
}

View File

@ -0,0 +1,146 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\JoomlaPower;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Componentbuilder\Interfaces\GrepInterface;
use VDM\Joomla\Componentbuilder\Power\Grep as ExtendingGrep;
/**
* Global Resource Empowerment Platform
*
* The Grep feature will try to find your joomla power in the repositories listed in the global
* Options of JCB in the super powers tab, and if it can't be found there will try the global core
* Super powers of JCB. All searches are performed according the the [algorithm:cascading]
* See documentation for more details: https://git.vdm.dev/joomla/super-powers/wiki
*
* @since 3.2.1
*/
final class Grep extends ExtendingGrep implements GrepInterface
{
/**
* Get a local power
*
* @param object $path The repository path details
* @param string $guid The global unique id of the power
*
* @return object|null
* @since 3.2.0
*/
private function getLocal(object $path, string $guid): ?object
{
if (empty($path->local->{$guid}->settings))
{
return null;
}
// get the settings
if (($settings = FileHelper::getContent($path->full_path . '/' . $path->local->{$guid}->settings, null)) !== null &&
JsonHelper::check($settings))
{
$power = json_decode($settings);
if (isset($power->guid))
{
return $power;
}
}
return null;
}
/**
* Get a remote power
*
* @param object $path The repository path details
* @param string $guid The global unique id of the power
*
* @return object|null
* @since 3.2.0
*/
private function getRemote(object $path, string $guid): ?object
{
if (empty($path->index->{$guid}->settings))
{
return null;
}
// get the settings
if (($power = $this->loadRemoteFile($path->owner, $path->repo, $path->index->{$guid}->settings, $path->branch)) !== null &&
isset($power->guid))
{
return $power;
}
return null;
}
/**
* Load the local repository index of powers
*
* @param object $path The repository path details
*
* @return void
* @since 3.2.0
*/
private function localIndex(object &$path)
{
if (isset($path->local) || !isset($path->full_path))
{
return;
}
if (($content = FileHelper::getContent($path->full_path . '/joomla-powers.json', null)) !== null &&
JsonHelper::check($content))
{
$path->local = json_decode($content);
return;
}
$path->local = null;
}
/**
* Load the remote repository index of powers
*
* @param object $path The repository path details
*
* @return void
* @since 3.2.0
*/
private function remoteIndex(object &$path)
{
if (isset($path->index))
{
return;
}
try
{
$path->index = $this->contents->get($path->owner, $path->repo, 'joomla-powers.json', $path->branch);
}
catch (\Exception $e)
{
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_PSUPER_POWERB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path->path, $e->getMessage()),
'Error'
);
$path->index = null;
}
}
}

View File

@ -0,0 +1,37 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\JoomlaPower\Model;
use VDM\Joomla\Interfaces\ModelInterface;
use VDM\Joomla\Componentbuilder\Power\Model\Load as ExtendingLoad;
/**
* Joomla Power Model Load
*
* @since 3.2.0
*/
final class Load extends ExtendingLoad implements ModelInterface
{
/**
* Get the current active table
*
* @return string
* @since 3.2.0
*/
protected function getTable(): string
{
return 'joomla_power';
}
}

View File

@ -0,0 +1,38 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\JoomlaPower\Model;
use VDM\Joomla\Interfaces\ModelInterface;
use VDM\Joomla\Componentbuilder\Power\Model\Upsert as ExtendingUpsert;
/**
* Joomla Power Model Update or Insert
*
* @since 3.2.0
*/
final class Upsert extends ExtendingUpsert implements ModelInterface
{
/**
* Get the current active table
*
* @return string
* @since 3.2.0
*/
protected function getTable(): string
{
return 'joomla_power';
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,135 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\JoomlaPower\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\JoomlaPower\Model\Load as ModelLoad;
use VDM\Joomla\Componentbuilder\JoomlaPower\Model\Upsert as ModelUpsert;
use VDM\Joomla\Componentbuilder\JoomlaPower\Database\Load as LoadDatabase;
use VDM\Joomla\Componentbuilder\JoomlaPower\Database\Insert as InsertDatabase;
use VDM\Joomla\Componentbuilder\JoomlaPower\Database\Update as UpdateDatabase;
/**
* Database Service Provider
*
* @since 3.2.0
*/
class Database implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(ModelLoad::class, 'Joomla.Power.Model.Load')
->share('Joomla.Power.Model.Load', [$this, 'getModelLoad'], true);
$container->alias(ModelUpsert::class, 'Joomla.Power.Model.Upsert')
->share('Joomla.Power.Model.Upsert', [$this, 'getModelUpsert'], true);
$container->alias(LoadDatabase::class, 'Joomla.Power.Database.Load')
->share('Joomla.Power.Database.Load', [$this, 'getLoadDatabase'], true);
$container->alias(InsertDatabase::class, 'Joomla.Power.Database.Insert')
->share('Joomla.Power.Database.Insert', [$this, 'getInsertDatabase'], true);
$container->alias(UpdateDatabase::class, 'Joomla.Power.Database.Update')
->share('Joomla.Power.Database.Update', [$this, 'getUpdateDatabase'], true);
}
/**
* Get the Power Model Load
*
* @param Container $container The DI container.
*
* @return ModelLoad
* @since 3.2.0
*/
public function getModelLoad(Container $container): ModelLoad
{
return new ModelLoad(
$container->get('Table')
);
}
/**
* Get the Power Model Update or Insert
*
* @param Container $container The DI container.
*
* @return ModelUpsert
* @since 3.2.0
*/
public function getModelUpsert(Container $container): ModelUpsert
{
return new ModelUpsert(
$container->get('Table')
);
}
/**
* Get the Load Database
*
* @param Container $container The DI container.
*
* @return LoadDatabase
* @since 3.2.0
*/
public function getLoadDatabase(Container $container): LoadDatabase
{
return new LoadDatabase(
$container->get('Joomla.Power.Model.Load'),
$container->get('Load')
);
}
/**
* Get the Insert Database
*
* @param Container $container The DI container.
*
* @return InsertDatabase
* @since 3.2.0
*/
public function getInsertDatabase(Container $container): InsertDatabase
{
return new InsertDatabase(
$container->get('Joomla.Power.Model.Upsert'),
$container->get('Insert')
);
}
/**
* Get the Update Database
*
* @param Container $container The DI container.
*
* @return UpdateDatabase
* @since 3.2.0
*/
public function getUpdateDatabase(Container $container): UpdateDatabase
{
return new UpdateDatabase(
$container->get('Joomla.Power.Model.Upsert'),
$container->get('Update')
);
}
}

View File

@ -0,0 +1,130 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\JoomlaPower\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\JoomlaPower\Config;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\JoomlaPower\Grep;
use VDM\Joomla\Componentbuilder\JoomlaPower\Super as Superpower;
use VDM\Joomla\Componentbuilder\Compiler\Power\Parser;
/**
* Joomla Power Service Provider
*
* @since 3.2.1
*/
class JoomlaPower implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Config::class, 'Config')
->share('Config', [$this, 'getConfig'], true);
$container->alias(Table::class, 'Table')
->share('Table', [$this, 'getTable'], true);
$container->alias(Grep::class, 'Joomla.Power.Grep')
->share('Joomla.Power.Grep', [$this, 'getGrep'], true);
$container->alias(Superpower::class, 'Joomlapower')
->share('Joomlapower', [$this, 'getSuperpower'], true);
$container->alias(Parser::class, 'Power.Parser')
->share('Power.Parser', [$this, 'getParser'], true);
}
/**
* Get The Config Class.
*
* @param Container $container The DI container.
*
* @return Config
* @since 3.2.0
*/
public function getConfig(Container $container): Config
{
return new Config();
}
/**
* Get The Table Class.
*
* @param Container $container The DI container.
*
* @return Table
* @since 3.2.0
*/
public function getTable(Container $container): Table
{
return new Table();
}
/**
* Get The Grep Class.
*
* @param Container $container The DI container.
*
* @return Grep
* @since 3.2.0
*/
public function getGrep(Container $container): Grep
{
return new Grep(
$container->get('Config')->local_joomla_powers_repository_path,
$container->get('Config')->approved_joomla_paths,
$container->get('Gitea.Repository.Contents')
);
}
/**
* Get The Super Class.
*
* @param Container $container The DI container.
*
* @return Superpower
* @since 3.2.0
*/
public function getSuperpower(Container $container): Superpower
{
return new Superpower(
$container->get('Joomla.Power.Grep'),
$container->get('Joomla.Power.Database.Insert'),
$container->get('Joomla.Power.Database.Update')
);
}
/**
* Get The Parser Class.
*
* @param Container $container The DI container.
*
* @return Parser
* @since 3.2.0
*/
public function getParser(Container $container): Parser
{
return new Parser();
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,34 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\JoomlaPower;
use VDM\Joomla\Componentbuilder\Interfaces\SuperInterface;
use VDM\Joomla\Componentbuilder\Power\Super as ExtendingSuper;
/**
* Super Joomla Power of JCB
*
* @since 3.2.0
*/
final class Super extends ExtendingSuper implements SuperInterface
{
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'joomla_power';
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -12,8 +12,9 @@
namespace VDM\Joomla\Componentbuilder\Power\Database; namespace VDM\Joomla\Componentbuilder\Power\Database;
use VDM\Joomla\Componentbuilder\Power\Model\Upsert as Model; use VDM\Joomla\Interfaces\ModelInterface as Model;
use VDM\Joomla\Database\Insert as Database; use VDM\Joomla\Database\Insert as Database;
use VDM\Joomla\Componentbuilder\Interfaces\Database\InsertInterface;
/** /**
@ -21,7 +22,7 @@ use VDM\Joomla\Database\Insert as Database;
* *
* @since 3.2.0 * @since 3.2.0
*/ */
final class Insert class Insert implements InsertInterface
{ {
/** /**
* Model * Model
@ -39,6 +40,14 @@ final class Insert
*/ */
protected Database $database; protected Database $database;
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'power';
/** /**
* Constructor * Constructor
* *
@ -88,10 +97,10 @@ final class Insert
public function row(array $item): bool public function row(array $item): bool
{ {
// check if object could be modelled // check if object could be modelled
if (($item = $this->model->row($item, 'power')) !== null) if (($item = $this->model->row($item, $this->table)) !== null)
{ {
// Insert the column of this table // Insert the column of this table
return $this->database->row($item, 'power'); return $this->database->row($item, $this->table);
} }
return false; return false;
} }
@ -108,10 +117,10 @@ final class Insert
public function rows(?array $items): bool public function rows(?array $items): bool
{ {
// check if object could be modelled // check if object could be modelled
if (($items = $this->model->rows($items, 'power')) !== null) if (($items = $this->model->rows($items, $this->table)) !== null)
{ {
// Insert the column of this table // Insert the column of this table
return $this->database->rows($items, 'power'); return $this->database->rows($items, $this->table);
} }
return false; return false;
} }
@ -128,10 +137,10 @@ final class Insert
public function item(object $item): bool public function item(object $item): bool
{ {
// check if object could be modelled // check if object could be modelled
if (($item = $this->model->item($item, 'power')) !== null) if (($item = $this->model->item($item, $this->table)) !== null)
{ {
// Insert the column of this table // Insert the column of this table
return $this->database->item($item, 'power'); return $this->database->item($item, $this->table);
} }
return false; return false;
} }
@ -148,13 +157,12 @@ final class Insert
public function items(?array $items): bool public function items(?array $items): bool
{ {
// check if object could be modelled // check if object could be modelled
if (($items = $this->model->items($items, 'power')) !== null) if (($items = $this->model->items($items, $this->table)) !== null)
{ {
// Update the column of this table using guid as the primary key. // Update the column of this table using guid as the primary key.
return $this->database->items($items, 'power'); return $this->database->items($items, $this->table);
} }
return false; return false;
} }
} }

View File

@ -12,8 +12,9 @@
namespace VDM\Joomla\Componentbuilder\Power\Database; namespace VDM\Joomla\Componentbuilder\Power\Database;
use VDM\Joomla\Componentbuilder\Power\Model\Load as Model; use VDM\Joomla\Interfaces\ModelInterface as Model;
use VDM\Joomla\Database\Load as Database; use VDM\Joomla\Database\Load as Database;
use VDM\Joomla\Componentbuilder\Power\Database\LoadInterface;
/** /**
@ -21,7 +22,7 @@ use VDM\Joomla\Database\Load as Database;
* *
* @since 2.0.1 * @since 2.0.1
*/ */
final class Load class Load implements LoadInterface
{ {
/** /**
* Model Load * Model Load
@ -39,6 +40,14 @@ final class Load
*/ */
protected Database $load; protected Database $load;
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'power';
/** /**
* Constructor * Constructor
* *
@ -74,11 +83,11 @@ final class Load
return $this->model->value( return $this->model->value(
$this->load->value( $this->load->value(
["a.{$field}" => $field], ["a.{$field}" => $field],
['a' => 'power'], ['a' => $this->table],
$this->prefix($keys) $this->prefix($keys)
), ),
$field, $field,
'power' $this->table
); );
} }
@ -101,10 +110,10 @@ final class Load
return $this->model->item( return $this->model->item(
$this->load->item( $this->load->item(
['all' => 'a.*'], ['all' => 'a.*'],
['a' => 'power'], ['a' => $this->table],
$this->prefix($keys) $this->prefix($keys)
), ),
'power' $this->table
); );
} }
@ -130,9 +139,9 @@ final class Load
{ {
return $this->model->items( return $this->model->items(
$this->load->items( $this->load->items(
['all' => 'a.*'], ['a' => 'power'], $this->prefix($keys) ['all' => 'a.*'], ['a' => $this->table], $this->prefix($keys)
), ),
'power' $this->table
); );
} }

View File

@ -0,0 +1,75 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Power\Database;
/**
* Power Database Load
*
* @since 2.0.1
*/
interface LoadInterface
{
/**
* Get a value from a given table
* Example: $this->value(
* [
* 'guid' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
* ], 'value_key'
* );
*
* @param array $keys The item keys
* @param string $field The field key
* @param string $table The table
*
* @return mixed
* @since 2.0.1
*/
public function value(array $keys, string $field);
/**
* Get values from a given table
* Example: $this->item(
* [
* 'guid' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
* ]
* );
*
* @param array $keys The item keys
* @param string $table The table
*
* @return object|null
* @since 2.0.1
*/
public function item(array $keys): ?object;
/**
* Get values from a given table
* Example: $this->items(
* [
* 'guid' => [
* 'operator' => 'IN',
* 'value' => [''xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'', ''xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'']
* ]
* ]
* );
* Example: $this->items($ids, 'table_name');
*
* @param array $keys The item keys
* @param string $table The table
*
* @return array|null
* @since 2.0.1
*/
public function items(array $keys): ?array;
}

View File

@ -12,8 +12,9 @@
namespace VDM\Joomla\Componentbuilder\Power\Database; namespace VDM\Joomla\Componentbuilder\Power\Database;
use VDM\Joomla\Componentbuilder\Power\Model\Upsert as Model; use VDM\Joomla\Interfaces\ModelInterface as Model;
use VDM\Joomla\Database\Update as Database; use VDM\Joomla\Database\Update as Database;
use VDM\Joomla\Componentbuilder\Interfaces\Database\UpdateInterface;
/** /**
@ -21,7 +22,7 @@ use VDM\Joomla\Database\Update as Database;
* *
* @since 3.2.0 * @since 3.2.0
*/ */
final class Update class Update implements UpdateInterface
{ {
/** /**
* Model * Model
@ -39,6 +40,14 @@ final class Update
*/ */
protected Database $database; protected Database $database;
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'power';
/** /**
* Constructor * Constructor
* *
@ -88,10 +97,10 @@ final class Update
public function row(array $item): bool public function row(array $item): bool
{ {
// check if object could be modelled // check if object could be modelled
if (($item = $this->model->row($item, 'power')) !== null) if (($item = $this->model->row($item, $this->table)) !== null)
{ {
// Update the column of this table using guid as the primary key. // Update the column of this table using guid as the primary key.
return $this->database->row($item, 'guid', 'power'); return $this->database->row($item, 'guid', $this->table);
} }
return false; return false;
} }
@ -108,10 +117,10 @@ final class Update
public function rows(?array $items): bool public function rows(?array $items): bool
{ {
// check if object could be modelled // check if object could be modelled
if (($items = $this->model->rows($items, 'power')) !== null) if (($items = $this->model->rows($items, $this->table)) !== null)
{ {
// Update the column of this table using guid as the primary key. // Update the column of this table using guid as the primary key.
return $this->database->rows($items, 'guid', 'power'); return $this->database->rows($items, 'guid', $this->table);
} }
return false; return false;
} }
@ -128,10 +137,10 @@ final class Update
public function item(object $item): bool public function item(object $item): bool
{ {
// check if object could be modelled // check if object could be modelled
if (($item = $this->model->item($item, 'power')) !== null) if (($item = $this->model->item($item, $this->table)) !== null)
{ {
// Update the column of this table using guid as the primary key. // Update the column of this table using guid as the primary key.
return $this->database->item($item, 'guid', 'power'); return $this->database->item($item, 'guid', $this->table);
} }
return false; return false;
} }
@ -148,10 +157,10 @@ final class Update
public function items(?array $items): bool public function items(?array $items): bool
{ {
// check if object could be modelled // check if object could be modelled
if (($items = $this->model->items($items, 'power')) !== null) if (($items = $this->model->items($items, $this->table)) !== null)
{ {
// Update the column of this table using guid as the primary key. // Update the column of this table using guid as the primary key.
return $this->database->items($items, 'guid', 'power'); return $this->database->items($items, 'guid', $this->table);
} }
return false; return false;
} }

View File

@ -19,6 +19,7 @@ use Joomla\CMS\Language\Text;
use VDM\Joomla\Gitea\Repository\Contents; use VDM\Joomla\Gitea\Repository\Contents;
use VDM\Joomla\Utilities\FileHelper; use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\JsonHelper; use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Componentbuilder\Interfaces\GrepInterface;
/** /**
@ -31,7 +32,7 @@ use VDM\Joomla\Utilities\JsonHelper;
* *
* @since 3.2.0 * @since 3.2.0
*/ */
final class Grep class Grep implements GrepInterface
{ {
/** /**
* The local path * The local path

View File

@ -24,7 +24,7 @@ use VDM\Joomla\Interfaces\ModelInterface;
* *
* @since 3.2.0 * @since 3.2.0
*/ */
final class Load extends AbstractionModel implements ModelInterface class Load extends AbstractionModel implements ModelInterface
{ {
/** /**
* Model the value * Model the value

View File

@ -12,11 +12,11 @@
namespace VDM\Joomla\Componentbuilder\Power\Model; namespace VDM\Joomla\Componentbuilder\Power\Model;
use VDM\Joomla\Abstraction\Model as AbstractionModel;
use VDM\Joomla\Utilities\StringHelper; use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper; use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Interfaces\ModelInterface; use VDM\Joomla\Interfaces\ModelInterface;
use VDM\Joomla\Abstraction\Model;
/** /**
@ -24,7 +24,7 @@ use VDM\Joomla\Interfaces\ModelInterface;
* *
* @since 3.2.0 * @since 3.2.0
*/ */
final class Upsert extends AbstractionModel implements ModelInterface class Upsert extends Model implements ModelInterface
{ {
/** /**
* Model the value * Model the value

View File

@ -12,9 +12,9 @@
namespace VDM\Joomla\Componentbuilder\Power; namespace VDM\Joomla\Componentbuilder\Power;
use VDM\Joomla\Componentbuilder\Power\Grep; use VDM\Joomla\Componentbuilder\Interfaces\GrepInterface as Grep;
use VDM\Joomla\Componentbuilder\Power\Database\Insert; use VDM\Joomla\Componentbuilder\Interfaces\Database\InsertInterface as Insert;
use VDM\Joomla\Componentbuilder\Power\Database\Update; use VDM\Joomla\Componentbuilder\Interfaces\Database\UpdateInterface as Update;
use VDM\Joomla\Utilities\GuidHelper; use VDM\Joomla\Utilities\GuidHelper;
@ -23,7 +23,7 @@ use VDM\Joomla\Utilities\GuidHelper;
* *
* @since 3.2.0 * @since 3.2.0
*/ */
final class Super class Super
{ {
/** /**
* The Power Search Tool * The Power Search Tool
@ -49,6 +49,14 @@ final class Super
**/ **/
protected Update $update; protected Update $update;
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'power';
/** /**
* Constructor. * Constructor.
* *
@ -174,7 +182,7 @@ final class Super
*/ */
private function action(string $guid): string private function action(string $guid): string
{ {
if (($id = GuidHelper::item($guid, 'power')) !== null && $id > 0) if (($id = GuidHelper::item($guid, $this->table)) !== null && $id > 0)
{ {
return 'update'; return 'update';
} }

View File

@ -1638,6 +1638,44 @@ class Table extends BaseTable implements Tableinterface
'tab_name' => 'Code', 'tab_name' => 'Code',
], ],
], ],
'joomla_power' => [
'system_name' => [
'name' => 'system_name',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_POWER_SYSTEM_NAME_LABEL',
'type' => 'text',
'title' => true,
'list' => 'joomla_powers',
'store' => NULL,
'tab_name' => 'Joomla Power',
],
'settings' => [
'name' => 'settings',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_POWER_SETTINGS_LABEL',
'type' => 'subform',
'title' => false,
'list' => 'joomla_powers',
'store' => 'json',
'tab_name' => 'Joomla Power',
],
'guid' => [
'name' => 'guid',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_POWER_GUID_LABEL',
'type' => 'text',
'title' => false,
'list' => 'joomla_powers',
'store' => NULL,
'tab_name' => 'publishing',
],
'description' => [
'name' => 'description',
'label' => 'COM_COMPONENTBUILDER_JOOMLA_POWER_DESCRIPTION_LABEL',
'type' => 'textarea',
'title' => false,
'list' => 'joomla_powers',
'store' => NULL,
'tab_name' => 'Joomla Power',
],
],
'power' => [ 'power' => [
'system_name' => [ 'system_name' => [
'name' => 'system_name', 'name' => 'system_name',

11
media/js/joomla_power.js Normal file
View File

@ -0,0 +1,11 @@
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

View File

@ -318,6 +318,92 @@ class Com_ComponentbuilderInstallerScript
} }
} }
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Joomla_power alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_power') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$joomla_power_found = $db->getNumRows();
// Now check if there were any rows
if ($joomla_power_found)
{
// Since there are load the needed joomla_power type ids
$joomla_power_ids = $db->loadColumn();
// Remove Joomla_power from the content type table
$joomla_power_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_power') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($joomla_power_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_power items
$joomla_power_done = $db->execute();
if ($joomla_power_done)
{
// If successfully remove Joomla_power add queued success message.
$app->enqueueMessage(Text::_('The (com_componentbuilder.joomla_power) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Joomla_power items from the contentitem tag map table
$joomla_power_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_power') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($joomla_power_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_power items
$joomla_power_done = $db->execute();
if ($joomla_power_done)
{
// If successfully remove Joomla_power add queued success message.
$app->enqueueMessage(Text::_('The (com_componentbuilder.joomla_power) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Joomla_power items from the ucm content table
$joomla_power_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.joomla_power') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($joomla_power_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_power items
$joomla_power_done = $db->execute();
if ($joomla_power_done)
{
// If successfully removed Joomla_power add queued success message.
$app->enqueueMessage(Text::_('The (com_componentbuilder.joomla_power) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Joomla_power items are cleared from DB
foreach ($joomla_power_ids as $joomla_power_id)
{
// Remove Joomla_power items from the ucm base table
$joomla_power_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_power_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($joomla_power_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_power items
$db->execute();
// Remove Joomla_power items from the ucm history table
$joomla_power_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_power_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($joomla_power_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_power items
$db->execute();
}
}
// Create a new query object. // Create a new query object.
$query = $db->getQuery(true); $query = $db->getQuery(true);
// Select id from content type table // Select id from content type table
@ -4587,6 +4673,31 @@ class Com_ComponentbuilderInstallerScript
$app->enqueueMessage(Text::_('The com_componentbuilder.joomla_plugin type alias was removed from the <b>#__action_log_config</b> table')); $app->enqueueMessage(Text::_('The com_componentbuilder.joomla_plugin type alias was removed from the <b>#__action_log_config</b> table'));
} }
// Set db if not set already.
if (!isset($db))
{
$db = Factory::getDbo();
}
// Set app if not set already.
if (!isset($app))
{
$app = Factory::getApplication();
}
// Remove Componentbuilder Joomla_power from the action_log_config table
$joomla_power_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_power') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__action_log_config'));
$query->where($joomla_power_action_log_config);
$db->setQuery($query);
// Execute the query to remove com_componentbuilder.joomla_power
$joomla_power_action_log_config_done = $db->execute();
if ($joomla_power_action_log_config_done)
{
// If successfully removed Componentbuilder Joomla_power add queued success message.
$app->enqueueMessage(Text::_('The com_componentbuilder.joomla_power type alias was removed from the <b>#__action_log_config</b> table'));
}
// Set db if not set already. // Set db if not set already.
if (!isset($db)) if (!isset($db))
{ {
@ -6232,6 +6343,90 @@ class Com_ComponentbuilderInstallerScript
foreach ($jcb_cleaner as $cleaner) foreach ($jcb_cleaner as $cleaner)
{ {
ComponentbuilderHelper::removeFolder($cleaner); ComponentbuilderHelper::removeFolder($cleaner);
}
// Define the required limits with specific messages for success and warning scenarios
$requiredConfigs = [
'upload_max_filesize' => [
'value' => '128M',
'success' => 'The upload_max_filesize is appropriately set to handle large files, which is essential for uploading substantial components and media.',
'warning' => 'The current upload_max_filesize may not support large file uploads effectively, potentially causing failures during component installation.'
],
'post_max_size' => [
'value' => '128M',
'success' => 'The post_max_size setting is sufficient to manage large data submissions, ensuring smooth data processing within forms and uploads.',
'warning' => 'An insufficient post_max_size can lead to truncated data submissions, affecting form functionality and data integrity.'
],
'max_execution_time' => [
'value' => 60,
'success' => 'Max execution time is set high enough to execute complex operations without premature termination, which is crucial for lengthy operations.',
'warning' => 'A low max execution time could lead to script timeouts, especially during intensive operations, which might interrupt execution and cause failures during the compiling of a large extension.'
],
'max_input_vars' => [
'value' => 7000,
'success' => 'The max_input_vars setting supports a high number of input variables, facilitating complex forms and detailed component configurations.',
'warning' => 'Too few max_input_vars may result in lost data during processing complex forms, which can lead to incomplete configurations and operational issues.'
],
'max_input_time' => [
'value' => 60,
'success' => 'Max input time is adequate for processing inputs efficiently during high-load operations, ensuring no premature timeouts.',
'warning' => 'An insufficient max input time could result in incomplete data processing during input-heavy operations, potentially leading to errors and data loss.'
],
'memory_limit' => [
'value' => '256M',
'success' => 'The memory limit is set high to accommodate extensive operations and data processing, which enhances overall performance and stability.',
'warning' => 'A low memory limit can lead to frequent crashes and performance issues, particularly when processing large amounts of data or complex calculations.'
]
];
// Helper function to convert PHP INI memory values to bytes
function convertToBytes($value) {
$value = trim($value);
$lastChar = strtolower($value[strlen($value) - 1]);
$numValue = substr($value, 0, -1);
switch ($lastChar)
{
case 'g':
return $numValue * 1024 * 1024 * 1024;
case 'm':
return $numValue * 1024 * 1024;
case 'k':
return $numValue * 1024;
default:
return (int) $value;
}
}
$showHelp = false;
// Check each configuration and provide detailed feedback
foreach ($requiredConfigs as $configName => $configDetails)
{
$currentValue = ini_get($configName);
if ($currentValue === false)
{
$app->enqueueMessage("Error: Unable to retrieve current setting for '{$configName}'.", 'error');
continue;
}
$isMemoryValue = strpbrk($configDetails['value'], 'KMG') !== false;
$requiredValueBytes = $isMemoryValue ? convertToBytes($configDetails['value']) : (int)$configDetails['value'];
$currentValueBytes = $isMemoryValue ? convertToBytes($currentValue) : (int)$currentValue;
$conditionMet = $currentValueBytes >= $requiredValueBytes;
$messageType = $conditionMet ? 'message' : 'warning';
$messageText = $conditionMet ?
"Success: {$configName} is set to {$currentValue}. " . $configDetails['success'] :
"Warning: {$configName} configuration should be at least {$configDetails['value']} but is currently {$currentValue}. " . $configDetails['warning'];
$showHelp = ($showHelp || $messageType === 'warning') ? true : false;
$app->enqueueMessage($messageText, $messageType);
}
if ($showHelp)
{
$app->enqueueMessage('To optimize your Joomla Component Builder (JCB) development environment, specific PHP settings must be enhanced. These settings are crucial for ensuring the successful installation and compilation of extensions. We\'ve identified that certain configurations currently do not meet the recommended standards. To adjust these settings and prevent potential issues, please consult our detailed guide available at <a href="https://git.vdm.dev/joomla/Component-Builder/wiki/PHP-Settings" target="_blank">JCB PHP Settings Wiki</a>.
', 'notice');
} }
} }
// do any install needed // do any install needed
@ -6306,6 +6501,18 @@ class Com_ComponentbuilderInstallerScript
// Set the object into the content types table. // Set the object into the content types table.
$joomla_plugin_Inserted = $db->insertObject('#__content_types', $joomla_plugin); $joomla_plugin_Inserted = $db->insertObject('#__content_types', $joomla_plugin);
// Create the joomla_power content type object.
$joomla_power = new \stdClass();
$joomla_power->type_title = 'Componentbuilder Joomla_power';
$joomla_power->type_alias = 'com_componentbuilder.joomla_power';
$joomla_power->table = '{"special": {"dbtable": "#__componentbuilder_joomla_power","key": "id","type": "Joomla_power","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
$joomla_power->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "system_name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","guid":"guid","description":"description"}}';
$joomla_power->router = 'ComponentbuilderHelperRoute::getJoomla_powerRoute';
$joomla_power->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/joomla_power.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}';
// Set the object into the content types table.
$joomla_power_Inserted = $db->insertObject('#__content_types', $joomla_power);
// Create the power content type object. // Create the power content type object.
$power = new \stdClass(); $power = new \stdClass();
$power->type_title = 'Componentbuilder Power'; $power->type_title = 'Componentbuilder Power';
@ -6890,7 +7097,7 @@ class Com_ComponentbuilderInstallerScript
{ {
$rule_length = $db->loadResult(); $rule_length = $db->loadResult();
// Check the size of the rules column // Check the size of the rules column
if ($rule_length <= 99360) if ($rule_length <= 101600)
{ {
// Fix the assets table rules column size // Fix the assets table rules column size
$fix_rules_size = "ALTER TABLE `#__assets` CHANGE `rules` `rules` MEDIUMTEXT NOT NULL COMMENT 'JSON encoded access control. Enlarged to MEDIUMTEXT by JCB';"; $fix_rules_size = "ALTER TABLE `#__assets` CHANGE `rules` `rules` MEDIUMTEXT NOT NULL COMMENT 'JSON encoded access control. Enlarged to MEDIUMTEXT by JCB';";
@ -6982,6 +7189,23 @@ class Com_ComponentbuilderInstallerScript
// Set the object into the action log config table. // Set the object into the action log config table.
$joomla_plugin_Inserted = $db->insertObject('#__action_log_config', $joomla_plugin_action_log_config); $joomla_plugin_Inserted = $db->insertObject('#__action_log_config', $joomla_plugin_action_log_config);
// Set db if not set already.
if (!isset($db))
{
$db = Factory::getDbo();
}
// Create the joomla_power action log config object.
$joomla_power_action_log_config = new \stdClass();
$joomla_power_action_log_config->type_title = 'JOOMLA_POWER';
$joomla_power_action_log_config->type_alias = 'com_componentbuilder.joomla_power';
$joomla_power_action_log_config->id_holder = 'id';
$joomla_power_action_log_config->title_holder = 'system_name';
$joomla_power_action_log_config->table_name = '#__componentbuilder_joomla_power';
$joomla_power_action_log_config->text_prefix = 'COM_COMPONENTBUILDER';
// Set the object into the action log config table.
$joomla_power_Inserted = $db->insertObject('#__action_log_config', $joomla_power_action_log_config);
// Set db if not set already. // Set db if not set already.
if (!isset($db)) if (!isset($db))
{ {
@ -7858,6 +8082,35 @@ class Com_ComponentbuilderInstallerScript
$joomla_plugin_Inserted = $db->insertObject('#__content_types', $joomla_plugin); $joomla_plugin_Inserted = $db->insertObject('#__content_types', $joomla_plugin);
} }
// Create the joomla_power content type object.
$joomla_power = new \stdClass();
$joomla_power->type_title = 'Componentbuilder Joomla_power';
$joomla_power->type_alias = 'com_componentbuilder.joomla_power';
$joomla_power->table = '{"special": {"dbtable": "#__componentbuilder_joomla_power","key": "id","type": "Joomla_power","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
$joomla_power->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "system_name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","guid":"guid","description":"description"}}';
$joomla_power->router = 'ComponentbuilderHelperRoute::getJoomla_powerRoute';
$joomla_power->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/joomla_power.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}';
// Check if joomla_power type is already in content_type DB.
$joomla_power_id = null;
$query = $db->getQuery(true);
$query->select($db->quoteName(array('type_id')));
$query->from($db->quoteName('#__content_types'));
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($joomla_power->type_alias));
$db->setQuery($query);
$db->execute();
// Set the object into the content types table.
if ($db->getNumRows())
{
$joomla_power->type_id = $db->loadResult();
$joomla_power_Updated = $db->updateObject('#__content_types', $joomla_power, 'type_id');
}
else
{
$joomla_power_Inserted = $db->insertObject('#__content_types', $joomla_power);
}
// Create the power content type object. // Create the power content type object.
$power = new \stdClass(); $power = new \stdClass();
$power->type_title = 'Componentbuilder Power'; $power->type_title = 'Componentbuilder Power';
@ -9627,7 +9880,7 @@ class Com_ComponentbuilderInstallerScript
echo '<div style="background-color: #fff;" class="alert alert-info"><a target="_blank" href="https://dev.vdm.io" title="Component Builder"> echo '<div style="background-color: #fff;" class="alert alert-info"><a target="_blank" href="https://dev.vdm.io" title="Component Builder">
<img src="components/com_componentbuilder/assets/images/vdm-component.jpg"/> <img src="components/com_componentbuilder/assets/images/vdm-component.jpg"/>
</a> </a>
<h3>Upgrade to Version 3.2.1-alpha3 Was Successful! Let us know if anything is not working as expected.</h3></div>'; <h3>Upgrade to Version 3.2.1-alpha4 Was Successful! Let us know if anything is not working as expected.</h3></div>';
// Set db if not set already. // Set db if not set already.
if (!isset($db)) if (!isset($db))
@ -9754,6 +10007,40 @@ class Com_ComponentbuilderInstallerScript
$joomla_plugin_action_log_config_Inserted = $db->insertObject('#__action_log_config', $joomla_plugin_action_log_config); $joomla_plugin_action_log_config_Inserted = $db->insertObject('#__action_log_config', $joomla_plugin_action_log_config);
} }
// Set db if not set already.
if (!isset($db))
{
$db = Factory::getDbo();
}
// Create the joomla_power action log config object.
$joomla_power_action_log_config = new \stdClass();
$joomla_power_action_log_config->id = null;
$joomla_power_action_log_config->type_title = 'JOOMLA_POWER';
$joomla_power_action_log_config->type_alias = 'com_componentbuilder.joomla_power';
$joomla_power_action_log_config->id_holder = 'id';
$joomla_power_action_log_config->title_holder = 'system_name';
$joomla_power_action_log_config->table_name = '#__componentbuilder_joomla_power';
$joomla_power_action_log_config->text_prefix = 'COM_COMPONENTBUILDER';
// Check if joomla_power action log config is already in action_log_config DB.
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')));
$query->from($db->quoteName('#__action_log_config'));
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($joomla_power_action_log_config->type_alias));
$db->setQuery($query);
$db->execute();
// Set the object into the content types table.
if ($db->getNumRows())
{
$joomla_power_action_log_config->id = $db->loadResult();
$joomla_power_action_log_config_Updated = $db->updateObject('#__action_log_config', $joomla_power_action_log_config, 'id');
}
else
{
$joomla_power_action_log_config_Inserted = $db->insertObject('#__action_log_config', $joomla_power_action_log_config);
}
// Set db if not set already. // Set db if not set already.
if (!isset($db)) if (!isset($db))
{ {

View File

@ -23,7 +23,60 @@ if (file_exists($composer_autoloader))
\spl_autoload_register(function ($class) { \spl_autoload_register(function ($class) {
// project-specific base directories and namespace prefix // project-specific base directories and namespace prefix
$search = [ $search = [
'libraries/vendor_jcb/VDM.Joomla.Openai' => 'VDM\\Joomla\\Openai', 'libraries/vendor_jcb/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea',
'libraries/vendor_jcb/VDM.Joomla.FOF' => 'VDM\\Joomla\\FOF',
'libraries/vendor_jcb/VDM.Joomla' => 'VDM\\Joomla',
'libraries/vendor_jcb/VDM.Minify' => 'VDM\\Minify',
'libraries/vendor_jcb/VDM.Psr' => 'VDM\\Psr'
];
// Start the search and load if found
$found = false;
$found_base_dir = "";
$found_len = 0;
foreach ($search as $base_dir => $prefix)
{
// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) === 0)
{
// we have a match so load the values
$found = true;
$found_base_dir = $base_dir;
$found_len = $len;
// done here
break;
}
}
// check if we found a match
if (!$found)
{
// not found so move to the next registered autoloader
return;
}
// get the relative class name
$relative_class = substr($class, $found_len);
// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = JPATH_ROOT . '/' . $found_base_dir . '/src' . str_replace('\\', '/', $relative_class) . '.php';
// if the file exists, require it
if (file_exists($file))
{
require $file;
}
});
// add the autoloader for the composer classes
$composer_autoloader = JPATH_LIBRARIES . '/phpseclib3/vendor/autoload.php';
if (file_exists($composer_autoloader))
{
require_once $composer_autoloader;
}
// register additional namespace
\spl_autoload_register(function ($class) {
// project-specific base directories and namespace prefix
$search = [
'libraries/vendor_jcb/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea', 'libraries/vendor_jcb/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea',
'libraries/vendor_jcb/VDM.Joomla.FOF' => 'VDM\\Joomla\\FOF', 'libraries/vendor_jcb/VDM.Joomla.FOF' => 'VDM\\Joomla\\FOF',
'libraries/vendor_jcb/VDM.Joomla' => 'VDM\\Joomla', 'libraries/vendor_jcb/VDM.Joomla' => 'VDM\\Joomla',

View File

@ -23,7 +23,60 @@ if (file_exists($composer_autoloader))
\spl_autoload_register(function ($class) { \spl_autoload_register(function ($class) {
// project-specific base directories and namespace prefix // project-specific base directories and namespace prefix
$search = [ $search = [
'libraries/vendor_jcb/VDM.Joomla.Openai' => 'VDM\\Joomla\\Openai', 'libraries/vendor_jcb/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea',
'libraries/vendor_jcb/VDM.Joomla.FOF' => 'VDM\\Joomla\\FOF',
'libraries/vendor_jcb/VDM.Joomla' => 'VDM\\Joomla',
'libraries/vendor_jcb/VDM.Minify' => 'VDM\\Minify',
'libraries/vendor_jcb/VDM.Psr' => 'VDM\\Psr'
];
// Start the search and load if found
$found = false;
$found_base_dir = "";
$found_len = 0;
foreach ($search as $base_dir => $prefix)
{
// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) === 0)
{
// we have a match so load the values
$found = true;
$found_base_dir = $base_dir;
$found_len = $len;
// done here
break;
}
}
// check if we found a match
if (!$found)
{
// not found so move to the next registered autoloader
return;
}
// get the relative class name
$relative_class = substr($class, $found_len);
// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = JPATH_ROOT . '/' . $found_base_dir . '/src' . str_replace('\\', '/', $relative_class) . '.php';
// if the file exists, require it
if (file_exists($file))
{
require $file;
}
});
// add the autoloader for the composer classes
$composer_autoloader = JPATH_LIBRARIES . '/phpseclib3/vendor/autoload.php';
if (file_exists($composer_autoloader))
{
require_once $composer_autoloader;
}
// register additional namespace
\spl_autoload_register(function ($class) {
// project-specific base directories and namespace prefix
$search = [
'libraries/vendor_jcb/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea', 'libraries/vendor_jcb/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea',
'libraries/vendor_jcb/VDM.Joomla.FOF' => 'VDM\\Joomla\\FOF', 'libraries/vendor_jcb/VDM.Joomla.FOF' => 'VDM\\Joomla\\FOF',
'libraries/vendor_jcb/VDM.Joomla' => 'VDM\\Joomla', 'libraries/vendor_jcb/VDM.Joomla' => 'VDM\\Joomla',

Some files were not shown because too many files have changed in this diff Show More