Release of v3.2.2-alpha5
Add repositories for better integration with gitea. Refactored the Data classes. Add new Data classes.
This commit is contained in:
@ -37,7 +37,7 @@ class ComponentbuilderModelComponentbuilder extends ListModel
|
||||
$icons = [];
|
||||
// view groups array
|
||||
$viewGroups = array(
|
||||
'main' => array('png.compiler', 'png.joomla_components', 'png.joomla_modules', 'png.joomla_plugins', 'png.powers', 'png.search', 'png||importjcbpackages||index.php?option=com_componentbuilder&view=joomla_components&task=joomla_components.smartImport', 'png.admin_views', 'png.custom_admin_views', 'png.site_views', 'png.template.add', 'png.templates', 'png.layouts', 'png.dynamic_get.add', 'png.dynamic_gets', 'png.custom_codes', 'png.placeholders', 'png.libraries', 'png.snippets', 'png.get_snippets', 'png.validation_rules', 'png.field.add', 'png.fields', 'png.fields.catid_qpo0O0oqp_com_componentbuilder_po0O0oq_field', 'png.fieldtypes', 'png.fieldtypes.catid_qpo0O0oqp_com_componentbuilder_po0O0oq_fieldtype', 'png.language_translations', 'png.servers', 'png.help_documents')
|
||||
'main' => array('png.compiler', 'png.joomla_components', 'png.joomla_modules', 'png.joomla_plugins', 'png.powers', 'png.search', 'png||importjcbpackages||index.php?option=com_componentbuilder&view=joomla_components&task=joomla_components.smartImport', 'png.admin_views', 'png.custom_admin_views', 'png.site_views', 'png.template.add', 'png.templates', 'png.layouts', 'png.dynamic_get.add', 'png.dynamic_gets', 'png.custom_codes', 'png.placeholders', 'png.libraries', 'png.snippets', 'png.get_snippets', 'png.validation_rules', 'png.field.add', 'png.fields', 'png.fields.catid_qpo0O0oqp_com_componentbuilder_po0O0oq_field', 'png.fieldtypes', 'png.fieldtypes.catid_qpo0O0oqp_com_componentbuilder_po0O0oq_fieldtype', 'png.language_translations', 'png.servers', 'png.repositories', 'png.help_documents')
|
||||
);
|
||||
// view access array
|
||||
$viewAccess = [
|
||||
@ -155,6 +155,11 @@ class ComponentbuilderModelComponentbuilder extends ListModel
|
||||
'server.access' => 'server.access',
|
||||
'servers.submenu' => 'server.submenu',
|
||||
'servers.dashboard_list' => 'server.dashboard_list',
|
||||
'repository.create' => 'repository.create',
|
||||
'repositories.access' => 'repository.access',
|
||||
'repository.access' => 'repository.access',
|
||||
'repositories.submenu' => 'repository.submenu',
|
||||
'repositories.dashboard_list' => 'repository.dashboard_list',
|
||||
'help_document.create' => 'help_document.create',
|
||||
'help_documents.access' => 'help_document.access',
|
||||
'help_document.access' => 'help_document.access',
|
||||
|
@ -71,7 +71,6 @@ class ComponentbuilderModelField extends AdminModel
|
||||
'store',
|
||||
'medium_encryption_note',
|
||||
'basic_encryption_note',
|
||||
'note_whmcs_encryption',
|
||||
'note_expert_field_save_mode',
|
||||
'initiator_on_save_model',
|
||||
'initiator_on_get_model',
|
||||
@ -215,6 +214,12 @@ class ComponentbuilderModelField extends AdminModel
|
||||
$item->metadata = $registry->toArray();
|
||||
}
|
||||
|
||||
if (!empty($item->on_get_model_field))
|
||||
{
|
||||
// base64 Decode on_get_model_field.
|
||||
$item->on_get_model_field = base64_decode($item->on_get_model_field);
|
||||
}
|
||||
|
||||
if (!empty($item->on_save_model_field))
|
||||
{
|
||||
// base64 Decode on_save_model_field.
|
||||
@ -227,10 +232,10 @@ class ComponentbuilderModelField extends AdminModel
|
||||
$item->initiator_on_get_model = base64_decode($item->initiator_on_get_model);
|
||||
}
|
||||
|
||||
if (!empty($item->initiator_on_save_model))
|
||||
if (!empty($item->javascript_view_footer))
|
||||
{
|
||||
// base64 Decode initiator_on_save_model.
|
||||
$item->initiator_on_save_model = base64_decode($item->initiator_on_save_model);
|
||||
// base64 Decode javascript_view_footer.
|
||||
$item->javascript_view_footer = base64_decode($item->javascript_view_footer);
|
||||
}
|
||||
|
||||
if (!empty($item->css_views))
|
||||
@ -245,24 +250,18 @@ class ComponentbuilderModelField extends AdminModel
|
||||
$item->css_view = base64_decode($item->css_view);
|
||||
}
|
||||
|
||||
if (!empty($item->on_get_model_field))
|
||||
{
|
||||
// base64 Decode on_get_model_field.
|
||||
$item->on_get_model_field = base64_decode($item->on_get_model_field);
|
||||
}
|
||||
|
||||
if (!empty($item->javascript_view_footer))
|
||||
{
|
||||
// base64 Decode javascript_view_footer.
|
||||
$item->javascript_view_footer = base64_decode($item->javascript_view_footer);
|
||||
}
|
||||
|
||||
if (!empty($item->javascript_views_footer))
|
||||
{
|
||||
// base64 Decode javascript_views_footer.
|
||||
$item->javascript_views_footer = base64_decode($item->javascript_views_footer);
|
||||
}
|
||||
|
||||
if (!empty($item->initiator_on_save_model))
|
||||
{
|
||||
// base64 Decode initiator_on_save_model.
|
||||
$item->initiator_on_save_model = base64_decode($item->initiator_on_save_model);
|
||||
}
|
||||
|
||||
if (!empty($item->xml))
|
||||
{
|
||||
// JSON Decode xml.
|
||||
@ -1172,6 +1171,12 @@ class ComponentbuilderModelField extends AdminModel
|
||||
$data['xml'] = (string) json_encode($data['xml']);
|
||||
}
|
||||
|
||||
// Set the on_get_model_field string to base64 string.
|
||||
if (isset($data['on_get_model_field']))
|
||||
{
|
||||
$data['on_get_model_field'] = base64_encode($data['on_get_model_field']);
|
||||
}
|
||||
|
||||
// Set the on_save_model_field string to base64 string.
|
||||
if (isset($data['on_save_model_field']))
|
||||
{
|
||||
@ -1184,10 +1189,10 @@ class ComponentbuilderModelField extends AdminModel
|
||||
$data['initiator_on_get_model'] = base64_encode($data['initiator_on_get_model']);
|
||||
}
|
||||
|
||||
// Set the initiator_on_save_model string to base64 string.
|
||||
if (isset($data['initiator_on_save_model']))
|
||||
// Set the javascript_view_footer string to base64 string.
|
||||
if (isset($data['javascript_view_footer']))
|
||||
{
|
||||
$data['initiator_on_save_model'] = base64_encode($data['initiator_on_save_model']);
|
||||
$data['javascript_view_footer'] = base64_encode($data['javascript_view_footer']);
|
||||
}
|
||||
|
||||
// Set the css_views string to base64 string.
|
||||
@ -1202,24 +1207,18 @@ class ComponentbuilderModelField extends AdminModel
|
||||
$data['css_view'] = base64_encode($data['css_view']);
|
||||
}
|
||||
|
||||
// Set the on_get_model_field string to base64 string.
|
||||
if (isset($data['on_get_model_field']))
|
||||
{
|
||||
$data['on_get_model_field'] = base64_encode($data['on_get_model_field']);
|
||||
}
|
||||
|
||||
// Set the javascript_view_footer string to base64 string.
|
||||
if (isset($data['javascript_view_footer']))
|
||||
{
|
||||
$data['javascript_view_footer'] = base64_encode($data['javascript_view_footer']);
|
||||
}
|
||||
|
||||
// Set the javascript_views_footer string to base64 string.
|
||||
if (isset($data['javascript_views_footer']))
|
||||
{
|
||||
$data['javascript_views_footer'] = base64_encode($data['javascript_views_footer']);
|
||||
}
|
||||
|
||||
// Set the initiator_on_save_model string to base64 string.
|
||||
if (isset($data['initiator_on_save_model']))
|
||||
{
|
||||
$data['initiator_on_save_model'] = base64_encode($data['initiator_on_save_model']);
|
||||
}
|
||||
|
||||
// Set the Params Items to data
|
||||
if (isset($data['params']) && is_array($data['params']))
|
||||
{
|
||||
|
@ -346,7 +346,6 @@ class ComponentbuilderModelFields extends ListModel
|
||||
2 => 'COM_COMPONENTBUILDER_FIELD_BASE64',
|
||||
3 => 'COM_COMPONENTBUILDER_FIELD_BASIC_ENCRYPTION_LOCALDBKEY',
|
||||
5 => 'COM_COMPONENTBUILDER_FIELD_MEDIUM_ENCRYPTION_LOCALFILEKEY',
|
||||
4 => 'COM_COMPONENTBUILDER_FIELD_WHMCSKEY_ENCRYPTION',
|
||||
6 => 'COM_COMPONENTBUILDER_FIELD_EXPERT_MODE_CUSTOM'
|
||||
);
|
||||
// Now check if value is found in this array
|
||||
@ -721,22 +720,22 @@ class ComponentbuilderModelFields extends ListModel
|
||||
continue;
|
||||
}
|
||||
|
||||
// decode on_get_model_field
|
||||
$item->on_get_model_field = base64_decode($item->on_get_model_field);
|
||||
// decode on_save_model_field
|
||||
$item->on_save_model_field = base64_decode($item->on_save_model_field);
|
||||
// decode initiator_on_get_model
|
||||
$item->initiator_on_get_model = base64_decode($item->initiator_on_get_model);
|
||||
// decode initiator_on_save_model
|
||||
$item->initiator_on_save_model = base64_decode($item->initiator_on_save_model);
|
||||
// decode javascript_view_footer
|
||||
$item->javascript_view_footer = base64_decode($item->javascript_view_footer);
|
||||
// decode css_views
|
||||
$item->css_views = base64_decode($item->css_views);
|
||||
// decode css_view
|
||||
$item->css_view = base64_decode($item->css_view);
|
||||
// decode on_get_model_field
|
||||
$item->on_get_model_field = base64_decode($item->on_get_model_field);
|
||||
// decode javascript_view_footer
|
||||
$item->javascript_view_footer = base64_decode($item->javascript_view_footer);
|
||||
// decode javascript_views_footer
|
||||
$item->javascript_views_footer = base64_decode($item->javascript_views_footer);
|
||||
// decode initiator_on_save_model
|
||||
$item->initiator_on_save_model = base64_decode($item->initiator_on_save_model);
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
|
71
admin/models/fields/repositoriesfilterbase.php
Normal file
71
admin/models/fields/repositoriesfilterbase.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?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;
|
||||
|
||||
// import the list field type
|
||||
jimport('joomla.form.helper');
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Repositoriesfilterbase Form Field class for the Componentbuilder component
|
||||
*/
|
||||
class JFormFieldRepositoriesfilterbase extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The repositoriesfilterbase field type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'repositoriesfilterbase';
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
*
|
||||
* @return array An array of Html options.
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select the text.
|
||||
$query->select($db->quoteName('base'));
|
||||
$query->from($db->quoteName('#__componentbuilder_repository'));
|
||||
$query->order($db->quoteName('base') . ' ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
|
||||
$_results = $db->loadColumn();
|
||||
$_filter = [];
|
||||
$_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_BASE_URL') . ' -');
|
||||
|
||||
if ($_results)
|
||||
{
|
||||
$_results = array_unique($_results);
|
||||
foreach ($_results as $base)
|
||||
{
|
||||
// Now add the base and its text to the options array
|
||||
$_filter[] = Html::_('select.option', $base, $base);
|
||||
}
|
||||
}
|
||||
return $_filter;
|
||||
}
|
||||
}
|
71
admin/models/fields/repositoriesfilterorganisation.php
Normal file
71
admin/models/fields/repositoriesfilterorganisation.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?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;
|
||||
|
||||
// import the list field type
|
||||
jimport('joomla.form.helper');
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Repositoriesfilterorganisation Form Field class for the Componentbuilder component
|
||||
*/
|
||||
class JFormFieldRepositoriesfilterorganisation extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The repositoriesfilterorganisation field type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'repositoriesfilterorganisation';
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
*
|
||||
* @return array An array of Html options.
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select the text.
|
||||
$query->select($db->quoteName('organisation'));
|
||||
$query->from($db->quoteName('#__componentbuilder_repository'));
|
||||
$query->order($db->quoteName('organisation') . ' ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
|
||||
$_results = $db->loadColumn();
|
||||
$_filter = [];
|
||||
$_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_ORGANISATION') . ' -');
|
||||
|
||||
if ($_results)
|
||||
{
|
||||
$_results = array_unique($_results);
|
||||
foreach ($_results as $organisation)
|
||||
{
|
||||
// Now add the organisation and its text to the options array
|
||||
$_filter[] = Html::_('select.option', $organisation, $organisation);
|
||||
}
|
||||
}
|
||||
return $_filter;
|
||||
}
|
||||
}
|
71
admin/models/fields/repositoriesfilterrepository.php
Normal file
71
admin/models/fields/repositoriesfilterrepository.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?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;
|
||||
|
||||
// import the list field type
|
||||
jimport('joomla.form.helper');
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Repositoriesfilterrepository Form Field class for the Componentbuilder component
|
||||
*/
|
||||
class JFormFieldRepositoriesfilterrepository extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The repositoriesfilterrepository field type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'repositoriesfilterrepository';
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
*
|
||||
* @return array An array of Html options.
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select the text.
|
||||
$query->select($db->quoteName('repository'));
|
||||
$query->from($db->quoteName('#__componentbuilder_repository'));
|
||||
$query->order($db->quoteName('repository') . ' ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
|
||||
$_results = $db->loadColumn();
|
||||
$_filter = [];
|
||||
$_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_REPOSITORY') . ' -');
|
||||
|
||||
if ($_results)
|
||||
{
|
||||
$_results = array_unique($_results);
|
||||
foreach ($_results as $repository)
|
||||
{
|
||||
// Now add the repository and its text to the options array
|
||||
$_filter[] = Html::_('select.option', $repository, $repository);
|
||||
}
|
||||
}
|
||||
return $_filter;
|
||||
}
|
||||
}
|
75
admin/models/fields/repositoriesfiltertarget.php
Normal file
75
admin/models/fields/repositoriesfiltertarget.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?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;
|
||||
|
||||
// import the list field type
|
||||
jimport('joomla.form.helper');
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Repositoriesfiltertarget Form Field class for the Componentbuilder component
|
||||
*/
|
||||
class JFormFieldRepositoriesfiltertarget extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The repositoriesfiltertarget field type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'repositoriesfiltertarget';
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
*
|
||||
* @return array An array of Html options.
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = Factory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select the text.
|
||||
$query->select($db->quoteName('target'));
|
||||
$query->from($db->quoteName('#__componentbuilder_repository'));
|
||||
$query->order($db->quoteName('target') . ' ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
|
||||
$_results = $db->loadColumn();
|
||||
$_filter = [];
|
||||
$_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_TARGET_CONTENT') . ' -');
|
||||
|
||||
if ($_results)
|
||||
{
|
||||
// get repositoriesmodel
|
||||
$_model = ComponentbuilderHelper::getModel('repositories');
|
||||
$_results = array_unique($_results);
|
||||
foreach ($_results as $target)
|
||||
{
|
||||
// Translate the target selection
|
||||
$_text = $_model->selectionTranslation($target,'target');
|
||||
// Now add the target and its text to the options array
|
||||
$_filter[] = Html::_('select.option', $target, Text::_($_text));
|
||||
}
|
||||
}
|
||||
return $_filter;
|
||||
}
|
||||
}
|
@ -15,7 +15,6 @@ defined('_JEXEC') or die('Restricted access');
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\HTML\HTMLHelper as Html;
|
||||
use VDM\Joomla\Utilities\Component\Helper;
|
||||
jimport('joomla.form.helper');
|
||||
\JFormHelper::loadFieldClass('checkboxes');
|
||||
|
||||
@ -33,69 +32,41 @@ class JFormFieldSuperpowerpaths extends JFormFieldCheckboxes
|
||||
|
||||
// A DynamicCheckboxes@ Field
|
||||
/**
|
||||
* Method to get the data to be passed to the layout for rendering.
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 3.5
|
||||
* @since 3.7.0
|
||||
*/
|
||||
protected function getLayoutData()
|
||||
protected function getOptions()
|
||||
{
|
||||
$data = parent::getLayoutData();
|
||||
|
||||
// True if the field has 'value' set. In other words, it has been stored, don't use the default values.
|
||||
$hasValue = (isset($this->value) && !empty($this->value));
|
||||
|
||||
// If a value has been stored, use it. Otherwise, use the defaults.
|
||||
$checkedOptions = $hasValue ? $this->value : $this->checkedOptions;
|
||||
|
||||
// get the form options
|
||||
// Get the databse object.
|
||||
$db = Factory::getDBO();
|
||||
$query = $db->getQuery(true);
|
||||
$query->select($db->quoteName(array('a.repository', 'a.organisation')))
|
||||
->from($db->quoteName('#__componentbuilder_repository', 'a'))
|
||||
->where($db->quoteName('a.published') . ' >= 1')
|
||||
->where($db->quoteName('a.target') . ' = 1') // super powers
|
||||
->order($db->quoteName('a.ordering') . ' ASC');
|
||||
$db->setQuery((string)$query);
|
||||
$items = $db->loadObjectList();
|
||||
$options = [];
|
||||
|
||||
// get the component params
|
||||
$params = Helper::getParams();
|
||||
$activate = $params->get('super_powers_repositories', 0);
|
||||
|
||||
// set the default
|
||||
$default = $params->get('super_powers_core', 'joomla/super-powers');
|
||||
|
||||
// must have one / in the path
|
||||
if (strpos($default, '/') !== false)
|
||||
if ($items)
|
||||
{
|
||||
$tmp = new \stdClass;
|
||||
$tmp->text = $tmp->value = trim($default);
|
||||
$tmp->checked = false;
|
||||
$options[$tmp->value] = $tmp;
|
||||
}
|
||||
|
||||
if ($activate == 1)
|
||||
{
|
||||
$subform = $params->get($this->fieldname);
|
||||
|
||||
// add the paths found in global settings
|
||||
if (is_object($subform))
|
||||
if ($this->multiple === false)
|
||||
{
|
||||
foreach ($subform as $value)
|
||||
{
|
||||
if (isset($value->owner) && strlen($value->owner) > 1 &&
|
||||
isset($value->repo) && strlen($value->repo) > 1)
|
||||
{
|
||||
$tmp = new \stdClass;
|
||||
$tmp->text = $tmp->value = trim($value->owner) . '/' . trim($value->repo);
|
||||
$tmp->checked = false;
|
||||
|
||||
$options[$tmp->value] = $tmp;
|
||||
}
|
||||
}
|
||||
$options[] = Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_SELECT_AN_OPTION'));
|
||||
}
|
||||
foreach($items as $item)
|
||||
{
|
||||
$path = $item->organisation . '/' . $item->repository;
|
||||
$options[] = Html::_('select.option', $path, $path);
|
||||
}
|
||||
}
|
||||
|
||||
$extraData = array(
|
||||
'checkedOptions' => is_array($checkedOptions) ? $checkedOptions : explode(',', (string) $checkedOptions),
|
||||
'hasValue' => $hasValue,
|
||||
'options' => array_values($options)
|
||||
);
|
||||
|
||||
return array_merge($data, $extraData);
|
||||
else
|
||||
{
|
||||
$options[] = Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_NO_ACTIVE_REPOSITORIES_FOUND'));
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ class ComponentbuilderModelFieldtype extends AdminModel
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getVxtfields()
|
||||
public function getVxsfields()
|
||||
{
|
||||
// Get the user object.
|
||||
$user = Factory::getUser();
|
||||
@ -399,13 +399,13 @@ class ComponentbuilderModelFieldtype extends AdminModel
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// convert datatype
|
||||
$item->datatype = $this->selectionTranslationVxtfields($item->datatype, 'datatype');
|
||||
$item->datatype = $this->selectionTranslationVxsfields($item->datatype, 'datatype');
|
||||
// convert indexes
|
||||
$item->indexes = $this->selectionTranslationVxtfields($item->indexes, 'indexes');
|
||||
$item->indexes = $this->selectionTranslationVxsfields($item->indexes, 'indexes');
|
||||
// convert null_switch
|
||||
$item->null_switch = $this->selectionTranslationVxtfields($item->null_switch, 'null_switch');
|
||||
$item->null_switch = $this->selectionTranslationVxsfields($item->null_switch, 'null_switch');
|
||||
// convert store
|
||||
$item->store = $this->selectionTranslationVxtfields($item->store, 'store');
|
||||
$item->store = $this->selectionTranslationVxsfields($item->store, 'store');
|
||||
}
|
||||
}
|
||||
|
||||
@ -419,7 +419,7 @@ class ComponentbuilderModelFieldtype extends AdminModel
|
||||
*
|
||||
* @return string The translatable string.
|
||||
*/
|
||||
public function selectionTranslationVxtfields($value,$name)
|
||||
public function selectionTranslationVxsfields($value,$name)
|
||||
{
|
||||
// Array of datatype language strings
|
||||
if ($name === 'datatype')
|
||||
@ -487,7 +487,6 @@ class ComponentbuilderModelFieldtype extends AdminModel
|
||||
2 => 'COM_COMPONENTBUILDER_FIELD_BASE64',
|
||||
3 => 'COM_COMPONENTBUILDER_FIELD_BASIC_ENCRYPTION_LOCALDBKEY',
|
||||
5 => 'COM_COMPONENTBUILDER_FIELD_MEDIUM_ENCRYPTION_LOCALFILEKEY',
|
||||
4 => 'COM_COMPONENTBUILDER_FIELD_WHMCSKEY_ENCRYPTION',
|
||||
6 => 'COM_COMPONENTBUILDER_FIELD_EXPERT_MODE_CUSTOM'
|
||||
);
|
||||
// Now check if value is found in this array
|
||||
|
@ -226,8 +226,6 @@
|
||||
COM_COMPONENTBUILDER_FIELD_BASIC_ENCRYPTION_LOCALDBKEY</option>
|
||||
<option value="5">
|
||||
COM_COMPONENTBUILDER_FIELD_MEDIUM_ENCRYPTION_LOCALFILEKEY</option>
|
||||
<option value="4">
|
||||
COM_COMPONENTBUILDER_FIELD_WHMCSKEY_ENCRYPTION</option>
|
||||
<option value="6">
|
||||
COM_COMPONENTBUILDER_FIELD_EXPERT_MODE_CUSTOM</option>
|
||||
</field>
|
||||
@ -240,6 +238,21 @@
|
||||
description="COM_COMPONENTBUILDER_FIELD_CATID_DESCRIPTION"
|
||||
class="inputbox"
|
||||
/>
|
||||
<!-- Note_no_database_settings_needed Field. Type: Note. A None Database Field. (joomla) -->
|
||||
<field type="note" name="note_no_database_settings_needed" label="COM_COMPONENTBUILDER_FIELD_NOTE_NO_DATABASE_SETTINGS_NEEDED_LABEL" description="COM_COMPONENTBUILDER_FIELD_NOTE_NO_DATABASE_SETTINGS_NEEDED_DESCRIPTION" heading="h4" class="alert alert-info note_no_database_settings_needed" />
|
||||
<!-- On_get_model_field Field. Type: Textarea. (joomla) -->
|
||||
<field
|
||||
type="textarea"
|
||||
name="on_get_model_field"
|
||||
label="COM_COMPONENTBUILDER_FIELD_ON_GET_MODEL_FIELD_LABEL"
|
||||
rows="5"
|
||||
cols="10"
|
||||
description="COM_COMPONENTBUILDER_FIELD_ON_GET_MODEL_FIELD_DESCRIPTION"
|
||||
class="text_area span12"
|
||||
filter="raw"
|
||||
hint="COM_COMPONENTBUILDER_FIELD_ON_GET_MODEL_FIELD_HINT"
|
||||
required="true"
|
||||
/>
|
||||
<!-- On_save_model_field Field. Type: Textarea. (joomla) -->
|
||||
<field
|
||||
type="textarea"
|
||||
@ -266,19 +279,6 @@
|
||||
hint="COM_COMPONENTBUILDER_FIELD_INITIATOR_ON_GET_MODEL_HINT"
|
||||
required="false"
|
||||
/>
|
||||
<!-- Initiator_on_save_model Field. Type: Textarea. (joomla) -->
|
||||
<field
|
||||
type="textarea"
|
||||
name="initiator_on_save_model"
|
||||
label="COM_COMPONENTBUILDER_FIELD_INITIATOR_ON_SAVE_MODEL_LABEL"
|
||||
rows="5"
|
||||
cols="10"
|
||||
description="COM_COMPONENTBUILDER_FIELD_INITIATOR_ON_SAVE_MODEL_DESCRIPTION"
|
||||
class="text_area span12"
|
||||
filter="raw"
|
||||
hint="COM_COMPONENTBUILDER_FIELD_INITIATOR_ON_SAVE_MODEL_HINT"
|
||||
required="false"
|
||||
/>
|
||||
<!-- Note_filter_information Field. Type: Note. A None Database Field. (joomla) -->
|
||||
<field type="note" name="note_filter_information" description="COM_COMPONENTBUILDER_FIELD_NOTE_FILTER_INFORMATION_DESCRIPTION" class="note_filter_information" />
|
||||
<!-- Xml Field. Type: Hidden. (joomla) -->
|
||||
@ -324,8 +324,22 @@
|
||||
<option value="Other">
|
||||
COM_COMPONENTBUILDER_FIELD_OTHER</option>
|
||||
</field>
|
||||
<!-- Note_database_settings_needed Field. Type: Note. A None Database Field. (joomla) -->
|
||||
<field type="note" name="note_database_settings_needed" label="COM_COMPONENTBUILDER_FIELD_NOTE_DATABASE_SETTINGS_NEEDED_LABEL" description="COM_COMPONENTBUILDER_FIELD_NOTE_DATABASE_SETTINGS_NEEDED_DESCRIPTION" heading="h4" class="alert alert-info note_database_settings_needed" />
|
||||
<!-- Javascript_view_footer Field. Type: Editor. (joomla) -->
|
||||
<field
|
||||
type="editor"
|
||||
name="javascript_view_footer"
|
||||
label="COM_COMPONENTBUILDER_FIELD_JAVASCRIPT_VIEW_FOOTER_LABEL"
|
||||
description="COM_COMPONENTBUILDER_FIELD_JAVASCRIPT_VIEW_FOOTER_DESCRIPTION"
|
||||
width="100%"
|
||||
height="450px"
|
||||
cols="15"
|
||||
rows="30"
|
||||
buttons="no"
|
||||
syntax="javascript"
|
||||
editor="codemirror|none"
|
||||
filter="raw"
|
||||
validate="code"
|
||||
/>
|
||||
<!-- Css_views Field. Type: Editor. (joomla) -->
|
||||
<field
|
||||
type="editor"
|
||||
@ -411,37 +425,8 @@
|
||||
message="COM_COMPONENTBUILDER_FIELD_DATALENGHT_OTHER_MESSAGE"
|
||||
hint="COM_COMPONENTBUILDER_FIELD_DATALENGHT_OTHER_HINT"
|
||||
/>
|
||||
<!-- On_get_model_field Field. Type: Textarea. (joomla) -->
|
||||
<field
|
||||
type="textarea"
|
||||
name="on_get_model_field"
|
||||
label="COM_COMPONENTBUILDER_FIELD_ON_GET_MODEL_FIELD_LABEL"
|
||||
rows="5"
|
||||
cols="10"
|
||||
description="COM_COMPONENTBUILDER_FIELD_ON_GET_MODEL_FIELD_DESCRIPTION"
|
||||
class="text_area span12"
|
||||
filter="raw"
|
||||
hint="COM_COMPONENTBUILDER_FIELD_ON_GET_MODEL_FIELD_HINT"
|
||||
required="true"
|
||||
/>
|
||||
<!-- Javascript_view_footer Field. Type: Editor. (joomla) -->
|
||||
<field
|
||||
type="editor"
|
||||
name="javascript_view_footer"
|
||||
label="COM_COMPONENTBUILDER_FIELD_JAVASCRIPT_VIEW_FOOTER_LABEL"
|
||||
description="COM_COMPONENTBUILDER_FIELD_JAVASCRIPT_VIEW_FOOTER_DESCRIPTION"
|
||||
width="100%"
|
||||
height="450px"
|
||||
cols="15"
|
||||
rows="30"
|
||||
buttons="no"
|
||||
syntax="javascript"
|
||||
editor="codemirror|none"
|
||||
filter="raw"
|
||||
validate="code"
|
||||
/>
|
||||
<!-- Note_no_database_settings_needed Field. Type: Note. A None Database Field. (joomla) -->
|
||||
<field type="note" name="note_no_database_settings_needed" label="COM_COMPONENTBUILDER_FIELD_NOTE_NO_DATABASE_SETTINGS_NEEDED_LABEL" description="COM_COMPONENTBUILDER_FIELD_NOTE_NO_DATABASE_SETTINGS_NEEDED_DESCRIPTION" heading="h4" class="alert alert-info note_no_database_settings_needed" />
|
||||
<!-- Note_database_settings_needed Field. Type: Note. A None Database Field. (joomla) -->
|
||||
<field type="note" name="note_database_settings_needed" label="COM_COMPONENTBUILDER_FIELD_NOTE_DATABASE_SETTINGS_NEEDED_LABEL" description="COM_COMPONENTBUILDER_FIELD_NOTE_DATABASE_SETTINGS_NEEDED_DESCRIPTION" heading="h4" class="alert alert-info note_database_settings_needed" />
|
||||
<!-- Javascript_views_footer Field. Type: Editor. (joomla) -->
|
||||
<field
|
||||
type="editor"
|
||||
@ -524,12 +509,23 @@
|
||||
<option value="0">
|
||||
COM_COMPONENTBUILDER_FIELD_NO</option>
|
||||
</field>
|
||||
<!-- Note_whmcs_encryption Field. Type: Note. A None Database Field. (joomla) -->
|
||||
<field type="note" name="note_whmcs_encryption" label="COM_COMPONENTBUILDER_FIELD_NOTE_WHMCS_ENCRYPTION_LABEL" description="COM_COMPONENTBUILDER_FIELD_NOTE_WHMCS_ENCRYPTION_DESCRIPTION" heading="h4" class="alert alert-success note_whmcs_encryption" />
|
||||
<!-- Helpnote Field. Type: Note. A None Database Field. (joomla) -->
|
||||
<field type="note" name="helpnote" label="COM_COMPONENTBUILDER_FIELD_HELPNOTE_LABEL" class="helpNote helpnote" />
|
||||
<!-- Note_expert_field_save_mode Field. Type: Note. A None Database Field. (joomla) -->
|
||||
<field type="note" name="note_expert_field_save_mode" label="COM_COMPONENTBUILDER_FIELD_NOTE_EXPERT_FIELD_SAVE_MODE_LABEL" description="COM_COMPONENTBUILDER_FIELD_NOTE_EXPERT_FIELD_SAVE_MODE_DESCRIPTION" heading="h4" class="alert alert-success note_expert_encryption note_expert_field_save_mode" />
|
||||
<!-- Helpnote Field. Type: Note. A None Database Field. (joomla) -->
|
||||
<field type="note" name="helpnote" label="COM_COMPONENTBUILDER_FIELD_HELPNOTE_LABEL" class="helpNote helpnote" />
|
||||
<!-- Initiator_on_save_model Field. Type: Textarea. (joomla) -->
|
||||
<field
|
||||
type="textarea"
|
||||
name="initiator_on_save_model"
|
||||
label="COM_COMPONENTBUILDER_FIELD_INITIATOR_ON_SAVE_MODEL_LABEL"
|
||||
rows="5"
|
||||
cols="10"
|
||||
description="COM_COMPONENTBUILDER_FIELD_INITIATOR_ON_SAVE_MODEL_DESCRIPTION"
|
||||
class="text_area span12"
|
||||
filter="raw"
|
||||
hint="COM_COMPONENTBUILDER_FIELD_INITIATOR_ON_SAVE_MODEL_HINT"
|
||||
required="false"
|
||||
/>
|
||||
<!-- Guid Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
|
@ -132,8 +132,6 @@
|
||||
COM_COMPONENTBUILDER_FIELDTYPE_BASIC_ENCRYPTION_LOCALDBKEY</option>
|
||||
<option value="5">
|
||||
COM_COMPONENTBUILDER_FIELDTYPE_MEDIUM_ENCRYPTION_LOCALFILEKEY</option>
|
||||
<option value="4">
|
||||
COM_COMPONENTBUILDER_FIELDTYPE_WHMCSKEY_ENCRYPTION</option>
|
||||
<option value="6">
|
||||
COM_COMPONENTBUILDER_FIELDTYPE_EXPERT_MODE_CUSTOM</option>
|
||||
</field>
|
||||
|
103
admin/models/forms/filter_repositories.xml
Normal file
103
admin/models/forms/filter_repositories.xml
Normal file
@ -0,0 +1,103 @@
|
||||
<?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_REPOSITORIES"
|
||||
hint="JSEARCH_FILTER"
|
||||
/>
|
||||
<field
|
||||
type="status"
|
||||
name="published"
|
||||
label="COM_COMPONENTBUILDER_FILTER_PUBLISHED"
|
||||
description="COM_COMPONENTBUILDER_FILTER_PUBLISHED_REPOSITORIES"
|
||||
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();"
|
||||
/>
|
||||
<field
|
||||
type="repositoriesfilterorganisation"
|
||||
name="organisation"
|
||||
label="COM_COMPONENTBUILDER_REPOSITORY_ORGANISATION_LABEL"
|
||||
multiple="false"
|
||||
onchange="this.form.submit();"
|
||||
/>
|
||||
<field
|
||||
type="repositoriesfilterrepository"
|
||||
name="repository"
|
||||
label="COM_COMPONENTBUILDER_REPOSITORY_REPOSITORY_LABEL"
|
||||
multiple="false"
|
||||
onchange="this.form.submit();"
|
||||
/>
|
||||
<field
|
||||
type="repositoriesfiltertarget"
|
||||
name="target"
|
||||
label="COM_COMPONENTBUILDER_REPOSITORY_TARGET_LABEL"
|
||||
multiple="false"
|
||||
onchange="this.form.submit();"
|
||||
/>
|
||||
<field
|
||||
type="repositoriesfilterbase"
|
||||
name="base"
|
||||
label="COM_COMPONENTBUILDER_REPOSITORY_BASE_LABEL"
|
||||
multiple="false"
|
||||
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.organisation ASC">COM_COMPONENTBUILDER_FILTER_ORGANISATION_ASCENDING</option>
|
||||
<option value="a.organisation DESC">COM_COMPONENTBUILDER_FILTER_ORGANISATION_DESCENDING</option>
|
||||
<option value="a.repository ASC">COM_COMPONENTBUILDER_FILTER_REPOSITORY_ASCENDING</option>
|
||||
<option value="a.repository DESC">COM_COMPONENTBUILDER_FILTER_REPOSITORY_DESCENDING</option>
|
||||
<option value="a.target ASC">COM_COMPONENTBUILDER_FILTER_TARGET_CONTENT_ASCENDING</option>
|
||||
<option value="a.target DESC">COM_COMPONENTBUILDER_FILTER_TARGET_CONTENT_DESCENDING</option>
|
||||
<option value="a.type ASC">COM_COMPONENTBUILDER_FILTER_TYPE_ASCENDING</option>
|
||||
<option value="a.type DESC">COM_COMPONENTBUILDER_FILTER_TYPE_DESCENDING</option>
|
||||
<option value="a.base ASC">COM_COMPONENTBUILDER_FILTER_BASE_URL_ASCENDING</option>
|
||||
<option value="a.base DESC">COM_COMPONENTBUILDER_FILTER_BASE_URL_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>
|
File diff suppressed because it is too large
Load Diff
302
admin/models/forms/repository.xml
Normal file
302
admin/models/forms/repository.xml
Normal file
@ -0,0 +1,302 @@
|
||||
<?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_REPOSITORY_CREATED_DATE_LABEL"
|
||||
description="COM_COMPONENTBUILDER_REPOSITORY_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_REPOSITORY_CREATED_BY_LABEL"
|
||||
description="COM_COMPONENTBUILDER_REPOSITORY_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_REPOSITORY_MODIFIED_DATE_LABEL" description="COM_COMPONENTBUILDER_REPOSITORY_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_REPOSITORY_MODIFIED_BY_LABEL"
|
||||
description="COM_COMPONENTBUILDER_REPOSITORY_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_REPOSITORY_ORDERING_LABEL"
|
||||
description=""
|
||||
default="0"
|
||||
size="6"
|
||||
required="false"
|
||||
/>
|
||||
<!-- Version Field. Type: Text (joomla) -->
|
||||
<field
|
||||
name="version"
|
||||
type="text"
|
||||
class="readonly"
|
||||
label="COM_COMPONENTBUILDER_REPOSITORY_VERSION_LABEL"
|
||||
description="COM_COMPONENTBUILDER_REPOSITORY_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 repository"
|
||||
/>
|
||||
<!-- Dynamic Fields. -->
|
||||
<!-- System_name Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="system_name"
|
||||
label="COM_COMPONENTBUILDER_REPOSITORY_SYSTEM_NAME_LABEL"
|
||||
size="10"
|
||||
maxlength="50"
|
||||
default=""
|
||||
description="COM_COMPONENTBUILDER_REPOSITORY_SYSTEM_NAME_DESCRIPTION"
|
||||
class="text_area"
|
||||
filter="STRING"
|
||||
message="COM_COMPONENTBUILDER_REPOSITORY_SYSTEM_NAME_MESSAGE"
|
||||
hint="COM_COMPONENTBUILDER_REPOSITORY_SYSTEM_NAME_HINT"
|
||||
/>
|
||||
<!-- Organisation Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="organisation"
|
||||
label="COM_COMPONENTBUILDER_REPOSITORY_ORGANISATION_LABEL"
|
||||
size="60"
|
||||
maxlength="150"
|
||||
description="COM_COMPONENTBUILDER_REPOSITORY_ORGANISATION_DESCRIPTION"
|
||||
class="text_area"
|
||||
required="true"
|
||||
filter="STRING"
|
||||
message="COM_COMPONENTBUILDER_REPOSITORY_ORGANISATION_MESSAGE"
|
||||
hint="COM_COMPONENTBUILDER_REPOSITORY_ORGANISATION_HINT"
|
||||
/>
|
||||
<!-- Repository Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="repository"
|
||||
label="COM_COMPONENTBUILDER_REPOSITORY_REPOSITORY_LABEL"
|
||||
size="70"
|
||||
maxlength="150"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
required="true"
|
||||
filter="CMD"
|
||||
hint="COM_COMPONENTBUILDER_REPOSITORY_REPOSITORY_HINT"
|
||||
autocomplete="on"
|
||||
/>
|
||||
<!-- Target Field. Type: List. (joomla) -->
|
||||
<field
|
||||
type="list"
|
||||
name="target"
|
||||
label="COM_COMPONENTBUILDER_REPOSITORY_TARGET_LABEL"
|
||||
description="COM_COMPONENTBUILDER_REPOSITORY_TARGET_DESCRIPTION"
|
||||
class="list_class"
|
||||
layout="joomla.form.field.list-fancy-select"
|
||||
multiple="false"
|
||||
filter="INT"
|
||||
required="true"
|
||||
validate="int">
|
||||
<!-- Option Set. -->
|
||||
<option value="">
|
||||
COM_COMPONENTBUILDER_REPOSITORY_SELECT_AN_OPTION</option>
|
||||
<option value="1">
|
||||
COM_COMPONENTBUILDER_REPOSITORY_SUPER_POWER</option>
|
||||
<option value="2">
|
||||
COM_COMPONENTBUILDER_REPOSITORY_JOOMLA_POWER</option>
|
||||
</field>
|
||||
<!-- Type Field. Type: List. (joomla) -->
|
||||
<field
|
||||
type="list"
|
||||
name="type"
|
||||
label="COM_COMPONENTBUILDER_REPOSITORY_TYPE_LABEL"
|
||||
description="COM_COMPONENTBUILDER_REPOSITORY_TYPE_DESCRIPTION"
|
||||
class="list_class"
|
||||
layout="joomla.form.field.list-fancy-select"
|
||||
multiple="false"
|
||||
filter="INT"
|
||||
required="true"
|
||||
validate="int">
|
||||
<!-- Option Set. -->
|
||||
<option value="">
|
||||
COM_COMPONENTBUILDER_REPOSITORY_SELECT_AN_OPTION</option>
|
||||
<option value="1">
|
||||
COM_COMPONENTBUILDER_REPOSITORY_GITEA</option>
|
||||
</field>
|
||||
<!-- Base Field. Type: Url. (joomla) -->
|
||||
<field
|
||||
type="url"
|
||||
name="base"
|
||||
label="COM_COMPONENTBUILDER_REPOSITORY_BASE_LABEL"
|
||||
size="70"
|
||||
maxlength="150"
|
||||
default="https://git.vdm.dev"
|
||||
description="COM_COMPONENTBUILDER_REPOSITORY_BASE_DESCRIPTION"
|
||||
class="text_area"
|
||||
required="true"
|
||||
filter="url"
|
||||
validated="url"
|
||||
scheme="http,https"
|
||||
message="COM_COMPONENTBUILDER_REPOSITORY_BASE_MESSAGE"
|
||||
hint="COM_COMPONENTBUILDER_REPOSITORY_BASE_HINT"
|
||||
autocomplete="on"
|
||||
showon="type:1"
|
||||
/>
|
||||
<!-- Guid Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="guid"
|
||||
label="COM_COMPONENTBUILDER_REPOSITORY_GUID_LABEL"
|
||||
size="40"
|
||||
maxlength="40"
|
||||
description="COM_COMPONENTBUILDER_REPOSITORY_GUID_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="true"
|
||||
filter="CMD"
|
||||
validate="guid"
|
||||
hint="COM_COMPONENTBUILDER_REPOSITORY_GUID_HINT"
|
||||
/>
|
||||
<!-- Access_repo Field. Type: Radio. (joomla) -->
|
||||
<field
|
||||
type="radio"
|
||||
name="access_repo"
|
||||
label="COM_COMPONENTBUILDER_REPOSITORY_ACCESS_REPO_LABEL"
|
||||
description="COM_COMPONENTBUILDER_REPOSITORY_ACCESS_REPO_DESCRIPTION"
|
||||
class="btn-group btn-group-yesno"
|
||||
default="">
|
||||
<!-- Option Set. -->
|
||||
<option value="">
|
||||
COM_COMPONENTBUILDER_REPOSITORY_GLOBAL</option>
|
||||
<option value="1">
|
||||
COM_COMPONENTBUILDER_REPOSITORY_OVERRIDE</option>
|
||||
</field>
|
||||
<!-- Write_branch Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="write_branch"
|
||||
label="COM_COMPONENTBUILDER_REPOSITORY_WRITE_BRANCH_LABEL"
|
||||
size="128"
|
||||
maxlength="50"
|
||||
description="COM_COMPONENTBUILDER_REPOSITORY_WRITE_BRANCH_DESCRIPTION"
|
||||
class="text_area"
|
||||
filter="STRING"
|
||||
message="COM_COMPONENTBUILDER_REPOSITORY_WRITE_BRANCH_MESSAGE"
|
||||
hint="COM_COMPONENTBUILDER_REPOSITORY_WRITE_BRANCH_HINT"
|
||||
/>
|
||||
<!-- Read_branch Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="read_branch"
|
||||
label="COM_COMPONENTBUILDER_REPOSITORY_READ_BRANCH_LABEL"
|
||||
size="128"
|
||||
maxlength="50"
|
||||
description="COM_COMPONENTBUILDER_REPOSITORY_READ_BRANCH_DESCRIPTION"
|
||||
class="text_area"
|
||||
filter="STRING"
|
||||
message="COM_COMPONENTBUILDER_REPOSITORY_READ_BRANCH_MESSAGE"
|
||||
hint="COM_COMPONENTBUILDER_REPOSITORY_READ_BRANCH_HINT"
|
||||
/>
|
||||
<!-- Token Field. Type: Password. (joomla) -->
|
||||
<field
|
||||
type="password"
|
||||
name="token"
|
||||
label="COM_COMPONENTBUILDER_REPOSITORY_TOKEN_LABEL"
|
||||
size="128"
|
||||
description="COM_COMPONENTBUILDER_REPOSITORY_TOKEN_DESCRIPTION"
|
||||
message="Error! Please add token here."
|
||||
class="text_area"
|
||||
filter="STRING"
|
||||
hint="COM_COMPONENTBUILDER_REPOSITORY_TOKEN_HINT"
|
||||
autocomplete="off"
|
||||
showon="type:1[AND]access_repo:1"
|
||||
/>
|
||||
<!-- Username Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="username"
|
||||
label="COM_COMPONENTBUILDER_REPOSITORY_USERNAME_LABEL"
|
||||
size="128"
|
||||
maxlength="50"
|
||||
description="COM_COMPONENTBUILDER_REPOSITORY_USERNAME_DESCRIPTION"
|
||||
class="text_area"
|
||||
filter="STRING"
|
||||
message="COM_COMPONENTBUILDER_REPOSITORY_USERNAME_MESSAGE"
|
||||
hint="COM_COMPONENTBUILDER_REPOSITORY_USERNAME_HINT"
|
||||
autocomplete="on"
|
||||
showon="type:1[AND]access_repo:1"
|
||||
/>
|
||||
</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 repository"
|
||||
translate_label="false"
|
||||
filter="rules"
|
||||
validate="rules"
|
||||
class="inputbox"
|
||||
component="com_componentbuilder"
|
||||
section="repository"
|
||||
/>
|
||||
</fieldset>
|
||||
</form>
|
@ -64,12 +64,6 @@ class ComponentbuilderModelJoomla_component extends AdminModel
|
||||
'author',
|
||||
'email',
|
||||
'website',
|
||||
'add_license',
|
||||
'license_type',
|
||||
'note_whmcs_lisencing_note',
|
||||
'whmcs_key',
|
||||
'whmcs_url',
|
||||
'whmcs_buy_link',
|
||||
'license',
|
||||
'bom',
|
||||
'image',
|
||||
@ -84,30 +78,6 @@ class ComponentbuilderModelJoomla_component extends AdminModel
|
||||
'not_required'
|
||||
)
|
||||
),
|
||||
'libs_helpers' => array(
|
||||
'fullwidth' => array(
|
||||
'creatuserhelper',
|
||||
'adduikit',
|
||||
'addfootable',
|
||||
'add_email_helper',
|
||||
'add_php_helper_both',
|
||||
'php_helper_both',
|
||||
'add_php_helper_admin',
|
||||
'php_helper_admin',
|
||||
'add_admin_event',
|
||||
'php_admin_event',
|
||||
'add_php_helper_site',
|
||||
'php_helper_site',
|
||||
'add_site_event',
|
||||
'php_site_event',
|
||||
'add_javascript',
|
||||
'javascript',
|
||||
'add_css_admin',
|
||||
'css_admin',
|
||||
'add_css_site',
|
||||
'css_site'
|
||||
)
|
||||
),
|
||||
'dynamic_integration' => array(
|
||||
'left' => array(
|
||||
'add_update_server',
|
||||
@ -137,6 +107,15 @@ class ComponentbuilderModelJoomla_component extends AdminModel
|
||||
'crowdin_account_api_key'
|
||||
)
|
||||
),
|
||||
'mysql' => array(
|
||||
'fullwidth' => array(
|
||||
'add_sql',
|
||||
'sql',
|
||||
'add_sql_uninstall',
|
||||
'sql_uninstall',
|
||||
'assets_table_fix'
|
||||
)
|
||||
),
|
||||
'dash_install' => array(
|
||||
'left' => array(
|
||||
'dashboard_type'
|
||||
@ -161,6 +140,30 @@ class ComponentbuilderModelJoomla_component extends AdminModel
|
||||
'php_method_install'
|
||||
)
|
||||
),
|
||||
'libs_helpers' => array(
|
||||
'fullwidth' => array(
|
||||
'creatuserhelper',
|
||||
'adduikit',
|
||||
'addfootable',
|
||||
'add_email_helper',
|
||||
'add_php_helper_both',
|
||||
'php_helper_both',
|
||||
'add_php_helper_admin',
|
||||
'php_helper_admin',
|
||||
'add_admin_event',
|
||||
'php_admin_event',
|
||||
'add_php_helper_site',
|
||||
'php_helper_site',
|
||||
'add_site_event',
|
||||
'php_site_event',
|
||||
'add_javascript',
|
||||
'javascript',
|
||||
'add_css_admin',
|
||||
'css_admin',
|
||||
'add_css_site',
|
||||
'css_site'
|
||||
)
|
||||
),
|
||||
'readme' => array(
|
||||
'left' => array(
|
||||
'addreadme',
|
||||
@ -170,15 +173,6 @@ class ComponentbuilderModelJoomla_component extends AdminModel
|
||||
'note_readme'
|
||||
)
|
||||
),
|
||||
'mysql' => array(
|
||||
'fullwidth' => array(
|
||||
'add_sql',
|
||||
'sql',
|
||||
'add_sql_uninstall',
|
||||
'sql_uninstall',
|
||||
'assets_table_fix'
|
||||
)
|
||||
),
|
||||
'dynamic_build' => array(
|
||||
'fullwidth' => array(
|
||||
'note_buildcomp_dynamic_mysql',
|
||||
@ -371,58 +365,22 @@ class ComponentbuilderModelJoomla_component extends AdminModel
|
||||
$item->metadata = $registry->toArray();
|
||||
}
|
||||
|
||||
if (!empty($item->php_site_event))
|
||||
if (!empty($item->sql_uninstall))
|
||||
{
|
||||
// base64 Decode php_site_event.
|
||||
$item->php_site_event = base64_decode($item->php_site_event);
|
||||
// base64 Decode sql_uninstall.
|
||||
$item->sql_uninstall = base64_decode($item->sql_uninstall);
|
||||
}
|
||||
|
||||
if (!empty($item->php_admin_event))
|
||||
if (!empty($item->php_postflight_update))
|
||||
{
|
||||
// base64 Decode php_admin_event.
|
||||
$item->php_admin_event = base64_decode($item->php_admin_event);
|
||||
// base64 Decode php_postflight_update.
|
||||
$item->php_postflight_update = base64_decode($item->php_postflight_update);
|
||||
}
|
||||
|
||||
if (!empty($item->php_preflight_install))
|
||||
if (!empty($item->css_site))
|
||||
{
|
||||
// base64 Decode php_preflight_install.
|
||||
$item->php_preflight_install = base64_decode($item->php_preflight_install);
|
||||
}
|
||||
|
||||
if (!empty($item->php_method_uninstall))
|
||||
{
|
||||
// base64 Decode php_method_uninstall.
|
||||
$item->php_method_uninstall = base64_decode($item->php_method_uninstall);
|
||||
}
|
||||
|
||||
if (!empty($item->css_admin))
|
||||
{
|
||||
// base64 Decode css_admin.
|
||||
$item->css_admin = base64_decode($item->css_admin);
|
||||
}
|
||||
|
||||
if (!empty($item->php_postflight_install))
|
||||
{
|
||||
// base64 Decode php_postflight_install.
|
||||
$item->php_postflight_install = base64_decode($item->php_postflight_install);
|
||||
}
|
||||
|
||||
if (!empty($item->sql))
|
||||
{
|
||||
// base64 Decode sql.
|
||||
$item->sql = base64_decode($item->sql);
|
||||
}
|
||||
|
||||
if (!empty($item->buildcompsql))
|
||||
{
|
||||
// base64 Decode buildcompsql.
|
||||
$item->buildcompsql = base64_decode($item->buildcompsql);
|
||||
}
|
||||
|
||||
if (!empty($item->php_helper_admin))
|
||||
{
|
||||
// base64 Decode php_helper_admin.
|
||||
$item->php_helper_admin = base64_decode($item->php_helper_admin);
|
||||
// base64 Decode css_site.
|
||||
$item->css_site = base64_decode($item->css_site);
|
||||
}
|
||||
|
||||
if (!empty($item->php_helper_site))
|
||||
@ -437,10 +395,28 @@ class ComponentbuilderModelJoomla_component extends AdminModel
|
||||
$item->javascript = base64_decode($item->javascript);
|
||||
}
|
||||
|
||||
if (!empty($item->css_site))
|
||||
if (!empty($item->php_method_install))
|
||||
{
|
||||
// base64 Decode css_site.
|
||||
$item->css_site = base64_decode($item->css_site);
|
||||
// base64 Decode php_method_install.
|
||||
$item->php_method_install = base64_decode($item->php_method_install);
|
||||
}
|
||||
|
||||
if (!empty($item->php_admin_event))
|
||||
{
|
||||
// base64 Decode php_admin_event.
|
||||
$item->php_admin_event = base64_decode($item->php_admin_event);
|
||||
}
|
||||
|
||||
if (!empty($item->php_site_event))
|
||||
{
|
||||
// base64 Decode php_site_event.
|
||||
$item->php_site_event = base64_decode($item->php_site_event);
|
||||
}
|
||||
|
||||
if (!empty($item->css_admin))
|
||||
{
|
||||
// base64 Decode css_admin.
|
||||
$item->css_admin = base64_decode($item->css_admin);
|
||||
}
|
||||
|
||||
if (!empty($item->php_preflight_update))
|
||||
@ -449,22 +425,34 @@ class ComponentbuilderModelJoomla_component extends AdminModel
|
||||
$item->php_preflight_update = base64_decode($item->php_preflight_update);
|
||||
}
|
||||
|
||||
if (!empty($item->php_postflight_update))
|
||||
if (!empty($item->php_preflight_install))
|
||||
{
|
||||
// base64 Decode php_postflight_update.
|
||||
$item->php_postflight_update = base64_decode($item->php_postflight_update);
|
||||
// base64 Decode php_preflight_install.
|
||||
$item->php_preflight_install = base64_decode($item->php_preflight_install);
|
||||
}
|
||||
|
||||
if (!empty($item->php_method_install))
|
||||
if (!empty($item->php_postflight_install))
|
||||
{
|
||||
// base64 Decode php_method_install.
|
||||
$item->php_method_install = base64_decode($item->php_method_install);
|
||||
// base64 Decode php_postflight_install.
|
||||
$item->php_postflight_install = base64_decode($item->php_postflight_install);
|
||||
}
|
||||
|
||||
if (!empty($item->sql_uninstall))
|
||||
if (!empty($item->php_method_uninstall))
|
||||
{
|
||||
// base64 Decode sql_uninstall.
|
||||
$item->sql_uninstall = base64_decode($item->sql_uninstall);
|
||||
// base64 Decode php_method_uninstall.
|
||||
$item->php_method_uninstall = base64_decode($item->php_method_uninstall);
|
||||
}
|
||||
|
||||
if (!empty($item->sql))
|
||||
{
|
||||
// base64 Decode sql.
|
||||
$item->sql = base64_decode($item->sql);
|
||||
}
|
||||
|
||||
if (!empty($item->buildcompsql))
|
||||
{
|
||||
// base64 Decode buildcompsql.
|
||||
$item->buildcompsql = base64_decode($item->buildcompsql);
|
||||
}
|
||||
|
||||
if (!empty($item->readme))
|
||||
@ -479,6 +467,12 @@ class ComponentbuilderModelJoomla_component extends AdminModel
|
||||
$item->php_helper_both = base64_decode($item->php_helper_both);
|
||||
}
|
||||
|
||||
if (!empty($item->php_helper_admin))
|
||||
{
|
||||
// base64 Decode php_helper_admin.
|
||||
$item->php_helper_admin = base64_decode($item->php_helper_admin);
|
||||
}
|
||||
|
||||
// Get the basic encryption.
|
||||
$basickey = ComponentbuilderHelper::getCryptKey('basic');
|
||||
// Get the encryption object.
|
||||
@ -490,12 +484,6 @@ class ComponentbuilderModelJoomla_component extends AdminModel
|
||||
$item->crowdin_username = rtrim($basic->decryptString($item->crowdin_username), "\0");
|
||||
}
|
||||
|
||||
if (!empty($item->whmcs_key) && $basickey && !is_numeric($item->whmcs_key) && $item->whmcs_key === base64_encode(base64_decode($item->whmcs_key, true)))
|
||||
{
|
||||
// basic decrypt data whmcs_key.
|
||||
$item->whmcs_key = rtrim($basic->decryptString($item->whmcs_key), "\0");
|
||||
}
|
||||
|
||||
if (!empty($item->export_key) && $basickey && !is_numeric($item->export_key) && $item->export_key === base64_encode(base64_decode($item->export_key, true)))
|
||||
{
|
||||
// basic decrypt data export_key.
|
||||
@ -1449,58 +1437,22 @@ class ComponentbuilderModelJoomla_component extends AdminModel
|
||||
$data['addcontributors'] = '';
|
||||
}
|
||||
|
||||
// Set the php_site_event string to base64 string.
|
||||
if (isset($data['php_site_event']))
|
||||
// Set the sql_uninstall string to base64 string.
|
||||
if (isset($data['sql_uninstall']))
|
||||
{
|
||||
$data['php_site_event'] = base64_encode($data['php_site_event']);
|
||||
$data['sql_uninstall'] = base64_encode($data['sql_uninstall']);
|
||||
}
|
||||
|
||||
// Set the php_admin_event string to base64 string.
|
||||
if (isset($data['php_admin_event']))
|
||||
// Set the php_postflight_update string to base64 string.
|
||||
if (isset($data['php_postflight_update']))
|
||||
{
|
||||
$data['php_admin_event'] = base64_encode($data['php_admin_event']);
|
||||
$data['php_postflight_update'] = base64_encode($data['php_postflight_update']);
|
||||
}
|
||||
|
||||
// Set the php_preflight_install string to base64 string.
|
||||
if (isset($data['php_preflight_install']))
|
||||
// Set the css_site string to base64 string.
|
||||
if (isset($data['css_site']))
|
||||
{
|
||||
$data['php_preflight_install'] = base64_encode($data['php_preflight_install']);
|
||||
}
|
||||
|
||||
// Set the php_method_uninstall string to base64 string.
|
||||
if (isset($data['php_method_uninstall']))
|
||||
{
|
||||
$data['php_method_uninstall'] = base64_encode($data['php_method_uninstall']);
|
||||
}
|
||||
|
||||
// Set the css_admin string to base64 string.
|
||||
if (isset($data['css_admin']))
|
||||
{
|
||||
$data['css_admin'] = base64_encode($data['css_admin']);
|
||||
}
|
||||
|
||||
// Set the php_postflight_install string to base64 string.
|
||||
if (isset($data['php_postflight_install']))
|
||||
{
|
||||
$data['php_postflight_install'] = base64_encode($data['php_postflight_install']);
|
||||
}
|
||||
|
||||
// Set the sql string to base64 string.
|
||||
if (isset($data['sql']))
|
||||
{
|
||||
$data['sql'] = base64_encode($data['sql']);
|
||||
}
|
||||
|
||||
// Set the buildcompsql string to base64 string.
|
||||
if (isset($data['buildcompsql']))
|
||||
{
|
||||
$data['buildcompsql'] = base64_encode($data['buildcompsql']);
|
||||
}
|
||||
|
||||
// Set the php_helper_admin string to base64 string.
|
||||
if (isset($data['php_helper_admin']))
|
||||
{
|
||||
$data['php_helper_admin'] = base64_encode($data['php_helper_admin']);
|
||||
$data['css_site'] = base64_encode($data['css_site']);
|
||||
}
|
||||
|
||||
// Set the php_helper_site string to base64 string.
|
||||
@ -1515,10 +1467,28 @@ class ComponentbuilderModelJoomla_component extends AdminModel
|
||||
$data['javascript'] = base64_encode($data['javascript']);
|
||||
}
|
||||
|
||||
// Set the css_site string to base64 string.
|
||||
if (isset($data['css_site']))
|
||||
// Set the php_method_install string to base64 string.
|
||||
if (isset($data['php_method_install']))
|
||||
{
|
||||
$data['css_site'] = base64_encode($data['css_site']);
|
||||
$data['php_method_install'] = base64_encode($data['php_method_install']);
|
||||
}
|
||||
|
||||
// Set the php_admin_event string to base64 string.
|
||||
if (isset($data['php_admin_event']))
|
||||
{
|
||||
$data['php_admin_event'] = base64_encode($data['php_admin_event']);
|
||||
}
|
||||
|
||||
// Set the php_site_event string to base64 string.
|
||||
if (isset($data['php_site_event']))
|
||||
{
|
||||
$data['php_site_event'] = base64_encode($data['php_site_event']);
|
||||
}
|
||||
|
||||
// Set the css_admin string to base64 string.
|
||||
if (isset($data['css_admin']))
|
||||
{
|
||||
$data['css_admin'] = base64_encode($data['css_admin']);
|
||||
}
|
||||
|
||||
// Set the php_preflight_update string to base64 string.
|
||||
@ -1527,22 +1497,34 @@ class ComponentbuilderModelJoomla_component extends AdminModel
|
||||
$data['php_preflight_update'] = base64_encode($data['php_preflight_update']);
|
||||
}
|
||||
|
||||
// Set the php_postflight_update string to base64 string.
|
||||
if (isset($data['php_postflight_update']))
|
||||
// Set the php_preflight_install string to base64 string.
|
||||
if (isset($data['php_preflight_install']))
|
||||
{
|
||||
$data['php_postflight_update'] = base64_encode($data['php_postflight_update']);
|
||||
$data['php_preflight_install'] = base64_encode($data['php_preflight_install']);
|
||||
}
|
||||
|
||||
// Set the php_method_install string to base64 string.
|
||||
if (isset($data['php_method_install']))
|
||||
// Set the php_postflight_install string to base64 string.
|
||||
if (isset($data['php_postflight_install']))
|
||||
{
|
||||
$data['php_method_install'] = base64_encode($data['php_method_install']);
|
||||
$data['php_postflight_install'] = base64_encode($data['php_postflight_install']);
|
||||
}
|
||||
|
||||
// Set the sql_uninstall string to base64 string.
|
||||
if (isset($data['sql_uninstall']))
|
||||
// Set the php_method_uninstall string to base64 string.
|
||||
if (isset($data['php_method_uninstall']))
|
||||
{
|
||||
$data['sql_uninstall'] = base64_encode($data['sql_uninstall']);
|
||||
$data['php_method_uninstall'] = base64_encode($data['php_method_uninstall']);
|
||||
}
|
||||
|
||||
// Set the sql string to base64 string.
|
||||
if (isset($data['sql']))
|
||||
{
|
||||
$data['sql'] = base64_encode($data['sql']);
|
||||
}
|
||||
|
||||
// Set the buildcompsql string to base64 string.
|
||||
if (isset($data['buildcompsql']))
|
||||
{
|
||||
$data['buildcompsql'] = base64_encode($data['buildcompsql']);
|
||||
}
|
||||
|
||||
// Set the readme string to base64 string.
|
||||
@ -1557,6 +1539,12 @@ class ComponentbuilderModelJoomla_component extends AdminModel
|
||||
$data['php_helper_both'] = base64_encode($data['php_helper_both']);
|
||||
}
|
||||
|
||||
// Set the php_helper_admin string to base64 string.
|
||||
if (isset($data['php_helper_admin']))
|
||||
{
|
||||
$data['php_helper_admin'] = base64_encode($data['php_helper_admin']);
|
||||
}
|
||||
|
||||
// Get the basic encryption key.
|
||||
$basickey = ComponentbuilderHelper::getCryptKey('basic');
|
||||
// Get the encryption object
|
||||
@ -1568,12 +1556,6 @@ class ComponentbuilderModelJoomla_component extends AdminModel
|
||||
$data['crowdin_username'] = $basic->encryptString($data['crowdin_username']);
|
||||
}
|
||||
|
||||
// Encrypt data whmcs_key.
|
||||
if (isset($data['whmcs_key']) && $basickey)
|
||||
{
|
||||
$data['whmcs_key'] = $basic->encryptString($data['whmcs_key']);
|
||||
}
|
||||
|
||||
// Encrypt data export_key.
|
||||
if (isset($data['export_key']) && $basickey)
|
||||
{
|
||||
|
@ -2694,48 +2694,41 @@ class ComponentbuilderModelJoomla_components extends ListModel
|
||||
continue;
|
||||
}
|
||||
|
||||
// decode php_site_event
|
||||
$item->php_site_event = base64_decode($item->php_site_event);
|
||||
// decode sql_uninstall
|
||||
$item->sql_uninstall = base64_decode($item->sql_uninstall);
|
||||
// decode php_postflight_update
|
||||
$item->php_postflight_update = base64_decode($item->php_postflight_update);
|
||||
// decode css_site
|
||||
$item->css_site = base64_decode($item->css_site);
|
||||
// decode php_helper_site
|
||||
$item->php_helper_site = base64_decode($item->php_helper_site);
|
||||
// decode javascript
|
||||
$item->javascript = base64_decode($item->javascript);
|
||||
// decode php_method_install
|
||||
$item->php_method_install = base64_decode($item->php_method_install);
|
||||
// decode php_admin_event
|
||||
$item->php_admin_event = base64_decode($item->php_admin_event);
|
||||
// decode php_site_event
|
||||
$item->php_site_event = base64_decode($item->php_site_event);
|
||||
// decode css_admin
|
||||
$item->css_admin = base64_decode($item->css_admin);
|
||||
// decode php_preflight_update
|
||||
$item->php_preflight_update = base64_decode($item->php_preflight_update);
|
||||
// decode php_preflight_install
|
||||
$item->php_preflight_install = base64_decode($item->php_preflight_install);
|
||||
// decode php_postflight_install
|
||||
$item->php_postflight_install = base64_decode($item->php_postflight_install);
|
||||
// decode php_method_uninstall
|
||||
$item->php_method_uninstall = base64_decode($item->php_method_uninstall);
|
||||
// decode sql
|
||||
$item->sql = base64_decode($item->sql);
|
||||
if ($basickey && !is_numeric($item->crowdin_username) && $item->crowdin_username === base64_encode(base64_decode($item->crowdin_username, true)))
|
||||
{
|
||||
// decrypt crowdin_username
|
||||
$item->crowdin_username = $basic->decryptString($item->crowdin_username);
|
||||
}
|
||||
// decode php_preflight_install
|
||||
$item->php_preflight_install = base64_decode($item->php_preflight_install);
|
||||
// decode php_method_uninstall
|
||||
$item->php_method_uninstall = base64_decode($item->php_method_uninstall);
|
||||
// decode css_admin
|
||||
$item->css_admin = base64_decode($item->css_admin);
|
||||
// decode php_postflight_install
|
||||
$item->php_postflight_install = base64_decode($item->php_postflight_install);
|
||||
// decode sql
|
||||
$item->sql = base64_decode($item->sql);
|
||||
// decode buildcompsql
|
||||
$item->buildcompsql = base64_decode($item->buildcompsql);
|
||||
// decode php_helper_admin
|
||||
$item->php_helper_admin = base64_decode($item->php_helper_admin);
|
||||
// decode php_helper_site
|
||||
$item->php_helper_site = base64_decode($item->php_helper_site);
|
||||
if ($basickey && !is_numeric($item->whmcs_key) && $item->whmcs_key === base64_encode(base64_decode($item->whmcs_key, true)))
|
||||
{
|
||||
// decrypt whmcs_key
|
||||
$item->whmcs_key = $basic->decryptString($item->whmcs_key);
|
||||
}
|
||||
// decode javascript
|
||||
$item->javascript = base64_decode($item->javascript);
|
||||
// decode css_site
|
||||
$item->css_site = base64_decode($item->css_site);
|
||||
// decode php_preflight_update
|
||||
$item->php_preflight_update = base64_decode($item->php_preflight_update);
|
||||
// decode php_postflight_update
|
||||
$item->php_postflight_update = base64_decode($item->php_postflight_update);
|
||||
// decode php_method_install
|
||||
$item->php_method_install = base64_decode($item->php_method_install);
|
||||
// decode sql_uninstall
|
||||
$item->sql_uninstall = base64_decode($item->sql_uninstall);
|
||||
if ($basickey && !is_numeric($item->export_key) && $item->export_key === base64_encode(base64_decode($item->export_key, true)))
|
||||
{
|
||||
// decrypt export_key
|
||||
@ -2748,13 +2741,15 @@ class ComponentbuilderModelJoomla_components extends ListModel
|
||||
// decrypt crowdin_project_api_key
|
||||
$item->crowdin_project_api_key = $basic->decryptString($item->crowdin_project_api_key);
|
||||
}
|
||||
// decode php_helper_both
|
||||
$item->php_helper_both = base64_decode($item->php_helper_both);
|
||||
if ($basickey && !is_numeric($item->crowdin_account_api_key) && $item->crowdin_account_api_key === base64_encode(base64_decode($item->crowdin_account_api_key, true)))
|
||||
{
|
||||
// decrypt crowdin_account_api_key
|
||||
$item->crowdin_account_api_key = $basic->decryptString($item->crowdin_account_api_key);
|
||||
}
|
||||
// decode php_helper_both
|
||||
$item->php_helper_both = base64_decode($item->php_helper_both);
|
||||
// decode php_helper_admin
|
||||
$item->php_helper_admin = base64_decode($item->php_helper_admin);
|
||||
// unset the values we don't want exported.
|
||||
unset($item->asset_id);
|
||||
unset($item->checked_out);
|
||||
|
@ -19,7 +19,6 @@ use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
use Joomla\CMS\Helper\TagsHelper;
|
||||
use VDM\Joomla\Utilities\Component\Helper as JCBHelper;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\FilterHelper as JCBFilterHelper;
|
||||
use VDM\Joomla\Utilities\FormHelper as JCBFormHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper;
|
||||
@ -68,7 +67,7 @@ class ComponentbuilderModelPowers extends ListModel
|
||||
// load form from the parent class
|
||||
$form = parent::getFilterForm($data, $loadData);
|
||||
|
||||
// Create the "admin_view" filter
|
||||
// Create the "namegroup" filter
|
||||
$attributes = array(
|
||||
'name' => 'namegroup',
|
||||
'type' => 'list',
|
||||
@ -77,7 +76,7 @@ class ComponentbuilderModelPowers extends ListModel
|
||||
$options = array(
|
||||
'' => '- ' . Text::_('COM_COMPONENTBUILDER_NO_NAMESPACE_FOUND') . ' -'
|
||||
);
|
||||
// check if we have namespace (and limit to an extension if it is set)
|
||||
// check if we have namespace
|
||||
if (($namespaces = JCBFilterHelper::namespaces()) !== null)
|
||||
{
|
||||
$options = array(
|
||||
@ -95,54 +94,33 @@ class ComponentbuilderModelPowers extends ListModel
|
||||
);
|
||||
array_push($this->filter_fields, 'namegroup');
|
||||
|
||||
// get the component params
|
||||
$params = JCBHelper::getParams();
|
||||
$activate = $params->get('super_powers_repositories', 0);
|
||||
if ($activate == 1)
|
||||
// Create the "approved_paths" filter
|
||||
$attributes = array(
|
||||
'name' => 'approved_paths',
|
||||
'type' => 'list',
|
||||
'onchange' => 'this.form.submit();',
|
||||
);
|
||||
$options = array(
|
||||
'' => '- ' . Text::_('COM_COMPONENTBUILDER_NO_PATHS_FOUND') . ' -'
|
||||
);
|
||||
// check if we have approved_paths = 1
|
||||
if (($approvedpaths = JCBFilterHelper::repositories(1)) !== null)
|
||||
{
|
||||
$subform = $params->get('approved_paths', null);
|
||||
|
||||
// create approved paths filter
|
||||
$attributes = array(
|
||||
'name' => 'approved_paths',
|
||||
'type' => 'list',
|
||||
'onchange' => 'this.form.submit();',
|
||||
);
|
||||
$options = array(
|
||||
'' => '- ' . Text::_('COM_COMPONENTBUILDER_NO_PATHS_FOUND') . ' -'
|
||||
'' => '- ' . Text::_('COM_COMPONENTBUILDER_SELECT_APPROVED_PATH') . ' -'
|
||||
);
|
||||
|
||||
// add the paths found in global settings
|
||||
if (is_object($subform))
|
||||
{
|
||||
$core = $params->get('super_powers_core', 'joomla/super-powers');
|
||||
|
||||
$options = array(
|
||||
'' => '- ' . Text::_('COM_COMPONENTBUILDER_SELECT_APPROVED_PATH') . ' -',
|
||||
$core => $core
|
||||
);
|
||||
|
||||
foreach ($subform as $value)
|
||||
{
|
||||
if (isset($value->owner) && strlen($value->owner) > 1 &&
|
||||
isset($value->repo) && strlen($value->repo) > 1)
|
||||
{
|
||||
$value = trim($value->owner) . '/' . trim($value->repo);
|
||||
|
||||
$options[$value] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$form->setField(JCBFormHelper::xml($attributes, $options), 'filter');
|
||||
$form->setValue(
|
||||
'approved_paths',
|
||||
'filter',
|
||||
$this->state->get("filter.approved_paths")
|
||||
);
|
||||
array_push($this->filter_fields, 'approved_paths');
|
||||
// make sure we do not lose the key values in normal merge
|
||||
$options = $options + $approvedpaths;
|
||||
}
|
||||
|
||||
$form->setField(JCBFormHelper::xml($attributes, $options),'filter');
|
||||
$form->setValue(
|
||||
'approved_paths',
|
||||
'filter',
|
||||
$this->state->get("filter.approved_paths")
|
||||
);
|
||||
array_push($this->filter_fields, 'approved_paths');
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
464
admin/models/repositories.php
Normal file
464
admin/models/repositories.php
Normal file
@ -0,0 +1,464 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* Repositories List Model
|
||||
*/
|
||||
class ComponentbuilderModelRepositories 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.organisation','organisation',
|
||||
'a.repository','repository',
|
||||
'a.target','target',
|
||||
'a.base','base',
|
||||
'a.type','type'
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
$organisation = $this->getUserStateFromRequest($this->context . '.filter.organisation', 'filter_organisation');
|
||||
if ($formSubmited)
|
||||
{
|
||||
$organisation = $app->input->post->get('organisation');
|
||||
$this->setState('filter.organisation', $organisation);
|
||||
}
|
||||
|
||||
$repository = $this->getUserStateFromRequest($this->context . '.filter.repository', 'filter_repository');
|
||||
if ($formSubmited)
|
||||
{
|
||||
$repository = $app->input->post->get('repository');
|
||||
$this->setState('filter.repository', $repository);
|
||||
}
|
||||
|
||||
$target = $this->getUserStateFromRequest($this->context . '.filter.target', 'filter_target');
|
||||
if ($formSubmited)
|
||||
{
|
||||
$target = $app->input->post->get('target');
|
||||
$this->setState('filter.target', $target);
|
||||
}
|
||||
|
||||
$base = $this->getUserStateFromRequest($this->context . '.filter.base', 'filter_base');
|
||||
if ($formSubmited)
|
||||
{
|
||||
$base = $app->input->post->get('base');
|
||||
$this->setState('filter.base', $base);
|
||||
}
|
||||
|
||||
$type = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type');
|
||||
if ($formSubmited)
|
||||
{
|
||||
$type = $app->input->post->get('type');
|
||||
$this->setState('filter.type', $type);
|
||||
}
|
||||
|
||||
// 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('repository.access', 'com_componentbuilder.repository.' . (int) $item->id) && $user->authorise('repository.access', 'com_componentbuilder'));
|
||||
if (!$access)
|
||||
{
|
||||
unset($items[$nr]);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// set selection value to a translatable value
|
||||
if (UtilitiesArrayHelper::check($items))
|
||||
{
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// convert target
|
||||
$item->target = $this->selectionTranslation($item->target, 'target');
|
||||
// convert type
|
||||
$item->type = $this->selectionTranslation($item->type, 'type');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// return items
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to convert selection values to translatable string.
|
||||
*
|
||||
* @return string The translatable string.
|
||||
*/
|
||||
public function selectionTranslation($value,$name)
|
||||
{
|
||||
// Array of target language strings
|
||||
if ($name === 'target')
|
||||
{
|
||||
$targetArray = array(
|
||||
0 => 'COM_COMPONENTBUILDER_REPOSITORY_SELECT_AN_OPTION',
|
||||
1 => 'COM_COMPONENTBUILDER_REPOSITORY_SUPER_POWER',
|
||||
2 => 'COM_COMPONENTBUILDER_REPOSITORY_JOOMLA_POWER'
|
||||
);
|
||||
// Now check if value is found in this array
|
||||
if (isset($targetArray[$value]) && StringHelper::check($targetArray[$value]))
|
||||
{
|
||||
return $targetArray[$value];
|
||||
}
|
||||
}
|
||||
// Array of type language strings
|
||||
if ($name === 'type')
|
||||
{
|
||||
$typeArray = array(
|
||||
0 => 'COM_COMPONENTBUILDER_REPOSITORY_SELECT_AN_OPTION',
|
||||
1 => 'COM_COMPONENTBUILDER_REPOSITORY_GITEA'
|
||||
);
|
||||
// Now check if value is found in this array
|
||||
if (isset($typeArray[$value]) && StringHelper::check($typeArray[$value]))
|
||||
{
|
||||
return $typeArray[$value];
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_repository', '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.organisation LIKE '.$search.' OR a.repository LIKE '.$search.' OR a.target LIKE '.$search.' OR a.type LIKE '.$search.' OR a.base LIKE '.$search.' OR a.guid LIKE '.$search.' OR a.username LIKE '.$search.')');
|
||||
}
|
||||
}
|
||||
|
||||
// Filter by Organisation.
|
||||
$_organisation = $this->getState('filter.organisation');
|
||||
if (is_numeric($_organisation))
|
||||
{
|
||||
if (is_float($_organisation))
|
||||
{
|
||||
$query->where('a.organisation = ' . (float) $_organisation);
|
||||
}
|
||||
else
|
||||
{
|
||||
$query->where('a.organisation = ' . (int) $_organisation);
|
||||
}
|
||||
}
|
||||
elseif (StringHelper::check($_organisation))
|
||||
{
|
||||
$query->where('a.organisation = ' . $db->quote($db->escape($_organisation)));
|
||||
}
|
||||
// Filter by Repository.
|
||||
$_repository = $this->getState('filter.repository');
|
||||
if (is_numeric($_repository))
|
||||
{
|
||||
if (is_float($_repository))
|
||||
{
|
||||
$query->where('a.repository = ' . (float) $_repository);
|
||||
}
|
||||
else
|
||||
{
|
||||
$query->where('a.repository = ' . (int) $_repository);
|
||||
}
|
||||
}
|
||||
elseif (StringHelper::check($_repository))
|
||||
{
|
||||
$query->where('a.repository = ' . $db->quote($db->escape($_repository)));
|
||||
}
|
||||
// Filter by Target.
|
||||
$_target = $this->getState('filter.target');
|
||||
if (is_numeric($_target))
|
||||
{
|
||||
if (is_float($_target))
|
||||
{
|
||||
$query->where('a.target = ' . (float) $_target);
|
||||
}
|
||||
else
|
||||
{
|
||||
$query->where('a.target = ' . (int) $_target);
|
||||
}
|
||||
}
|
||||
elseif (StringHelper::check($_target))
|
||||
{
|
||||
$query->where('a.target = ' . $db->quote($db->escape($_target)));
|
||||
}
|
||||
// Filter by Base.
|
||||
$_base = $this->getState('filter.base');
|
||||
if (is_numeric($_base))
|
||||
{
|
||||
if (is_float($_base))
|
||||
{
|
||||
$query->where('a.base = ' . (float) $_base);
|
||||
}
|
||||
else
|
||||
{
|
||||
$query->where('a.base = ' . (int) $_base);
|
||||
}
|
||||
}
|
||||
elseif (StringHelper::check($_base))
|
||||
{
|
||||
$query->where('a.base = ' . $db->quote($db->escape($_base)));
|
||||
}
|
||||
|
||||
// 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.organisation');
|
||||
$id .= ':' . $this->getState('filter.repository');
|
||||
$id .= ':' . $this->getState('filter.target');
|
||||
$id .= ':' . $this->getState('filter.base');
|
||||
$id .= ':' . $this->getState('filter.type');
|
||||
|
||||
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_repository'));
|
||||
// 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_repository'))->set($fields)->where($conditions);
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->execute();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
916
admin/models/repository.php
Normal file
916
admin/models/repository.php
Normal file
@ -0,0 +1,916 @@
|
||||
<?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 Repository Admin Model
|
||||
*/
|
||||
class ComponentbuilderModelRepository extends AdminModel
|
||||
{
|
||||
/**
|
||||
* The tab layout fields array.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $tabLayoutFields = array(
|
||||
'details' => array(
|
||||
'left' => array(
|
||||
'type',
|
||||
'base',
|
||||
'username',
|
||||
'token'
|
||||
),
|
||||
'right' => array(
|
||||
'organisation',
|
||||
'repository',
|
||||
'read_branch',
|
||||
'write_branch'
|
||||
),
|
||||
'above' => array(
|
||||
'system_name',
|
||||
'target',
|
||||
'access_repo'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* @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.repository';
|
||||
|
||||
/**
|
||||
* 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 = 'repository', $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();
|
||||
}
|
||||
}
|
||||
|
||||
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.repository', 'repository', $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('repository.edit.state', 'com_componentbuilder.repository.' . (int) $id))
|
||||
|| ($id == 0 && !$user->authorise('repository.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('repository.edit.created_by', 'com_componentbuilder.repository.' . (int) $id))
|
||||
|| ($id == 0 && !$user->authorise('repository.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('repository.edit.created', 'com_componentbuilder.repository.' . (int) $id))
|
||||
|| ($id == 0 && !$user->authorise('repository.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/repository.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('repository.delete', 'com_componentbuilder.repository.' . (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('repository.edit.state', 'com_componentbuilder.repository.' . (int) $recordId);
|
||||
if (!$permission && !is_null($permission))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// In the absence of better information, revert to the component permissions.
|
||||
return $user->authorise('repository.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('repository.edit', 'com_componentbuilder.repository.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('repository.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_repository'));
|
||||
$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.repository.data', []);
|
||||
|
||||
if (empty($data))
|
||||
{
|
||||
$data = $this->getItem();
|
||||
// run the perprocess of the data
|
||||
$this->preprocessData('com_componentbuilder.repository', $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('repository');
|
||||
$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('repository');
|
||||
}
|
||||
|
||||
if (!$this->canDo->get('repository.create') && !$this->canDo->get('repository.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('repository.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('repository.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('repository');
|
||||
}
|
||||
|
||||
if (!$this->canDo->get('repository.edit') && !$this->canDo->get('repository.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('repository.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('repository.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('repository', $data['id'], 'id', 'guid');
|
||||
}
|
||||
|
||||
// Set the GUID if empty or not valid
|
||||
while (!GuidHelper::valid($data['guid'], "repository", $data['id']))
|
||||
{
|
||||
// must always be set
|
||||
$data['guid'] = (string) GuidHelper::get();
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user