2017-03-27 12:38:51 +00:00
|
|
|
<?php
|
2021-03-05 03:08:47 +00:00
|
|
|
/**
|
|
|
|
* @package Joomla.Component.Builder
|
|
|
|
*
|
|
|
|
* @created 30th April, 2015
|
2022-07-09 15:45:08 +00:00
|
|
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
|
|
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
2021-03-05 03:08:47 +00:00
|
|
|
* @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');
|
|
|
|
|
2024-03-02 20:10:30 +00:00
|
|
|
use Joomla\CMS\Factory;
|
|
|
|
use Joomla\CMS\Language\Text;
|
|
|
|
use Joomla\CMS\Form\FormHelper;
|
2022-05-25 08:30:55 +00:00
|
|
|
use Joomla\CMS\MVC\View\HtmlView;
|
2024-03-02 20:10:30 +00:00
|
|
|
use Joomla\CMS\Toolbar\ToolbarHelper;
|
|
|
|
use Joomla\CMS\Component\ComponentHelper;
|
|
|
|
use Joomla\CMS\HTML\HTMLHelper as Html;
|
|
|
|
use VDM\Joomla\Utilities\FormHelper as UtilitiesFormHelper;
|
2023-10-18 07:26:30 +00:00
|
|
|
use VDM\Joomla\Utilities\ArrayHelper;
|
|
|
|
use VDM\Joomla\Utilities\StringHelper;
|
2022-05-25 08:30:55 +00:00
|
|
|
|
2021-03-05 03:08:47 +00:00
|
|
|
/**
|
2022-05-25 08:30:55 +00:00
|
|
|
* Componentbuilder Import_joomla_components Html View
|
2021-03-05 03:08:47 +00:00
|
|
|
*/
|
2022-05-25 08:30:55 +00:00
|
|
|
class ComponentbuilderViewImport_joomla_components extends HtmlView
|
2017-03-27 12:38:51 +00:00
|
|
|
{
|
|
|
|
protected $headerList;
|
|
|
|
protected $hasPackage = false;
|
|
|
|
protected $headers;
|
|
|
|
protected $hasHeader = 0;
|
|
|
|
protected $dataType;
|
2017-03-30 21:19:12 +00:00
|
|
|
protected $packageInfo;
|
|
|
|
protected $formPackage;
|
2018-03-21 02:45:51 +00:00
|
|
|
protected $vdmPackages = false;
|
2018-05-03 14:04:47 +00:00
|
|
|
protected $directories = array();
|
2017-03-28 14:57:59 +00:00
|
|
|
|
2017-03-27 12:38:51 +00:00
|
|
|
public function display($tpl = null)
|
|
|
|
{
|
|
|
|
if ($this->getLayout() !== 'modal')
|
|
|
|
{
|
|
|
|
// Include helper submenu
|
|
|
|
ComponentbuilderHelper::addSubmenu('import');
|
|
|
|
}
|
2018-05-01 22:17:38 +00:00
|
|
|
// get component params
|
2024-03-02 20:10:30 +00:00
|
|
|
$this->params = ComponentHelper::getParams('com_componentbuilder');
|
2017-03-27 12:38:51 +00:00
|
|
|
|
2024-03-02 20:10:30 +00:00
|
|
|
$paths = new \stdClass;
|
2017-03-27 12:38:51 +00:00
|
|
|
$paths->first = '';
|
|
|
|
$state = $this->get('state');
|
|
|
|
|
|
|
|
$this->paths = &$paths;
|
|
|
|
$this->state = &$state;
|
|
|
|
// get global action permissions
|
|
|
|
$this->canDo = ComponentbuilderHelper::getActions('import');
|
2018-05-04 20:27:49 +00:00
|
|
|
// load the application
|
2024-03-02 20:10:30 +00:00
|
|
|
$this->app = Factory::getApplication();
|
2017-03-27 12:38:51 +00:00
|
|
|
|
|
|
|
// We don't need toolbar in the modal window.
|
|
|
|
if ($this->getLayout() !== 'modal')
|
|
|
|
{
|
|
|
|
$this->addToolbar();
|
|
|
|
$this->sidebar = JHtmlSidebar::render();
|
2018-05-04 20:27:49 +00:00
|
|
|
// add title to the page
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_JCB_PACKAGE_IMPORT'), 'upload');
|
2018-05-04 20:27:49 +00:00
|
|
|
// add refesh button.
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::custom('joomla_component.refresh', 'refresh', '', 'COM_COMPONENTBUILDER_REFRESH', false);
|
2017-03-27 12:38:51 +00:00
|
|
|
}
|
|
|
|
// get the session object
|
2024-03-02 20:10:30 +00:00
|
|
|
$session = Factory::getSession();
|
2017-03-27 12:38:51 +00:00
|
|
|
// check if it has package
|
2018-03-24 01:36:07 +00:00
|
|
|
$this->hasPackage = $session->get('hasPackage', false);
|
|
|
|
$this->dataType = $session->get('dataType', false);
|
|
|
|
if (!$this->dataType)
|
2017-03-27 12:38:51 +00:00
|
|
|
{
|
|
|
|
$this->dataType = $session->get('dataType_VDM_IMPORTINTO', null);
|
|
|
|
}
|
2018-05-03 14:04:47 +00:00
|
|
|
|
|
|
|
// get the management input from global settings
|
|
|
|
$manageDirectories = $this->params->get('manage_jcb_package_directories', 2);
|
|
|
|
if ($manageDirectories == 2)
|
|
|
|
{
|
2022-06-02 12:05:34 +00:00
|
|
|
$this->directories = array('vdm', 'jcb');
|
2018-05-03 14:04:47 +00:00
|
|
|
}
|
|
|
|
elseif ($manageDirectories == 1)
|
|
|
|
{
|
|
|
|
$this->directories = (array) $this->params->get('jcb_package_directories');
|
|
|
|
}
|
|
|
|
|
2017-03-28 14:57:59 +00:00
|
|
|
// set form only if smart package
|
|
|
|
if ($this->dataType === 'smart_package')
|
|
|
|
{
|
2017-03-30 21:19:12 +00:00
|
|
|
$this->packageInfo = json_decode($session->get('smart_package_info', false), true);
|
2018-05-03 14:04:47 +00:00
|
|
|
|
2018-03-21 02:45:51 +00:00
|
|
|
// add the form class
|
|
|
|
jimport('joomla.form.form');
|
2018-05-03 14:04:47 +00:00
|
|
|
|
2018-03-21 02:45:51 +00:00
|
|
|
// load the forms
|
|
|
|
$this->formPackage = $this->_getForm($this->dataType);
|
|
|
|
$this->vdmPackages = $this->_getForm('vdm_package');
|
2018-05-01 22:17:38 +00:00
|
|
|
$this->jcbPackages = $this->_getForm('jcb_package');
|
2017-03-28 14:57:59 +00:00
|
|
|
}
|
2017-10-14 17:18:29 +00:00
|
|
|
|
|
|
|
// Check for errors.
|
|
|
|
if (count($errors = $this->get('Errors')))
|
|
|
|
{
|
|
|
|
throw new Exception(implode("\n", $errors), 500);
|
|
|
|
}
|
|
|
|
|
2018-05-01 22:17:38 +00:00
|
|
|
// set the document
|
|
|
|
$this->setDocument();
|
|
|
|
|
2017-03-27 12:38:51 +00:00
|
|
|
// Display the template
|
|
|
|
parent::display($tpl);
|
|
|
|
}
|
|
|
|
|
2018-05-01 22:17:38 +00:00
|
|
|
/**
|
|
|
|
* Prepares the document
|
|
|
|
*/
|
|
|
|
protected function setDocument()
|
|
|
|
{
|
|
|
|
// always make sure jquery is loaded.
|
2024-03-02 20:10:30 +00:00
|
|
|
Html::_('jquery.framework');
|
2018-05-01 22:17:38 +00:00
|
|
|
|
|
|
|
// Add the JavaScript for JStore
|
2024-03-02 20:10:30 +00:00
|
|
|
Html::_('script', 'media/com_componentbuilder/js/jquery.json.min.js', ['version' => 'auto']);
|
|
|
|
Html::_('script', 'media/com_componentbuilder/js/jstorage.min.js', ['version' => 'auto']);
|
|
|
|
Html::_('script', 'media/com_componentbuilder/js/strtotime.js', ['version' => 'auto']);
|
2018-05-01 22:17:38 +00:00
|
|
|
// add marked library
|
2024-03-02 20:10:30 +00:00
|
|
|
Html::_('script', "media/com_componentbuilder/js/marked.js", ['version' => 'auto']);
|
2018-05-01 22:17:38 +00:00
|
|
|
// check if we should use browser storage
|
|
|
|
$setBrowserStorage = $this->params->get('set_browser_storage', null);
|
|
|
|
if ($setBrowserStorage)
|
|
|
|
{
|
|
|
|
// check what (Time To Live) show we use
|
|
|
|
$storageTimeToLive = $this->params->get('storage_time_to_live', 'global');
|
|
|
|
if ('global' == $storageTimeToLive)
|
|
|
|
{
|
|
|
|
// use the global session time
|
2024-03-02 20:10:30 +00:00
|
|
|
$session = Factory::getSession();
|
2018-05-01 22:17:38 +00:00
|
|
|
// must have itin milliseconds
|
|
|
|
$expire = ($session->getExpire()*60)* 1000;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// use the Componentbuilder Global setting
|
|
|
|
if (0 != $storageTimeToLive)
|
|
|
|
{
|
|
|
|
// this will convert the time into milliseconds
|
|
|
|
$storageTimeToLive = $storageTimeToLive * 1000;
|
|
|
|
}
|
|
|
|
$expire = $storageTimeToLive;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// set to use no storage
|
|
|
|
$expire = 30000; // only 30 seconds
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the Time To Live To JavaScript
|
|
|
|
$this->document->addScriptDeclaration("var expire = ". (int) $expire.";");
|
2024-03-02 20:10:30 +00:00
|
|
|
$this->document->addScriptDeclaration("var all_is_good = '".Text::_('COM_COMPONENTBUILDER_ALL_IS_GOOD_THERE_IS_NO_NOTICE_AT_THIS_TIME')."';");
|
2018-05-01 22:17:38 +00:00
|
|
|
// add a token on the page for javascript
|
|
|
|
$this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';");
|
|
|
|
|
2020-05-29 01:01:07 +00:00
|
|
|
|
2018-05-01 22:17:38 +00:00
|
|
|
// add the Uikit v2 style sheets
|
2024-03-02 20:10:30 +00:00
|
|
|
Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']);
|
2018-05-01 22:17:38 +00:00
|
|
|
// add Uikit v2 JavaScripts
|
2024-03-02 20:10:30 +00:00
|
|
|
Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']);
|
2020-05-29 01:01:07 +00:00
|
|
|
|
|
|
|
// add the Uikit v2 extra style sheets
|
2024-03-02 20:10:30 +00:00
|
|
|
Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']);
|
2020-05-29 01:01:07 +00:00
|
|
|
// add Uikit v2 extra JavaScripts
|
2024-03-02 20:10:30 +00:00
|
|
|
Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']);
|
|
|
|
Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']);
|
2018-05-01 22:17:38 +00:00
|
|
|
}
|
|
|
|
|
2018-03-21 02:45:51 +00:00
|
|
|
public function _getForm($type)
|
|
|
|
{
|
2017-03-30 21:19:12 +00:00
|
|
|
$form = array();
|
2018-03-21 02:45:51 +00:00
|
|
|
if ('smart_package' === $type)
|
2017-03-30 21:19:12 +00:00
|
|
|
{
|
2018-04-08 06:12:18 +00:00
|
|
|
// get the force_update radio field
|
2024-03-02 20:10:30 +00:00
|
|
|
$force_update = FormHelper::loadFieldType('radio',true);
|
|
|
|
// start force_update xl
|
|
|
|
$force_updateXML = new \SimpleXMLElement('<field/>');
|
2018-04-08 06:12:18 +00:00
|
|
|
// force_update attributes
|
|
|
|
$force_updateAttributes = array(
|
|
|
|
'type' => 'radio',
|
2018-04-13 17:48:55 +00:00
|
|
|
'name' => 'force_update',
|
2018-04-08 06:12:18 +00:00
|
|
|
'label' => 'COM_COMPONENTBUILDER_FORCE_LOCAL_UPDATE',
|
|
|
|
'class' => 'btn-group btn-group-yesno',
|
|
|
|
'description' => 'COM_COMPONENTBUILDER_SHOULD_WE_FORCE_THE_UPDATE_OF_ALL_LOCAL_DATA_EVEN_IF_IT_IS_NEWER_THEN_THE_DATA_BEING_IMPORTED',
|
|
|
|
'default' => '0');
|
|
|
|
// load the force_update attributes
|
2024-03-02 20:10:30 +00:00
|
|
|
UtilitiesFormHelper::attributes($force_updateXML, $force_updateAttributes);
|
2018-04-08 06:12:18 +00:00
|
|
|
// set the force_update options
|
|
|
|
$force_updateOptions = array(
|
|
|
|
'1' => 'COM_COMPONENTBUILDER_YES',
|
|
|
|
'0' => 'COM_COMPONENTBUILDER_NO');
|
|
|
|
// load the force_update options
|
2024-03-02 20:10:30 +00:00
|
|
|
UtilitiesFormHelper::options($force_updateXML, $force_updateOptions);
|
2018-04-08 06:12:18 +00:00
|
|
|
// setup the force_update radio field
|
|
|
|
$force_update->setup($force_updateXML,0);
|
2018-03-21 02:45:51 +00:00
|
|
|
// add to form
|
2018-04-08 06:12:18 +00:00
|
|
|
$form[] = $force_update;
|
2018-03-21 02:45:51 +00:00
|
|
|
|
2018-04-08 06:12:18 +00:00
|
|
|
// get the more_info radio field
|
2024-03-02 20:10:30 +00:00
|
|
|
$more_info = FormHelper::loadFieldType('radio',true);
|
2018-04-08 06:12:18 +00:00
|
|
|
// start more_info xml
|
2024-03-02 20:10:30 +00:00
|
|
|
$more_infoXML = new \SimpleXMLElement('<field/>');
|
2018-04-08 06:12:18 +00:00
|
|
|
// more_info attributes
|
|
|
|
$more_infoAttributes = array(
|
|
|
|
'type' => 'radio',
|
2018-04-13 17:48:55 +00:00
|
|
|
'name' => 'more_info',
|
2018-04-08 06:12:18 +00:00
|
|
|
'label' => 'COM_COMPONENTBUILDER_SEE_ALL_IMPORT_INFO',
|
|
|
|
'class' => 'btn-group btn-group-yesno',
|
|
|
|
'description' => 'COM_COMPONENTBUILDER_SHOULD_WE_BE_SHOWING_MORE_ELABORATE_INFORMATION_DURING_IMPORT',
|
|
|
|
'default' => '0');
|
|
|
|
// load the more_info attributes
|
2024-03-02 20:10:30 +00:00
|
|
|
UtilitiesFormHelper::attributes($more_infoXML, $more_infoAttributes);
|
2018-04-08 06:12:18 +00:00
|
|
|
// set the more_info options
|
|
|
|
$more_infoOptions = array(
|
|
|
|
'1' => 'COM_COMPONENTBUILDER_YES',
|
|
|
|
'0' => 'COM_COMPONENTBUILDER_NO');
|
|
|
|
// load the more_info options
|
2024-03-02 20:10:30 +00:00
|
|
|
UtilitiesFormHelper::options($more_infoXML, $more_infoOptions);
|
2018-04-08 06:12:18 +00:00
|
|
|
// setup the more_info radio field
|
|
|
|
$more_info->setup($more_infoXML,0);
|
2018-03-21 02:45:51 +00:00
|
|
|
// add to form
|
2018-04-08 06:12:18 +00:00
|
|
|
$form[] = $more_info;
|
2018-04-17 21:25:03 +00:00
|
|
|
|
|
|
|
// get the merge radio field
|
2024-03-02 20:10:30 +00:00
|
|
|
$merge = FormHelper::loadFieldType('radio',true);
|
2018-04-17 21:25:03 +00:00
|
|
|
// start merge xml
|
2024-03-02 20:10:30 +00:00
|
|
|
$mergeXML = new \SimpleXMLElement('<field/>');
|
2018-04-17 21:25:03 +00:00
|
|
|
// merge attributes
|
|
|
|
$mergeAttributes = array(
|
|
|
|
'type' => 'radio',
|
|
|
|
'name' => 'canmerge',
|
|
|
|
'label' => 'COM_COMPONENTBUILDER_MERGE',
|
|
|
|
'class' => 'btn-group btn-group-yesno',
|
2019-08-12 21:30:31 +00:00
|
|
|
'description' => 'COM_COMPONENTBUILDER_SHOULD_WE_MERGE_THE_COMPONENTS_WITH_SIMILAR_LOCAL_COMPONENTS_MERGING_THE_COMPONENTS_USE_TO_BE_THE_DEFAULT_BEHAVIOUR_BUT_NOW_YOU_CAN_IMPORT_THE_COMPONENTS_AND_FORCE_IT_NOT_TO_MERGE_THE_FOLLOWING_AREAS_VALIDATION_RULE_FIELDTYPE_SNIPPET_LANGUAGE_LANGUAGE_TRANSLATION_JOOMLA_PLUGIN_GROUP_CLASS_EXTENDS_CLASS_PROPERTY_CLASS_METHOD_BMUST_AND_WILL_STILLB_MERGE_EVEN_OF_YOUR_SELECTION_IS_BNOB_BECAUSE_OF_THE_SINGULAR_NATURE_OF_THOSE_AREAS',
|
2018-04-17 21:25:03 +00:00
|
|
|
'default' => '1');
|
|
|
|
// load the merge attributes
|
2024-03-02 20:10:30 +00:00
|
|
|
UtilitiesFormHelper::attributes($mergeXML, $mergeAttributes);
|
2018-04-17 21:25:03 +00:00
|
|
|
// set the merge options
|
|
|
|
$mergeOptions = array(
|
|
|
|
'1' => 'COM_COMPONENTBUILDER_YES',
|
|
|
|
'0' => 'COM_COMPONENTBUILDER_NO');
|
|
|
|
// load the merge options
|
2024-03-02 20:10:30 +00:00
|
|
|
UtilitiesFormHelper::options($mergeXML, $mergeOptions);
|
2018-04-17 21:25:03 +00:00
|
|
|
// setup the merge radio field
|
|
|
|
$merge->setup($mergeXML,1);
|
|
|
|
// add to form
|
|
|
|
$form[] = $merge;
|
2021-08-11 12:15:35 +00:00
|
|
|
|
|
|
|
// get the import_guid_only radio field
|
2024-03-02 20:10:30 +00:00
|
|
|
$import_guid_only = FormHelper::loadFieldType('radio',true);
|
2021-08-11 12:15:35 +00:00
|
|
|
// start import_guid_only xml
|
2024-03-02 20:10:30 +00:00
|
|
|
$import_guid_onlyXML = new \SimpleXMLElement('<field/>');
|
2021-08-11 12:15:35 +00:00
|
|
|
// import_guid_only attributes
|
|
|
|
$import_guid_onlyAttributes = array(
|
|
|
|
'type' => 'radio',
|
|
|
|
'name' => 'import_guid_only',
|
|
|
|
'label' => 'COM_COMPONENTBUILDER_IMPORT_BY_GUID_ONLY',
|
|
|
|
'class' => 'btn-group btn-group-yesno',
|
|
|
|
'description' => 'COM_COMPONENTBUILDER_FORCE_THAT_THIS_JCB_PACKAGE_IMPORT_SEARCH_FOR_LOCAL_ITEMS_TO_BE_DONE_WITH_GUID_VALUE_ONLY_IF_BMERGEB_IS_SET_TO_YES_ABOVE',
|
|
|
|
'default' => '1');
|
|
|
|
// load the import_guid_only attributes
|
2024-03-02 20:10:30 +00:00
|
|
|
UtilitiesFormHelper::attributes($import_guid_onlyXML, $import_guid_onlyAttributes);
|
2021-08-11 12:15:35 +00:00
|
|
|
// set the import_guid_only options
|
|
|
|
$import_guid_onlyOptions = array(
|
|
|
|
'1' => 'COM_COMPONENTBUILDER_YES',
|
|
|
|
'0' => 'COM_COMPONENTBUILDER_NO');
|
|
|
|
// load the import_guid_only options
|
2024-03-02 20:10:30 +00:00
|
|
|
UtilitiesFormHelper::options($import_guid_onlyXML, $import_guid_onlyOptions);
|
2021-08-11 12:15:35 +00:00
|
|
|
// setup the import_guid_only radio field
|
|
|
|
$import_guid_only->setup($import_guid_onlyXML, $this->params->get('import_guid_only', 0));
|
|
|
|
// add to form
|
|
|
|
$form[] = $import_guid_only;
|
2018-03-21 02:45:51 +00:00
|
|
|
|
2018-05-02 14:47:01 +00:00
|
|
|
if (!$this->packageInfo || ComponentbuilderHelper::getPackageComponentsKeyStatus($this->packageInfo))
|
2017-03-30 21:19:12 +00:00
|
|
|
{
|
2018-03-21 02:45:51 +00:00
|
|
|
// set required field
|
2018-04-08 06:12:18 +00:00
|
|
|
$required = true;
|
|
|
|
// does the packages has info
|
2018-03-21 02:45:51 +00:00
|
|
|
if (!$this->packageInfo)
|
|
|
|
{
|
2018-04-08 06:12:18 +00:00
|
|
|
// get the haskey radio field
|
2024-03-02 20:10:30 +00:00
|
|
|
$haskey = FormHelper::loadFieldType('radio',true);
|
2018-04-08 06:12:18 +00:00
|
|
|
// start haskey xml
|
2024-03-02 20:10:30 +00:00
|
|
|
$haskeyXML = new \SimpleXMLElement('<field/>');
|
2018-04-08 06:12:18 +00:00
|
|
|
// haskey attributes
|
|
|
|
$haskeyAttributes = array(
|
|
|
|
'type' => 'radio',
|
2018-04-13 17:48:55 +00:00
|
|
|
'name' => 'haskey',
|
2018-04-08 06:12:18 +00:00
|
|
|
'label' => 'COM_COMPONENTBUILDER_USE_KEY',
|
|
|
|
'class' => 'btn-group btn-group-yesno',
|
|
|
|
'description' => 'COM_COMPONENTBUILDER_DOES_THIS_PACKAGE_REQUIRE_A_KEY_TO_INSTALL',
|
|
|
|
'default' => '1',
|
|
|
|
'filter' => 'INT');
|
|
|
|
// load the haskey attributes
|
2024-03-02 20:10:30 +00:00
|
|
|
UtilitiesFormHelper::attributes($haskeyXML, $haskeyAttributes);
|
2018-04-08 06:12:18 +00:00
|
|
|
// set the haskey options
|
|
|
|
$haskeyOptions = array(
|
|
|
|
'1' => 'COM_COMPONENTBUILDER_YES',
|
|
|
|
'0' => 'COM_COMPONENTBUILDER_NO');
|
|
|
|
// load the haskey options
|
2024-03-02 20:10:30 +00:00
|
|
|
UtilitiesFormHelper::options($haskeyXML, $haskeyOptions);
|
2018-04-08 06:12:18 +00:00
|
|
|
// setup the haskey radio field
|
|
|
|
$haskey->setup($haskeyXML,1);
|
2018-03-21 02:45:51 +00:00
|
|
|
// add to form
|
2018-04-08 06:12:18 +00:00
|
|
|
$form[] = $haskey;
|
|
|
|
|
|
|
|
// now make required false
|
|
|
|
$required = false;
|
2018-03-21 02:45:51 +00:00
|
|
|
}
|
|
|
|
|
2018-04-08 06:12:18 +00:00
|
|
|
// get the sleutle password field
|
2024-03-02 20:10:30 +00:00
|
|
|
$sleutle = FormHelper::loadFieldType('password',true);
|
2018-04-08 06:12:18 +00:00
|
|
|
// start sleutle xml
|
2024-03-02 20:10:30 +00:00
|
|
|
$sleutleXML = new \SimpleXMLElement('<field/>');
|
2018-04-08 06:12:18 +00:00
|
|
|
// sleutle attributes
|
|
|
|
$sleutleAttributes = array(
|
|
|
|
'type' => 'password',
|
2018-04-13 17:48:55 +00:00
|
|
|
'name' => 'sleutle',
|
2018-04-08 06:12:18 +00:00
|
|
|
'label' => 'COM_COMPONENTBUILDER_KEY',
|
|
|
|
'class' => 'text_area',
|
|
|
|
'description' => 'COM_COMPONENTBUILDER_THE_KEY_OF_THIS_PACKAGE',
|
|
|
|
'autocomplete' => 'false',
|
|
|
|
'filter' => 'STRING',
|
|
|
|
'hint' => 'COM_COMPONENTBUILDER_ADD_KEY_HERE');
|
|
|
|
// should this be required
|
|
|
|
if ($required)
|
|
|
|
{
|
|
|
|
$sleutleAttributes['required'] = 'true';
|
|
|
|
}
|
|
|
|
// load the sleutle attributes
|
2024-03-02 20:10:30 +00:00
|
|
|
UtilitiesFormHelper::attributes($sleutleXML, $sleutleAttributes);
|
2018-04-08 06:12:18 +00:00
|
|
|
// setup the sleutle password field
|
|
|
|
$sleutle->setup($sleutleXML,'');
|
2017-03-30 21:19:12 +00:00
|
|
|
// add to form
|
2018-04-08 06:12:18 +00:00
|
|
|
$form[] = $sleutle;
|
2017-03-30 21:19:12 +00:00
|
|
|
}
|
2018-03-21 02:45:51 +00:00
|
|
|
}
|
2019-09-10 16:47:39 +00:00
|
|
|
elseif ('vdm_package' === $type && in_array('vdm', $this->directories) && $vdmListObjects = ComponentbuilderHelper::getGithubRepoFileList('vdmGithubPackages', ComponentbuilderHelper::$vdmGithubPackagesUrl))
|
2018-03-21 02:45:51 +00:00
|
|
|
{
|
2023-10-18 07:26:30 +00:00
|
|
|
if (ArrayHelper::check($vdmListObjects))
|
2018-03-21 02:45:51 +00:00
|
|
|
{
|
2018-04-08 06:12:18 +00:00
|
|
|
// get the vdm_package list field
|
2024-03-02 20:10:30 +00:00
|
|
|
$vdm_package = FormHelper::loadFieldType('list',true);
|
2018-04-08 06:12:18 +00:00
|
|
|
// start vdm_package xml
|
2024-03-02 20:10:30 +00:00
|
|
|
$vdm_packageXML = new \SimpleXMLElement('<field/>');
|
2018-04-08 06:12:18 +00:00
|
|
|
// vdm_package attributes
|
|
|
|
$vdm_packageAttributes = array(
|
|
|
|
'type' => 'list',
|
|
|
|
'name' => 'vdm_package',
|
|
|
|
'label' => 'COM_COMPONENTBUILDER_PACKAGE',
|
|
|
|
'class' => 'list_class',
|
2018-05-01 22:17:38 +00:00
|
|
|
'description' => 'COM_COMPONENTBUILDER_SELECT_THE_PACKAGE_TO_IMPORT',
|
|
|
|
'onchange' => "getJCBpackageInfo('vdm')");
|
2018-03-21 02:45:51 +00:00
|
|
|
// load the list
|
|
|
|
$load = false;
|
2018-04-08 06:12:18 +00:00
|
|
|
// load the vdm_package attributes
|
2024-03-02 20:10:30 +00:00
|
|
|
UtilitiesFormHelper::attributes($vdm_packageXML, $vdm_packageAttributes);
|
2018-04-08 06:12:18 +00:00
|
|
|
// start the vdm_package options
|
|
|
|
$vdm_packageOptions = array();
|
|
|
|
$vdm_packageOptions[''] = 'COM_COMPONENTBUILDER__SELECT_PACKAGE_';
|
|
|
|
// load vdm_package options from array
|
2018-05-01 22:17:38 +00:00
|
|
|
foreach($vdmListObjects as $vdmListObject)
|
2018-03-21 02:45:51 +00:00
|
|
|
{
|
2018-05-01 22:17:38 +00:00
|
|
|
if (strpos($vdmListObject->path, '.zip') !== false)
|
2018-03-21 02:45:51 +00:00
|
|
|
{
|
2022-06-02 12:05:34 +00:00
|
|
|
$vdm_packageOptions[base64_encode(ComponentbuilderHelper::$vdmGithubPackageUrl.$vdmListObject->path)] = $this->setPackageName($vdmListObject->path);
|
2018-03-21 02:45:51 +00:00
|
|
|
$load = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// only load if at least one item was found
|
|
|
|
if ($load)
|
|
|
|
{
|
2018-04-08 06:12:18 +00:00
|
|
|
// load the vdm_package options
|
2024-03-02 20:10:30 +00:00
|
|
|
UtilitiesFormHelper::options($vdm_packageXML, $vdm_packageOptions);
|
2018-04-08 06:12:18 +00:00
|
|
|
// setup the vdm_package radio field
|
|
|
|
$vdm_package->setup($vdm_packageXML,'');
|
|
|
|
// add to form
|
|
|
|
$form[] = $vdm_package;
|
2018-03-21 02:45:51 +00:00
|
|
|
}
|
|
|
|
}
|
2017-03-30 21:19:12 +00:00
|
|
|
}
|
2019-09-10 16:47:39 +00:00
|
|
|
elseif ('jcb_package' === $type && in_array('jcb', $this->directories) && $jcbListObjects = ComponentbuilderHelper::getGithubRepoFileList('communityGithubPackages', ComponentbuilderHelper::$jcbGithubPackagesUrl))
|
2018-05-01 22:17:38 +00:00
|
|
|
{
|
2023-10-18 07:26:30 +00:00
|
|
|
if (ArrayHelper::check($jcbListObjects))
|
2018-05-01 22:17:38 +00:00
|
|
|
{
|
|
|
|
// get the jcb_package list field
|
2024-03-02 20:10:30 +00:00
|
|
|
$jcb_package = FormHelper::loadFieldType('list',true);
|
2018-05-01 22:17:38 +00:00
|
|
|
// start jcb_package xml
|
2024-03-02 20:10:30 +00:00
|
|
|
$jcb_packageXML = new \SimpleXMLElement('<field/>');
|
2018-05-01 22:17:38 +00:00
|
|
|
// jcb_package attributes
|
|
|
|
$jcb_packageAttributes = array(
|
|
|
|
'type' => 'list',
|
|
|
|
'name' => 'jcb_package',
|
|
|
|
'label' => 'COM_COMPONENTBUILDER_PACKAGE',
|
|
|
|
'class' => 'list_class',
|
|
|
|
'description' => 'COM_COMPONENTBUILDER_SELECT_THE_PACKAGE_TO_IMPORT',
|
|
|
|
'onchange' => "getJCBpackageInfo('jcb')");
|
|
|
|
// load the list
|
|
|
|
$load = false;
|
|
|
|
// load the jcb_package attributes
|
2024-03-02 20:10:30 +00:00
|
|
|
UtilitiesFormHelper::attributes($jcb_packageXML, $jcb_packageAttributes);
|
2018-05-01 22:17:38 +00:00
|
|
|
// start the jcb_package options
|
|
|
|
$jcb_packageOptions = array();
|
|
|
|
$jcb_packageOptions[''] = 'COM_COMPONENTBUILDER__SELECT_PACKAGE_';
|
|
|
|
// load jcb_package options from array
|
|
|
|
foreach($jcbListObjects as $jcbListObject)
|
|
|
|
{
|
|
|
|
if (strpos($jcbListObject->path, '.zip') !== false)
|
|
|
|
{
|
2022-06-02 12:05:34 +00:00
|
|
|
$jcb_packageOptions[base64_encode(ComponentbuilderHelper::$jcbGithubPackageUrl.$jcbListObject->path)] = $this->setPackageName($jcbListObject->path);
|
2018-05-01 22:17:38 +00:00
|
|
|
$load = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// only load if at least one item was found
|
|
|
|
if ($load)
|
|
|
|
{
|
|
|
|
// load the jcb_package options
|
2024-03-02 20:10:30 +00:00
|
|
|
UtilitiesFormHelper::options($jcb_packageXML, $jcb_packageOptions);
|
2018-05-01 22:17:38 +00:00
|
|
|
// setup the jcb_package radio field
|
|
|
|
$jcb_package->setup($jcb_packageXML,'');
|
|
|
|
// add to form
|
|
|
|
$form[] = $jcb_package;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-30 21:19:12 +00:00
|
|
|
return $form;
|
2017-03-28 14:57:59 +00:00
|
|
|
}
|
|
|
|
|
2018-03-21 02:45:51 +00:00
|
|
|
public function setPackageName($name)
|
|
|
|
{
|
2018-03-21 03:10:34 +00:00
|
|
|
// return the name
|
2023-10-18 07:26:30 +00:00
|
|
|
return StringHelper::safe( preg_replace('/(?<!^)([A-Z])/', '-\ \1', str_replace(array('.zip', 'JCB_'), '', $name)), 'W');
|
2021-03-05 03:08:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Setting the toolbar
|
|
|
|
*/
|
|
|
|
protected function addToolBar()
|
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_IMPORT_TITLE'), 'upload');
|
2021-03-05 03:08:47 +00:00
|
|
|
JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=import_joomla_components');
|
|
|
|
|
|
|
|
if ($this->canDo->get('core.admin') || $this->canDo->get('core.options'))
|
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::preferences('com_componentbuilder');
|
2021-03-05 03:08:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// set help url for this view if found
|
2022-02-12 22:28:17 +00:00
|
|
|
$this->help_url = ComponentbuilderHelper::getHelpUrl('import_joomla_components');
|
2024-03-02 20:10:30 +00:00
|
|
|
if (StringHelper::check($this->help_url))
|
2021-03-05 03:08:47 +00:00
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url);
|
2021-03-05 03:08:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|