Skip to content

Commit

Permalink
Fixed gh-334 to insure that we always have a path/string in the defau…
Browse files Browse the repository at this point in the history
…lt value. Made other improvements in the compiler and the bcmath methods.
  • Loading branch information
Llewellynvdm committed Aug 31, 2018
1 parent f353918 commit abb046f
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ 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*: 30th August, 2018
+ *Last Build*: 31st August, 2018
+ *Version*: 2.9.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*: **192879**
+ *Line count*: **192959**
+ *Field count*: **1081**
+ *File count*: **1273**
+ *Folder count*: **201**
Expand Down
4 changes: 2 additions & 2 deletions admin/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ 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*: 30th August, 2018
+ *Last Build*: 31st August, 2018
+ *Version*: 2.9.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*: **192879**
+ *Line count*: **192959**
+ *Field count*: **1081**
+ *File count*: **1273**
+ *Folder count*: **201**
Expand Down
52 changes: 46 additions & 6 deletions admin/helpers/componentbuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2338,6 +2338,11 @@ public static function urlExists($url)
*/
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
if (!self::checkObject(self::$params))
{
Expand Down Expand Up @@ -2407,6 +2412,11 @@ public static function getFilePath($type = 'path', $target = 'filepath', $fileTy
*/
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
if (!self::checkObject(self::$params))
{
Expand Down Expand Up @@ -2523,7 +2533,7 @@ public static function bcmath($type, $val1, $val2, $scale = 0)
{
// build function name
$function = 'bc' . $type;
// use the bcmath function of available
// use the bcmath function if available
if (function_exists($function))
{
return $function($val1, $val2, $scale);
Expand Down Expand Up @@ -2559,6 +2569,32 @@ public static function bcmath($type, $val1, $val2, $scale = 0)
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
Expand Down Expand Up @@ -3599,12 +3635,13 @@ public static function getServerDetails($serverID, $protocol = 2, $permission =
}

/**
* Get the edit button
* Get an edit button
*
* @param int $item The 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 $component The component these views belong to
* @param string $headsup The message to show on click of button
*
* @return string On success the full html edit button
Expand Down Expand Up @@ -3639,7 +3676,7 @@ public static function getEditButton(&$item, $view, $views, $ref = '', $componen
// check that there is a check message
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
{
Expand All @@ -3664,9 +3701,12 @@ public static function getEditButton(&$item, $view, $views, $ref = '', $componen
/**
* Get the edit URL
*
* @param int $item The item to edit
* @param string $view The type of item to edit
* @param string $ref The return path
* @param int $item The 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 $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
*
Expand Down
2 changes: 1 addition & 1 deletion admin/models/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public function getButtonID($type, $size)
// only load referral if not new item.
$ref = '&ref=' . $values['a_view'] . '&refid=' . $values['a_id'] . '&return=' . urlencode(base64_encode($return_url));
// 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'));
$buttonTextSmall = JText::_('COM_COMPONENTBUILDER_EDIT');
Expand Down
2 changes: 1 addition & 1 deletion componentbuilder.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2" method="upgrade">
<name>COM_COMPONENTBUILDER</name>
<creationDate>30th August, 2018</creationDate>
<creationDate>31st August, 2018</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>
Expand Down
52 changes: 46 additions & 6 deletions site/helpers/componentbuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2338,6 +2338,11 @@ public static function urlExists($url)
*/
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
if (!self::checkObject(self::$params))
{
Expand Down Expand Up @@ -2407,6 +2412,11 @@ public static function getFilePath($type = 'path', $target = 'filepath', $fileTy
*/
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
if (!self::checkObject(self::$params))
{
Expand Down Expand Up @@ -2523,7 +2533,7 @@ public static function bcmath($type, $val1, $val2, $scale = 0)
{
// build function name
$function = 'bc' . $type;
// use the bcmath function of available
// use the bcmath function if available
if (function_exists($function))
{
return $function($val1, $val2, $scale);
Expand Down Expand Up @@ -2559,6 +2569,32 @@ public static function bcmath($type, $val1, $val2, $scale = 0)
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
Expand Down Expand Up @@ -3599,12 +3635,13 @@ public static function getServerDetails($serverID, $protocol = 2, $permission =
}

/**
* Get the edit button
* Get an edit button
*
* @param int $item The 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 $component The component these views belong to
* @param string $headsup The message to show on click of button
*
* @return string On success the full html edit button
Expand Down Expand Up @@ -3639,7 +3676,7 @@ public static function getEditButton(&$item, $view, $views, $ref = '', $componen
// check that there is a check message
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
{
Expand All @@ -3664,9 +3701,12 @@ public static function getEditButton(&$item, $view, $views, $ref = '', $componen
/**
* Get the edit URL
*
* @param int $item The item to edit
* @param string $view The type of item to edit
* @param string $ref The return path
* @param int $item The 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 $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
*
Expand Down

0 comments on commit abb046f

Please sign in to comment.