Fixed gh-334 to insure that we always have a path/string in the default value. Made other improvements in the compiler and the bcmath methods.

This commit is contained in:
Llewellyn van der Merwe 2018-08-31 23:11:23 +02:00
parent f3539185ab
commit abb046f671
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
6 changed files with 98 additions and 18 deletions

View File

@ -125,11 +125,11 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 30th August, 2018 + *Last Build*: 31st August, 2018
+ *Version*: 2.9.0 + *Version*: 2.9.0
+ *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 - 2018 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*: **192879** + *Line count*: **192959**
+ *Field count*: **1081** + *Field count*: **1081**
+ *File count*: **1273** + *File count*: **1273**
+ *Folder count*: **201** + *Folder count*: **201**

View File

@ -125,11 +125,11 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 30th August, 2018 + *Last Build*: 31st August, 2018
+ *Version*: 2.9.0 + *Version*: 2.9.0
+ *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 - 2018 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*: **192879** + *Line count*: **192959**
+ *Field count*: **1081** + *Field count*: **1081**
+ *File count*: **1273** + *File count*: **1273**
+ *Folder count*: **201** + *Folder count*: **201**

View File

@ -2338,6 +2338,11 @@ abstract class ComponentbuilderHelper
*/ */
public static function getFilePath($type = 'path', $target = 'filepath', $fileType = null, $key = '', $default = JPATH_SITE . '/images/', $createIfNotSet = true) public static function getFilePath($type = 'path', $target = 'filepath', $fileType = null, $key = '', $default = JPATH_SITE . '/images/', $createIfNotSet = true)
{ {
// make sure to always have a string/path
if(!self::checkString($default))
{
$default = JPATH_SITE . '/images/';
}
// get the global settings // get the global settings
if (!self::checkObject(self::$params)) if (!self::checkObject(self::$params))
{ {
@ -2407,6 +2412,11 @@ abstract class ComponentbuilderHelper
*/ */
public static function getFolderPath($type = 'path', $target = 'folderpath', $default = JPATH_SITE . '/images/', $createIfNotSet = true) public static function getFolderPath($type = 'path', $target = 'folderpath', $default = JPATH_SITE . '/images/', $createIfNotSet = true)
{ {
// make sure to always have a string/path
if(!self::checkString($default))
{
$default = JPATH_SITE . '/images/';
}
// get the global settings // get the global settings
if (!self::checkObject(self::$params)) if (!self::checkObject(self::$params))
{ {
@ -2523,7 +2533,7 @@ abstract class ComponentbuilderHelper
{ {
// build function name // build function name
$function = 'bc' . $type; $function = 'bc' . $type;
// use the bcmath function of available // use the bcmath function if available
if (function_exists($function)) if (function_exists($function))
{ {
return $function($val1, $val2, $scale); return $function($val1, $val2, $scale);
@ -2559,6 +2569,32 @@ abstract class ComponentbuilderHelper
return false; return false;
} }
/**
* Basic sum of an array with more precision
*
* @param array $array The values to sum
* @param int $scale The scale value
*
* @return float
*
*/
public static function bcsum($array, $scale = 4)
{
// use the bcadd function if available
if (function_exists('bcadd'))
{
// set the start value
$value = 0.0;
// loop the values and run bcadd
foreach($array as $val)
{
$value = bcadd($value, $val, $scale);
}
return $value;
}
// fall back on array sum
return array_sum($array);
}
/** /**
* the locker * the locker
@ -3599,12 +3635,13 @@ abstract class ComponentbuilderHelper
} }
/** /**
* Get the edit button * Get an edit button
* *
* @param int $item The item to edit * @param int $item The item to edit
* @param string $view The type of item to edit * @param string $view The type of item to edit
* @param string $views The list view controller name * @param string $views The list view controller name
* @param string $ref The return path * @param string $ref The return path
* @param string $component The component these views belong to
* @param string $headsup The message to show on click of button * @param string $headsup The message to show on click of button
* *
* @return string On success the full html edit button * @return string On success the full html edit button
@ -3639,7 +3676,7 @@ abstract class ComponentbuilderHelper
// check that there is a check message // check that there is a check message
if (self::checkString($headsup)) if (self::checkString($headsup))
{ {
$href = 'onclick="UIkit.modal.confirm(\''.JText::_($headsup).'\', function(){ window.location.href = \'' . $url . '\' })" href="javascript:void(0)"'; $href = 'onclick="UIkit2.modal.confirm(\''.JText::_($headsup).'\', function(){ window.location.href = \'' . $url . '\' })" href="javascript:void(0)"';
} }
else else
{ {
@ -3666,7 +3703,10 @@ abstract class ComponentbuilderHelper
* *
* @param int $item The item to edit * @param int $item The item to edit
* @param string $view The type of item to edit * @param string $view The type of item to edit
* @param string $views The list view controller name
* @param string $ref The return path * @param string $ref The return path
* @param string $component The component these views belong to
* @param bool $jRoute The switch to add use JRoute or not
* *
* @return string On success the edit url * @return string On success the edit url
* *

View File

@ -342,7 +342,7 @@ class ComponentbuilderModelAjax extends JModelList
// only load referral if not new item. // only load referral if not new item.
$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));
// get item id // get item id
if ($id = ComponentbuilderHelper::getVar($type, $values['a_id'], $values['a_view'], 'id')) if (($id = ComponentbuilderHelper::getVar($type, $values['a_id'], $values['a_view'], 'id')) !== false && $id > 0)
{ {
$buttonText = JText::sprintf('COM_COMPONENTBUILDER_EDIT_S_FOR_THIS_S', ComponentbuilderHelper::safeString($type, 'w'), ComponentbuilderHelper::safeString($values['a_view'], 'w')); $buttonText = JText::sprintf('COM_COMPONENTBUILDER_EDIT_S_FOR_THIS_S', ComponentbuilderHelper::safeString($type, 'w'), ComponentbuilderHelper::safeString($values['a_view'], 'w'));
$buttonTextSmall = JText::_('COM_COMPONENTBUILDER_EDIT'); $buttonTextSmall = JText::_('COM_COMPONENTBUILDER_EDIT');

View File

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

View File

@ -2338,6 +2338,11 @@ abstract class ComponentbuilderHelper
*/ */
public static function getFilePath($type = 'path', $target = 'filepath', $fileType = null, $key = '', $default = JPATH_SITE . '/images/', $createIfNotSet = true) public static function getFilePath($type = 'path', $target = 'filepath', $fileType = null, $key = '', $default = JPATH_SITE . '/images/', $createIfNotSet = true)
{ {
// make sure to always have a string/path
if(!self::checkString($default))
{
$default = JPATH_SITE . '/images/';
}
// get the global settings // get the global settings
if (!self::checkObject(self::$params)) if (!self::checkObject(self::$params))
{ {
@ -2407,6 +2412,11 @@ abstract class ComponentbuilderHelper
*/ */
public static function getFolderPath($type = 'path', $target = 'folderpath', $default = JPATH_SITE . '/images/', $createIfNotSet = true) public static function getFolderPath($type = 'path', $target = 'folderpath', $default = JPATH_SITE . '/images/', $createIfNotSet = true)
{ {
// make sure to always have a string/path
if(!self::checkString($default))
{
$default = JPATH_SITE . '/images/';
}
// get the global settings // get the global settings
if (!self::checkObject(self::$params)) if (!self::checkObject(self::$params))
{ {
@ -2523,7 +2533,7 @@ abstract class ComponentbuilderHelper
{ {
// build function name // build function name
$function = 'bc' . $type; $function = 'bc' . $type;
// use the bcmath function of available // use the bcmath function if available
if (function_exists($function)) if (function_exists($function))
{ {
return $function($val1, $val2, $scale); return $function($val1, $val2, $scale);
@ -2559,6 +2569,32 @@ abstract class ComponentbuilderHelper
return false; return false;
} }
/**
* Basic sum of an array with more precision
*
* @param array $array The values to sum
* @param int $scale The scale value
*
* @return float
*
*/
public static function bcsum($array, $scale = 4)
{
// use the bcadd function if available
if (function_exists('bcadd'))
{
// set the start value
$value = 0.0;
// loop the values and run bcadd
foreach($array as $val)
{
$value = bcadd($value, $val, $scale);
}
return $value;
}
// fall back on array sum
return array_sum($array);
}
/** /**
* the locker * the locker
@ -3599,12 +3635,13 @@ abstract class ComponentbuilderHelper
} }
/** /**
* Get the edit button * Get an edit button
* *
* @param int $item The item to edit * @param int $item The item to edit
* @param string $view The type of item to edit * @param string $view The type of item to edit
* @param string $views The list view controller name * @param string $views The list view controller name
* @param string $ref The return path * @param string $ref The return path
* @param string $component The component these views belong to
* @param string $headsup The message to show on click of button * @param string $headsup The message to show on click of button
* *
* @return string On success the full html edit button * @return string On success the full html edit button
@ -3639,7 +3676,7 @@ abstract class ComponentbuilderHelper
// check that there is a check message // check that there is a check message
if (self::checkString($headsup)) if (self::checkString($headsup))
{ {
$href = 'onclick="UIkit.modal.confirm(\''.JText::_($headsup).'\', function(){ window.location.href = \'' . $url . '\' })" href="javascript:void(0)"'; $href = 'onclick="UIkit2.modal.confirm(\''.JText::_($headsup).'\', function(){ window.location.href = \'' . $url . '\' })" href="javascript:void(0)"';
} }
else else
{ {
@ -3666,7 +3703,10 @@ abstract class ComponentbuilderHelper
* *
* @param int $item The item to edit * @param int $item The item to edit
* @param string $view The type of item to edit * @param string $view The type of item to edit
* @param string $views The list view controller name
* @param string $ref The return path * @param string $ref The return path
* @param string $component The component these views belong to
* @param bool $jRoute The switch to add use JRoute or not
* *
* @return string On success the edit url * @return string On success the edit url
* *