Fixed the javascript in the new relation area. Fixed gh-294 that hade count not array errors. Added the option to over-ride the column name in the new relation area.

This commit is contained in:
Llewellyn van der Merwe 2018-05-29 05:45:16 +02:00
parent f7be7ddad0
commit a7c3a6e8f2
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
16 changed files with 120 additions and 29 deletions

View File

@ -125,12 +125,12 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 26th May, 2018
+ *Last Build*: 29th May, 2018
+ *Version*: 2.8.0
+ *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **185523**
+ *Field count*: **1053**
+ *Line count*: **185583**
+ *Field count*: **1054**
+ *File count*: **1236**
+ *Folder count*: **197**

View File

@ -125,12 +125,12 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 26th May, 2018
+ *Last Build*: 29th May, 2018
+ *Version*: 2.8.0
+ *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **185523**
+ *Field count*: **1053**
+ *Line count*: **185583**
+ *Field count*: **1054**
+ *File count*: **1236**
+ *Folder count*: **197**

View File

@ -647,7 +647,7 @@ abstract class ###Component###Helper
}
}
// check if there are any view values remaining
if (count($_result))
if (count((array)$_result))
{
$_result = json_encode($_result);
$_result = array($_result);
@ -841,7 +841,7 @@ abstract class ###Component###Helper
**/
public static function checkArray($array, $removeEmptyString = false)
{
if (isset($array) && is_array($array) && count($array) > 0)
if (isset($array) && is_array($array) && count((array)$array) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
@ -944,7 +944,7 @@ abstract class ###Component###Helper
{
$initial = strlen($string);
$words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE);
$words_count = count($words);
$words_count = count((array)$words);
$word_length = 0;
$last_word = 0;

View File

@ -232,7 +232,7 @@ abstract class ###Component###Email
if (is_array($mailreply))
{
$mail->ClearReplyTos();
$numReplyTo = count($mailreply);
$numReplyTo = count((array)$mailreply);
for ($i=0; $i < $numReplyTo; $i++)
{
$mail->addReplyTo($mailreply[$i], $replyname[$i]);

View File

@ -293,7 +293,7 @@ abstract class ###Component###Helper
}
}
// check if there are any view values remaining
if (count($_result))
if (count((array)$_result))
{
$_result = json_encode($_result);
$_result = array($_result);
@ -833,7 +833,7 @@ abstract class ###Component###Helper
**/
public static function checkArray($array, $removeEmptyString = false)
{
if (isset($array) && is_array($array) && count($array) > 0)
if (isset($array) && is_array($array) && count((array)$array) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
@ -936,7 +936,7 @@ abstract class ###Component###Helper
{
$initial = strlen($string);
$words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE);
$words_count = count($words);
$words_count = count((array)$words);
$word_length = 0;
$last_word = 0;

View File

@ -501,6 +501,13 @@ class Get
*/
public $listJoinBuilder = array();
/**
* The list head over ride
*
* @var array
*/
public $listHeadOverRide = array();
/**
* The linked admin view tabs
*
@ -1683,6 +1690,7 @@ class Get
// prep the buckets
$this->fieldRelations[$name_list] = array();
$this->listJoinBuilder[$name_list] = array();
$this->listHeadOverRide[$name_list] = array();
// set the relations
$view->addrelations = (isset($view->addrelations) && ComponentbuilderHelper::checkJson($view->addrelations)) ? json_decode($view->addrelations, true) : null;
if (ComponentbuilderHelper::checkArray($view->addrelations))
@ -1708,6 +1716,18 @@ class Get
{
$this->listJoinBuilder[$name_list][(int) $join] = (int) $join;
}
// set header over-ride
if (isset($relationsValue['column_name']) && ComponentbuilderHelper::checkString($relationsValue['column_name']))
{
$check_column_name = trim(strtolower($relationsValue['column_name']));
// confirm it should really make the over ride
if ('default' !== $check_column_name)
{
$column_name_lang = ComponentbuilderHelper::safeString($name_list, 'U') . '_' . ComponentbuilderHelper::safeString($relationsValue['column_name'], 'U');
$this->langContent['admin'][$column_name_lang] = trim($relationsValue['column_name']);
$this->listHeadOverRide[$name_list][(int) $relationsValue['listfield']] = $column_name_lang;
}
}
}
}
}

View File

@ -6886,6 +6886,12 @@ class Interpretation extends Fields
// build the dynamic fields
foreach ($this->listBuilder[$viewName_list] as $item)
{
// check if we have an over-ride
if (isset($this->listHeadOverRide[$viewName_list]) && ComponentbuilderHelper::checkArray($this->listHeadOverRide[$viewName_list]) && isset($this->listHeadOverRide[$viewName_list][$item['id']]))
{
$item['lang'] = $this->listHeadOverRide[$viewName_list][$item['id']];
}
// set the custom code
if (ComponentbuilderHelper::checkArray($item['custom']))
{
$item['code'] = $item['code'] . '_' . $item['custom']['text'];
@ -7953,6 +7959,11 @@ class Interpretation extends Fields
// build the dynamic fields
foreach ($this->listBuilder[$viewName_list] as $item)
{
// check if we have an over-ride
if (isset($this->listHeadOverRide[$viewName_list]) && ComponentbuilderHelper::checkArray($this->listHeadOverRide[$viewName_list]) && isset($this->listHeadOverRide[$viewName_list][$item['id']]))
{
$item['lang'] = $this->listHeadOverRide[$viewName_list][$item['id']];
}
$setin = (2 == $this->footableVersion) ? ' data-hide="phone"' : ' data-breakpoints="xs sm"';
if ($controller > 3)
{

View File

@ -4625,7 +4625,7 @@ abstract class ComponentbuilderHelper
}
}
// check if there are any view values remaining
if (count($_result))
if (count((array)$_result))
{
$_result = json_encode($_result);
$_result = array($_result);
@ -4819,7 +4819,7 @@ abstract class ComponentbuilderHelper
**/
public static function checkArray($array, $removeEmptyString = false)
{
if (isset($array) && is_array($array) && count($array) > 0)
if (isset($array) && is_array($array) && count((array)$array) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
@ -4922,7 +4922,7 @@ abstract class ComponentbuilderHelper
{
$initial = strlen($string);
$words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE);
$words_count = count($words);
$words_count = count((array)$words);
$word_length = 0;
$last_word = 0;

View File

@ -215,7 +215,7 @@ abstract class ComponentbuilderEmail
if (is_array($mailreply))
{
$mail->ClearReplyTos();
$numReplyTo = count($mailreply);
$numReplyTo = count((array)$mailreply);
for ($i=0; $i < $numReplyTo; $i++)
{
$mail->addReplyTo($mailreply[$i], $replyname[$i]);

View File

@ -255,6 +255,9 @@ COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_ADMIN_VIEW="Admin View"
COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_ADMIN_VIEW_DESCRIPTION="Select an admin view"
COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_ADMIN_VIEW_LABEL="View"
COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_AREA_LABEL="Area"
COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_COLUMN_NAME_HINT="Default"
COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_COLUMN_NAME_LABEL="Table Column Name"
COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_COLUMN_NAME_MESSAGE="Error! Please add some text here."
COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_CONCATENATE_RAQUO_GLUE="Concatenate &raquo; Glue"
COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_CREATED_BY_DESC="The user that created this Admin Fields Relations."
COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_CREATED_BY_LABEL="Created By"
@ -5525,6 +5528,8 @@ COM_COMPONENTBUILDER_MAX_LENGTH_ONLY_FOUR_TEXT_FIELD="Max Length (only 4 text_fi
COM_COMPONENTBUILDER_MERGE="Merge"
COM_COMPONENTBUILDER_MINIFY_JAVASCRIPT="Minify JavaScript"
COM_COMPONENTBUILDER_MIN_LENGTH_ONLY_FOUR_TEXT_FIELD="Min Length (only 4 text_field)"
COM_COMPONENTBUILDER_MODEL_AFTER_MODELLING="Model (after modelling)"
COM_COMPONENTBUILDER_MODEL_BEFORE_MODELLING="Model (before modelling)"
COM_COMPONENTBUILDER_NAME="Name"
COM_COMPONENTBUILDER_NAME_ASC="Name (Asc)"
COM_COMPONENTBUILDER_NAME_DESC="Name (Desc)"

View File

@ -413,6 +413,8 @@ class ComponentbuilderModelAjax extends JModelList
'field' => 'setItemNames',
'listfield' => 'setItemNames',
'joinfields' => 'setItemNames',
'area' => 'setAreaName',
'set' => 'setCode',
'join_type' => 'setJoinType',
'list' => 'setAdminBehaviour',
'title' => 'setYesNo',
@ -994,6 +996,28 @@ class ComponentbuilderModelAjax extends JModelList
return JText::_('COM_COMPONENTBUILDER_DETAILS');
}
protected function setAreaName($header, $value)
{
switch ($value)
{
case 1:
return JText::_('COM_COMPONENTBUILDER_MODEL_BEFORE_MODELLING');
break;
case 2:
return JText::_('COM_COMPONENTBUILDER_VIEW');
break;
case 3:
return JText::_('COM_COMPONENTBUILDER_MODEL_AFTER_MODELLING');
break;
}
return JText::_('COM_COMPONENTBUILDER_NOT_SET');
}
protected function setCode($header, $value)
{
return nl2br(htmlspecialchars($value));
}
protected function setYesNo($header, $value)
{
if (1 == $value)
@ -2580,7 +2604,7 @@ class ComponentbuilderModelAjax extends JModelList
if ($type == 1)
{
// MODEL
if ($area == 1)
if ($area == 1 || $area == 3)
{
return ', ';
}

View File

@ -26,12 +26,19 @@ function getCodeGlueOptions(field) {
var type = jQuery('#'+subID+'__join_type').val();
// get area value
var area = jQuery('#'+subID+'__area').val();
// get codeGlueOptions
getCodeGlueOptions_server(listfield, joinfields, type, area).done(function(result) {
if(result){
jQuery('#'+subID+'__set').val(result);
}
});
// check that values are set
if (_isSet(listfield) && _isSet(joinfields) && _isSet(type) && _isSet(area)) {
// get codeGlueOptions
getCodeGlueOptions_server(listfield, joinfields, type, area).done(function(result) {
if(result){
jQuery('#'+subID+'__set').val(result);
} else {
jQuery('#'+subID+'__set').val('');
}
});
} else {
jQuery('#'+subID+'__set').val('');
}
}
function getCodeGlueOptions_server(listfield, joinfields, type, area){
@ -48,4 +55,12 @@ function getCodeGlueOptions_server(listfield, joinfields, type, area){
});
}
// the isSet function
function _isSet(val)
{
if ((val != undefined) && (val != null) && 0 !== val.length){
return true;
}
return false;
}

View File

@ -119,6 +119,21 @@
onchange="getCodeGlueOptions(this)"
button="false"
/>
<!-- Column_name Field. Type: Text. (joomla) -->
<field
type="text"
name="column_name"
label="COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_COLUMN_NAME_LABEL"
size="50"
maxlength="50"
default="Default"
class="text_area"
required="false"
filter="STRING"
message="COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_COLUMN_NAME_MESSAGE"
hint="COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_COLUMN_NAME_HINT"
autocomplete="on"
/>
<!-- Joinfields Field. Type: Joinfields. (custom) -->
<field
type="joinfields"

View File

@ -1677,7 +1677,8 @@ INSERT INTO `#__componentbuilder_admin_fields_conditions` (`id`, `addconditions`
INSERT INTO `#__componentbuilder_admin_fields_relations` (`id`, `addrelations`, `admin_view`, `published`, `created`, `modified`, `version`, `hits`, `ordering`) VALUES
(1, '', 14, 1, '2018-05-22 01:20:34', '2018-05-23 03:37:27', 9, '', 1),
(2, '', 22, 1, '2018-05-23 03:38:52', '2018-05-26 07:37:25', 18, '', 2),
(3, '', 13, 1, '2018-05-24 17:04:40', '2018-05-24 17:12:52', 4, '', 3);
(3, '', 13, 1, '2018-05-24 17:04:40', '2018-05-24 17:12:52', 4, '', 3),
(4, '{\"addrelations0\":{\"listfield\":\"913\",\"column_name\":\"Preacher Details\",\"joinfields\":[\"691\"],\"area\":\"2\",\"join_type\":\"1\",\"set\":\"<br \\/>\"}}', 54, 1, '2018-05-28 07:00:41', '2018-05-28 09:45:25', 7, '', 4);
--
-- Dumping data for table `#__componentbuilder_component_admin_views`

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2" method="upgrade">
<name>COM_COMPONENTBUILDER</name>
<creationDate>26th May, 2018</creationDate>
<creationDate>29th May, 2018</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>

View File

@ -3911,7 +3911,7 @@ abstract class ComponentbuilderHelper
}
}
// check if there are any view values remaining
if (count($_result))
if (count((array)$_result))
{
$_result = json_encode($_result);
$_result = array($_result);
@ -4553,7 +4553,7 @@ abstract class ComponentbuilderHelper
**/
public static function checkArray($array, $removeEmptyString = false)
{
if (isset($array) && is_array($array) && count($array) > 0)
if (isset($array) && is_array($array) && count((array)$array) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
@ -4656,7 +4656,7 @@ abstract class ComponentbuilderHelper
{
$initial = strlen($string);
$words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE);
$words_count = count($words);
$words_count = count((array)$words);
$word_length = 0;
$last_word = 0;