Added more dynamic behavior to the new plugin area. Added a funding yml file.

This commit is contained in:
2019-07-17 01:15:42 +02:00
parent eae07504fa
commit 8d2af8365b
31 changed files with 573 additions and 32 deletions

View File

@ -2402,6 +2402,34 @@ class ComponentbuilderModelAjax extends JModelList
'views' => 'validation_rules',
'not_base64' => array(),
'name' => 'name'
),
// #__componentbuilder_joomla_plugin (q)
'joomla_plugin' => array(
'search' => array('id', 'name', 'main_class_code'),
'views' => 'joomla_plugins',
'not_base64' => array(),
'name' => 'name'
),
// #__componentbuilder_class_extends (r)
'class_extends' => array(
'search' => array('id', 'name', 'head', 'comment'),
'views' => 'class_extendings',
'not_base64' => array(),
'name' => 'name'
),
// #__componentbuilder_class_property (s)
'class_property' => array(
'search' => array('id', 'name', 'default', 'comment'),
'views' => 'class_properties',
'not_base64' => array(),
'name' => 'name'
),
// #__componentbuilder_class_method (t)
'class_method' => array(
'search' => array('id', 'name', 'code', 'comment'),
'views' => 'class_methods',
'not_base64' => array(),
'name' => 'name'
)
);

View File

