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:
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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user