Adds new utilities abstract classes as helper methods. Moves the helper class autoloader above the class. Adds option to override the settings.json file.
This commit is contained in:
parent
dd3335771c
commit
278f70c8a6
@ -143,14 +143,14 @@ TODO
|
|||||||
+ *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*: 12th February, 2022
|
+ *Last Build*: 9th March, 2022
|
||||||
+ *Version*: 2.12.15
|
+ *Version*: 2.12.15
|
||||||
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
|
+ *Copyright*: Copyright (C) 2015 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*: **286261**
|
+ *Line count*: **286315**
|
||||||
+ *Field count*: **1580**
|
+ *Field count*: **1580**
|
||||||
+ *File count*: **1829**
|
+ *File count*: **1848**
|
||||||
+ *Folder count*: **256**
|
+ *Folder count*: **260**
|
||||||
|
|
||||||
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).
|
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).
|
||||||
> Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
|
> Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
|
||||||
|
@ -143,14 +143,14 @@ TODO
|
|||||||
+ *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*: 12th February, 2022
|
+ *Last Build*: 9th March, 2022
|
||||||
+ *Version*: 2.12.15
|
+ *Version*: 2.12.15
|
||||||
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
|
+ *Copyright*: Copyright (C) 2015 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*: **286261**
|
+ *Line count*: **286315**
|
||||||
+ *Field count*: **1580**
|
+ *Field count*: **1580**
|
||||||
+ *File count*: **1829**
|
+ *File count*: **1848**
|
||||||
+ *Folder count*: **256**
|
+ *Folder count*: **260**
|
||||||
|
|
||||||
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).
|
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).
|
||||||
> Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
|
> Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
|
||||||
|
@ -15,7 +15,7 @@ defined('_JEXEC') or die('Restricted access');
|
|||||||
###BOM###
|
###BOM###
|
||||||
|
|
||||||
// No direct access to this file
|
// No direct access to this file
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');###ADMIN_POWER_HELPER###
|
||||||
|
|
||||||
###ADMIN_HELPER_CLASS_HEADER###
|
###ADMIN_HELPER_CLASS_HEADER###
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ abstract class ###Component###Helper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public static $langTag;###ADMIN_GLOBAL_EVENT_HELPER######CUSTOM_HELPER_SCRIPT######BOTH_CUSTOM_HELPER_SCRIPT######ADMIN_POWER_EVENT_HELPER###
|
public static $langTag;###ADMIN_GLOBAL_EVENT_HELPER######CUSTOM_HELPER_SCRIPT######BOTH_CUSTOM_HELPER_SCRIPT###
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the Composer Vendors
|
* Load the Composer Vendors
|
||||||
@ -1339,3 +1339,4 @@ abstract class ###Component###Helper
|
|||||||
return implode($key);
|
return implode($key);
|
||||||
}###GET_CRYPT_KEY###
|
}###GET_CRYPT_KEY###
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ defined('_JEXEC') or die('Restricted access');
|
|||||||
###BOM###
|
###BOM###
|
||||||
|
|
||||||
// No direct access to this file
|
// No direct access to this file
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');###SITE_POWER_HELPER###
|
||||||
|
|
||||||
###SITE_HELPER_CLASS_HEADER###
|
###SITE_HELPER_CLASS_HEADER###
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ abstract class ###Component###Helper
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public static $langTag;###SITE_GLOBAL_EVENT_HELPER######SITE_CUSTOM_HELPER_SCRIPT######BOTH_CUSTOM_HELPER_SCRIPT######SITE_POWER_EVENT_HELPER###
|
public static $langTag;###SITE_GLOBAL_EVENT_HELPER######SITE_CUSTOM_HELPER_SCRIPT######BOTH_CUSTOM_HELPER_SCRIPT###
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the Composer Vendors
|
* Load the Composer Vendors
|
||||||
@ -1331,3 +1331,4 @@ abstract class ###Component###Helper
|
|||||||
return implode($key);
|
return implode($key);
|
||||||
}###GET_CRYPT_KEY###
|
}###GET_CRYPT_KEY###
|
||||||
}
|
}
|
||||||
|
|
||||||
|
760
admin/compiler/joomla_3/JCB_Helper.php
Normal file
760
admin/compiler/joomla_3/JCB_Helper.php
Normal file
@ -0,0 +1,760 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
?>
|
||||||
|
###BOM###
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');###ADMIN_POWER_HELPER###
|
||||||
|
|
||||||
|
###ADMIN_HELPER_CLASS_HEADER###
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ###Component### component helper.
|
||||||
|
*/
|
||||||
|
abstract class ###Component###Helper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Adding the utilities trait to this class
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Check the trait methods for details, a legacy implementation
|
||||||
|
*/
|
||||||
|
use Utilities;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Composer Switch
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected static $composer = array();###ADMIN_GLOBAL_EVENT_HELPER######CUSTOM_HELPER_SCRIPT######BOTH_CUSTOM_HELPER_SCRIPT###
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the Composer Vendors
|
||||||
|
*/
|
||||||
|
public static function composerAutoload($target)
|
||||||
|
{
|
||||||
|
// insure we load the composer vendor only once
|
||||||
|
if (!isset(self::$composer[$target]))
|
||||||
|
{
|
||||||
|
// get the function name
|
||||||
|
$functionName = self::safeString('compose' . $target);
|
||||||
|
// check if method exist
|
||||||
|
if (method_exists(__CLASS__, $functionName))
|
||||||
|
{
|
||||||
|
return self::{$functionName}();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return self::$composer[$target];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the Component xml manifest.
|
||||||
|
*/
|
||||||
|
public static function manifest()
|
||||||
|
{
|
||||||
|
$manifestUrl = JPATH_ADMINISTRATOR."/components/com_###component###/###component###.xml";
|
||||||
|
return simplexml_load_file($manifestUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Joomla version object
|
||||||
|
*/
|
||||||
|
protected static $JVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set/get Joomla version
|
||||||
|
*/
|
||||||
|
public static function jVersion()
|
||||||
|
{
|
||||||
|
// check if set
|
||||||
|
if (!self::checkObject(self::$JVersion))
|
||||||
|
{
|
||||||
|
self::$JVersion = new JVersion();
|
||||||
|
}
|
||||||
|
return self::$JVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the Contributors details.
|
||||||
|
*/
|
||||||
|
public static function getContributors()
|
||||||
|
{
|
||||||
|
// get params
|
||||||
|
$params = JComponentHelper::getParams('com_###component###');
|
||||||
|
// start contributors array
|
||||||
|
$contributors = array();
|
||||||
|
// get all Contributors (max 20)
|
||||||
|
$searchArray = range('0','20');
|
||||||
|
foreach($searchArray as $nr)
|
||||||
|
{
|
||||||
|
if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 1 || $params->get("showContributor".$nr) == 3))
|
||||||
|
{
|
||||||
|
// set link based of selected option
|
||||||
|
if($params->get("useContributor".$nr) == 1)
|
||||||
|
{
|
||||||
|
$link_front = '<a href="mailto:'.$params->get("emailContributor".$nr).'" target="_blank">';
|
||||||
|
$link_back = '</a>';
|
||||||
|
}
|
||||||
|
elseif($params->get("useContributor".$nr) == 2)
|
||||||
|
{
|
||||||
|
$link_front = '<a href="'.$params->get("linkContributor".$nr).'" target="_blank">';
|
||||||
|
$link_back = '</a>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$link_front = '';
|
||||||
|
$link_back = '';
|
||||||
|
}
|
||||||
|
$contributors[$nr]['title'] = self::htmlEscape($params->get("titleContributor".$nr));
|
||||||
|
$contributors[$nr]['name'] = $link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $contributors;
|
||||||
|
}###HELP###
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure the Linkbar.
|
||||||
|
*/
|
||||||
|
public static function addSubmenu($submenu)
|
||||||
|
{
|
||||||
|
// load user for access menus
|
||||||
|
$user = JFactory::getUser();
|
||||||
|
// load the submenus to sidebar
|
||||||
|
###SUBMENU###
|
||||||
|
}###HELPER_CREATEUSER######HELPER_UIKIT######HELPER_EXEL###
|
||||||
|
|
||||||
|
public static function isPublished($id,$type)
|
||||||
|
{
|
||||||
|
if ($type == 'raw')
|
||||||
|
{
|
||||||
|
$type = 'item';
|
||||||
|
}
|
||||||
|
$db = JFactory::getDbo();
|
||||||
|
$query = $db->getQuery(true);
|
||||||
|
$query->select(array('a.published'));
|
||||||
|
$query->from('#__###component###_'.$type.' AS a');
|
||||||
|
$query->where('a.id = '. (int) $id);
|
||||||
|
$query->where('a.published = 1');
|
||||||
|
$db->setQuery($query);
|
||||||
|
$db->execute();
|
||||||
|
$found = $db->getNumRows();
|
||||||
|
if($found)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getGroupName($id)
|
||||||
|
{
|
||||||
|
$db = JFactory::getDBO();
|
||||||
|
$query = $db->getQuery(true);
|
||||||
|
$query->select(array('a.title'));
|
||||||
|
$query->from('#__usergroups AS a');
|
||||||
|
$query->where('a.id = '. (int) $id);
|
||||||
|
$db->setQuery($query);
|
||||||
|
$db->execute();
|
||||||
|
$found = $db->getNumRows();
|
||||||
|
if($found)
|
||||||
|
{
|
||||||
|
return $db->loadResult();
|
||||||
|
}
|
||||||
|
return $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the action permissions
|
||||||
|
*
|
||||||
|
* @param string $view The related view name
|
||||||
|
* @param int $record The item to act upon
|
||||||
|
* @param string $views The related list view name
|
||||||
|
* @param mixed $target Only get this permission (like edit, create, delete)
|
||||||
|
* @param string $component The target component
|
||||||
|
* @param object $user The user whose permissions we are loading
|
||||||
|
*
|
||||||
|
* @return object The JObject of permission/authorised actions
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function getActions($view, &$record = null, $views = null, $target = null, $component = '###component###', $user = 'null')
|
||||||
|
{
|
||||||
|
// load the user if not given
|
||||||
|
if (!self::checkObject($user))
|
||||||
|
{
|
||||||
|
// get the user object
|
||||||
|
$user = JFactory::getUser();
|
||||||
|
}
|
||||||
|
// load the JObject
|
||||||
|
$result = new JObject;
|
||||||
|
// make view name safe (just incase)
|
||||||
|
$view = self::safeString($view);
|
||||||
|
if (self::checkString($views))
|
||||||
|
{
|
||||||
|
$views = self::safeString($views);
|
||||||
|
}
|
||||||
|
// get all actions from component
|
||||||
|
$actions = JAccess::getActionsFromFile(
|
||||||
|
JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml',
|
||||||
|
"/access/section[@name='component']/"
|
||||||
|
);
|
||||||
|
// if non found then return empty JObject
|
||||||
|
if (empty($actions))
|
||||||
|
{
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
// get created by if not found
|
||||||
|
if (self::checkObject($record) && !isset($record->created_by) && isset($record->id))
|
||||||
|
{
|
||||||
|
$record->created_by = self::getVar($view, $record->id, 'id', 'created_by', '=', $component);
|
||||||
|
}
|
||||||
|
// set actions only set in component settings
|
||||||
|
$componentActions = array('core.admin', 'core.manage', 'core.options', 'core.export');
|
||||||
|
// check if we have a target
|
||||||
|
$checkTarget = false;
|
||||||
|
if ($target)
|
||||||
|
{
|
||||||
|
// convert to an array
|
||||||
|
if (self::checkString($target))
|
||||||
|
{
|
||||||
|
$target = array($target);
|
||||||
|
}
|
||||||
|
// check if we are good to go
|
||||||
|
if (self::checkArray($target))
|
||||||
|
{
|
||||||
|
$checkTarget = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// loop the actions and set the permissions
|
||||||
|
foreach ($actions as $action)
|
||||||
|
{
|
||||||
|
// check target action filter
|
||||||
|
if ($checkTarget && self::filterActions($view, $action->name, $target))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// set to use component default
|
||||||
|
$fallback = true;
|
||||||
|
// reset permission per/action
|
||||||
|
$permission = false;
|
||||||
|
$catpermission = false;
|
||||||
|
// set area
|
||||||
|
$area = 'comp';
|
||||||
|
// check if the record has an ID and the action is item related (not a component action)
|
||||||
|
if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) &&
|
||||||
|
(strpos($action->name, 'core.') !== false || strpos($action->name, $view . '.') !== false))
|
||||||
|
{
|
||||||
|
// we are in item
|
||||||
|
$area = 'item';
|
||||||
|
// The record has been set. Check the record permissions.
|
||||||
|
$permission = $user->authorise($action->name, 'com_' . $component . '.' . $view . '.' . (int) $record->id);
|
||||||
|
// if no permission found, check edit own
|
||||||
|
if (!$permission)
|
||||||
|
{
|
||||||
|
// With edit, if the created_by matches current user then dig deeper.
|
||||||
|
if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id))
|
||||||
|
{
|
||||||
|
// the correct target
|
||||||
|
$coreCheck = (array) explode('.', $action->name);
|
||||||
|
// check that we have both local and global access
|
||||||
|
if ($user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component . '.' . $view . '.' . (int) $record->id) &&
|
||||||
|
$user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component))
|
||||||
|
{
|
||||||
|
// allow edit
|
||||||
|
$result->set($action->name, true);
|
||||||
|
// set not to use global default
|
||||||
|
// because we already validated it
|
||||||
|
$fallback = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// do not allow edit
|
||||||
|
$result->set($action->name, false);
|
||||||
|
$fallback = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0)
|
||||||
|
{
|
||||||
|
// we are in item
|
||||||
|
$area = 'category';
|
||||||
|
// set the core check
|
||||||
|
$coreCheck = explode('.', $action->name);
|
||||||
|
$core = $coreCheck[0];
|
||||||
|
// make sure we use the core. action check for the categories
|
||||||
|
if (strpos($action->name, $view) !== false && strpos($action->name, 'core.') === false )
|
||||||
|
{
|
||||||
|
$coreCheck[0] = 'core';
|
||||||
|
$categoryCheck = implode('.', $coreCheck);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$categoryCheck = $action->name;
|
||||||
|
}
|
||||||
|
// The record has a category. Check the category permissions.
|
||||||
|
$catpermission = $user->authorise($categoryCheck, 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid);
|
||||||
|
if (!$catpermission && !is_null($catpermission))
|
||||||
|
{
|
||||||
|
// With edit, if the created_by matches current user then dig deeper.
|
||||||
|
if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id))
|
||||||
|
{
|
||||||
|
// check that we have both local and global access
|
||||||
|
if ($user->authorise('core.edit.own', 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid) &&
|
||||||
|
$user->authorise($core . '.edit.own', 'com_' . $component))
|
||||||
|
{
|
||||||
|
// allow edit
|
||||||
|
$result->set($action->name, true);
|
||||||
|
// set not to use global default
|
||||||
|
// because we already validated it
|
||||||
|
$fallback = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// do not allow edit
|
||||||
|
$result->set($action->name, false);
|
||||||
|
$fallback = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if allowed then fallback on component global settings
|
||||||
|
if ($fallback)
|
||||||
|
{
|
||||||
|
// if item/category blocks access then don't fall back on global
|
||||||
|
if ((($area === 'item') && !$permission) || (($area === 'category') && !$catpermission))
|
||||||
|
{
|
||||||
|
// do not allow
|
||||||
|
$result->set($action->name, false);
|
||||||
|
}
|
||||||
|
// Finally remember the global settings have the final say. (even if item allow)
|
||||||
|
// The local item permissions can block, but it can't open and override of global permissions.
|
||||||
|
// Since items are created by users and global permissions is set by system admin.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$result->set($action->name, $user->authorise($action->name, 'com_' . $component));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the action permissions
|
||||||
|
*
|
||||||
|
* @param string $action The action to check
|
||||||
|
* @param array $targets The array of target actions
|
||||||
|
*
|
||||||
|
* @return boolean true if action should be filtered out
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected static function filterActions(&$view, &$action, &$targets)
|
||||||
|
{
|
||||||
|
foreach ($targets as $target)
|
||||||
|
{
|
||||||
|
if (strpos($action, $view . '.' . $target) !== false ||
|
||||||
|
strpos($action, 'core.' . $target) !== false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get any component's model
|
||||||
|
*/
|
||||||
|
public static function getModel($name, $path = JPATH_COMPONENT_ADMINISTRATOR, $Component = '###Component###', $config = array())
|
||||||
|
{
|
||||||
|
// fix the name
|
||||||
|
$name = self::safeString($name);
|
||||||
|
// full path to models
|
||||||
|
$fullPathModels = $path . '/models';
|
||||||
|
// load the model file
|
||||||
|
JModelLegacy::addIncludePath($fullPathModels, $Component . 'Model');
|
||||||
|
// make sure the table path is loaded
|
||||||
|
if (!isset($config['table_path']) || !self::checkString($config['table_path']))
|
||||||
|
{
|
||||||
|
// This is the JCB default path to tables in Joomla 3.x
|
||||||
|
$config['table_path'] = JPATH_ADMINISTRATOR . '/components/com_' . strtolower($Component) . '/tables';
|
||||||
|
}
|
||||||
|
// get instance
|
||||||
|
$model = JModelLegacy::getInstance($name, $Component . 'Model', $config);
|
||||||
|
// if model not found (strange)
|
||||||
|
if ($model == false)
|
||||||
|
{
|
||||||
|
jimport('joomla.filesystem.file');
|
||||||
|
// get file path
|
||||||
|
$filePath = $path . '/' . $name . '.php';
|
||||||
|
$fullPathModel = $fullPathModels . '/' . $name . '.php';
|
||||||
|
// check if it exists
|
||||||
|
if (File::exists($filePath))
|
||||||
|
{
|
||||||
|
// get the file
|
||||||
|
require_once $filePath;
|
||||||
|
}
|
||||||
|
elseif (File::exists($fullPathModel))
|
||||||
|
{
|
||||||
|
// get the file
|
||||||
|
require_once $fullPathModel;
|
||||||
|
}
|
||||||
|
// build class names
|
||||||
|
$modelClass = $Component . 'Model' . $name;
|
||||||
|
if (class_exists($modelClass))
|
||||||
|
{
|
||||||
|
// initialize the model
|
||||||
|
return new $modelClass($config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add to asset Table
|
||||||
|
*/
|
||||||
|
public static function setAsset($id, $table, $inherit = true)
|
||||||
|
{
|
||||||
|
$parent = JTable::getInstance('Asset');
|
||||||
|
$parent->loadByName('com_###component###');
|
||||||
|
|
||||||
|
$parentId = $parent->id;
|
||||||
|
$name = 'com_###component###.'.$table.'.'.$id;
|
||||||
|
$title = '';
|
||||||
|
|
||||||
|
$asset = JTable::getInstance('Asset');
|
||||||
|
$asset->loadByName($name);
|
||||||
|
|
||||||
|
// Check for an error.
|
||||||
|
$error = $asset->getError();
|
||||||
|
|
||||||
|
if ($error)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Specify how a new or moved node asset is inserted into the tree.
|
||||||
|
if ($asset->parent_id != $parentId)
|
||||||
|
{
|
||||||
|
$asset->setLocation($parentId, 'last-child');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare the asset to be stored.
|
||||||
|
$asset->parent_id = $parentId;
|
||||||
|
$asset->name = $name;
|
||||||
|
$asset->title = $title;
|
||||||
|
// get the default asset rules
|
||||||
|
$rules = self::getDefaultAssetRules('com_###component###', $table, $inherit);
|
||||||
|
if ($rules instanceof JAccessRules)
|
||||||
|
{
|
||||||
|
$asset->rules = (string) $rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$asset->check() || !$asset->store())
|
||||||
|
{
|
||||||
|
JFactory::getApplication()->enqueueMessage($asset->getError(), 'warning');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Create an asset_id or heal one that is corrupted.
|
||||||
|
$object = new stdClass();
|
||||||
|
|
||||||
|
// Must be a valid primary key value.
|
||||||
|
$object->id = $id;
|
||||||
|
$object->asset_id = (int) $asset->id;
|
||||||
|
|
||||||
|
// Update their asset_id to link to the asset table.
|
||||||
|
return JFactory::getDbo()->updateObject('#__###component###_'.$table, $object, 'id');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default asset Rules for a component/view.
|
||||||
|
*/
|
||||||
|
protected static function getDefaultAssetRules($component, $view, $inherit = true)
|
||||||
|
{
|
||||||
|
// if new or inherited
|
||||||
|
$assetId = 0;
|
||||||
|
// Only get the actual item rules if not inheriting
|
||||||
|
if (!$inherit)
|
||||||
|
{
|
||||||
|
// Need to find the asset id by the name of the component.
|
||||||
|
$db = JFactory::getDbo();
|
||||||
|
$query = $db->getQuery(true)
|
||||||
|
->select($db->quoteName('id'))
|
||||||
|
->from($db->quoteName('#__assets'))
|
||||||
|
->where($db->quoteName('name') . ' = ' . $db->quote($component));
|
||||||
|
$db->setQuery($query);
|
||||||
|
$db->execute();
|
||||||
|
// check that there is a value
|
||||||
|
if ($db->getNumRows())
|
||||||
|
{
|
||||||
|
// asset already set so use saved rules
|
||||||
|
$assetId = (int) $db->loadResult();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// get asset rules
|
||||||
|
$result = JAccess::getAssetRules($assetId);
|
||||||
|
if ($result instanceof JAccessRules)
|
||||||
|
{
|
||||||
|
$_result = (string) $result;
|
||||||
|
$_result = json_decode($_result);
|
||||||
|
foreach ($_result as $name => &$rule)
|
||||||
|
{
|
||||||
|
$v = explode('.', $name);
|
||||||
|
if ($view !== $v[0])
|
||||||
|
{
|
||||||
|
// remove since it is not part of this view
|
||||||
|
unset($_result->$name);
|
||||||
|
}
|
||||||
|
elseif ($inherit)
|
||||||
|
{
|
||||||
|
// clear the value since we inherit
|
||||||
|
$rule = array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check if there are any view values remaining
|
||||||
|
if (count((array) $_result))
|
||||||
|
{
|
||||||
|
$_result = json_encode($_result);
|
||||||
|
$_result = array($_result);
|
||||||
|
// Instantiate and return the JAccessRules object for the asset rules.
|
||||||
|
$rules = new JAccessRules($_result);
|
||||||
|
// return filtered rules
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlAppend
|
||||||
|
*
|
||||||
|
* @param SimpleXMLElement $xml The XML element reference in which to inject a comment
|
||||||
|
* @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function xmlAppend(&$xml, $node)
|
||||||
|
{
|
||||||
|
if (!$node)
|
||||||
|
{
|
||||||
|
// element was not returned
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (get_class($node))
|
||||||
|
{
|
||||||
|
case 'stdClass':
|
||||||
|
if (property_exists($node, 'comment'))
|
||||||
|
{
|
||||||
|
self::xmlComment($xml, $node->comment);
|
||||||
|
}
|
||||||
|
if (property_exists($node, 'fieldXML'))
|
||||||
|
{
|
||||||
|
self::xmlAppend($xml, $node->fieldXML);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'SimpleXMLElement':
|
||||||
|
$domXML = dom_import_simplexml($xml);
|
||||||
|
$domNode = dom_import_simplexml($node);
|
||||||
|
$domXML->appendChild($domXML->ownerDocument->importNode($domNode, true));
|
||||||
|
$xml = simplexml_import_dom($domXML);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlComment
|
||||||
|
*
|
||||||
|
* @param SimpleXMLElement $xml The XML element reference in which to inject a comment
|
||||||
|
* @param string $comment The comment to inject
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function xmlComment(&$xml, $comment)
|
||||||
|
{
|
||||||
|
$domXML = dom_import_simplexml($xml);
|
||||||
|
$domComment = new DOMComment($comment);
|
||||||
|
$nodeTarget = $domXML->ownerDocument->importNode($domComment, true);
|
||||||
|
$domXML->appendChild($nodeTarget);
|
||||||
|
$xml = simplexml_import_dom($domXML);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlAddAttributes
|
||||||
|
*
|
||||||
|
* @param SimpleXMLElement $xml The XML element reference in which to inject a comment
|
||||||
|
* @param array $attributes The attributes to apply to the XML element
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function xmlAddAttributes(&$xml, $attributes = array())
|
||||||
|
{
|
||||||
|
foreach ($attributes as $key => $value)
|
||||||
|
{
|
||||||
|
$xml->addAttribute($key, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlAddOptions
|
||||||
|
*
|
||||||
|
* @param SimpleXMLElement $xml The XML element reference in which to inject a comment
|
||||||
|
* @param array $options The options to apply to the XML element
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function xmlAddOptions(&$xml, $options = array())
|
||||||
|
{
|
||||||
|
foreach ($options as $key => $value)
|
||||||
|
{
|
||||||
|
$addOption = $xml->addChild('option');
|
||||||
|
$addOption->addAttribute('value', $key);
|
||||||
|
$addOption[] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the field object
|
||||||
|
*
|
||||||
|
* @param array $attributes The array of attributes
|
||||||
|
* @param string $default The default of the field
|
||||||
|
* @param array $options The options to apply to the XML element
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function getFieldObject(&$attributes, $default = '', $options = null)
|
||||||
|
{
|
||||||
|
// make sure we have attributes and a type value
|
||||||
|
if (self::checkArray($attributes) && isset($attributes['type']))
|
||||||
|
{
|
||||||
|
// make sure the form helper class is loaded
|
||||||
|
if (!method_exists('JFormHelper', 'loadFieldType'))
|
||||||
|
{
|
||||||
|
jimport('joomla.form.form');
|
||||||
|
}
|
||||||
|
// get field type
|
||||||
|
$field = JFormHelper::loadFieldType($attributes['type'], true);
|
||||||
|
// get field xml
|
||||||
|
$XML = self::getFieldXML($attributes, $options);
|
||||||
|
// setup the field
|
||||||
|
$field->setup($XML, $default);
|
||||||
|
// return the field object
|
||||||
|
return $field;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the field xml
|
||||||
|
*
|
||||||
|
* @param array $attributes The array of attributes
|
||||||
|
* @param array $options The options to apply to the XML element
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function getFieldXML(&$attributes, $options = null)
|
||||||
|
{
|
||||||
|
// make sure we have attributes and a type value
|
||||||
|
if (self::checkArray($attributes))
|
||||||
|
{
|
||||||
|
// start field xml
|
||||||
|
$XML = new SimpleXMLElement('<field/>');
|
||||||
|
// load the attributes
|
||||||
|
self::xmlAddAttributes($XML, $attributes);
|
||||||
|
// check if we have options
|
||||||
|
if (self::checkArray($options))
|
||||||
|
{
|
||||||
|
// load the options
|
||||||
|
self::xmlAddOptions($XML, $options);
|
||||||
|
}
|
||||||
|
// return the field xml
|
||||||
|
return $XML;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render Bool Button
|
||||||
|
*
|
||||||
|
* @param array $args All the args for the button
|
||||||
|
* 0) name
|
||||||
|
* 1) additional (options class) // not used at this time
|
||||||
|
* 2) default
|
||||||
|
* 3) yes (name)
|
||||||
|
* 4) no (name)
|
||||||
|
*
|
||||||
|
* @return string The input html of the button
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function renderBoolButton()
|
||||||
|
{
|
||||||
|
$args = func_get_args();
|
||||||
|
// check if there is additional button class
|
||||||
|
$additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time
|
||||||
|
// button attributes
|
||||||
|
$buttonAttributes = array(
|
||||||
|
'type' => 'radio',
|
||||||
|
'name' => isset($args[0]) ? self::htmlEscape($args[0]) : 'bool_button',
|
||||||
|
'label' => isset($args[0]) ? self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool Button', // not seen anyway
|
||||||
|
'class' => 'btn-group',
|
||||||
|
'filter' => 'INT',
|
||||||
|
'default' => isset($args[2]) ? (int) $args[2] : 0);
|
||||||
|
// set the button options
|
||||||
|
$buttonOptions = array(
|
||||||
|
'1' => isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES',
|
||||||
|
'0' => isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO');
|
||||||
|
// return the input
|
||||||
|
return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if we are connected
|
||||||
|
* Thanks https://stackoverflow.com/a/4860432/1429677
|
||||||
|
*
|
||||||
|
* @returns bool true on success
|
||||||
|
*/
|
||||||
|
public static function isConnected()
|
||||||
|
{
|
||||||
|
// If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right?
|
||||||
|
$connected = @fsockopen("www.example.com", 80);
|
||||||
|
// website, port (try 80 or 443)
|
||||||
|
if ($connected)
|
||||||
|
{
|
||||||
|
//action when connected
|
||||||
|
$is_conn = true;
|
||||||
|
fclose($connected);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//action in connection failure
|
||||||
|
$is_conn = false;
|
||||||
|
}
|
||||||
|
return $is_conn;
|
||||||
|
}
|
||||||
|
|
||||||
|
// typo sorry!
|
||||||
|
public static function sorten($string, $length = 40, $addTip = true)
|
||||||
|
{
|
||||||
|
return self::shorten($string, $length, $addTip);
|
||||||
|
}###HELPER_LICENSE_LOCK######GET_CRYPT_KEY###
|
||||||
|
}
|
749
admin/compiler/joomla_3/JCB_Helper_site.php
Normal file
749
admin/compiler/joomla_3/JCB_Helper_site.php
Normal file
@ -0,0 +1,749 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
?>
|
||||||
|
###BOM###
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');###SITE_POWER_HELPER###
|
||||||
|
|
||||||
|
###SITE_HELPER_CLASS_HEADER###
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ###Component### component helper
|
||||||
|
*/
|
||||||
|
abstract class ###Component###Helper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Adding the utilities trait to this class
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Check the trait methods for details, a legacy implementation
|
||||||
|
*/
|
||||||
|
use Utilities;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Composer Switch
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected static $composer = array();###SITE_GLOBAL_EVENT_HELPER######SITE_CUSTOM_HELPER_SCRIPT######BOTH_CUSTOM_HELPER_SCRIPT###
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the Composer Vendors
|
||||||
|
*/
|
||||||
|
public static function composerAutoload($target)
|
||||||
|
{
|
||||||
|
// insure we load the composer vendor only once
|
||||||
|
if (!isset(self::$composer[$target]))
|
||||||
|
{
|
||||||
|
// get the function name
|
||||||
|
$functionName = self::safeString('compose' . $target);
|
||||||
|
// check if method exist
|
||||||
|
if (method_exists(__CLASS__, $functionName))
|
||||||
|
{
|
||||||
|
return self::{$functionName}();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return self::$composer[$target];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the Component xml manifest.
|
||||||
|
*/
|
||||||
|
public static function manifest()
|
||||||
|
{
|
||||||
|
$manifestUrl = JPATH_ADMINISTRATOR."/components/com_###component###/###component###.xml";
|
||||||
|
return simplexml_load_file($manifestUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Joomla version object
|
||||||
|
*/
|
||||||
|
protected static $JVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set/get Joomla version
|
||||||
|
*/
|
||||||
|
public static function jVersion()
|
||||||
|
{
|
||||||
|
// check if set
|
||||||
|
if (!self::checkObject(self::$JVersion))
|
||||||
|
{
|
||||||
|
self::$JVersion = new JVersion();
|
||||||
|
}
|
||||||
|
return self::$JVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the Contributors details.
|
||||||
|
*/
|
||||||
|
public static function getContributors()
|
||||||
|
{
|
||||||
|
// get params
|
||||||
|
$params = JComponentHelper::getParams('com_###component###');
|
||||||
|
// start contributors array
|
||||||
|
$contributors = array();
|
||||||
|
// get all Contributors (max 20)
|
||||||
|
$searchArray = range('0','20');
|
||||||
|
foreach($searchArray as $nr)
|
||||||
|
{
|
||||||
|
if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 2 || $params->get("showContributor".$nr) == 3))
|
||||||
|
{
|
||||||
|
// set link based of selected option
|
||||||
|
if($params->get("useContributor".$nr) == 1)
|
||||||
|
{
|
||||||
|
$link_front = '<a href="mailto:'.$params->get("emailContributor".$nr).'" target="_blank">';
|
||||||
|
$link_back = '</a>';
|
||||||
|
}
|
||||||
|
elseif($params->get("useContributor".$nr) == 2)
|
||||||
|
{
|
||||||
|
$link_front = '<a href="'.$params->get("linkContributor".$nr).'" target="_blank">';
|
||||||
|
$link_back = '</a>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$link_front = '';
|
||||||
|
$link_back = '';
|
||||||
|
}
|
||||||
|
$contributors[$nr]['title'] = self::htmlEscape($params->get("titleContributor".$nr));
|
||||||
|
$contributors[$nr]['name'] = $link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $contributors;
|
||||||
|
}###HELP_SITE###
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get any component's model
|
||||||
|
*/
|
||||||
|
public static function getModel($name, $path = JPATH_COMPONENT_SITE, $Component = '###Component###', $config = array())
|
||||||
|
{
|
||||||
|
// fix the name
|
||||||
|
$name = self::safeString($name);
|
||||||
|
// full path to models
|
||||||
|
$fullPathModels = $path . '/models';
|
||||||
|
// load the model file
|
||||||
|
JModelLegacy::addIncludePath($fullPathModels, $Component . 'Model');
|
||||||
|
// make sure the table path is loaded
|
||||||
|
if (!isset($config['table_path']) || !self::checkString($config['table_path']))
|
||||||
|
{
|
||||||
|
// This is the JCB default path to tables in Joomla 3.x
|
||||||
|
$config['table_path'] = JPATH_ADMINISTRATOR . '/components/com_' . strtolower($Component) . '/tables';
|
||||||
|
}
|
||||||
|
// get instance
|
||||||
|
$model = JModelLegacy::getInstance($name, $Component . 'Model', $config);
|
||||||
|
// if model not found (strange)
|
||||||
|
if ($model == false)
|
||||||
|
{
|
||||||
|
jimport('joomla.filesystem.file');
|
||||||
|
// get file path
|
||||||
|
$filePath = $path . '/' . $name . '.php';
|
||||||
|
$fullPathModel = $fullPathModels . '/' . $name . '.php';
|
||||||
|
// check if it exists
|
||||||
|
if (File::exists($filePath))
|
||||||
|
{
|
||||||
|
// get the file
|
||||||
|
require_once $filePath;
|
||||||
|
}
|
||||||
|
elseif (File::exists($fullPathModel))
|
||||||
|
{
|
||||||
|
// get the file
|
||||||
|
require_once $fullPathModel;
|
||||||
|
}
|
||||||
|
// build class names
|
||||||
|
$modelClass = $Component . 'Model' . $name;
|
||||||
|
if (class_exists($modelClass))
|
||||||
|
{
|
||||||
|
// initialize the model
|
||||||
|
return new $modelClass($config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add to asset Table
|
||||||
|
*/
|
||||||
|
public static function setAsset($id, $table, $inherit = true)
|
||||||
|
{
|
||||||
|
$parent = JTable::getInstance('Asset');
|
||||||
|
$parent->loadByName('com_###component###');
|
||||||
|
|
||||||
|
$parentId = $parent->id;
|
||||||
|
$name = 'com_###component###.'.$table.'.'.$id;
|
||||||
|
$title = '';
|
||||||
|
|
||||||
|
$asset = JTable::getInstance('Asset');
|
||||||
|
$asset->loadByName($name);
|
||||||
|
|
||||||
|
// Check for an error.
|
||||||
|
$error = $asset->getError();
|
||||||
|
|
||||||
|
if ($error)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Specify how a new or moved node asset is inserted into the tree.
|
||||||
|
if ($asset->parent_id != $parentId)
|
||||||
|
{
|
||||||
|
$asset->setLocation($parentId, 'last-child');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare the asset to be stored.
|
||||||
|
$asset->parent_id = $parentId;
|
||||||
|
$asset->name = $name;
|
||||||
|
$asset->title = $title;
|
||||||
|
// get the default asset rules
|
||||||
|
$rules = self::getDefaultAssetRules('com_###component###', $table, $inherit);
|
||||||
|
if ($rules instanceof JAccessRules)
|
||||||
|
{
|
||||||
|
$asset->rules = (string) $rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$asset->check() || !$asset->store())
|
||||||
|
{
|
||||||
|
JFactory::getApplication()->enqueueMessage($asset->getError(), 'warning');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Create an asset_id or heal one that is corrupted.
|
||||||
|
$object = new stdClass();
|
||||||
|
|
||||||
|
// Must be a valid primary key value.
|
||||||
|
$object->id = $id;
|
||||||
|
$object->asset_id = (int) $asset->id;
|
||||||
|
|
||||||
|
// Update their asset_id to link to the asset table.
|
||||||
|
return JFactory::getDbo()->updateObject('#__###component###_'.$table, $object, 'id');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default asset Rules for a component/view.
|
||||||
|
*/
|
||||||
|
protected static function getDefaultAssetRules($component, $view, $inherit = true)
|
||||||
|
{
|
||||||
|
// if new or inherited
|
||||||
|
$assetId = 0;
|
||||||
|
// Only get the actual item rules if not inheriting
|
||||||
|
if (!$inherit)
|
||||||
|
{
|
||||||
|
// Need to find the asset id by the name of the component.
|
||||||
|
$db = JFactory::getDbo();
|
||||||
|
$query = $db->getQuery(true)
|
||||||
|
->select($db->quoteName('id'))
|
||||||
|
->from($db->quoteName('#__assets'))
|
||||||
|
->where($db->quoteName('name') . ' = ' . $db->quote($component));
|
||||||
|
$db->setQuery($query);
|
||||||
|
$db->execute();
|
||||||
|
// check that there is a value
|
||||||
|
if ($db->getNumRows())
|
||||||
|
{
|
||||||
|
// asset already set so use saved rules
|
||||||
|
$assetId = (int) $db->loadResult();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// get asset rules
|
||||||
|
$result = JAccess::getAssetRules($assetId);
|
||||||
|
if ($result instanceof JAccessRules)
|
||||||
|
{
|
||||||
|
$_result = (string) $result;
|
||||||
|
$_result = json_decode($_result);
|
||||||
|
foreach ($_result as $name => &$rule)
|
||||||
|
{
|
||||||
|
$v = explode('.', $name);
|
||||||
|
if ($view !== $v[0])
|
||||||
|
{
|
||||||
|
// remove since it is not part of this view
|
||||||
|
unset($_result->$name);
|
||||||
|
}
|
||||||
|
elseif ($inherit)
|
||||||
|
{
|
||||||
|
// clear the value since we inherit
|
||||||
|
$rule = array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check if there are any view values remaining
|
||||||
|
if (count((array) $_result))
|
||||||
|
{
|
||||||
|
$_result = json_encode($_result);
|
||||||
|
$_result = array($_result);
|
||||||
|
// Instantiate and return the JAccessRules object for the asset rules.
|
||||||
|
$rules = new JAccessRules($_result);
|
||||||
|
// return filtered rules
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlAppend
|
||||||
|
*
|
||||||
|
* @param SimpleXMLElement $xml The XML element reference in which to inject a comment
|
||||||
|
* @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function xmlAppend(&$xml, $node)
|
||||||
|
{
|
||||||
|
if (!$node)
|
||||||
|
{
|
||||||
|
// element was not returned
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (get_class($node))
|
||||||
|
{
|
||||||
|
case 'stdClass':
|
||||||
|
if (property_exists($node, 'comment'))
|
||||||
|
{
|
||||||
|
self::xmlComment($xml, $node->comment);
|
||||||
|
}
|
||||||
|
if (property_exists($node, 'fieldXML'))
|
||||||
|
{
|
||||||
|
self::xmlAppend($xml, $node->fieldXML);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'SimpleXMLElement':
|
||||||
|
$domXML = dom_import_simplexml($xml);
|
||||||
|
$domNode = dom_import_simplexml($node);
|
||||||
|
$domXML->appendChild($domXML->ownerDocument->importNode($domNode, true));
|
||||||
|
$xml = simplexml_import_dom($domXML);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlComment
|
||||||
|
*
|
||||||
|
* @param SimpleXMLElement $xml The XML element reference in which to inject a comment
|
||||||
|
* @param string $comment The comment to inject
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function xmlComment(&$xml, $comment)
|
||||||
|
{
|
||||||
|
$domXML = dom_import_simplexml($xml);
|
||||||
|
$domComment = new DOMComment($comment);
|
||||||
|
$nodeTarget = $domXML->ownerDocument->importNode($domComment, true);
|
||||||
|
$domXML->appendChild($nodeTarget);
|
||||||
|
$xml = simplexml_import_dom($domXML);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlAddAttributes
|
||||||
|
*
|
||||||
|
* @param SimpleXMLElement $xml The XML element reference in which to inject a comment
|
||||||
|
* @param array $attributes The attributes to apply to the XML element
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function xmlAddAttributes(&$xml, $attributes = array())
|
||||||
|
{
|
||||||
|
foreach ($attributes as $key => $value)
|
||||||
|
{
|
||||||
|
$xml->addAttribute($key, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlAddOptions
|
||||||
|
*
|
||||||
|
* @param SimpleXMLElement $xml The XML element reference in which to inject a comment
|
||||||
|
* @param array $options The options to apply to the XML element
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function xmlAddOptions(&$xml, $options = array())
|
||||||
|
{
|
||||||
|
foreach ($options as $key => $value)
|
||||||
|
{
|
||||||
|
$addOption = $xml->addChild('option');
|
||||||
|
$addOption->addAttribute('value', $key);
|
||||||
|
$addOption[] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the field object
|
||||||
|
*
|
||||||
|
* @param array $attributes The array of attributes
|
||||||
|
* @param string $default The default of the field
|
||||||
|
* @param array $options The options to apply to the XML element
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function getFieldObject(&$attributes, $default = '', $options = null)
|
||||||
|
{
|
||||||
|
// make sure we have attributes and a type value
|
||||||
|
if (self::checkArray($attributes) && isset($attributes['type']))
|
||||||
|
{
|
||||||
|
// make sure the form helper class is loaded
|
||||||
|
if (!method_exists('JFormHelper', 'loadFieldType'))
|
||||||
|
{
|
||||||
|
jimport('joomla.form.form');
|
||||||
|
}
|
||||||
|
// get field type
|
||||||
|
$field = JFormHelper::loadFieldType($attributes['type'], true);
|
||||||
|
// get field xml
|
||||||
|
$XML = self::getFieldXML($attributes, $options);
|
||||||
|
// setup the field
|
||||||
|
$field->setup($XML, $default);
|
||||||
|
// return the field object
|
||||||
|
return $field;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the field xml
|
||||||
|
*
|
||||||
|
* @param array $attributes The array of attributes
|
||||||
|
* @param array $options The options to apply to the XML element
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function getFieldXML(&$attributes, $options = null)
|
||||||
|
{
|
||||||
|
// make sure we have attributes and a type value
|
||||||
|
if (self::checkArray($attributes))
|
||||||
|
{
|
||||||
|
// start field xml
|
||||||
|
$XML = new SimpleXMLElement('<field/>');
|
||||||
|
// load the attributes
|
||||||
|
self::xmlAddAttributes($XML, $attributes);
|
||||||
|
// check if we have options
|
||||||
|
if (self::checkArray($options))
|
||||||
|
{
|
||||||
|
// load the options
|
||||||
|
self::xmlAddOptions($XML, $options);
|
||||||
|
}
|
||||||
|
// return the field xml
|
||||||
|
return $XML;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render Bool Button
|
||||||
|
*
|
||||||
|
* @param array $args All the args for the button
|
||||||
|
* 0) name
|
||||||
|
* 1) additional (options class) // not used at this time
|
||||||
|
* 2) default
|
||||||
|
* 3) yes (name)
|
||||||
|
* 4) no (name)
|
||||||
|
*
|
||||||
|
* @return string The input html of the button
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function renderBoolButton()
|
||||||
|
{
|
||||||
|
$args = func_get_args();
|
||||||
|
// check if there is additional button class
|
||||||
|
$additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time
|
||||||
|
// button attributes
|
||||||
|
$buttonAttributes = array(
|
||||||
|
'type' => 'radio',
|
||||||
|
'name' => isset($args[0]) ? self::htmlEscape($args[0]) : 'bool_button',
|
||||||
|
'label' => isset($args[0]) ? self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool Button', // not seen anyway
|
||||||
|
'class' => 'btn-group',
|
||||||
|
'filter' => 'INT',
|
||||||
|
'default' => isset($args[2]) ? (int) $args[2] : 0);
|
||||||
|
// set the button options
|
||||||
|
$buttonOptions = array(
|
||||||
|
'1' => isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES',
|
||||||
|
'0' => isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO');
|
||||||
|
// return the input
|
||||||
|
return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input;
|
||||||
|
}###HELPER_UIKIT######HELPER_CREATEUSER###
|
||||||
|
|
||||||
|
public static function isPublished($id,$type)
|
||||||
|
{
|
||||||
|
if ($type == 'raw')
|
||||||
|
{
|
||||||
|
$type = 'item';
|
||||||
|
}
|
||||||
|
$db = JFactory::getDbo();
|
||||||
|
$query = $db->getQuery(true);
|
||||||
|
$query->select(array('a.published'));
|
||||||
|
$query->from('#__###component###_'.$type.' AS a');
|
||||||
|
$query->where('a.id = '. (int) $id);
|
||||||
|
$query->where('a.published = 1');
|
||||||
|
$db->setQuery($query);
|
||||||
|
$db->execute();
|
||||||
|
$found = $db->getNumRows();
|
||||||
|
if($found)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getGroupName($id)
|
||||||
|
{
|
||||||
|
$db = JFactory::getDBO();
|
||||||
|
$query = $db->getQuery(true);
|
||||||
|
$query->select(array('a.title'));
|
||||||
|
$query->from('#__usergroups AS a');
|
||||||
|
$query->where('a.id = '. (int) $id);
|
||||||
|
$db->setQuery($query);
|
||||||
|
$db->execute();
|
||||||
|
$found = $db->getNumRows();
|
||||||
|
if($found)
|
||||||
|
{
|
||||||
|
return $db->loadResult();
|
||||||
|
}
|
||||||
|
return $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the action permissions
|
||||||
|
*
|
||||||
|
* @param string $view The related view name
|
||||||
|
* @param int $record The item to act upon
|
||||||
|
* @param string $views The related list view name
|
||||||
|
* @param mixed $target Only get this permission (like edit, create, delete)
|
||||||
|
* @param string $component The target component
|
||||||
|
* @param object $user The user whose permissions we are loading
|
||||||
|
*
|
||||||
|
* @return object The JObject of permission/authorised actions
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function getActions($view, &$record = null, $views = null, $target = null, $component = '###component###', $user = 'null')
|
||||||
|
{
|
||||||
|
// load the user if not given
|
||||||
|
if (!self::checkObject($user))
|
||||||
|
{
|
||||||
|
// get the user object
|
||||||
|
$user = JFactory::getUser();
|
||||||
|
}
|
||||||
|
// load the JObject
|
||||||
|
$result = new JObject;
|
||||||
|
// make view name safe (just incase)
|
||||||
|
$view = self::safeString($view);
|
||||||
|
if (self::checkString($views))
|
||||||
|
{
|
||||||
|
$views = self::safeString($views);
|
||||||
|
}
|
||||||
|
// get all actions from component
|
||||||
|
$actions = JAccess::getActionsFromFile(
|
||||||
|
JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml',
|
||||||
|
"/access/section[@name='component']/"
|
||||||
|
);
|
||||||
|
// if non found then return empty JObject
|
||||||
|
if (empty($actions))
|
||||||
|
{
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
// get created by if not found
|
||||||
|
if (self::checkObject($record) && !isset($record->created_by) && isset($record->id))
|
||||||
|
{
|
||||||
|
$record->created_by = self::getVar($view, $record->id, 'id', 'created_by', '=', $component);
|
||||||
|
}
|
||||||
|
// set actions only set in component settings
|
||||||
|
$componentActions = array('core.admin', 'core.manage', 'core.options', 'core.export');
|
||||||
|
// check if we have a target
|
||||||
|
$checkTarget = false;
|
||||||
|
if ($target)
|
||||||
|
{
|
||||||
|
// convert to an array
|
||||||
|
if (self::checkString($target))
|
||||||
|
{
|
||||||
|
$target = array($target);
|
||||||
|
}
|
||||||
|
// check if we are good to go
|
||||||
|
if (self::checkArray($target))
|
||||||
|
{
|
||||||
|
$checkTarget = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// loop the actions and set the permissions
|
||||||
|
foreach ($actions as $action)
|
||||||
|
{
|
||||||
|
// check target action filter
|
||||||
|
if ($checkTarget && self::filterActions($view, $action->name, $target))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// set to use component default
|
||||||
|
$fallback = true;
|
||||||
|
// reset permission per/action
|
||||||
|
$permission = false;
|
||||||
|
$catpermission = false;
|
||||||
|
// set area
|
||||||
|
$area = 'comp';
|
||||||
|
// check if the record has an ID and the action is item related (not a component action)
|
||||||
|
if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) &&
|
||||||
|
(strpos($action->name, 'core.') !== false || strpos($action->name, $view . '.') !== false))
|
||||||
|
{
|
||||||
|
// we are in item
|
||||||
|
$area = 'item';
|
||||||
|
// The record has been set. Check the record permissions.
|
||||||
|
$permission = $user->authorise($action->name, 'com_' . $component . '.' . $view . '.' . (int) $record->id);
|
||||||
|
// if no permission found, check edit own
|
||||||
|
if (!$permission)
|
||||||
|
{
|
||||||
|
// With edit, if the created_by matches current user then dig deeper.
|
||||||
|
if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id))
|
||||||
|
{
|
||||||
|
// the correct target
|
||||||
|
$coreCheck = (array) explode('.', $action->name);
|
||||||
|
// check that we have both local and global access
|
||||||
|
if ($user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component . '.' . $view . '.' . (int) $record->id) &&
|
||||||
|
$user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component))
|
||||||
|
{
|
||||||
|
// allow edit
|
||||||
|
$result->set($action->name, true);
|
||||||
|
// set not to use global default
|
||||||
|
// because we already validated it
|
||||||
|
$fallback = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// do not allow edit
|
||||||
|
$result->set($action->name, false);
|
||||||
|
$fallback = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0)
|
||||||
|
{
|
||||||
|
// we are in item
|
||||||
|
$area = 'category';
|
||||||
|
// set the core check
|
||||||
|
$coreCheck = explode('.', $action->name);
|
||||||
|
$core = $coreCheck[0];
|
||||||
|
// make sure we use the core. action check for the categories
|
||||||
|
if (strpos($action->name, $view) !== false && strpos($action->name, 'core.') === false )
|
||||||
|
{
|
||||||
|
$coreCheck[0] = 'core';
|
||||||
|
$categoryCheck = implode('.', $coreCheck);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$categoryCheck = $action->name;
|
||||||
|
}
|
||||||
|
// The record has a category. Check the category permissions.
|
||||||
|
$catpermission = $user->authorise($categoryCheck, 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid);
|
||||||
|
if (!$catpermission && !is_null($catpermission))
|
||||||
|
{
|
||||||
|
// With edit, if the created_by matches current user then dig deeper.
|
||||||
|
if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id))
|
||||||
|
{
|
||||||
|
// check that we have both local and global access
|
||||||
|
if ($user->authorise('core.edit.own', 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid) &&
|
||||||
|
$user->authorise($core . '.edit.own', 'com_' . $component))
|
||||||
|
{
|
||||||
|
// allow edit
|
||||||
|
$result->set($action->name, true);
|
||||||
|
// set not to use global default
|
||||||
|
// because we already validated it
|
||||||
|
$fallback = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// do not allow edit
|
||||||
|
$result->set($action->name, false);
|
||||||
|
$fallback = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if allowed then fallback on component global settings
|
||||||
|
if ($fallback)
|
||||||
|
{
|
||||||
|
// if item/category blocks access then don't fall back on global
|
||||||
|
if ((($area === 'item') && !$permission) || (($area === 'category') && !$catpermission))
|
||||||
|
{
|
||||||
|
// do not allow
|
||||||
|
$result->set($action->name, false);
|
||||||
|
}
|
||||||
|
// Finally remember the global settings have the final say. (even if item allow)
|
||||||
|
// The local item permissions can block, but it can't open and override of global permissions.
|
||||||
|
// Since items are created by users and global permissions is set by system admin.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$result->set($action->name, $user->authorise($action->name, 'com_' . $component));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the action permissions
|
||||||
|
*
|
||||||
|
* @param string $action The action to check
|
||||||
|
* @param array $targets The array of target actions
|
||||||
|
*
|
||||||
|
* @return boolean true if action should be filtered out
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected static function filterActions(&$view, &$action, &$targets)
|
||||||
|
{
|
||||||
|
foreach ($targets as $target)
|
||||||
|
{
|
||||||
|
if (strpos($action, $view . '.' . $target) !== false ||
|
||||||
|
strpos($action, 'core.' . $target) !== false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if we are connected
|
||||||
|
* Thanks https://stackoverflow.com/a/4860432/1429677
|
||||||
|
*
|
||||||
|
* @returns bool true on success
|
||||||
|
*/
|
||||||
|
public static function isConnected()
|
||||||
|
{
|
||||||
|
// If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right?
|
||||||
|
$connected = @fsockopen("www.example.com", 80);
|
||||||
|
// website, port (try 80 or 443)
|
||||||
|
if ($connected)
|
||||||
|
{
|
||||||
|
//action when connected
|
||||||
|
$is_conn = true;
|
||||||
|
fclose($connected);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//action in connection failure
|
||||||
|
$is_conn = false;
|
||||||
|
}
|
||||||
|
return $is_conn;
|
||||||
|
}
|
||||||
|
|
||||||
|
// typo sorry!
|
||||||
|
public static function sorten($string, $length = 40, $addTip = true)
|
||||||
|
{
|
||||||
|
return self::shorten($string, $length, $addTip);
|
||||||
|
}###HELPER_SITE_LICENSE_LOCK######GET_CRYPT_KEY###
|
||||||
|
}
|
@ -32,7 +32,7 @@ $document->addScript('components/com_###component###/assets/js/admin.js');
|
|||||||
|
|
||||||
// require helper files
|
// require helper files
|
||||||
JLoader::register('###Component###Helper', __DIR__ . '/helpers/###component###.php');###HELPER_EMAIL###
|
JLoader::register('###Component###Helper', __DIR__ . '/helpers/###component###.php');###HELPER_EMAIL###
|
||||||
JLoader::register('JHtmlBatch_', __DIR__ . '/helpers/html/batch_.php');###LICENSE_LOCKED_INT######ADMIN_GLOBAL_EVENT######ADMIN_POWER_EVENT###
|
JLoader::register('JHtmlBatch_', __DIR__ . '/helpers/html/batch_.php');###LICENSE_LOCKED_INT######ADMIN_GLOBAL_EVENT###
|
||||||
|
|
||||||
// Get an instance of the controller prefixed by ###Component###
|
// Get an instance of the controller prefixed by ###Component###
|
||||||
$controller = JControllerLegacy::getInstance('###Component###');
|
$controller = JControllerLegacy::getInstance('###Component###');
|
||||||
|
@ -26,7 +26,7 @@ $document->addScript('components/com_###component###/assets/js/site.js');
|
|||||||
|
|
||||||
// Require helper files
|
// Require helper files
|
||||||
JLoader::register('###Component###Helper', __DIR__ . '/helpers/###component###.php');###HELPER_EMAIL###
|
JLoader::register('###Component###Helper', __DIR__ . '/helpers/###component###.php');###HELPER_EMAIL###
|
||||||
JLoader::register('###Component###HelperRoute', __DIR__ . '/helpers/route.php');###LICENSE_LOCKED_INT######SITE_GLOBAL_EVENT######SITE_POWER_EVENT###
|
JLoader::register('###Component###HelperRoute', __DIR__ . '/helpers/route.php');###LICENSE_LOCKED_INT######SITE_GLOBAL_EVENT###
|
||||||
|
|
||||||
// Get an instance of the controller prefixed by ###Component###
|
// Get an instance of the controller prefixed by ###Component###
|
||||||
$controller = JControllerLegacy::getInstance('###Component###');
|
$controller = JControllerLegacy::getInstance('###Component###');
|
||||||
|
784
admin/compiler/joomla_3/settings_componentbuilder.json
Normal file
784
admin/compiler/joomla_3/settings_componentbuilder.json
Normal file
@ -0,0 +1,784 @@
|
|||||||
|
{
|
||||||
|
"create": {
|
||||||
|
"admin": {
|
||||||
|
"assets": {
|
||||||
|
"css": "css",
|
||||||
|
"images": {
|
||||||
|
"icons": "icons"
|
||||||
|
},
|
||||||
|
"js": "js"
|
||||||
|
},
|
||||||
|
"controllers": "controllers",
|
||||||
|
"helpers": {
|
||||||
|
"html": "html"
|
||||||
|
},
|
||||||
|
"language": {
|
||||||
|
"en-GB": "en-GB"
|
||||||
|
},
|
||||||
|
"layouts": "layouts",
|
||||||
|
"models": {
|
||||||
|
"fields": "fields",
|
||||||
|
"forms": "forms",
|
||||||
|
"rules": "rules"
|
||||||
|
},
|
||||||
|
"sql": {
|
||||||
|
"updates": {
|
||||||
|
"mysql": "mysql"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tables": "tables",
|
||||||
|
"views": "views"
|
||||||
|
},
|
||||||
|
"site": {
|
||||||
|
"assets": {
|
||||||
|
"css": "css",
|
||||||
|
"images": "images",
|
||||||
|
"js": "js"
|
||||||
|
},
|
||||||
|
"controllers": "controllers",
|
||||||
|
"helpers": "helpers",
|
||||||
|
"language": {
|
||||||
|
"en-GB": "en-GB"
|
||||||
|
},
|
||||||
|
"layouts": "layouts",
|
||||||
|
"models": "models",
|
||||||
|
"views": "views"
|
||||||
|
},
|
||||||
|
"media": {
|
||||||
|
"css": "css",
|
||||||
|
"images": "images",
|
||||||
|
"js": "js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"move": {
|
||||||
|
"static": {
|
||||||
|
"access.xml": {
|
||||||
|
"naam": "access.xml",
|
||||||
|
"path": "c0mp0n3nt/admin",
|
||||||
|
"rename": false,
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"config.xml": {
|
||||||
|
"naam": "config.xml",
|
||||||
|
"path": "c0mp0n3nt/admin",
|
||||||
|
"rename": false,
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"JControllerLegacy.php": {
|
||||||
|
"naam": "JControllerLegacy.php",
|
||||||
|
"path": "c0mp0n3nt/admin",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "controller.php",
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"component.xml": {
|
||||||
|
"naam": "component.xml",
|
||||||
|
"path": "c0mp0n3nt/",
|
||||||
|
"rename": "component",
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"component_admin.php": {
|
||||||
|
"naam": "component_admin.php",
|
||||||
|
"path": "c0mp0n3nt/admin",
|
||||||
|
"rename": "component_admin",
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"admin.css": {
|
||||||
|
"naam": "admin.css",
|
||||||
|
"path": "c0mp0n3nt/admin/assets/css",
|
||||||
|
"rename": false,
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"admin.js": {
|
||||||
|
"naam": "admin.js",
|
||||||
|
"path": "c0mp0n3nt/admin/assets/js",
|
||||||
|
"rename": false,
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"site.css": {
|
||||||
|
"naam": "site.css",
|
||||||
|
"path": "c0mp0n3nt/site/assets/css",
|
||||||
|
"rename": false,
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"site.js": {
|
||||||
|
"naam": "site.js",
|
||||||
|
"path": "c0mp0n3nt/site/assets/js",
|
||||||
|
"rename": false,
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"batch_.php": {
|
||||||
|
"naam": "batch_.php",
|
||||||
|
"path": "c0mp0n3nt/admin/helpers/html",
|
||||||
|
"rename": false,
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"batchselection.php": {
|
||||||
|
"naam": "batchselection.php",
|
||||||
|
"path": "c0mp0n3nt/admin/layouts",
|
||||||
|
"rename": false,
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"component_site.php": {
|
||||||
|
"naam": "component_site.php",
|
||||||
|
"path": "c0mp0n3nt/site",
|
||||||
|
"rename": "component_site",
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"router.php": {
|
||||||
|
"naam": "router.php",
|
||||||
|
"path": "c0mp0n3nt/site",
|
||||||
|
"rename": false,
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"routeHelper.php": {
|
||||||
|
"naam": "routeHelper.php",
|
||||||
|
"path": "c0mp0n3nt/site/helpers",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "route.php",
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"JControllerLegacySITE.php": {
|
||||||
|
"naam": "JControllerLegacySITE.php",
|
||||||
|
"path": "c0mp0n3nt/site",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "controller.php",
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"Helper.php": {
|
||||||
|
"naam": "JCB_Helper.php",
|
||||||
|
"path": "c0mp0n3nt/admin/helpers",
|
||||||
|
"rename": "JCB_Helper",
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"Helper_site.php": {
|
||||||
|
"naam": "JCB_Helper_site.php",
|
||||||
|
"path": "c0mp0n3nt/site/helpers",
|
||||||
|
"rename": "JCB_Helper_site",
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"Helper_category.php": {
|
||||||
|
"naam": "Helper_category.php",
|
||||||
|
"path": "c0mp0n3nt/site/helpers",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "category.php",
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"script.php": {
|
||||||
|
"naam": "script.php",
|
||||||
|
"path": "c0mp0n3nt/",
|
||||||
|
"rename": false,
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"install.mysql.utf8.sql": {
|
||||||
|
"naam": "install.mysql.utf8.sql",
|
||||||
|
"path": "c0mp0n3nt/admin/sql",
|
||||||
|
"rename": false,
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"uninstall.mysql.utf8.sql": {
|
||||||
|
"naam": "uninstall.mysql.utf8.sql",
|
||||||
|
"path": "c0mp0n3nt/admin/sql",
|
||||||
|
"rename": false,
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"headercheck_admin.php": {
|
||||||
|
"naam": "headercheck_admin.php",
|
||||||
|
"path": "c0mp0n3nt/admin/helpers",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "headercheck.php",
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"LICENSE.txt": {
|
||||||
|
"naam": "LICENSE.txt",
|
||||||
|
"path": "c0mp0n3nt/",
|
||||||
|
"rename": false,
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"README.txt": {
|
||||||
|
"naam": "README.txt",
|
||||||
|
"path": "c0mp0n3nt/admin",
|
||||||
|
"rename": false,
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"README.md": {
|
||||||
|
"naam": "README.md",
|
||||||
|
"path": "c0mp0n3nt/",
|
||||||
|
"rename": false,
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"headercheck.php": {
|
||||||
|
"naam": "headercheck.php",
|
||||||
|
"path": "c0mp0n3nt/site/helpers",
|
||||||
|
"rename": false,
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
|
"import.gif": {
|
||||||
|
"naam": "import.gif",
|
||||||
|
"path": "c0mp0n3nt/admin/assets/images",
|
||||||
|
"rename": false,
|
||||||
|
"type": "file"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dynamic": {
|
||||||
|
"admin": {
|
||||||
|
"whmcs.php": {
|
||||||
|
"path": "c0mp0n3nt/admin",
|
||||||
|
"rename": false,
|
||||||
|
"type": "whmcs"
|
||||||
|
},
|
||||||
|
"Helper_email.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/helpers",
|
||||||
|
"rename": "Helper_",
|
||||||
|
"type": "emailer"
|
||||||
|
},
|
||||||
|
"DASHJControllerAdmin.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/controllers",
|
||||||
|
"rename": "DASHJControllerAdmin",
|
||||||
|
"type": "dashboard"
|
||||||
|
},
|
||||||
|
"DASHJModelList.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/models",
|
||||||
|
"rename": "DASHJModelList",
|
||||||
|
"type": "dashboard"
|
||||||
|
},
|
||||||
|
"DASHJViewLagacy.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "view.html.php",
|
||||||
|
"type": "dashboard"
|
||||||
|
},
|
||||||
|
"default_vdm.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW/tmpl",
|
||||||
|
"rename": false,
|
||||||
|
"type": "dashboard"
|
||||||
|
},
|
||||||
|
"default_main.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW/tmpl",
|
||||||
|
"rename": false,
|
||||||
|
"type": "dashboard"
|
||||||
|
},
|
||||||
|
"DASHdefault.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW/tmpl",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "default.php",
|
||||||
|
"type": "dashboard"
|
||||||
|
},
|
||||||
|
"dashboard.css": {
|
||||||
|
"path": "c0mp0n3nt/admin/assets/css",
|
||||||
|
"rename": false,
|
||||||
|
"type": "dashboard"
|
||||||
|
},
|
||||||
|
"filter_forms.xml": {
|
||||||
|
"path": "c0mp0n3nt/admin/models/forms",
|
||||||
|
"rename": "filter_forms",
|
||||||
|
"type": "filter"
|
||||||
|
},
|
||||||
|
"module_forms.xml": {
|
||||||
|
"path": "c0mp0n3nt/admin/models/forms",
|
||||||
|
"rename": "module_forms",
|
||||||
|
"type": "single"
|
||||||
|
},
|
||||||
|
"module_forms.js": {
|
||||||
|
"path": "c0mp0n3nt/media/js",
|
||||||
|
"rename": "module_forms",
|
||||||
|
"type": "single"
|
||||||
|
},
|
||||||
|
"edit.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW/tmpl",
|
||||||
|
"rename": false,
|
||||||
|
"type": "single"
|
||||||
|
},
|
||||||
|
"JModelAdmin.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/models",
|
||||||
|
"rename": "JModelAdmin",
|
||||||
|
"type": "single"
|
||||||
|
},
|
||||||
|
"JControllerForm.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/controllers",
|
||||||
|
"rename": "JControllerForm",
|
||||||
|
"type": "single"
|
||||||
|
},
|
||||||
|
"JTable.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/tables",
|
||||||
|
"rename": "JTable",
|
||||||
|
"type": "single"
|
||||||
|
},
|
||||||
|
"submitbutton.js": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW",
|
||||||
|
"rename": false,
|
||||||
|
"type": "single"
|
||||||
|
},
|
||||||
|
"JViewLegacy_edit.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "view.html.php",
|
||||||
|
"type": "single"
|
||||||
|
},
|
||||||
|
"view.css": {
|
||||||
|
"path": "c0mp0n3nt/admin/assets/css",
|
||||||
|
"rename": "view",
|
||||||
|
"type": "single"
|
||||||
|
},
|
||||||
|
"JControllerAdmin.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/controllers",
|
||||||
|
"rename": "JControllerAdmin",
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"JModelList.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/models",
|
||||||
|
"rename": "JModelList",
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"views.css": {
|
||||||
|
"path": "c0mp0n3nt/admin/assets/css",
|
||||||
|
"rename": "views",
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"JViewLegacy_list.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "view.html.php",
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"default.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW/tmpl",
|
||||||
|
"rename": false,
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"default_batch_body.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW/tmpl",
|
||||||
|
"rename": false,
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"default_batch_footer.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW/tmpl",
|
||||||
|
"rename": false,
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"default_toolbar.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW/tmpl",
|
||||||
|
"rename": false,
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"default_head.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW/tmpl",
|
||||||
|
"rename": false,
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"default_body.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW/tmpl",
|
||||||
|
"rename": false,
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"default_foot.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW/tmpl",
|
||||||
|
"rename": false,
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"JFormRule.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/models/rules",
|
||||||
|
"rename": "JFormRule",
|
||||||
|
"type": "rule"
|
||||||
|
},
|
||||||
|
"layout_admin.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/layouts",
|
||||||
|
"rename": "layout_admin",
|
||||||
|
"type": "layout"
|
||||||
|
},
|
||||||
|
"layoutoverride.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/layouts/VIEW",
|
||||||
|
"rename": "layoutoverride",
|
||||||
|
"type": "layoutoverride"
|
||||||
|
},
|
||||||
|
"layoutitems.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/layouts/VIEW",
|
||||||
|
"rename": "layoutitems",
|
||||||
|
"type": "layoutitems"
|
||||||
|
},
|
||||||
|
"layoutfull.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/layouts/VIEW",
|
||||||
|
"rename": "layoutfull",
|
||||||
|
"type": "layoutfull"
|
||||||
|
},
|
||||||
|
"layoutlinkedview.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/layouts/VIEW",
|
||||||
|
"rename": "layoutlinkedview",
|
||||||
|
"type": "layoutlinkedview"
|
||||||
|
},
|
||||||
|
"layouttitle.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/layouts/VIEW",
|
||||||
|
"rename": "layouttitle",
|
||||||
|
"type": "layouttitle"
|
||||||
|
},
|
||||||
|
"layoutpublished.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/layouts/VIEW",
|
||||||
|
"rename": "layoutpublished",
|
||||||
|
"type": "layoutpublished"
|
||||||
|
},
|
||||||
|
"layoutmetadata.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/layouts/VIEW",
|
||||||
|
"rename": "layoutmetadata",
|
||||||
|
"type": "layoutmetadata"
|
||||||
|
},
|
||||||
|
"JFormFieldCustom.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/models/fields",
|
||||||
|
"rename": "JFormFieldCustom",
|
||||||
|
"type": "fieldcustom"
|
||||||
|
},
|
||||||
|
"JFormFieldList.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/models/fields",
|
||||||
|
"rename": "JFormFieldList",
|
||||||
|
"type": "fieldlist"
|
||||||
|
},
|
||||||
|
"JFormFieldRadio.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/models/fields",
|
||||||
|
"rename": "JFormFieldRadio",
|
||||||
|
"type": "fieldradio"
|
||||||
|
},
|
||||||
|
"JFormFieldCheckboxes.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/models/fields",
|
||||||
|
"rename": "JFormFieldCheckboxes",
|
||||||
|
"type": "fieldcheckboxes"
|
||||||
|
},
|
||||||
|
"JFormFieldUser.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/models/fields",
|
||||||
|
"rename": "JFormFieldUser",
|
||||||
|
"type": "fielduser"
|
||||||
|
},
|
||||||
|
"JControllerLegacyAjax.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/controllers",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "ajax.json.php",
|
||||||
|
"type": "ajax"
|
||||||
|
},
|
||||||
|
"JModelListAjax.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/models",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "ajax.php",
|
||||||
|
"type": "ajax"
|
||||||
|
},
|
||||||
|
"JControllerLegacy_import.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/controllers",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "import.php",
|
||||||
|
"type": "import"
|
||||||
|
},
|
||||||
|
"JModelLegacy_import.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/models",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "import.php",
|
||||||
|
"type": "import"
|
||||||
|
},
|
||||||
|
"JViewLegacy_import.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/import",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "view.html.php",
|
||||||
|
"type": "import"
|
||||||
|
},
|
||||||
|
"default_import.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/import/tmpl",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "default.php",
|
||||||
|
"type": "import"
|
||||||
|
},
|
||||||
|
"JControllerLegacy_import_custom.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/controllers",
|
||||||
|
"rename": "JControllerLegacy_import_custom",
|
||||||
|
"type": "customimport"
|
||||||
|
},
|
||||||
|
"JModelLegacy_import_custom.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/models",
|
||||||
|
"rename": "JModelLegacy_import_custom",
|
||||||
|
"type": "customimport"
|
||||||
|
},
|
||||||
|
"JViewLegacy_import_custom.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "view.html.php",
|
||||||
|
"type": "customimport"
|
||||||
|
},
|
||||||
|
"default_import_custom.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW/tmpl",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "default.php",
|
||||||
|
"type": "customimport"
|
||||||
|
},
|
||||||
|
"JControllerLegacyHelp.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/controllers",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "help.php",
|
||||||
|
"type": "help"
|
||||||
|
},
|
||||||
|
"1.0.0.sql": {
|
||||||
|
"path": "c0mp0n3nt/admin/sql/updates/mysql",
|
||||||
|
"rename": "1.0.0",
|
||||||
|
"type": "sql_update"
|
||||||
|
},
|
||||||
|
"update_server.xml": {
|
||||||
|
"path": "c0mp0n3nt/",
|
||||||
|
"rename": "update_server",
|
||||||
|
"type": "update_server"
|
||||||
|
},
|
||||||
|
"viewFile.js": {
|
||||||
|
"path": "c0mp0n3nt/admin/assets/js",
|
||||||
|
"rename": "viewFile",
|
||||||
|
"type": "javascript_file"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"site": {
|
||||||
|
"JViewLegacy_list_site.php": {
|
||||||
|
"path": "c0mp0n3nt/site/views/VIEW",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "view.html.php",
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"JModelList_site.php": {
|
||||||
|
"path": "c0mp0n3nt/site/models",
|
||||||
|
"rename": "JModelList_site",
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"views_site.css": {
|
||||||
|
"path": "c0mp0n3nt/site/assets/css",
|
||||||
|
"rename": "views_site",
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"default_list_site.php": {
|
||||||
|
"path": "c0mp0n3nt/site/views/VIEW/tmpl",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "default.php",
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"JViewLegacy_site.php": {
|
||||||
|
"path": "c0mp0n3nt/site/views/VIEW",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "view.html.php",
|
||||||
|
"type": "single"
|
||||||
|
},
|
||||||
|
"view_site.css": {
|
||||||
|
"path": "c0mp0n3nt/site/assets/css",
|
||||||
|
"rename": "view_site",
|
||||||
|
"type": "single"
|
||||||
|
},
|
||||||
|
"JModelItem_site.php": {
|
||||||
|
"path": "c0mp0n3nt/site/models",
|
||||||
|
"rename": "JModelItem_site",
|
||||||
|
"type": "single"
|
||||||
|
},
|
||||||
|
"default_site.php": {
|
||||||
|
"path": "c0mp0n3nt/site/views/VIEW/tmpl",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "default.php",
|
||||||
|
"type": "single"
|
||||||
|
},
|
||||||
|
"default_site_template.php": {
|
||||||
|
"path": "c0mp0n3nt/site/views/VIEW/tmpl",
|
||||||
|
"rename": "site_template",
|
||||||
|
"type": "template"
|
||||||
|
},
|
||||||
|
"layout_site.php": {
|
||||||
|
"path": "c0mp0n3nt/site/layouts",
|
||||||
|
"rename": "layout_site",
|
||||||
|
"type": "layout"
|
||||||
|
},
|
||||||
|
"layoutoverride.php": {
|
||||||
|
"path": "c0mp0n3nt/site/layouts/VIEW",
|
||||||
|
"rename": "layoutoverride",
|
||||||
|
"type": "layoutoverride"
|
||||||
|
},
|
||||||
|
"layoutitems.php": {
|
||||||
|
"path": "c0mp0n3nt/site/layouts/VIEW",
|
||||||
|
"rename": "layoutitems",
|
||||||
|
"type": "layoutitems"
|
||||||
|
},
|
||||||
|
"layoutfull.php": {
|
||||||
|
"path": "c0mp0n3nt/site/layouts/VIEW",
|
||||||
|
"rename": "layoutfull",
|
||||||
|
"type": "layoutfull"
|
||||||
|
},
|
||||||
|
"layoutlinkedview.php": {
|
||||||
|
"path": "c0mp0n3nt/site/layouts/VIEW",
|
||||||
|
"rename": "layoutlinkedview",
|
||||||
|
"type": "layoutlinkedview"
|
||||||
|
},
|
||||||
|
"layouttitle.php": {
|
||||||
|
"path": "c0mp0n3nt/site/layouts/VIEW",
|
||||||
|
"rename": "layouttitle",
|
||||||
|
"type": "layouttitle"
|
||||||
|
},
|
||||||
|
"layoutpublished.php": {
|
||||||
|
"path": "c0mp0n3nt/site/layouts/VIEW",
|
||||||
|
"rename": "layoutpublished",
|
||||||
|
"type": "layoutpublished"
|
||||||
|
},
|
||||||
|
"layoutmetadata.php": {
|
||||||
|
"path": "c0mp0n3nt/site/layouts/VIEW",
|
||||||
|
"rename": "layoutmetadata",
|
||||||
|
"type": "layoutmetadata"
|
||||||
|
},
|
||||||
|
"default.xml": {
|
||||||
|
"path": "c0mp0n3nt/site/views/VIEW/tmpl",
|
||||||
|
"rename": false,
|
||||||
|
"type": "menu"
|
||||||
|
},
|
||||||
|
"edit.xml": {
|
||||||
|
"path": "c0mp0n3nt/site/views/VIEW/tmpl",
|
||||||
|
"rename": false,
|
||||||
|
"type": "admin_menu"
|
||||||
|
},
|
||||||
|
"module_forms.xml": {
|
||||||
|
"path": "c0mp0n3nt/site/models/forms",
|
||||||
|
"rename": "module_forms",
|
||||||
|
"type": "edit"
|
||||||
|
},
|
||||||
|
"module_forms.js": {
|
||||||
|
"path": "c0mp0n3nt/site/models/forms",
|
||||||
|
"rename": "module_forms",
|
||||||
|
"type": "edit"
|
||||||
|
},
|
||||||
|
"edit_site.php": {
|
||||||
|
"path": "c0mp0n3nt/site/views/VIEW/tmpl",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "edit.php",
|
||||||
|
"type": "edit"
|
||||||
|
},
|
||||||
|
"JModelAdmin_site.php": {
|
||||||
|
"path": "c0mp0n3nt/site/models",
|
||||||
|
"rename": "JModelAdmin_site",
|
||||||
|
"type": "edit"
|
||||||
|
},
|
||||||
|
"JControllerForm_site.php": {
|
||||||
|
"path": "c0mp0n3nt/site/controllers",
|
||||||
|
"rename": "JControllerForm_site",
|
||||||
|
"type": "edit"
|
||||||
|
},
|
||||||
|
"submitbutton.js": {
|
||||||
|
"path": "c0mp0n3nt/site/views/VIEW",
|
||||||
|
"rename": false,
|
||||||
|
"type": "edit"
|
||||||
|
},
|
||||||
|
"JViewLegacy_edit_site.php": {
|
||||||
|
"path": "c0mp0n3nt/site/views/VIEW",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "view.html.php",
|
||||||
|
"type": "edit"
|
||||||
|
},
|
||||||
|
"view_site_edit.css": {
|
||||||
|
"path": "c0mp0n3nt/site/assets/css",
|
||||||
|
"rename": "view_site_edit",
|
||||||
|
"type": "edit"
|
||||||
|
},
|
||||||
|
"JControllerLegacyAjaxSite.php": {
|
||||||
|
"path": "c0mp0n3nt/site/controllers",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "ajax.json.php",
|
||||||
|
"type": "ajax"
|
||||||
|
},
|
||||||
|
"JModelListAjaxSite.php": {
|
||||||
|
"path": "c0mp0n3nt/site/models",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "ajax.php",
|
||||||
|
"type": "ajax"
|
||||||
|
},
|
||||||
|
"JControllerLegacyHelp_site.php": {
|
||||||
|
"path": "c0mp0n3nt/site/controllers",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "help.php",
|
||||||
|
"type": "help"
|
||||||
|
},
|
||||||
|
"JControllerForm_custom_site.php": {
|
||||||
|
"path": "c0mp0n3nt/site/controllers",
|
||||||
|
"rename": "JControllerForm_custom_site",
|
||||||
|
"type": "custom_form"
|
||||||
|
},
|
||||||
|
"submitbutton_site.js": {
|
||||||
|
"path": "c0mp0n3nt/site/views/VIEW",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "submitbutton.js",
|
||||||
|
"type": "custom_form"
|
||||||
|
},
|
||||||
|
"Helper_category_view.php": {
|
||||||
|
"path": "c0mp0n3nt/site/helpers",
|
||||||
|
"rename": "Helper_category_view",
|
||||||
|
"type": "category"
|
||||||
|
},
|
||||||
|
"viewFileSite.js": {
|
||||||
|
"path": "c0mp0n3nt/site/assets/js",
|
||||||
|
"rename": "viewFileSite",
|
||||||
|
"type": "javascript_file"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"custom_admin": {
|
||||||
|
"JViewLegacy_list_custom_admin.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "view.html.php",
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"JModelList_custom_admin.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/models",
|
||||||
|
"rename": "JModelList_custom_admin",
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"default_list_custom_admin.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW/tmpl",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "default.php",
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"JControllerAdmin_custom_admin.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/controllers",
|
||||||
|
"rename": "JControllerAdmin_custom_admin",
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"views_custom_admin.css": {
|
||||||
|
"path": "c0mp0n3nt/admin/assets/css",
|
||||||
|
"rename": "views_custom_admin",
|
||||||
|
"type": "list"
|
||||||
|
},
|
||||||
|
"view_custom_admin.css": {
|
||||||
|
"path": "c0mp0n3nt/admin/assets/css",
|
||||||
|
"rename": "view_custom_admin",
|
||||||
|
"type": "single"
|
||||||
|
},
|
||||||
|
"JViewLegacy_custom_admin.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "view.html.php",
|
||||||
|
"type": "single"
|
||||||
|
},
|
||||||
|
"JModelItem_custom_admin.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/models",
|
||||||
|
"rename": "JModelItem_custom_admin",
|
||||||
|
"type": "single"
|
||||||
|
},
|
||||||
|
"default_custom_admin.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW/tmpl",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "default.php",
|
||||||
|
"type": "single"
|
||||||
|
},
|
||||||
|
"JControllerLegacy_custom_admin.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/controllers",
|
||||||
|
"rename": "JControllerLegacy_custom_admin",
|
||||||
|
"type": "single"
|
||||||
|
},
|
||||||
|
"default_custom_admin_template.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/views/VIEW/tmpl",
|
||||||
|
"rename": "custom_admin_template",
|
||||||
|
"type": "template"
|
||||||
|
},
|
||||||
|
"layout_custom_admin.php": {
|
||||||
|
"path": "c0mp0n3nt/admin/layouts",
|
||||||
|
"rename": "layout_custom_admin",
|
||||||
|
"type": "layout"
|
||||||
|
},
|
||||||
|
"viewFileCustomAdmin.js": {
|
||||||
|
"path": "c0mp0n3nt/admin/assets/js",
|
||||||
|
"rename": "viewFileCustomAdmin",
|
||||||
|
"type": "javascript_file"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,11 @@ defined('_JEXEC') or die('Restricted access');
|
|||||||
|
|
||||||
use Joomla\CMS\Filesystem\File;
|
use Joomla\CMS\Filesystem\File;
|
||||||
use Joomla\CMS\Filesystem\Folder;
|
use Joomla\CMS\Filesystem\Folder;
|
||||||
|
use VDM\Joomla\Utilities\StringHelper;
|
||||||
|
use VDM\Joomla\Utilities\ArrayHelper;
|
||||||
|
use VDM\Joomla\Utilities\ObjectHelper;
|
||||||
|
use VDM\Joomla\Utilities\MathHelper;
|
||||||
|
|
||||||
// Use the component builder autoloader
|
// Use the component builder autoloader
|
||||||
ComponentbuilderHelper::autoLoader();
|
ComponentbuilderHelper::autoLoader();
|
||||||
|
|
||||||
@ -145,10 +150,10 @@ class Compiler extends Infusion
|
|||||||
// set the lang data now
|
// set the lang data now
|
||||||
$this->setLangFileData();
|
$this->setLangFileData();
|
||||||
// set the language notice if it was set
|
// set the language notice if it was set
|
||||||
if (ComponentbuilderHelper::checkArray($this->langNot)
|
if (ArrayHelper::check($this->langNot)
|
||||||
|| ComponentbuilderHelper::checkArray($this->langSet))
|
|| ArrayHelper::check($this->langSet))
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkArray($this->langNot))
|
if (ArrayHelper::check($this->langNot))
|
||||||
{
|
{
|
||||||
$this->app->enqueueMessage(
|
$this->app->enqueueMessage(
|
||||||
JText::_('<hr /><h3>Language Warning</h3>'), 'Warning'
|
JText::_('<hr /><h3>Language Warning</h3>'), 'Warning'
|
||||||
@ -184,7 +189,7 @@ class Compiler extends Infusion
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
// show languages that were added
|
// show languages that were added
|
||||||
if (ComponentbuilderHelper::checkArray($this->langSet))
|
if (ArrayHelper::check($this->langSet))
|
||||||
{
|
{
|
||||||
$this->app->enqueueMessage(
|
$this->app->enqueueMessage(
|
||||||
JText::_('<hr /><h3>Language Notice</h3>'), 'Notice'
|
JText::_('<hr /><h3>Language Notice</h3>'), 'Notice'
|
||||||
@ -275,9 +280,9 @@ class Compiler extends Infusion
|
|||||||
// if there are plugins zip them
|
// if there are plugins zip them
|
||||||
$this->zipPlugins();
|
$this->zipPlugins();
|
||||||
// do lang mismatch check
|
// do lang mismatch check
|
||||||
if (ComponentbuilderHelper::checkArray($this->langMismatch))
|
if (ArrayHelper::check($this->langMismatch))
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkArray($this->langMatch))
|
if (ArrayHelper::check($this->langMatch))
|
||||||
{
|
{
|
||||||
$mismatch = array_diff(
|
$mismatch = array_diff(
|
||||||
array_unique($this->langMismatch),
|
array_unique($this->langMismatch),
|
||||||
@ -290,7 +295,7 @@ class Compiler extends Infusion
|
|||||||
}
|
}
|
||||||
// set a notice if we have a mismatch
|
// set a notice if we have a mismatch
|
||||||
if (isset($mismatch)
|
if (isset($mismatch)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$mismatch
|
$mismatch
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -317,7 +322,7 @@ class Compiler extends Infusion
|
|||||||
foreach ($mismatch as $string)
|
foreach ($mismatch as $string)
|
||||||
{
|
{
|
||||||
$constant = $this->langPrefix . '_'
|
$constant = $this->langPrefix . '_'
|
||||||
. ComponentbuilderHelper::safeString($string, 'U');
|
. StringHelper::safe($string, 'U');
|
||||||
$this->app->enqueueMessage(
|
$this->app->enqueueMessage(
|
||||||
JText::sprintf(
|
JText::sprintf(
|
||||||
'The <b>Joomla.JText._('%s')</b> language constant for <b>%s</b> does not have a corresponding <code>JText::script('%s')</code> decalaration, please add it.',
|
'The <b>Joomla.JText._('%s')</b> language constant for <b>%s</b> does not have a corresponding <code>JText::script('%s')</code> decalaration, please add it.',
|
||||||
@ -328,7 +333,7 @@ class Compiler extends Infusion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check if we should add a EXTERNALCODE notice
|
// check if we should add a EXTERNALCODE notice
|
||||||
if (ComponentbuilderHelper::checkArray($this->externalCodeString))
|
if (ArrayHelper::check($this->externalCodeString))
|
||||||
{
|
{
|
||||||
// number of external code strings
|
// number of external code strings
|
||||||
$externalCount = count($this->externalCodeString);
|
$externalCount = count($this->externalCodeString);
|
||||||
@ -385,9 +390,9 @@ class Compiler extends Infusion
|
|||||||
protected function updateFiles()
|
protected function updateFiles()
|
||||||
{
|
{
|
||||||
if (isset($this->newFiles['static'])
|
if (isset($this->newFiles['static'])
|
||||||
&& ComponentbuilderHelper::checkArray($this->newFiles['static'])
|
&& ArrayHelper::check($this->newFiles['static'])
|
||||||
&& isset($this->newFiles['dynamic'])
|
&& isset($this->newFiles['dynamic'])
|
||||||
&& ComponentbuilderHelper::checkArray($this->newFiles['dynamic']))
|
&& ArrayHelper::check($this->newFiles['dynamic']))
|
||||||
{
|
{
|
||||||
// get the bom file
|
// get the bom file
|
||||||
$bom = ComponentbuilderHelper::getFileContents($this->bomPath);
|
$bom = ComponentbuilderHelper::getFileContents($this->bomPath);
|
||||||
@ -405,7 +410,7 @@ class Compiler extends Infusion
|
|||||||
foreach ($this->newFiles['dynamic'] as $view => $files)
|
foreach ($this->newFiles['dynamic'] as $view => $files)
|
||||||
{
|
{
|
||||||
if (isset($this->fileContentDynamic[$view])
|
if (isset($this->fileContentDynamic[$view])
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$this->fileContentDynamic[$view]
|
$this->fileContentDynamic[$view]
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -429,13 +434,13 @@ class Compiler extends Infusion
|
|||||||
// free up some memory
|
// free up some memory
|
||||||
unset($this->newFiles['dynamic']);
|
unset($this->newFiles['dynamic']);
|
||||||
// do modules if found
|
// do modules if found
|
||||||
if (ComponentbuilderHelper::checkArray($this->joomlaModules))
|
if (ArrayHelper::check($this->joomlaModules))
|
||||||
{
|
{
|
||||||
foreach ($this->joomlaModules as $module)
|
foreach ($this->joomlaModules as $module)
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject($module)
|
if (ObjectHelper::check($module)
|
||||||
&& isset($this->newFiles[$module->key])
|
&& isset($this->newFiles[$module->key])
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$this->newFiles[$module->key]
|
$this->newFiles[$module->key]
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -445,7 +450,7 @@ class Compiler extends Infusion
|
|||||||
{
|
{
|
||||||
// check the config fields
|
// check the config fields
|
||||||
if (isset($module->config_fields)
|
if (isset($module->config_fields)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$module->config_fields
|
$module->config_fields
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -467,7 +472,7 @@ class Compiler extends Infusion
|
|||||||
}
|
}
|
||||||
// check the fieldsets
|
// check the fieldsets
|
||||||
if (isset($module->form_files)
|
if (isset($module->form_files)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$module->form_files
|
$module->form_files
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -510,13 +515,13 @@ class Compiler extends Infusion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// do plugins if found
|
// do plugins if found
|
||||||
if (ComponentbuilderHelper::checkArray($this->joomlaPlugins))
|
if (ArrayHelper::check($this->joomlaPlugins))
|
||||||
{
|
{
|
||||||
foreach ($this->joomlaPlugins as $plugin)
|
foreach ($this->joomlaPlugins as $plugin)
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject($plugin)
|
if (ObjectHelper::check($plugin)
|
||||||
&& isset($this->newFiles[$plugin->key])
|
&& isset($this->newFiles[$plugin->key])
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$this->newFiles[$plugin->key]
|
$this->newFiles[$plugin->key]
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -526,7 +531,7 @@ class Compiler extends Infusion
|
|||||||
{
|
{
|
||||||
// check the config fields
|
// check the config fields
|
||||||
if (isset($plugin->config_fields)
|
if (isset($plugin->config_fields)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$plugin->config_fields
|
$plugin->config_fields
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -548,7 +553,7 @@ class Compiler extends Infusion
|
|||||||
}
|
}
|
||||||
// check the fieldsets
|
// check the fieldsets
|
||||||
if (isset($plugin->form_files)
|
if (isset($plugin->form_files)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$plugin->form_files
|
$plugin->form_files
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -591,13 +596,13 @@ class Compiler extends Infusion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// do powers if found
|
// do powers if found
|
||||||
if (ComponentbuilderHelper::checkArray($this->powers))
|
if (ArrayHelper::check($this->powers))
|
||||||
{
|
{
|
||||||
foreach ($this->powers as $power)
|
foreach ($this->powers as $power)
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject($power)
|
if (ObjectHelper::check($power)
|
||||||
&& isset($this->newFiles[$power->key])
|
&& isset($this->newFiles[$power->key])
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$this->newFiles[$power->key]
|
$this->newFiles[$power->key]
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -720,11 +725,11 @@ class Compiler extends Infusion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// move the modules update server to host
|
// move the modules update server to host
|
||||||
if (ComponentbuilderHelper::checkArray($this->joomlaModules))
|
if (ArrayHelper::check($this->joomlaModules))
|
||||||
{
|
{
|
||||||
foreach ($this->joomlaModules as $module)
|
foreach ($this->joomlaModules as $module)
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject($module)
|
if (ObjectHelper::check($module)
|
||||||
&& isset($module->add_update_server)
|
&& isset($module->add_update_server)
|
||||||
&& $module->add_update_server == 1
|
&& $module->add_update_server == 1
|
||||||
&& isset($module->update_server_target)
|
&& isset($module->update_server_target)
|
||||||
@ -735,7 +740,7 @@ class Compiler extends Infusion
|
|||||||
&& isset($module->update_server_xml_path)
|
&& isset($module->update_server_xml_path)
|
||||||
&& File::exists($module->update_server_xml_path)
|
&& File::exists($module->update_server_xml_path)
|
||||||
&& isset($module->update_server_xml_file_name)
|
&& isset($module->update_server_xml_file_name)
|
||||||
&& ComponentbuilderHelper::checkString(
|
&& StringHelper::check(
|
||||||
$module->update_server_xml_file_name
|
$module->update_server_xml_file_name
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -753,11 +758,11 @@ class Compiler extends Infusion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// move the plugins update server to host
|
// move the plugins update server to host
|
||||||
if (ComponentbuilderHelper::checkArray($this->joomlaPlugins))
|
if (ArrayHelper::check($this->joomlaPlugins))
|
||||||
{
|
{
|
||||||
foreach ($this->joomlaPlugins as $plugin)
|
foreach ($this->joomlaPlugins as $plugin)
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject($plugin)
|
if (ObjectHelper::check($plugin)
|
||||||
&& isset($plugin->add_update_server)
|
&& isset($plugin->add_update_server)
|
||||||
&& $plugin->add_update_server == 1
|
&& $plugin->add_update_server == 1
|
||||||
&& isset($plugin->update_server_target)
|
&& isset($plugin->update_server_target)
|
||||||
@ -768,7 +773,7 @@ class Compiler extends Infusion
|
|||||||
&& isset($plugin->update_server_xml_path)
|
&& isset($plugin->update_server_xml_path)
|
||||||
&& File::exists($plugin->update_server_xml_path)
|
&& File::exists($plugin->update_server_xml_path)
|
||||||
&& isset($plugin->update_server_xml_file_name)
|
&& isset($plugin->update_server_xml_file_name)
|
||||||
&& ComponentbuilderHelper::checkString(
|
&& StringHelper::check(
|
||||||
$plugin->update_server_xml_file_name
|
$plugin->update_server_xml_file_name
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -791,7 +796,7 @@ class Compiler extends Infusion
|
|||||||
{
|
{
|
||||||
// check if these files have its own config data)
|
// check if these files have its own config data)
|
||||||
if (isset($data['config'])
|
if (isset($data['config'])
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$data['config']
|
$data['config']
|
||||||
)
|
)
|
||||||
&& $this->componentData->mvc_versiondate == 1)
|
&& $this->componentData->mvc_versiondate == 1)
|
||||||
@ -981,7 +986,7 @@ class Compiler extends Infusion
|
|||||||
{
|
{
|
||||||
// move it to the repo folder if set
|
// move it to the repo folder if set
|
||||||
if (isset($this->repoPath)
|
if (isset($this->repoPath)
|
||||||
&& ComponentbuilderHelper::checkString(
|
&& StringHelper::check(
|
||||||
$this->repoPath
|
$this->repoPath
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1007,11 +1012,11 @@ class Compiler extends Infusion
|
|||||||
);
|
);
|
||||||
|
|
||||||
// move the modules to local folder repos
|
// move the modules to local folder repos
|
||||||
if (ComponentbuilderHelper::checkArray($this->joomlaModules))
|
if (ArrayHelper::check($this->joomlaModules))
|
||||||
{
|
{
|
||||||
foreach ($this->joomlaModules as $module)
|
foreach ($this->joomlaModules as $module)
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject($module)
|
if (ObjectHelper::check($module)
|
||||||
&& isset($module->file_name))
|
&& isset($module->file_name))
|
||||||
{
|
{
|
||||||
$module_context = 'module.' . $module->file_name . '.'
|
$module_context = 'module.' . $module->file_name . '.'
|
||||||
@ -1044,11 +1049,11 @@ class Compiler extends Infusion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// move the plugins to local folder repos
|
// move the plugins to local folder repos
|
||||||
if (ComponentbuilderHelper::checkArray($this->joomlaPlugins))
|
if (ArrayHelper::check($this->joomlaPlugins))
|
||||||
{
|
{
|
||||||
foreach ($this->joomlaPlugins as $plugin)
|
foreach ($this->joomlaPlugins as $plugin)
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject($plugin)
|
if (ObjectHelper::check($plugin)
|
||||||
&& isset($plugin->file_name))
|
&& isset($plugin->file_name))
|
||||||
{
|
{
|
||||||
$plugin_context = 'plugin.' . $plugin->file_name . '.'
|
$plugin_context = 'plugin.' . $plugin->file_name . '.'
|
||||||
@ -1162,15 +1167,15 @@ class Compiler extends Infusion
|
|||||||
|
|
||||||
private function zipModules()
|
private function zipModules()
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkArray($this->joomlaModules))
|
if (ArrayHelper::check($this->joomlaModules))
|
||||||
{
|
{
|
||||||
foreach ($this->joomlaModules as $module)
|
foreach ($this->joomlaModules as $module)
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject($module)
|
if (ObjectHelper::check($module)
|
||||||
&& isset($module->zip_name)
|
&& isset($module->zip_name)
|
||||||
&& ComponentbuilderHelper::checkString($module->zip_name)
|
&& StringHelper::check($module->zip_name)
|
||||||
&& isset($module->folder_path)
|
&& isset($module->folder_path)
|
||||||
&& ComponentbuilderHelper::checkString(
|
&& StringHelper::check(
|
||||||
$module->folder_path
|
$module->folder_path
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1256,15 +1261,15 @@ class Compiler extends Infusion
|
|||||||
|
|
||||||
private function zipPlugins()
|
private function zipPlugins()
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkArray($this->joomlaPlugins))
|
if (ArrayHelper::check($this->joomlaPlugins))
|
||||||
{
|
{
|
||||||
foreach ($this->joomlaPlugins as $plugin)
|
foreach ($this->joomlaPlugins as $plugin)
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject($plugin)
|
if (ObjectHelper::check($plugin)
|
||||||
&& isset($plugin->zip_name)
|
&& isset($plugin->zip_name)
|
||||||
&& ComponentbuilderHelper::checkString($plugin->zip_name)
|
&& StringHelper::check($plugin->zip_name)
|
||||||
&& isset($plugin->folder_path)
|
&& isset($plugin->folder_path)
|
||||||
&& ComponentbuilderHelper::checkString(
|
&& StringHelper::check(
|
||||||
$plugin->folder_path
|
$plugin->folder_path
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1359,9 +1364,9 @@ class Compiler extends Infusion
|
|||||||
$fingerPrint = array();
|
$fingerPrint = array();
|
||||||
if (isset($target['hashtarget'][0]) && $target['hashtarget'][0] > 3
|
if (isset($target['hashtarget'][0]) && $target['hashtarget'][0] > 3
|
||||||
&& isset($target['path'])
|
&& isset($target['path'])
|
||||||
&& ComponentbuilderHelper::checkString($target['path'])
|
&& StringHelper::check($target['path'])
|
||||||
&& isset($target['hashtarget'][1])
|
&& isset($target['hashtarget'][1])
|
||||||
&& ComponentbuilderHelper::checkString(
|
&& StringHelper::check(
|
||||||
$target['hashtarget'][1]
|
$target['hashtarget'][1]
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1400,7 +1405,7 @@ class Compiler extends Infusion
|
|||||||
);
|
);
|
||||||
if (!$found)
|
if (!$found)
|
||||||
{
|
{
|
||||||
$bites = (int) ComponentbuilderHelper::bcmath(
|
$bites = (int) MathHelper::bc(
|
||||||
'add', $lineBites[$lineNumber], $bites
|
'add', $lineBites[$lineNumber], $bites
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1590,14 +1595,14 @@ class Compiler extends Infusion
|
|||||||
// Add the data
|
// Add the data
|
||||||
fwrite($fpFile, $data);
|
fwrite($fpFile, $data);
|
||||||
// truncate file at the end of the data that was added
|
// truncate file at the end of the data that was added
|
||||||
$remove = ComponentbuilderHelper::bcmath(
|
$remove = MathHelper::bc(
|
||||||
'add', $position, mb_strlen($data, '8bit')
|
'add', $position, mb_strlen($data, '8bit')
|
||||||
);
|
);
|
||||||
ftruncate($fpFile, $remove);
|
ftruncate($fpFile, $remove);
|
||||||
// check if this was a replacement of data
|
// check if this was a replacement of data
|
||||||
if ($replace)
|
if ($replace)
|
||||||
{
|
{
|
||||||
$position = ComponentbuilderHelper::bcmath(
|
$position = MathHelper::bc(
|
||||||
'add', $position, $replace
|
'add', $position, $replace
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -15,6 +15,10 @@ defined('_JEXEC') or die('Restricted access');
|
|||||||
|
|
||||||
use Joomla\CMS\Filesystem\File;
|
use Joomla\CMS\Filesystem\File;
|
||||||
use Joomla\CMS\Filesystem\Folder;
|
use Joomla\CMS\Filesystem\Folder;
|
||||||
|
use VDM\Joomla\Utilities\StringHelper;
|
||||||
|
use VDM\Joomla\Utilities\ArrayHelper;
|
||||||
|
use VDM\Joomla\Utilities\ObjectHelper;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Structure class
|
* Structure class
|
||||||
@ -485,7 +489,7 @@ class Structure extends Get
|
|||||||
*/
|
*/
|
||||||
private function buildPowers()
|
private function buildPowers()
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkArray($this->powers))
|
if (ArrayHelper::check($this->powers))
|
||||||
{
|
{
|
||||||
// Trigger Event: jcb_ce_onBeforeSetModules
|
// Trigger Event: jcb_ce_onBeforeSetModules
|
||||||
$this->triggerEvent(
|
$this->triggerEvent(
|
||||||
@ -496,9 +500,9 @@ class Structure extends Get
|
|||||||
$htaccess = array();
|
$htaccess = array();
|
||||||
foreach ($this->powers as $power)
|
foreach ($this->powers as $power)
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject($power)
|
if (ObjectHelper::check($power)
|
||||||
&& isset($power->path)
|
&& isset($power->path)
|
||||||
&& ComponentbuilderHelper::checkString(
|
&& StringHelper::check(
|
||||||
$power->path
|
$power->path
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -594,7 +598,7 @@ class Structure extends Get
|
|||||||
*/
|
*/
|
||||||
private function buildModules()
|
private function buildModules()
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkArray($this->joomlaModules))
|
if (ArrayHelper::check($this->joomlaModules))
|
||||||
{
|
{
|
||||||
// Trigger Event: jcb_ce_onBeforeSetModules
|
// Trigger Event: jcb_ce_onBeforeSetModules
|
||||||
$this->triggerEvent(
|
$this->triggerEvent(
|
||||||
@ -603,9 +607,9 @@ class Structure extends Get
|
|||||||
);
|
);
|
||||||
foreach ($this->joomlaModules as $module)
|
foreach ($this->joomlaModules as $module)
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject($module)
|
if (ObjectHelper::check($module)
|
||||||
&& isset($module->folder_name)
|
&& isset($module->folder_name)
|
||||||
&& ComponentbuilderHelper::checkString(
|
&& StringHelper::check(
|
||||||
$module->folder_name
|
$module->folder_name
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -764,7 +768,7 @@ class Structure extends Get
|
|||||||
if (($css = $this->getCustomScriptBuilder(
|
if (($css = $this->getCustomScriptBuilder(
|
||||||
'css_view', $module->key
|
'css_view', $module->key
|
||||||
)) !== null
|
)) !== null
|
||||||
&& ComponentbuilderHelper::checkString($css))
|
&& StringHelper::check($css))
|
||||||
{
|
{
|
||||||
// make sure this script does not have PHP
|
// make sure this script does not have PHP
|
||||||
if (strpos($css, '<?php') === false)
|
if (strpos($css, '<?php') === false)
|
||||||
@ -799,7 +803,7 @@ class Structure extends Get
|
|||||||
if (($javascript = $this->getCustomScriptBuilder(
|
if (($javascript = $this->getCustomScriptBuilder(
|
||||||
'view_footer', $module->key
|
'view_footer', $module->key
|
||||||
)) !== null
|
)) !== null
|
||||||
&& ComponentbuilderHelper::checkString($javascript))
|
&& StringHelper::check($javascript))
|
||||||
{
|
{
|
||||||
// make sure this script does not have PHP
|
// make sure this script does not have PHP
|
||||||
if (strpos($javascript, '<?php') === false)
|
if (strpos($javascript, '<?php') === false)
|
||||||
@ -864,7 +868,7 @@ class Structure extends Get
|
|||||||
}
|
}
|
||||||
// set forms folder if needed
|
// set forms folder if needed
|
||||||
if (isset($module->form_files)
|
if (isset($module->form_files)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$module->form_files
|
$module->form_files
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1020,7 +1024,7 @@ class Structure extends Get
|
|||||||
. $fieldset . '" label="' . $label . '">';
|
. $fieldset . '" label="' . $label . '">';
|
||||||
}
|
}
|
||||||
// check if we have an inner field set
|
// check if we have an inner field set
|
||||||
if (ComponentbuilderHelper::checkString(
|
if (StringHelper::check(
|
||||||
$field_name_inner
|
$field_name_inner
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1032,7 +1036,7 @@ class Structure extends Get
|
|||||||
$xml .= $this->hhh . 'FIELDSET_' . $file
|
$xml .= $this->hhh . 'FIELDSET_' . $file
|
||||||
. $field_name . $fieldset . $this->hhh;
|
. $field_name . $fieldset . $this->hhh;
|
||||||
// check if we have an inner field set
|
// check if we have an inner field set
|
||||||
if (ComponentbuilderHelper::checkString(
|
if (StringHelper::check(
|
||||||
$field_name_inner
|
$field_name_inner
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1091,7 +1095,7 @@ class Structure extends Get
|
|||||||
);
|
);
|
||||||
// check if this lib has files
|
// check if this lib has files
|
||||||
if (isset($module->files)
|
if (isset($module->files)
|
||||||
&& ComponentbuilderHelper::checkArray($module->files))
|
&& ArrayHelper::check($module->files))
|
||||||
{
|
{
|
||||||
// add to component files
|
// add to component files
|
||||||
foreach ($module->files as $file)
|
foreach ($module->files as $file)
|
||||||
@ -1104,7 +1108,7 @@ class Structure extends Get
|
|||||||
}
|
}
|
||||||
// check if this lib has folders
|
// check if this lib has folders
|
||||||
if (isset($module->folders)
|
if (isset($module->folders)
|
||||||
&& ComponentbuilderHelper::checkArray($module->folders))
|
&& ArrayHelper::check($module->folders))
|
||||||
{
|
{
|
||||||
// add to component folders
|
// add to component folders
|
||||||
foreach ($module->folders as $folder)
|
foreach ($module->folders as $folder)
|
||||||
@ -1117,7 +1121,7 @@ class Structure extends Get
|
|||||||
}
|
}
|
||||||
// check if this module has urls
|
// check if this module has urls
|
||||||
if (isset($module->urls)
|
if (isset($module->urls)
|
||||||
&& ComponentbuilderHelper::checkArray($module->urls))
|
&& ArrayHelper::check($module->urls))
|
||||||
{
|
{
|
||||||
// add to component urls
|
// add to component urls
|
||||||
foreach ($module->urls as $n => &$url)
|
foreach ($module->urls as $n => &$url)
|
||||||
@ -1125,7 +1129,7 @@ class Structure extends Get
|
|||||||
// should we add the local folder
|
// should we add the local folder
|
||||||
if (isset($url['type']) && $url['type'] > 1
|
if (isset($url['type']) && $url['type'] > 1
|
||||||
&& isset($url['url'])
|
&& isset($url['url'])
|
||||||
&& ComponentbuilderHelper::checkString(
|
&& StringHelper::check(
|
||||||
$url['url']
|
$url['url']
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1175,7 +1179,7 @@ class Structure extends Get
|
|||||||
*/
|
*/
|
||||||
private function buildPlugins()
|
private function buildPlugins()
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkArray($this->joomlaPlugins))
|
if (ArrayHelper::check($this->joomlaPlugins))
|
||||||
{
|
{
|
||||||
// Trigger Event: jcb_ce_onBeforeSetPlugins
|
// Trigger Event: jcb_ce_onBeforeSetPlugins
|
||||||
$this->triggerEvent(
|
$this->triggerEvent(
|
||||||
@ -1184,9 +1188,9 @@ class Structure extends Get
|
|||||||
);
|
);
|
||||||
foreach ($this->joomlaPlugins as $plugin)
|
foreach ($this->joomlaPlugins as $plugin)
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject($plugin)
|
if (ObjectHelper::check($plugin)
|
||||||
&& isset($plugin->folder_name)
|
&& isset($plugin->folder_name)
|
||||||
&& ComponentbuilderHelper::checkString(
|
&& StringHelper::check(
|
||||||
$plugin->folder_name
|
$plugin->folder_name
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1273,7 +1277,7 @@ class Structure extends Get
|
|||||||
}
|
}
|
||||||
// set forms folder if needed
|
// set forms folder if needed
|
||||||
if (isset($plugin->form_files)
|
if (isset($plugin->form_files)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$plugin->form_files
|
$plugin->form_files
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1411,7 +1415,7 @@ class Structure extends Get
|
|||||||
. $fieldset . '" label="' . $label . '">';
|
. $fieldset . '" label="' . $label . '">';
|
||||||
}
|
}
|
||||||
// check if we have an inner field set
|
// check if we have an inner field set
|
||||||
if (ComponentbuilderHelper::checkString(
|
if (StringHelper::check(
|
||||||
$field_name_inner
|
$field_name_inner
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1423,7 +1427,7 @@ class Structure extends Get
|
|||||||
$xml .= $this->hhh . 'FIELDSET_' . $file
|
$xml .= $this->hhh . 'FIELDSET_' . $file
|
||||||
. $field_name . $fieldset . $this->hhh;
|
. $field_name . $fieldset . $this->hhh;
|
||||||
// check if we have an inner field set
|
// check if we have an inner field set
|
||||||
if (ComponentbuilderHelper::checkString(
|
if (StringHelper::check(
|
||||||
$field_name_inner
|
$field_name_inner
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1482,7 +1486,7 @@ class Structure extends Get
|
|||||||
);
|
);
|
||||||
// check if this lib has files
|
// check if this lib has files
|
||||||
if (isset($plugin->files)
|
if (isset($plugin->files)
|
||||||
&& ComponentbuilderHelper::checkArray($plugin->files))
|
&& ArrayHelper::check($plugin->files))
|
||||||
{
|
{
|
||||||
// add to component files
|
// add to component files
|
||||||
foreach ($plugin->files as $file)
|
foreach ($plugin->files as $file)
|
||||||
@ -1495,7 +1499,7 @@ class Structure extends Get
|
|||||||
}
|
}
|
||||||
// check if this lib has folders
|
// check if this lib has folders
|
||||||
if (isset($plugin->folders)
|
if (isset($plugin->folders)
|
||||||
&& ComponentbuilderHelper::checkArray($plugin->folders))
|
&& ArrayHelper::check($plugin->folders))
|
||||||
{
|
{
|
||||||
// add to component folders
|
// add to component folders
|
||||||
foreach ($plugin->folders as $folder)
|
foreach ($plugin->folders as $folder)
|
||||||
@ -1508,7 +1512,7 @@ class Structure extends Get
|
|||||||
}
|
}
|
||||||
// check if this plugin has urls
|
// check if this plugin has urls
|
||||||
if (isset($plugin->urls)
|
if (isset($plugin->urls)
|
||||||
&& ComponentbuilderHelper::checkArray($plugin->urls))
|
&& ArrayHelper::check($plugin->urls))
|
||||||
{
|
{
|
||||||
// add to component urls
|
// add to component urls
|
||||||
foreach ($plugin->urls as $n => &$url)
|
foreach ($plugin->urls as $n => &$url)
|
||||||
@ -1516,7 +1520,7 @@ class Structure extends Get
|
|||||||
// should we add the local folder
|
// should we add the local folder
|
||||||
if (isset($url['type']) && $url['type'] > 1
|
if (isset($url['type']) && $url['type'] > 1
|
||||||
&& isset($url['url'])
|
&& isset($url['url'])
|
||||||
&& ComponentbuilderHelper::checkString(
|
&& StringHelper::check(
|
||||||
$url['url']
|
$url['url']
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1591,7 +1595,7 @@ class Structure extends Get
|
|||||||
*/
|
*/
|
||||||
private function setLibraries()
|
private function setLibraries()
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkArray($this->libraries))
|
if (ArrayHelper::check($this->libraries))
|
||||||
{
|
{
|
||||||
// Trigger Event: jcb_ce_onBeforeSetLibraries
|
// Trigger Event: jcb_ce_onBeforeSetLibraries
|
||||||
$this->triggerEvent(
|
$this->triggerEvent(
|
||||||
@ -1610,11 +1614,11 @@ class Structure extends Get
|
|||||||
$this->createFolder($this->componentPath . '/media');
|
$this->createFolder($this->componentPath . '/media');
|
||||||
foreach ($this->libraries as $id => &$library)
|
foreach ($this->libraries as $id => &$library)
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject($library))
|
if (ObjectHelper::check($library))
|
||||||
{
|
{
|
||||||
// check if this lib has files
|
// check if this lib has files
|
||||||
if (isset($library->files)
|
if (isset($library->files)
|
||||||
&& ComponentbuilderHelper::checkArray($library->files))
|
&& ArrayHelper::check($library->files))
|
||||||
{
|
{
|
||||||
// add to component files
|
// add to component files
|
||||||
foreach ($library->files as $file)
|
foreach ($library->files as $file)
|
||||||
@ -1624,7 +1628,7 @@ class Structure extends Get
|
|||||||
}
|
}
|
||||||
// check if this lib has folders
|
// check if this lib has folders
|
||||||
if (isset($library->folders)
|
if (isset($library->folders)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$library->folders
|
$library->folders
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1636,13 +1640,13 @@ class Structure extends Get
|
|||||||
}
|
}
|
||||||
// check if this lib has urls
|
// check if this lib has urls
|
||||||
if (isset($library->urls)
|
if (isset($library->urls)
|
||||||
&& ComponentbuilderHelper::checkArray($library->urls))
|
&& ArrayHelper::check($library->urls))
|
||||||
{
|
{
|
||||||
// build media folder path
|
// build media folder path
|
||||||
$libFolder = strtolower(
|
$libFolder = strtolower(
|
||||||
preg_replace(
|
preg_replace(
|
||||||
'/\s+/', '-',
|
'/\s+/', '-',
|
||||||
ComponentbuilderHelper::safeString(
|
StringHelper::safe(
|
||||||
$library->name, 'filename', ' ', false
|
$library->name, 'filename', ' ', false
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -1655,7 +1659,7 @@ class Structure extends Get
|
|||||||
{
|
{
|
||||||
if (isset($url['type']) && $url['type'] > 1
|
if (isset($url['type']) && $url['type'] > 1
|
||||||
&& isset($url['url'])
|
&& isset($url['url'])
|
||||||
&& ComponentbuilderHelper::checkString(
|
&& StringHelper::check(
|
||||||
$url['url']
|
$url['url']
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1712,7 +1716,7 @@ class Structure extends Get
|
|||||||
// if config fields are found load into component config (avoiding duplicates)
|
// if config fields are found load into component config (avoiding duplicates)
|
||||||
if (isset($library->how) && $library->how > 1
|
if (isset($library->how) && $library->how > 1
|
||||||
&& isset($library->config)
|
&& isset($library->config)
|
||||||
&& ComponentbuilderHelper::checkArray($library->config))
|
&& ArrayHelper::check($library->config))
|
||||||
{
|
{
|
||||||
foreach ($library->config as $cofig)
|
foreach ($library->config as $cofig)
|
||||||
{
|
{
|
||||||
@ -1723,7 +1727,7 @@ class Structure extends Get
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
// set the config data if not found
|
// set the config data if not found
|
||||||
if (!ComponentbuilderHelper::checkArray($found))
|
if (!ArrayHelper::check($found))
|
||||||
{
|
{
|
||||||
$this->componentData->config[] = $cofig;
|
$this->componentData->config[] = $cofig;
|
||||||
}
|
}
|
||||||
@ -1746,7 +1750,7 @@ class Structure extends Get
|
|||||||
if (isset($this->componentData->dashboard_type)
|
if (isset($this->componentData->dashboard_type)
|
||||||
&& 2 == $this->componentData->dashboard_type
|
&& 2 == $this->componentData->dashboard_type
|
||||||
&& isset($this->componentData->dashboard)
|
&& isset($this->componentData->dashboard)
|
||||||
&& ComponentbuilderHelper::checkString(
|
&& StringHelper::check(
|
||||||
$this->componentData->dashboard
|
$this->componentData->dashboard
|
||||||
)
|
)
|
||||||
&& strpos($this->componentData->dashboard, '_') !== false)
|
&& strpos($this->componentData->dashboard, '_') !== false)
|
||||||
@ -1756,7 +1760,7 @@ class Structure extends Get
|
|||||||
if (count((array) $getter) == 2 && is_numeric($getter[1]))
|
if (count((array) $getter) == 2 && is_numeric($getter[1]))
|
||||||
{
|
{
|
||||||
// the pointers
|
// the pointers
|
||||||
$t = ComponentbuilderHelper::safeString($getter[0], 'U');
|
$t = StringHelper::safe($getter[0], 'U');
|
||||||
$id = (int) $getter[1];
|
$id = (int) $getter[1];
|
||||||
// the dynamic stuff
|
// the dynamic stuff
|
||||||
$targets = array('A' => 'admin_views',
|
$targets = array('A' => 'admin_views',
|
||||||
@ -1769,12 +1773,12 @@ class Structure extends Get
|
|||||||
if (isset($targets[$t]) && $id > 0)
|
if (isset($targets[$t]) && $id > 0)
|
||||||
{
|
{
|
||||||
// set the type name
|
// set the type name
|
||||||
$type_names = ComponentbuilderHelper::safeString(
|
$type_names = StringHelper::safe(
|
||||||
$targets[$t], 'w'
|
$targets[$t], 'w'
|
||||||
);
|
);
|
||||||
// set the dynamic dash
|
// set the dynamic dash
|
||||||
if (isset($this->componentData->{$targets[$t]})
|
if (isset($this->componentData->{$targets[$t]})
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$this->componentData->{$targets[$t]}
|
$this->componentData->{$targets[$t]}
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1792,7 +1796,7 @@ class Structure extends Get
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
// set dashboard
|
// set dashboard
|
||||||
if (ComponentbuilderHelper::checkArray($dashboard))
|
if (ArrayHelper::check($dashboard))
|
||||||
{
|
{
|
||||||
$dashboard = array_values($dashboard)[0];
|
$dashboard = array_values($dashboard)[0];
|
||||||
}
|
}
|
||||||
@ -1801,7 +1805,7 @@ class Structure extends Get
|
|||||||
&& isset($dashboard['settings']->{$keys[$t]}))
|
&& isset($dashboard['settings']->{$keys[$t]}))
|
||||||
{
|
{
|
||||||
$this->dynamicDashboard
|
$this->dynamicDashboard
|
||||||
= ComponentbuilderHelper::safeString(
|
= StringHelper::safe(
|
||||||
$dashboard['settings']->{$keys[$t]}
|
$dashboard['settings']->{$keys[$t]}
|
||||||
);
|
);
|
||||||
$this->dynamicDashboardType
|
$this->dynamicDashboardType
|
||||||
@ -1866,7 +1870,7 @@ class Structure extends Get
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
// if default was changed to dynamic dashboard the remove default tab and methods
|
// if default was changed to dynamic dashboard the remove default tab and methods
|
||||||
if (ComponentbuilderHelper::checkString($this->dynamicDashboard))
|
if (StringHelper::check($this->dynamicDashboard))
|
||||||
{
|
{
|
||||||
// dynamic dashboard is used
|
// dynamic dashboard is used
|
||||||
$this->componentData->dashboard_tab = '';
|
$this->componentData->dashboard_tab = '';
|
||||||
@ -1894,7 +1898,7 @@ class Structure extends Get
|
|||||||
*/
|
*/
|
||||||
private function setFolders()
|
private function setFolders()
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject(
|
if (ObjectHelper::check(
|
||||||
$this->joomlaVersionData->create
|
$this->joomlaVersionData->create
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1910,14 +1914,14 @@ class Structure extends Get
|
|||||||
foreach ($this->joomlaVersionData->create as $main => $folders)
|
foreach ($this->joomlaVersionData->create as $main => $folders)
|
||||||
{
|
{
|
||||||
$this->createFolder($this->componentPath . '/' . $main);
|
$this->createFolder($this->componentPath . '/' . $main);
|
||||||
if (ComponentbuilderHelper::checkObject($folders))
|
if (ObjectHelper::check($folders))
|
||||||
{
|
{
|
||||||
foreach ($folders as $sub => $subFolders)
|
foreach ($folders as $sub => $subFolders)
|
||||||
{
|
{
|
||||||
$this->createFolder(
|
$this->createFolder(
|
||||||
$this->componentPath . '/' . $main . '/' . $sub
|
$this->componentPath . '/' . $main . '/' . $sub
|
||||||
);
|
);
|
||||||
if (ComponentbuilderHelper::checkObject($subFolders))
|
if (ObjectHelper::check($subFolders))
|
||||||
{
|
{
|
||||||
foreach ($subFolders as $sub_2 => $subFolders_2)
|
foreach ($subFolders as $sub_2 => $subFolders_2)
|
||||||
{
|
{
|
||||||
@ -1925,7 +1929,7 @@ class Structure extends Get
|
|||||||
$this->componentPath . '/' . $main . '/'
|
$this->componentPath . '/' . $main . '/'
|
||||||
. $sub . '/' . $sub_2
|
. $sub . '/' . $sub_2
|
||||||
);
|
);
|
||||||
if (ComponentbuilderHelper::checkObject(
|
if (ObjectHelper::check(
|
||||||
$subFolders_2
|
$subFolders_2
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1938,7 +1942,7 @@ class Structure extends Get
|
|||||||
. '/' . $sub . '/' . $sub_2 . '/'
|
. '/' . $sub . '/' . $sub_2 . '/'
|
||||||
. $sub_3
|
. $sub_3
|
||||||
);
|
);
|
||||||
if (ComponentbuilderHelper::checkObject(
|
if (ObjectHelper::check(
|
||||||
$subFolders_3
|
$subFolders_3
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1953,7 +1957,7 @@ class Structure extends Get
|
|||||||
. $sub_2 . '/' . $sub_3
|
. $sub_2 . '/' . $sub_3
|
||||||
. '/' . $sub_4
|
. '/' . $sub_4
|
||||||
);
|
);
|
||||||
if (ComponentbuilderHelper::checkObject(
|
if (ObjectHelper::check(
|
||||||
$subFolders_4
|
$subFolders_4
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1971,7 +1975,7 @@ class Structure extends Get
|
|||||||
. $sub_4 . '/'
|
. $sub_4 . '/'
|
||||||
. $sub_5
|
. $sub_5
|
||||||
);
|
);
|
||||||
if (ComponentbuilderHelper::checkObject(
|
if (ObjectHelper::check(
|
||||||
$subFolders_5
|
$subFolders_5
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1998,7 +2002,7 @@ class Structure extends Get
|
|||||||
. '/'
|
. '/'
|
||||||
. $sub_6
|
. $sub_6
|
||||||
);
|
);
|
||||||
if (ComponentbuilderHelper::checkObject(
|
if (ObjectHelper::check(
|
||||||
$subFolders_6
|
$subFolders_6
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -2059,7 +2063,7 @@ class Structure extends Get
|
|||||||
*/
|
*/
|
||||||
private function setStatic()
|
private function setStatic()
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject(
|
if (ObjectHelper::check(
|
||||||
$this->joomlaVersionData->move->static
|
$this->joomlaVersionData->move->static
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -2248,7 +2252,7 @@ class Structure extends Get
|
|||||||
// TODO <-- this may not be the best way, will keep an eye on this.
|
// TODO <-- this may not be the best way, will keep an eye on this.
|
||||||
// We basicly only want to check if a folder is added that is not in the stdFolders array
|
// We basicly only want to check if a folder is added that is not in the stdFolders array
|
||||||
if (isset($checker[0])
|
if (isset($checker[0])
|
||||||
&& ComponentbuilderHelper::checkString($checker[0])
|
&& StringHelper::check($checker[0])
|
||||||
&& !in_array($checker[0], $this->stdFolders))
|
&& !in_array($checker[0], $this->stdFolders))
|
||||||
{
|
{
|
||||||
// check if we should add the dynamic folder moving script to the installer script
|
// check if we should add the dynamic folder moving script to the installer script
|
||||||
@ -2270,7 +2274,7 @@ class Structure extends Get
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif (count((array) $checker) == 2
|
elseif (count((array) $checker) == 2
|
||||||
&& ComponentbuilderHelper::checkString($checker[0]))
|
&& StringHelper::check($checker[0]))
|
||||||
{
|
{
|
||||||
$add_to_extra = false;
|
$add_to_extra = false;
|
||||||
// set the target
|
// set the target
|
||||||
@ -2302,7 +2306,7 @@ class Structure extends Get
|
|||||||
}
|
}
|
||||||
// set the xml file
|
// set the xml file
|
||||||
$this->fileContentStatic[$this->hhh . 'EXSTRA_'
|
$this->fileContentStatic[$this->hhh . 'EXSTRA_'
|
||||||
. ComponentbuilderHelper::safeString(
|
. StringHelper::safe(
|
||||||
$checker[0], 'U'
|
$checker[0], 'U'
|
||||||
) . '_' . $eNAME . $this->hhh]
|
) . '_' . $eNAME . $this->hhh]
|
||||||
.= PHP_EOL . $eTab . "<" . $ename . ">"
|
.= PHP_EOL . $eTab . "<" . $ename . ">"
|
||||||
@ -2329,15 +2333,15 @@ class Structure extends Get
|
|||||||
$back = false;
|
$back = false;
|
||||||
$front = false;
|
$front = false;
|
||||||
if ((isset($this->joomlaVersionData->move->dynamic)
|
if ((isset($this->joomlaVersionData->move->dynamic)
|
||||||
&& ComponentbuilderHelper::checkObject(
|
&& ObjectHelper::check(
|
||||||
$this->joomlaVersionData->move->dynamic
|
$this->joomlaVersionData->move->dynamic
|
||||||
))
|
))
|
||||||
&& (isset($this->componentData->admin_views)
|
&& (isset($this->componentData->admin_views)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$this->componentData->admin_views
|
$this->componentData->admin_views
|
||||||
)))
|
)))
|
||||||
{
|
{
|
||||||
if (!ComponentbuilderHelper::checkString($this->dynamicDashboard))
|
if (!StringHelper::check($this->dynamicDashboard))
|
||||||
{
|
{
|
||||||
// setup dashboard
|
// setup dashboard
|
||||||
$target = array('admin' => $this->componentData->name_code);
|
$target = array('admin' => $this->componentData->name_code);
|
||||||
@ -2346,7 +2350,7 @@ class Structure extends Get
|
|||||||
// now the rest of the views
|
// now the rest of the views
|
||||||
foreach ($this->componentData->admin_views as $nr => $view)
|
foreach ($this->componentData->admin_views as $nr => $view)
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject($view['settings']))
|
if (ObjectHelper::check($view['settings']))
|
||||||
{
|
{
|
||||||
$created = $this->getCreatedDate($view);
|
$created = $this->getCreatedDate($view);
|
||||||
$modified = $this->getLastModifiedDate($view);
|
$modified = $this->getLastModifiedDate($view);
|
||||||
@ -2405,11 +2409,11 @@ class Structure extends Get
|
|||||||
$back = true;
|
$back = true;
|
||||||
}
|
}
|
||||||
if ((isset($this->joomlaVersionData->move->dynamic)
|
if ((isset($this->joomlaVersionData->move->dynamic)
|
||||||
&& ComponentbuilderHelper::checkObject(
|
&& ObjectHelper::check(
|
||||||
$this->joomlaVersionData->move->dynamic
|
$this->joomlaVersionData->move->dynamic
|
||||||
))
|
))
|
||||||
&& (isset($this->componentData->site_views)
|
&& (isset($this->componentData->site_views)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$this->componentData->site_views
|
$this->componentData->site_views
|
||||||
)))
|
)))
|
||||||
{
|
{
|
||||||
@ -2446,11 +2450,11 @@ class Structure extends Get
|
|||||||
$front = true;
|
$front = true;
|
||||||
}
|
}
|
||||||
if ((isset($this->joomlaVersionData->move->dynamic)
|
if ((isset($this->joomlaVersionData->move->dynamic)
|
||||||
&& ComponentbuilderHelper::checkObject(
|
&& ObjectHelper::check(
|
||||||
$this->joomlaVersionData->move->dynamic
|
$this->joomlaVersionData->move->dynamic
|
||||||
))
|
))
|
||||||
&& (isset($this->componentData->custom_admin_views)
|
&& (isset($this->componentData->custom_admin_views)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$this->componentData->custom_admin_views
|
$this->componentData->custom_admin_views
|
||||||
)))
|
)))
|
||||||
{
|
{
|
||||||
@ -2592,7 +2596,7 @@ class Structure extends Get
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if (ComponentbuilderHelper::checkArray($ids))
|
if (ArrayHelper::check($ids))
|
||||||
{
|
{
|
||||||
foreach ($ids as $id)
|
foreach ($ids as $id)
|
||||||
{
|
{
|
||||||
@ -2617,7 +2621,7 @@ class Structure extends Get
|
|||||||
public function getCreatedDate($view)
|
public function getCreatedDate($view)
|
||||||
{
|
{
|
||||||
if (isset($view['settings']->created)
|
if (isset($view['settings']->created)
|
||||||
&& ComponentbuilderHelper::checkString($view['settings']->created))
|
&& StringHelper::check($view['settings']->created))
|
||||||
{
|
{
|
||||||
// first set the main date
|
// first set the main date
|
||||||
$date = strtotime($view['settings']->created);
|
$date = strtotime($view['settings']->created);
|
||||||
@ -2643,7 +2647,7 @@ class Structure extends Get
|
|||||||
{
|
{
|
||||||
// first set the main date
|
// first set the main date
|
||||||
if (isset($view['settings']->modified)
|
if (isset($view['settings']->modified)
|
||||||
&& ComponentbuilderHelper::checkString($view['settings']->modified)
|
&& StringHelper::check($view['settings']->modified)
|
||||||
&& '0000-00-00 00:00:00' !== $view['settings']->modified)
|
&& '0000-00-00 00:00:00' !== $view['settings']->modified)
|
||||||
{
|
{
|
||||||
$date = strtotime($view['settings']->modified);
|
$date = strtotime($view['settings']->modified);
|
||||||
@ -2661,18 +2665,18 @@ class Structure extends Get
|
|||||||
if (!isset($this->lastModifiedDate[$id]))
|
if (!isset($this->lastModifiedDate[$id]))
|
||||||
{
|
{
|
||||||
if (isset($view['settings']->fields)
|
if (isset($view['settings']->fields)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$view['settings']->fields
|
$view['settings']->fields
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
foreach ($view['settings']->fields as $field)
|
foreach ($view['settings']->fields as $field)
|
||||||
{
|
{
|
||||||
if (isset($field['settings'])
|
if (isset($field['settings'])
|
||||||
&& ComponentbuilderHelper::checkObject(
|
&& ObjectHelper::check(
|
||||||
$field['settings']
|
$field['settings']
|
||||||
)
|
)
|
||||||
&& isset($field['settings']->modified)
|
&& isset($field['settings']->modified)
|
||||||
&& ComponentbuilderHelper::checkString(
|
&& StringHelper::check(
|
||||||
$field['settings']->modified
|
$field['settings']->modified
|
||||||
)
|
)
|
||||||
&& '0000-00-00 00:00:00'
|
&& '0000-00-00 00:00:00'
|
||||||
@ -2697,7 +2701,7 @@ class Structure extends Get
|
|||||||
if (!isset($this->lastModifiedDate[$id]))
|
if (!isset($this->lastModifiedDate[$id]))
|
||||||
{
|
{
|
||||||
if (isset($view['settings']->main_get->modified)
|
if (isset($view['settings']->main_get->modified)
|
||||||
&& ComponentbuilderHelper::checkString(
|
&& StringHelper::check(
|
||||||
$view['settings']->main_get->modified
|
$view['settings']->main_get->modified
|
||||||
)
|
)
|
||||||
&& '0000-00-00 00:00:00'
|
&& '0000-00-00 00:00:00'
|
||||||
@ -2720,7 +2724,7 @@ class Structure extends Get
|
|||||||
if (!isset($this->lastModifiedDate[$id]))
|
if (!isset($this->lastModifiedDate[$id]))
|
||||||
{
|
{
|
||||||
if (isset($view['settings']->main_get->modified)
|
if (isset($view['settings']->main_get->modified)
|
||||||
&& ComponentbuilderHelper::checkString(
|
&& StringHelper::check(
|
||||||
$view['settings']->main_get->modified
|
$view['settings']->main_get->modified
|
||||||
)
|
)
|
||||||
&& '0000-00-00 00:00:00'
|
&& '0000-00-00 00:00:00'
|
||||||
@ -2770,13 +2774,13 @@ class Structure extends Get
|
|||||||
// did we build the files (any number)
|
// did we build the files (any number)
|
||||||
$build_status = false;
|
$build_status = false;
|
||||||
// check that we have the target values
|
// check that we have the target values
|
||||||
if (ComponentbuilderHelper::checkArray($target))
|
if (ArrayHelper::check($target))
|
||||||
{
|
{
|
||||||
// search the target
|
// search the target
|
||||||
foreach ($target as $main => $name)
|
foreach ($target as $main => $name)
|
||||||
{
|
{
|
||||||
// make sure it is lower case
|
// make sure it is lower case
|
||||||
$name = ComponentbuilderHelper::safeString($name);
|
$name = StringHelper::safe($name);
|
||||||
// setup the files
|
// setup the files
|
||||||
foreach (
|
foreach (
|
||||||
$this->joomlaVersionData->move->dynamic->{$main} as $item =>
|
$this->joomlaVersionData->move->dynamic->{$main} as $item =>
|
||||||
@ -2861,7 +2865,7 @@ class Structure extends Get
|
|||||||
$newFIle = array('path' => $path . '/' . $new,
|
$newFIle = array('path' => $path . '/' . $new,
|
||||||
'name' => $new, 'view' => $name,
|
'name' => $new, 'view' => $name,
|
||||||
'zip' => $zipPath . '/' . $new);
|
'zip' => $zipPath . '/' . $new);
|
||||||
if (ComponentbuilderHelper::checkArray($config))
|
if (ArrayHelper::check($config))
|
||||||
{
|
{
|
||||||
$newFIle['config'] = $config;
|
$newFIle['config'] = $config;
|
||||||
}
|
}
|
||||||
@ -2885,15 +2889,28 @@ class Structure extends Get
|
|||||||
*/
|
*/
|
||||||
private function setJoomlaVersionData()
|
private function setJoomlaVersionData()
|
||||||
{
|
{
|
||||||
|
// option to load other settings
|
||||||
|
$custom_settings = $this->templatePath . '/settings_' . $this->componentCodeName . '.json';
|
||||||
// set the version data
|
// set the version data
|
||||||
$versionData = json_decode(
|
if (File::exists($custom_settings))
|
||||||
|
{
|
||||||
|
$version_data = json_decode(
|
||||||
|
ComponentbuilderHelper::getFileContents(
|
||||||
|
$custom_settings
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$version_data = json_decode(
|
||||||
ComponentbuilderHelper::getFileContents(
|
ComponentbuilderHelper::getFileContents(
|
||||||
$this->templatePath . '/settings.json'
|
$this->templatePath . '/settings.json'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
// add custom folders
|
// add custom folders
|
||||||
if ((isset($this->componentData->folders)
|
if ((isset($this->componentData->folders)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$this->componentData->folders
|
$this->componentData->folders
|
||||||
))
|
))
|
||||||
|| $this->addEximport
|
|| $this->addEximport
|
||||||
@ -2965,7 +2982,7 @@ class Structure extends Get
|
|||||||
);
|
);
|
||||||
// fix custom path
|
// fix custom path
|
||||||
if (isset($custom['path'])
|
if (isset($custom['path'])
|
||||||
&& ComponentbuilderHelper::checkString($custom['path']))
|
&& StringHelper::check($custom['path']))
|
||||||
{
|
{
|
||||||
$custom['path'] = trim($custom['path'], '/');
|
$custom['path'] = trim($custom['path'], '/');
|
||||||
}
|
}
|
||||||
@ -3017,31 +3034,31 @@ class Structure extends Get
|
|||||||
$newname = '';
|
$newname = '';
|
||||||
}
|
}
|
||||||
// insure we have no duplicates
|
// insure we have no duplicates
|
||||||
$key_pointer = ComponentbuilderHelper::safeString(
|
$key_pointer = StringHelper::safe(
|
||||||
$custom['folder']
|
$custom['folder']
|
||||||
) . '_f' . $pointer_tracker;
|
) . '_f' . $pointer_tracker;
|
||||||
$pointer_tracker++;
|
$pointer_tracker++;
|
||||||
// fix custom path
|
// fix custom path
|
||||||
$custom['path'] = ltrim($custom['path'], '/');
|
$custom['path'] = ltrim($custom['path'], '/');
|
||||||
// set new folder to object
|
// set new folder to object
|
||||||
$versionData->move->static->{$key_pointer} = new stdClass();
|
$version_data->move->static->{$key_pointer} = new stdClass();
|
||||||
$versionData->move->static->{$key_pointer}->naam
|
$version_data->move->static->{$key_pointer}->naam
|
||||||
= str_replace(
|
= str_replace(
|
||||||
'//', '/', $custom['folder']
|
'//', '/', $custom['folder']
|
||||||
);
|
);
|
||||||
$versionData->move->static->{$key_pointer}->path
|
$version_data->move->static->{$key_pointer}->path
|
||||||
= $_target_type
|
= $_target_type
|
||||||
. '/' . $custom['path'];
|
. '/' . $custom['path'];
|
||||||
$versionData->move->static->{$key_pointer}->rename = $rename;
|
$version_data->move->static->{$key_pointer}->rename = $rename;
|
||||||
$versionData->move->static->{$key_pointer}->newName = $newname;
|
$version_data->move->static->{$key_pointer}->newName = $newname;
|
||||||
$versionData->move->static->{$key_pointer}->type = 'folder';
|
$version_data->move->static->{$key_pointer}->type = 'folder';
|
||||||
$versionData->move->static->{$key_pointer}->custom
|
$version_data->move->static->{$key_pointer}->custom
|
||||||
= $customPath;
|
= $customPath;
|
||||||
// set the target if type and id is found
|
// set the target if type and id is found
|
||||||
if (isset($custom['target_id'])
|
if (isset($custom['target_id'])
|
||||||
&& isset($custom['target_type']))
|
&& isset($custom['target_type']))
|
||||||
{
|
{
|
||||||
$versionData->move->static->{$key_pointer}->_target
|
$version_data->move->static->{$key_pointer}->_target
|
||||||
= array('key' => $custom['target_id'] . '_'
|
= array('key' => $custom['target_id'] . '_'
|
||||||
. $custom['target_type'],
|
. $custom['target_type'],
|
||||||
'type' => $custom['target_type']);
|
'type' => $custom['target_type']);
|
||||||
@ -3052,7 +3069,7 @@ class Structure extends Get
|
|||||||
}
|
}
|
||||||
// add custom files
|
// add custom files
|
||||||
if ((isset($this->componentData->files)
|
if ((isset($this->componentData->files)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$this->componentData->files
|
$this->componentData->files
|
||||||
))
|
))
|
||||||
|| $this->googlechart)
|
|| $this->googlechart)
|
||||||
@ -3106,13 +3123,13 @@ class Structure extends Get
|
|||||||
$customPath = 'full';
|
$customPath = 'full';
|
||||||
}
|
}
|
||||||
// make sure we have not duplicates
|
// make sure we have not duplicates
|
||||||
$key_pointer = ComponentbuilderHelper::safeString(
|
$key_pointer = StringHelper::safe(
|
||||||
$custom['file']
|
$custom['file']
|
||||||
) . '_g' . $pointer_tracker;
|
) . '_g' . $pointer_tracker;
|
||||||
$pointer_tracker++;
|
$pointer_tracker++;
|
||||||
// set new file to object
|
// set new file to object
|
||||||
$versionData->move->static->{$key_pointer} = new stdClass();
|
$version_data->move->static->{$key_pointer} = new stdClass();
|
||||||
$versionData->move->static->{$key_pointer}->naam = str_replace(
|
$version_data->move->static->{$key_pointer}->naam = str_replace(
|
||||||
'//', '/', $custom['file']
|
'//', '/', $custom['file']
|
||||||
);
|
);
|
||||||
// update the dynamic component name placholders in file names
|
// update the dynamic component name placholders in file names
|
||||||
@ -3125,11 +3142,11 @@ class Structure extends Get
|
|||||||
{
|
{
|
||||||
$pathInfo['dirname'] = trim($pathInfo['dirname'], '/');
|
$pathInfo['dirname'] = trim($pathInfo['dirname'], '/');
|
||||||
// set the info
|
// set the info
|
||||||
$versionData->move->static->{$key_pointer}->path
|
$version_data->move->static->{$key_pointer}->path
|
||||||
= $_target_type
|
= $_target_type
|
||||||
. '/' . $pathInfo['dirname'];
|
. '/' . $pathInfo['dirname'];
|
||||||
$versionData->move->static->{$key_pointer}->rename = 'new';
|
$version_data->move->static->{$key_pointer}->rename = 'new';
|
||||||
$versionData->move->static->{$key_pointer}->newName
|
$version_data->move->static->{$key_pointer}->newName
|
||||||
= $pathInfo['basename'];
|
= $pathInfo['basename'];
|
||||||
}
|
}
|
||||||
elseif ('full' === $customPath)
|
elseif ('full' === $customPath)
|
||||||
@ -3139,11 +3156,11 @@ class Structure extends Get
|
|||||||
// get file array
|
// get file array
|
||||||
$fileArray = (array) explode('/', $custom['file']);
|
$fileArray = (array) explode('/', $custom['file']);
|
||||||
// set the info
|
// set the info
|
||||||
$versionData->move->static->{$key_pointer}->path
|
$version_data->move->static->{$key_pointer}->path
|
||||||
= $_target_type
|
= $_target_type
|
||||||
. '/' . $custom['path'];
|
. '/' . $custom['path'];
|
||||||
$versionData->move->static->{$key_pointer}->rename = 'new';
|
$version_data->move->static->{$key_pointer}->rename = 'new';
|
||||||
$versionData->move->static->{$key_pointer}->newName = end(
|
$version_data->move->static->{$key_pointer}->newName = end(
|
||||||
$fileArray
|
$fileArray
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -3152,19 +3169,19 @@ class Structure extends Get
|
|||||||
// fix custom path
|
// fix custom path
|
||||||
$custom['path'] = ltrim($custom['path'], '/');
|
$custom['path'] = ltrim($custom['path'], '/');
|
||||||
// set the info
|
// set the info
|
||||||
$versionData->move->static->{$key_pointer}->path
|
$version_data->move->static->{$key_pointer}->path
|
||||||
= $_target_type
|
= $_target_type
|
||||||
. '/' . $custom['path'];
|
. '/' . $custom['path'];
|
||||||
$versionData->move->static->{$key_pointer}->rename = false;
|
$version_data->move->static->{$key_pointer}->rename = false;
|
||||||
}
|
}
|
||||||
$versionData->move->static->{$key_pointer}->type = 'file';
|
$version_data->move->static->{$key_pointer}->type = 'file';
|
||||||
$versionData->move->static->{$key_pointer}->custom
|
$version_data->move->static->{$key_pointer}->custom
|
||||||
= $customPath;
|
= $customPath;
|
||||||
// set the target if type and id is found
|
// set the target if type and id is found
|
||||||
if (isset($custom['target_id'])
|
if (isset($custom['target_id'])
|
||||||
&& isset($custom['target_type']))
|
&& isset($custom['target_type']))
|
||||||
{
|
{
|
||||||
$versionData->move->static->{$key_pointer}->_target
|
$version_data->move->static->{$key_pointer}->_target
|
||||||
= array('key' => $custom['target_id'] . '_'
|
= array('key' => $custom['target_id'] . '_'
|
||||||
. $custom['target_type'],
|
. $custom['target_type'],
|
||||||
'type' => $custom['target_type']);
|
'type' => $custom['target_type']);
|
||||||
@ -3185,7 +3202,7 @@ class Structure extends Get
|
|||||||
unset($custom);
|
unset($custom);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $versionData;
|
return $version_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -15,6 +15,9 @@ defined('_JEXEC') or die('Restricted access');
|
|||||||
|
|
||||||
use Joomla\CMS\Filesystem\File;
|
use Joomla\CMS\Filesystem\File;
|
||||||
use Joomla\CMS\Filesystem\Folder;
|
use Joomla\CMS\Filesystem\Folder;
|
||||||
|
use VDM\Joomla\Utilities\StringHelper;
|
||||||
|
use VDM\Joomla\Utilities\ArrayHelper;
|
||||||
|
use VDM\Joomla\Utilities\ObjectHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Infusion class
|
* Infusion class
|
||||||
@ -68,7 +71,7 @@ class Infusion extends Interpretation
|
|||||||
protected function buildFileContent()
|
protected function buildFileContent()
|
||||||
{
|
{
|
||||||
if (isset($this->componentData->admin_views)
|
if (isset($this->componentData->admin_views)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$this->componentData->admin_views
|
$this->componentData->admin_views
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -157,7 +160,7 @@ class Infusion extends Interpretation
|
|||||||
}
|
}
|
||||||
// load only first two values
|
// load only first two values
|
||||||
if (isset($versionArray)
|
if (isset($versionArray)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$versionArray
|
$versionArray
|
||||||
)
|
)
|
||||||
&& $this->componentData->mvc_versiondate == 2)
|
&& $this->componentData->mvc_versiondate == 2)
|
||||||
@ -167,7 +170,7 @@ class Infusion extends Interpretation
|
|||||||
}
|
}
|
||||||
// load only the first value
|
// load only the first value
|
||||||
elseif (isset($versionArray)
|
elseif (isset($versionArray)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$versionArray
|
$versionArray
|
||||||
)
|
)
|
||||||
&& $this->componentData->mvc_versiondate == 3)
|
&& $this->componentData->mvc_versiondate == 3)
|
||||||
@ -356,7 +359,7 @@ class Infusion extends Interpretation
|
|||||||
= $this->addEmailHelper();
|
= $this->addEmailHelper();
|
||||||
|
|
||||||
// load the global placeholders
|
// load the global placeholders
|
||||||
if (ComponentbuilderHelper::checkArray($this->globalPlaceholders))
|
if (ArrayHelper::check($this->globalPlaceholders))
|
||||||
{
|
{
|
||||||
foreach (
|
foreach (
|
||||||
$this->globalPlaceholders as $globalPlaceholder =>
|
$this->globalPlaceholders as $globalPlaceholder =>
|
||||||
@ -1030,7 +1033,7 @@ class Infusion extends Interpretation
|
|||||||
$scriptNote, true,
|
$scriptNote, true,
|
||||||
false, PHP_EOL
|
false, PHP_EOL
|
||||||
)) !== false
|
)) !== false
|
||||||
&& ComponentbuilderHelper::checkString($footerScript))
|
&& StringHelper::check($footerScript))
|
||||||
{
|
{
|
||||||
// only minfy if no php is added to the footer script
|
// only minfy if no php is added to the footer script
|
||||||
if ($this->minify
|
if ($this->minify
|
||||||
@ -1296,7 +1299,7 @@ class Infusion extends Interpretation
|
|||||||
|
|
||||||
// setup custom_admin_views and all needed stuff for the site
|
// setup custom_admin_views and all needed stuff for the site
|
||||||
if (isset($this->componentData->custom_admin_views)
|
if (isset($this->componentData->custom_admin_views)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$this->componentData->custom_admin_views
|
$this->componentData->custom_admin_views
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -1667,7 +1670,7 @@ class Infusion extends Interpretation
|
|||||||
$this->setVersionController();
|
$this->setVersionController();
|
||||||
|
|
||||||
// only set these if default dashboard it used
|
// only set these if default dashboard it used
|
||||||
if (!ComponentbuilderHelper::checkString($this->dynamicDashboard))
|
if (!StringHelper::check($this->dynamicDashboard))
|
||||||
{
|
{
|
||||||
// DASHBOARDVIEW
|
// DASHBOARDVIEW
|
||||||
$this->fileContentStatic[$this->hhh . 'DASHBOARDVIEW'
|
$this->fileContentStatic[$this->hhh . 'DASHBOARDVIEW'
|
||||||
@ -1801,7 +1804,7 @@ class Infusion extends Interpretation
|
|||||||
|
|
||||||
// build the validation rules
|
// build the validation rules
|
||||||
if (isset($this->validationRules)
|
if (isset($this->validationRules)
|
||||||
&& ComponentbuilderHelper::checkArray($this->validationRules))
|
&& ArrayHelper::check($this->validationRules))
|
||||||
{
|
{
|
||||||
foreach ($this->validationRules as $rule => $_php)
|
foreach ($this->validationRules as $rule => $_php)
|
||||||
{
|
{
|
||||||
@ -1821,13 +1824,13 @@ class Infusion extends Interpretation
|
|||||||
|
|
||||||
// run the second run if needed
|
// run the second run if needed
|
||||||
if (isset($this->secondRunAdmin)
|
if (isset($this->secondRunAdmin)
|
||||||
&& ComponentbuilderHelper::checkArray($this->secondRunAdmin))
|
&& ArrayHelper::check($this->secondRunAdmin))
|
||||||
{
|
{
|
||||||
// start dynamic build
|
// start dynamic build
|
||||||
foreach ($this->secondRunAdmin as $function => $arrays)
|
foreach ($this->secondRunAdmin as $function => $arrays)
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkArray($arrays)
|
if (ArrayHelper::check($arrays)
|
||||||
&& ComponentbuilderHelper::checkString($function))
|
&& StringHelper::check($function))
|
||||||
{
|
{
|
||||||
foreach ($arrays as $array)
|
foreach ($arrays as $array)
|
||||||
{
|
{
|
||||||
@ -1846,7 +1849,7 @@ class Infusion extends Interpretation
|
|||||||
|
|
||||||
// setup front-views and all needed stuff for the site
|
// setup front-views and all needed stuff for the site
|
||||||
if (isset($this->componentData->site_views)
|
if (isset($this->componentData->site_views)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$this->componentData->site_views
|
$this->componentData->site_views
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -2072,7 +2075,7 @@ class Infusion extends Interpretation
|
|||||||
if ($view['settings']->main_get->gettype == 1)
|
if ($view['settings']->main_get->gettype == 1)
|
||||||
{
|
{
|
||||||
// insure the controller headers are added
|
// insure the controller headers are added
|
||||||
if (ComponentbuilderHelper::checkString(
|
if (StringHelper::check(
|
||||||
$view['settings']->php_controller
|
$view['settings']->php_controller
|
||||||
)
|
)
|
||||||
&& $view['settings']->php_controller != '//')
|
&& $view['settings']->php_controller != '//')
|
||||||
@ -2106,7 +2109,7 @@ class Infusion extends Interpretation
|
|||||||
elseif ($view['settings']->main_get->gettype == 2)
|
elseif ($view['settings']->main_get->gettype == 2)
|
||||||
{
|
{
|
||||||
// insure the controller headers are added
|
// insure the controller headers are added
|
||||||
if (ComponentbuilderHelper::checkString(
|
if (StringHelper::check(
|
||||||
$view['settings']->php_controller
|
$view['settings']->php_controller
|
||||||
)
|
)
|
||||||
&& $view['settings']->php_controller != '//')
|
&& $view['settings']->php_controller != '//')
|
||||||
@ -2286,7 +2289,7 @@ class Infusion extends Interpretation
|
|||||||
$this->fileContentStatic[$this->hhh . 'ROUTER_BUILD_VIEWS'
|
$this->fileContentStatic[$this->hhh . 'ROUTER_BUILD_VIEWS'
|
||||||
. $this->hhh]
|
. $this->hhh]
|
||||||
)
|
)
|
||||||
|| !ComponentbuilderHelper::checkString(
|
|| !StringHelper::check(
|
||||||
$this->fileContentStatic[$this->hhh . 'ROUTER_BUILD_VIEWS'
|
$this->fileContentStatic[$this->hhh . 'ROUTER_BUILD_VIEWS'
|
||||||
. $this->hhh]
|
. $this->hhh]
|
||||||
))
|
))
|
||||||
@ -2310,18 +2313,16 @@ class Infusion extends Interpretation
|
|||||||
= $this->componentData->readme;
|
= $this->componentData->readme;
|
||||||
}
|
}
|
||||||
// remove all the power placeholders
|
// remove all the power placeholders
|
||||||
$this->fileContentStatic[$this->hhh . 'ADMIN_POWER_EVENT_HELPER' . $this->hhh] = '';
|
$this->fileContentStatic[$this->hhh . 'ADMIN_POWER_HELPER' . $this->hhh] = '';
|
||||||
$this->fileContentStatic[$this->hhh . 'ADMIN_POWER_EVENT' . $this->hhh] = '';
|
$this->fileContentStatic[$this->hhh . 'SITE_POWER_HELPER' . $this->hhh] = '';
|
||||||
$this->fileContentStatic[$this->hhh . 'SITE_POWER_EVENT_HELPER' . $this->hhh] = '';
|
|
||||||
$this->fileContentStatic[$this->hhh . 'SITE_POWER_EVENT' . $this->hhh] = '';
|
|
||||||
// infuse powers data if set
|
// infuse powers data if set
|
||||||
if (ComponentbuilderHelper::checkArray($this->powers))
|
if (ArrayHelper::check($this->powers))
|
||||||
{
|
{
|
||||||
// start the autoloader
|
// start the autoloader
|
||||||
$autoloader = array();
|
$autoloader = array();
|
||||||
foreach ($this->powers as $power)
|
foreach ($this->powers as $power)
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject($power))
|
if (ObjectHelper::check($power))
|
||||||
{
|
{
|
||||||
// Trigger Event: jcb_ce_onBeforeInfusePowerData
|
// Trigger Event: jcb_ce_onBeforeInfusePowerData
|
||||||
$this->triggerEvent(
|
$this->triggerEvent(
|
||||||
@ -2349,11 +2350,11 @@ class Infusion extends Interpretation
|
|||||||
$_backup_lang = $this->lang;
|
$_backup_lang = $this->lang;
|
||||||
$_backup_langPrefix = $this->langPrefix;
|
$_backup_langPrefix = $this->langPrefix;
|
||||||
// infuse module data if set
|
// infuse module data if set
|
||||||
if (ComponentbuilderHelper::checkArray($this->joomlaModules))
|
if (ArrayHelper::check($this->joomlaModules))
|
||||||
{
|
{
|
||||||
foreach ($this->joomlaModules as $module)
|
foreach ($this->joomlaModules as $module)
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject($module))
|
if (ObjectHelper::check($module))
|
||||||
{
|
{
|
||||||
// Trigger Event: jcb_ce_onBeforeInfuseModuleData
|
// Trigger Event: jcb_ce_onBeforeInfuseModuleData
|
||||||
$this->triggerEvent(
|
$this->triggerEvent(
|
||||||
@ -2394,7 +2395,7 @@ class Infusion extends Interpretation
|
|||||||
}
|
}
|
||||||
// FIELDSET
|
// FIELDSET
|
||||||
if (isset($module->form_files)
|
if (isset($module->form_files)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$module->form_files
|
$module->form_files
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -2428,11 +2429,11 @@ class Infusion extends Interpretation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// infuse plugin data if set
|
// infuse plugin data if set
|
||||||
if (ComponentbuilderHelper::checkArray($this->joomlaPlugins))
|
if (ArrayHelper::check($this->joomlaPlugins))
|
||||||
{
|
{
|
||||||
foreach ($this->joomlaPlugins as $plugin)
|
foreach ($this->joomlaPlugins as $plugin)
|
||||||
{
|
{
|
||||||
if (ComponentbuilderHelper::checkObject($plugin))
|
if (ObjectHelper::check($plugin))
|
||||||
{
|
{
|
||||||
// Trigger Event: jcb_ce_onBeforeInfusePluginData
|
// Trigger Event: jcb_ce_onBeforeInfusePluginData
|
||||||
$this->triggerEvent(
|
$this->triggerEvent(
|
||||||
@ -2456,7 +2457,7 @@ class Infusion extends Interpretation
|
|||||||
}
|
}
|
||||||
// FIELDSET
|
// FIELDSET
|
||||||
if (isset($plugin->form_files)
|
if (isset($plugin->form_files)
|
||||||
&& ComponentbuilderHelper::checkArray(
|
&& ArrayHelper::check(
|
||||||
$plugin->form_files
|
$plugin->form_files
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -2524,10 +2525,10 @@ class Infusion extends Interpretation
|
|||||||
{
|
{
|
||||||
// set main keys
|
// set main keys
|
||||||
$nameSingleCode = $view->name_single_code;
|
$nameSingleCode = $view->name_single_code;
|
||||||
$name_single_uppercase = ComponentbuilderHelper::safeString(
|
$name_single_uppercase = StringHelper::safe(
|
||||||
$view->name_single, 'U'
|
$view->name_single, 'U'
|
||||||
);
|
);
|
||||||
$name_single_first_uppercase = ComponentbuilderHelper::safeString(
|
$name_single_first_uppercase = StringHelper::safe(
|
||||||
$view->name_single, 'F'
|
$view->name_single, 'F'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -2550,10 +2551,10 @@ class Infusion extends Interpretation
|
|||||||
if (isset($view->name_list) && $view->name_list != 'null')
|
if (isset($view->name_list) && $view->name_list != 'null')
|
||||||
{
|
{
|
||||||
$nameListCode = $view->name_list_code;
|
$nameListCode = $view->name_list_code;
|
||||||
$name_list_uppercase = ComponentbuilderHelper::safeString(
|
$name_list_uppercase = StringHelper::safe(
|
||||||
$view->name_list, 'U'
|
$view->name_list, 'U'
|
||||||
);
|
);
|
||||||
$name_list_first_uppercase = ComponentbuilderHelper::safeString(
|
$name_list_first_uppercase = StringHelper::safe(
|
||||||
$view->name_list, 'F'
|
$view->name_list, 'F'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -2683,7 +2684,7 @@ class Infusion extends Interpretation
|
|||||||
$this->languages['components'][$this->langTag]['sitesys']
|
$this->languages['components'][$this->langTag]['sitesys']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$values = array_unique(ComponentbuilderHelper::mergeArrays($values));
|
$values = array_unique(ArrayHelper::merge($values));
|
||||||
// get the other lang strings if there is any
|
// get the other lang strings if there is any
|
||||||
$this->multiLangString = $this->getMultiLangStrings($values);
|
$this->multiLangString = $this->getMultiLangStrings($values);
|
||||||
// update insert the current lang in to DB
|
// update insert the current lang in to DB
|
||||||
@ -2699,7 +2700,7 @@ class Infusion extends Interpretation
|
|||||||
&$this->langTag)
|
&$this->langTag)
|
||||||
);
|
);
|
||||||
// now we insert the values into the files
|
// now we insert the values into the files
|
||||||
if (ComponentbuilderHelper::checkArray($this->languages['components']))
|
if (ArrayHelper::check($this->languages['components']))
|
||||||
{
|
{
|
||||||
// rest xml array
|
// rest xml array
|
||||||
$langXML = array();
|
$langXML = array();
|
||||||
@ -2775,18 +2776,18 @@ class Infusion extends Interpretation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// load the lang xml
|
// load the lang xml
|
||||||
if (ComponentbuilderHelper::checkArray($langXML))
|
if (ArrayHelper::check($langXML))
|
||||||
{
|
{
|
||||||
$replace = array();
|
$replace = array();
|
||||||
if (isset($langXML['admin'])
|
if (isset($langXML['admin'])
|
||||||
&& ComponentbuilderHelper::checkArray($langXML['admin']))
|
&& ArrayHelper::check($langXML['admin']))
|
||||||
{
|
{
|
||||||
$replace[$this->hhh . 'ADMIN_LANGUAGES' . $this->hhh]
|
$replace[$this->hhh . 'ADMIN_LANGUAGES' . $this->hhh]
|
||||||
= implode(PHP_EOL . $this->_t(3), $langXML['admin']);
|
= implode(PHP_EOL . $this->_t(3), $langXML['admin']);
|
||||||
}
|
}
|
||||||
if ((!$this->removeSiteFolder || !$this->removeSiteEditFolder)
|
if ((!$this->removeSiteFolder || !$this->removeSiteEditFolder)
|
||||||
&& isset($langXML['site'])
|
&& isset($langXML['site'])
|
||||||
&& ComponentbuilderHelper::checkArray($langXML['site']))
|
&& ArrayHelper::check($langXML['site']))
|
||||||
{
|
{
|
||||||
$replace[$this->hhh . 'SITE_LANGUAGES' . $this->hhh]
|
$replace[$this->hhh . 'SITE_LANGUAGES' . $this->hhh]
|
||||||
= implode(PHP_EOL . $this->_t(2), $langXML['site']);
|
= implode(PHP_EOL . $this->_t(2), $langXML['site']);
|
||||||
|
@ -13,6 +13,50 @@
|
|||||||
// No direct access to this file
|
// No direct access to this file
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
|
||||||
|
// register this component namespace
|
||||||
|
spl_autoload_register(function ($class) {
|
||||||
|
// project-specific base directories and namespace prefix
|
||||||
|
$search = array(
|
||||||
|
'libraries/jcb_powers/VDM.Joomla' => 'VDM\\Joomla'
|
||||||
|
);
|
||||||
|
// Start the search and load if found
|
||||||
|
$found = false;
|
||||||
|
$found_base_dir = "";
|
||||||
|
$found_len = 0;
|
||||||
|
foreach ($search as $base_dir => $prefix)
|
||||||
|
{
|
||||||
|
// does the class use the namespace prefix?
|
||||||
|
$len = strlen($prefix);
|
||||||
|
if (strncmp($prefix, $class, $len) === 0)
|
||||||
|
{
|
||||||
|
// we have a match so load the values
|
||||||
|
$found = true;
|
||||||
|
$found_base_dir = $base_dir;
|
||||||
|
$found_len = $len;
|
||||||
|
// done here
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check if we found a match
|
||||||
|
if (!$found)
|
||||||
|
{
|
||||||
|
// no, move to the next registered autoloader
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// get the relative class name
|
||||||
|
$relative_class = substr($class, $found_len);
|
||||||
|
// replace the namespace prefix with the base directory, replace namespace
|
||||||
|
// separators with directory separators in the relative class name, append
|
||||||
|
// with .php
|
||||||
|
$file = JPATH_ROOT . '/' . $found_base_dir . '/src' . str_replace('\\', '/', $relative_class) . '.php';
|
||||||
|
// if the file exists, require it
|
||||||
|
if (file_exists($file))
|
||||||
|
{
|
||||||
|
require $file;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
use Joomla\CMS\Language\Language;
|
use Joomla\CMS\Language\Language;
|
||||||
use Joomla\Registry\Registry;
|
use Joomla\Registry\Registry;
|
||||||
use Joomla\String\StringHelper;
|
use Joomla\String\StringHelper;
|
||||||
@ -24,12 +68,20 @@ use Joomla\Archive\Archive;
|
|||||||
use Joomla\CMS\Filesystem\File;
|
use Joomla\CMS\Filesystem\File;
|
||||||
use Joomla\CMS\Filesystem\Folder;
|
use Joomla\CMS\Filesystem\Folder;
|
||||||
use Joomla\CMS\Filesystem\Path;
|
use Joomla\CMS\Filesystem\Path;
|
||||||
|
use VDM\Joomla\Utilities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Componentbuilder component helper.
|
* Componentbuilder component helper.
|
||||||
*/
|
*/
|
||||||
abstract class ComponentbuilderHelper
|
abstract class ComponentbuilderHelper
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Adding the utilities trait to this class
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Check the trait methods for details, a legacy implementation
|
||||||
|
*/
|
||||||
|
use Utilities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Composer Switch
|
* Composer Switch
|
||||||
*
|
*
|
||||||
@ -37,13 +89,6 @@ abstract class ComponentbuilderHelper
|
|||||||
*/
|
*/
|
||||||
protected static $composer = array();
|
protected static $composer = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* The Main Active Language
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public static $langTag;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Global Admin Event Method.
|
* The Global Admin Event Method.
|
||||||
**/
|
**/
|
||||||
@ -665,157 +710,6 @@ abstract class ComponentbuilderHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Making class or function name safe
|
|
||||||
*
|
|
||||||
* @input string The name you would like to make safe
|
|
||||||
*
|
|
||||||
* @returns string on success
|
|
||||||
**/
|
|
||||||
public static function safeClassFunctionName($name)
|
|
||||||
{
|
|
||||||
// remove numbers if the first character is a number
|
|
||||||
if (is_numeric(substr($name, 0, 1)))
|
|
||||||
{
|
|
||||||
$name = self::replaceNumbers($name);
|
|
||||||
}
|
|
||||||
// remove all spaces and strange characters
|
|
||||||
return trim(preg_replace("/[^A-Za-z0-9_-]/", '', $name));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The field builder switch
|
|
||||||
**/
|
|
||||||
protected static $fieldNameBuilder = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Making field names safe
|
|
||||||
*
|
|
||||||
* @input string The you would like to make safe
|
|
||||||
* @input boolean The switch to return an ALL UPPER CASE string
|
|
||||||
* @input string The string to use in white space
|
|
||||||
*
|
|
||||||
* @returns string on success
|
|
||||||
**/
|
|
||||||
public static function safeFieldName($string, $allcap = false, $spacer = '_')
|
|
||||||
{
|
|
||||||
// get global value
|
|
||||||
if (self::$fieldNameBuilder === false)
|
|
||||||
{
|
|
||||||
self::$fieldNameBuilder = JComponentHelper::getParams('com_componentbuilder')->get('field_name_builder', 1);
|
|
||||||
}
|
|
||||||
// use the new convention
|
|
||||||
if (2 == self::$fieldNameBuilder)
|
|
||||||
{
|
|
||||||
// 0nly continue if we have a string
|
|
||||||
if (self::checkString($string))
|
|
||||||
{
|
|
||||||
// check that the first character is not a number
|
|
||||||
if (is_numeric(substr($string, 0, 1)))
|
|
||||||
{
|
|
||||||
$string = self::replaceNumbers($string);
|
|
||||||
}
|
|
||||||
// remove all other strange characters
|
|
||||||
$string = trim($string);
|
|
||||||
$string = preg_replace('/'.$spacer.'+/', ' ', $string);
|
|
||||||
$string = preg_replace('/\s+/', ' ', $string);
|
|
||||||
// Transliterate string
|
|
||||||
$string = self::transliterate($string);
|
|
||||||
// remove all and keep only characters and numbers
|
|
||||||
$string = preg_replace("/[^A-Za-z0-9 ]/", '', $string);
|
|
||||||
// replace white space with underscore (SAFEST OPTION)
|
|
||||||
$string = preg_replace('/\s+/', $spacer, $string);
|
|
||||||
// return all caps
|
|
||||||
if ($allcap)
|
|
||||||
{
|
|
||||||
return strtoupper($string);
|
|
||||||
}
|
|
||||||
// default is to return lower
|
|
||||||
return strtolower($string);
|
|
||||||
}
|
|
||||||
// not a string
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
// return all caps
|
|
||||||
if ($allcap)
|
|
||||||
{
|
|
||||||
return self::safeString($string, 'U');
|
|
||||||
}
|
|
||||||
// use the default (original behaviour/convention)
|
|
||||||
return self::safeString($string);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The type builder switch
|
|
||||||
**/
|
|
||||||
protected static $typeNameBuilder = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Making field type name safe
|
|
||||||
*
|
|
||||||
* @input string The you would like to make safe
|
|
||||||
*
|
|
||||||
* @returns string on success
|
|
||||||
**/
|
|
||||||
public static function safeTypeName($string)
|
|
||||||
{
|
|
||||||
// get global value
|
|
||||||
if (self::$typeNameBuilder === false)
|
|
||||||
{
|
|
||||||
self::$typeNameBuilder = JComponentHelper::getParams('com_componentbuilder')->get('type_name_builder', 1);
|
|
||||||
}
|
|
||||||
// use the new convention
|
|
||||||
if (2 == self::$typeNameBuilder)
|
|
||||||
{
|
|
||||||
// 0nly continue if we have a string
|
|
||||||
if (self::checkString($string))
|
|
||||||
{
|
|
||||||
// check that the first character is not a number
|
|
||||||
if (is_numeric(substr($string, 0, 1)))
|
|
||||||
{
|
|
||||||
$string = self::replaceNumbers($string);
|
|
||||||
}
|
|
||||||
// Transliterate string
|
|
||||||
$string = self::transliterate($string);
|
|
||||||
// remove all and keep only characters and numbers and point (TODO just one point)
|
|
||||||
$string = trim(preg_replace("/[^A-Za-z0-9\.]/", '', $string));
|
|
||||||
// best is to return lower (for all string equality in compiler)
|
|
||||||
return strtolower($string);
|
|
||||||
}
|
|
||||||
// not a string
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
// use the default (original behaviour/convention)
|
|
||||||
return self::safeString($string);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Making namespace safe
|
|
||||||
*
|
|
||||||
* @input string The you would like to make safe
|
|
||||||
*
|
|
||||||
* @returns string on success
|
|
||||||
**/
|
|
||||||
public static function safeNamespace($string)
|
|
||||||
{
|
|
||||||
// 0nly continue if we have a string
|
|
||||||
if (self::checkString($string))
|
|
||||||
{
|
|
||||||
// make sure it has not numbers
|
|
||||||
$string = self::replaceNumbers($string);
|
|
||||||
// Transliterate string TODO: look again as this make it lowercase
|
|
||||||
// $string = self::transliterate($string);
|
|
||||||
// first remove all [\] backslashes
|
|
||||||
$string = str_replace('\\', '1', $string);
|
|
||||||
// remove all and keep only characters and [\] backslashes inside of the string
|
|
||||||
$string = trim(preg_replace("/[^A-Za-z1]/", '', $string), '1');
|
|
||||||
// place the [\] backslashes back
|
|
||||||
return trim(preg_replace("/1+/", '\\', $string));
|
|
||||||
}
|
|
||||||
// not a string
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the Array of Existing Validation Rule Names
|
* Get the Array of Existing Validation Rule Names
|
||||||
*
|
*
|
||||||
@ -4917,85 +4811,6 @@ abstract class ComponentbuilderHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* bc math wrapper (very basic not for accounting)
|
|
||||||
*
|
|
||||||
* @param string $type The type bc math
|
|
||||||
* @param int $val1 The first value
|
|
||||||
* @param int $val2 The second value
|
|
||||||
* @param int $scale The scale value
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static function bcmath($type, $val1, $val2, $scale = 0)
|
|
||||||
{
|
|
||||||
// build function name
|
|
||||||
$function = 'bc' . $type;
|
|
||||||
// use the bcmath function if available
|
|
||||||
if (function_exists($function))
|
|
||||||
{
|
|
||||||
return $function($val1, $val2, $scale);
|
|
||||||
}
|
|
||||||
// if function does not exist we use +-*/ operators (fallback - not ideal)
|
|
||||||
switch ($type)
|
|
||||||
{
|
|
||||||
// Multiply two numbers
|
|
||||||
case 'mul':
|
|
||||||
return (string) round($val1 * $val2, $scale);
|
|
||||||
break;
|
|
||||||
// Divide of two numbers
|
|
||||||
case 'div':
|
|
||||||
return (string) round($val1 / $val2, $scale);
|
|
||||||
break;
|
|
||||||
// Adding two numbers
|
|
||||||
case 'add':
|
|
||||||
return (string) round($val1 + $val2, $scale);
|
|
||||||
break;
|
|
||||||
// Subtract one number from the other
|
|
||||||
case 'sub':
|
|
||||||
return (string) round($val1 - $val2, $scale);
|
|
||||||
break;
|
|
||||||
// Raise an arbitrary precision number to another
|
|
||||||
case 'pow':
|
|
||||||
return (string) round(pow($val1, $val2), $scale);
|
|
||||||
break;
|
|
||||||
// Compare two arbitrary precision numbers
|
|
||||||
case 'comp':
|
|
||||||
return (round($val1,2) == round($val2,2));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
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
|
||||||
*
|
*
|
||||||
@ -7436,177 +7251,6 @@ abstract class ComponentbuilderHelper
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a Variable
|
|
||||||
*
|
|
||||||
* @param string $table The table from which to get the variable
|
|
||||||
* @param string $where The value where
|
|
||||||
* @param string $whereString The target/field string where/name
|
|
||||||
* @param string $what The return field
|
|
||||||
* @param string $operator The operator between $whereString/field and $where/value
|
|
||||||
* @param string $main The component in which the table is found
|
|
||||||
*
|
|
||||||
* @return mix string/int/float
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'componentbuilder')
|
|
||||||
{
|
|
||||||
if(!$where)
|
|
||||||
{
|
|
||||||
$where = JFactory::getUser()->id;
|
|
||||||
}
|
|
||||||
// Get a db connection.
|
|
||||||
$db = JFactory::getDbo();
|
|
||||||
// Create a new query object.
|
|
||||||
$query = $db->getQuery(true);
|
|
||||||
$query->select($db->quoteName(array($what)));
|
|
||||||
if (empty($table))
|
|
||||||
{
|
|
||||||
$query->from($db->quoteName('#__'.$main));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$query->from($db->quoteName('#__'.$main.'_'.$table));
|
|
||||||
}
|
|
||||||
if (is_numeric($where))
|
|
||||||
{
|
|
||||||
$query->where($db->quoteName($whereString) . ' '.$operator.' '.(int) $where);
|
|
||||||
}
|
|
||||||
elseif (is_string($where))
|
|
||||||
{
|
|
||||||
$query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$where));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$db->setQuery($query);
|
|
||||||
$db->execute();
|
|
||||||
if ($db->getNumRows())
|
|
||||||
{
|
|
||||||
return $db->loadResult();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get array of variables
|
|
||||||
*
|
|
||||||
* @param string $table The table from which to get the variables
|
|
||||||
* @param string $where The value where
|
|
||||||
* @param string $whereString The target/field string where/name
|
|
||||||
* @param string $what The return field
|
|
||||||
* @param string $operator The operator between $whereString/field and $where/value
|
|
||||||
* @param string $main The component in which the table is found
|
|
||||||
* @param bool $unique The switch to return a unique array
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = 'componentbuilder', $unique = true)
|
|
||||||
{
|
|
||||||
if(!$where)
|
|
||||||
{
|
|
||||||
$where = JFactory::getUser()->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!self::checkArray($where) && $where > 0)
|
|
||||||
{
|
|
||||||
$where = array($where);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self::checkArray($where))
|
|
||||||
{
|
|
||||||
// prep main <-- why? well if $main='' is empty then $table can be categories or users
|
|
||||||
if (self::checkString($main))
|
|
||||||
{
|
|
||||||
$main = '_'.ltrim($main, '_');
|
|
||||||
}
|
|
||||||
// Get a db connection.
|
|
||||||
$db = JFactory::getDbo();
|
|
||||||
// Create a new query object.
|
|
||||||
$query = $db->getQuery(true);
|
|
||||||
|
|
||||||
$query->select($db->quoteName(array($what)));
|
|
||||||
if (empty($table))
|
|
||||||
{
|
|
||||||
$query->from($db->quoteName('#__'.$main));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$query->from($db->quoteName('#_'.$main.'_'.$table));
|
|
||||||
}
|
|
||||||
// add strings to array search
|
|
||||||
if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator)
|
|
||||||
{
|
|
||||||
$query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$where) . '")');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',',$where) . ')');
|
|
||||||
}
|
|
||||||
$db->setQuery($query);
|
|
||||||
$db->execute();
|
|
||||||
if ($db->getNumRows())
|
|
||||||
{
|
|
||||||
if ($unique)
|
|
||||||
{
|
|
||||||
return array_unique($db->loadColumn());
|
|
||||||
}
|
|
||||||
return $db->loadColumn();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name')
|
|
||||||
{
|
|
||||||
// do some table foot work
|
|
||||||
$external = false;
|
|
||||||
if (strpos($table, '#__') !== false)
|
|
||||||
{
|
|
||||||
$external = true;
|
|
||||||
$table = str_replace('#__', '', $table);
|
|
||||||
}
|
|
||||||
// check if string is JSON
|
|
||||||
$result = json_decode($value, true);
|
|
||||||
if (json_last_error() === JSON_ERROR_NONE)
|
|
||||||
{
|
|
||||||
// is JSON
|
|
||||||
if (self::checkArray($result))
|
|
||||||
{
|
|
||||||
if (self::checkString($table))
|
|
||||||
{
|
|
||||||
$names = array();
|
|
||||||
foreach ($result as $val)
|
|
||||||
{
|
|
||||||
if ($external)
|
|
||||||
{
|
|
||||||
if ($_name = self::getVar(null, $val, $id, $name, '=', $table))
|
|
||||||
{
|
|
||||||
$names[] = $_name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($_name = self::getVar($table, $val, $id, $name))
|
|
||||||
{
|
|
||||||
$names[] = $_name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (self::checkArray($names))
|
|
||||||
{
|
|
||||||
return (string) implode($sperator,$names);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (string) implode($sperator,$result);
|
|
||||||
}
|
|
||||||
return (string) json_decode($value);
|
|
||||||
}
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function isPublished($id,$type)
|
public static function isPublished($id,$type)
|
||||||
{
|
{
|
||||||
if ($type == 'raw')
|
if ($type == 'raw')
|
||||||
@ -8200,83 +7844,6 @@ abstract class ComponentbuilderHelper
|
|||||||
return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input;
|
return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if have an json string
|
|
||||||
*
|
|
||||||
* @input string The json string to check
|
|
||||||
*
|
|
||||||
* @returns bool true on success
|
|
||||||
*/
|
|
||||||
public static function checkJson($string)
|
|
||||||
{
|
|
||||||
if (self::checkString($string))
|
|
||||||
{
|
|
||||||
json_decode($string);
|
|
||||||
return (json_last_error() === JSON_ERROR_NONE);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if have an object with a length
|
|
||||||
*
|
|
||||||
* @input object The object to check
|
|
||||||
*
|
|
||||||
* @returns bool true on success
|
|
||||||
*/
|
|
||||||
public static function checkObject($object)
|
|
||||||
{
|
|
||||||
if (isset($object) && is_object($object))
|
|
||||||
{
|
|
||||||
return count((array)$object) > 0;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if have an array with a length
|
|
||||||
*
|
|
||||||
* @input array The array to check
|
|
||||||
*
|
|
||||||
* @returns bool/int number of items in array on success
|
|
||||||
*/
|
|
||||||
public static function checkArray($array, $removeEmptyString = false)
|
|
||||||
{
|
|
||||||
if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0)
|
|
||||||
{
|
|
||||||
// also make sure the empty strings are removed
|
|
||||||
if ($removeEmptyString)
|
|
||||||
{
|
|
||||||
foreach ($array as $key => $string)
|
|
||||||
{
|
|
||||||
if (empty($string))
|
|
||||||
{
|
|
||||||
unset($array[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return self::checkArray($array, false);
|
|
||||||
}
|
|
||||||
return $nr;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if have a string with a length
|
|
||||||
*
|
|
||||||
* @input string The string to check
|
|
||||||
*
|
|
||||||
* @returns bool true on success
|
|
||||||
*/
|
|
||||||
public static function checkString($string)
|
|
||||||
{
|
|
||||||
if (isset($string) && is_string($string) && strlen($string) > 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we are connected
|
* Check if we are connected
|
||||||
* Thanks https://stackoverflow.com/a/4860432/1429677
|
* Thanks https://stackoverflow.com/a/4860432/1429677
|
||||||
@ -8302,345 +7869,12 @@ abstract class ComponentbuilderHelper
|
|||||||
return $is_conn;
|
return $is_conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Merge an array of array's
|
|
||||||
*
|
|
||||||
* @input array The arrays you would like to merge
|
|
||||||
*
|
|
||||||
* @returns array on success
|
|
||||||
*/
|
|
||||||
public static function mergeArrays($arrays)
|
|
||||||
{
|
|
||||||
if(self::checkArray($arrays))
|
|
||||||
{
|
|
||||||
$arrayBuket = array();
|
|
||||||
foreach ($arrays as $array)
|
|
||||||
{
|
|
||||||
if (self::checkArray($array))
|
|
||||||
{
|
|
||||||
$arrayBuket = array_merge($arrayBuket, $array);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $arrayBuket;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// typo sorry!
|
// typo sorry!
|
||||||
public static function sorten($string, $length = 40, $addTip = true)
|
public static function sorten($string, $length = 40, $addTip = true)
|
||||||
{
|
{
|
||||||
return self::shorten($string, $length, $addTip);
|
return self::shorten($string, $length, $addTip);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Shorten a string
|
|
||||||
*
|
|
||||||
* @input string The you would like to shorten
|
|
||||||
*
|
|
||||||
* @returns string on success
|
|
||||||
*/
|
|
||||||
public static function shorten($string, $length = 40, $addTip = true)
|
|
||||||
{
|
|
||||||
if (self::checkString($string))
|
|
||||||
{
|
|
||||||
$initial = strlen($string);
|
|
||||||
$words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE);
|
|
||||||
$words_count = count((array)$words);
|
|
||||||
|
|
||||||
$word_length = 0;
|
|
||||||
$last_word = 0;
|
|
||||||
for (; $last_word < $words_count; ++$last_word)
|
|
||||||
{
|
|
||||||
$word_length += strlen($words[$last_word]);
|
|
||||||
if ($word_length > $length)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$newString = implode(array_slice($words, 0, $last_word));
|
|
||||||
$final = strlen($newString);
|
|
||||||
if ($initial != $final && $addTip)
|
|
||||||
{
|
|
||||||
$title = self::shorten($string, 400 , false);
|
|
||||||
return '<span class="hasTip" title="'.$title.'" style="cursor:help">'.trim($newString).'...</span>';
|
|
||||||
}
|
|
||||||
elseif ($initial != $final && !$addTip)
|
|
||||||
{
|
|
||||||
return trim($newString).'...';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Making strings safe (various ways)
|
|
||||||
*
|
|
||||||
* @input string The you would like to make safe
|
|
||||||
*
|
|
||||||
* @returns string on success
|
|
||||||
*/
|
|
||||||
public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true)
|
|
||||||
{
|
|
||||||
if ($replaceNumbers === true)
|
|
||||||
{
|
|
||||||
// remove all numbers and replace with english text version (works well only up to millions)
|
|
||||||
$string = self::replaceNumbers($string);
|
|
||||||
}
|
|
||||||
// 0nly continue if we have a string
|
|
||||||
if (self::checkString($string))
|
|
||||||
{
|
|
||||||
// create file name without the extention that is safe
|
|
||||||
if ($type === 'filename')
|
|
||||||
{
|
|
||||||
// make sure VDM is not in the string
|
|
||||||
$string = str_replace('VDM', 'vDm', $string);
|
|
||||||
// Remove anything which isn't a word, whitespace, number
|
|
||||||
// or any of the following caracters -_()
|
|
||||||
// If you don't need to handle multi-byte characters
|
|
||||||
// you can use preg_replace rather than mb_ereg_replace
|
|
||||||
// Thanks @Łukasz Rysiak!
|
|
||||||
// $string = mb_ereg_replace("([^\w\s\d\-_\(\)])", '', $string);
|
|
||||||
$string = preg_replace("([^\w\s\d\-_\(\)])", '', $string);
|
|
||||||
// http://stackoverflow.com/a/2021729/1429677
|
|
||||||
return preg_replace('/\s+/', ' ', $string);
|
|
||||||
}
|
|
||||||
// remove all other characters
|
|
||||||
$string = trim($string);
|
|
||||||
$string = preg_replace('/'.$spacer.'+/', ' ', $string);
|
|
||||||
$string = preg_replace('/\s+/', ' ', $string);
|
|
||||||
// Transliterate string
|
|
||||||
$string = self::transliterate($string);
|
|
||||||
// remove all and keep only characters
|
|
||||||
if ($keepOnlyCharacters)
|
|
||||||
{
|
|
||||||
$string = preg_replace("/[^A-Za-z ]/", '', $string);
|
|
||||||
}
|
|
||||||
// keep both numbers and characters
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$string = preg_replace("/[^A-Za-z0-9 ]/", '', $string);
|
|
||||||
}
|
|
||||||
// select final adaptations
|
|
||||||
if ($type === 'L' || $type === 'strtolower')
|
|
||||||
{
|
|
||||||
// replace white space with underscore
|
|
||||||
$string = preg_replace('/\s+/', $spacer, $string);
|
|
||||||
// default is to return lower
|
|
||||||
return strtolower($string);
|
|
||||||
}
|
|
||||||
elseif ($type === 'W')
|
|
||||||
{
|
|
||||||
// return a string with all first letter of each word uppercase(no undersocre)
|
|
||||||
return ucwords(strtolower($string));
|
|
||||||
}
|
|
||||||
elseif ($type === 'w' || $type === 'word')
|
|
||||||
{
|
|
||||||
// return a string with all lowercase(no undersocre)
|
|
||||||
return strtolower($string);
|
|
||||||
}
|
|
||||||
elseif ($type === 'Ww' || $type === 'Word')
|
|
||||||
{
|
|
||||||
// return a string with first letter of the first word uppercase and all the rest lowercase(no undersocre)
|
|
||||||
return ucfirst(strtolower($string));
|
|
||||||
}
|
|
||||||
elseif ($type === 'WW' || $type === 'WORD')
|
|
||||||
{
|
|
||||||
// return a string with all the uppercase(no undersocre)
|
|
||||||
return strtoupper($string);
|
|
||||||
}
|
|
||||||
elseif ($type === 'U' || $type === 'strtoupper')
|
|
||||||
{
|
|
||||||
// replace white space with underscore
|
|
||||||
$string = preg_replace('/\s+/', $spacer, $string);
|
|
||||||
// return all upper
|
|
||||||
return strtoupper($string);
|
|
||||||
}
|
|
||||||
elseif ($type === 'F' || $type === 'ucfirst')
|
|
||||||
{
|
|
||||||
// replace white space with underscore
|
|
||||||
$string = preg_replace('/\s+/', $spacer, $string);
|
|
||||||
// return with first caracter to upper
|
|
||||||
return ucfirst(strtolower($string));
|
|
||||||
}
|
|
||||||
elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase')
|
|
||||||
{
|
|
||||||
// convert all words to first letter uppercase
|
|
||||||
$string = ucwords(strtolower($string));
|
|
||||||
// remove white space
|
|
||||||
$string = preg_replace('/\s+/', '', $string);
|
|
||||||
// now return first letter lowercase
|
|
||||||
return lcfirst($string);
|
|
||||||
}
|
|
||||||
// return string
|
|
||||||
return $string;
|
|
||||||
}
|
|
||||||
// not a string
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function transliterate($string)
|
|
||||||
{
|
|
||||||
// set tag only once
|
|
||||||
if (!self::checkString(self::$langTag))
|
|
||||||
{
|
|
||||||
// get global value
|
|
||||||
self::$langTag = JComponentHelper::getParams('com_componentbuilder')->get('language', 'en-GB');
|
|
||||||
}
|
|
||||||
// Transliterate on the language requested
|
|
||||||
$lang = Language::getInstance(self::$langTag);
|
|
||||||
return $lang->transliterate($string);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40)
|
|
||||||
{
|
|
||||||
if (self::checkString($var))
|
|
||||||
{
|
|
||||||
$filter = new JFilterInput();
|
|
||||||
$string = $filter->clean(html_entity_decode(htmlentities($var, ENT_COMPAT, $charset)), 'HTML');
|
|
||||||
if ($shorten)
|
|
||||||
{
|
|
||||||
return self::shorten($string,$length);
|
|
||||||
}
|
|
||||||
return $string;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function replaceNumbers($string)
|
|
||||||
{
|
|
||||||
// set numbers array
|
|
||||||
$numbers = array();
|
|
||||||
// first get all numbers
|
|
||||||
preg_match_all('!\d+!', $string, $numbers);
|
|
||||||
// check if we have any numbers
|
|
||||||
if (isset($numbers[0]) && self::checkArray($numbers[0]))
|
|
||||||
{
|
|
||||||
foreach ($numbers[0] as $number)
|
|
||||||
{
|
|
||||||
$searchReplace[$number] = self::numberToString((int)$number);
|
|
||||||
}
|
|
||||||
// now replace numbers in string
|
|
||||||
$string = str_replace(array_keys($searchReplace), array_values($searchReplace),$string);
|
|
||||||
// check if we missed any, strange if we did.
|
|
||||||
return self::replaceNumbers($string);
|
|
||||||
}
|
|
||||||
// return the string with no numbers remaining.
|
|
||||||
return $string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert an integer into an English word string
|
|
||||||
* Thanks to Tom Nicholson <http://php.net/manual/en/function.strval.php#41988>
|
|
||||||
*
|
|
||||||
* @input an int
|
|
||||||
* @returns a string
|
|
||||||
*/
|
|
||||||
public static function numberToString($x)
|
|
||||||
{
|
|
||||||
$nwords = array( "zero", "one", "two", "three", "four", "five", "six", "seven",
|
|
||||||
"eight", "nine", "ten", "eleven", "twelve", "thirteen",
|
|
||||||
"fourteen", "fifteen", "sixteen", "seventeen", "eighteen",
|
|
||||||
"nineteen", "twenty", 30 => "thirty", 40 => "forty",
|
|
||||||
50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty",
|
|
||||||
90 => "ninety" );
|
|
||||||
|
|
||||||
if(!is_numeric($x))
|
|
||||||
{
|
|
||||||
$w = $x;
|
|
||||||
}
|
|
||||||
elseif(fmod($x, 1) != 0)
|
|
||||||
{
|
|
||||||
$w = $x;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if($x < 0)
|
|
||||||
{
|
|
||||||
$w = 'minus ';
|
|
||||||
$x = -$x;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$w = '';
|
|
||||||
// ... now $x is a non-negative integer.
|
|
||||||
}
|
|
||||||
|
|
||||||
if($x < 21) // 0 to 20
|
|
||||||
{
|
|
||||||
$w .= $nwords[$x];
|
|
||||||
}
|
|
||||||
elseif($x < 100) // 21 to 99
|
|
||||||
{
|
|
||||||
$w .= $nwords[10 * floor($x/10)];
|
|
||||||
$r = fmod($x, 10);
|
|
||||||
if($r > 0)
|
|
||||||
{
|
|
||||||
$w .= ' '. $nwords[$r];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif($x < 1000) // 100 to 999
|
|
||||||
{
|
|
||||||
$w .= $nwords[floor($x/100)] .' hundred';
|
|
||||||
$r = fmod($x, 100);
|
|
||||||
if($r > 0)
|
|
||||||
{
|
|
||||||
$w .= ' and '. self::numberToString($r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif($x < 1000000) // 1000 to 999999
|
|
||||||
{
|
|
||||||
$w .= self::numberToString(floor($x/1000)) .' thousand';
|
|
||||||
$r = fmod($x, 1000);
|
|
||||||
if($r > 0)
|
|
||||||
{
|
|
||||||
$w .= ' ';
|
|
||||||
if($r < 100)
|
|
||||||
{
|
|
||||||
$w .= 'and ';
|
|
||||||
}
|
|
||||||
$w .= self::numberToString($r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // millions
|
|
||||||
{
|
|
||||||
$w .= self::numberToString(floor($x/1000000)) .' million';
|
|
||||||
$r = fmod($x, 1000000);
|
|
||||||
if($r > 0)
|
|
||||||
{
|
|
||||||
$w .= ' ';
|
|
||||||
if($r < 100)
|
|
||||||
{
|
|
||||||
$w .= 'and ';
|
|
||||||
}
|
|
||||||
$w .= self::numberToString($r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $w;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Random Key
|
|
||||||
*
|
|
||||||
* @returns a string
|
|
||||||
*/
|
|
||||||
public static function randomkey($size)
|
|
||||||
{
|
|
||||||
$bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
|
|
||||||
$key = array();
|
|
||||||
$bagsize = strlen($bag) - 1;
|
|
||||||
for ($i = 0; $i < $size; $i++)
|
|
||||||
{
|
|
||||||
$get = rand(0, $bagsize);
|
|
||||||
$key[] = $bag[$get];
|
|
||||||
}
|
|
||||||
return implode($key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get The Encryption Keys
|
* Get The Encryption Keys
|
||||||
*
|
*
|
||||||
|
@ -620,7 +620,7 @@ jQuery(document).ready( function($) {
|
|||||||
jQuery(document).ready(function () {
|
jQuery(document).ready(function () {
|
||||||
jQuery.get(getreadme)
|
jQuery.get(getreadme)
|
||||||
.success(function(readme) {
|
.success(function(readme) {
|
||||||
jQuery("#readme-md").html(marked(readme));
|
jQuery("#readme-md").html(marked.parse(readme));
|
||||||
})
|
})
|
||||||
.error(function(jqXHR, textStatus, errorThrown) {
|
.error(function(jqXHR, textStatus, errorThrown) {
|
||||||
jQuery("#readme-md").html("'.JText::_('COM_COMPONENTBUILDER_PLEASE_CHECK_AGAIN_LATTER').'");
|
jQuery("#readme-md").html("'.JText::_('COM_COMPONENTBUILDER_PLEASE_CHECK_AGAIN_LATTER').'");
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<extension type="component" version="4" method="upgrade">
|
<extension type="component" version="4" method="upgrade">
|
||||||
<name>COM_COMPONENTBUILDER</name>
|
<name>COM_COMPONENTBUILDER</name>
|
||||||
<creationDate>12th February, 2022</creationDate>
|
<creationDate>9th March, 2022</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>
|
||||||
|
9
libraries/jcb_powers/.htaccess
Normal file
9
libraries/jcb_powers/.htaccess
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Apache 2.4+
|
||||||
|
<IfModule mod_authz_core.c>
|
||||||
|
Require all denied
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
# Apache 2.0-2.2
|
||||||
|
<IfModule !mod_authz_core.c>
|
||||||
|
Deny from all
|
||||||
|
</IfModule>
|
1
libraries/jcb_powers/VDM.Joomla/index.html
Normal file
1
libraries/jcb_powers/VDM.Joomla/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<html><body bgcolor="#FFFFFF"></body></html>
|
346
libraries/jcb_powers/VDM.Joomla/src/Utilities.php
Normal file
346
libraries/jcb_powers/VDM.Joomla/src/Utilities.php
Normal file
@ -0,0 +1,346 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @gitea Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace VDM\Joomla;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Utilities\StringHelper;
|
||||||
|
use VDM\Joomla\Utilities\JsonHelper;
|
||||||
|
use VDM\Joomla\Utilities\ArrayHelper;
|
||||||
|
use VDM\Joomla\Utilities\ObjectHelper;
|
||||||
|
use VDM\Joomla\Utilities\MathHelper;
|
||||||
|
use VDM\Joomla\Utilities\GetHelper;
|
||||||
|
use VDM\Joomla\Utilities\String\FieldHelper;
|
||||||
|
use VDM\Joomla\Utilities\String\TypeHelper;
|
||||||
|
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
|
||||||
|
use VDM\Joomla\Utilities\String\NamespaceHelper;
|
||||||
|
use VDM\Joomla\Utilities\String\PluginHelper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic shared utilities, a legacy implementation
|
||||||
|
*/
|
||||||
|
trait Utilities
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The Main Active Language
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public static $langTag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if have a string with a length
|
||||||
|
*
|
||||||
|
* @input string $string The string to check
|
||||||
|
*
|
||||||
|
* @returns bool true on success
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Use StringHelper::check($string);
|
||||||
|
*/
|
||||||
|
public static function checkString($string): bool
|
||||||
|
{
|
||||||
|
return StringHelper::check($string);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shorten a string
|
||||||
|
*
|
||||||
|
* @input string $string That you would like to shorten
|
||||||
|
*
|
||||||
|
* @returns string on success
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Use StringHelper::shorten($string, $length, $addTip);
|
||||||
|
*/
|
||||||
|
public static function shorten($string, $length = 40, $addTip = true)
|
||||||
|
{
|
||||||
|
return StringHelper::shorten($string, $length, $addTip);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Making strings safe (various ways)
|
||||||
|
*
|
||||||
|
* @input string $string That you would like to make safe
|
||||||
|
*
|
||||||
|
* @returns string on success
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Use StringHelper::safe($string, $type, $spacer, $replaceNumbers, $keepOnlyCharacters);
|
||||||
|
*/
|
||||||
|
public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true)
|
||||||
|
{
|
||||||
|
return StringHelper::safe($string, $type, $spacer, $replaceNumbers, $keepOnlyCharacters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Making class or function name safe
|
||||||
|
*
|
||||||
|
* @input string The name you would like to make safe
|
||||||
|
*
|
||||||
|
* @returns string on success
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Use ClassfunctionHelper::safe($name);
|
||||||
|
*/
|
||||||
|
public static function safeClassFunctionName($name)
|
||||||
|
{
|
||||||
|
return ClassfunctionHelper::safe($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Making field names safe
|
||||||
|
*
|
||||||
|
* @input string The you would like to make safe
|
||||||
|
* @input boolean The switch to return an ALL UPPER CASE string
|
||||||
|
* @input string The string to use in white space
|
||||||
|
*
|
||||||
|
* @returns string on success
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Use FieldHelper::safe($string, $allcap, $spacer);
|
||||||
|
*/
|
||||||
|
public static function safeFieldName($string, $allcap = false, $spacer = '_')
|
||||||
|
{
|
||||||
|
return FieldHelper::safe($string, $allcap, $spacer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Making field type name safe
|
||||||
|
*
|
||||||
|
* @input string The you would like to make safe
|
||||||
|
*
|
||||||
|
* @returns string on success
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Use TypeHelper::safe($string);
|
||||||
|
*/
|
||||||
|
public static function safeTypeName($string)
|
||||||
|
{
|
||||||
|
return TypeHelper::safe($string);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Making namespace safe
|
||||||
|
*
|
||||||
|
* @input string The you would like to make safe
|
||||||
|
*
|
||||||
|
* @returns string on success
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Use NamespaceHelper::safe($string);
|
||||||
|
*/
|
||||||
|
public static function safeNamespace($string)
|
||||||
|
{
|
||||||
|
return NamespaceHelper::safe($string);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated 4.0 - Use StringHelper::transliterate($string);
|
||||||
|
*/
|
||||||
|
public static function transliterate($string)
|
||||||
|
{
|
||||||
|
return StringHelper::transliterate($string);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated 4.0 - Use StringHelper::html($var, $charset, $shorten, $length);
|
||||||
|
*/
|
||||||
|
public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40)
|
||||||
|
{
|
||||||
|
return StringHelper::html($var, $charset, $shorten, $length);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated 4.0 - Use StringHelper::numbers($string);
|
||||||
|
*/
|
||||||
|
public static function replaceNumbers($string)
|
||||||
|
{
|
||||||
|
return StringHelper::numbers($string);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an integer into an English word string
|
||||||
|
* Thanks to Tom Nicholson <http://php.net/manual/en/function.strval.php#41988>
|
||||||
|
*
|
||||||
|
* @input int $x an int
|
||||||
|
*
|
||||||
|
* @returns string a string
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Use StringHelper::number($x);
|
||||||
|
*/
|
||||||
|
public static function numberToString($x)
|
||||||
|
{
|
||||||
|
return StringHelper::number($x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Random Key
|
||||||
|
*
|
||||||
|
* @input int $size the length of the string
|
||||||
|
*
|
||||||
|
* @returns string a string of random characters
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Use StringHelper::random($size);
|
||||||
|
*/
|
||||||
|
public static function randomkey($size): string
|
||||||
|
{
|
||||||
|
return StringHelper::random($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if you have a json string
|
||||||
|
*
|
||||||
|
* @input string $string The json string to check
|
||||||
|
*
|
||||||
|
* @returns bool true on success
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Use JsonHelper::check($string);
|
||||||
|
*/
|
||||||
|
public static function checkJson($string): bool
|
||||||
|
{
|
||||||
|
return JsonHelper::check($string);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated 4.0 - Use JsonHelper::string($value, $sperator, $table, $id, $name);
|
||||||
|
*/
|
||||||
|
public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name')
|
||||||
|
{
|
||||||
|
return JsonHelper::string($value, $sperator, $table, $id, $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if you have an array with a length
|
||||||
|
*
|
||||||
|
* @input mixed $array The array to check
|
||||||
|
* @input bool $removeEmptyString Should we remove empty values
|
||||||
|
*
|
||||||
|
* @returns int number of items in array on success
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Use ArrayHelper::check($array, $removeEmptyString);
|
||||||
|
*/
|
||||||
|
public static function checkArray($array, $removeEmptyString = false): int
|
||||||
|
{
|
||||||
|
return ArrayHelper::check($array, $removeEmptyString);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merge an array of array's
|
||||||
|
*
|
||||||
|
* @input mixed $arrays The arrays you would like to merge
|
||||||
|
*
|
||||||
|
* @returns mixed array on success
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Use ArrayHelper::merge($arrays);
|
||||||
|
*/
|
||||||
|
public static function mergeArrays($arrays)
|
||||||
|
{
|
||||||
|
return ArrayHelper::merge($arrays);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if you have an object with a length
|
||||||
|
*
|
||||||
|
* @input object $object The object to check
|
||||||
|
*
|
||||||
|
* @returns bool true on success
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Use ObjectHelper::check($object);
|
||||||
|
*/
|
||||||
|
public static function checkObject($object): bool
|
||||||
|
{
|
||||||
|
return ObjectHelper::check($object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a Variable
|
||||||
|
*
|
||||||
|
* @param string $table The table from which to get the variable
|
||||||
|
* @param string $where The value where
|
||||||
|
* @param string $whereString The target/field string where/name
|
||||||
|
* @param string $what The return field
|
||||||
|
* @param string $operator The operator between $whereString/field and $where/value
|
||||||
|
* @param string $main The component in which the table is found
|
||||||
|
*
|
||||||
|
* @return mix string/int/float
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Use GetHelper::var($table, $where, $whereString, $what, $operator, $main);
|
||||||
|
*/
|
||||||
|
public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'componentbuilder')
|
||||||
|
{
|
||||||
|
return GetHelper::var($table, $where, $whereString, $what, $operator, $main);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get array of variables
|
||||||
|
*
|
||||||
|
* @param string $table The table from which to get the variables
|
||||||
|
* @param string $where The value where
|
||||||
|
* @param string $whereString The target/field string where/name
|
||||||
|
* @param string $what The return field
|
||||||
|
* @param string $operator The operator between $whereString/field and $where/value
|
||||||
|
* @param string $main The component in which the table is found
|
||||||
|
* @param bool $unique The switch to return a unique array
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Use GetHelper::vars($table, $where, $whereString, $what, $operator, $main, $unique);
|
||||||
|
*/
|
||||||
|
public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = 'componentbuilder', $unique = true)
|
||||||
|
{
|
||||||
|
return GetHelper::vars($table, $where, $whereString, $what, $operator, $main, $unique);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bc math wrapper (very basic not for accounting)
|
||||||
|
*
|
||||||
|
* @param string $type The type bc math
|
||||||
|
* @param int $val1 The first value
|
||||||
|
* @param int $val2 The second value
|
||||||
|
* @param int $scale The scale value
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Use MathHelper::bc($type, $val1, $val2, $scale);
|
||||||
|
*/
|
||||||
|
public static function bcmath($type, $val1, $val2, $scale = 0)
|
||||||
|
{
|
||||||
|
return MathHelper::bc($type, $val1, $val2, $scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic sum of an array with more precision
|
||||||
|
*
|
||||||
|
* @param array $array The values to sum
|
||||||
|
* @param int $scale The scale value
|
||||||
|
*
|
||||||
|
* @return float
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Use MathHelper::sum($array, $scale);
|
||||||
|
*/
|
||||||
|
public static function bcsum($array, $scale = 4)
|
||||||
|
{
|
||||||
|
return MathHelper::sum($array, $scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create plugin class name
|
||||||
|
*
|
||||||
|
* @input string The group name
|
||||||
|
* @input string The name
|
||||||
|
*
|
||||||
|
* @return float
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Use PluginHelper::safe($name, $group);
|
||||||
|
*/
|
||||||
|
public static function createPluginClassName($group, $name)
|
||||||
|
{
|
||||||
|
return PluginHelper::safeClassName($name, $group);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @gitea Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Utilities;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some array tricks helper
|
||||||
|
*/
|
||||||
|
abstract class ArrayHelper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Check if have an array with a length
|
||||||
|
*
|
||||||
|
* @input array The array to check
|
||||||
|
*
|
||||||
|
* @returns bool/int number of items in array on success
|
||||||
|
*/
|
||||||
|
public static function check($array, $removeEmptyString = false)
|
||||||
|
{
|
||||||
|
if (is_array($array) && ($nr = count((array)$array)) > 0)
|
||||||
|
{
|
||||||
|
// also make sure the empty strings are removed
|
||||||
|
if ($removeEmptyString)
|
||||||
|
{
|
||||||
|
foreach ($array as $key => $string)
|
||||||
|
{
|
||||||
|
if (empty($string))
|
||||||
|
{
|
||||||
|
unset($array[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return self::check($array, false);
|
||||||
|
}
|
||||||
|
return $nr;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merge an array of array's
|
||||||
|
*
|
||||||
|
* @input array The arrays you would like to merge
|
||||||
|
*
|
||||||
|
* @returns array on success
|
||||||
|
*/
|
||||||
|
public static function merge($arrays)
|
||||||
|
{
|
||||||
|
if(self::check($arrays))
|
||||||
|
{
|
||||||
|
$arrayBuket = array();
|
||||||
|
foreach ($arrays as $array)
|
||||||
|
{
|
||||||
|
if (self::check($array))
|
||||||
|
{
|
||||||
|
$arrayBuket = array_merge($arrayBuket, $array);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $arrayBuket;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
159
libraries/jcb_powers/VDM.Joomla/src/Utilities/GetHelper.php
Normal file
159
libraries/jcb_powers/VDM.Joomla/src/Utilities/GetHelper.php
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @gitea Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Utilities;
|
||||||
|
|
||||||
|
|
||||||
|
use Joomla\CMS\Factory;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some easy get...
|
||||||
|
*/
|
||||||
|
abstract class GetHelper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get a Variable
|
||||||
|
*
|
||||||
|
* @param string $table The table from which to get the variable
|
||||||
|
* @param string $where The value where
|
||||||
|
* @param string $whereString The target/field string where/name
|
||||||
|
* @param string $what The return field
|
||||||
|
* @param string $operator The operator between $whereString/field and $where/value
|
||||||
|
* @param string $main The component in which the table is found
|
||||||
|
*
|
||||||
|
* @return mix string/int/float
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function var($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'componentbuilder')
|
||||||
|
{
|
||||||
|
if(!$where)
|
||||||
|
{
|
||||||
|
$where = Factory::getUser()->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a db connection.
|
||||||
|
$db = Factory::getDbo();
|
||||||
|
|
||||||
|
// Create a new query object.
|
||||||
|
$query = $db->getQuery(true);
|
||||||
|
$query->select($db->quoteName(array($what)));
|
||||||
|
|
||||||
|
if (empty($table))
|
||||||
|
{
|
||||||
|
$query->from($db->quoteName('#__' . $main));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$query->from($db->quoteName('#__' . $main . '_' . $table));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_numeric($where))
|
||||||
|
{
|
||||||
|
$query->where($db->quoteName($whereString) . ' ' . $operator . ' ' . (int) $where);
|
||||||
|
}
|
||||||
|
elseif (is_string($where))
|
||||||
|
{
|
||||||
|
$query->where($db->quoteName($whereString) . ' ' . $operator . ' ' . $db->quote((string)$where));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->setQuery($query);
|
||||||
|
$db->execute();
|
||||||
|
|
||||||
|
if ($db->getNumRows())
|
||||||
|
{
|
||||||
|
return $db->loadResult();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get array of variables
|
||||||
|
*
|
||||||
|
* @param string $table The table from which to get the variables
|
||||||
|
* @param string $where The value where
|
||||||
|
* @param string $whereString The target/field string where/name
|
||||||
|
* @param string $what The return field
|
||||||
|
* @param string $operator The operator between $whereString/field and $where/value
|
||||||
|
* @param string $main The component in which the table is found
|
||||||
|
* @param bool $unique The switch to return a unique array
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function vars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = 'componentbuilder', $unique = true)
|
||||||
|
{
|
||||||
|
if(!$where)
|
||||||
|
{
|
||||||
|
$where = Factory::getUser()->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ArrayHelper::check($where) && $where > 0)
|
||||||
|
{
|
||||||
|
$where = array($where);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ArrayHelper::check($where))
|
||||||
|
{
|
||||||
|
// prep main <-- why? well if $main='' is empty then $table can be categories or users
|
||||||
|
if (StringHelper::check($main))
|
||||||
|
{
|
||||||
|
$main = '_' . ltrim($main, '_');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a db connection.
|
||||||
|
$db = Factory::getDbo();
|
||||||
|
|
||||||
|
// Create a new query object.
|
||||||
|
$query = $db->getQuery(true);
|
||||||
|
$query->select($db->quoteName(array($what)));
|
||||||
|
|
||||||
|
if (empty($table))
|
||||||
|
{
|
||||||
|
$query->from($db->quoteName('#__' . $main));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$query->from($db->quoteName('#_' . $main . '_' . $table));
|
||||||
|
}
|
||||||
|
|
||||||
|
// add strings to array search
|
||||||
|
if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator)
|
||||||
|
{
|
||||||
|
$query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$where) . '")');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',',$where) . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->setQuery($query);
|
||||||
|
$db->execute();
|
||||||
|
|
||||||
|
if ($db->getNumRows())
|
||||||
|
{
|
||||||
|
if ($unique)
|
||||||
|
{
|
||||||
|
return array_unique($db->loadColumn());
|
||||||
|
}
|
||||||
|
return $db->loadColumn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
89
libraries/jcb_powers/VDM.Joomla/src/Utilities/JsonHelper.php
Normal file
89
libraries/jcb_powers/VDM.Joomla/src/Utilities/JsonHelper.php
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @gitea Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Utilities;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The json checker
|
||||||
|
*/
|
||||||
|
abstract class JsonHelper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Check if you have a json string
|
||||||
|
*
|
||||||
|
* @input string $string The json string to check
|
||||||
|
*
|
||||||
|
* @returns bool true on success
|
||||||
|
*/
|
||||||
|
public static function check($string): bool
|
||||||
|
{
|
||||||
|
if (StringHelper::check($string))
|
||||||
|
{
|
||||||
|
json_decode($string);
|
||||||
|
return (json_last_error() === JSON_ERROR_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function string($value, $separator = ", ", $table = null, $id = 'id', $name = 'name')
|
||||||
|
{
|
||||||
|
// do some table foot work
|
||||||
|
$external = false;
|
||||||
|
if (strpos($table, '#__') !== false)
|
||||||
|
{
|
||||||
|
$external = true;
|
||||||
|
$table = str_replace('#__', '', $table);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if string is JSON
|
||||||
|
$result = json_decode($value, true);
|
||||||
|
if (json_last_error() === JSON_ERROR_NONE)
|
||||||
|
{
|
||||||
|
// is JSON
|
||||||
|
if (ArrayHelper::check($result))
|
||||||
|
{
|
||||||
|
if (StringHelper::check($table))
|
||||||
|
{
|
||||||
|
$names = array();
|
||||||
|
foreach ($result as $val)
|
||||||
|
{
|
||||||
|
if ($external)
|
||||||
|
{
|
||||||
|
if ($_name = GetHelper::var(null, $val, $id, $name, '=', $table))
|
||||||
|
{
|
||||||
|
$names[] = $_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($_name = GetHelper::var($table, $val, $id, $name))
|
||||||
|
{
|
||||||
|
$names[] = $_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ArrayHelper::check($names))
|
||||||
|
{
|
||||||
|
return (string) implode($separator, $names);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (string) implode($separator, $result);
|
||||||
|
}
|
||||||
|
return (string) json_decode($value);
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
100
libraries/jcb_powers/VDM.Joomla/src/Utilities/MathHelper.php
Normal file
100
libraries/jcb_powers/VDM.Joomla/src/Utilities/MathHelper.php
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @gitea Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Utilities;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic Math Helper
|
||||||
|
*/
|
||||||
|
abstract class MathHelper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* bc math wrapper (very basic not for accounting)
|
||||||
|
*
|
||||||
|
* @param string $type The type bc math
|
||||||
|
* @param int $val1 The first value
|
||||||
|
* @param int $val2 The second value
|
||||||
|
* @param int $scale The scale value
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function bc($type, $val1, $val2, $scale = 0)
|
||||||
|
{
|
||||||
|
// build function name
|
||||||
|
$function = 'bc' . $type;
|
||||||
|
// use the bcmath function if available
|
||||||
|
if (function_exists($function))
|
||||||
|
{
|
||||||
|
return $function($val1, $val2, $scale);
|
||||||
|
}
|
||||||
|
// if function does not exist we use +-*/ operators (fallback - not ideal)
|
||||||
|
switch ($type)
|
||||||
|
{
|
||||||
|
// Multiply two numbers
|
||||||
|
case 'mul':
|
||||||
|
return (string) round($val1 * $val2, $scale);
|
||||||
|
break;
|
||||||
|
// Divide of two numbers
|
||||||
|
case 'div':
|
||||||
|
return (string) round($val1 / $val2, $scale);
|
||||||
|
break;
|
||||||
|
// Adding two numbers
|
||||||
|
case 'add':
|
||||||
|
return (string) round($val1 + $val2, $scale);
|
||||||
|
break;
|
||||||
|
// Subtract one number from the other
|
||||||
|
case 'sub':
|
||||||
|
return (string) round($val1 - $val2, $scale);
|
||||||
|
break;
|
||||||
|
// Raise an arbitrary precision number to another
|
||||||
|
case 'pow':
|
||||||
|
return (string) round(pow($val1, $val2), $scale);
|
||||||
|
break;
|
||||||
|
// Compare two arbitrary precision numbers
|
||||||
|
case 'comp':
|
||||||
|
return (round($val1,2) == round($val2,2));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
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 sum($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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @gitea Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Utilities;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some object tricks
|
||||||
|
*/
|
||||||
|
abstract class ObjectHelper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Check if have an object with a length
|
||||||
|
*
|
||||||
|
* @input object The object to check
|
||||||
|
*
|
||||||
|
* @returns bool true on success
|
||||||
|
*/
|
||||||
|
public static function check($object)
|
||||||
|
{
|
||||||
|
if (is_object($object))
|
||||||
|
{
|
||||||
|
return count((array) $object) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @gitea Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Utilities\String;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Utilities\StringHelper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Control the naming of a class and function
|
||||||
|
*/
|
||||||
|
abstract class ClassfunctionHelper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Making class or function name safe
|
||||||
|
*
|
||||||
|
* @input string The name you would like to make safe
|
||||||
|
*
|
||||||
|
* @returns string on success
|
||||||
|
**/
|
||||||
|
public static function safe($name)
|
||||||
|
{
|
||||||
|
// remove numbers if the first character is a number
|
||||||
|
if (is_numeric(substr($name, 0, 1)))
|
||||||
|
{
|
||||||
|
$name = StringHelper::numbers($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove all spaces and strange characters
|
||||||
|
return trim(preg_replace("/[^A-Za-z0-9_-]/", '', $name));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @gitea Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Utilities\String;
|
||||||
|
|
||||||
|
|
||||||
|
use Joomla\CMS\Component\ComponentHelper;
|
||||||
|
use VDM\Joomla\Utilities\StringHelper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Control the naming of a field
|
||||||
|
*/
|
||||||
|
abstract class FieldHelper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The field builder switch
|
||||||
|
**/
|
||||||
|
protected static $builder = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Making field names safe
|
||||||
|
*
|
||||||
|
* @input string The string you would like to make safe
|
||||||
|
* @input boolean The switch to return an ALL UPPER CASE string
|
||||||
|
* @input string The string to use in white space
|
||||||
|
*
|
||||||
|
* @returns string on success
|
||||||
|
**/
|
||||||
|
public static function safe($string, $allcap = false, $spacer = '_')
|
||||||
|
{
|
||||||
|
// get global value
|
||||||
|
if (self::$builder === false)
|
||||||
|
{
|
||||||
|
self::$builder = ComponentHelper::getParams('com_componentbuilder')->get('field_name_builder', 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// use the new convention
|
||||||
|
if (2 == self::$builder)
|
||||||
|
{
|
||||||
|
// 0nly continue if we have a string
|
||||||
|
if (StringHelper::check($string))
|
||||||
|
{
|
||||||
|
// check that the first character is not a number
|
||||||
|
if (is_numeric(substr($string, 0, 1)))
|
||||||
|
{
|
||||||
|
$string = StringHelper::numbers($string);
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove all other strange characters
|
||||||
|
$string = trim($string);
|
||||||
|
$string = preg_replace('/'.$spacer.'+/', ' ', $string);
|
||||||
|
$string = preg_replace('/\s+/', ' ', $string);
|
||||||
|
|
||||||
|
// Transliterate string
|
||||||
|
$string = StringHelper::transliterate($string);
|
||||||
|
|
||||||
|
// remove all and keep only characters and numbers
|
||||||
|
$string = preg_replace("/[^A-Za-z0-9 ]/", '', $string);
|
||||||
|
|
||||||
|
// replace white space with underscore (SAFEST OPTION)
|
||||||
|
$string = preg_replace('/\s+/', $spacer, $string);
|
||||||
|
|
||||||
|
// return all caps
|
||||||
|
if ($allcap)
|
||||||
|
{
|
||||||
|
return strtoupper($string);
|
||||||
|
}
|
||||||
|
|
||||||
|
// default is to return lower
|
||||||
|
return strtolower($string);
|
||||||
|
}
|
||||||
|
// not a string
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// return all caps
|
||||||
|
if ($allcap)
|
||||||
|
{
|
||||||
|
return StringHelper::safe($string, 'U');
|
||||||
|
}
|
||||||
|
|
||||||
|
// use the default (original behavior/convention)
|
||||||
|
return StringHelper::safe($string);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @gitea Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Utilities\String;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Utilities\StringHelper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Control the naming of a namespace helper
|
||||||
|
*/
|
||||||
|
abstract class NamespaceHelper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Making namespace safe
|
||||||
|
*
|
||||||
|
* @input string The you would like to make safe
|
||||||
|
*
|
||||||
|
* @returns string on success
|
||||||
|
**/
|
||||||
|
public static function safe($string)
|
||||||
|
{
|
||||||
|
// 0nly continue if we have a string
|
||||||
|
if (StringHelper::check($string))
|
||||||
|
{
|
||||||
|
// make sure it has not numbers
|
||||||
|
$string = StringHelper::numbers($string);
|
||||||
|
|
||||||
|
// Transliterate string TODO: look again as this make it lowercase
|
||||||
|
// $string = StringHelper::transliterate($string);
|
||||||
|
|
||||||
|
// first remove all [\] backslashes
|
||||||
|
$string = str_replace('\\', '1', $string);
|
||||||
|
|
||||||
|
// remove all and keep only characters and [\] backslashes inside of the string
|
||||||
|
$string = trim(preg_replace("/[^A-Za-z1]/", '', $string), '1');
|
||||||
|
|
||||||
|
// place the [\] backslashes back
|
||||||
|
return trim(preg_replace("/1+/", '\\', $string));
|
||||||
|
}
|
||||||
|
// not a string
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,106 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @gitea Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Utilities\String;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Control the naming of a plugin
|
||||||
|
*/
|
||||||
|
abstract class PluginHelper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Making plugin folder name safe
|
||||||
|
*
|
||||||
|
* @input string $codeName The name
|
||||||
|
* @input string $group The group name
|
||||||
|
*
|
||||||
|
* @returns string on success
|
||||||
|
*/
|
||||||
|
public static function safeFolderName($codeName, $group)
|
||||||
|
{
|
||||||
|
// editors-xtd group plugins must have a class with plgButton<PluginName> structure
|
||||||
|
if ($group === 'editors-xtd')
|
||||||
|
{
|
||||||
|
$group = 'Button';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'plg_' . strtolower($group) . '_' . strtolower(
|
||||||
|
$codeName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Making plugin class name safe
|
||||||
|
*
|
||||||
|
* @input string $codeName The name
|
||||||
|
* @input string $group The group name
|
||||||
|
*
|
||||||
|
* @returns string on success
|
||||||
|
*/
|
||||||
|
public static function safeClassName($codeName, $group)
|
||||||
|
{
|
||||||
|
// editors-xtd group plugins must have a class with plgButton<PluginName> structure
|
||||||
|
if ($group === 'editors-xtd')
|
||||||
|
{
|
||||||
|
$group = 'Button';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'Plg' . ucfirst($group) . ucfirst(
|
||||||
|
$codeName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Making plugin install class name safe
|
||||||
|
*
|
||||||
|
* @input string $codeName The name
|
||||||
|
* @input string $group The group name
|
||||||
|
*
|
||||||
|
* @returns string on success
|
||||||
|
*/
|
||||||
|
public static function safeInstallClassName($codeName, $group)
|
||||||
|
{
|
||||||
|
// editors-xtd group plugins must have a class with plgButton<PluginName> structure
|
||||||
|
if ($group === 'editors-xtd')
|
||||||
|
{
|
||||||
|
$group = 'Button';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'plg' . ucfirst($group) . ucfirst(
|
||||||
|
$codeName
|
||||||
|
) . 'InstallerScript';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Making language prefix safe
|
||||||
|
*
|
||||||
|
* @input string $codeName The name
|
||||||
|
* @input string $group The group name
|
||||||
|
*
|
||||||
|
* @returns string on success
|
||||||
|
*/
|
||||||
|
public static function safeLangPrefix($codeName, $group)
|
||||||
|
{
|
||||||
|
// editors-xtd group plugins must have a class with plgButton<PluginName> structure
|
||||||
|
if ($group === 'editors-xtd')
|
||||||
|
{
|
||||||
|
$group = 'Button';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'PLG_' . strtoupper($group) . strtoupper(
|
||||||
|
$codeName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @gitea Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Utilities\String;
|
||||||
|
|
||||||
|
|
||||||
|
use Joomla\CMS\Component\ComponentHelper;
|
||||||
|
use VDM\Joomla\Utilities\StringHelper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Control the naming of a field type
|
||||||
|
*/
|
||||||
|
abstract class TypeHelper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The field builder switch
|
||||||
|
**/
|
||||||
|
protected static $builder = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Making field type name safe
|
||||||
|
*
|
||||||
|
* @input string The you would like to make safe
|
||||||
|
*
|
||||||
|
* @returns string on success
|
||||||
|
**/
|
||||||
|
public static function safe($string)
|
||||||
|
{
|
||||||
|
// get global value
|
||||||
|
if (self::$builder === false)
|
||||||
|
{
|
||||||
|
self::$builder = ComponentHelper::getParams('com_componentbuilder')->get('type_name_builder', 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// use the new convention
|
||||||
|
if (2 == self::$builder)
|
||||||
|
{
|
||||||
|
// 0nly continue if we have a string
|
||||||
|
if (StringHelper::check($string))
|
||||||
|
{
|
||||||
|
// check that the first character is not a number
|
||||||
|
if (is_numeric(substr($string, 0, 1)))
|
||||||
|
{
|
||||||
|
$string = StringHelper::numbers($string);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transliterate string
|
||||||
|
$string = StringHelper::transliterate($string);
|
||||||
|
|
||||||
|
// remove all and keep only characters and numbers and point (TODO just one point)
|
||||||
|
$string = trim(preg_replace("/[^A-Za-z0-9\.]/", '', $string));
|
||||||
|
|
||||||
|
// best is to return lower (for all string equality in compiler)
|
||||||
|
return strtolower($string);
|
||||||
|
}
|
||||||
|
// not a string
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// use the default (original behaviour/convention)
|
||||||
|
return StringHelper::safe($string);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
<html><body bgcolor="#FFFFFF"></body></html>
|
379
libraries/jcb_powers/VDM.Joomla/src/Utilities/StringHelper.php
Normal file
379
libraries/jcb_powers/VDM.Joomla/src/Utilities/StringHelper.php
Normal file
@ -0,0 +1,379 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @gitea Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Utilities;
|
||||||
|
|
||||||
|
|
||||||
|
use Joomla\CMS\Filter\InputFilter;
|
||||||
|
use Joomla\CMS\Language\Language;
|
||||||
|
use Joomla\CMS\Component\ComponentHelper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some string tricks
|
||||||
|
*/
|
||||||
|
abstract class StringHelper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The Main Active Language
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public static $langTag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if we have a string with a length
|
||||||
|
*
|
||||||
|
* @input string $string The string to check
|
||||||
|
*
|
||||||
|
* @returns bool true on success
|
||||||
|
*/
|
||||||
|
public static function check($string): bool
|
||||||
|
{
|
||||||
|
if (is_string($string) && strlen($string) > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shorten a string
|
||||||
|
*
|
||||||
|
* @input string The you would like to shorten
|
||||||
|
*
|
||||||
|
* @returns string on success
|
||||||
|
*/
|
||||||
|
public static function shorten($string, $length = 40, $addTip = true)
|
||||||
|
{
|
||||||
|
if (self::check($string))
|
||||||
|
{
|
||||||
|
$initial = strlen($string);
|
||||||
|
$words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE);
|
||||||
|
$words_count = count((array)$words);
|
||||||
|
|
||||||
|
$word_length = 0;
|
||||||
|
$last_word = 0;
|
||||||
|
for (; $last_word < $words_count; ++$last_word)
|
||||||
|
{
|
||||||
|
$word_length += strlen($words[$last_word]);
|
||||||
|
if ($word_length > $length)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$newString = implode(array_slice($words, 0, $last_word));
|
||||||
|
$final = strlen($newString);
|
||||||
|
if ($initial != $final && $addTip)
|
||||||
|
{
|
||||||
|
$title = self::shorten($string, 400 , false);
|
||||||
|
return '<span class="hasTip" title="' . $title . '" style="cursor:help">' . trim($newString) . '...</span>';
|
||||||
|
}
|
||||||
|
elseif ($initial != $final && !$addTip)
|
||||||
|
{
|
||||||
|
return trim($newString) . '...';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Making strings safe (various ways)
|
||||||
|
*
|
||||||
|
* @input string The you would like to make safe
|
||||||
|
*
|
||||||
|
* @returns string on success
|
||||||
|
*/
|
||||||
|
public static function safe($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true)
|
||||||
|
{
|
||||||
|
if ($replaceNumbers === true)
|
||||||
|
{
|
||||||
|
// remove all numbers and replace with english text version (works well only up to millions)
|
||||||
|
$string = self::numbers($string);
|
||||||
|
}
|
||||||
|
// 0nly continue if we have a string
|
||||||
|
if (self::check($string))
|
||||||
|
{
|
||||||
|
// create file name without the extension that is safe
|
||||||
|
if ($type === 'filename')
|
||||||
|
{
|
||||||
|
// make sure VDM is not in the string
|
||||||
|
$string = str_replace('VDM', 'vDm', $string);
|
||||||
|
// Remove anything which isn't a word, whitespace, number
|
||||||
|
// or any of the following caracters -_()
|
||||||
|
// If you don't need to handle multi-byte characters
|
||||||
|
// you can use preg_replace rather than mb_ereg_replace
|
||||||
|
// Thanks @Łukasz Rysiak!
|
||||||
|
// $string = mb_ereg_replace("([^\w\s\d\-_\(\)])", '', $string);
|
||||||
|
$string = preg_replace("([^\w\s\d\-_\(\)])", '', $string);
|
||||||
|
|
||||||
|
// http://stackoverflow.com/a/2021729/1429677
|
||||||
|
return preg_replace('/\s+/', ' ', $string);
|
||||||
|
}
|
||||||
|
// remove all other characters
|
||||||
|
$string = trim($string);
|
||||||
|
$string = preg_replace('/'.$spacer.'+/', ' ', $string);
|
||||||
|
$string = preg_replace('/\s+/', ' ', $string);
|
||||||
|
// Transliterate string
|
||||||
|
$string = self::transliterate($string);
|
||||||
|
// remove all and keep only characters
|
||||||
|
if ($keepOnlyCharacters)
|
||||||
|
{
|
||||||
|
$string = preg_replace("/[^A-Za-z ]/", '', $string);
|
||||||
|
}
|
||||||
|
// keep both numbers and characters
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$string = preg_replace("/[^A-Za-z0-9 ]/", '', $string);
|
||||||
|
}
|
||||||
|
// select final adaptations
|
||||||
|
if ($type === 'L' || $type === 'strtolower')
|
||||||
|
{
|
||||||
|
// replace white space with underscore
|
||||||
|
$string = preg_replace('/\s+/', $spacer, $string);
|
||||||
|
// default is to return lower
|
||||||
|
return strtolower($string);
|
||||||
|
}
|
||||||
|
elseif ($type === 'W')
|
||||||
|
{
|
||||||
|
// return a string with all first letter of each word uppercase(no underscore)
|
||||||
|
return ucwords(strtolower($string));
|
||||||
|
}
|
||||||
|
elseif ($type === 'w' || $type === 'word')
|
||||||
|
{
|
||||||
|
// return a string with all lowercase(no underscore)
|
||||||
|
return strtolower($string);
|
||||||
|
}
|
||||||
|
elseif ($type === 'Ww' || $type === 'Word')
|
||||||
|
{
|
||||||
|
// return a string with first letter of the first word uppercase and all the rest lowercase(no underscore)
|
||||||
|
return ucfirst(strtolower($string));
|
||||||
|
}
|
||||||
|
elseif ($type === 'WW' || $type === 'WORD')
|
||||||
|
{
|
||||||
|
// return a string with all the uppercase(no underscore)
|
||||||
|
return strtoupper($string);
|
||||||
|
}
|
||||||
|
elseif ($type === 'U' || $type === 'strtoupper')
|
||||||
|
{
|
||||||
|
// replace white space with underscore
|
||||||
|
$string = preg_replace('/\s+/', $spacer, $string);
|
||||||
|
// return all upper
|
||||||
|
return strtoupper($string);
|
||||||
|
}
|
||||||
|
elseif ($type === 'F' || $type === 'ucfirst')
|
||||||
|
{
|
||||||
|
// replace white space with underscore
|
||||||
|
$string = preg_replace('/\s+/', $spacer, $string);
|
||||||
|
// return with first character to upper
|
||||||
|
return ucfirst(strtolower($string));
|
||||||
|
}
|
||||||
|
elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase')
|
||||||
|
{
|
||||||
|
// convert all words to first letter uppercase
|
||||||
|
$string = ucwords(strtolower($string));
|
||||||
|
// remove white space
|
||||||
|
$string = preg_replace('/\s+/', '', $string);
|
||||||
|
// now return first letter lowercase
|
||||||
|
return lcfirst($string);
|
||||||
|
}
|
||||||
|
// return string
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
// not a string
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function transliterate($string)
|
||||||
|
{
|
||||||
|
// set tag only once
|
||||||
|
if (!self::check(self::$langTag))
|
||||||
|
{
|
||||||
|
// get global value
|
||||||
|
self::$langTag = ComponentHelper::getParams('com_componentbuilder')->get('language', 'en-GB');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transliterate on the language requested
|
||||||
|
$lang = Language::getInstance(self::$langTag);
|
||||||
|
|
||||||
|
return $lang->transliterate($string);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function html($var, $charset = 'UTF-8', $shorten = false, $length = 40)
|
||||||
|
{
|
||||||
|
if (self::check($var))
|
||||||
|
{
|
||||||
|
$filter = new InputFilter();
|
||||||
|
$string = $filter->clean(
|
||||||
|
html_entity_decode(
|
||||||
|
htmlentities(
|
||||||
|
$var,
|
||||||
|
ENT_COMPAT,
|
||||||
|
$charset
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'HTML'
|
||||||
|
);
|
||||||
|
if ($shorten)
|
||||||
|
{
|
||||||
|
return self::shorten($string, $length);
|
||||||
|
}
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function numbers($string)
|
||||||
|
{
|
||||||
|
// set numbers array
|
||||||
|
$numbers = array();
|
||||||
|
|
||||||
|
// first get all numbers
|
||||||
|
preg_match_all('!\d+!', $string, $numbers);
|
||||||
|
|
||||||
|
// check if we have any numbers
|
||||||
|
if (isset($numbers[0]) && ArrayHelper::check($numbers[0]))
|
||||||
|
{
|
||||||
|
foreach ($numbers[0] as $number)
|
||||||
|
{
|
||||||
|
$searchReplace[$number] = self::number((int)$number);
|
||||||
|
}
|
||||||
|
|
||||||
|
// now replace numbers in string
|
||||||
|
$string = str_replace(array_keys($searchReplace), array_values($searchReplace), $string);
|
||||||
|
|
||||||
|
// check if we missed any, strange if we did.
|
||||||
|
return self::numbers($string);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the string with no numbers remaining.
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an integer into an English word string
|
||||||
|
* Thanks to Tom Nicholson <http://php.net/manual/en/function.strval.php#41988>
|
||||||
|
*
|
||||||
|
* @input an int
|
||||||
|
* @returns a string
|
||||||
|
*/
|
||||||
|
public static function number($x)
|
||||||
|
{
|
||||||
|
$nwords = array( "zero", "one", "two", "three", "four", "five", "six", "seven",
|
||||||
|
"eight", "nine", "ten", "eleven", "twelve", "thirteen",
|
||||||
|
"fourteen", "fifteen", "sixteen", "seventeen", "eighteen",
|
||||||
|
"nineteen", "twenty", 30 => "thirty", 40 => "forty",
|
||||||
|
50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty",
|
||||||
|
90 => "ninety" );
|
||||||
|
|
||||||
|
if(!is_numeric($x))
|
||||||
|
{
|
||||||
|
$w = $x;
|
||||||
|
}
|
||||||
|
elseif(fmod($x, 1) != 0)
|
||||||
|
{
|
||||||
|
$w = $x;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if($x < 0)
|
||||||
|
{
|
||||||
|
$w = 'minus ';
|
||||||
|
$x = -$x;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$w = '';
|
||||||
|
// ... now $x is a non-negative integer.
|
||||||
|
}
|
||||||
|
|
||||||
|
if($x < 21) // 0 to 20
|
||||||
|
{
|
||||||
|
$w .= $nwords[$x];
|
||||||
|
}
|
||||||
|
elseif($x < 100) // 21 to 99
|
||||||
|
{
|
||||||
|
$w .= $nwords[10 * floor($x/10)];
|
||||||
|
$r = fmod($x, 10);
|
||||||
|
if($r > 0)
|
||||||
|
{
|
||||||
|
$w .= ' ' . $nwords[$r];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif($x < 1000) // 100 to 999
|
||||||
|
{
|
||||||
|
$w .= $nwords[floor($x/100)] .' hundred';
|
||||||
|
$r = fmod($x, 100);
|
||||||
|
if($r > 0)
|
||||||
|
{
|
||||||
|
$w .= ' and '. self::number($r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif($x < 1000000) // 1000 to 999999
|
||||||
|
{
|
||||||
|
$w .= self::number(floor($x/1000)) .' thousand';
|
||||||
|
$r = fmod($x, 1000);
|
||||||
|
if($r > 0)
|
||||||
|
{
|
||||||
|
$w .= ' ';
|
||||||
|
if($r < 100)
|
||||||
|
{
|
||||||
|
$w .= 'and ';
|
||||||
|
}
|
||||||
|
$w .= self::number($r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // millions
|
||||||
|
{
|
||||||
|
$w .= self::number(floor($x/1000000)) .' million';
|
||||||
|
$r = fmod($x, 1000000);
|
||||||
|
if($r > 0)
|
||||||
|
{
|
||||||
|
$w .= ' ';
|
||||||
|
if($r < 100)
|
||||||
|
{
|
||||||
|
$w .= 'and ';
|
||||||
|
}
|
||||||
|
$w .= self::number($r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $w;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Random Key
|
||||||
|
*
|
||||||
|
* @returns a string
|
||||||
|
*/
|
||||||
|
public static function random($size)
|
||||||
|
{
|
||||||
|
$bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
|
||||||
|
$key = array();
|
||||||
|
$bagsize = strlen($bag) - 1;
|
||||||
|
|
||||||
|
for ($i = 0; $i < $size; $i++)
|
||||||
|
{
|
||||||
|
$get = rand(0, $bagsize);
|
||||||
|
$key[] = $bag[$get];
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
1
libraries/jcb_powers/VDM.Joomla/src/Utilities/index.html
Normal file
1
libraries/jcb_powers/VDM.Joomla/src/Utilities/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<html><body bgcolor="#FFFFFF"></body></html>
|
9
libraries/jcb_powers/htaccess.txt
Normal file
9
libraries/jcb_powers/htaccess.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Apache 2.4+
|
||||||
|
<IfModule mod_authz_core.c>
|
||||||
|
Require all denied
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
# Apache 2.0-2.2
|
||||||
|
<IfModule !mod_authz_core.c>
|
||||||
|
Deny from all
|
||||||
|
</IfModule>
|
1
libraries/jcb_powers/index.html
Normal file
1
libraries/jcb_powers/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<html><body bgcolor="#FFFFFF"></body></html>
|
7
libraries/jcb_powers/web.config
Normal file
7
libraries/jcb_powers/web.config
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<system.web>
|
||||||
|
<authorization>
|
||||||
|
<deny users="*" />
|
||||||
|
</authorization>
|
||||||
|
</system.web>
|
||||||
|
</configuration>
|
@ -13,6 +13,50 @@
|
|||||||
// No direct access to this file
|
// No direct access to this file
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
|
||||||
|
// register this component namespace
|
||||||
|
spl_autoload_register(function ($class) {
|
||||||
|
// project-specific base directories and namespace prefix
|
||||||
|
$search = array(
|
||||||
|
'libraries/jcb_powers/VDM.Joomla' => 'VDM\\Joomla'
|
||||||
|
);
|
||||||
|
// Start the search and load if found
|
||||||
|
$found = false;
|
||||||
|
$found_base_dir = "";
|
||||||
|
$found_len = 0;
|
||||||
|
foreach ($search as $base_dir => $prefix)
|
||||||
|
{
|
||||||
|
// does the class use the namespace prefix?
|
||||||
|
$len = strlen($prefix);
|
||||||
|
if (strncmp($prefix, $class, $len) === 0)
|
||||||
|
{
|
||||||
|
// we have a match so load the values
|
||||||
|
$found = true;
|
||||||
|
$found_base_dir = $base_dir;
|
||||||
|
$found_len = $len;
|
||||||
|
// done here
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check if we found a match
|
||||||
|
if (!$found)
|
||||||
|
{
|
||||||
|
// no, move to the next registered autoloader
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// get the relative class name
|
||||||
|
$relative_class = substr($class, $found_len);
|
||||||
|
// replace the namespace prefix with the base directory, replace namespace
|
||||||
|
// separators with directory separators in the relative class name, append
|
||||||
|
// with .php
|
||||||
|
$file = JPATH_ROOT . '/' . $found_base_dir . '/src' . str_replace('\\', '/', $relative_class) . '.php';
|
||||||
|
// if the file exists, require it
|
||||||
|
if (file_exists($file))
|
||||||
|
{
|
||||||
|
require $file;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
use Joomla\CMS\Language\Language;
|
use Joomla\CMS\Language\Language;
|
||||||
use Joomla\Registry\Registry;
|
use Joomla\Registry\Registry;
|
||||||
use Joomla\String\StringHelper;
|
use Joomla\String\StringHelper;
|
||||||
@ -21,12 +65,20 @@ use Joomla\Archive\Archive;
|
|||||||
use Joomla\CMS\Filesystem\File;
|
use Joomla\CMS\Filesystem\File;
|
||||||
use Joomla\CMS\Filesystem\Folder;
|
use Joomla\CMS\Filesystem\Folder;
|
||||||
use Joomla\CMS\Filesystem\Path;
|
use Joomla\CMS\Filesystem\Path;
|
||||||
|
use VDM\Joomla\Utilities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Componentbuilder component helper
|
* Componentbuilder component helper
|
||||||
*/
|
*/
|
||||||
abstract class ComponentbuilderHelper
|
abstract class ComponentbuilderHelper
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Adding the utilities trait to this class
|
||||||
|
*
|
||||||
|
* @deprecated 4.0 - Check the trait methods for details, a legacy implementation
|
||||||
|
*/
|
||||||
|
use Utilities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Composer Switch
|
* Composer Switch
|
||||||
*
|
*
|
||||||
@ -34,13 +86,6 @@ abstract class ComponentbuilderHelper
|
|||||||
*/
|
*/
|
||||||
protected static $composer = array();
|
protected static $composer = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* The Main Active Language
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public static $langTag;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Global Site Event Method.
|
* The Global Site Event Method.
|
||||||
**/
|
**/
|
||||||
@ -662,157 +707,6 @@ abstract class ComponentbuilderHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Making class or function name safe
|
|
||||||
*
|
|
||||||
* @input string The name you would like to make safe
|
|
||||||
*
|
|
||||||
* @returns string on success
|
|
||||||
**/
|
|
||||||
public static function safeClassFunctionName($name)
|
|
||||||
{
|
|
||||||
// remove numbers if the first character is a number
|
|
||||||
if (is_numeric(substr($name, 0, 1)))
|
|
||||||
{
|
|
||||||
$name = self::replaceNumbers($name);
|
|
||||||
}
|
|
||||||
// remove all spaces and strange characters
|
|
||||||
return trim(preg_replace("/[^A-Za-z0-9_-]/", '', $name));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The field builder switch
|
|
||||||
**/
|
|
||||||
protected static $fieldNameBuilder = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Making field names safe
|
|
||||||
*
|
|
||||||
* @input string The you would like to make safe
|
|
||||||
* @input boolean The switch to return an ALL UPPER CASE string
|
|
||||||
* @input string The string to use in white space
|
|
||||||
*
|
|
||||||
* @returns string on success
|
|
||||||
**/
|
|
||||||
public static function safeFieldName($string, $allcap = false, $spacer = '_')
|
|
||||||
{
|
|
||||||
// get global value
|
|
||||||
if (self::$fieldNameBuilder === false)
|
|
||||||
{
|
|
||||||
self::$fieldNameBuilder = JComponentHelper::getParams('com_componentbuilder')->get('field_name_builder', 1);
|
|
||||||
}
|
|
||||||
// use the new convention
|
|
||||||
if (2 == self::$fieldNameBuilder)
|
|
||||||
{
|
|
||||||
// 0nly continue if we have a string
|
|
||||||
if (self::checkString($string))
|
|
||||||
{
|
|
||||||
// check that the first character is not a number
|
|
||||||
if (is_numeric(substr($string, 0, 1)))
|
|
||||||
{
|
|
||||||
$string = self::replaceNumbers($string);
|
|
||||||
}
|
|
||||||
// remove all other strange characters
|
|
||||||
$string = trim($string);
|
|
||||||
$string = preg_replace('/'.$spacer.'+/', ' ', $string);
|
|
||||||
$string = preg_replace('/\s+/', ' ', $string);
|
|
||||||
// Transliterate string
|
|
||||||
$string = self::transliterate($string);
|
|
||||||
// remove all and keep only characters and numbers
|
|
||||||
$string = preg_replace("/[^A-Za-z0-9 ]/", '', $string);
|
|
||||||
// replace white space with underscore (SAFEST OPTION)
|
|
||||||
$string = preg_replace('/\s+/', $spacer, $string);
|
|
||||||
// return all caps
|
|
||||||
if ($allcap)
|
|
||||||
{
|
|
||||||
return strtoupper($string);
|
|
||||||
}
|
|
||||||
// default is to return lower
|
|
||||||
return strtolower($string);
|
|
||||||
}
|
|
||||||
// not a string
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
// return all caps
|
|
||||||
if ($allcap)
|
|
||||||
{
|
|
||||||
return self::safeString($string, 'U');
|
|
||||||
}
|
|
||||||
// use the default (original behaviour/convention)
|
|
||||||
return self::safeString($string);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The type builder switch
|
|
||||||
**/
|
|
||||||
protected static $typeNameBuilder = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Making field type name safe
|
|
||||||
*
|
|
||||||
* @input string The you would like to make safe
|
|
||||||
*
|
|
||||||
* @returns string on success
|
|
||||||
**/
|
|
||||||
public static function safeTypeName($string)
|
|
||||||
{
|
|
||||||
// get global value
|
|
||||||
if (self::$typeNameBuilder === false)
|
|
||||||
{
|
|
||||||
self::$typeNameBuilder = JComponentHelper::getParams('com_componentbuilder')->get('type_name_builder', 1);
|
|
||||||
}
|
|
||||||
// use the new convention
|
|
||||||
if (2 == self::$typeNameBuilder)
|
|
||||||
{
|
|
||||||
// 0nly continue if we have a string
|
|
||||||
if (self::checkString($string))
|
|
||||||
{
|
|
||||||
// check that the first character is not a number
|
|
||||||
if (is_numeric(substr($string, 0, 1)))
|
|
||||||
{
|
|
||||||
$string = self::replaceNumbers($string);
|
|
||||||
}
|
|
||||||
// Transliterate string
|
|
||||||
$string = self::transliterate($string);
|
|
||||||
// remove all and keep only characters and numbers and point (TODO just one point)
|
|
||||||
$string = trim(preg_replace("/[^A-Za-z0-9\.]/", '', $string));
|
|
||||||
// best is to return lower (for all string equality in compiler)
|
|
||||||
return strtolower($string);
|
|
||||||
}
|
|
||||||
// not a string
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
// use the default (original behaviour/convention)
|
|
||||||
return self::safeString($string);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Making namespace safe
|
|
||||||
*
|
|
||||||
* @input string The you would like to make safe
|
|
||||||
*
|
|
||||||
* @returns string on success
|
|
||||||
**/
|
|
||||||
public static function safeNamespace($string)
|
|
||||||
{
|
|
||||||
// 0nly continue if we have a string
|
|
||||||
if (self::checkString($string))
|
|
||||||
{
|
|
||||||
// make sure it has not numbers
|
|
||||||
$string = self::replaceNumbers($string);
|
|
||||||
// Transliterate string TODO: look again as this make it lowercase
|
|
||||||
// $string = self::transliterate($string);
|
|
||||||
// first remove all [\] backslashes
|
|
||||||
$string = str_replace('\\', '1', $string);
|
|
||||||
// remove all and keep only characters and [\] backslashes inside of the string
|
|
||||||
$string = trim(preg_replace("/[^A-Za-z1]/", '', $string), '1');
|
|
||||||
// place the [\] backslashes back
|
|
||||||
return trim(preg_replace("/1+/", '\\', $string));
|
|
||||||
}
|
|
||||||
// not a string
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the Array of Existing Validation Rule Names
|
* Get the Array of Existing Validation Rule Names
|
||||||
*
|
*
|
||||||
@ -4914,85 +4808,6 @@ abstract class ComponentbuilderHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* bc math wrapper (very basic not for accounting)
|
|
||||||
*
|
|
||||||
* @param string $type The type bc math
|
|
||||||
* @param int $val1 The first value
|
|
||||||
* @param int $val2 The second value
|
|
||||||
* @param int $scale The scale value
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static function bcmath($type, $val1, $val2, $scale = 0)
|
|
||||||
{
|
|
||||||
// build function name
|
|
||||||
$function = 'bc' . $type;
|
|
||||||
// use the bcmath function if available
|
|
||||||
if (function_exists($function))
|
|
||||||
{
|
|
||||||
return $function($val1, $val2, $scale);
|
|
||||||
}
|
|
||||||
// if function does not exist we use +-*/ operators (fallback - not ideal)
|
|
||||||
switch ($type)
|
|
||||||
{
|
|
||||||
// Multiply two numbers
|
|
||||||
case 'mul':
|
|
||||||
return (string) round($val1 * $val2, $scale);
|
|
||||||
break;
|
|
||||||
// Divide of two numbers
|
|
||||||
case 'div':
|
|
||||||
return (string) round($val1 / $val2, $scale);
|
|
||||||
break;
|
|
||||||
// Adding two numbers
|
|
||||||
case 'add':
|
|
||||||
return (string) round($val1 + $val2, $scale);
|
|
||||||
break;
|
|
||||||
// Subtract one number from the other
|
|
||||||
case 'sub':
|
|
||||||
return (string) round($val1 - $val2, $scale);
|
|
||||||
break;
|
|
||||||
// Raise an arbitrary precision number to another
|
|
||||||
case 'pow':
|
|
||||||
return (string) round(pow($val1, $val2), $scale);
|
|
||||||
break;
|
|
||||||
// Compare two arbitrary precision numbers
|
|
||||||
case 'comp':
|
|
||||||
return (round($val1,2) == round($val2,2));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
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
|
||||||
*
|
*
|
||||||
@ -6872,57 +6687,6 @@ abstract class ComponentbuilderHelper
|
|||||||
return self::$composer[$target];
|
return self::$composer[$target];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert it into a string
|
|
||||||
*/
|
|
||||||
public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name')
|
|
||||||
{
|
|
||||||
// do some table foot work
|
|
||||||
$external = false;
|
|
||||||
if (strpos($table, '#__') !== false)
|
|
||||||
{
|
|
||||||
$external = true;
|
|
||||||
$table = str_replace('#__', '', $table);
|
|
||||||
}
|
|
||||||
// check if string is JSON
|
|
||||||
$result = json_decode($value, true);
|
|
||||||
if (json_last_error() === JSON_ERROR_NONE)
|
|
||||||
{
|
|
||||||
// is JSON
|
|
||||||
if (self::checkArray($result))
|
|
||||||
{
|
|
||||||
if (self::checkString($table))
|
|
||||||
{
|
|
||||||
$names = array();
|
|
||||||
foreach ($result as $val)
|
|
||||||
{
|
|
||||||
if ($external)
|
|
||||||
{
|
|
||||||
if ($_name = self::getVar(null, $val, $id, $name, '=', $table))
|
|
||||||
{
|
|
||||||
$names[] = $_name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($_name = self::getVar($table, $val, $id, $name))
|
|
||||||
{
|
|
||||||
$names[] = $_name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (self::checkArray($names))
|
|
||||||
{
|
|
||||||
return (string) implode($sperator,$names);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (string) implode($sperator,$result);
|
|
||||||
}
|
|
||||||
return (string) json_decode($value);
|
|
||||||
}
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the Component xml manifest.
|
* Load the Component xml manifest.
|
||||||
*/
|
*/
|
||||||
@ -7518,129 +7282,6 @@ abstract class ComponentbuilderHelper
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a variable
|
|
||||||
*
|
|
||||||
* @param string $table The table from which to get the variable
|
|
||||||
* @param string $where The value where
|
|
||||||
* @param string $whereString The target/field string where/name
|
|
||||||
* @param string $what The return field
|
|
||||||
* @param string $operator The operator between $whereString/field and $where/value
|
|
||||||
* @param string $main The component in which the table is found
|
|
||||||
*
|
|
||||||
* @return mix string/int/float
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'componentbuilder')
|
|
||||||
{
|
|
||||||
if(!$where)
|
|
||||||
{
|
|
||||||
$where = JFactory::getUser()->id;
|
|
||||||
}
|
|
||||||
// Get a db connection.
|
|
||||||
$db = JFactory::getDbo();
|
|
||||||
// Create a new query object.
|
|
||||||
$query = $db->getQuery(true);
|
|
||||||
$query->select($db->quoteName(array($what)));
|
|
||||||
if (empty($table))
|
|
||||||
{
|
|
||||||
$query->from($db->quoteName('#__'.$main));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$query->from($db->quoteName('#__'.$main.'_'.$table));
|
|
||||||
}
|
|
||||||
if (is_numeric($where))
|
|
||||||
{
|
|
||||||
$query->where($db->quoteName($whereString) . ' '.$operator.' '.(int) $where);
|
|
||||||
}
|
|
||||||
elseif (is_string($where))
|
|
||||||
{
|
|
||||||
$query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$where));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$db->setQuery($query);
|
|
||||||
$db->execute();
|
|
||||||
if ($db->getNumRows())
|
|
||||||
{
|
|
||||||
return $db->loadResult();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get array of variables
|
|
||||||
*
|
|
||||||
* @param string $table The table from which to get the variables
|
|
||||||
* @param string $where The value where
|
|
||||||
* @param string $whereString The target/field string where/name
|
|
||||||
* @param string $what The return field
|
|
||||||
* @param string $operator The operator between $whereString/field and $where/value
|
|
||||||
* @param string $main The component in which the table is found
|
|
||||||
* @param bool $unique The switch to return a unique array
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = 'componentbuilder', $unique = true)
|
|
||||||
{
|
|
||||||
if(!$where)
|
|
||||||
{
|
|
||||||
$where = JFactory::getUser()->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!self::checkArray($where) && $where > 0)
|
|
||||||
{
|
|
||||||
$where = array($where);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self::checkArray($where))
|
|
||||||
{
|
|
||||||
// prep main <-- why? well if $main='' is empty then $table can be categories or users
|
|
||||||
if (self::checkString($main))
|
|
||||||
{
|
|
||||||
$main = '_'.ltrim($main, '_');
|
|
||||||
}
|
|
||||||
// Get a db connection.
|
|
||||||
$db = JFactory::getDbo();
|
|
||||||
// Create a new query object.
|
|
||||||
$query = $db->getQuery(true);
|
|
||||||
|
|
||||||
$query->select($db->quoteName(array($what)));
|
|
||||||
if (empty($table))
|
|
||||||
{
|
|
||||||
$query->from($db->quoteName('#__'.$main));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$query->from($db->quoteName('#_'.$main.'_'.$table));
|
|
||||||
}
|
|
||||||
// add strings to array search
|
|
||||||
if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator)
|
|
||||||
{
|
|
||||||
$query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$where) . '")');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',',$where) . ')');
|
|
||||||
}
|
|
||||||
$db->setQuery($query);
|
|
||||||
$db->execute();
|
|
||||||
if ($db->getNumRows())
|
|
||||||
{
|
|
||||||
if ($unique)
|
|
||||||
{
|
|
||||||
return array_unique($db->loadColumn());
|
|
||||||
}
|
|
||||||
return $db->loadColumn();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function isPublished($id,$type)
|
public static function isPublished($id,$type)
|
||||||
{
|
{
|
||||||
if ($type == 'raw')
|
if ($type == 'raw')
|
||||||
@ -7878,83 +7519,6 @@ abstract class ComponentbuilderHelper
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if have an json string
|
|
||||||
*
|
|
||||||
* @input string The json string to check
|
|
||||||
*
|
|
||||||
* @returns bool true on success
|
|
||||||
*/
|
|
||||||
public static function checkJson($string)
|
|
||||||
{
|
|
||||||
if (self::checkString($string))
|
|
||||||
{
|
|
||||||
json_decode($string);
|
|
||||||
return (json_last_error() === JSON_ERROR_NONE);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if have an object with a length
|
|
||||||
*
|
|
||||||
* @input object The object to check
|
|
||||||
*
|
|
||||||
* @returns bool true on success
|
|
||||||
*/
|
|
||||||
public static function checkObject($object)
|
|
||||||
{
|
|
||||||
if (isset($object) && is_object($object))
|
|
||||||
{
|
|
||||||
return count((array)$object) > 0;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if have an array with a length
|
|
||||||
*
|
|
||||||
* @input array The array to check
|
|
||||||
*
|
|
||||||
* @returns bool/int number of items in array on success
|
|
||||||
*/
|
|
||||||
public static function checkArray($array, $removeEmptyString = false)
|
|
||||||
{
|
|
||||||
if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0)
|
|
||||||
{
|
|
||||||
// also make sure the empty strings are removed
|
|
||||||
if ($removeEmptyString)
|
|
||||||
{
|
|
||||||
foreach ($array as $key => $string)
|
|
||||||
{
|
|
||||||
if (empty($string))
|
|
||||||
{
|
|
||||||
unset($array[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return self::checkArray($array, false);
|
|
||||||
}
|
|
||||||
return $nr;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if have a string with a length
|
|
||||||
*
|
|
||||||
* @input string The string to check
|
|
||||||
*
|
|
||||||
* @returns bool true on success
|
|
||||||
*/
|
|
||||||
public static function checkString($string)
|
|
||||||
{
|
|
||||||
if (isset($string) && is_string($string) && strlen($string) > 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we are connected
|
* Check if we are connected
|
||||||
* Thanks https://stackoverflow.com/a/4860432/1429677
|
* Thanks https://stackoverflow.com/a/4860432/1429677
|
||||||
@ -7980,345 +7544,12 @@ abstract class ComponentbuilderHelper
|
|||||||
return $is_conn;
|
return $is_conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Merge an array of array's
|
|
||||||
*
|
|
||||||
* @input array The arrays you would like to merge
|
|
||||||
*
|
|
||||||
* @returns array on success
|
|
||||||
*/
|
|
||||||
public static function mergeArrays($arrays)
|
|
||||||
{
|
|
||||||
if(self::checkArray($arrays))
|
|
||||||
{
|
|
||||||
$arrayBuket = array();
|
|
||||||
foreach ($arrays as $array)
|
|
||||||
{
|
|
||||||
if (self::checkArray($array))
|
|
||||||
{
|
|
||||||
$arrayBuket = array_merge($arrayBuket, $array);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $arrayBuket;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// typo sorry!
|
// typo sorry!
|
||||||
public static function sorten($string, $length = 40, $addTip = true)
|
public static function sorten($string, $length = 40, $addTip = true)
|
||||||
{
|
{
|
||||||
return self::shorten($string, $length, $addTip);
|
return self::shorten($string, $length, $addTip);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Shorten a string
|
|
||||||
*
|
|
||||||
* @input string The you would like to shorten
|
|
||||||
*
|
|
||||||
* @returns string on success
|
|
||||||
*/
|
|
||||||
public static function shorten($string, $length = 40, $addTip = true)
|
|
||||||
{
|
|
||||||
if (self::checkString($string))
|
|
||||||
{
|
|
||||||
$initial = strlen($string);
|
|
||||||
$words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE);
|
|
||||||
$words_count = count((array)$words);
|
|
||||||
|
|
||||||
$word_length = 0;
|
|
||||||
$last_word = 0;
|
|
||||||
for (; $last_word < $words_count; ++$last_word)
|
|
||||||
{
|
|
||||||
$word_length += strlen($words[$last_word]);
|
|
||||||
if ($word_length > $length)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$newString = implode(array_slice($words, 0, $last_word));
|
|
||||||
$final = strlen($newString);
|
|
||||||
if ($initial != $final && $addTip)
|
|
||||||
{
|
|
||||||
$title = self::shorten($string, 400 , false);
|
|
||||||
return '<span class="hasTip" title="'.$title.'" style="cursor:help">'.trim($newString).'...</span>';
|
|
||||||
}
|
|
||||||
elseif ($initial != $final && !$addTip)
|
|
||||||
{
|
|
||||||
return trim($newString).'...';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Making strings safe (various ways)
|
|
||||||
*
|
|
||||||
* @input string The you would like to make safe
|
|
||||||
*
|
|
||||||
* @returns string on success
|
|
||||||
*/
|
|
||||||
public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true)
|
|
||||||
{
|
|
||||||
if ($replaceNumbers === true)
|
|
||||||
{
|
|
||||||
// remove all numbers and replace with english text version (works well only up to millions)
|
|
||||||
$string = self::replaceNumbers($string);
|
|
||||||
}
|
|
||||||
// 0nly continue if we have a string
|
|
||||||
if (self::checkString($string))
|
|
||||||
{
|
|
||||||
// create file name without the extention that is safe
|
|
||||||
if ($type === 'filename')
|
|
||||||
{
|
|
||||||
// make sure VDM is not in the string
|
|
||||||
$string = str_replace('VDM', 'vDm', $string);
|
|
||||||
// Remove anything which isn't a word, whitespace, number
|
|
||||||
// or any of the following caracters -_()
|
|
||||||
// If you don't need to handle multi-byte characters
|
|
||||||
// you can use preg_replace rather than mb_ereg_replace
|
|
||||||
// Thanks @Łukasz Rysiak!
|
|
||||||
// $string = mb_ereg_replace("([^\w\s\d\-_\(\)])", '', $string);
|
|
||||||
$string = preg_replace("([^\w\s\d\-_\(\)])", '', $string);
|
|
||||||
// http://stackoverflow.com/a/2021729/1429677
|
|
||||||
return preg_replace('/\s+/', ' ', $string);
|
|
||||||
}
|
|
||||||
// remove all other characters
|
|
||||||
$string = trim($string);
|
|
||||||
$string = preg_replace('/'.$spacer.'+/', ' ', $string);
|
|
||||||
$string = preg_replace('/\s+/', ' ', $string);
|
|
||||||
// Transliterate string
|
|
||||||
$string = self::transliterate($string);
|
|
||||||
// remove all and keep only characters
|
|
||||||
if ($keepOnlyCharacters)
|
|
||||||
{
|
|
||||||
$string = preg_replace("/[^A-Za-z ]/", '', $string);
|
|
||||||
}
|
|
||||||
// keep both numbers and characters
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$string = preg_replace("/[^A-Za-z0-9 ]/", '', $string);
|
|
||||||
}
|
|
||||||
// select final adaptations
|
|
||||||
if ($type === 'L' || $type === 'strtolower')
|
|
||||||
{
|
|
||||||
// replace white space with underscore
|
|
||||||
$string = preg_replace('/\s+/', $spacer, $string);
|
|
||||||
// default is to return lower
|
|
||||||
return strtolower($string);
|
|
||||||
}
|
|
||||||
elseif ($type === 'W')
|
|
||||||
{
|
|
||||||
// return a string with all first letter of each word uppercase(no undersocre)
|
|
||||||
return ucwords(strtolower($string));
|
|
||||||
}
|
|
||||||
elseif ($type === 'w' || $type === 'word')
|
|
||||||
{
|
|
||||||
// return a string with all lowercase(no undersocre)
|
|
||||||
return strtolower($string);
|
|
||||||
}
|
|
||||||
elseif ($type === 'Ww' || $type === 'Word')
|
|
||||||
{
|
|
||||||
// return a string with first letter of the first word uppercase and all the rest lowercase(no undersocre)
|
|
||||||
return ucfirst(strtolower($string));
|
|
||||||
}
|
|
||||||
elseif ($type === 'WW' || $type === 'WORD')
|
|
||||||
{
|
|
||||||
// return a string with all the uppercase(no undersocre)
|
|
||||||
return strtoupper($string);
|
|
||||||
}
|
|
||||||
elseif ($type === 'U' || $type === 'strtoupper')
|
|
||||||
{
|
|
||||||
// replace white space with underscore
|
|
||||||
$string = preg_replace('/\s+/', $spacer, $string);
|
|
||||||
// return all upper
|
|
||||||
return strtoupper($string);
|
|
||||||
}
|
|
||||||
elseif ($type === 'F' || $type === 'ucfirst')
|
|
||||||
{
|
|
||||||
// replace white space with underscore
|
|
||||||
$string = preg_replace('/\s+/', $spacer, $string);
|
|
||||||
// return with first caracter to upper
|
|
||||||
return ucfirst(strtolower($string));
|
|
||||||
}
|
|
||||||
elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase')
|
|
||||||
{
|
|
||||||
// convert all words to first letter uppercase
|
|
||||||
$string = ucwords(strtolower($string));
|
|
||||||
// remove white space
|
|
||||||
$string = preg_replace('/\s+/', '', $string);
|
|
||||||
// now return first letter lowercase
|
|
||||||
return lcfirst($string);
|
|
||||||
}
|
|
||||||
// return string
|
|
||||||
return $string;
|
|
||||||
}
|
|
||||||
// not a string
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function transliterate($string)
|
|
||||||
{
|
|
||||||
// set tag only once
|
|
||||||
if (!self::checkString(self::$langTag))
|
|
||||||
{
|
|
||||||
// get global value
|
|
||||||
self::$langTag = JComponentHelper::getParams('com_componentbuilder')->get('language', 'en-GB');
|
|
||||||
}
|
|
||||||
// Transliterate on the language requested
|
|
||||||
$lang = Language::getInstance(self::$langTag);
|
|
||||||
return $lang->transliterate($string);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40)
|
|
||||||
{
|
|
||||||
if (self::checkString($var))
|
|
||||||
{
|
|
||||||
$filter = new JFilterInput();
|
|
||||||
$string = $filter->clean(html_entity_decode(htmlentities($var, ENT_COMPAT, $charset)), 'HTML');
|
|
||||||
if ($shorten)
|
|
||||||
{
|
|
||||||
return self::shorten($string,$length);
|
|
||||||
}
|
|
||||||
return $string;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function replaceNumbers($string)
|
|
||||||
{
|
|
||||||
// set numbers array
|
|
||||||
$numbers = array();
|
|
||||||
// first get all numbers
|
|
||||||
preg_match_all('!\d+!', $string, $numbers);
|
|
||||||
// check if we have any numbers
|
|
||||||
if (isset($numbers[0]) && self::checkArray($numbers[0]))
|
|
||||||
{
|
|
||||||
foreach ($numbers[0] as $number)
|
|
||||||
{
|
|
||||||
$searchReplace[$number] = self::numberToString((int)$number);
|
|
||||||
}
|
|
||||||
// now replace numbers in string
|
|
||||||
$string = str_replace(array_keys($searchReplace), array_values($searchReplace),$string);
|
|
||||||
// check if we missed any, strange if we did.
|
|
||||||
return self::replaceNumbers($string);
|
|
||||||
}
|
|
||||||
// return the string with no numbers remaining.
|
|
||||||
return $string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert an integer into an English word string
|
|
||||||
* Thanks to Tom Nicholson <http://php.net/manual/en/function.strval.php#41988>
|
|
||||||
*
|
|
||||||
* @input an int
|
|
||||||
* @returns a string
|
|
||||||
*/
|
|
||||||
public static function numberToString($x)
|
|
||||||
{
|
|
||||||
$nwords = array( "zero", "one", "two", "three", "four", "five", "six", "seven",
|
|
||||||
"eight", "nine", "ten", "eleven", "twelve", "thirteen",
|
|
||||||
"fourteen", "fifteen", "sixteen", "seventeen", "eighteen",
|
|
||||||
"nineteen", "twenty", 30 => "thirty", 40 => "forty",
|
|
||||||
50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty",
|
|
||||||
90 => "ninety" );
|
|
||||||
|
|
||||||
if(!is_numeric($x))
|
|
||||||
{
|
|
||||||
$w = $x;
|
|
||||||
}
|
|
||||||
elseif(fmod($x, 1) != 0)
|
|
||||||
{
|
|
||||||
$w = $x;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if($x < 0)
|
|
||||||
{
|
|
||||||
$w = 'minus ';
|
|
||||||
$x = -$x;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$w = '';
|
|
||||||
// ... now $x is a non-negative integer.
|
|
||||||
}
|
|
||||||
|
|
||||||
if($x < 21) // 0 to 20
|
|
||||||
{
|
|
||||||
$w .= $nwords[$x];
|
|
||||||
}
|
|
||||||
elseif($x < 100) // 21 to 99
|
|
||||||
{
|
|
||||||
$w .= $nwords[10 * floor($x/10)];
|
|
||||||
$r = fmod($x, 10);
|
|
||||||
if($r > 0)
|
|
||||||
{
|
|
||||||
$w .= ' '. $nwords[$r];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif($x < 1000) // 100 to 999
|
|
||||||
{
|
|
||||||
$w .= $nwords[floor($x/100)] .' hundred';
|
|
||||||
$r = fmod($x, 100);
|
|
||||||
if($r > 0)
|
|
||||||
{
|
|
||||||
$w .= ' and '. self::numberToString($r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif($x < 1000000) // 1000 to 999999
|
|
||||||
{
|
|
||||||
$w .= self::numberToString(floor($x/1000)) .' thousand';
|
|
||||||
$r = fmod($x, 1000);
|
|
||||||
if($r > 0)
|
|
||||||
{
|
|
||||||
$w .= ' ';
|
|
||||||
if($r < 100)
|
|
||||||
{
|
|
||||||
$w .= 'and ';
|
|
||||||
}
|
|
||||||
$w .= self::numberToString($r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // millions
|
|
||||||
{
|
|
||||||
$w .= self::numberToString(floor($x/1000000)) .' million';
|
|
||||||
$r = fmod($x, 1000000);
|
|
||||||
if($r > 0)
|
|
||||||
{
|
|
||||||
$w .= ' ';
|
|
||||||
if($r < 100)
|
|
||||||
{
|
|
||||||
$w .= 'and ';
|
|
||||||
}
|
|
||||||
$w .= self::numberToString($r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $w;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Random Key
|
|
||||||
*
|
|
||||||
* @returns a string
|
|
||||||
*/
|
|
||||||
public static function randomkey($size)
|
|
||||||
{
|
|
||||||
$bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
|
|
||||||
$key = array();
|
|
||||||
$bagsize = strlen($bag) - 1;
|
|
||||||
for ($i = 0; $i < $size; $i++)
|
|
||||||
{
|
|
||||||
$get = rand(0, $bagsize);
|
|
||||||
$key[] = $bag[$get];
|
|
||||||
}
|
|
||||||
return implode($key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get The Encryption Keys
|
* Get The Encryption Keys
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user