Fix gh-249 that caused the admin views to break in PHP 7.2 We also added VDM package import to the import of JCB packages
This commit is contained in:
@ -704,7 +704,7 @@ jQuery('input.form-field-repeatable').on('row-add', function (e) {
|
||||
});
|
||||
});
|
||||
<?php endforeach; ?>
|
||||
<?php $numberAddtables = range(0, count($this->item->addtables) + 3, 1);?>
|
||||
<?php $numberAddtables = range(0, count( (array) $this->item->addtables) + 3, 1);?>
|
||||
|
||||
// for the values already set
|
||||
jQuery(document).ready(function(){
|
||||
|
@ -120,6 +120,23 @@ JHtml::_('behavior.keepalive');
|
||||
form.submit();
|
||||
}
|
||||
};
|
||||
Joomla.submitbuttonVDM = function()
|
||||
{
|
||||
var form = document.getElementById('adminForm');
|
||||
// do field validation
|
||||
if (form.vdm_package.value == "" || form.vdm_package.value == "http://")
|
||||
{
|
||||
alert("<?php echo JText::_('COM_COMPONENTBUILDER_SELECT_THE_COMPONENT_YOUR_WOULD_LIKE_TO_IMPORT', true); ?>");
|
||||
}
|
||||
else
|
||||
{
|
||||
// set the url
|
||||
form.import_url.value = form.vdm_package.value;
|
||||
jQuery('#loading').css('display', 'block');
|
||||
form.gettype.value = 'url';
|
||||
form.submit();
|
||||
}
|
||||
};
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
@ -157,9 +174,9 @@ jQuery(document).ready(function($) {
|
||||
<div id="j-main-container">
|
||||
<?php endif;?>
|
||||
<?php if ($this->hasPackage && ComponentbuilderHelper::checkArray($this->headerList) && ComponentbuilderHelper::checkArray($this->headers)) : ?>
|
||||
<?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => $this->activeTab)); ?>
|
||||
<?php echo JHtml::_('bootstrap.startTabSet', 'jcbImportTab', array('active' => $this->activeTab)); ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'basic', JText::_('COM_COMPONENTBUILDER_BASIC_METHOD', true)); ?>
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'jcbImportTab', 'basic', JText::_('COM_COMPONENTBUILDER_BASIC_METHOD', true)); ?>
|
||||
<fieldset class="uploadform">
|
||||
<legend><?php echo JText::_('COM_COMPONENTBUILDER_IMPORT_LINK_FILE_TO_TABLE_COLUMNS'); ?></legend>
|
||||
<div class="control-group">
|
||||
@ -205,9 +222,9 @@ jQuery(document).ready(function($) {
|
||||
?>
|
||||
<h3 style="color: #1F73BA;"><?php echo JText::_('COM_COMPONENTBUILDER_CONFIRMATION_STEP_BEFORE_IMPORTING'); ?></h3>
|
||||
<p style="color: #1F73BA;"><?php echo JText::_('COM_COMPONENTBUILDER_YOU_SHOULD_ONLY_CONTINUE_THIS_IMPORT_IF_YOU_HAVE_BACKUP_YOUR_COMPONENTS_AND_INSURED_THAT_THE_PACKAGE_OWNER_IS_REPUTABLE'); ?></p>
|
||||
<?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'advanced')); ?>
|
||||
<?php echo JHtml::_('bootstrap.startTabSet', 'jcbImportTab', array('active' => 'advanced')); ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'advanced', JText::sprintf('COM_COMPONENTBUILDER_IMPORT_S', $comP)); ?>
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'jcbImportTab', 'advanced', JText::sprintf('COM_COMPONENTBUILDER_IMPORT_S', $comP)); ?>
|
||||
<div class="<?php echo $class1; ?>">
|
||||
<fieldset class="uploadform">
|
||||
<legend><?php echo JText::_('COM_COMPONENTBUILDER_SMART_PACKAGE_OPTIONS'); ?></legend>
|
||||
@ -299,7 +316,7 @@ jQuery(document).ready(function($) {
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
|
||||
<?php if (isset($this->packageInfo['name']) && ComponentbuilderHelper::checkArray($this->packageInfo['name'])) : ?>
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'info', JText::sprintf('COM_COMPONENTBUILDER_S_BEING_IMPORTED', $comP)); ?>
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'jcbImportTab', 'info', JText::sprintf('COM_COMPONENTBUILDER_S_BEING_IMPORTED', $comP)); ?>
|
||||
<?php $class2 = ($cAmount == 1) ? 'span12' : 'span6'; ?>
|
||||
<?php $counter = 1; foreach ($this->packageInfo['name'] as $key => $value): ?>
|
||||
<?php if ($cAmount > 1 && $counter == 3) { echo '</div>'; $counter = 1;} ?>
|
||||
@ -330,9 +347,9 @@ jQuery(document).ready(function($) {
|
||||
<h1 style="color: #922924;"><?php echo JText::_('COM_COMPONENTBUILDER_BACKUP_LOCAL_DATA_FIRST'); ?></h1>
|
||||
<p style="color: #922924;"><?php echo JText::_('COM_COMPONENTBUILDER_ALWAYS_INSURE_THAT_YOU_HAVE_YOUR_LOCAL_COMPONENTS_BACKED_UP_BY_MAKING_AN_EXPORT_OF_ALL_YOUR_LOCAL_COMPONENTS_BEFORE_IMPORTING_ANY_NEW_COMPONENTS_SMALLMAKE_BSUREB_TO_MOVE_THIS_ZIPPED_BACKUP_PACKAGE_OUT_OF_THE_TMP_FOLDER_BEFORE_DOING_AN_IMPORTSMALLBR_IF_YOU_ARE_IMPORTING_A_PACKAGE_OF_A_THREERD_PARTY_JCB_PACKAGE_DEVELOPER_BMAKE_SURE_IT_IS_A_REPUTABLE_JCB_PACKAGE_DEVELOPERSB'); ?></p>
|
||||
<?php endif; ?>
|
||||
<?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'upload')); ?>
|
||||
<?php echo JHtml::_('bootstrap.startTabSet', 'jcbImportTab', array('active' => 'upload')); ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'upload', JText::_('COM_COMPONENTBUILDER_IMPORT_FROM_UPLOAD', true)); ?>
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'jcbImportTab', 'upload', JText::_('COM_COMPONENTBUILDER_IMPORT_FROM_UPLOAD', true)); ?>
|
||||
<fieldset class="uploadform">
|
||||
<legend><?php echo JText::_('COM_COMPONENTBUILDER_IMPORT_UPDATE_DATA'); ?></legend>
|
||||
<div class="control-group">
|
||||
@ -347,7 +364,7 @@ jQuery(document).ready(function($) {
|
||||
</fieldset>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'directory', JText::_('COM_COMPONENTBUILDER_IMPORT_FROM_DIRECTORY', true)); ?>
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'jcbImportTab', 'directory', JText::_('COM_COMPONENTBUILDER_IMPORT_FROM_DIRECTORY', true)); ?>
|
||||
<fieldset class="uploadform">
|
||||
<legend><?php echo JText::_('COM_COMPONENTBUILDER_IMPORT_UPDATE_DATA'); ?></legend>
|
||||
<div class="control-group">
|
||||
@ -362,7 +379,7 @@ jQuery(document).ready(function($) {
|
||||
</fieldset>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'url', JText::_('COM_COMPONENTBUILDER_IMPORT_FROM_URL', true)); ?>
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'jcbImportTab', 'url', JText::_('COM_COMPONENTBUILDER_IMPORT_FROM_URL', true)); ?>
|
||||
<fieldset class="uploadform">
|
||||
<legend><?php echo JText::_('COM_COMPONENTBUILDER_IMPORT_UPDATE_DATA'); ?></legend>
|
||||
<div class="control-group">
|
||||
@ -376,6 +393,27 @@ jQuery(document).ready(function($) {
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
|
||||
<?php if ($this->vdmPackages): ?>
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'jcbImportTab', 'url_vdm', JText::_('COM_COMPONENTBUILDER_VDM_PACKAGES', true)); ?>
|
||||
<fieldset class="uploadform">
|
||||
<legend><?php echo JText::_("COM_COMPONENTBUILDER_PACKAGES_FROM_VAST_DEVELOPMENT_METHOD"); ?></legend>
|
||||
<p><?php echo JText::_('COM_COMPONENTBUILDER_ALL_OF_THESE_PACKAGES_ARE_A_FULLY_DEVELOPEDMAPPED_COMPONENTS_FOR_JCB_THEY_CAN_BE_SEEN_AS_DEMO_CONTENT_OR_BASE_IMAGES_FROM_WHICH_TO_START_YOUR_PROJECT_ALWAYS_MAKE_SURE_YOU_ARE_ON_THE_LATEST_VERSION_OF_JCB_BEFORE_IMPORTING_ANY_OF_THESE_PACKAGES_SHOULD_ANY_OF_THEM_FAIL_TO_IMPORT_PLEASE_LET_US_KNOW'); ?></p>
|
||||
<p><?php echo JText::sprintf('COM_COMPONENTBUILDER_THEY_ARE_BEING_HOSTED_ON_A_S_GITHUBA_AND_CAN_BE_IMPORTED_BY_SIMPLY_MAKING_A_SELECTION_AND_THEN_CLICKING_THE_GET_PACKAGE_BUTTON', 'href="https://github.com/vdm-io/JCB-Packages" target="_blank" title="gitHub Reposetory"'); ?></p>
|
||||
<?php foreach ($this->vdmPackages as $field): ?>
|
||||
<div class="control-group">
|
||||
<div class="control-label"><?php echo $field->label;?></div>
|
||||
<div class="controls"><?php echo $field->input;?></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<div class="form-actions">
|
||||
<input type="button" class="btn btn-primary" value="<?php echo JText::_('COM_COMPONENTBUILDER_GET_PACKAGE'); ?>" onclick="Joomla.submitbuttonVDM()" /> <small><span class="icon-shield"> </span><?php echo JText::_('COM_COMPONENTBUILDER_OFFICIAL_VDM_PACKAGES'); ?></small>
|
||||
</div>
|
||||
<div class="control-group"><small><?php echo JText::sprintf('COM_COMPONENTBUILDER_A_S_SPAN_CLASSICONFLAG_SPANREPORT_BROKEN_PACKAGEA', 'href="https://www.vdm.io/support" target="_blank" title="Should any of these packages fail to import please let us know"'); ?></small></div>
|
||||
</fieldset>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.endTabSet'); ?>
|
||||
<input type="hidden" name="gettype" value="upload" />
|
||||
<?php endif; ?>
|
||||
|
@ -41,6 +41,7 @@ class ComponentbuilderViewImport_joomla_components extends JViewLegacy
|
||||
protected $dataType;
|
||||
protected $packageInfo;
|
||||
protected $formPackage;
|
||||
protected $vdmPackages = false;
|
||||
|
||||
public function display($tpl = null)
|
||||
{
|
||||
@ -87,7 +88,11 @@ class ComponentbuilderViewImport_joomla_components extends JViewLegacy
|
||||
if ($this->dataType === 'smart_package')
|
||||
{
|
||||
$this->packageInfo = json_decode($session->get('smart_package_info', false), true);
|
||||
$this->formPackage = $this->getForm();
|
||||
// add the form class
|
||||
jimport('joomla.form.form');
|
||||
// load the forms
|
||||
$this->formPackage = $this->_getForm($this->dataType);
|
||||
$this->vdmPackages = $this->_getForm('vdm_package');
|
||||
}
|
||||
|
||||
// Check for errors.
|
||||
@ -100,56 +105,107 @@ class ComponentbuilderViewImport_joomla_components extends JViewLegacy
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
public function getForm()
|
||||
{
|
||||
jimport('joomla.form.form');
|
||||
public function _getForm($type)
|
||||
{
|
||||
$form = array();
|
||||
$radio1 = JFormHelper::loadFieldType('radio',true);
|
||||
// Switch to force local update
|
||||
$xml = '<field label="'.JText::_('COM_COMPONENTBUILDER_FORCE_LOCAL_UPDATE').'" description="'.JText::_('COM_COMPONENTBUILDER_SHOULD_WE_FORCE_THE_UPDATE_OF_ALL_LOCAL_DATA_EVEN_IF_IT_IS_NEWER_THEN_THE_DATA_BEING_IMPORTED').'" name="force_update" type="radio" class="btn-group btn-group-yesno" default="0" filter="INT">';
|
||||
$xml .= '<option value="1">'.JText::_('COM_COMPONENTBUILDER_YES').'</option> <option value="0">'.JText::_('COM_COMPONENTBUILDER_NO').'</option>';
|
||||
$xml .= "</field>";
|
||||
// prepare the xml
|
||||
$force = new SimpleXMLElement($xml);
|
||||
// set components to form
|
||||
$radio1->setup($force,0);
|
||||
// add to form
|
||||
$form[] = $radio1;
|
||||
|
||||
if (!$this->packageInfo || (isset($this->packageInfo['getKeyFrom']) && ComponentbuilderHelper::checkArray($this->packageInfo['getKeyFrom'])))
|
||||
if ('smart_package' === $type)
|
||||
{
|
||||
// set required field
|
||||
$required = 'required="true"';
|
||||
if (!$this->packageInfo)
|
||||
{
|
||||
$radio2 = JFormHelper::loadFieldType('radio',true);
|
||||
// has key
|
||||
$xml = '<field label="'.JText::_('COM_COMPONENTBUILDER_USE_KEY').'" description="'.JText::_('COM_COMPONENTBUILDER_DOES_THIS_PACKAGE_REQUIRE_A_KEY_TO_INSTALL').'" name="haskey" type="radio" class="btn-group btn-group-yesno" default="1" filter="INT">';
|
||||
$xml .= '<option value="1">'.JText::_('COM_COMPONENTBUILDER_YES').'</option> <option value="0">'.JText::_('COM_COMPONENTBUILDER_NO').'</option>';
|
||||
$xml .= "</field>";
|
||||
// prepare the xml
|
||||
$license = new SimpleXMLElement($xml);
|
||||
// set components to form
|
||||
$radio2->setup($license,1);
|
||||
$required = ''; // change required field
|
||||
// add to form
|
||||
$form[] = $radio2;
|
||||
}
|
||||
|
||||
$text1 = JFormHelper::loadFieldType('text',true);
|
||||
// add the key
|
||||
$xml = '<field type="password" label="'.JText::_('COM_COMPONENTBUILDER_KEY').'" description="'.JText::_('COM_COMPONENTBUILDER_THE_KEY_OF_THIS_PACKAGE').'" name="sleutle" autocomplete="false" class="text_area" filter="STRING" hint="add key here" '.$required.' />';
|
||||
$radio1 = JFormHelper::loadFieldType('radio',true);
|
||||
// Switch to force local update
|
||||
$xml = '<field label="'.JText::_('COM_COMPONENTBUILDER_FORCE_LOCAL_UPDATE').'" description="'.JText::_('COM_COMPONENTBUILDER_SHOULD_WE_FORCE_THE_UPDATE_OF_ALL_LOCAL_DATA_EVEN_IF_IT_IS_NEWER_THEN_THE_DATA_BEING_IMPORTED').'" name="force_update" type="radio" class="btn-group btn-group-yesno" default="0" filter="INT">';
|
||||
$xml .= '<option value="1">'.JText::_('COM_COMPONENTBUILDER_YES').'</option> <option value="0">'.JText::_('COM_COMPONENTBUILDER_NO').'</option>';
|
||||
$xml .= "</field>";
|
||||
// prepare the xml
|
||||
$sleutle = new SimpleXMLElement($xml);
|
||||
$force = new SimpleXMLElement($xml);
|
||||
// set components to form
|
||||
$text1->setup($sleutle,'');
|
||||
$radio1->setup($force,0);
|
||||
// add to form
|
||||
$form[] = $text1;
|
||||
$form[] = $radio1;
|
||||
|
||||
$radio2 = JFormHelper::loadFieldType('radio',true);
|
||||
// Switch to show more information about the import
|
||||
$xml = '<field label="'.JText::_('COM_COMPONENTBUILDER_QUITE').'" description="'.JText::_('COM_COMPONENTBUILDER_SELECT_IF_THE_IMPORT_SHOULD_BE_SHOWING_MORE_OR_LESS_INFORMATION_DURING_IMPORT').'" name="more_info" type="radio" class="btn-group btn-group-yesno" default="0" filter="INT">';
|
||||
$xml .= '<option value="0">'.JText::_('COM_COMPONENTBUILDER_YES').'</option> <option value="1">'.JText::_('COM_COMPONENTBUILDER_NO').'</option>';
|
||||
$xml .= "</field>";
|
||||
// prepare the xml
|
||||
$information = new SimpleXMLElement($xml);
|
||||
// set information to form
|
||||
$radio2->setup($information,0);
|
||||
// add to form
|
||||
$form[] = $radio2;
|
||||
|
||||
if (!$this->packageInfo || (isset($this->packageInfo['getKeyFrom']) && ComponentbuilderHelper::checkArray($this->packageInfo['getKeyFrom'])))
|
||||
{
|
||||
// set required field
|
||||
$required = 'required="true"';
|
||||
if (!$this->packageInfo)
|
||||
{
|
||||
$radio2 = JFormHelper::loadFieldType('radio',true);
|
||||
// has key
|
||||
$xml = '<field label="'.JText::_('COM_COMPONENTBUILDER_USE_KEY').'" description="'.JText::_('COM_COMPONENTBUILDER_DOES_THIS_PACKAGE_REQUIRE_A_KEY_TO_INSTALL').'" name="haskey" type="radio" class="btn-group btn-group-yesno" default="1" filter="INT">';
|
||||
$xml .= '<option value="1">'.JText::_('COM_COMPONENTBUILDER_YES').'</option> <option value="0">'.JText::_('COM_COMPONENTBUILDER_NO').'</option>';
|
||||
$xml .= "</field>";
|
||||
// prepare the xml
|
||||
$license = new SimpleXMLElement($xml);
|
||||
// set components to form
|
||||
$radio2->setup($license,1);
|
||||
$required = ''; // change required field
|
||||
// add to form
|
||||
$form[] = $radio2;
|
||||
}
|
||||
|
||||
$text1 = JFormHelper::loadFieldType('text',true);
|
||||
// add the key
|
||||
$xml = '<field type="password" label="'.JText::_('COM_COMPONENTBUILDER_KEY').'" description="'.JText::_('COM_COMPONENTBUILDER_THE_KEY_OF_THIS_PACKAGE').'" name="sleutle" autocomplete="false" class="text_area" filter="STRING" hint="add key here" '.$required.' />';
|
||||
// prepare the xml
|
||||
$sleutle = new SimpleXMLElement($xml);
|
||||
// set components to form
|
||||
$text1->setup($sleutle,'');
|
||||
// add to form
|
||||
$form[] = $text1;
|
||||
}
|
||||
}
|
||||
elseif ('vdm_package' === $type && $listObjects = ComponentbuilderHelper::getGithubRepoFileList('jcbGithubPackages', ComponentbuilderHelper::$jcbGithubPackagesUrl.ComponentbuilderHelper::$accessToken))
|
||||
{
|
||||
if (ComponentbuilderHelper::checkArray($listObjects))
|
||||
{
|
||||
// load the vdm packages if available
|
||||
$list = JFormHelper::loadFieldType('list',true);
|
||||
// load the list
|
||||
$load = false;
|
||||
// start building componet xml field
|
||||
$xml = '<field label="Package" description="'.JText::_('COM_COMPONENTBUILDER_SELECT_THE_PACKAGE_TO_IMPORT').'" name="vdm_package" type="list" class="list_class">';
|
||||
$xml .= '<option value="">'.JText::_('COM_COMPONENTBUILDER__SELECT_PACKAGE_').'</option>';
|
||||
foreach($listObjects as $listObject)
|
||||
{
|
||||
if (strpos($listObject->path, '.zip') !== false)
|
||||
{
|
||||
$xml .= '<option value="'.ComponentbuilderHelper::$jcbGithubPackageUrl.$listObject->path.'">'.$this->setPackageName($listObject->path).'</option>';
|
||||
$load = true;
|
||||
}
|
||||
}
|
||||
$xml .= "</field>";
|
||||
// only load if at least one item was found
|
||||
if ($load)
|
||||
{
|
||||
// prepare the xml
|
||||
$packages = new SimpleXMLElement($xml);
|
||||
// set components to form
|
||||
$list->setup($packages, '');
|
||||
|
||||
// set to form
|
||||
$form[] = $list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function setPackageName($name)
|
||||
{
|
||||
return ComponentbuilderHelper::safeString( preg_replace('/(?<!^)([A-Z])/', '-\ \1', str_replace(array('.zip', 'JCB_'), '', $name)), 'W');
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting the toolbar
|
||||
*/
|
||||
|
Reference in New Issue
Block a user