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:
@@ -15,6 +15,11 @@ defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
use Joomla\CMS\Filesystem\File;
|
||||
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
|
||||
ComponentbuilderHelper::autoLoader();
|
||||
|
||||
@@ -145,10 +150,10 @@ class Compiler extends Infusion
|
||||
// set the lang data now
|
||||
$this->setLangFileData();
|
||||
// set the language notice if it was set
|
||||
if (ComponentbuilderHelper::checkArray($this->langNot)
|
||||
|| ComponentbuilderHelper::checkArray($this->langSet))
|
||||
if (ArrayHelper::check($this->langNot)
|
||||
|| ArrayHelper::check($this->langSet))
|
||||
{
|
||||
if (ComponentbuilderHelper::checkArray($this->langNot))
|
||||
if (ArrayHelper::check($this->langNot))
|
||||
{
|
||||
$this->app->enqueueMessage(
|
||||
JText::_('<hr /><h3>Language Warning</h3>'), 'Warning'
|
||||
@@ -184,7 +189,7 @@ class Compiler extends Infusion
|
||||
);
|
||||
}
|
||||
// show languages that were added
|
||||
if (ComponentbuilderHelper::checkArray($this->langSet))
|
||||
if (ArrayHelper::check($this->langSet))
|
||||
{
|
||||
$this->app->enqueueMessage(
|
||||
JText::_('<hr /><h3>Language Notice</h3>'), 'Notice'
|
||||
@@ -275,9 +280,9 @@ class Compiler extends Infusion
|
||||
// if there are plugins zip them
|
||||
$this->zipPlugins();
|
||||
// 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(
|
||||
array_unique($this->langMismatch),
|
||||
@@ -290,7 +295,7 @@ class Compiler extends Infusion
|
||||
}
|
||||
// set a notice if we have a mismatch
|
||||
if (isset($mismatch)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$mismatch
|
||||
))
|
||||
{
|
||||
@@ -317,7 +322,7 @@ class Compiler extends Infusion
|
||||
foreach ($mismatch as $string)
|
||||
{
|
||||
$constant = $this->langPrefix . '_'
|
||||
. ComponentbuilderHelper::safeString($string, 'U');
|
||||
. StringHelper::safe($string, 'U');
|
||||
$this->app->enqueueMessage(
|
||||
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.',
|
||||
@@ -328,7 +333,7 @@ class Compiler extends Infusion
|
||||
}
|
||||
}
|
||||
// check if we should add a EXTERNALCODE notice
|
||||
if (ComponentbuilderHelper::checkArray($this->externalCodeString))
|
||||
if (ArrayHelper::check($this->externalCodeString))
|
||||
{
|
||||
// number of external code strings
|
||||
$externalCount = count($this->externalCodeString);
|
||||
@@ -385,9 +390,9 @@ class Compiler extends Infusion
|
||||
protected function updateFiles()
|
||||
{
|
||||
if (isset($this->newFiles['static'])
|
||||
&& ComponentbuilderHelper::checkArray($this->newFiles['static'])
|
||||
&& ArrayHelper::check($this->newFiles['static'])
|
||||
&& isset($this->newFiles['dynamic'])
|
||||
&& ComponentbuilderHelper::checkArray($this->newFiles['dynamic']))
|
||||
&& ArrayHelper::check($this->newFiles['dynamic']))
|
||||
{
|
||||
// get the bom file
|
||||
$bom = ComponentbuilderHelper::getFileContents($this->bomPath);
|
||||
@@ -405,7 +410,7 @@ class Compiler extends Infusion
|
||||
foreach ($this->newFiles['dynamic'] as $view => $files)
|
||||
{
|
||||
if (isset($this->fileContentDynamic[$view])
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$this->fileContentDynamic[$view]
|
||||
))
|
||||
{
|
||||
@@ -429,13 +434,13 @@ class Compiler extends Infusion
|
||||
// free up some memory
|
||||
unset($this->newFiles['dynamic']);
|
||||
// do modules if found
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaModules))
|
||||
if (ArrayHelper::check($this->joomlaModules))
|
||||
{
|
||||
foreach ($this->joomlaModules as $module)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($module)
|
||||
if (ObjectHelper::check($module)
|
||||
&& isset($this->newFiles[$module->key])
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$this->newFiles[$module->key]
|
||||
))
|
||||
{
|
||||
@@ -445,7 +450,7 @@ class Compiler extends Infusion
|
||||
{
|
||||
// check the config fields
|
||||
if (isset($module->config_fields)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$module->config_fields
|
||||
))
|
||||
{
|
||||
@@ -467,7 +472,7 @@ class Compiler extends Infusion
|
||||
}
|
||||
// check the fieldsets
|
||||
if (isset($module->form_files)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$module->form_files
|
||||
))
|
||||
{
|
||||
@@ -510,13 +515,13 @@ class Compiler extends Infusion
|
||||
}
|
||||
}
|
||||
// do plugins if found
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaPlugins))
|
||||
if (ArrayHelper::check($this->joomlaPlugins))
|
||||
{
|
||||
foreach ($this->joomlaPlugins as $plugin)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($plugin)
|
||||
if (ObjectHelper::check($plugin)
|
||||
&& isset($this->newFiles[$plugin->key])
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$this->newFiles[$plugin->key]
|
||||
))
|
||||
{
|
||||
@@ -526,7 +531,7 @@ class Compiler extends Infusion
|
||||
{
|
||||
// check the config fields
|
||||
if (isset($plugin->config_fields)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$plugin->config_fields
|
||||
))
|
||||
{
|
||||
@@ -548,7 +553,7 @@ class Compiler extends Infusion
|
||||
}
|
||||
// check the fieldsets
|
||||
if (isset($plugin->form_files)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$plugin->form_files
|
||||
))
|
||||
{
|
||||
@@ -591,13 +596,13 @@ class Compiler extends Infusion
|
||||
}
|
||||
}
|
||||
// do powers if found
|
||||
if (ComponentbuilderHelper::checkArray($this->powers))
|
||||
if (ArrayHelper::check($this->powers))
|
||||
{
|
||||
foreach ($this->powers as $power)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($power)
|
||||
if (ObjectHelper::check($power)
|
||||
&& isset($this->newFiles[$power->key])
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$this->newFiles[$power->key]
|
||||
))
|
||||
{
|
||||
@@ -720,11 +725,11 @@ class Compiler extends Infusion
|
||||
}
|
||||
}
|
||||
// move the modules update server to host
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaModules))
|
||||
if (ArrayHelper::check($this->joomlaModules))
|
||||
{
|
||||
foreach ($this->joomlaModules as $module)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($module)
|
||||
if (ObjectHelper::check($module)
|
||||
&& isset($module->add_update_server)
|
||||
&& $module->add_update_server == 1
|
||||
&& isset($module->update_server_target)
|
||||
@@ -735,7 +740,7 @@ class Compiler extends Infusion
|
||||
&& isset($module->update_server_xml_path)
|
||||
&& File::exists($module->update_server_xml_path)
|
||||
&& isset($module->update_server_xml_file_name)
|
||||
&& ComponentbuilderHelper::checkString(
|
||||
&& StringHelper::check(
|
||||
$module->update_server_xml_file_name
|
||||
))
|
||||
{
|
||||
@@ -753,11 +758,11 @@ class Compiler extends Infusion
|
||||
}
|
||||
}
|
||||
// move the plugins update server to host
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaPlugins))
|
||||
if (ArrayHelper::check($this->joomlaPlugins))
|
||||
{
|
||||
foreach ($this->joomlaPlugins as $plugin)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($plugin)
|
||||
if (ObjectHelper::check($plugin)
|
||||
&& isset($plugin->add_update_server)
|
||||
&& $plugin->add_update_server == 1
|
||||
&& isset($plugin->update_server_target)
|
||||
@@ -768,7 +773,7 @@ class Compiler extends Infusion
|
||||
&& isset($plugin->update_server_xml_path)
|
||||
&& File::exists($plugin->update_server_xml_path)
|
||||
&& isset($plugin->update_server_xml_file_name)
|
||||
&& ComponentbuilderHelper::checkString(
|
||||
&& StringHelper::check(
|
||||
$plugin->update_server_xml_file_name
|
||||
))
|
||||
{
|
||||
@@ -791,7 +796,7 @@ class Compiler extends Infusion
|
||||
{
|
||||
// check if these files have its own config data)
|
||||
if (isset($data['config'])
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$data['config']
|
||||
)
|
||||
&& $this->componentData->mvc_versiondate == 1)
|
||||
@@ -981,7 +986,7 @@ class Compiler extends Infusion
|
||||
{
|
||||
// move it to the repo folder if set
|
||||
if (isset($this->repoPath)
|
||||
&& ComponentbuilderHelper::checkString(
|
||||
&& StringHelper::check(
|
||||
$this->repoPath
|
||||
))
|
||||
{
|
||||
@@ -1007,11 +1012,11 @@ class Compiler extends Infusion
|
||||
);
|
||||
|
||||
// move the modules to local folder repos
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaModules))
|
||||
if (ArrayHelper::check($this->joomlaModules))
|
||||
{
|
||||
foreach ($this->joomlaModules as $module)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($module)
|
||||
if (ObjectHelper::check($module)
|
||||
&& isset($module->file_name))
|
||||
{
|
||||
$module_context = 'module.' . $module->file_name . '.'
|
||||
@@ -1044,11 +1049,11 @@ class Compiler extends Infusion
|
||||
}
|
||||
}
|
||||
// move the plugins to local folder repos
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaPlugins))
|
||||
if (ArrayHelper::check($this->joomlaPlugins))
|
||||
{
|
||||
foreach ($this->joomlaPlugins as $plugin)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($plugin)
|
||||
if (ObjectHelper::check($plugin)
|
||||
&& isset($plugin->file_name))
|
||||
{
|
||||
$plugin_context = 'plugin.' . $plugin->file_name . '.'
|
||||
@@ -1162,15 +1167,15 @@ class Compiler extends Infusion
|
||||
|
||||
private function zipModules()
|
||||
{
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaModules))
|
||||
if (ArrayHelper::check($this->joomlaModules))
|
||||
{
|
||||
foreach ($this->joomlaModules as $module)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($module)
|
||||
if (ObjectHelper::check($module)
|
||||
&& isset($module->zip_name)
|
||||
&& ComponentbuilderHelper::checkString($module->zip_name)
|
||||
&& StringHelper::check($module->zip_name)
|
||||
&& isset($module->folder_path)
|
||||
&& ComponentbuilderHelper::checkString(
|
||||
&& StringHelper::check(
|
||||
$module->folder_path
|
||||
))
|
||||
{
|
||||
@@ -1256,15 +1261,15 @@ class Compiler extends Infusion
|
||||
|
||||
private function zipPlugins()
|
||||
{
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaPlugins))
|
||||
if (ArrayHelper::check($this->joomlaPlugins))
|
||||
{
|
||||
foreach ($this->joomlaPlugins as $plugin)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($plugin)
|
||||
if (ObjectHelper::check($plugin)
|
||||
&& isset($plugin->zip_name)
|
||||
&& ComponentbuilderHelper::checkString($plugin->zip_name)
|
||||
&& StringHelper::check($plugin->zip_name)
|
||||
&& isset($plugin->folder_path)
|
||||
&& ComponentbuilderHelper::checkString(
|
||||
&& StringHelper::check(
|
||||
$plugin->folder_path
|
||||
))
|
||||
{
|
||||
@@ -1359,9 +1364,9 @@ class Compiler extends Infusion
|
||||
$fingerPrint = array();
|
||||
if (isset($target['hashtarget'][0]) && $target['hashtarget'][0] > 3
|
||||
&& isset($target['path'])
|
||||
&& ComponentbuilderHelper::checkString($target['path'])
|
||||
&& StringHelper::check($target['path'])
|
||||
&& isset($target['hashtarget'][1])
|
||||
&& ComponentbuilderHelper::checkString(
|
||||
&& StringHelper::check(
|
||||
$target['hashtarget'][1]
|
||||
))
|
||||
{
|
||||
@@ -1400,7 +1405,7 @@ class Compiler extends Infusion
|
||||
);
|
||||
if (!$found)
|
||||
{
|
||||
$bites = (int) ComponentbuilderHelper::bcmath(
|
||||
$bites = (int) MathHelper::bc(
|
||||
'add', $lineBites[$lineNumber], $bites
|
||||
);
|
||||
}
|
||||
@@ -1590,14 +1595,14 @@ class Compiler extends Infusion
|
||||
// Add the data
|
||||
fwrite($fpFile, $data);
|
||||
// truncate file at the end of the data that was added
|
||||
$remove = ComponentbuilderHelper::bcmath(
|
||||
$remove = MathHelper::bc(
|
||||
'add', $position, mb_strlen($data, '8bit')
|
||||
);
|
||||
ftruncate($fpFile, $remove);
|
||||
// check if this was a replacement of data
|
||||
if ($replace)
|
||||
{
|
||||
$position = ComponentbuilderHelper::bcmath(
|
||||
$position = MathHelper::bc(
|
||||
'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\Folder;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
|
||||
|
||||
/**
|
||||
* Structure class
|
||||
@@ -485,7 +489,7 @@ class Structure extends Get
|
||||
*/
|
||||
private function buildPowers()
|
||||
{
|
||||
if (ComponentbuilderHelper::checkArray($this->powers))
|
||||
if (ArrayHelper::check($this->powers))
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeSetModules
|
||||
$this->triggerEvent(
|
||||
@@ -496,9 +500,9 @@ class Structure extends Get
|
||||
$htaccess = array();
|
||||
foreach ($this->powers as $power)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($power)
|
||||
if (ObjectHelper::check($power)
|
||||
&& isset($power->path)
|
||||
&& ComponentbuilderHelper::checkString(
|
||||
&& StringHelper::check(
|
||||
$power->path
|
||||
))
|
||||
{
|
||||
@@ -594,7 +598,7 @@ class Structure extends Get
|
||||
*/
|
||||
private function buildModules()
|
||||
{
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaModules))
|
||||
if (ArrayHelper::check($this->joomlaModules))
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeSetModules
|
||||
$this->triggerEvent(
|
||||
@@ -603,9 +607,9 @@ class Structure extends Get
|
||||
);
|
||||
foreach ($this->joomlaModules as $module)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($module)
|
||||
if (ObjectHelper::check($module)
|
||||
&& isset($module->folder_name)
|
||||
&& ComponentbuilderHelper::checkString(
|
||||
&& StringHelper::check(
|
||||
$module->folder_name
|
||||
))
|
||||
{
|
||||
@@ -764,7 +768,7 @@ class Structure extends Get
|
||||
if (($css = $this->getCustomScriptBuilder(
|
||||
'css_view', $module->key
|
||||
)) !== null
|
||||
&& ComponentbuilderHelper::checkString($css))
|
||||
&& StringHelper::check($css))
|
||||
{
|
||||
// make sure this script does not have PHP
|
||||
if (strpos($css, '<?php') === false)
|
||||
@@ -799,7 +803,7 @@ class Structure extends Get
|
||||
if (($javascript = $this->getCustomScriptBuilder(
|
||||
'view_footer', $module->key
|
||||
)) !== null
|
||||
&& ComponentbuilderHelper::checkString($javascript))
|
||||
&& StringHelper::check($javascript))
|
||||
{
|
||||
// make sure this script does not have PHP
|
||||
if (strpos($javascript, '<?php') === false)
|
||||
@@ -864,7 +868,7 @@ class Structure extends Get
|
||||
}
|
||||
// set forms folder if needed
|
||||
if (isset($module->form_files)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$module->form_files
|
||||
))
|
||||
{
|
||||
@@ -1020,7 +1024,7 @@ class Structure extends Get
|
||||
. $fieldset . '" label="' . $label . '">';
|
||||
}
|
||||
// check if we have an inner field set
|
||||
if (ComponentbuilderHelper::checkString(
|
||||
if (StringHelper::check(
|
||||
$field_name_inner
|
||||
))
|
||||
{
|
||||
@@ -1032,7 +1036,7 @@ class Structure extends Get
|
||||
$xml .= $this->hhh . 'FIELDSET_' . $file
|
||||
. $field_name . $fieldset . $this->hhh;
|
||||
// check if we have an inner field set
|
||||
if (ComponentbuilderHelper::checkString(
|
||||
if (StringHelper::check(
|
||||
$field_name_inner
|
||||
))
|
||||
{
|
||||
@@ -1091,7 +1095,7 @@ class Structure extends Get
|
||||
);
|
||||
// check if this lib has files
|
||||
if (isset($module->files)
|
||||
&& ComponentbuilderHelper::checkArray($module->files))
|
||||
&& ArrayHelper::check($module->files))
|
||||
{
|
||||
// add to component files
|
||||
foreach ($module->files as $file)
|
||||
@@ -1104,7 +1108,7 @@ class Structure extends Get
|
||||
}
|
||||
// check if this lib has folders
|
||||
if (isset($module->folders)
|
||||
&& ComponentbuilderHelper::checkArray($module->folders))
|
||||
&& ArrayHelper::check($module->folders))
|
||||
{
|
||||
// add to component folders
|
||||
foreach ($module->folders as $folder)
|
||||
@@ -1117,7 +1121,7 @@ class Structure extends Get
|
||||
}
|
||||
// check if this module has urls
|
||||
if (isset($module->urls)
|
||||
&& ComponentbuilderHelper::checkArray($module->urls))
|
||||
&& ArrayHelper::check($module->urls))
|
||||
{
|
||||
// add to component urls
|
||||
foreach ($module->urls as $n => &$url)
|
||||
@@ -1125,7 +1129,7 @@ class Structure extends Get
|
||||
// should we add the local folder
|
||||
if (isset($url['type']) && $url['type'] > 1
|
||||
&& isset($url['url'])
|
||||
&& ComponentbuilderHelper::checkString(
|
||||
&& StringHelper::check(
|
||||
$url['url']
|
||||
))
|
||||
{
|
||||
@@ -1175,7 +1179,7 @@ class Structure extends Get
|
||||
*/
|
||||
private function buildPlugins()
|
||||
{
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaPlugins))
|
||||
if (ArrayHelper::check($this->joomlaPlugins))
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeSetPlugins
|
||||
$this->triggerEvent(
|
||||
@@ -1184,9 +1188,9 @@ class Structure extends Get
|
||||
);
|
||||
foreach ($this->joomlaPlugins as $plugin)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($plugin)
|
||||
if (ObjectHelper::check($plugin)
|
||||
&& isset($plugin->folder_name)
|
||||
&& ComponentbuilderHelper::checkString(
|
||||
&& StringHelper::check(
|
||||
$plugin->folder_name
|
||||
))
|
||||
{
|
||||
@@ -1273,7 +1277,7 @@ class Structure extends Get
|
||||
}
|
||||
// set forms folder if needed
|
||||
if (isset($plugin->form_files)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$plugin->form_files
|
||||
))
|
||||
{
|
||||
@@ -1411,7 +1415,7 @@ class Structure extends Get
|
||||
. $fieldset . '" label="' . $label . '">';
|
||||
}
|
||||
// check if we have an inner field set
|
||||
if (ComponentbuilderHelper::checkString(
|
||||
if (StringHelper::check(
|
||||
$field_name_inner
|
||||
))
|
||||
{
|
||||
@@ -1423,7 +1427,7 @@ class Structure extends Get
|
||||
$xml .= $this->hhh . 'FIELDSET_' . $file
|
||||
. $field_name . $fieldset . $this->hhh;
|
||||
// check if we have an inner field set
|
||||
if (ComponentbuilderHelper::checkString(
|
||||
if (StringHelper::check(
|
||||
$field_name_inner
|
||||
))
|
||||
{
|
||||
@@ -1482,7 +1486,7 @@ class Structure extends Get
|
||||
);
|
||||
// check if this lib has files
|
||||
if (isset($plugin->files)
|
||||
&& ComponentbuilderHelper::checkArray($plugin->files))
|
||||
&& ArrayHelper::check($plugin->files))
|
||||
{
|
||||
// add to component files
|
||||
foreach ($plugin->files as $file)
|
||||
@@ -1495,7 +1499,7 @@ class Structure extends Get
|
||||
}
|
||||
// check if this lib has folders
|
||||
if (isset($plugin->folders)
|
||||
&& ComponentbuilderHelper::checkArray($plugin->folders))
|
||||
&& ArrayHelper::check($plugin->folders))
|
||||
{
|
||||
// add to component folders
|
||||
foreach ($plugin->folders as $folder)
|
||||
@@ -1508,7 +1512,7 @@ class Structure extends Get
|
||||
}
|
||||
// check if this plugin has urls
|
||||
if (isset($plugin->urls)
|
||||
&& ComponentbuilderHelper::checkArray($plugin->urls))
|
||||
&& ArrayHelper::check($plugin->urls))
|
||||
{
|
||||
// add to component urls
|
||||
foreach ($plugin->urls as $n => &$url)
|
||||
@@ -1516,7 +1520,7 @@ class Structure extends Get
|
||||
// should we add the local folder
|
||||
if (isset($url['type']) && $url['type'] > 1
|
||||
&& isset($url['url'])
|
||||
&& ComponentbuilderHelper::checkString(
|
||||
&& StringHelper::check(
|
||||
$url['url']
|
||||
))
|
||||
{
|
||||
@@ -1591,7 +1595,7 @@ class Structure extends Get
|
||||
*/
|
||||
private function setLibraries()
|
||||
{
|
||||
if (ComponentbuilderHelper::checkArray($this->libraries))
|
||||
if (ArrayHelper::check($this->libraries))
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeSetLibraries
|
||||
$this->triggerEvent(
|
||||
@@ -1610,11 +1614,11 @@ class Structure extends Get
|
||||
$this->createFolder($this->componentPath . '/media');
|
||||
foreach ($this->libraries as $id => &$library)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($library))
|
||||
if (ObjectHelper::check($library))
|
||||
{
|
||||
// check if this lib has files
|
||||
if (isset($library->files)
|
||||
&& ComponentbuilderHelper::checkArray($library->files))
|
||||
&& ArrayHelper::check($library->files))
|
||||
{
|
||||
// add to component files
|
||||
foreach ($library->files as $file)
|
||||
@@ -1624,7 +1628,7 @@ class Structure extends Get
|
||||
}
|
||||
// check if this lib has folders
|
||||
if (isset($library->folders)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$library->folders
|
||||
))
|
||||
{
|
||||
@@ -1636,13 +1640,13 @@ class Structure extends Get
|
||||
}
|
||||
// check if this lib has urls
|
||||
if (isset($library->urls)
|
||||
&& ComponentbuilderHelper::checkArray($library->urls))
|
||||
&& ArrayHelper::check($library->urls))
|
||||
{
|
||||
// build media folder path
|
||||
$libFolder = strtolower(
|
||||
preg_replace(
|
||||
'/\s+/', '-',
|
||||
ComponentbuilderHelper::safeString(
|
||||
StringHelper::safe(
|
||||
$library->name, 'filename', ' ', false
|
||||
)
|
||||
)
|
||||
@@ -1655,7 +1659,7 @@ class Structure extends Get
|
||||
{
|
||||
if (isset($url['type']) && $url['type'] > 1
|
||||
&& isset($url['url'])
|
||||
&& ComponentbuilderHelper::checkString(
|
||||
&& StringHelper::check(
|
||||
$url['url']
|
||||
))
|
||||
{
|
||||
@@ -1712,7 +1716,7 @@ class Structure extends Get
|
||||
// if config fields are found load into component config (avoiding duplicates)
|
||||
if (isset($library->how) && $library->how > 1
|
||||
&& isset($library->config)
|
||||
&& ComponentbuilderHelper::checkArray($library->config))
|
||||
&& ArrayHelper::check($library->config))
|
||||
{
|
||||
foreach ($library->config as $cofig)
|
||||
{
|
||||
@@ -1723,7 +1727,7 @@ class Structure extends Get
|
||||
}
|
||||
);
|
||||
// set the config data if not found
|
||||
if (!ComponentbuilderHelper::checkArray($found))
|
||||
if (!ArrayHelper::check($found))
|
||||
{
|
||||
$this->componentData->config[] = $cofig;
|
||||
}
|
||||
@@ -1746,7 +1750,7 @@ class Structure extends Get
|
||||
if (isset($this->componentData->dashboard_type)
|
||||
&& 2 == $this->componentData->dashboard_type
|
||||
&& isset($this->componentData->dashboard)
|
||||
&& ComponentbuilderHelper::checkString(
|
||||
&& StringHelper::check(
|
||||
$this->componentData->dashboard
|
||||
)
|
||||
&& strpos($this->componentData->dashboard, '_') !== false)
|
||||
@@ -1756,7 +1760,7 @@ class Structure extends Get
|
||||
if (count((array) $getter) == 2 && is_numeric($getter[1]))
|
||||
{
|
||||
// the pointers
|
||||
$t = ComponentbuilderHelper::safeString($getter[0], 'U');
|
||||
$t = StringHelper::safe($getter[0], 'U');
|
||||
$id = (int) $getter[1];
|
||||
// the dynamic stuff
|
||||
$targets = array('A' => 'admin_views',
|
||||
@@ -1769,12 +1773,12 @@ class Structure extends Get
|
||||
if (isset($targets[$t]) && $id > 0)
|
||||
{
|
||||
// set the type name
|
||||
$type_names = ComponentbuilderHelper::safeString(
|
||||
$type_names = StringHelper::safe(
|
||||
$targets[$t], 'w'
|
||||
);
|
||||
// set the dynamic dash
|
||||
if (isset($this->componentData->{$targets[$t]})
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$this->componentData->{$targets[$t]}
|
||||
))
|
||||
{
|
||||
@@ -1792,7 +1796,7 @@ class Structure extends Get
|
||||
}
|
||||
);
|
||||
// set dashboard
|
||||
if (ComponentbuilderHelper::checkArray($dashboard))
|
||||
if (ArrayHelper::check($dashboard))
|
||||
{
|
||||
$dashboard = array_values($dashboard)[0];
|
||||
}
|
||||
@@ -1801,7 +1805,7 @@ class Structure extends Get
|
||||
&& isset($dashboard['settings']->{$keys[$t]}))
|
||||
{
|
||||
$this->dynamicDashboard
|
||||
= ComponentbuilderHelper::safeString(
|
||||
= StringHelper::safe(
|
||||
$dashboard['settings']->{$keys[$t]}
|
||||
);
|
||||
$this->dynamicDashboardType
|
||||
@@ -1866,7 +1870,7 @@ class Structure extends Get
|
||||
);
|
||||
}
|
||||
// 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
|
||||
$this->componentData->dashboard_tab = '';
|
||||
@@ -1894,7 +1898,7 @@ class Structure extends Get
|
||||
*/
|
||||
private function setFolders()
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject(
|
||||
if (ObjectHelper::check(
|
||||
$this->joomlaVersionData->create
|
||||
))
|
||||
{
|
||||
@@ -1910,14 +1914,14 @@ class Structure extends Get
|
||||
foreach ($this->joomlaVersionData->create as $main => $folders)
|
||||
{
|
||||
$this->createFolder($this->componentPath . '/' . $main);
|
||||
if (ComponentbuilderHelper::checkObject($folders))
|
||||
if (ObjectHelper::check($folders))
|
||||
{
|
||||
foreach ($folders as $sub => $subFolders)
|
||||
{
|
||||
$this->createFolder(
|
||||
$this->componentPath . '/' . $main . '/' . $sub
|
||||
);
|
||||
if (ComponentbuilderHelper::checkObject($subFolders))
|
||||
if (ObjectHelper::check($subFolders))
|
||||
{
|
||||
foreach ($subFolders as $sub_2 => $subFolders_2)
|
||||
{
|
||||
@@ -1925,7 +1929,7 @@ class Structure extends Get
|
||||
$this->componentPath . '/' . $main . '/'
|
||||
. $sub . '/' . $sub_2
|
||||
);
|
||||
if (ComponentbuilderHelper::checkObject(
|
||||
if (ObjectHelper::check(
|
||||
$subFolders_2
|
||||
))
|
||||
{
|
||||
@@ -1938,7 +1942,7 @@ class Structure extends Get
|
||||
. '/' . $sub . '/' . $sub_2 . '/'
|
||||
. $sub_3
|
||||
);
|
||||
if (ComponentbuilderHelper::checkObject(
|
||||
if (ObjectHelper::check(
|
||||
$subFolders_3
|
||||
))
|
||||
{
|
||||
@@ -1953,7 +1957,7 @@ class Structure extends Get
|
||||
. $sub_2 . '/' . $sub_3
|
||||
. '/' . $sub_4
|
||||
);
|
||||
if (ComponentbuilderHelper::checkObject(
|
||||
if (ObjectHelper::check(
|
||||
$subFolders_4
|
||||
))
|
||||
{
|
||||
@@ -1971,7 +1975,7 @@ class Structure extends Get
|
||||
. $sub_4 . '/'
|
||||
. $sub_5
|
||||
);
|
||||
if (ComponentbuilderHelper::checkObject(
|
||||
if (ObjectHelper::check(
|
||||
$subFolders_5
|
||||
))
|
||||
{
|
||||
@@ -1998,7 +2002,7 @@ class Structure extends Get
|
||||
. '/'
|
||||
. $sub_6
|
||||
);
|
||||
if (ComponentbuilderHelper::checkObject(
|
||||
if (ObjectHelper::check(
|
||||
$subFolders_6
|
||||
))
|
||||
{
|
||||
@@ -2059,7 +2063,7 @@ class Structure extends Get
|
||||
*/
|
||||
private function setStatic()
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject(
|
||||
if (ObjectHelper::check(
|
||||
$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.
|
||||
// We basicly only want to check if a folder is added that is not in the stdFolders array
|
||||
if (isset($checker[0])
|
||||
&& ComponentbuilderHelper::checkString($checker[0])
|
||||
&& StringHelper::check($checker[0])
|
||||
&& !in_array($checker[0], $this->stdFolders))
|
||||
{
|
||||
// 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
|
||||
&& ComponentbuilderHelper::checkString($checker[0]))
|
||||
&& StringHelper::check($checker[0]))
|
||||
{
|
||||
$add_to_extra = false;
|
||||
// set the target
|
||||
@@ -2302,7 +2306,7 @@ class Structure extends Get
|
||||
}
|
||||
// set the xml file
|
||||
$this->fileContentStatic[$this->hhh . 'EXSTRA_'
|
||||
. ComponentbuilderHelper::safeString(
|
||||
. StringHelper::safe(
|
||||
$checker[0], 'U'
|
||||
) . '_' . $eNAME . $this->hhh]
|
||||
.= PHP_EOL . $eTab . "<" . $ename . ">"
|
||||
@@ -2329,15 +2333,15 @@ class Structure extends Get
|
||||
$back = false;
|
||||
$front = false;
|
||||
if ((isset($this->joomlaVersionData->move->dynamic)
|
||||
&& ComponentbuilderHelper::checkObject(
|
||||
&& ObjectHelper::check(
|
||||
$this->joomlaVersionData->move->dynamic
|
||||
))
|
||||
&& (isset($this->componentData->admin_views)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$this->componentData->admin_views
|
||||
)))
|
||||
{
|
||||
if (!ComponentbuilderHelper::checkString($this->dynamicDashboard))
|
||||
if (!StringHelper::check($this->dynamicDashboard))
|
||||
{
|
||||
// setup dashboard
|
||||
$target = array('admin' => $this->componentData->name_code);
|
||||
@@ -2346,7 +2350,7 @@ class Structure extends Get
|
||||
// now the rest of the views
|
||||
foreach ($this->componentData->admin_views as $nr => $view)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($view['settings']))
|
||||
if (ObjectHelper::check($view['settings']))
|
||||
{
|
||||
$created = $this->getCreatedDate($view);
|
||||
$modified = $this->getLastModifiedDate($view);
|
||||
@@ -2405,11 +2409,11 @@ class Structure extends Get
|
||||
$back = true;
|
||||
}
|
||||
if ((isset($this->joomlaVersionData->move->dynamic)
|
||||
&& ComponentbuilderHelper::checkObject(
|
||||
&& ObjectHelper::check(
|
||||
$this->joomlaVersionData->move->dynamic
|
||||
))
|
||||
&& (isset($this->componentData->site_views)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$this->componentData->site_views
|
||||
)))
|
||||
{
|
||||
@@ -2446,11 +2450,11 @@ class Structure extends Get
|
||||
$front = true;
|
||||
}
|
||||
if ((isset($this->joomlaVersionData->move->dynamic)
|
||||
&& ComponentbuilderHelper::checkObject(
|
||||
&& ObjectHelper::check(
|
||||
$this->joomlaVersionData->move->dynamic
|
||||
))
|
||||
&& (isset($this->componentData->custom_admin_views)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$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)
|
||||
{
|
||||
@@ -2617,7 +2621,7 @@ class Structure extends Get
|
||||
public function getCreatedDate($view)
|
||||
{
|
||||
if (isset($view['settings']->created)
|
||||
&& ComponentbuilderHelper::checkString($view['settings']->created))
|
||||
&& StringHelper::check($view['settings']->created))
|
||||
{
|
||||
// first set the main date
|
||||
$date = strtotime($view['settings']->created);
|
||||
@@ -2643,7 +2647,7 @@ class Structure extends Get
|
||||
{
|
||||
// first set the main date
|
||||
if (isset($view['settings']->modified)
|
||||
&& ComponentbuilderHelper::checkString($view['settings']->modified)
|
||||
&& StringHelper::check($view['settings']->modified)
|
||||
&& '0000-00-00 00:00:00' !== $view['settings']->modified)
|
||||
{
|
||||
$date = strtotime($view['settings']->modified);
|
||||
@@ -2661,18 +2665,18 @@ class Structure extends Get
|
||||
if (!isset($this->lastModifiedDate[$id]))
|
||||
{
|
||||
if (isset($view['settings']->fields)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$view['settings']->fields
|
||||
))
|
||||
{
|
||||
foreach ($view['settings']->fields as $field)
|
||||
{
|
||||
if (isset($field['settings'])
|
||||
&& ComponentbuilderHelper::checkObject(
|
||||
&& ObjectHelper::check(
|
||||
$field['settings']
|
||||
)
|
||||
&& isset($field['settings']->modified)
|
||||
&& ComponentbuilderHelper::checkString(
|
||||
&& StringHelper::check(
|
||||
$field['settings']->modified
|
||||
)
|
||||
&& '0000-00-00 00:00:00'
|
||||
@@ -2697,7 +2701,7 @@ class Structure extends Get
|
||||
if (!isset($this->lastModifiedDate[$id]))
|
||||
{
|
||||
if (isset($view['settings']->main_get->modified)
|
||||
&& ComponentbuilderHelper::checkString(
|
||||
&& StringHelper::check(
|
||||
$view['settings']->main_get->modified
|
||||
)
|
||||
&& '0000-00-00 00:00:00'
|
||||
@@ -2720,7 +2724,7 @@ class Structure extends Get
|
||||
if (!isset($this->lastModifiedDate[$id]))
|
||||
{
|
||||
if (isset($view['settings']->main_get->modified)
|
||||
&& ComponentbuilderHelper::checkString(
|
||||
&& StringHelper::check(
|
||||
$view['settings']->main_get->modified
|
||||
)
|
||||
&& '0000-00-00 00:00:00'
|
||||
@@ -2770,13 +2774,13 @@ class Structure extends Get
|
||||
// did we build the files (any number)
|
||||
$build_status = false;
|
||||
// check that we have the target values
|
||||
if (ComponentbuilderHelper::checkArray($target))
|
||||
if (ArrayHelper::check($target))
|
||||
{
|
||||
// search the target
|
||||
foreach ($target as $main => $name)
|
||||
{
|
||||
// make sure it is lower case
|
||||
$name = ComponentbuilderHelper::safeString($name);
|
||||
$name = StringHelper::safe($name);
|
||||
// setup the files
|
||||
foreach (
|
||||
$this->joomlaVersionData->move->dynamic->{$main} as $item =>
|
||||
@@ -2861,7 +2865,7 @@ class Structure extends Get
|
||||
$newFIle = array('path' => $path . '/' . $new,
|
||||
'name' => $new, 'view' => $name,
|
||||
'zip' => $zipPath . '/' . $new);
|
||||
if (ComponentbuilderHelper::checkArray($config))
|
||||
if (ArrayHelper::check($config))
|
||||
{
|
||||
$newFIle['config'] = $config;
|
||||
}
|
||||
@@ -2885,15 +2889,28 @@ class Structure extends Get
|
||||
*/
|
||||
private function setJoomlaVersionData()
|
||||
{
|
||||
// option to load other settings
|
||||
$custom_settings = $this->templatePath . '/settings_' . $this->componentCodeName . '.json';
|
||||
// set the version data
|
||||
$versionData = json_decode(
|
||||
ComponentbuilderHelper::getFileContents(
|
||||
$this->templatePath . '/settings.json'
|
||||
)
|
||||
);
|
||||
if (File::exists($custom_settings))
|
||||
{
|
||||
$version_data = json_decode(
|
||||
ComponentbuilderHelper::getFileContents(
|
||||
$custom_settings
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$version_data = json_decode(
|
||||
ComponentbuilderHelper::getFileContents(
|
||||
$this->templatePath . '/settings.json'
|
||||
)
|
||||
);
|
||||
}
|
||||
// add custom folders
|
||||
if ((isset($this->componentData->folders)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$this->componentData->folders
|
||||
))
|
||||
|| $this->addEximport
|
||||
@@ -2965,7 +2982,7 @@ class Structure extends Get
|
||||
);
|
||||
// fix custom path
|
||||
if (isset($custom['path'])
|
||||
&& ComponentbuilderHelper::checkString($custom['path']))
|
||||
&& StringHelper::check($custom['path']))
|
||||
{
|
||||
$custom['path'] = trim($custom['path'], '/');
|
||||
}
|
||||
@@ -3017,31 +3034,31 @@ class Structure extends Get
|
||||
$newname = '';
|
||||
}
|
||||
// insure we have no duplicates
|
||||
$key_pointer = ComponentbuilderHelper::safeString(
|
||||
$key_pointer = StringHelper::safe(
|
||||
$custom['folder']
|
||||
) . '_f' . $pointer_tracker;
|
||||
$pointer_tracker++;
|
||||
// fix custom path
|
||||
$custom['path'] = ltrim($custom['path'], '/');
|
||||
// set new folder to object
|
||||
$versionData->move->static->{$key_pointer} = new stdClass();
|
||||
$versionData->move->static->{$key_pointer}->naam
|
||||
$version_data->move->static->{$key_pointer} = new stdClass();
|
||||
$version_data->move->static->{$key_pointer}->naam
|
||||
= str_replace(
|
||||
'//', '/', $custom['folder']
|
||||
);
|
||||
$versionData->move->static->{$key_pointer}->path
|
||||
$version_data->move->static->{$key_pointer}->path
|
||||
= $_target_type
|
||||
. '/' . $custom['path'];
|
||||
$versionData->move->static->{$key_pointer}->rename = $rename;
|
||||
$versionData->move->static->{$key_pointer}->newName = $newname;
|
||||
$versionData->move->static->{$key_pointer}->type = 'folder';
|
||||
$versionData->move->static->{$key_pointer}->custom
|
||||
$version_data->move->static->{$key_pointer}->rename = $rename;
|
||||
$version_data->move->static->{$key_pointer}->newName = $newname;
|
||||
$version_data->move->static->{$key_pointer}->type = 'folder';
|
||||
$version_data->move->static->{$key_pointer}->custom
|
||||
= $customPath;
|
||||
// set the target if type and id is found
|
||||
if (isset($custom['target_id'])
|
||||
&& isset($custom['target_type']))
|
||||
{
|
||||
$versionData->move->static->{$key_pointer}->_target
|
||||
$version_data->move->static->{$key_pointer}->_target
|
||||
= array('key' => $custom['target_id'] . '_'
|
||||
. $custom['target_type'],
|
||||
'type' => $custom['target_type']);
|
||||
@@ -3052,7 +3069,7 @@ class Structure extends Get
|
||||
}
|
||||
// add custom files
|
||||
if ((isset($this->componentData->files)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$this->componentData->files
|
||||
))
|
||||
|| $this->googlechart)
|
||||
@@ -3106,13 +3123,13 @@ class Structure extends Get
|
||||
$customPath = 'full';
|
||||
}
|
||||
// make sure we have not duplicates
|
||||
$key_pointer = ComponentbuilderHelper::safeString(
|
||||
$key_pointer = StringHelper::safe(
|
||||
$custom['file']
|
||||
) . '_g' . $pointer_tracker;
|
||||
$pointer_tracker++;
|
||||
// set new file to object
|
||||
$versionData->move->static->{$key_pointer} = new stdClass();
|
||||
$versionData->move->static->{$key_pointer}->naam = str_replace(
|
||||
$version_data->move->static->{$key_pointer} = new stdClass();
|
||||
$version_data->move->static->{$key_pointer}->naam = str_replace(
|
||||
'//', '/', $custom['file']
|
||||
);
|
||||
// update the dynamic component name placholders in file names
|
||||
@@ -3125,11 +3142,11 @@ class Structure extends Get
|
||||
{
|
||||
$pathInfo['dirname'] = trim($pathInfo['dirname'], '/');
|
||||
// set the info
|
||||
$versionData->move->static->{$key_pointer}->path
|
||||
$version_data->move->static->{$key_pointer}->path
|
||||
= $_target_type
|
||||
. '/' . $pathInfo['dirname'];
|
||||
$versionData->move->static->{$key_pointer}->rename = 'new';
|
||||
$versionData->move->static->{$key_pointer}->newName
|
||||
$version_data->move->static->{$key_pointer}->rename = 'new';
|
||||
$version_data->move->static->{$key_pointer}->newName
|
||||
= $pathInfo['basename'];
|
||||
}
|
||||
elseif ('full' === $customPath)
|
||||
@@ -3139,11 +3156,11 @@ class Structure extends Get
|
||||
// get file array
|
||||
$fileArray = (array) explode('/', $custom['file']);
|
||||
// set the info
|
||||
$versionData->move->static->{$key_pointer}->path
|
||||
$version_data->move->static->{$key_pointer}->path
|
||||
= $_target_type
|
||||
. '/' . $custom['path'];
|
||||
$versionData->move->static->{$key_pointer}->rename = 'new';
|
||||
$versionData->move->static->{$key_pointer}->newName = end(
|
||||
$version_data->move->static->{$key_pointer}->rename = 'new';
|
||||
$version_data->move->static->{$key_pointer}->newName = end(
|
||||
$fileArray
|
||||
);
|
||||
}
|
||||
@@ -3152,19 +3169,19 @@ class Structure extends Get
|
||||
// fix custom path
|
||||
$custom['path'] = ltrim($custom['path'], '/');
|
||||
// set the info
|
||||
$versionData->move->static->{$key_pointer}->path
|
||||
$version_data->move->static->{$key_pointer}->path
|
||||
= $_target_type
|
||||
. '/' . $custom['path'];
|
||||
$versionData->move->static->{$key_pointer}->rename = false;
|
||||
$version_data->move->static->{$key_pointer}->rename = false;
|
||||
}
|
||||
$versionData->move->static->{$key_pointer}->type = 'file';
|
||||
$versionData->move->static->{$key_pointer}->custom
|
||||
$version_data->move->static->{$key_pointer}->type = 'file';
|
||||
$version_data->move->static->{$key_pointer}->custom
|
||||
= $customPath;
|
||||
// set the target if type and id is found
|
||||
if (isset($custom['target_id'])
|
||||
&& isset($custom['target_type']))
|
||||
{
|
||||
$versionData->move->static->{$key_pointer}->_target
|
||||
$version_data->move->static->{$key_pointer}->_target
|
||||
= array('key' => $custom['target_id'] . '_'
|
||||
. $custom['target_type'],
|
||||
'type' => $custom['target_type']);
|
||||
@@ -3185,7 +3202,7 @@ class Structure extends Get
|
||||
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\Folder;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
|
||||
/**
|
||||
* Infusion class
|
||||
@@ -68,7 +71,7 @@ class Infusion extends Interpretation
|
||||
protected function buildFileContent()
|
||||
{
|
||||
if (isset($this->componentData->admin_views)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$this->componentData->admin_views
|
||||
))
|
||||
{
|
||||
@@ -157,7 +160,7 @@ class Infusion extends Interpretation
|
||||
}
|
||||
// load only first two values
|
||||
if (isset($versionArray)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$versionArray
|
||||
)
|
||||
&& $this->componentData->mvc_versiondate == 2)
|
||||
@@ -167,7 +170,7 @@ class Infusion extends Interpretation
|
||||
}
|
||||
// load only the first value
|
||||
elseif (isset($versionArray)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$versionArray
|
||||
)
|
||||
&& $this->componentData->mvc_versiondate == 3)
|
||||
@@ -356,7 +359,7 @@ class Infusion extends Interpretation
|
||||
= $this->addEmailHelper();
|
||||
|
||||
// load the global placeholders
|
||||
if (ComponentbuilderHelper::checkArray($this->globalPlaceholders))
|
||||
if (ArrayHelper::check($this->globalPlaceholders))
|
||||
{
|
||||
foreach (
|
||||
$this->globalPlaceholders as $globalPlaceholder =>
|
||||
@@ -1030,7 +1033,7 @@ class Infusion extends Interpretation
|
||||
$scriptNote, true,
|
||||
false, PHP_EOL
|
||||
)) !== false
|
||||
&& ComponentbuilderHelper::checkString($footerScript))
|
||||
&& StringHelper::check($footerScript))
|
||||
{
|
||||
// only minfy if no php is added to the footer script
|
||||
if ($this->minify
|
||||
@@ -1296,7 +1299,7 @@ class Infusion extends Interpretation
|
||||
|
||||
// setup custom_admin_views and all needed stuff for the site
|
||||
if (isset($this->componentData->custom_admin_views)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$this->componentData->custom_admin_views
|
||||
))
|
||||
{
|
||||
@@ -1667,7 +1670,7 @@ class Infusion extends Interpretation
|
||||
$this->setVersionController();
|
||||
|
||||
// only set these if default dashboard it used
|
||||
if (!ComponentbuilderHelper::checkString($this->dynamicDashboard))
|
||||
if (!StringHelper::check($this->dynamicDashboard))
|
||||
{
|
||||
// DASHBOARDVIEW
|
||||
$this->fileContentStatic[$this->hhh . 'DASHBOARDVIEW'
|
||||
@@ -1801,7 +1804,7 @@ class Infusion extends Interpretation
|
||||
|
||||
// build the validation rules
|
||||
if (isset($this->validationRules)
|
||||
&& ComponentbuilderHelper::checkArray($this->validationRules))
|
||||
&& ArrayHelper::check($this->validationRules))
|
||||
{
|
||||
foreach ($this->validationRules as $rule => $_php)
|
||||
{
|
||||
@@ -1821,13 +1824,13 @@ class Infusion extends Interpretation
|
||||
|
||||
// run the second run if needed
|
||||
if (isset($this->secondRunAdmin)
|
||||
&& ComponentbuilderHelper::checkArray($this->secondRunAdmin))
|
||||
&& ArrayHelper::check($this->secondRunAdmin))
|
||||
{
|
||||
// start dynamic build
|
||||
foreach ($this->secondRunAdmin as $function => $arrays)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkArray($arrays)
|
||||
&& ComponentbuilderHelper::checkString($function))
|
||||
if (ArrayHelper::check($arrays)
|
||||
&& StringHelper::check($function))
|
||||
{
|
||||
foreach ($arrays as $array)
|
||||
{
|
||||
@@ -1846,7 +1849,7 @@ class Infusion extends Interpretation
|
||||
|
||||
// setup front-views and all needed stuff for the site
|
||||
if (isset($this->componentData->site_views)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$this->componentData->site_views
|
||||
))
|
||||
{
|
||||
@@ -2072,7 +2075,7 @@ class Infusion extends Interpretation
|
||||
if ($view['settings']->main_get->gettype == 1)
|
||||
{
|
||||
// insure the controller headers are added
|
||||
if (ComponentbuilderHelper::checkString(
|
||||
if (StringHelper::check(
|
||||
$view['settings']->php_controller
|
||||
)
|
||||
&& $view['settings']->php_controller != '//')
|
||||
@@ -2106,7 +2109,7 @@ class Infusion extends Interpretation
|
||||
elseif ($view['settings']->main_get->gettype == 2)
|
||||
{
|
||||
// insure the controller headers are added
|
||||
if (ComponentbuilderHelper::checkString(
|
||||
if (StringHelper::check(
|
||||
$view['settings']->php_controller
|
||||
)
|
||||
&& $view['settings']->php_controller != '//')
|
||||
@@ -2286,7 +2289,7 @@ class Infusion extends Interpretation
|
||||
$this->fileContentStatic[$this->hhh . 'ROUTER_BUILD_VIEWS'
|
||||
. $this->hhh]
|
||||
)
|
||||
|| !ComponentbuilderHelper::checkString(
|
||||
|| !StringHelper::check(
|
||||
$this->fileContentStatic[$this->hhh . 'ROUTER_BUILD_VIEWS'
|
||||
. $this->hhh]
|
||||
))
|
||||
@@ -2310,18 +2313,16 @@ class Infusion extends Interpretation
|
||||
= $this->componentData->readme;
|
||||
}
|
||||
// remove all the power placeholders
|
||||
$this->fileContentStatic[$this->hhh . 'ADMIN_POWER_EVENT_HELPER' . $this->hhh] = '';
|
||||
$this->fileContentStatic[$this->hhh . 'ADMIN_POWER_EVENT' . $this->hhh] = '';
|
||||
$this->fileContentStatic[$this->hhh . 'SITE_POWER_EVENT_HELPER' . $this->hhh] = '';
|
||||
$this->fileContentStatic[$this->hhh . 'SITE_POWER_EVENT' . $this->hhh] = '';
|
||||
$this->fileContentStatic[$this->hhh . 'ADMIN_POWER_HELPER' . $this->hhh] = '';
|
||||
$this->fileContentStatic[$this->hhh . 'SITE_POWER_HELPER' . $this->hhh] = '';
|
||||
// infuse powers data if set
|
||||
if (ComponentbuilderHelper::checkArray($this->powers))
|
||||
if (ArrayHelper::check($this->powers))
|
||||
{
|
||||
// start the autoloader
|
||||
$autoloader = array();
|
||||
foreach ($this->powers as $power)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($power))
|
||||
if (ObjectHelper::check($power))
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeInfusePowerData
|
||||
$this->triggerEvent(
|
||||
@@ -2349,11 +2350,11 @@ class Infusion extends Interpretation
|
||||
$_backup_lang = $this->lang;
|
||||
$_backup_langPrefix = $this->langPrefix;
|
||||
// infuse module data if set
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaModules))
|
||||
if (ArrayHelper::check($this->joomlaModules))
|
||||
{
|
||||
foreach ($this->joomlaModules as $module)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($module))
|
||||
if (ObjectHelper::check($module))
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeInfuseModuleData
|
||||
$this->triggerEvent(
|
||||
@@ -2394,7 +2395,7 @@ class Infusion extends Interpretation
|
||||
}
|
||||
// FIELDSET
|
||||
if (isset($module->form_files)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$module->form_files
|
||||
))
|
||||
{
|
||||
@@ -2428,11 +2429,11 @@ class Infusion extends Interpretation
|
||||
}
|
||||
}
|
||||
// infuse plugin data if set
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaPlugins))
|
||||
if (ArrayHelper::check($this->joomlaPlugins))
|
||||
{
|
||||
foreach ($this->joomlaPlugins as $plugin)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($plugin))
|
||||
if (ObjectHelper::check($plugin))
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeInfusePluginData
|
||||
$this->triggerEvent(
|
||||
@@ -2456,7 +2457,7 @@ class Infusion extends Interpretation
|
||||
}
|
||||
// FIELDSET
|
||||
if (isset($plugin->form_files)
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
&& ArrayHelper::check(
|
||||
$plugin->form_files
|
||||
))
|
||||
{
|
||||
@@ -2524,10 +2525,10 @@ class Infusion extends Interpretation
|
||||
{
|
||||
// set main keys
|
||||
$nameSingleCode = $view->name_single_code;
|
||||
$name_single_uppercase = ComponentbuilderHelper::safeString(
|
||||
$name_single_uppercase = StringHelper::safe(
|
||||
$view->name_single, 'U'
|
||||
);
|
||||
$name_single_first_uppercase = ComponentbuilderHelper::safeString(
|
||||
$name_single_first_uppercase = StringHelper::safe(
|
||||
$view->name_single, 'F'
|
||||
);
|
||||
|
||||
@@ -2550,10 +2551,10 @@ class Infusion extends Interpretation
|
||||
if (isset($view->name_list) && $view->name_list != 'null')
|
||||
{
|
||||
$nameListCode = $view->name_list_code;
|
||||
$name_list_uppercase = ComponentbuilderHelper::safeString(
|
||||
$name_list_uppercase = StringHelper::safe(
|
||||
$view->name_list, 'U'
|
||||
);
|
||||
$name_list_first_uppercase = ComponentbuilderHelper::safeString(
|
||||
$name_list_first_uppercase = StringHelper::safe(
|
||||
$view->name_list, 'F'
|
||||
);
|
||||
|
||||
@@ -2683,7 +2684,7 @@ class Infusion extends Interpretation
|
||||
$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
|
||||
$this->multiLangString = $this->getMultiLangStrings($values);
|
||||
// update insert the current lang in to DB
|
||||
@@ -2699,7 +2700,7 @@ class Infusion extends Interpretation
|
||||
&$this->langTag)
|
||||
);
|
||||
// now we insert the values into the files
|
||||
if (ComponentbuilderHelper::checkArray($this->languages['components']))
|
||||
if (ArrayHelper::check($this->languages['components']))
|
||||
{
|
||||
// rest xml array
|
||||
$langXML = array();
|
||||
@@ -2775,18 +2776,18 @@ class Infusion extends Interpretation
|
||||
}
|
||||
}
|
||||
// load the lang xml
|
||||
if (ComponentbuilderHelper::checkArray($langXML))
|
||||
if (ArrayHelper::check($langXML))
|
||||
{
|
||||
$replace = array();
|
||||
if (isset($langXML['admin'])
|
||||
&& ComponentbuilderHelper::checkArray($langXML['admin']))
|
||||
&& ArrayHelper::check($langXML['admin']))
|
||||
{
|
||||
$replace[$this->hhh . 'ADMIN_LANGUAGES' . $this->hhh]
|
||||
= implode(PHP_EOL . $this->_t(3), $langXML['admin']);
|
||||
}
|
||||
if ((!$this->removeSiteFolder || !$this->removeSiteEditFolder)
|
||||
&& isset($langXML['site'])
|
||||
&& ComponentbuilderHelper::checkArray($langXML['site']))
|
||||
&& ArrayHelper::check($langXML['site']))
|
||||
{
|
||||
$replace[$this->hhh . 'SITE_LANGUAGES' . $this->hhh]
|
||||
= implode(PHP_EOL . $this->_t(2), $langXML['site']);
|
||||
|
@@ -13,6 +13,50 @@
|
||||
// No direct access to this file
|
||||
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\Registry\Registry;
|
||||
use Joomla\String\StringHelper;
|
||||
@@ -24,12 +68,20 @@ use Joomla\Archive\Archive;
|
||||
use Joomla\CMS\Filesystem\File;
|
||||
use Joomla\CMS\Filesystem\Folder;
|
||||
use Joomla\CMS\Filesystem\Path;
|
||||
use VDM\Joomla\Utilities;
|
||||
|
||||
/**
|
||||
* Componentbuilder component helper.
|
||||
*/
|
||||
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
|
||||
*
|
||||
@@ -37,13 +89,6 @@ abstract class ComponentbuilderHelper
|
||||
*/
|
||||
protected static $composer = array();
|
||||
|
||||
/**
|
||||
* The Main Active Language
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $langTag;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
@@ -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
|
||||
*
|
||||
@@ -7436,177 +7251,6 @@ abstract class ComponentbuilderHelper
|
||||
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)
|
||||
{
|
||||
if ($type == 'raw')
|
||||
@@ -8200,83 +7844,6 @@ abstract class ComponentbuilderHelper
|
||||
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
|
||||
* Thanks https://stackoverflow.com/a/4860432/1429677
|
||||
@@ -8302,345 +7869,12 @@ abstract class ComponentbuilderHelper
|
||||
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!
|
||||
public static function sorten($string, $length = 40, $addTip = true)
|
||||
{
|
||||
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
|
||||
*
|
||||
|
Reference in New Issue
Block a user