Added create new custom code to all fields that have string lenght.

This commit is contained in:
Llewellyn van der Merwe 2019-05-16 00:50:45 +02:00
parent 80c588a33a
commit 8e79417664
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
18 changed files with 59 additions and 44 deletions

View File

@ -150,7 +150,7 @@ TODO
+ *Version*: 2.9.18 + *Version*: 2.9.18
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **206359** + *Line count*: **206374**
+ *Field count*: **1136** + *Field count*: **1136**
+ *File count*: **1344** + *File count*: **1344**
+ *Folder count*: **209** + *Folder count*: **209**

View File

@ -150,7 +150,7 @@ TODO
+ *Version*: 2.9.18 + *Version*: 2.9.18
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **206359** + *Line count*: **206374**
+ *Field count*: **1136** + *Field count*: **1136**
+ *File count*: **1344** + *File count*: **1344**
+ *Folder count*: **209** + *Folder count*: **209**

View File

@ -315,6 +315,7 @@ class ComponentbuilderModelAjax extends JModelList
'component_config' => 'components_config', 'component_config' => 'components_config',
'component_dashboard' => 'components_dashboard', 'component_dashboard' => 'components_dashboard',
'component_files_folders' => 'components_files_folders', 'component_files_folders' => 'components_files_folders',
'custom_code' => 'custom_codes',
'language' => true); 'language' => true);
public function getButton($type, $size) public function getButton($type, $size)
@ -341,11 +342,16 @@ class ComponentbuilderModelAjax extends JModelList
$ref = '&ref=' . $values['a_view'] . '&refid=' . $values['a_id'] . '&return=' . urlencode(base64_encode($return_url)); $ref = '&ref=' . $values['a_view'] . '&refid=' . $values['a_id'] . '&return=' . urlencode(base64_encode($return_url));
} }
// build url (A tag) // build url (A tag)
$startAtag = '<a class="btn btn-success vdm-button-new" onclick="UIkit2.modal.confirm(\''.JText::_('COM_COMPONENTBUILDER_ALL_UNSAVED_WORK_ON_THIS_PAGE_WILL_BE_LOST_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE').'\', function(){ window.location.href = \'index.php?option=com_componentbuilder&amp;view=' . $type . '&amp;layout=edit' . $ref . '\' })" href="javascript:void(0)" title="'.JText::sprintf('COM_COMPONENTBUILDER_CREATE_NEW_S', ComponentbuilderHelper::safeString($type, 'W')).'">'; $startAtag = 'onclick="UIkit2.modal.confirm(\''.JText::_('COM_COMPONENTBUILDER_ALL_UNSAVED_WORK_ON_THIS_PAGE_WILL_BE_LOST_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE').'\', function(){ window.location.href = \'index.php?option=com_componentbuilder&amp;view=' . $type . '&amp;layout=edit' . $ref . '\' })" href="javascript:void(0)" title="'.JText::sprintf('COM_COMPONENTBUILDER_CREATE_NEW_S', ComponentbuilderHelper::safeString($type, 'W')).'">';
// build the smaller button // build the smallest button
if (2 == $size) if (3 == $size)
{ {
$button = $startAtag.'<span class="icon-new icon-white"></span> ' . JText::_('COM_COMPONENTBUILDER_CREATE') . '</a>'; $button = '<a class="btn btn-small btn-success" style="margin: 0 0 5px 0;" ' . $startAtag.'<span class="icon-new icon-white"></span></a>';
}
// build the smaller button
elseif (2 == $size)
{
$button = '<a class="btn btn-success vdm-button-new" ' . $startAtag . '<span class="icon-new icon-white"></span> ' . JText::_('COM_COMPONENTBUILDER_CREATE') . '</a>';
} }
else else
// build the big button // build the big button
@ -354,7 +360,7 @@ class ComponentbuilderModelAjax extends JModelList
<div class="control-label"> <div class="control-label">
<label>' . ucwords($type) . '</label> <label>' . ucwords($type) . '</label>
</div> </div>
<div class="controls"> '.$startAtag.' <div class="controls"><a class="btn btn-success vdm-button-new" ' . $startAtag . '
<span class="icon-new icon-white"></span> <span class="icon-new icon-white"></span>
' . JText::_('COM_COMPONENTBUILDER_NEW') . ' ' . JText::_('COM_COMPONENTBUILDER_NEW') . '
</a> </a>
@ -1934,6 +1940,23 @@ class ComponentbuilderModelAjax extends JModelList
// only continue if this is a legitimate call // only continue if this is a legitimate call
if (isset($view['a_id']) && $view['a_id'] == $id && isset($view['a_view']) && ($target = $this->getCodeSearchKeys($view['a_view'], 'query_')) !== false) if (isset($view['a_id']) && $view['a_id'] == $id && isset($view['a_view']) && ($target = $this->getCodeSearchKeys($view['a_view'], 'query_')) !== false)
{ {
// reset the buttons bucket
$buttons = array();
// some helper for some fields
$helper = array('xml' => 'note_select_field_type');
// get input
$jinput = JFactory::getApplication()->input;
$return_here = $jinput->get('return_here', null, 'base64');
// set the return here value if not found
if (ComponentbuilderHelper::checkString($return_here))
{
$return_here = '&return=' . $return_here;
}
else
{
$return_here = '&ref=' . $view['a_view'] . '&refid=' . (int) $id;
}
// start db query
$db = JFactory::getDbo(); $db = JFactory::getDbo();
$query = $db->getQuery(true) $query = $db->getQuery(true)
->select($db->quoteName($target['select'])) ->select($db->quoteName($target['select']))
@ -1944,8 +1967,6 @@ class ComponentbuilderModelAjax extends JModelList
if ($db->loadRowList()) if ($db->loadRowList())
{ {
$data = $db->loadAssoc(); $data = $db->loadAssoc();
// some helper for some fields
$helper = array('xml' => 'note_select_field_type');
// reset the bucket // reset the bucket
$bucket = array(); $bucket = array();
foreach ($data as $key => $value) foreach ($data as $key => $value)
@ -1973,25 +1994,20 @@ class ComponentbuilderModelAjax extends JModelList
// get all custom codes in value // get all custom codes in value
$bucket[$key] = ComponentbuilderHelper::getAllBetween($value, '[CUSTOMC' . 'ODE=', ']'); $bucket[$key] = ComponentbuilderHelper::getAllBetween($value, '[CUSTOMC' . 'ODE=', ']');
} }
// check if field has string length
if (ComponentbuilderHelper::checkString($value))
{
$buttons[$key] = array();
if (($button = $this->getButton('custom_code', 3)) && ComponentbuilderHelper::checkString($button))
{
$buttons[$key]['_create'] = $button;
}
}
} }
} }
// check if any values found // check if any values found
if (ComponentbuilderHelper::checkArray($bucket)) if (ComponentbuilderHelper::checkArray($bucket))
{ {
// get input
$jinput = JFactory::getApplication()->input;
$return_here = $jinput->get('return_here', null, 'base64');
// set the return here value if not found
if (ComponentbuilderHelper::checkString($return_here))
{
$return_here = '&return=' . $return_here;
}
else
{
$return_here = '&ref=' . $view['a_view'] . '&refid=' . (int) $id;
}
// reset the buttons bucket
$buttons = array();
foreach ($bucket as $field => $customcodes) foreach ($bucket as $field => $customcodes)
{ {
$edit_icon = '<span class="icon-edit" aria-hidden="true"></span> '; $edit_icon = '<span class="icon-edit" aria-hidden="true"></span> ';
@ -2000,7 +2016,6 @@ class ComponentbuilderModelAjax extends JModelList
{ {
$field = $helper[$field]; $field = $helper[$field];
} }
$buttons[$field] = array();
foreach ($customcodes as $customcode) foreach ($customcodes as $customcode)
{ {
$key = (array) explode('+', $customcode); $key = (array) explode('+', $customcode);
@ -2012,13 +2027,13 @@ class ComponentbuilderModelAjax extends JModelList
} }
} }
} }
// only continue if we have buttons in array
if (ComponentbuilderHelper::checkArray($buttons, true))
{
return $buttons;
}
} }
} }
// only continue if we have buttons in array
if (ComponentbuilderHelper::checkArray($buttons, true))
{
return $buttons;
}
} }
return false; return false;
} }