@ -70,7 +70,19 @@ class ComponentbuilderModelClass_extends extends JModelAdmin
$this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_componentbuilder/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/**
* get VDM session key
*
* @return string the session key
*
*/
public function getVDM()
{
return $this->vastDevMod;
}
/**
* Method to get a single record.
@ -111,6 +123,32 @@ class ComponentbuilderModelClass_extends extends JModelAdmin
{
// base64 Decode comment.
$item->comment = base64_decode($item->comment);
}
if (empty($item->id))
{
$id = 0;
}
else
{
$id = $item->id;
}
// set the id and view name to session
if ($vdm = ComponentbuilderHelper::get('class_extends__'.$id))
{
$this->vastDevMod = $vdm;
}
else
{
// set the vast development method key
$this->vastDevMod = ComponentbuilderHelper::randomkey(50);
ComponentbuilderHelper::set($this->vastDevMod, 'class_extends__'.$id);
ComponentbuilderHelper::set('class_extends__'.$id, $this->vastDevMod);
// set a return value if found
$jinput = JFactory::getApplication()->input;
$return = $jinput->get('return', null, 'base64');
ComponentbuilderHelper::set($this->vastDevMod . '__return', $return);
}
if (!empty($item->id))

View File

@ -73,7 +73,19 @@ class ComponentbuilderModelClass_method extends JModelAdmin
$this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_componentbuilder/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/**
* get VDM session key
*
* @return string the session key
*
*/
public function getVDM()
{
return $this->vastDevMod;
}
/**
* Method to get a single record.
@ -120,6 +132,32 @@ class ComponentbuilderModelClass_method extends JModelAdmin
{
// base64 Decode arguments.
$item->arguments = base64_decode($item->arguments);
}
if (empty($item->id))
{
$id = 0;
}
else
{
$id = $item->id;
}
// set the id and view name to session
if ($vdm = ComponentbuilderHelper::get('class_method__'.$id))
{
$this->vastDevMod = $vdm;
}
else
{
// set the vast development method key
$this->vastDevMod = ComponentbuilderHelper::randomkey(50);
ComponentbuilderHelper::set($this->vastDevMod, 'class_method__'.$id);
ComponentbuilderHelper::set('class_method__'.$id, $this->vastDevMod);
// set a return value if found
$jinput = JFactory::getApplication()->input;
$return = $jinput->get('return', null, 'base64');
ComponentbuilderHelper::set($this->vastDevMod . '__return', $return);
}
if (!empty($item->id))

View File

@ -70,7 +70,19 @@ class ComponentbuilderModelClass_property extends JModelAdmin
$this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_componentbuilder/tables');
// get instance of the table
return JTable::getInstance($type, $prefix, $config);
}
/**
* get VDM session key
*
* @return string the session key
*
*/
public function getVDM()
{
return $this->vastDevMod;
}
/**
* Method to get a single record.
@ -111,6 +123,32 @@ class ComponentbuilderModelClass_property extends JModelAdmin
{
// base64 Decode default.
$item->default = base64_decode($item->default);
}
if (empty($item->id))
{
$id = 0;
}
else
{
$id = $item->id;
}
// set the id and view name to session
if ($vdm = ComponentbuilderHelper::get('class_property__'.$id))
{
$this->vastDevMod = $vdm;
}
else
{
// set the vast development method key
$this->vastDevMod = ComponentbuilderHelper::randomkey(50);
ComponentbuilderHelper::set($this->vastDevMod, 'class_property__'.$id);
ComponentbuilderHelper::set('class_property__'.$id, $this->vastDevMod);
// set a return value if found
$jinput = JFactory::getApplication()->input;
$return = $jinput->get('return', null, 'base64');
ComponentbuilderHelper::set($this->vastDevMod . '__return', $return);
}
if (!empty($item->id))

View File

@ -8,4 +8,52 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
jQuery(document).ready(function()
{
// load the used in div
// jQuery('#usedin').show();
// check and load all the customcode edit buttons
setTimeout(getEditCustomCodeButtons, 300);
});
function getEditCustomCodeButtons_server(id){
var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod);
if(token.length > 0 && id > 0){
var request = token+'=1&id='+id+'&return_here='+return_here;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
dataType: 'json',
data: request,
jsonp: false
});
}
function getEditCustomCodeButtons(){
// get the id
id = jQuery("#jform_id").val();
getEditCustomCodeButtons_server(id).done(function(result) {
if(isObject(result)){
jQuery.each(result, function( field, buttons ) {
jQuery('<div class="control-group"><div class="control-label"><label>Add/Edit Customcode</label></div><div class="controls control-customcode-buttons-'+field+'"></div></div>').insertBefore(".control-wrapper-"+ field);
jQuery.each(buttons, function( name, button ) {
jQuery(".control-customcode-buttons-"+field).append(button);
});
});
}
})
}
// check object is not empty
function isObject(obj) {
for(var prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
return true;
}
}
return false;
}

View File

@ -108,4 +108,52 @@ function isSet(val)
return true;
}
return false;
}
jQuery(document).ready(function()
{
// load the used in div
// jQuery('#usedin').show();
// check and load all the customcode edit buttons
setTimeout(getEditCustomCodeButtons, 300);
});
function getEditCustomCodeButtons_server(id){
var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod);
if(token.length > 0 && id > 0){
var request = token+'=1&id='+id+'&return_here='+return_here;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
dataType: 'json',
data: request,
jsonp: false
});
}
function getEditCustomCodeButtons(){
// get the id
id = jQuery("#jform_id").val();
getEditCustomCodeButtons_server(id).done(function(result) {
if(isObject(result)){
jQuery.each(result, function( field, buttons ) {
jQuery('<div class="control-group"><div class="control-label"><label>Add/Edit Customcode</label></div><div class="controls control-customcode-buttons-'+field+'"></div></div>').insertBefore(".control-wrapper-"+ field);
jQuery.each(buttons, function( name, button ) {
jQuery(".control-customcode-buttons-"+field).append(button);
});
});
}
})
}
// check object is not empty
function isObject(obj) {
for(var prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
return true;
}
}
return false;
}

View File

@ -108,4 +108,52 @@ function isSet(val)
return true;
}
return false;
}
jQuery(document).ready(function()
{
// load the used in div
// jQuery('#usedin').show();
// check and load all the customcode edit buttons
setTimeout(getEditCustomCodeButtons, 300);
});
function getEditCustomCodeButtons_server(id){
var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod);
if(token.length > 0 && id > 0){
var request = token+'=1&id='+id+'&return_here='+return_here;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
dataType: 'json',
data: request,
jsonp: false
});
}
function getEditCustomCodeButtons(){
// get the id
id = jQuery("#jform_id").val();
getEditCustomCodeButtons_server(id).done(function(result) {
if(isObject(result)){
jQuery.each(result, function( field, buttons ) {
jQuery('<div class="control-group"><div class="control-label"><label>Add/Edit Customcode</label></div><div class="controls control-customcode-buttons-'+field+'"></div></div>').insertBefore(".control-wrapper-"+ field);
jQuery.each(buttons, function( name, button ) {
jQuery(".control-customcode-buttons-"+field).append(button);
});
});
}
})
}
// check object is not empty
function isObject(obj) {
for(var prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
return true;
}
}
return false;
}

View File

@ -313,8 +313,8 @@ function usedin(functioName, ide) {
jQuery('#note-usedin-not').hide();
jQuery('#note-usedin-found').hide();
jQuery('#loading-usedin').show();
var targets = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p']; // if you update this, also update (below 15) & [customcode-codeUsedInHtmlNote]!
var targetNumber = 15;
var targets = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t']; // if you update this, also update (below 19) & [customcode-codeUsedInHtmlNote]!
var targetNumber = 19;
var run = 0;
var usedinChecker = setInterval(function(){
var target = targets[run];

View File

@ -162,6 +162,8 @@ function isSet(val)
jQuery(document).ready(function()
{
// get the linked details
getLinked();
// load the active array values
buildSelectionArray('property');
buildSelectionArray('method');
@ -176,11 +178,9 @@ jQuery(document).ready(function()
getClassCodeIds('joomla_plugin_group', 'jform_class_extends', false);
getClassCodeIds('property', 'jform_joomla_plugin_group', false);
getClassCodeIds('method', 'jform_joomla_plugin_group', false);
// load the used in div
// jQuery('#usedin').show();
// check and load all the customcode edit buttons
// setTimeout(getEditCustomCodeButtons, 300);
setTimeout(getEditCustomCodeButtons, 300);
// trigger the row watcher
rowWatcher();
});
@ -291,7 +291,7 @@ function getClassCode(field, type){
jQuery.UIkit.notify({message: Joomla.JText._('COM_COMPONENTBUILDER_ALREADY_SELECTED_TRY_ANOTHER'), timeout: 5000, status: 'warning', pos: 'top-center'});
} else {
// set the active removed value
selectedIdRemoved[type] = value;
selectedIdRemoved[type] = id;
// do a dynamic update (to remove what was already used)
selectionDynamicUpdate(type);
// now get the code
@ -414,6 +414,31 @@ function rowWatcher() {
if (isSet(valid_call)){
selectedIdRemoved[type_call] = valid_call;
selectionDynamicUpdate(type_call);
// also remove from code
var valid_value = jQuery(row.innerHTML).find('#' + valid_call + ' option:selected').val();
getClassStuff_server(valid_value, type_call, 'getClassCode').done(function(result) {
if(result){
if (Joomla.editors.instances.hasOwnProperty("jform_main_class_code")) {
var old_result = Joomla.editors.instances['jform_main_class_code'].getValue();
if (old_result.length > 0) {
// make sure not to load the same string twice
if (old_result.indexOf(result) !== -1) {
// remove the code
Joomla.editors.instances['jform_main_class_code'].setValue(old_result.replace(result+"\n\n",'').replace("\n\n"+result,'').replace(result,''));
}
}
} else {
var old_result = jQuery('textarea#jform_main_class_code').val();
if (old_result.length > 0) {
// make sure not to load the same string twice
if (old_result.indexOf(result) !== -1) {
// remove the code
jQuery('textarea#jform_main_class_code').val(old_result.replace(result+"\n\n",'').replace("\n\n"+result,'').replace(result,''));
}
}
}
}
});
}
});
jQuery(document).on('subform-row-add', function(event, row){
@ -451,6 +476,28 @@ function propertyIsSet(prop, id, type) {
return false;
}
function getLinked_server(type){
var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getLinked&format=json&raw=true&vdm="+vastDevMod);
if(token.length > 0 && type > 0){
var request = token+'=1&type='+type;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
dataType: 'json',
data: request,
jsonp: false
});
}
function getLinked(){
getLinked_server(1).done(function(result) {
if(result){
jQuery('#display_linked_to').html(result);
}
});
}
function getEditCustomCodeButtons_server(id){
var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod);
if(token.length > 0 && id > 0){

View File

@ -162,6 +162,8 @@
/>
</form>
</field>
<!-- Note_linked_to_notice Field. Type: Note. A None Database Field. (joomla) -->
<field type="note" name="note_linked_to_notice" label="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_NOTE_LINKED_TO_NOTICE_LABEL" description="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_NOTE_LINKED_TO_NOTICE_DESCRIPTION" heading="h4" class="note_linked_to_notice" />
<!-- Main_class_code Field. Type: Editor. (joomla) -->
<field
type="editor"
@ -189,7 +191,7 @@
description="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_METHOD_SELECTION_DESCRIPTION"
icon="list"
max="150"
min="1">
min="0">
<form hidden="true" name="list_method_selection_modal" repeat="true">
<!-- Method Field. Type: Pluginsclassmethods. (custom) -->
<field
@ -215,7 +217,7 @@
description="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PROPERTY_SELECTION_DESCRIPTION"
icon="list"
max="150"
min="1">
min="0">
<form hidden="true" name="list_property_selection_modal" repeat="true">
<!-- Property Field. Type: Pluginsclassproperties. (custom) -->
<field

View File

@ -78,8 +78,8 @@ function placedin(placeholder, ide) {
jQuery('#note-placedin-not').hide();
jQuery('#note-placedin-found').hide();
jQuery('#loading-placedin').show();
var targets = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p']; // if you update this, also update (below 15) & [customcode-codeUsedInHtmlNote]!
var targetNumber = 15;
var targets = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t']; // if you update this, also update (below 19) & [customcode-codeUsedInHtmlNote]!
var targetNumber = 19;
var run = 0;
var placedinChecker = setInterval(function(){
var target = targets[run];

View File

@ -1821,6 +1821,34 @@ class ComponentbuilderModelJoomla_components extends JModelList
'views' => 'validation_rules',
'not_base64' => array(),
'name' => 'name'
),
// #__componentbuilder_joomla_plugin (q)
'joomla_plugin' => array(
'search' => array('id', 'name', 'main_class_code'),
'views' => 'joomla_plugins',
'not_base64' => array(),
'name' => 'name'
),
// #__componentbuilder_class_extends (r)
'class_extends' => array(
'search' => array('id', 'name', 'head', 'comment'),
'views' => 'class_extendings',
'not_base64' => array(),
'name' => 'name'
),
// #__componentbuilder_class_property (s)
'class_property' => array(
'search' => array('id', 'name', 'default', 'comment'),
'views' => 'class_properties',
'not_base64' => array(),
'name' => 'name'
),
// #__componentbuilder_class_method (t)
'class_method' => array(
'search' => array('id', 'name', 'code', 'comment'),
'views' => 'class_methods',
'not_base64' => array(),
'name' => 'name'
)
);

View File

@ -35,7 +35,8 @@ class ComponentbuilderModelJoomla_plugin extends JModelAdmin
'method_selection'
),
'fullwidth' => array(
'main_class_code'
'main_class_code',
'note_linked_to_notice'
),
'above' => array(
'name',
@ -882,8 +883,12 @@ class ComponentbuilderModelJoomla_plugin extends JModelAdmin
$data['metadata'] = (string) $metadata;
}
// make sure the name is safe to be used as a function name
$data['name'] = ComponentbuilderHelper::safeClassFunctionName($data['name']);
// check if the name has placeholder
if (strpos($data['name'], '[[[') === false && strpos($data['name'], '###') === false)
{
// make sure the name is safe to be used as a function name
$data['name'] = ComponentbuilderHelper::safeClassFunctionName($data['name']);
}
// Set the fields items to data.
if (isset($data['fields']) && is_array($data['fields']))