View File

@ -93,7 +93,7 @@ function getEditCustomCodeButtons(){
getEditCustomCodeButtons_server(id).done(function(result) { getEditCustomCodeButtons_server(id).done(function(result) {
if(isObject(result)){ if(isObject(result)){
jQuery.each(result, function( field, buttons ) { jQuery.each(result, function( field, buttons ) {
jQuery('<div class="control-group"><div class="control-label"><label>Edit Customcode</label></div><div class="controls control-customcode-buttons-'+field+'"></div></div>').insertBefore(".control-wrapper-"+ field); 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.each(buttons, function( name, button ) {
jQuery(".control-customcode-buttons-"+field).append(button); jQuery(".control-customcode-buttons-"+field).append(button);
}); });

View File

@ -1507,7 +1507,7 @@ function getEditCustomCodeButtons(){
getEditCustomCodeButtons_server(id).done(function(result) { getEditCustomCodeButtons_server(id).done(function(result) {
if(isObject(result)){ if(isObject(result)){
jQuery.each(result, function( field, buttons ) { jQuery.each(result, function( field, buttons ) {
jQuery('<div class="control-group"><div class="control-label"><label>Edit Customcode</label></div><div class="controls control-customcode-buttons-'+field+'"></div></div>').insertBefore(".control-wrapper-"+ field); 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.each(buttons, function( name, button ) {
jQuery(".control-customcode-buttons-"+field).append(button); jQuery(".control-customcode-buttons-"+field).append(button);
}); });

View File

@ -37,7 +37,7 @@ function getEditCustomCodeButtons(){
getEditCustomCodeButtons_server(id).done(function(result) { getEditCustomCodeButtons_server(id).done(function(result) {
if(isObject(result)){ if(isObject(result)){
jQuery.each(result, function( field, buttons ) { jQuery.each(result, function( field, buttons ) {
jQuery('<div class="control-group"><div class="control-label"><label>Edit Customcode</label></div><div class="controls control-customcode-buttons-'+field+'"></div></div>').insertBefore(".control-wrapper-"+ field); 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.each(buttons, function( name, button ) {
jQuery(".control-customcode-buttons-"+field).append(button); jQuery(".control-customcode-buttons-"+field).append(button);
}); });

View File

@ -686,7 +686,7 @@ function getEditCustomCodeButtons(){
getEditCustomCodeButtons_server(id).done(function(result) { getEditCustomCodeButtons_server(id).done(function(result) {
if(isObject(result)){ if(isObject(result)){
jQuery.each(result, function( field, buttons ) { jQuery.each(result, function( field, buttons ) {
jQuery('<div class="control-group"><div class="control-label"><label>Edit Customcode</label></div><div class="controls control-customcode-buttons-'+field+'"></div></div>').insertBefore(".control-wrapper-"+ field); 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.each(buttons, function( name, button ) {
jQuery(".control-customcode-buttons-"+field).append(button); jQuery(".control-customcode-buttons-"+field).append(button);
}); });

View File

@ -377,7 +377,7 @@ function getEditCustomCodeButtons(){
getEditCustomCodeButtons_server(id).done(function(result) { getEditCustomCodeButtons_server(id).done(function(result) {
if(isObject(result)){ if(isObject(result)){
jQuery.each(result, function( field, buttons ) { jQuery.each(result, function( field, buttons ) {
jQuery('<div class="control-group"><div class="control-label"><label>Edit Customcode</label></div><div class="controls control-customcode-buttons-'+field+'"></div></div>').insertBefore(".control-wrapper-"+ field); 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.each(buttons, function( name, button ) {
jQuery(".control-customcode-buttons-"+field).append(button); jQuery(".control-customcode-buttons-"+field).append(button);
}); });

View File

@ -1744,7 +1744,7 @@ function getEditCustomCodeButtons(){
getEditCustomCodeButtons_server(id).done(function(result) { getEditCustomCodeButtons_server(id).done(function(result) {
if(isObject(result)){ if(isObject(result)){
jQuery.each(result, function( field, buttons ) { jQuery.each(result, function( field, buttons ) {
jQuery('<div class="control-group"><div class="control-label"><label>Edit Customcode</label></div><div class="controls control-customcode-buttons-'+field+'"></div></div>').insertBefore(".control-wrapper-"+ field); 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.each(buttons, function( name, button ) {
jQuery(".control-customcode-buttons-"+field).append(button); jQuery(".control-customcode-buttons-"+field).append(button);
}); });

View File

@ -873,7 +873,7 @@ function getEditCustomCodeButtons(){
getEditCustomCodeButtons_server(id).done(function(result) { getEditCustomCodeButtons_server(id).done(function(result) {
if(isObject(result)){ if(isObject(result)){
jQuery.each(result, function( field, buttons ) { jQuery.each(result, function( field, buttons ) {
jQuery('<div class="control-group"><div class="control-label"><label>Edit Customcode</label></div><div class="controls control-customcode-buttons-'+field+'"></div></div>').insertBefore(".control-wrapper-"+ field); 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.each(buttons, function( name, button ) {
jQuery(".control-customcode-buttons-"+field).append(button); jQuery(".control-customcode-buttons-"+field).append(button);
}); });

View File

@ -829,7 +829,7 @@ function getEditCustomCodeButtons(){
getEditCustomCodeButtons_server(id).done(function(result) { getEditCustomCodeButtons_server(id).done(function(result) {
if(isObject(result)){ if(isObject(result)){
jQuery.each(result, function( field, buttons ) { jQuery.each(result, function( field, buttons ) {
jQuery('<div class="control-group"><div class="control-label"><label>Edit Customcode</label></div><div class="controls control-customcode-buttons-'+field+'"></div></div>').insertBefore(".control-wrapper-"+ field); 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.each(buttons, function( name, button ) {
jQuery(".control-customcode-buttons-"+field).append(button); jQuery(".control-customcode-buttons-"+field).append(button);
}); });

View File

@ -1184,7 +1184,7 @@ function getEditCustomCodeButtons(){
getEditCustomCodeButtons_server(id).done(function(result) { getEditCustomCodeButtons_server(id).done(function(result) {
if(isObject(result)){ if(isObject(result)){
jQuery.each(result, function( field, buttons ) { jQuery.each(result, function( field, buttons ) {
jQuery('<div class="control-group"><div class="control-label"><label>Edit Customcode</label></div><div class="controls control-customcode-buttons-'+field+'"></div></div>').insertBefore(".control-wrapper-"+ field); 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.each(buttons, function( name, button ) {
jQuery(".control-customcode-buttons-"+field).append(button); jQuery(".control-customcode-buttons-"+field).append(button);
}); });

View File

@ -113,7 +113,7 @@ function getEditCustomCodeButtons(){
getEditCustomCodeButtons_server(id).done(function(result) { getEditCustomCodeButtons_server(id).done(function(result) {
if(isObject(result)){ if(isObject(result)){
jQuery.each(result, function( field, buttons ) { jQuery.each(result, function( field, buttons ) {
jQuery('<div class="control-group"><div class="control-label"><label>Edit Customcode</label></div><div class="controls control-customcode-buttons-'+field+'"></div></div>').insertBefore(".control-wrapper-"+ field); 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.each(buttons, function( name, button ) {
jQuery(".control-customcode-buttons-"+field).append(button); jQuery(".control-customcode-buttons-"+field).append(button);
}); });

View File

@ -491,7 +491,7 @@ function getEditCustomCodeButtons(){
getEditCustomCodeButtons_server(id).done(function(result) { getEditCustomCodeButtons_server(id).done(function(result) {
if(isObject(result)){ if(isObject(result)){
jQuery.each(result, function( field, buttons ) { jQuery.each(result, function( field, buttons ) {
jQuery('<div class="control-group"><div class="control-label"><label>Edit Customcode</label></div><div class="controls control-customcode-buttons-'+field+'"></div></div>').insertBefore(".control-wrapper-"+ field); 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.each(buttons, function( name, button ) {
jQuery(".control-customcode-buttons-"+field).append(button); jQuery(".control-customcode-buttons-"+field).append(button);
}); });

View File

@ -727,7 +727,7 @@ function getEditCustomCodeButtons(){
getEditCustomCodeButtons_server(id).done(function(result) { getEditCustomCodeButtons_server(id).done(function(result) {
if(isObject(result)){ if(isObject(result)){
jQuery.each(result, function( field, buttons ) { jQuery.each(result, function( field, buttons ) {
jQuery('<div class="control-group"><div class="control-label"><label>Edit Customcode</label></div><div class="controls control-customcode-buttons-'+field+'"></div></div>').insertBefore(".control-wrapper-"+ field); 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.each(buttons, function( name, button ) {
jQuery(".control-customcode-buttons-"+field).append(button); jQuery(".control-customcode-buttons-"+field).append(button);
}); });

View File

@ -113,7 +113,7 @@ function getEditCustomCodeButtons(){
getEditCustomCodeButtons_server(id).done(function(result) { getEditCustomCodeButtons_server(id).done(function(result) {
if(isObject(result)){ if(isObject(result)){
jQuery.each(result, function( field, buttons ) { jQuery.each(result, function( field, buttons ) {
jQuery('<div class="control-group"><div class="control-label"><label>Edit Customcode</label></div><div class="controls control-customcode-buttons-'+field+'"></div></div>').insertBefore(".control-wrapper-"+ field); 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.each(buttons, function( name, button ) {
jQuery(".control-customcode-buttons-"+field).append(button); jQuery(".control-customcode-buttons-"+field).append(button);
}); });

View File

@ -117,7 +117,7 @@ function getEditCustomCodeButtons(){
getEditCustomCodeButtons_server(id).done(function(result) { getEditCustomCodeButtons_server(id).done(function(result) {
if(isObject(result)){ if(isObject(result)){
jQuery.each(result, function( field, buttons ) { jQuery.each(result, function( field, buttons ) {
jQuery('<div class="control-group"><div class="control-label"><label>Edit Customcode</label></div><div class="controls control-customcode-buttons-'+field+'"></div></div>').insertBefore(".control-wrapper-"+ field); 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.each(buttons, function( name, button ) {
jQuery(".control-customcode-buttons-"+field).append(button); jQuery(".control-customcode-buttons-"+field).append(button);
}); });