diff --git a/README.md b/README.md index c09c7d233..646e98b9c 100644 --- a/README.md +++ b/README.md @@ -140,14 +140,14 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 15th January, 2023 ++ *Last Build*: 22nd January, 2023 + *Version*: 3.1.13 + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **345248** ++ *Line count*: **357633** + *Field count*: **2009** -+ *File count*: **2240** -+ *Folder count*: **399** ++ *File count*: **2304** ++ *Folder count*: **408** > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com). > Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) diff --git a/admin/README.txt b/admin/README.txt index c09c7d233..646e98b9c 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -140,14 +140,14 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 15th January, 2023 ++ *Last Build*: 22nd January, 2023 + *Version*: 3.1.13 + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **345248** ++ *Line count*: **357633** + *Field count*: **2009** -+ *File count*: **2240** -+ *Folder count*: **399** ++ *File count*: **2304** ++ *Folder count*: **408** > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com). > Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) diff --git a/admin/controllers/compiler.php b/admin/controllers/compiler.php index 2cde5d620..e5653f11e 100644 --- a/admin/controllers/compiler.php +++ b/admin/controllers/compiler.php @@ -171,19 +171,19 @@ class ComponentbuilderControllerCompiler extends AdminController } $message[] = '

Total time saved

'; $message[] = ''; - $message[] = '

'.$model->compiler->totalHours.' Hours or '.$model->compiler->totalDays.' Eight Hour Days (actual time you saved)
'; + $message[] = '

#'.'##totalHours##'.'# Hours or #'.'##totalDays##'.'# Eight Hour Days (actual time you saved)
'; $message[] = '(if creating a folder and file took 5 seconds and writing one line of code took 10 seconds, never making one mistake or taking any coffee break.)
'; - $message[] = ''.$model->compiler->actualHoursSpent.' Hours or '.$model->compiler->actualDaysSpent.' Eight Hour Days (the actual time you spent)
'; - $message[] = '(with the following break down: debugging @'.$model->compiler->debuggingHours.'hours = codingtime / 4; planning @'.$model->compiler->planningHours.'hours = codingtime / 7; mapping @'.$model->compiler->mappingHours.'hours = codingtime / 10; office @'.$model->compiler->officeHours.'hours = codingtime / 6;)

'; - $message[] = '

'.$model->compiler->actualTotalHours.' Hours or '.$model->compiler->actualTotalDays.' Eight Hour Days (a total of the realistic time frame for this project)
'; + $message[] = '#'.'##actualHoursSpent##'.'# Hours or #'.'##actualDaysSpent##'.'# Eight Hour Days (the actual time you spent)
'; + $message[] = '(with the following break down: debugging @#'.'##debuggingHours##'.'#hours = codingtime / 4; planning @#'.'##planningHours##'.'#hours = codingtime / 7; mapping @#'.'##mappingHours##'.'#hours = codingtime / 10; office @#'.'##officeHours##'.'#hours = codingtime / 6;)

'; + $message[] = '

#'.'##actualTotalHours##'.'# Hours or #'.'##actualTotalDays##'.'# Eight Hour Days (a total of the realistic time frame for this project)
'; $message[] = '(if creating a folder and file took 5 seconds and writing one line of code took 10 seconds, with the normal everyday realities at the office, that includes the component planning, mapping & debugging.)

'; - $message[] = '

Project duration: '.$model->compiler->projectWeekTime. ' weeks or '.$model->compiler->projectMonthTime.' months

'; + $message[] = '

Project duration: '.$model->compiler->projectWeekTime. ' weeks or #'.'##projectMonthTime##'.'# months

'; // check if we have modules or plugins if ($add_multi_install) { @@ -254,9 +254,14 @@ class ComponentbuilderControllerCompiler extends AdminController $message[] = 'Download

'; $message[] = '

Remember! This zip file is in your tmp folder and therefore publicly accessible until you click [Clear tmp]!

'; } - $message[] = '

Compilation took '.$model->compiler->secondsCompiled.' seconds to complete.

'; + $message[] = '

Compilation took #'.'##COMPILER_TIMER##'.'# seconds to complete.

'; // pass the message via the user state... wow this is painful - $app->setUserState('com_componentbuilder.success_message', implode(PHP_EOL, $message)); + $app->setUserState('com_componentbuilder.success_message', + CFactory::_('Placeholder')->update( + implode(PHP_EOL, $message), + CFactory::_('Content')->active + ) + ); // set redirect $this->setRedirect($redirect_url, '

Successful Build!

', 'message'); $app->setUserState('com_componentbuilder.component_folder_name', $model->compiler->filepath['component-folder']); diff --git a/admin/helpers/compiler.php b/admin/helpers/compiler.php index 8e577cba5..598318ded 100644 --- a/admin/helpers/compiler.php +++ b/admin/helpers/compiler.php @@ -31,6 +31,7 @@ ComponentbuilderHelper::autoLoader(); /** * Compiler class + * @deprecated 3.3 */ class Compiler extends Infusion { @@ -79,7 +80,8 @@ class Compiler extends Infusion { // to check the compiler speed $this->time_start = microtime(true); - // first we run the perent constructors + CFactory::_('Counter')->start(); + // first we run the parent constructors if (parent::__construct()) { // set temp directory @@ -271,8 +273,6 @@ class Compiler extends Infusion } // move the update server into place $this->setUpdateServer(); - // set the global counters - $this->setCountingStuff(); // build read me $this->buildReadMe(); // set local repos @@ -363,6 +363,7 @@ class Compiler extends Infusion // end the timer here $this->time_end = microtime(true); $this->secondsCompiled = $this->time_end - $this->time_start; + CFactory::_('Counter')->end(); // completed the compilation return true; @@ -424,9 +425,9 @@ class Compiler extends Infusion // free up some memory unset($this->newFiles['dynamic']); // do modules if found - if (ArrayHelper::check($this->joomlaModules)) + if (CFactory::_('Joomlamodule.Data')->exists()) { - foreach ($this->joomlaModules as $module) + foreach (CFactory::_('Joomlamodule.Data')->get() as $module) { if (ObjectHelper::check($module) && isset($this->newFiles[$module->key]) @@ -505,9 +506,9 @@ class Compiler extends Infusion } } // do plugins if found - if (ArrayHelper::check($this->joomlaPlugins)) + if (CFactory::_('Joomlaplugin.Data')->exists()) { - foreach ($this->joomlaPlugins as $plugin) + foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin) { if (ObjectHelper::check($plugin) && isset($this->newFiles[$plugin->key]) @@ -682,7 +683,7 @@ class Compiler extends Infusion // add answer back to file $this->writeFile($path, $answer); // count the file lines - $this->lineCount = $this->lineCount + substr_count((string) $answer, PHP_EOL); + CFactory::_('Counter')->line += substr_count((string) $answer, PHP_EOL); } /** @@ -694,8 +695,7 @@ class Compiler extends Infusion protected function setUpdateServer() { // move the component update server to host - if ($this->componentData->add_update_server == 1 - && $this->componentData->update_server_target == 1 + if (CFactory::_('Component')->get('add_update_server', 0) == 1 && isset($this->updateServerFileName) && $this->dynamicIntegration) { @@ -703,23 +703,23 @@ class Compiler extends Infusion . $this->updateServerFileName . '.xml'; // make sure we have the correct file if (File::exists($update_server_xml_path) - && isset($this->componentData->update_server)) + && ($update_server = CFactory::_('Component')->get('update_server')) !== null) { // move to server ComponentbuilderHelper::moveToServer( $update_server_xml_path, $this->updateServerFileName . '.xml', - (int) $this->componentData->update_server, - $this->componentData->update_server_protocol + (int) $update_server, + CFactory::_('Component')->get('update_server_protocol') ); // remove the local file File::delete($update_server_xml_path); } } // move the modules update server to host - if (ArrayHelper::check($this->joomlaModules)) + if (CFactory::_('Joomlamodule.Data')->exists()) { - foreach ($this->joomlaModules as $module) + foreach (CFactory::_('Joomlamodule.Data')->get() as $module) { if (ObjectHelper::check($module) && isset($module->add_update_server) @@ -750,9 +750,9 @@ class Compiler extends Infusion } } // move the plugins update server to host - if (ArrayHelper::check($this->joomlaPlugins)) + if (CFactory::_('Joomlaplugin.Data')->exists()) { - foreach ($this->joomlaPlugins as $plugin) + foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin) { if (ObjectHelper::check($plugin) && isset($plugin->add_update_server) @@ -791,7 +791,7 @@ class Compiler extends Infusion && ArrayHelper::check( $data['config'] ) - && $this->componentData->mvc_versiondate == 1) + && CFactory::_('Component')->get('mvc_versiondate', 0) == 1) { foreach ($data['config'] as $key => $value) { @@ -820,40 +820,23 @@ class Compiler extends Infusion CFactory::_('Content')->set('VERSION', CFactory::_('Content')->get('GLOBALVERSION')); } - // set all global numbers + /** + * Set all global numbers + * + * @return void + * @deprecated 3.3 + */ protected function setCountingStuff() { - // what is the size in terms of an A4 book - $this->pageCount = round($this->lineCount / 56); - // setup the unrealistic numbers - $this->folderSeconds = $this->folderCount * 5; - $this->fileSeconds = $this->fileCount * 5; - $this->lineSeconds = $this->lineCount * 10; - $this->seconds = $this->folderSeconds + $this->fileSeconds - + $this->lineSeconds; - $this->totalHours = round($this->seconds / 3600); - $this->totalDays = round($this->totalHours / 8); - // setup the more realistic numbers - $this->secondsDebugging = $this->seconds / 4; - $this->secondsPlanning = $this->seconds / 7; - $this->secondsMapping = $this->seconds / 10; - $this->secondsOffice = $this->seconds / 6; - $this->actualSeconds = $this->folderSeconds + $this->fileSeconds - + $this->lineSeconds + $this->secondsDebugging - + $this->secondsPlanning + $this->secondsMapping - + $this->secondsOffice; - $this->actualTotalHours = round($this->actualSeconds / 3600); - $this->actualTotalDays = round($this->actualTotalHours / 8); - $this->debuggingHours = round($this->secondsDebugging / 3600); - $this->planningHours = round($this->secondsPlanning / 3600); - $this->mappingHours = round($this->secondsMapping / 3600); - $this->officeHours = round($this->secondsOffice / 3600); - // the actual time spent - $this->actualHoursSpent = $this->actualTotalHours - $this->totalHours; - $this->actualDaysSpent = $this->actualTotalDays - $this->totalDays; - // calculate the projects actual time frame of completion - $this->projectWeekTime = round($this->actualTotalDays / 5, 1); - $this->projectMonthTime = round($this->actualTotalDays / 24, 1); + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + JText::sprintf('

%s Warning

', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + JText::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); } private function buildReadMe() @@ -864,7 +847,7 @@ class Compiler extends Infusion { if (('README.md' === $static['name'] || 'README.txt' === $static['name']) - && $this->componentData->addreadme + && CFactory::_('Component')->get('addreadme') && File::exists($static['path'])) { $this->setReadMe($static['path']); @@ -882,10 +865,9 @@ class Compiler extends Infusion { // set readme data if not set already if (!CFactory::_('Content')->exist('LINE_COUNT') - || CFactory::_('Content')->get('LINE_COUNT') - != $this->lineCount) + || CFactory::_('Content')->get('LINE_COUNT') != CFactory::_('Counter')->line) { - $this->buildReadMeData(); + CFactory::_('Counter')->set(); } // get the file $string = FileHelper::getContent($path); @@ -895,42 +877,23 @@ class Compiler extends Infusion $this->writeFile($path, $answer); } + /** + * Build README data + * + * @return void + * @deprecated 3.3 + */ private function buildReadMeData() { - // set some defaults - CFactory::_('Content')->set('LINE_COUNT', $this->lineCount); - CFactory::_('Content')->set('FIELD_COUNT', $this->fieldCount); - CFactory::_('Content')->set('FILE_COUNT', $this->fileCount); - CFactory::_('Content')->set('FOLDER_COUNT', $this->folderCount); - CFactory::_('Content')->set('PAGE_COUNT', $this->pageCount); - CFactory::_('Content')->set('folders', $this->folderSeconds); - CFactory::_('Content')->set('foldersSeconds', $this->folderSeconds); - CFactory::_('Content')->set('files', $this->fileSeconds); - CFactory::_('Content')->set('filesSeconds', $this->fileSeconds); - CFactory::_('Content')->set('lines', $this->lineSeconds); - CFactory::_('Content')->set('linesSeconds', $this->lineSeconds); - CFactory::_('Content')->set('seconds', $this->actualSeconds); - CFactory::_('Content')->set('actualSeconds', $this->actualSeconds); - CFactory::_('Content')->set('totalHours', $this->totalHours); - CFactory::_('Content')->set('totalDays', $this->totalDays); - CFactory::_('Content')->set('debugging', $this->secondsDebugging); - CFactory::_('Content')->set('secondsDebugging', $this->secondsDebugging); - CFactory::_('Content')->set('planning', $this->secondsPlanning); - CFactory::_('Content')->set('secondsPlanning', $this->secondsPlanning); - CFactory::_('Content')->set('mapping', $this->secondsMapping); - CFactory::_('Content')->set('secondsMapping', $this->secondsMapping); - CFactory::_('Content')->set('office', $this->secondsOffice); - CFactory::_('Content')->set('secondsOffice', $this->secondsOffice); - CFactory::_('Content')->set('actualTotalHours', $this->actualTotalHours); - CFactory::_('Content')->set('actualTotalDays', $this->actualTotalDays); - CFactory::_('Content')->set('debuggingHours', $this->debuggingHours); - CFactory::_('Content')->set('planningHours', $this->planningHours); - CFactory::_('Content')->set('mappingHours', $this->mappingHours); - CFactory::_('Content')->set('officeHours', $this->officeHours); - CFactory::_('Content')->set('actualHoursSpent', $this->actualHoursSpent); - CFactory::_('Content')->set('actualDaysSpent', $this->actualDaysSpent); - CFactory::_('Content')->set('projectWeekTime', $this->projectWeekTime); - CFactory::_('Content')->set('projectMonthTime', $this->projectMonthTime); + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + JText::sprintf('

%s Warning

', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + JText::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); } private function setLocalRepos() @@ -943,7 +906,7 @@ class Compiler extends Infusion { // set the repo path $repoFullPath = $this->repoPath . '/com_' - . $this->componentData->sales_name . '__joomla_' + . CFactory::_('Component')->get('sales_name') . '__joomla_' . CFactory::_('Config')->get('version', 3); // for plugin event TODO change event api signatures $component_context = CFactory::_('Config')->component_context; @@ -954,7 +917,7 @@ class Compiler extends Infusion &$repoFullPath, &$this->componentData) ); // remove old data - $this->removeFolder($repoFullPath, $this->componentData->toignore); + $this->removeFolder($repoFullPath, CFactory::_('Component')->get('toignore')); // set the new data Folder::copy($this->componentPath, $repoFullPath, '', true); // Trigger Event: jcb_ce_onAfterUpdateRepo @@ -965,9 +928,9 @@ class Compiler extends Infusion ); // move the modules to local folder repos - if (ArrayHelper::check($this->joomlaModules)) + if (CFactory::_('Joomlamodule.Data')->exists()) { - foreach ($this->joomlaModules as $module) + foreach (CFactory::_('Joomlamodule.Data')->get() as $module) { if (ObjectHelper::check($module) && isset($module->file_name)) @@ -986,7 +949,7 @@ class Compiler extends Infusion ); // remove old data $this->removeFolder( - $repoFullPath, $this->componentData->toignore + $repoFullPath, CFactory::_('Component')->get('toignore') ); // set the new data Folder::copy( @@ -1002,9 +965,9 @@ class Compiler extends Infusion } } // move the plugins to local folder repos - if (ArrayHelper::check($this->joomlaPlugins)) + if (CFactory::_('Joomlaplugin.Data')->exists()) { - foreach ($this->joomlaPlugins as $plugin) + foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin) { if (ObjectHelper::check($plugin) && isset($plugin->file_name)) @@ -1023,7 +986,7 @@ class Compiler extends Infusion ); // remove old data $this->removeFolder( - $repoFullPath, $this->componentData->toignore + $repoFullPath, CFactory::_('Component')->get('toignore') ); // set the new data Folder::copy( @@ -1081,11 +1044,11 @@ class Compiler extends Infusion ); } // move to sales server host - if ($this->componentData->add_sales_server == 1 + if (CFactory::_('Component')->get('add_sales_server', 0) == 1 && $this->dynamicIntegration) { // make sure we have the correct file - if (isset($this->componentData->sales_server)) + if (CFactory::_('Component')->get('sales_server')) { // Trigger Event: jcb_ce_onBeforeMoveToServer CFactory::_('Event')->trigger( @@ -1098,8 +1061,8 @@ class Compiler extends Infusion ComponentbuilderHelper::moveToServer( $this->filepath['component'], $this->componentSalesName . '.zip', - (int) $this->componentData->sales_server, - $this->componentData->sales_server_protocol + (int) CFactory::_('Component')->get('sales_server'), + CFactory::_('Component')->get('sales_server_protocol') ); } } @@ -1122,9 +1085,9 @@ class Compiler extends Infusion private function zipModules() { - if (ArrayHelper::check($this->joomlaModules)) + if (CFactory::_('Joomlamodule.Data')->exists()) { - foreach ($this->joomlaModules as $module) + foreach (CFactory::_('Joomlamodule.Data')->get() as $module) { if (ObjectHelper::check($module) && isset($module->zip_name) @@ -1216,9 +1179,9 @@ class Compiler extends Infusion private function zipPlugins() { - if (ArrayHelper::check($this->joomlaPlugins)) + if (CFactory::_('Joomlaplugin.Data')->exists()) { - foreach ($this->joomlaPlugins as $plugin) + foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin) { if (ObjectHelper::check($plugin) && isset($plugin->zip_name) diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index 90227ae4e..d6ed9f0bd 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -13,27 +13,18 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -use Joomla\CMS\Filesystem\File; -use Joomla\CMS\Filesystem\Folder; -use VDM\Joomla\Utilities\GuidHelper; use VDM\Joomla\Utilities\StringHelper; use VDM\Joomla\Utilities\JsonHelper; use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\ObjectHelper; -use VDM\Joomla\Utilities\GetHelper; -use VDM\Joomla\Utilities\FileHelper; -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; use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Unique; /** * Get class as the main compilers class + * @deprecated 3.3 */ class Get { @@ -200,6 +191,7 @@ class Get * The Component data * * @var object + * @deprecated 3.3 Use CFactory::_('Component'); */ public $componentData; @@ -238,6 +230,7 @@ class Get * The Plugins data * * @var array + * @deprecated 3.3 Use CFactory::_('Joomlaplugin.Data')->get(); */ public $joomlaPlugins = array(); @@ -245,6 +238,7 @@ class Get * The Modules data * * @var array + * @deprecated 3.3 Use CFactory::_('Joomlamodule.Data')->get(); */ public $joomlaModules = array(); @@ -280,7 +274,6 @@ class Get * ////////23 is the ID of the code in the system don't change it!!!!!!!!!!!!!!!!!!!!!!!!!! * * @var array - * * @deprecated 3.3 */ protected $customCodePlaceholders @@ -607,7 +600,7 @@ class Get * The site edit views * * @var array - * @deprecated 3.3 Use CFactory::_('Registry')->get('builder.site_edit_view.'); + * @deprecated 3.3 Use CFactory::_('Registry')->get('builder.site_edit_view'); */ public $siteEditView = []; @@ -1114,27 +1107,30 @@ class Get 'jcb_ce_onBeforeGetComponentData', array(&$component_context, &$this) ); - // get the component data - $this->componentData = $this->getComponentData(); + + // get the component data @deprecated + $this->componentData = CFactory::_('Component'); + // Trigger Event: jcb_ce_onAfterGetComponentData CFactory::_('Event')->trigger( 'jcb_ce_onAfterGetComponentData', array(&$component_context, &$this) ); + // make sure we have a version - if (strpos((string) $this->componentData->component_version, '.') + if (strpos((string) CFactory::_('Component')->component_version, '.') === false) { - $this->componentData->component_version = '1.0.0'; + CFactory::_('Component')->set('component_version ', '1.0.0'); } // update the version - if (!isset($this->componentData->old_component_version) + if (!CFactory::_('Component')->exists('old_component_version') && (CFactory::_('Registry')->get('builder.add_sql', null) || CFactory::_('Registry')->get('builder.update_sql', null))) { // set the new version $version = (array) explode( - '.', (string) $this->componentData->component_version + '.', (string) CFactory::_('Component')->component_version ); // get last key end($version); @@ -1142,13 +1138,13 @@ class Get // just increment the last $version[$key]++; // set the old version - $this->componentData->old_component_version - = $this->componentData->component_version; + CFactory::_('Component')->set('old_component_version', CFactory::_('Component')->component_version); // set the new version, and set update switch - $this->componentData->component_version = implode( + CFactory::_('Component')->set('component_version ', implode( '.', $version - ); + )); } + // get powers *+*+*+*+*+*+*+*PRO CFactory::_('Power')->load($this->linkedPowers); // set the percentage when a language can be added @@ -1206,880 +1202,12 @@ class Get /** * get all Component Data * - * @param int $id The component ID - * * @return oject The component data - * + * @deprecated 3.3 Use CFactory::_('Component'); */ public function getComponentData() { - // Create a new query object. - $query = $this->db->getQuery(true); - // selection - $selection = array( - 'b.addadmin_views' => 'addadmin_views', - 'b.id' => 'addadmin_views_id', - 'h.addconfig' => 'addconfig', - 'd.addcustom_admin_views' => 'addcustom_admin_views', - 'g.addcustommenus' => 'addcustommenus', - 'j.addfiles' => 'addfiles', - 'j.addfolders' => 'addfolders', - 'j.addfilesfullpath' => 'addfilesfullpath', - 'j.addfoldersfullpath' => 'addfoldersfullpath', - 'c.addsite_views' => 'addsite_views', - 'l.addjoomla_plugins' => 'addjoomla_plugins', - 'k.addjoomla_modules' => 'addjoomla_modules', - 'i.dashboard_tab' => 'dashboard_tab', - 'i.php_dashboard_methods' => 'php_dashboard_methods', - 'i.params' => 'dashboard_params', - 'i.id' => 'component_dashboard_id', - 'f.sql_tweak' => 'sql_tweak', - 'e.version_update' => 'version_update', - 'e.id' => 'version_update_id' - ); - $query->select('a.*'); - $query->select( - $this->db->quoteName( - array_keys($selection), array_values($selection) - ) - ); - // from this table - $query->from('#__componentbuilder_joomla_component AS a'); - // jointer-map - $joiners = array( - 'b' => 'component_admin_views', - 'c' => 'component_site_views', - 'd' => 'component_custom_admin_views', - 'e' => 'component_updates', - 'f' => 'component_mysql_tweaks', - 'g' => 'component_custom_admin_menus', - 'h' => 'component_config', - 'i' => 'component_dashboard', - 'j' => 'component_files_folders', - 'l' => 'component_plugins', - 'k' => 'component_modules' - ); - // load the joins - foreach ($joiners as $as => $join) - { - $query->join( - 'LEFT', - $this->db->quoteName('#__componentbuilder_' . $join, $as) - . ' ON (' . $this->db->quoteName('a.id') . ' = ' - . $this->db->quoteName($as . '.joomla_component') . ')' - ); - } - $query->where( - $this->db->quoteName('a.id') . ' = ' . (int) CFactory::_('Config')->component_id - ); - // for plugin event TODO change event api signatures - $component_context = CFactory::_('Config')->component_context; - $component_id = CFactory::_('Config')->component_id; - // Trigger Event: jcb_ce_onBeforeQueryComponentData - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeQueryComponentData', - array(&$component_context, &$component_id, &$query, - &$this->db) - ); - - // Reset the query using our newly populated query object. - $this->db->setQuery($query); - - // Load the results as a list of stdClass objects - $component = $this->db->loadObject(); - - // Trigger Event: jcb_ce_onBeforeModelComponentData - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeModelComponentData', - array(&$component_context, &$component) - ); - - // load the global placeholders - CFactory::_('Placeholder')->active = CFactory::_('Component.Placeholder')->get(); - - // set component sales name - $component->sales_name = StringHelper::safe( - $component->system_name - ); - - // set the component name_code - $component->name_code = StringHelper::safe( - $component->name_code - ); - - // ensure version naming is correct - CFactory::_('Config')->set('component_version', preg_replace( - '/[^0-9.]+/', '', (string) $component->component_version - ) - ); - - // set the add targets - $addArrayF = array('files' => 'files', - 'folders' => 'folders', - 'filesfullpath' => 'files', - 'foldersfullpath' => 'folders'); - foreach ($addArrayF as $addTarget => $targetHere) - { - // set the add target data - $component->{'add' . $addTarget} = (isset( - $component->{'add' . $addTarget} - ) - && JsonHelper::check( - $component->{'add' . $addTarget} - )) ? json_decode((string) $component->{'add' . $addTarget}, true) : null; - if (ArrayHelper::check( - $component->{'add' . $addTarget} - )) - { - if (isset($component->{$targetHere}) - && ArrayHelper::check( - $component->{$targetHere} - )) - { - foreach ($component->{'add' . $addTarget} as $taget) - { - $component->{$targetHere}[] = $taget; - } - } - else - { - $component->{$targetHere} = array_values( - $component->{'add' . $addTarget} - ); - } - } - unset($component->{'add' . $addTarget}); - } - - // set the uikit switch - CFactory::_('Config')->set('uikit', $component->adduikit); - - // set whmcs links if needed - if (1 == $component->add_license - && (!isset($component->whmcs_buy_link) - || !StringHelper::check( - $component->whmcs_buy_link - ))) - { - // update with the whmcs url - if (isset($component->whmcs_url) - && StringHelper::check($component->whmcs_url)) - { - $component->whmcs_buy_link = $component->whmcs_url; - } - // use the company website - elseif (isset($component->website) - && StringHelper::check($component->website)) - { - $component->whmcs_buy_link = $component->website; - $component->whmcs_url = rtrim((string) $component->website, '/') - . '/whmcs'; - } - // none set - else - { - $component->whmcs_buy_link = '#'; - $component->whmcs_url = '#'; - } - } - // since the license details are not set clear - elseif (0 == $component->add_license) - { - $component->whmcs_key = ''; - $component->whmcs_buy_link = ''; - $component->whmcs_url = ''; - } - - // set the footable switch - if ($component->addfootable) - { - // force add footable - CFactory::_('Config')->set('footable ', true); - // add the version - CFactory::_('Config')->set('footable_version', (3 == $component->addfootable) ? 3 : 2); - } - - // set the addcustommenus data - $component->addcustommenus = (isset($component->addcustommenus) - && JsonHelper::check($component->addcustommenus)) - ? json_decode((string) $component->addcustommenus, true) : null; - if (ArrayHelper::check($component->addcustommenus)) - { - $component->custommenus = array_values($component->addcustommenus); - } - unset($component->addcustommenus); - - // set the sql_tweak data - $component->sql_tweak = (isset($component->sql_tweak) - && JsonHelper::check($component->sql_tweak)) - ? json_decode((string) $component->sql_tweak, true) : null; - if (ArrayHelper::check($component->sql_tweak)) - { - // build the tweak settings - $this->setSqlTweaking( - array_map( - function ($array) { - return array_map( - function ($value) { - if (!ArrayHelper::check($value) - && !ObjectHelper::check( - $value - ) - && strval($value) === strval( - intval($value) - )) - { - return (int) $value; - } - - return $value; - }, $array - ); - }, array_values($component->sql_tweak) - ) - ); - } - unset($component->sql_tweak); - - // set the admin_view data - $component->addadmin_views = (isset($component->addadmin_views) - && JsonHelper::check($component->addadmin_views)) - ? json_decode((string) $component->addadmin_views, true) : null; - if (ArrayHelper::check($component->addadmin_views)) - { - CFactory::_('Config')->lang_target = 'admin'; - CFactory::_('Config')->build_target = 'admin'; - // sort the views according to order - usort( - $component->addadmin_views, function ($a, $b) { - if ($a['order'] != 0 && $b['order'] != 0) - { - return $a['order'] - $b['order']; - } - elseif ($b['order'] != 0 && $a['order'] == 0) - { - return 1; - } - elseif ($a['order'] != 0 && $b['order'] == 0) - { - return 0; - } - - return 1; - } - ); - // build the admin_views settings - $component->admin_views = array_map( - function ($array) { - $array = array_map( - function ($value) { - if (!ArrayHelper::check($value) - && !ObjectHelper::check($value) - && strval($value) === strval(intval($value))) - { - return (int) $value; - } - - return $value; - }, $array - ); - // check if we must add to site - if (isset($array['edit_create_site_view']) - && is_numeric( - $array['edit_create_site_view'] - ) - && $array['edit_create_site_view'] > 0) - { - CFactory::_('Registry')->set('builder.site_edit_view.' . $array['adminview'], true); - CFactory::_('Config')->lang_target = 'both'; - } - // set the import/export option for this view - if (isset($array['port']) && $array['port']) - { - CFactory::_('Config')->set('add_eximport', true); - } - // set the history tracking option for this view - if (isset($array['history']) && $array['history']) - { - CFactory::_('Config')->set('set_tag_history', true); - } - // set the custom field integration for this view - if (isset($array['joomla_fields']) && $array['joomla_fields']) - { - CFactory::_('Config')->set('set_joomla_fields', true); - } - // has become a legacy issue, can't remove this - $array['view'] = $array['adminview']; - // get the admin settings/data - $array['settings'] = $this->getAdminViewData( - $array['view'] - ); - // set the filter option for this view - CFactory::_('Registry')-> // Side (old) [default for now] - set('builder.admin_filter_type.' . $array['settings']->name_list_code, - 1); - if (isset($array['filter']) - && is_numeric( - $array['filter'] - ) && $array['filter'] > 0) - { - CFactory::_('Registry')-> - set('builder.admin_filter_type.' . $array['settings']->name_list_code, - (int) $array['filter']); - } - - return $array; - }, array_values($component->addadmin_views) - ); - } - // set the site_view data - $component->addsite_views = (isset($component->addsite_views) - && JsonHelper::check($component->addsite_views)) - ? json_decode((string) $component->addsite_views, true) : null; - if (ArrayHelper::check($component->addsite_views)) - { - CFactory::_('Config')->lang_target = 'site'; - CFactory::_('Config')->build_target = 'site'; - // build the site_views settings - $component->site_views = array_map( - function ($array) { - // has become a legacy issue, can't remove this - $array['view'] = $array['siteview']; - $array['settings'] = $this->getCustomViewData( - $array['view'] - ); - - return array_map( - function ($value) { - if (!ArrayHelper::check($value) - && !ObjectHelper::check($value) - && strval($value) === strval(intval($value))) - { - return (int) $value; - } - - return $value; - }, $array - ); - }, array_values($component->addsite_views) - ); - // unset original value - unset($component->addsite_views); - } - - // set the custom_admin_views data - $component->addcustom_admin_views - = (isset($component->addcustom_admin_views) - && JsonHelper::check( - $component->addcustom_admin_views - )) ? json_decode((string) $component->addcustom_admin_views, true) : null; - if (ArrayHelper::check( - $component->addcustom_admin_views - )) - { - CFactory::_('Config')->lang_target = 'admin'; - CFactory::_('Config')->build_target = 'custom_admin'; - // build the custom_admin_views settings - $component->custom_admin_views = array_map( - function ($array) { - // has become a legacy issue, can't remove this - $array['view'] = $array['customadminview']; - $array['settings'] = $this->getCustomViewData( - $array['view'], 'custom_admin_view' - ); - - return array_map( - function ($value) { - if (!ArrayHelper::check($value) - && !ObjectHelper::check($value) - && strval($value) === strval(intval($value))) - { - return (int) $value; - } - - return $value; - }, $array - ); - }, array_values($component->addcustom_admin_views) - ); - // unset original value - unset($component->addcustom_admin_views); - } - - // set the config data - $component->addconfig = (isset($component->addconfig) - && JsonHelper::check($component->addconfig)) - ? json_decode((string) $component->addconfig, true) : null; - if (ArrayHelper::check($component->addconfig)) - { - $component->config = array_map( - function ($field) { - // make sure the alias and title is 0 - $field['alias'] = 0; - $field['title'] = 0; - // set the field details - CFactory::_('Field')->set($field); - // set unique name counter - CFactory::_('Field.Unique.Name')->set($field['base_name'], 'configs'); - - // return field - return $field; - }, array_values($component->addconfig) - ); - - // do some house cleaning (for fields) - foreach ($component->config as $field) - { - // so first we lock the field name in - CFactory::_('Field.Name')->get($field, 'configs'); - } - // unset original value - unset($component->addconfig); - } - - // set the add contributors - $component->addcontributors = (isset($component->addcontributors) - && JsonHelper::check($component->addcontributors)) - ? json_decode((string) $component->addcontributors, true) : null; - if (ArrayHelper::check($component->addcontributors)) - { - CFactory::_('Config')->set('add_contributors', true); - $component->contributors = array_values( - $component->addcontributors - ); - } - unset($component->addcontributors); - - // set the version updates - $component->version_update = (isset($component->version_update) - && JsonHelper::check($component->version_update)) - ? json_decode((string) $component->version_update, true) : null; - if (ArrayHelper::check($component->version_update)) - { - $component->version_update = array_values( - $component->version_update - ); - } - - // build update SQL - $old_admin_views = CFactory::_('History')->get( - 'component_admin_views', $component->addadmin_views_id - ); - $old_component = CFactory::_('History')->get( - 'joomla_component', CFactory::_('Config')->component_id - ); - if ($old_component || $old_admin_views) - { - if (ObjectHelper::check($old_admin_views)) - { - // add new views if found - if (isset($old_admin_views->addadmin_views) - && JsonHelper::check( - $old_admin_views->addadmin_views - )) - { - $this->setUpdateSQL( - json_decode((string) $old_admin_views->addadmin_views, true), - $component->addadmin_views, 'adminview' - ); - } - // check if a new version was manually set - if (ObjectHelper::check($old_component)) - { - $old_component_version = preg_replace( - '/[^0-9.]+/', '', (string) $old_component->component_version - ); - if ($old_component_version != CFactory::_('Config')->component_version) - { - // yes, this is a new version, this mean there may be manual sql and must be checked and updated - $component->old_component_version - = $old_component_version; - } - // clear this data - unset($old_component); - } - // clear this data - unset($old_admin_views); - } - } - // unset original value - unset($component->addadmin_views); - - // set GUI mapper - $guiMapper = array('table' => 'joomla_component', - 'id' => (int) CFactory::_('Config')->component_id, - 'field' => 'javascript', 'type' => 'js'); - - // add_javascript - if ($component->add_javascript == 1) - { - CFactory::_('Customcode.Dispenser')->set( - $component->javascript, - 'component_js', - null, - null, - $guiMapper - ); - } - else - { - CFactory::_('Customcode.Dispenser')->hub['component_js'] = ''; - } - unset($component->javascript); - - // add global CSS - $addGlobalCss = array('admin', 'site'); - foreach ($addGlobalCss as $area) - { - // add_css if found - if (isset($component->{'add_css_' . $area}) - && $component->{'add_css_' . $area} == 1 - && isset($component->{'css_' . $area}) - && StringHelper::check( - $component->{'css_' . $area} - )) - { - CFactory::_('Customcode.Dispenser')->set( - $component->{'css_' . $area}, - 'component_css_' . $area - ); - } - else - { - CFactory::_('Customcode.Dispenser')->hub['component_css_' . $area] = ''; - } - unset($component->{'css_' . $area}); - } - // set the lang target - CFactory::_('Config')->lang_target = 'admin'; - // add PHP in ADMIN - $addScriptMethods = array('php_preflight', 'php_postflight', - 'php_method'); - $addScriptTypes = array('install', 'update', 'uninstall'); - // update GUI mapper - $guiMapper['type'] = 'php'; - foreach ($addScriptMethods as $scriptMethod) - { - foreach ($addScriptTypes as $scriptType) - { - if (isset( - $component->{'add_' . $scriptMethod . '_' . $scriptType} - ) - && $component->{'add_' . $scriptMethod . '_' . $scriptType} - == 1 - && StringHelper::check( - $component->{$scriptMethod . '_' . $scriptType} - )) - { - // set GUI mapper field - $guiMapper['field'] = $scriptMethod . '_' . $scriptType; - CFactory::_('Customcode.Dispenser')->set( - $component->{$scriptMethod . '_' . $scriptType}, - $scriptMethod, - $scriptType, - null, - $guiMapper - ); - } - else - { - CFactory::_('Customcode.Dispenser')->hub[$scriptMethod][$scriptType] = ''; - } - unset($component->{$scriptMethod . '_' . $scriptType}); - } - } - // add_php_helper - if ($component->add_php_helper_admin == 1 - && StringHelper::check( - $component->php_helper_admin - )) - { - CFactory::_('Config')->lang_target = 'admin'; - // update GUI mapper - $guiMapper['field'] = 'php_helper_admin'; - $guiMapper['prefix'] = PHP_EOL . PHP_EOL; - CFactory::_('Customcode.Dispenser')->set( - $component->php_helper_admin, - 'component_php_helper_admin', - null, - null, - $guiMapper - ); - unset($guiMapper['prefix']); - } - else - { - CFactory::_('Customcode.Dispenser')->hub['component_php_helper_admin'] = ''; - } - unset($component->php_helper); - // add_admin_event - if ($component->add_admin_event == 1 - && StringHelper::check($component->php_admin_event)) - { - CFactory::_('Config')->lang_target = 'admin'; - // update GUI mapper field - $guiMapper['field'] = 'php_admin_event'; - CFactory::_('Customcode.Dispenser')->set( - $component->php_admin_event, - 'component_php_admin_event', - null, - null, - $guiMapper - ); - } - else - { - CFactory::_('Customcode.Dispenser')->hub['component_php_admin_event'] = ''; - } - unset($component->php_admin_event); - // add_php_helper_both - if ($component->add_php_helper_both == 1 - && StringHelper::check($component->php_helper_both)) - { - CFactory::_('Config')->lang_target = 'both'; - // update GUI mapper field - $guiMapper['field'] = 'php_helper_both'; - $guiMapper['prefix'] = PHP_EOL . PHP_EOL; - CFactory::_('Customcode.Dispenser')->set( - $component->php_helper_both, - 'component_php_helper_both', - null, - null, - $guiMapper - ); - unset($guiMapper['prefix']); - } - else - { - CFactory::_('Customcode.Dispenser')->hub['component_php_helper_both'] = ''; - } - // add_php_helper_site - if ($component->add_php_helper_site == 1 - && StringHelper::check($component->php_helper_site)) - { - CFactory::_('Config')->lang_target = 'site'; - // update GUI mapper field - $guiMapper['field'] = 'php_helper_site'; - $guiMapper['prefix'] = PHP_EOL . PHP_EOL; - CFactory::_('Customcode.Dispenser')->set( - $component->php_helper_site, - 'component_php_helper_site', - null, - null, - $guiMapper - ); - unset($guiMapper['prefix']); - } - else - { - CFactory::_('Customcode.Dispenser')->hub['component_php_helper_site'] = ''; - } - unset($component->php_helper); - // add_site_event - if ($component->add_site_event == 1 - && StringHelper::check($component->php_site_event)) - { - CFactory::_('Config')->lang_target = 'site'; - // update GUI mapper field - $guiMapper['field'] = 'php_site_event'; - CFactory::_('Customcode.Dispenser')->set( - $component->php_site_event, - 'component_php_site_event', - null, - null, - $guiMapper - ); - } - else - { - CFactory::_('Customcode.Dispenser')->hub['component_php_site_event'] = ''; - } - unset($component->php_site_event); - // add_sql - if ($component->add_sql == 1) - { - CFactory::_('Customcode.Dispenser')->set( - $component->sql, - 'sql', - 'component_sql' - ); - } - unset($component->sql); - // add_sql_uninstall - if ($component->add_sql_uninstall == 1) - { - CFactory::_('Customcode.Dispenser')->set( - $component->sql_uninstall, - 'sql_uninstall' - ); - } - unset($component->sql_uninstall); - // bom - if (StringHelper::check($component->bom)) - { - CFactory::_('Config')->set('bom_path', - CFactory::_('Config')->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/' . $component->bom - ); - } - unset($component->bom); - // README - if ($component->addreadme) - { - $component->readme = CFactory::_('Customcode')->update( - base64_decode((string) $component->readme) - ); - } - else - { - $component->readme = ''; - } - - // set lang now - $nowLang = CFactory::_('Config')->lang_target; - CFactory::_('Config')->lang_target = 'admin'; - // dashboard methods - $component->dashboard_tab = (isset($component->dashboard_tab) - && JsonHelper::check($component->dashboard_tab)) - ? json_decode((string) $component->dashboard_tab, true) : null; - if (ArrayHelper::check($component->dashboard_tab)) - { - $component->dashboard_tab = array_map( - function ($array) { - $array['html'] = CFactory::_('Customcode')->update($array['html']); - - return $array; - }, array_values($component->dashboard_tab) - ); - } - else - { - $component->dashboard_tab = ''; - } - // add the php of the dashboard if set - if (isset($component->php_dashboard_methods) - && StringHelper::check( - $component->php_dashboard_methods - )) - { - // load the php for the dashboard model - $component->php_dashboard_methods = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->update( - base64_decode((string) $component->php_dashboard_methods) - ), - array( - 'table' => 'component_dashboard', - 'field' => 'php_dashboard_methods', - 'id' => (int) $component->component_dashboard_id, - 'type' => 'php') - ); - } - else - { - $component->php_dashboard_methods = ''; - } - // reset back to now lang - CFactory::_('Config')->lang_target = $nowLang; - - // add the update/sales server FTP details if that is the expected protocol - $serverArray = array('update_server', 'sales_server'); - foreach ($serverArray as $server) - { - if ($component->{'add_' . $server} == 1 - && is_numeric( - $component->{$server} - ) - && $component->{$server} > 0) - { - // get the server protocol - $component->{$server . '_protocol'} - = GetHelper::var( - 'server', (int) $component->{$server}, 'id', 'protocol' - ); - } - else - { - $component->{$server} = 0; - // only change this for sales server (update server can be added loacaly to the zip file) - if ('sales_server' === $server) - { - $component->{'add_' . $server} = 0; - } - $component->{$server . '_protocol'} = 0; - } - } - // set the ignore folders for repo if found - if (isset($component->toignore) - && StringHelper::check( - $component->toignore - )) - { - if (strpos((string) $component->toignore, ',') !== false) - { - $component->toignore = array_map( - 'trim', (array) explode(',', (string) $component->toignore) - ); - } - else - { - $component->toignore = array(trim((string) $component->toignore)); - } - } - else - { - // the default is to ignore the repo folder - $component->toignore = array('.git'); - } - // get all modules - $component->addjoomla_modules = (isset($component->addjoomla_modules) - && JsonHelper::check($component->addjoomla_modules)) - ? json_decode((string) $component->addjoomla_modules, true) : null; - if (ArrayHelper::check($component->addjoomla_modules)) - { - $joomla_modules = array_map( - function ($array) use (&$component) { - // only load the modules whose target association calls for it - if (!isset($array['target']) || $array['target'] != 2) - { - return $this->setJoomlaModule( - $array['module'], $component - ); - } - - return null; - }, array_values($component->addjoomla_modules) - ); - } - unset($component->addjoomla_modules); - // get all plugins - $component->addjoomla_plugins = (isset($component->addjoomla_plugins) - && JsonHelper::check($component->addjoomla_plugins)) - ? json_decode((string) $component->addjoomla_plugins, true) : null; - if (ArrayHelper::check($component->addjoomla_plugins)) - { - $joomla_plugins = array_map( - function ($array) use (&$component) { - // only load the plugins whose target association calls for it - if (!isset($array['target']) || $array['target'] != 2) - { - return $this->setJoomlaPlugin( - $array['plugin'], $component - ); - } - - return null; - }, array_values($component->addjoomla_plugins) - ); - } - unset($component->addjoomla_plugins); - - // Trigger Event: jcb_ce_onAfterModelComponentData - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterModelComponentData', - array(&$component_context, &$component) - ); - - // return the found component data - return $component; + return CFactory::_('Component'); } /** @@ -2124,1130 +1252,11 @@ class Get * @param int $id The view ID * * @return oject The view data - * + * @deprecated 3.3 Use CFactory::_('Adminview.Data')->get($id); */ public function getAdminViewData($id) { - if (!isset($this->_adminViewData[$id])) - { - // Create a new query object. - $query = $this->db->getQuery(true); - - $query->select('a.*'); - $query->select( - $this->db->quoteName( - array( - 'b.addfields', - 'b.id', - 'c.addconditions', - 'c.id', - 'r.addrelations', - 't.tabs' - ), array( - 'addfields', - 'addfields_id', - 'addconditions', - 'addconditions_id', - 'addrelations', - 'customtabs' - ) - ) - ); - $query->from('#__componentbuilder_admin_view AS a'); - $query->join( - 'LEFT', - $this->db->quoteName('#__componentbuilder_admin_fields', 'b') - . ' ON (' . $this->db->quoteName('a.id') . ' = ' - . $this->db->quoteName('b.admin_view') . ')' - ); - $query->join( - 'LEFT', $this->db->quoteName( - '#__componentbuilder_admin_fields_conditions', 'c' - ) . ' ON (' . $this->db->quoteName('a.id') . ' = ' - . $this->db->quoteName('c.admin_view') . ')' - ); - $query->join( - 'LEFT', $this->db->quoteName( - '#__componentbuilder_admin_fields_relations', 'r' - ) . ' ON (' . $this->db->quoteName('a.id') . ' = ' - . $this->db->quoteName('r.admin_view') . ')' - ); - $query->join( - 'LEFT', $this->db->quoteName( - '#__componentbuilder_admin_custom_tabs', 't' - ) . ' ON (' . $this->db->quoteName('a.id') . ' = ' - . $this->db->quoteName('t.admin_view') . ')' - ); - $query->where($this->db->quoteName('a.id') . ' = ' . (int) $id); - - // for plugin event TODO change event api signatures - $component_context = CFactory::_('Config')->component_context; - // Trigger Event: jcb_ce_onBeforeQueryViewData - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeQueryViewData', - array(&$component_context, &$id, &$query, &$this->db) - ); - - // Reset the query using our newly populated query object. - $this->db->setQuery($query); - - // Load the results as a list of stdClass objects (see later for more options on retrieving data). - $view = $this->db->loadObject(); - - // setup single view code names to use in storing the data - $view->name_single_code = 'oops_hmm_' . $id; - if (isset($view->name_single) && $view->name_single != 'null') - { - $view->name_single_code = StringHelper::safe( - $view->name_single - ); - } - - // setup list view code name to use in storing the data - $view->name_list_code = 'oops_hmmm_' . $id; - if (isset($view->name_list) && $view->name_list != 'null') - { - $view->name_list_code = StringHelper::safe( - $view->name_list - ); - } - - // check the length of the view name (+5 for com_ and _) - $name_length = CFactory::_('Config')->component_code_name_length + strlen( - (string) $view->name_single_code - ) + 5; - // when the name is larger than 49 we need to add the assets' table name fix - if ($name_length > 49) - { - CFactory::_('Config')->set('add_assets_table_name_fix', true); - } - - // set updater - $updater = array( - 'unique' => array( - 'addfields' => array('table' => 'admin_fields', - 'val' => (int) $view->addfields_id, - 'key' => 'id'), - 'addconditions' => array('table' => 'admin_fields_conditions', - 'val' => (int) $view->addconditions_id, - 'key' => 'id') - ), - 'table' => 'admin_view', - 'key' => 'id', - 'val' => (int) $id - ); - // repeatable fields to update - $searchRepeatables = array( - // repeatablefield => checker - 'addfields' => 'field', - 'addconditions' => 'target_field', - 'ajax_input' => 'value_name', - 'custom_button' => 'name', - 'addlinked_views' => 'adminview', - 'addtables' => 'table', - 'addtabs' => 'name', - 'addpermissions' => 'action' - ); - // update the repeatable fields - $view = ComponentbuilderHelper::convertRepeatableFields( - $view, $searchRepeatables, $updater - ); - - // setup token check - if (!isset(CFactory::_('Customcode.Dispenser')->hub['token'])) - { - CFactory::_('Customcode.Dispenser')->hub['token'] = []; - } - CFactory::_('Customcode.Dispenser')->hub['token'][$view->name_single_code] - = false; - CFactory::_('Customcode.Dispenser')->hub['token'][$view->name_list_code] = false; - - // set some placeholders - CFactory::_('Placeholder')->set('view', $view->name_single_code); - CFactory::_('Placeholder')->set('views', $view->name_list_code); - CFactory::_('Placeholder')->set('View', StringHelper::safe( - $view->name_single, 'F' - )); - CFactory::_('Placeholder')->set('Views', StringHelper::safe( - $view->name_list, 'F' - )); - CFactory::_('Placeholder')->set('VIEW', StringHelper::safe( - $view->name_single, 'U' - )); - CFactory::_('Placeholder')->set('VIEWS', StringHelper::safe( - $view->name_list, 'U' - )); - - // for plugin event TODO change event api signatures - $placeholders = CFactory::_('Placeholder')->active; - $component_context = CFactory::_('Config')->component_context; - // Trigger Event: jcb_ce_onBeforeModelViewData - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeModelViewData', - array(&$component_context, &$view, &$placeholders) - ); - unset($placeholders); - - // add the tables - $view->addtables = (isset($view->addtables) - && JsonHelper::check($view->addtables)) - ? json_decode((string) $view->addtables, true) : null; - if (ArrayHelper::check($view->addtables)) - { - $view->tables = array_values($view->addtables); - } - unset($view->addtables); - - // set custom tabs - $view->customtabs = (isset($view->customtabs) - && JsonHelper::check($view->customtabs)) - ? json_decode((string) $view->customtabs, true) : null; - if (ArrayHelper::check($view->customtabs)) - { - // setup custom tabs to global data sets - CFactory::_('Registry')->set('builder.custom_tabs.' . $view->name_single_code, - array_map( - function ($tab) use (&$view) { - // set the view name - $tab['view'] = $view->name_single_code; - // load the dynamic data - $tab['html'] = CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update($tab['html']) - ); - // set the tab name - $tab['name'] = (isset($tab['name']) - && StringHelper::check( - $tab['name'] - )) ? $tab['name'] : 'Tab'; - // set lang - $tab['lang'] = CFactory::_('Config')->lang_prefix . '_' - . StringHelper::safe( - $tab['view'], 'U' - ) . '_' . StringHelper::safe( - $tab['name'], 'U' - ); - CFactory::_('Language')->set( - 'both', $tab['lang'], $tab['name'] - ); - // set code name - $tab['code'] = StringHelper::safe( - $tab['name'] - ); - // check if the permissions for the tab should be added - $_tab = ''; - if (isset($tab['permission']) - && $tab['permission'] == 1) - { - $_tab = Indent::_(1); - } - // check if the php of the tab is set, if not load it now - if (strpos((string) $tab['html'], 'bootstrap.addTab') === false - && strpos((string) $tab['html'], 'bootstrap.endTab') - === false) - { - // add the tab - $tmp = PHP_EOL . $_tab . Indent::_(1) - . ""; - $tmp .= PHP_EOL . $_tab . Indent::_(2) - . '
'; - $tmp .= PHP_EOL . $_tab . Indent::_(3) - . '
'; - $tmp .= PHP_EOL . $_tab . Indent::_(4) . implode( - PHP_EOL . $_tab . Indent::_(4), - (array) explode(PHP_EOL, trim((string) $tab['html'])) - ); - $tmp .= PHP_EOL . $_tab . Indent::_(3) . '
'; - $tmp .= PHP_EOL . $_tab . Indent::_(2) . '
'; - $tmp .= PHP_EOL . $_tab . Indent::_(1) - . ""; - // update html - $tab['html'] = $tmp; - } - else - { - $tab['html'] = PHP_EOL . $_tab . Indent::_(1) - . implode( - PHP_EOL . $_tab . Indent::_(1), - (array) explode(PHP_EOL, trim((string) $tab['html'])) - ); - } - // add the permissions if needed - if (isset($tab['permission']) - && $tab['permission'] == 1) - { - $tmp = PHP_EOL . Indent::_(1) - . "canDo->get('" - . $tab['view'] . "." . $tab['code'] - . ".viewtab')) : ?>"; - $tmp .= $tab['html']; - $tmp .= PHP_EOL . Indent::_(1) . ""; - // update html - $tab['html'] = $tmp; - // set lang for permissions - $tab['lang_permission'] = $tab['lang'] - . '_TAB_PERMISSION'; - $tab['lang_permission_desc'] = $tab['lang'] - . '_TAB_PERMISSION_DESC'; - $tab['lang_permission_title'] - = CFactory::_('Placeholder')->get('Views') . ' View ' - . $tab['name'] . ' Tab'; - CFactory::_('Language')->set( - 'both', $tab['lang_permission'], - $tab['lang_permission_title'] - ); - CFactory::_('Language')->set( - 'both', $tab['lang_permission_desc'], - 'Allow the users in this group to view ' - . $tab['name'] . ' Tab of ' - . CFactory::_('Placeholder')->get('views') - ); - // set the sort key - $tab['sortKey'] - = StringHelper::safe( - $tab['lang_permission_title'] - ); - } - - // return tab - return $tab; - }, array_values($view->customtabs) - ) - ); - } - unset($view->customtabs); - - // add the local tabs - $view->addtabs = (isset($view->addtabs) - && JsonHelper::check($view->addtabs)) - ? json_decode((string) $view->addtabs, true) : null; - if (ArrayHelper::check($view->addtabs)) - { - $nr = 1; - foreach ($view->addtabs as $tab) - { - $view->tabs[$nr] = trim((string) $tab['name']); - $nr++; - } - } - // if Details tab is not set, then set it here - if (!isset($view->tabs[1])) - { - $view->tabs[1] = 'Details'; - } - // always make sure that publishing is lowercase - if (($removeKey = array_search( - 'publishing', array_map('strtolower', $view->tabs) - )) !== false) - { - $view->tabs[$removeKey] = 'publishing'; - } - // make sure to set the publishing tab (just incase we need it) - $view->tabs[15] = 'publishing'; - unset($view->addtabs); - // add permissions - $view->addpermissions = (isset($view->addpermissions) - && JsonHelper::check($view->addpermissions)) - ? json_decode((string) $view->addpermissions, true) : null; - if (ArrayHelper::check($view->addpermissions)) - { - $view->permissions = array_values($view->addpermissions); - } - unset($view->addpermissions); - // reset fields - $view->fields = array(); - // set fields - $view->addfields = (isset($view->addfields) - && JsonHelper::check($view->addfields)) - ? json_decode((string) $view->addfields, true) : null; - if (ArrayHelper::check($view->addfields)) - { - $ignore_fields = array(); - $default_fields = CFactory::_('Config')->default_fields; - // load the field data - $view->fields = array_map( - function ($field) use ( - &$view, &$ignore_fields, &$default_fields - ) { - // set the field details - CFactory::_('Field')->set( - $field, $view->name_single_code, - $view->name_list_code - ); - // check if this field is a default field OR - // check if this is none database related field - if (in_array($field['base_name'], $default_fields) - || ComponentbuilderHelper::fieldCheck( - $field['type_name'], 'spacer' - ) - || (isset($field['list']) - && $field['list'] == 2)) // 2 = none database - { - $ignore_fields[$field['field']] = $field['field']; - } - - // return field - return $field; - }, array_values($view->addfields) - ); - // build update SQL - if ($old_view = CFactory::_('History')->get( - 'admin_fields', $view->addfields_id - )) - { - // add new fields were added - if (isset($old_view->addfields) - && JsonHelper::check( - $old_view->addfields - )) - { - $this->setUpdateSQL( - json_decode((string) $old_view->addfields, true), - $view->addfields, 'field', $view->name_single_code, - $ignore_fields - ); - } - // clear this data - unset($old_view); - } - // sort the fields according to order - usort( - $view->fields, function ($a, $b) { - if (isset($a['order_list']) && isset($b['order_list'])) - { - if ($a['order_list'] != 0 && $b['order_list'] != 0) - { - return $a['order_list'] - $b['order_list']; - } - elseif ($b['order_list'] != 0 && $a['order_list'] == 0) - { - return 1; - } - elseif ($a['order_list'] != 0 && $b['order_list'] == 0) - { - return 0; - } - - return 1; - } - - return 0; - } - ); - // do some house cleaning (for fields) - foreach ($view->fields as $field) - { - // so first we lock the field name in - $field_name = CFactory::_('Field.Name')->get( - $field, $view->name_list_code - ); - // check if the field changed since the last compilation (default fields never change and are always added) - if (!isset($ignore_fields[$field['field']]) - && ObjectHelper::check( - $field['settings']->history - )) - { - // check if the datatype changed - if (isset($field['settings']->history->datatype)) - { - $this->setUpdateSQL( - $field['settings']->history->datatype, - $field['settings']->datatype, 'field.datatype', - $view->name_single_code . '.' . $field_name - ); - } - // check if the datatype lenght changed - if (isset($field['settings']->history->datalenght) - && isset($field['settings']->history->datalenght_other)) - { - $this->setUpdateSQL( - $field['settings']->history->datalenght - . $field['settings']->history->datalenght_other, - $field['settings']->datalenght - . $field['settings']->datalenght_other, - 'field.lenght', - $view->name_single_code . '.' . $field_name - ); - } - // check if the name changed - if (isset($field['settings']->history->xml) - && JsonHelper::check( - $field['settings']->history->xml - )) - { - // only run if this is not an alias or a tag - if ((!isset($field['alias']) || !$field['alias']) - && 'tag' !== $field['settings']->type_name) - { - // build temp field bucket - $tmpfield = array(); - $tmpfield['settings'] = new stdClass(); - // convert the xml json string to normal string - $tmpfield['settings']->xml - = CFactory::_('Customcode')->update( - json_decode( - (string) $field['settings']->history->xml - ) - ); - // add properties from current field as it is generic - $tmpfield['settings']->properties - = $field['settings']->properties; - // add the old name - $tmpfield['settings']->name - = $field['settings']->history->name; - // add the field type from current field since it is generic - $tmpfield['settings']->type_name - = $field['settings']->type_name; - // get the old name - $old_field_name = CFactory::_('Field.Name')->get( - $tmpfield - ); - - // only run this if not a multi field - if (CFactory::_('Registry')->get('unique.names.' . $view->name_list_code . '.names.' . $field_name) === null) - { - // this only works when the field is not multiple of the same field - $this->setUpdateSQL( - $old_field_name, $field_name, - 'field.name', - $view->name_single_code . '.' - . $field_name - ); - } - elseif ($old_field_name !== $field_name) - { - // give a notice atleast that the multi fields could have changed and no DB update was done - $this->app->enqueueMessage( - JText::_('

Field Notice

'), - 'Notice' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'You have a field called %s that has been added multiple times to the %s view, the name of that field has changed to %s. Normaly we would automaticly add the update SQL to your component, but with multiple fields this does not work automaticly since it could be that noting changed and it just seems like it did. Therefore you will have to do this manualy if it actualy did change!', - $field_name, - $view->name_single_code, - $old_field_name - ), 'Notice' - ); - } - // remove tmp - unset($tmpfield); - } - } - } - } - } - unset($view->addfields); - // build update SQL - if ($old_view = CFactory::_('History')->get('admin_view', $id)) - { - // check if the view name changed - if (StringHelper::check($old_view->name_single)) - { - $this->setUpdateSQL( - StringHelper::safe( - $old_view->name_single - ), $view->name_single_code, 'table_name', - $view->name_single_code - ); - } - // loop the mysql table settings - foreach ( - CFactory::_('Config')->mysql_table_keys as $mysql_table_key => $mysql_table_val - ) - { - // check if the table engine changed - if (isset($old_view->{'mysql_table_' . $mysql_table_key}) - && isset($view->{'mysql_table_' . $mysql_table_key})) - { - $this->setUpdateSQL( - $old_view->{'mysql_table_' . $mysql_table_key}, - $view->{'mysql_table_' . $mysql_table_key}, - 'table_' . $mysql_table_key, $view->name_single_code - ); - } - // check if there is no history on table engine, and it changed from the default/global - elseif (isset($view->{'mysql_table_' . $mysql_table_key}) - && StringHelper::check( - $view->{'mysql_table_' . $mysql_table_key} - ) - && !is_numeric( - $view->{'mysql_table_' . $mysql_table_key} - )) - { - $this->setUpdateSQL( - $mysql_table_val['default'], - $view->{'mysql_table_' . $mysql_table_key}, - 'table_' . $mysql_table_key, $view->name_single_code - ); - } - } - // clear this data - unset($old_view); - } - // set the conditions - $view->addconditions = (isset($view->addconditions) - && JsonHelper::check($view->addconditions)) - ? json_decode((string) $view->addconditions, true) : null; - if (ArrayHelper::check($view->addconditions)) - { - $view->conditions = array(); - $ne = 0; - foreach ($view->addconditions as $nr => $conditionValue) - { - if (ArrayHelper::check( - $conditionValue['target_field'] - ) - && ArrayHelper::check($view->fields)) - { - foreach ( - $conditionValue['target_field'] as $fieldKey => - $fieldId - ) - { - foreach ($view->fields as $fieldValues) - { - if ((int) $fieldValues['field'] - == (int) $fieldId) - { - // load the field details - $required - = GetHelper::between( - $fieldValues['settings']->xml, - 'required="', '"' - ); - $required = ($required === 'true' - || $required === '1') ? 'yes' : 'no'; - $filter - = GetHelper::between( - $fieldValues['settings']->xml, - 'filter="', '"' - ); - $filter - = StringHelper::check( - $filter - ) ? $filter : 'none'; - // set the field name - $conditionValue['target_field'][$fieldKey] - = array( - 'name' => CFactory::_('Field.Name')->get( - $fieldValues, $view->name_list_code - ), - 'type' => CFactory::_('Field.Type.Name')->get( - $fieldValues - ), - 'required' => $required, - 'filter' => $filter - ); - break; - } - } - } - } - - // load match field - if (ArrayHelper::check($view->fields) - && isset($conditionValue['match_field'])) - { - foreach ($view->fields as $fieldValue) - { - if ((int) $fieldValue['field'] - == (int) $conditionValue['match_field']) - { - // set the type - $type = CFactory::_('Field.Type.Name')->get($fieldValue); - // set the field details - $conditionValue['match_name'] - = CFactory::_('Field.Name')->get( - $fieldValue, $view->name_list_code - ); - $conditionValue['match_type'] = $type; - $conditionValue['match_xml'] - = $fieldValue['settings']->xml; - // if custom field load field being extended - if (!ComponentbuilderHelper::fieldCheck($type)) - { - $conditionValue['match_extends'] - = GetHelper::between( - $fieldValue['settings']->xml, - 'extends="', '"' - ); - } - else - { - $conditionValue['match_extends'] = ''; - } - break; - } - } - } - // set condition values - $view->conditions[$ne] = $conditionValue; - $ne++; - } - } - unset($view->addconditions); - - // set the relations - $view->addrelations = (isset($view->addrelations) - && JsonHelper::check($view->addrelations)) - ? json_decode((string) $view->addrelations, true) : null; - if (ArrayHelper::check($view->addrelations)) - { - foreach ($view->addrelations as $nr => $relationsValue) - { - // only add if list view field is selected and joined fields are set - if (isset($relationsValue['listfield']) - && is_numeric( - $relationsValue['listfield'] - ) - && $relationsValue['listfield'] > 0 - && isset($relationsValue['area']) - && is_numeric($relationsValue['area']) - && $relationsValue['area'] > 0) - { - // do a dynamic update on the set values - if (isset($relationsValue['set']) - && StringHelper::check( - $relationsValue['set'] - )) - { - $relationsValue['set'] = CFactory::_('Customcode')->update( - $relationsValue['set'] - ); - } - - // load the field relations - CFactory::_('Registry')->set('builder.field_relations.' . $view->name_list_code . '.' . (int) $relationsValue['listfield'] - . '.' . (int) $relationsValue['area'], $relationsValue); - - // load the list joints - if (isset($relationsValue['joinfields']) - && ArrayHelper::check( - $relationsValue['joinfields'] - )) - { - foreach ($relationsValue['joinfields'] as $join) - { - CFactory::_('Registry')->set('builder.list_join.' . $view->name_list_code . '.' . (int) $join, (int) $join); - } - } - // set header over-ride - if (isset($relationsValue['column_name']) - && StringHelper::check( - $relationsValue['column_name'] - )) - { - $check_column_name = trim( - strtolower((string) $relationsValue['column_name']) - ); - // confirm it should really make the over ride - if ('default' !== $check_column_name) - { - $column_name_lang = CFactory::_('Config')->lang_prefix . '_' - . StringHelper::safe( - $view->name_list_code, 'U' - ) . '_' - . StringHelper::safe( - $relationsValue['column_name'], 'U' - ); - CFactory::_('Language')->set( - 'admin', $column_name_lang, - $relationsValue['column_name'] - ); - CFactory::_('Registry')->set('builder.list_head_override.' . - $view->name_list_code . '.' . (int) $relationsValue['listfield'], - $column_name_lang - ); - - } - } - } - } - } - unset($view->addrelations); - - // set linked views - $view->addlinked_views = (isset($view->addlinked_views) - && JsonHelper::check($view->addlinked_views)) - ? json_decode((string) $view->addlinked_views, true) : null; - if (ArrayHelper::check($view->addlinked_views)) - { - // setup linked views to global data sets - CFactory::_('Registry')->set('builder.linked_admin_views.' . $view->name_single_code, - array_values( - $view->addlinked_views - ) - ); - } - unset($view->addlinked_views); - // set the lang target - CFactory::_('Config')->lang_target = 'admin'; - if (CFactory::_('Registry')->get('builder.site_edit_view..' . $id, false)) - { - CFactory::_('Config')->lang_target = 'both'; - } - // set GUI mapper - $guiMapper = array('table' => 'admin_view', 'id' => (int) $id, - 'type' => 'js'); - // add_javascript - $addArrayJ = array('javascript_view_file', 'javascript_view_footer', - 'javascript_views_file', - 'javascript_views_footer'); - // update GUI mapper - $guiMapper['prefix'] = PHP_EOL; - foreach ($addArrayJ as $scripter) - { - if (isset($view->{'add_' . $scripter}) - && $view->{'add_' . $scripter} == 1 - && StringHelper::check($view->$scripter)) - { - $scripter_target = str_replace( - 'javascript_', '', $scripter - ); - // update GUI mapper field - $guiMapper['field'] = $scripter; - CFactory::_('Customcode.Dispenser')->set( - $view->{$scripter}, - $scripter_target, - $view->name_single_code, - null, - $guiMapper, - true, - true, - true - ); - // check if a token must be set - if (strpos((string) $view->$scripter, "token") !== false - || strpos( - (string) $view->$scripter, "task=ajax" - ) !== false) - { - if (!CFactory::_('Customcode.Dispenser')->hub['token'][$view->name_single_code]) - { - CFactory::_('Customcode.Dispenser')->hub['token'][$view->name_single_code] - = true; - } - } - unset($view->{$scripter}); - } - } - unset($guiMapper['prefix']); - // add_css - $addArrayC = array('css_view', 'css_views'); - foreach ($addArrayC as $scripter) - { - if (isset($view->{'add_' . $scripter}) - && $view->{'add_' . $scripter} == 1 - && StringHelper::check($view->{$scripter})) - { - CFactory::_('Customcode.Dispenser')->set( - $view->{$scripter}, - $scripter, - $view->name_single_code, - null, - array('prefix' => PHP_EOL), - true, - true, - true - ); - unset($view->{$scripter}); - } - } - // update GUI mapper - $guiMapper['type'] = 'php'; - // add_php - $addArrayP = array('php_getitem', 'php_before_save', 'php_save', - 'php_getform', 'php_postsavehook', - 'php_getitems', 'php_getitems_after_all', - 'php_getlistquery', 'php_allowadd', - 'php_allowedit', 'php_before_cancel', - 'php_after_cancel', 'php_before_delete', - 'php_after_delete', 'php_before_publish', - 'php_after_publish', 'php_batchcopy', - 'php_batchmove', 'php_document'); - foreach ($addArrayP as $scripter) - { - if (isset($view->{'add_' . $scripter}) - && $view->{'add_' . $scripter} == 1) - { - // update GUI mapper field - $guiMapper['field'] = $scripter; - CFactory::_('Customcode.Dispenser')->set( - $view->{$scripter}, - $scripter, - $view->name_single_code, - null, - $guiMapper - ); - - // check if we have template or layouts to load - $this->setTemplateAndLayoutData( - $view->{$scripter}, $view->name_single_code - ); - - unset($view->{$scripter}); - } - } - // add the custom buttons - if (isset($view->add_custom_button) - && $view->add_custom_button == 1) - { - $button_code_array = array( - 'php_model', - 'php_controller', - 'php_model_list', - 'php_controller_list' - ); - // set for the code - foreach ($button_code_array as $button_code_field) - { - if (isset($view->{$button_code_field}) - && StringHelper::check( - $view->{$button_code_field} - )) - { - // set field - $guiMapper['field'] = $button_code_field; - $view->{$button_code_field} - = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->update( - base64_decode((string) $view->{$button_code_field}) - ), - $guiMapper - ); - - // check if we have template or layouts to load - $this->setTemplateAndLayoutData( - $view->{$button_code_field}, $view->name_single_code - ); - } - } - // set the button array - $view->custom_button = (isset($view->custom_button) - && JsonHelper::check($view->custom_button)) - ? json_decode((string) $view->custom_button, true) : null; - if (ArrayHelper::check($view->custom_button)) - { - $view->custom_buttons = array_values($view->custom_button); - } - unset($view->custom_button); - } - // set custom import scripts - if (isset($view->add_custom_import) - && $view->add_custom_import == 1) - { - $addImportArray = array('php_import_ext', 'php_import_display', - 'php_import', 'php_import_setdata', - 'php_import_save', 'php_import_headers', - 'html_import_view'); - foreach ($addImportArray as $importScripter) - { - if (isset($view->$importScripter) - && strlen( - (string) $view->$importScripter - ) > 0) - { - // update GUI mapper field - $guiMapper['field'] = $importScripter; - $guiMapper['type'] = 'php'; - // Make sure html gets HTML comment for placeholder - if ('html_import_view' === $importScripter) - { - $guiMapper['type'] = 'html'; - } - CFactory::_('Customcode.Dispenser')->set( - $view->$importScripter, - $importScripter, - 'import_' . $view->name_list_code, - null, - $guiMapper - ); - unset($view->$importScripter); - } - else - { - // load the default - CFactory::_('Customcode.Dispenser')->hub[$importScripter]['import_' - . $view->name_list_code] - = ComponentbuilderHelper::getDynamicScripts( - $importScripter, true - ); - } - } - } - // add_Ajax for this view - if (isset($view->add_php_ajax) && $view->add_php_ajax == 1) - { - // insure the token is added to edit view atleast - CFactory::_('Customcode.Dispenser')->hub['token'][$view->name_single_code] - = true; - $addAjaxSite = false; - if (CFactory::_('Registry')->get('builder.site_edit_view..' . $id, false)) - { - // we should add this site ajax to front ajax - $addAjaxSite = true; - CFactory::_('Config')->set('add_site_ajax', true); - } - // check if controller input as been set - $view->ajax_input = (isset($view->ajax_input) - && JsonHelper::check($view->ajax_input)) - ? json_decode((string) $view->ajax_input, true) : null; - if (ArrayHelper::check($view->ajax_input)) - { - if ($addAjaxSite) - { - CFactory::_('Customcode.Dispenser')->hub['site']['ajax_controller'][$view->name_single_code] - = array_values($view->ajax_input); - } - CFactory::_('Customcode.Dispenser')->hub['admin']['ajax_controller'][$view->name_single_code] - = array_values($view->ajax_input); - CFactory::_('Config')->set('add_ajax', true); - unset($view->ajax_input); - } - if (StringHelper::check($view->php_ajaxmethod)) - { - // make sure we are still in PHP - $guiMapper['type'] = 'php'; - // update GUI mapper field - $guiMapper['field'] = 'php_ajaxmethod'; - CFactory::_('Customcode.Dispenser')->set( - $view->php_ajaxmethod, - 'admin', - 'ajax_model', - $view->name_single_code, - $guiMapper - ); - - if ($addAjaxSite) - { - CFactory::_('Customcode.Dispenser')->set( - $view->php_ajaxmethod, - 'site', - 'ajax_model', - $view->name_single_code, - $guiMapper, - false, - false - ); - } - // switch ajax on - CFactory::_('Config')->set('add_ajax', true); - // unset anyway - unset($view->php_ajaxmethod); - } - } - // activate alias builder - if (!CFactory::_('Registry')->get('builder.custom_alias.' . $view->name_single_code, null) - && isset($view->alias_builder_type) - && 2 == $view->alias_builder_type - && isset($view->alias_builder) - && JsonHelper::check($view->alias_builder)) - { - // get the aliasFields - $alias_fields = (array) json_decode((string) $view->alias_builder, true); - // get the active fields - $alias_fields = (array) array_filter( - $view->fields, function ($field) use ($alias_fields) { - // check if field is in view fields - if (in_array($field['field'], $alias_fields)) - { - return true; - } - - return false; - } - ); - // check if all is well - if (ArrayHelper::check($alias_fields)) - { - // load the field names - CFactory::_('Registry')->set('builder.custom_alias.' . $view->name_single_code, - (array) array_map( - function ($field) use (&$view) { - return CFactory::_('Field.Name')->get( - $field, $view->name_list_code - ); - }, $alias_fields - ) - ); - } - } - // unset - unset($view->alias_builder); - // add_sql - if ($view->add_sql == 1) - { - if ($view->source == 1 && isset($view->tables)) - { - // build and add the SQL dump - CFactory::_('Customcode.Dispenser')->hub['sql'][$view->name_single_code] - = $this->buildSqlDump( - $view->tables, $view->name_single_code, $id - ); - unset($view->tables); - } - elseif ($view->source == 2 && isset($view->sql)) - { - // add the SQL dump string - CFactory::_('Customcode.Dispenser')->set( - $view->sql, - 'sql', - $view->name_single_code - ); - unset($view->sql); - } - } - // set mySql Table Settings - foreach ( - CFactory::_('Config')->mysql_table_keys as $mysql_table_key => $mysql_table_val - ) - { - if (isset($view->{'mysql_table_' . $mysql_table_key}) - && StringHelper::check( - $view->{'mysql_table_' . $mysql_table_key} - ) - && !is_numeric($view->{'mysql_table_' . $mysql_table_key})) - { - CFactory::_('Registry')->set('builder.mysql_table_setting.' . $view->name_single_code . '.' . - $mysql_table_key, $view->{'mysql_table_' . $mysql_table_key} - ); - } - else - { - CFactory::_('Registry')->set('builder.mysql_table_setting.' . $view->name_single_code . '.' . - $mysql_table_key, $mysql_table_val['default'] - ); - } - // remove the table values since we moved to another object - unset($view->{'mysql_table_' . $mysql_table_key}); - } - - // for plugin event TODO change event api signatures - $placeholders = CFactory::_('Placeholder')->active; - // Trigger Event: jcb_ce_onAfterModelViewData - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterModelViewData', - array(&$component_context, &$view, &$placeholders) - ); - unset($placeholders); - - // clear placeholders - CFactory::_('Placeholder')->remove('view'); - CFactory::_('Placeholder')->remove('views'); - CFactory::_('Placeholder')->remove('View'); - CFactory::_('Placeholder')->remove('Views'); - CFactory::_('Placeholder')->remove('VIEW'); - CFactory::_('Placeholder')->remove('VIEWS'); - - // store this view to class object - $this->_adminViewData[$id] = $view; - } - - // return the found view data - return $this->_adminViewData[$id]; + return CFactory::_('Adminview.Data')->get($id); } /** @@ -3257,320 +1266,11 @@ class Get * @param string $table The view table * * @return oject The view data - * + * @deprecated 3.3 Use CFactory::_('Customview.Data')->get($id, $table); */ public function getCustomViewData($id, $table = 'site_view') { - // Create a new query object. - $query = $this->db->getQuery(true); - - $query->select('a.*'); - $query->from('#__componentbuilder_' . $table . ' AS a'); - $query->where($this->db->quoteName('a.id') . ' = ' . (int) $id); - - // for plugin event TODO change event api signatures - $component_context = CFactory::_('Config')->component_context; - // Trigger Event: jcb_ce_onBeforeQueryCustomViewData - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeQueryCustomViewData', - array(&$component_context, &$id, &$table, &$query, &$this->db) - ); - - // Reset the query using our newly populated query object. - $this->db->setQuery($query); - - // Load the results as a list of stdClass objects (see later for more options on retrieving data). - $view = $this->db->loadObject(); - // fix alias to use in code - $view->code = $this->uniqueCode( - StringHelper::safe($view->codename) - ); - $view->Code = StringHelper::safe($view->code, 'F'); - $view->CODE = StringHelper::safe($view->code, 'U'); - // Trigger Event: jcb_ce_onBeforeModelCustomViewData - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeModelCustomViewData', - array(&$component_context, &$view, &$id, &$table) - ); - - // set GUI mapper - $guiMapper = array('table' => $table, 'id' => (int) $id, - 'field' => 'default', 'type' => 'html'); - - // set the default data - $view->default = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->update(base64_decode((string) $view->default)), - $guiMapper - ); - // load context if not set - if (!isset($view->context) - || !StringHelper::check( - $view->context - )) - { - $view->context = $view->code; - } - else - { - // always make sure context is a safe string - $view->context = StringHelper::safe($view->context); - } - // make sure json become array - if (JsonHelper::check($view->libraries)) - { - $view->libraries = json_decode((string) $view->libraries, true); - } - // if we have an array add it - if (ArrayHelper::check($view->libraries)) - { - foreach ($view->libraries as $library) - { - if (!CFactory::_('Registry')->exists('builder.library_manager.' . - CFactory::_('Config')->build_target . '.' . $view->code . '.' . $library)) - { - if ($this->getMediaLibrary((int) $library)) - { - CFactory::_('Registry')->set('builder.library_manager.' . - CFactory::_('Config')->build_target . '.' . - $view->code . '.' . $library, true); - } - } - } - } - elseif (is_numeric($view->libraries) - && !CFactory::_('Registry')->exists('builder.library_manager.' . - CFactory::_('Config')->build_target . '.' . $view->code . '.' . (int) $view->libraries)) - { - if ($this->getMediaLibrary((int) $view->libraries)) - { - CFactory::_('Registry')->set('builder.library_manager.' . - CFactory::_('Config')->build_target . '.' . - $view->code . '.' . (int) $view->libraries, true); - } - } - // setup template and layout data - $this->setTemplateAndLayoutData($view->default, $view->code); - // get uikit switch - $uikit = CFactory::_('Config')->get('uikit', 0); - // insure the uikit components are loaded - if (2 == $uikit || 1 == $uikit) - { - // set uikit to views - if (($found = ComponentbuilderHelper::getUikitComp( - $view->default, (array) CFactory::_('Registry')->get('builder.uikit_comp.' . $view->code, []) - )) !== false) - { - CFactory::_('Registry')->set('builder.uikit_comp.' . $view->code, $found); - } - } - // check for footable - if (!CFactory::_('Registry')-> - exists('builder.footable_scripts.' . CFactory::_('Config')->build_target . '.' . $view->code)) - { - if ($this->getFootableScripts($view->default)) - { - CFactory::_('Registry')-> - set('builder.footable_scripts.' . CFactory::_('Config')->build_target . '.' . $view->code, true); - - CFactory::_('Config')->set('footable ', true); - } - } - // check for get module - if (!CFactory::_('Registry')-> - exists('builder.get_module.' . CFactory::_('Config')->build_target . '.' . $view->code)) - { - if ($this->getGetModule($view->default)) - { - CFactory::_('Registry')-> - set('builder.get_module.' . CFactory::_('Config')->build_target . '.' . $view->code, true); - } - } - // set the main get data - $main_get = $this->setGetData( - array($view->main_get), $view->code, $view->context - ); - $view->main_get = $main_get[0]; - // set the custom_get data - $view->custom_get = $this->setGetData( - json_decode((string) $view->custom_get, true), $view->code, $view->context - ); - // set array adding array of scripts - $addArray = array('php_view', 'php_jview', 'php_jview_display', - 'php_document', 'javascript_file', 'js_document', - 'css_document', 'css'); - // set GUI mapper - $guiMapper['type'] = 'php'; - foreach ($addArray as $scripter) - { - if (isset($view->{'add_' . $scripter}) - && $view->{'add_' . $scripter} == 1 - && StringHelper::check($view->$scripter)) - { - // css does not get placholders yet - if (strpos($scripter, 'css') === false) - { - // set field - $guiMapper['field'] = $scripter; - $view->$scripter = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->update( - base64_decode((string) $view->$scripter) - ), - $guiMapper - ); - } - else - { - $view->$scripter = CFactory::_('Customcode')->update( - base64_decode((string) $view->$scripter) - ); - } - if (2 == $uikit || 1 == $uikit) - { - // set uikit to views - if (($found = ComponentbuilderHelper::getUikitComp( - $view->$scripter, (array) CFactory::_('Registry')->get('builder.uikit_comp.' . $view->code, []) - )) !== false) - { - CFactory::_('Registry')->set('builder.uikit_comp.' . $view->code, $found); - } - } - - $this->setTemplateAndLayoutData($view->$scripter, $view->code); - - // check for footable - if (!CFactory::_('Registry')-> - exists('builder.footable_scripts.' . CFactory::_('Config')->build_target . '.' . $view->code)) - { - if ($this->getFootableScripts($view->$scripter)) - { - CFactory::_('Registry')-> - set('builder.footable_scripts.' . CFactory::_('Config')->build_target . '.' . $view->code, true); - - CFactory::_('Config')->set('footable ', true); - } - } - // check for google chart - if (!CFactory::_('Registry')-> - exists('builder.google_chart.' . CFactory::_('Config')->build_target . '.' . $view->code)) - { - if ($this->getGoogleChart($view->$scripter)) - { - CFactory::_('Registry')-> - set('builder.google_chart.' . CFactory::_('Config')->build_target . '.' . $view->code, true); - - CFactory::_('Config')->set('google_chart', true); - } - } - // check for get module - if (!CFactory::_('Registry')-> - exists('builder.get_module.' . CFactory::_('Config')->build_target . '.' . $view->code)) - { - if ($this->getGetModule($view->$scripter)) - { - CFactory::_('Registry')-> - set('builder.get_module.' . CFactory::_('Config')->build_target . '.' . $view->code, true); - } - } - } - } - // add_Ajax for this view - if (isset($view->add_php_ajax) && $view->add_php_ajax == 1) - { - // ajax target (since we only have two options really) - if ('site' === CFactory::_('Config')->build_target) - { - $target = 'site'; - } - else - { - $target = 'admin'; - } - $setAjax = false; - // check if controller input as been set - $view->ajax_input = (isset($view->ajax_input) - && JsonHelper::check($view->ajax_input)) - ? json_decode((string) $view->ajax_input, true) : null; - if (ArrayHelper::check($view->ajax_input)) - { - CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller'][$view->code] - = array_values($view->ajax_input); - $setAjax = true; - } - unset($view->ajax_input); - // load the ajax class mathods (if set) - if (StringHelper::check($view->php_ajaxmethod)) - { - // set field - $guiMapper['field'] = 'php_ajaxmethod'; - CFactory::_('Customcode.Dispenser')->set( - $view->php_ajaxmethod, - $target, - 'ajax_model', - $view->code, - $guiMapper - ); - $setAjax = true; - } - // unset anyway - unset($view->php_ajaxmethod); - // should ajax be set - if ($setAjax) - { - // turn on ajax area - if ('site' === CFactory::_('Config')->build_target) - { - CFactory::_('Config')->set('add_site_ajax', true); - } - else - { - CFactory::_('Config')->set('add_ajax', true); - } - } - } - // add the custom buttons - if (isset($view->add_custom_button) && $view->add_custom_button == 1) - { - $button_code_array = array( - 'php_model', - 'php_controller' - ); - // set for the code - foreach ($button_code_array as $button_code_field) - { - if (isset($view->{$button_code_field}) - && StringHelper::check( - $view->{$button_code_field} - )) - { - // set field - $guiMapper['field'] = $button_code_field; - $view->{$button_code_field} = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->update( - base64_decode((string) $view->{$button_code_field}) - ), - $guiMapper - ); - } - } - // set the button array - $view->custom_button = (isset($view->custom_button) - && JsonHelper::check($view->custom_button)) - ? json_decode((string) $view->custom_button, true) : null; - if (ArrayHelper::check($view->custom_button)) - { - $view->custom_buttons = array_values($view->custom_button); - } - unset($view->custom_button); - } - - // Trigger Event: jcb_ce_onAfterModelCustomViewData - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterModelCustomViewData', - array(&$component_context, &$view) - ); - - // return the found view data - return $view; + return CFactory::_('Customview.Data')->get($id, $table); } /** @@ -3730,572 +1430,11 @@ class Get * @param string $context The context for events * * @return oject the get dynamicGet data - * + * @deprecated Use CFactory::_('Dynamicget.Data')->get($ids, $view_code, $context); */ public function setGetData($ids, $view_code, $context) { - if (ArrayHelper::check($ids)) - { - $ids = implode(',', $ids); - // for plugin event TODO change event api signatures - $component_context = CFactory::_('Config')->component_context; - if (StringHelper::check($ids)) - { - // Create a new query object. - $query = $this->db->getQuery(true); - $query->select('a.*'); - $query->from('#__componentbuilder_dynamic_get AS a'); - $query->where('a.id IN (' . $ids . ')'); - $this->db->setQuery($query); - $this->db->execute(); - if ($this->db->getNumRows()) - { - $results = $this->db->loadObjectList(); - $typeArray = array(1 => 'LEFT', 2 => 'LEFT OUTER', - 3 => 'INNER', 4 => 'RIGHT', - 5 => 'RIGHT OUTER'); - $operatorArray = array(1 => '=', 2 => '!=', 3 => '<>', - 4 => '>', 5 => '<', 6 => '>=', - 7 => '<=', 8 => '!<', 9 => '!>', - 10 => 'IN', 11 => 'NOT IN'); - $guiMapper = array('table' => 'dynamic_get', - 'type' => 'php'); - foreach ($results as $_nr => &$result) - { - // Trigger Event: jcb_ce_onBeforeModelDynamicGetData - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeModelDynamicGetData', - array(&$component_context, &$result, &$result->id, &$view_code, &$context) - ); - // set GUI mapper id - $guiMapper['id'] = (int) $result->id; - // add calculations if set - if ($result->addcalculation == 1 - && StringHelper::check( - $result->php_calculation - )) - { - // set GUI mapper field - $guiMapper['field'] = 'php_calculation'; - $result->php_calculation - = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->update( - base64_decode((string) $result->php_calculation) - ), - $guiMapper - ); - } - // setup the router parse - if (isset($result->add_php_router_parse) - && $result->add_php_router_parse == 1 - && isset($result->php_router_parse) - && StringHelper::check( - $result->php_router_parse - )) - { - // set GUI mapper field - $guiMapper['field'] = 'php_router_parse'; - $result->php_router_parse - = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->update( - base64_decode((string) $result->php_router_parse) - ), - $guiMapper - ); - } - else - { - $result->add_php_router_parse = 0; - } - // The array of the php scripts that should be added to the script builder - $phpSripts = array('php_before_getitem', - 'php_after_getitem', - 'php_before_getitems', - 'php_after_getitems', - 'php_getlistquery'); - // load the php scripts - foreach ($phpSripts as $script) - { - // add php script to the script builder - if (isset($result->{'add_' . $script}) - && $result->{'add_' . $script} == 1 - && isset($result->{$script}) - && StringHelper::check( - $result->{$script} - )) - { - // move all main gets out to the customscript builder - if ($result->gettype <= 2) - { - // set GUI mapper field - $guiMapper['field'] = $script; - $guiMapper['prefix'] = PHP_EOL . PHP_EOL; - CFactory::_('Customcode.Dispenser')->set( - $result->{$script}, - CFactory::_('Config')->build_target . '_' . $script, - $view_code, - null, - $guiMapper, - true, - true, - true - ); - unset($guiMapper['prefix']); - // remove from local item - unset($result->{$script}); - unset($result->{'add_' . $script}); - } - else - { - // set GUI mapper field - $guiMapper['field'] = $script; - $guiMapper['prefix'] = PHP_EOL; - // only for custom gets - $result->{$script} - = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->update( - base64_decode((string) $result->{$script}) - ), - $guiMapper - ); - unset($guiMapper['prefix']); - } - } - else - { - // remove from local item - unset($result->{$script}); - unset($result->{'add_' . $script}); - } - } - // set the getmethod code name - $result->key = StringHelper::safe( - $view_code . ' ' . $result->name . ' ' . $result->id - ); - // reset buckets - $result->main_get = array(); - $result->custom_get = array(); - // should joineds and other weaks be added - $addDynamicTweaksJoints = true; - // set source data - switch ($result->main_source) - { - case 1: - // check if auto sync is set - if ($result->select_all == 1) - { - $result->view_selection = '*'; - } - // set the view data - $result->main_get[0]['selection'] - = $this->setDataSelection( - $result->key, $view_code, - $result->view_selection, - $result->view_table_main, 'a', null, 'view' - ); - $result->main_get[0]['as'] = 'a'; - $result->main_get[0]['key'] = $result->key; - $result->main_get[0]['context'] = $context; - unset($result->view_selection); - break; - case 2: - // check if auto sync is set - if ($result->select_all == 1) - { - $result->db_selection = '*'; - } - // set the database data - $result->main_get[0]['selection'] - = $this->setDataSelection( - $result->key, $view_code, - $result->db_selection, - $result->db_table_main, 'a', null, 'db' - ); - $result->main_get[0]['as'] = 'a'; - $result->main_get[0]['key'] = $result->key; - $result->main_get[0]['context'] = $context; - unset($result->db_selection); - break; - case 3: - // set GUI mapper field - $guiMapper['field'] = 'php_custom_get'; - // get the custom query - $customQueryString - = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->update( - base64_decode((string) $result->php_custom_get) - ), - $guiMapper - ); - // get the table name - $_searchQuery - = GetHelper::between( - $customQueryString, '$query->from(', ')' - ); - if (StringHelper::check( - $_searchQuery - ) - && strpos((string) $_searchQuery, '#__') !== false) - { - $_queryName - = GetHelper::between( - $_searchQuery, '#__', "'" - ); - if (!StringHelper::check( - $_queryName - )) - { - $_queryName - = GetHelper::between( - $_searchQuery, '#__', '"' - ); - } - } - // set to blank if not found - if (!isset($_queryName) - || !StringHelper::check( - $_queryName - )) - { - $_queryName = ''; - } - // set custom script - $result->main_get[0]['selection'] = array( - 'select' => $customQueryString, - 'from' => '', 'table' => '', 'type' => '', - 'name' => $_queryName); - $result->main_get[0]['as'] = 'a'; - $result->main_get[0]['key'] - = $result->key; - $result->main_get[0]['context'] = $context; - // do not add - $addDynamicTweaksJoints = false; - break; - } - // only add if main source is not custom - if ($addDynamicTweaksJoints) - { - // set join_view_table details - $result->join_view_table = json_decode( - (string) $result->join_view_table, true - ); - if (ArrayHelper::check( - $result->join_view_table - )) - { - // start the part of a table bucket - $_part_of_a = array(); - // build relationship - $_relationship = array_map( - function ($op) use (&$_part_of_a) { - $bucket = array(); - // array(on_field_as, on_field) - $bucket['on_field'] = array_map( - 'trim', - explode('.', (string) $op['on_field']) - ); - // array(join_field_as, join_field) - $bucket['join_field'] = array_map( - 'trim', - explode('.', (string) $op['join_field']) - ); - // triget filed that has table a relationship - if ($op['row_type'] == 1 - && ($bucket['on_field'][0] === 'a' - || isset($_part_of_a[$bucket['on_field'][0]]) - || isset($_part_of_a[$bucket['join_field'][0]]))) - { - $_part_of_a[$op['as']] = $op['as']; - } - - return $bucket; - }, $result->join_view_table - ); - // loop joints - foreach ( - $result->join_view_table as $nr => &$option - ) - { - if (StringHelper::check( - $option['selection'] - )) - { - // convert the type - $option['type'] - = $typeArray[$option['type']]; - // convert the operator - $option['operator'] - = $operatorArray[$option['operator']]; - // get the on field values - $on_field - = $_relationship[$nr]['on_field']; - // get the join field values - $join_field - = $_relationship[$nr]['join_field']; - // set selection - $option['selection'] - = $this->setDataSelection( - $result->key, $view_code, - $option['selection'], - $option['view_table'], - $option['as'], $option['row_type'], - 'view' - ); - $option['key'] = $result->key; - $option['context'] = $context; - // load to the getters - if ($option['row_type'] == 1) - { - $result->main_get[] = $option; - if ($on_field[0] === 'a' - || isset($_part_of_a[$join_field[0]]) - || isset($_part_of_a[$on_field[0]])) - { - CFactory::_('Registry')-> - set('builder.site_main_get.' . CFactory::_('Config')->build_target . - '.' . $view_code . '.' . $option['as'], $option['as']); - } - else - { - CFactory::_('Registry')-> - set('builder.site_dynamic_get.' . CFactory::_('Config')->build_target . - '.' . $view_code . '.' . $option['as'] . '.' . $join_field[1], $on_field[0]); - } - } - elseif ($option['row_type'] == 2) - { - $result->custom_get[] = $option; - if ($on_field[0] != 'a') - { - CFactory::_('Registry')-> - set('builder.site_dynamic_get.' . CFactory::_('Config')->build_target . - '.' . $view_code . '.' . $option['as'] . '.' . $join_field[1], $on_field[0]); - } - } - } - unset($result->join_view_table[$nr]); - } - } - unset($result->join_view_table); - // set join_db_table details - $result->join_db_table = json_decode( - (string) $result->join_db_table, true - ); - if (ArrayHelper::check( - $result->join_db_table - )) - { - // start the part of a table bucket - $_part_of_a = array(); - // build relationship - $_relationship = array_map( - function ($op) use (&$_part_of_a) { - $bucket = array(); - // array(on_field_as, on_field) - $bucket['on_field'] = array_map( - 'trim', - explode('.', (string) $op['on_field']) - ); - // array(join_field_as, join_field) - $bucket['join_field'] = array_map( - 'trim', - explode('.', (string) $op['join_field']) - ); - // triget filed that has table a relationship - if ($op['row_type'] == 1 - && ($bucket['on_field'][0] === 'a' - || isset($_part_of_a[$bucket['on_field'][0]]) - || isset($_part_of_a[$bucket['join_field'][0]]))) - { - $_part_of_a[$op['as']] = $op['as']; - } - - return $bucket; - }, $result->join_db_table - ); - - // loop joints - foreach ( - $result->join_db_table as $nr => &$option1 - ) - { - if (StringHelper::check( - $option1['selection'] - )) - { - // convert the type - $option1['type'] - = $typeArray[$option1['type']]; - // convert the operator - $option1['operator'] - = $operatorArray[$option1['operator']]; - // get the on field values - $on_field - = $_relationship[$nr]['on_field']; - // get the join field values - $join_field - = $_relationship[$nr]['join_field']; - // set selection - $option1['selection'] - = $this->setDataSelection( - $result->key, $view_code, - $option1['selection'], - $option1['db_table'], - $option1['as'], - $option1['row_type'], 'db' - ); - $option1['key'] = $result->key; - $option1['context'] = $context; - // load to the getters - if ($option1['row_type'] == 1) - { - $result->main_get[] = $option1; - if ($on_field[0] === 'a' - || isset($_part_of_a[$join_field[0]]) - || isset($_part_of_a[$on_field[0]])) - { - CFactory::_('Registry')-> - set('builder.site_main_get.' . CFactory::_('Config')->build_target . - '.' . $view_code . '.' . $option1['as'], $option1['as']); - } - else - { - CFactory::_('Registry')-> - set('builder.site_dynamic_get.' . CFactory::_('Config')->build_target . - '.' . $view_code . '.' . $option1['as'] . '.' . $join_field[1], $on_field[0]); - } - } - elseif ($option1['row_type'] == 2) - { - $result->custom_get[] = $option1; - if ($on_field[0] != 'a') - { - CFactory::_('Registry')-> - set('builder.site_dynamic_get.' . CFactory::_('Config')->build_target . - '.' . $view_code . '.' . $option1['as'] . '.' . $join_field[1], $on_field[0]); - } - } - } - unset($result->join_db_table[$nr]); - } - } - unset($result->join_db_table); - // set filter details - $result->filter = json_decode( - (string) $result->filter, true - ); - if (ArrayHelper::check( - $result->filter - )) - { - foreach ($result->filter as $nr => &$option2) - { - if (isset($option2['operator'])) - { - $option2['operator'] - = $operatorArray[$option2['operator']]; - $option2['state_key'] - = CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update( - $option2['state_key'] - ) - ); - $option2['key'] = $result->key; - } - else - { - unset($result->filter[$nr]); - } - } - } - // set where details - $result->where = json_decode((string) $result->where, true); - if (ArrayHelper::check( - $result->where - )) - { - foreach ($result->where as $nr => &$option3) - { - if (isset($option3['operator'])) - { - $option3['operator'] - = $operatorArray[$option3['operator']]; - } - else - { - unset($result->where[$nr]); - } - } - } - else - { - unset($result->where); - } - // set order details - $result->order = json_decode((string) $result->order, true); - if (!ArrayHelper::check( - $result->order - )) - { - unset($result->order); - } - // set grouping - $result->group = json_decode((string) $result->group, true); - if (!ArrayHelper::check( - $result->group - )) - { - unset($result->group); - } - // set global details - $result->global = json_decode( - (string) $result->global, true - ); - if (!ArrayHelper::check( - $result->global - )) - { - unset($result->global); - } - } - else - { - // when we have a custom query script we do not add the dynamic options - unset($result->join_view_table); - unset($result->join_db_table); - unset($result->filter); - unset($result->where); - unset($result->order); - unset($result->group); - unset($result->global); - } - // load the events if any is set - if ($result->gettype == 1 - && JsonHelper::check( - $result->plugin_events - )) - { - $result->plugin_events = json_decode( - (string) $result->plugin_events, true - ); - } - else - { - $result->plugin_events = ''; - } - // Trigger Event: jcb_ce_onAfterModelDynamicGetData - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterModelDynamicGetData', - array(&$component_context, &$result, &$result->id, &$view_code, &$context) - ); - } - - return $results; - } - } - } - - return false; + return CFactory::_('Dynamicget.Data')->get($ids, $view_code, $context); } /** @@ -4357,82 +1496,19 @@ class Get * @param array $settings Tweaking array. * * @return void - * + * @deprecated 3.3 */ public function setSqlTweaking($settings) { - if (ArrayHelper::check($settings)) - { - foreach ($settings as $setting) - { - // should sql dump be added - if (1 == $setting['add_sql']) - { - // add sql (by option) - if (2 == $setting['add_sql_options']) - { - // rest always - $id_array = array(); - // by id (first remove backups) - $ids = $setting['ids']; - // now get the ids - if (strpos((string) $ids, ',') !== false) - { - $id_array = (array) array_map( - 'trim', explode(',', (string) $ids) - ); - } - else - { - $id_array[] = trim((string) $ids); - } - $id_array_new = array(); - // check for ranges - foreach ($id_array as $key => $id) - { - if (strpos($id, '=>') !== false) - { - $id_range = (array) array_map( - 'trim', explode('=>', $id) - ); - unset($id_array[$key]); - // build range - if (count((array) $id_range) == 2) - { - $range = range( - $id_range[0], $id_range[1] - ); - $id_array_new = array_merge( - $id_array_new, $range - ); - } - } - } - if (ArrayHelper::check($id_array_new)) - { - $id_array = array_merge($id_array_new, $id_array); - } - // final fixing to array - if (ArrayHelper::check($id_array)) - { - // unique - $id_array = array_unique($id_array, SORT_NUMERIC); - // sort - sort($id_array, SORT_NUMERIC); - // now set it to global - CFactory::_('Registry')-> - set('builder.sql_tweak.' . (int) $setting['adminview'] . '.where', implode(',', $id_array)); - } - } - } - else - { - // do not add sql dump options - CFactory::_('Registry')-> - set('builder.sql_tweak.' . (int) $setting['adminview'] . '.add', false); - } - } - } + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + JText::sprintf('

%s Warning

', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + JText::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); } /** @@ -4445,142 +1521,13 @@ class Get * @param array $ignore The ids to ignore * * @return void - * + * @deprecated 3.3 Use CFactory::_('Model.Updatesql')->set($old, $new, $type, $key, $ignore); */ protected function setUpdateSQL($old, $new, $type, $key = null, $ignore = null ) { - // check if there were new items added - if (ArrayHelper::check($new) - && ArrayHelper::check($old)) - { - // check if this is old repeatable field - if (isset($new[$type])) - { - foreach ($new[$type] as $item) - { - $newItem = true; - // check if this is an id to ignore - if (ArrayHelper::check($ignore) - && in_array( - $item, $ignore - )) - { - // don't add ignored ids - $newItem = false; - } - // check if this is old repeatable field - elseif (isset($old[$type]) - && ArrayHelper::check($old[$type])) - { - if (!in_array($item, $old[$type])) - { - // we have a new item, lets add to SQL - $this->setAddSQL($type, $item, $key); - } - // add only once - $newItem = false; - } - elseif (!isset($old[$type])) - { - // we have new values - foreach ($old as $oldItem) - { - if (isset($oldItem[$type])) - { - if ($oldItem[$type] == $item[$type]) - { - $newItem = false; - break; - } - } - else - { - $newItem = false; - break; - } - } - } - else - { - $newItem = false; - } - // add if new - if ($newItem) - { - // we have a new item, lets add to SQL - $this->setAddSQL($type, $item[$type], $key); - } - } - } - else - { - foreach ($new as $item) - { - if (isset($item[$type])) - { - // search to see if this is a new value - $newItem = true; - // check if this is an id to ignore - if (ArrayHelper::check($ignore) - && in_array($item[$type], $ignore)) - { - // don't add ignored ids - $newItem = false; - } - // check if this is old repeatable field - elseif (isset($old[$type]) - && ArrayHelper::check($old[$type])) - { - if (in_array($item[$type], $old[$type])) - { - $newItem = false; - } - } - elseif (!isset($old[$type])) - { - // we have new values - foreach ($old as $oldItem) - { - if (isset($oldItem[$type])) - { - if ($oldItem[$type] == $item[$type]) - { - $newItem = false; - break; - } - } - else - { - $newItem = false; - break; - } - } - } - else - { - $newItem = false; - } - // add if new - if ($newItem) - { - // we have a new item, lets add to SQL - $this->setAddSQL($type, $item[$type], $key); - } - } - } - } - } - elseif ($key - && ((StringHelper::check($new) - && StringHelper::check($old)) - || (is_numeric($new) && is_numeric($old))) - && $new !== $old) - { - // set at key - CFactory::_('Registry')->set('builder.update_sql.' . $type . '.' . $key, ['old' => $old, 'new' => $new]); - } + CFactory::_('Model.Updatesql')->set($old, $new, $type, $key, $ignore); } /** @@ -4591,6 +1538,7 @@ class Get * @param int|null $key The id/key where values changed * * @return void + * @deprecated 3.3 */ protected function setAddSQL(string $type, int $item, ?int $key = null) { @@ -4664,151 +1612,13 @@ class Get * @param array $layouts The option to pass layout keys (to avoid search) * * @return boolean if something was found true - * + * @deprecated 3.3 Use CFactory::_('Templatelayout.Data')->set($default, $view, $found, $templates, $layouts); */ public function setTemplateAndLayoutData($default, $view, $found = false, $templates = array(), $layouts = array() ) { - // to check inside the templates - $again = array(); - // check if template keys were passed - if (!ArrayHelper::check($templates)) - { - // set the Template data - $temp1 = GetHelper::allBetween( - $default, "\$this->loadTemplate('", "')" - ); - $temp2 = GetHelper::allBetween( - $default, '$this->loadTemplate("', '")' - ); - if (ArrayHelper::check($temp1) - && ArrayHelper::check($temp2)) - { - $templates = array_merge($temp1, $temp2); - } - else - { - if (ArrayHelper::check($temp1)) - { - $templates = $temp1; - } - elseif (ArrayHelper::check($temp2)) - { - $templates = $temp2; - } - } - } - // check if we found templates - if (ArrayHelper::check($templates, true)) - { - foreach ($templates as $template) - { - if (!CFactory::_('Registry')-> - get('builder.template_data.' . CFactory::_('Config')->build_target . '.' . $view . '.' . $template, null)) - { - $data = $this->getDataWithAlias( - $template, 'template', $view - ); - if (ArrayHelper::check($data)) - { - // load it to the template data array - CFactory::_('Registry')-> - set('builder.template_data.' . CFactory::_('Config')->build_target . '.' . $view . '.' . $template, $data); - // call self to get child data - $again[] = array($data['html'], $view); - $again[] = array($data['php_view'], $view); - } - } - // check if we have the template set (and nothing yet found) - if (!$found && CFactory::_('Registry')-> - get('builder.template_data.' . CFactory::_('Config')->build_target . '.' . $view . '.' . $template, null)) - { - // something was found - $found = true; - } - } - } - // check if layout keys were passed - if (!ArrayHelper::check($layouts)) - { - // set the Layout data - $lay1 = GetHelper::allBetween( - $default, "JLayoutHelper::render('", "'," - ); - $lay2 = GetHelper::allBetween( - $default, 'JLayoutHelper::render("', '",' - ); - if (ArrayHelper::check($lay1) - && ArrayHelper::check($lay2)) - { - $layouts = array_merge($lay1, $lay2); - } - else - { - if (ArrayHelper::check($lay1)) - { - $layouts = $lay1; - } - elseif (ArrayHelper::check($lay2)) - { - $layouts = $lay2; - } - } - } - // check if we found layouts - if (ArrayHelper::check($layouts, true)) - { - // get the other target if both - $_target = null; - if (CFactory::_('Config')->lang_target === 'both') - { - $_target = (CFactory::_('Config')->build_target === 'admin') ? 'site' : 'admin'; - } - foreach ($layouts as $layout) - { - if (!CFactory::_('Registry')-> - get('builder.layout_data.' . CFactory::_('Config')->build_target . '.' . $layout, null)) - { - $data = $this->getDataWithAlias($layout, 'layout', $view); - if (ArrayHelper::check($data)) - { - // load it to the layout data array - CFactory::_('Registry')-> - set('builder.layout_data.' . CFactory::_('Config')->build_target . '.' . $layout, $data); - // check if other target is set - if (CFactory::_('Config')->lang_target === 'both' && $_target) - { - CFactory::_('Registry')-> - set('builder.layout_data.' . $_target . '.' . $layout, $data); - } - // call self to get child data - $again[] = array($data['html'], $view); - $again[] = array($data['php_view'], $view); - } - } - // check if we have the layout set (and nothing yet found) - if (!$found && CFactory::_('Registry')-> - get('builder.layout_data.' . CFactory::_('Config')->build_target . '.' . $layout, null)) - { - // something was found - $found = true; - } - } - } - // check again - if (ArrayHelper::check($again)) - { - foreach ($again as $go) - { - $found = $this->setTemplateAndLayoutData( - $go[0], $go[1], $found - ); - } - } - - // return the proof that something was found - return $found; + return CFactory::_('Templatelayout.Data')->set($default, $view, $found, $templates, $layouts); } /** @@ -4819,164 +1629,11 @@ class Get * @param string $view The view code name * * @return array The data found with the alias - * + * @deprecated 3.3 Use CFactory::_('Alias.Data')->get($n_ame, $table, $view); */ protected function getDataWithAlias($n_ame, $table, $view) { - // if not set, get all keys in table and set by ID - $this->setDataWithAliasKeys($table); - // now check if key is found - $name = preg_replace("/[^A-Za-z]/", '', $n_ame); - if (($ID = CFactory::_('Registry')->get('builder.data_with_alias_keys.' . $table . '.' . $name, null)) === null && - ($ID = CFactory::_('Registry')->get('builder.data_with_alias_keys.' . $table . '.' . $n_ame, null)) === null) - { - return false; - } - // Create a new query object. - $query = $this->db->getQuery(true); - $query->select('a.*'); - $query->from('#__componentbuilder_' . $table . ' AS a'); - $query->where( - $this->db->quoteName('a.id') . ' = ' . (int) $ID - ); - // get the other target if both - $_targets = array(CFactory::_('Config')->build_target); - if (CFactory::_('Config')->lang_target === 'both') - { - $_targets = array('site', 'admin'); - } - $this->db->setQuery($query); - // get the row - $row = $this->db->loadObject(); - // we load this layout - $php_view = ''; - if ($row->add_php_view == 1 - && StringHelper::check($row->php_view)) - { - $php_view = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->update(base64_decode((string) $row->php_view)), - array( - 'table' => $table, - 'field' => 'php_view', - 'id' => (int) $row->id, - 'type' => 'php') - ); - } - $content = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->update(base64_decode((string) $row->{$table})), - array( - 'table' => $table, - 'field' => $table, - 'id' => (int) $row->id, - 'type' => 'html') - ); - // load all targets - foreach ($_targets as $_target) - { - // make sure json become array - if (JsonHelper::check($row->libraries)) - { - $row->libraries = json_decode((string) $row->libraries, true); - } - // if we have an array add it - if (ArrayHelper::check($row->libraries)) - { - foreach ($row->libraries as $library) - { - if (!CFactory::_('Registry')->exists('builder.library_manager.' . - $_target . '.' . $view . '.' . (int) $library)) - { - if ($this->getMediaLibrary((int) $library)) - { - CFactory::_('Registry')->set('builder.library_manager.' . - $_target . '.' . $view . '.' . (int) $library, true); - } - } - } - } - elseif (is_numeric($row->libraries) - && !CFactory::_('Registry')->exists('builder.library_manager.' . - $_target . '.' . $view . '.' . (int) $row->libraries)) - { - if ($this->getMediaLibrary((int) $row->libraries)) - { - CFactory::_('Registry')->set('builder.library_manager.' . - $_target . '.' . $view . '.' . (int) $row->libraries, true); - } - } - // set footable to views and turn it on - if (!CFactory::_('Registry')-> - exists('builder.footable_scripts.' . $_target . '.' . $view)) - { - if ($this->getFootableScripts($content)) - { - CFactory::_('Registry')-> - set('builder.footable_scripts.' . $_target . '.' . $view, true); - - CFactory::_('Config')->set('footable ', true); - } - } - // set google charts to views and turn it on - if (!CFactory::_('Registry')-> - exists('builder.google_chart.' . $_target . '.' . $view)) - { - $foundA = $this->getGoogleChart($php_view); - $foundB = $this->getGoogleChart($content); - if ($foundA || $foundB) - { - CFactory::_('Registry')-> - set('builder.google_chart.' . $_target . '.' . $view, true); - - CFactory::_('Config')->set('google_chart', true); - } - } - // check for get module - if (!CFactory::_('Registry')-> - exists('builder.get_module.' . $_target . '.' . $view)) - { - $foundA = $this->getGetModule($php_view); - $foundB = $this->getGetModule($content); - if ($foundA || $foundB) - { - CFactory::_('Registry')-> - set('builder.get_module.' . $_target . '.' . $view, true); - } - } - } - // load UIKIT if needed - $uikit = CFactory::_('Config')->get('uikit', 0); - if (2 == $uikit || 1 == $uikit) - { - // set uikit to views - if (($found = ComponentbuilderHelper::getUikitComp( - $content, (array) CFactory::_('Registry')->get('builder.uikit_comp.' . $view, []) - )) !== false) - { - CFactory::_('Registry')->set('builder.uikit_comp.' . $view, $found); - } - } - - return array( - 'id' => $row->id, - 'html' => CFactory::_('Customcode.Gui')->set( - $content, - array( - 'table' => $table, - 'field' => $table, - 'id' => $row->id, - 'type' => 'html' - ) - ), - 'php_view' => CFactory::_('Customcode.Gui')->set( - $php_view, - array( - 'table' => $table, - 'field' => 'php_view', - 'id' => $row->id, - 'type' => 'php' - ) - ) - ); + return CFactory::_('Alias.Data')->get($n_ame, $table, $view); } /** @@ -4985,34 +1642,19 @@ class Get * @param string $table The table where to find the alias * * @return void - * + * @deprecated 3.3 */ protected function setDataWithAliasKeys($table) { - // now check if key is found - if (!CFactory::_('Registry')->get('builder.data_with_alias_keys.' . $table, null)) - { - // Create a new query object. - $query = $this->db->getQuery(true); - $query->select(array('a.id', 'a.alias')); - $query->from('#__componentbuilder_' . $table . ' AS a'); - $this->db->setQuery($query); - $rows = $this->db->loadObjectList(); - // check if we have an array - if (ArrayHelper::check($rows)) - { - foreach ($rows as $row) - { - // build the key - $k_ey = StringHelper::safe($row->alias); - $key = preg_replace("/[^A-Za-z]/", '', (string) $k_ey); - // set the keys - CFactory::_('Registry')->set('builder.data_with_alias_keys.' . $table . '.' . $row->alias, $row->id); - CFactory::_('Registry')->set('builder.data_with_alias_keys.' . $table . '.' . $k_ey, $row->id); - CFactory::_('Registry')->set('builder.data_with_alias_keys.' . $table . '.' . $key, $row->id); - } - } - } + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + JText::sprintf('

%s Warning

', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + JText::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); } /** @@ -5021,261 +1663,11 @@ class Get * @param string $id the library id * * @return bool true on success - * + * @deprecated 3.3 Use CFactory::_('Library.Data')->get($id); */ protected function getMediaLibrary($id) { - // check if the lib has already been set - if (!CFactory::_('Registry')->exists("builder.libraries.$id")) - { - // get some switches - $uikit = CFactory::_('Config')->get('uikit', 0); - $footable_version = CFactory::_('Config')->get('footable_version', 0); - // make sure we should continue and that the lib is not already being loaded - switch ($id) - { - case 1: // No Library - return false; - break; - case 3: // Uikit v3 - if (2 == $uikit || 3 == $uikit) - { - // already being loaded - CFactory::_('Registry')->set("builder.libraries.$id", false); - } - break; - case 4: // Uikit v2 - if (2 == $uikit || 1 == $uikit) - { - // already being loaded - CFactory::_('Registry')->set("builder.libraries.$id", false); - } - break; - case 5: // FooTable v2 - if (2 == $footable_version) - { - // already being loaded - CFactory::_('Registry')->set("builder.libraries.$id", false); - } - break; - case 6: // FooTable v3 - if (3 == $footable_version) - { - // already being loaded - CFactory::_('Registry')->set("builder.libraries.$id", false); - } - break; - } - } - // check if the lib has already been set - if (!CFactory::_('Registry')->exists("builder.libraries.$id")) - { - $query = $this->db->getQuery(true); - - $query->select('a.*'); - $query->select( - $this->db->quoteName( - array( - 'a.id', - 'a.name', - 'a.how', - 'a.type', - 'a.addconditions', - 'b.addconfig', - 'c.addfiles', - 'c.addfolders', - 'c.addfilesfullpath', - 'c.addfoldersfullpath', - 'c.addurls', - 'a.php_setdocument' - ), array( - 'id', - 'name', - 'how', - 'type', - 'addconditions', - 'addconfig', - 'addfiles', - 'addfolders', - 'addfilesfullpath', - 'addfoldersfullpath', - 'addurls', - 'php_setdocument' - ) - ) - ); - // from these tables - $query->from('#__componentbuilder_library AS a'); - $query->join( - 'LEFT', - $this->db->quoteName('#__componentbuilder_library_config', 'b') - . ' ON (' . $this->db->quoteName('a.id') . ' = ' - . $this->db->quoteName('b.library') . ')' - ); - $query->join( - 'LEFT', $this->db->quoteName( - '#__componentbuilder_library_files_folders_urls', 'c' - ) . ' ON (' . $this->db->quoteName('a.id') . ' = ' - . $this->db->quoteName('c.library') . ')' - ); - $query->where($this->db->quoteName('a.id') . ' = ' . (int) $id); - $query->where($this->db->quoteName('a.target') . ' = 1'); - - // Reset the query using our newly populated query object. - $this->db->setQuery($query); - - // Load the results as a list of stdClass objects - $library = $this->db->loadObject(); - - // check if this lib uses build-in behaviour - if ($library->how == 4) - { - // fall back on build-in features - $buildin = array(3 => array('uikit' => 3), - 4 => array('uikit' => 1), - 5 => array('footable_version' => 2, - 'footable' => true), - 6 => array('footable_version' => 3, - 'footable' => true)); - if (isset($buildin[$library->id]) - && ArrayHelper::check( - $buildin[$library->id] - )) - { - // set the lib switch - foreach ($buildin[$library->id] as $lib => $val) - { - // ---- we are targeting these ---- - // $this->uikit CFactory::_('Config')->uikit - // $this->footableVersion CFactory::_('Config')->footable_version - // $this->footable CFactory::_('Config')->footable - CFactory::_('Config')->set($lib, $val); - } - // since we are falling back on build-in feature - $library->how = 0; - } - else - { - // since we did not find build in behaviour we must load always. - $library->how = 1; - } - } - // check if this lib has dynamic behaviour - if ($library->how > 0) - { - // set the add targets - $addArray = array('files' => 'files', - 'folders' => 'folders', - 'urls' => 'urls', - 'filesfullpath' => 'files', - 'foldersfullpath' => 'folders'); - foreach ($addArray as $addTarget => $targetHere) - { - // set the add target data - $library->{'add' . $addTarget} = (isset( - $library->{'add' . $addTarget} - ) - && JsonHelper::check( - $library->{'add' . $addTarget} - )) ? json_decode((string) $library->{'add' . $addTarget}, true) - : null; - if (ArrayHelper::check( - $library->{'add' . $addTarget} - )) - { - if (isset($library->{$targetHere}) - && ArrayHelper::check( - $library->{$targetHere} - )) - { - foreach ($library->{'add' . $addTarget} as $taget) - { - $library->{$targetHere}[] = $taget; - } - } - else - { - $library->{$targetHere} = array_values( - $library->{'add' . $addTarget} - ); - } - } - unset($library->{'add' . $addTarget}); - } - // add config fields only if needed - if ($library->how > 1) - { - // set the config data - $library->addconfig = (isset($library->addconfig) - && JsonHelper::check( - $library->addconfig - )) ? json_decode((string) $library->addconfig, true) : null; - if (ArrayHelper::check($library->addconfig)) - { - $library->config = array_map( - function ($array) { - $array['alias'] = 0; - $array['title'] = 0; - $array['settings'] = CFactory::_('Field.Data')->get( - $array['field'] - ); - - return $array; - }, array_values($library->addconfig) - ); - } - } - // if this lib is controlled by custom script - if (3 == $library->how) - { - // set Needed PHP - if (isset($library->php_setdocument) - && StringHelper::check( - $library->php_setdocument - )) - { - $library->document = CFactory::_('Customcode.Gui')->set( - CFactory::_('Customcode')->update( - base64_decode((string) $library->php_setdocument) - ), - array( - 'table' => 'library', - 'field' => 'php_setdocument', - 'id' => (int) $id, - 'type' => 'php') - ); - } - } - // if this lib is controlled by conditions - elseif (2 == $library->how) - { - // set the addconditions data - $library->addconditions = (isset($library->addconditions) - && JsonHelper::check( - $library->addconditions - )) ? json_decode((string) $library->addconditions, true) : null; - if (ArrayHelper::check( - $library->addconditions - )) - { - $library->conditions = array_values( - $library->addconditions - ); - } - } - unset($library->php_setdocument); - unset($library->addconditions); - unset($library->addconfig); - // load to global lib - CFactory::_('Registry')->set("builder.libraries.$id", $library); - } - else - { - CFactory::_('Registry')->set("builder.libraries.$id", false); - } - } - // if set return - return CFactory::_('Registry')->get("builder.libraries.$id", false); + return CFactory::_('Library.Data')->get($id); } /** @@ -5316,150 +1708,15 @@ class Get * @param string $type The target type (db||view) * * @return array the select query - * + * @deprecated 3.3 Use CFactory::_('Dynamicget.Selection')->get($method_key, $view_code, $string, $asset, $as, $type, $row_type); */ public function setDataSelection($method_key, $view_code, $string, $asset, $as, $row_type, $type ) { - if (StringHelper::check($string)) - { - if ('db' === $type) - { - $table = '#__' . $asset; - $queryName = $asset; - $view = ''; - } - elseif ('view' === $type) - { - $view = $this->getViewTableName($asset); - $table = '#__' . CFactory::_('Config')->component_code_name . '_' . $view; - $queryName = $view; - } - // just get all values from table if * is found - if ($string === '*' || strpos($string, '*') !== false) - { - if ($type == 'view') - { - $_string = ComponentbuilderHelper::getViewTableColumns( - $asset, $as, $row_type - ); - } - else - { - $_string = ComponentbuilderHelper::getDbTableColumns( - $asset, $as, $row_type - ); - } - // get only selected values - $lines = explode(PHP_EOL, (string) $_string); - // make sure to set the string to * - $string = '*'; - } - else - { - // get only selected values - $lines = explode(PHP_EOL, $string); - } - // only continue if lines are available - if (ArrayHelper::check($lines)) - { - $gets = array(); - $keys = array(); - // first load all options - foreach ($lines as $line) - { - if (strpos($line, 'AS') !== false) - { - $lineArray = explode("AS", $line); - } - elseif (strpos($line, 'as') !== false) - { - $lineArray = explode("as", $line); - } - else - { - $lineArray = array($line, null); - } - // set the get and key - $get = trim($lineArray[0]); - $key = trim($lineArray[1]); - // only add the view (we must adapt this) - if (CFactory::_('Registry')->exists('builder.get_as_lookup.' . $method_key . '.' . $get) - && 'a' != $as - && 1 == $row_type - && 'view' === $type - && strpos('#' . $key, '#' . $view . '_') === false) - { - // this is a problem (TODO) since we may want to not add the view name. - $key = $view . '_' . trim($key); - } - // continue only if we have get - if (StringHelper::check($get)) - { - $gets[] = $this->db->quote($get); - if (StringHelper::check($key)) - { - CFactory::_('Registry')-> - set('builder.get_as_lookup.' . $method_key . '.' . $get, $key); - } - else - { - $key = str_replace( - $as . '.', '', $get - ); - CFactory::_('Registry')-> - set('builder.get_as_lookup.' . $method_key . '.' . $get, $key); - } - // set the keys - $keys[] = $this->db->quote( - $key - ); - // make sure we have the view name - if (StringHelper::check($view)) - { - // prep the field name - $field = str_replace($as . '.', '', $get); - // load to the site fields memory bucket - CFactory::_('Registry')-> - set('builder.site_fields.' . $view . '.' . $field . '.' . $method_key . '___' . $as, - ['site' => $view_code, 'get' => $get, 'as' => $as, 'key' => $key]); - } - } - } - if (ArrayHelper::check($gets) - && ArrayHelper::check($keys)) - { - // single joined selection needs the prefix to the values to avoid conflict in the names - // so we must still add then AS - if ($string == '*' && 1 != $row_type) - { - $querySelect = "\$query->select('" . $as . ".*');"; - } - else - { - $querySelect = '$query->select($db->quoteName(' - . PHP_EOL . Indent::_(3) . 'array(' . implode( - ',', $gets - ) . '),' . PHP_EOL . Indent::_(3) . 'array(' - . implode(',', $keys) . ')));'; - } - $queryFrom = '$db->quoteName(' . $this->db->quote($table) - . ', ' . $this->db->quote($as) . ')'; - - // return the select query - return array('select' => $querySelect, - 'from' => $queryFrom, - 'name' => $queryName, - 'table' => $table, - 'type' => $type, - 'select_gets' => $gets, - 'select_keys' => $keys); - } - } - } - - return false; + return CFactory::_('Dynamicget.Selection')->get( + $method_key, $view_code, $string, $asset, + $as, $type, $row_type); } /** @@ -5468,7 +1725,7 @@ class Get * @param int $id The admin view in * * @return string view code name - * + * @deprecated 3.3 */ public function getViewTableName($id) { @@ -5492,220 +1749,11 @@ class Get * @param int $view_id The id of the target view * * @return string on success with the Dump SQL - * + * @deprecated 3.3 Use CFactory::_('Model.Sqldump')->key($tables, $view, $view_id); */ public function buildSqlDump($tables, $view, $view_id) { - // first build a query statement to get all the data (insure it must be added - check the tweaking) - if (ArrayHelper::check($tables) - && CFactory::_('Registry')-> // default is to add - get('builder.sql_tweak.' . (int) $view_id . '.add', true)) - { - $counter = 'a'; - // Create a new query object. - $query = $this->db->getQuery(true); - // switch to onlu trigger the run of the query if we have tables to query - $runQuery = false; - foreach ($tables as $table) - { - if (isset($table['table'])) - { - if ($counter === 'a') - { - // the main table fields - if (strpos((string) $table['sourcemap'], PHP_EOL) !== false) - { - $fields = explode(PHP_EOL, (string) $table['sourcemap']); - if (ArrayHelper::check($fields)) - { - // reset array buckets - $sourceArray = array(); - $targetArray = array(); - foreach ($fields as $field) - { - if (strpos($field, "=>") !== false) - { - list($source, $target) = explode( - "=>", $field - ); - $sourceArray[] = $counter . '.' . trim( - $source - ); - $targetArray[] = trim($target); - } - } - if (ArrayHelper::check( - $sourceArray - ) - && ArrayHelper::check( - $targetArray - )) - { - // add to query - $query->select( - $this->db->quoteName( - $sourceArray, $targetArray - ) - ); - $query->from( - '#__' . $table['table'] . ' AS a' - ); - $runQuery = true; - } - // we may need to filter the selection - if (($ids_ = CFactory::_('Registry')-> - get('builder.sql_tweak.' . (int) $view_id . '.where', null)) !== null) - { - // add to query the where filter - $query->where( - 'a.id IN (' . $ids_ . ')' - ); - } - } - } - } - else - { - // the other tables - if (strpos((string) $table['sourcemap'], PHP_EOL) !== false) - { - $fields = explode(PHP_EOL, (string) $table['sourcemap']); - if (ArrayHelper::check($fields)) - { - // reset array buckets - $sourceArray = array(); - $targetArray = array(); - foreach ($fields as $field) - { - if (strpos($field, "=>") !== false) - { - list($source, $target) = explode( - "=>", $field - ); - $sourceArray[] = $counter . '.' . trim( - $source - ); - $targetArray[] = trim($target); - } - if (strpos($field, "==") !== false) - { - list($aKey, $bKey) = explode( - "==", $field - ); - // add to query - $query->join( - 'LEFT', $this->db->quoteName( - '#__' . $table['table'], - $counter - ) . ' ON (' . $this->db->quoteName( - 'a.' . trim($aKey) - ) . ' = ' . $this->db->quoteName( - $counter . '.' . trim($bKey) - ) . ')' - ); - } - } - if (ArrayHelper::check( - $sourceArray - ) - && ArrayHelper::check( - $targetArray - )) - { - // add to query - $query->select( - $this->db->quoteName( - $sourceArray, $targetArray - ) - ); - } - } - } - } - $counter++; - } - else - { - // see where - // var_dump($view); - // jexit(); - } - } - // check if we should run query - if ($runQuery) - { - // now get the data - $this->db->setQuery($query); - $this->db->execute(); - if ($this->db->getNumRows()) - { - // get the data - $data = $this->db->loadObjectList(); - // start building the MySql dump - $dump = "--"; - $dump .= PHP_EOL . "-- Dumping data for table `#__" - . Placefix::_( "component" ) . "_" . $view - . "`"; - $dump .= PHP_EOL . "--"; - $dump .= PHP_EOL . PHP_EOL . "INSERT INTO `#__" . Placefix::_("component" ) . "_" . $view . "` ("; - foreach ($data as $line) - { - $comaSet = 0; - foreach ($line as $fieldName => $fieldValue) - { - if ($comaSet == 0) - { - $dump .= $this->db->quoteName($fieldName); - } - else - { - $dump .= ", " . $this->db->quoteName( - $fieldName - ); - } - $comaSet++; - } - break; - } - $dump .= ") VALUES"; - $coma = 0; - foreach ($data as $line) - { - if ($coma == 0) - { - $dump .= PHP_EOL . "("; - } - else - { - $dump .= "," . PHP_EOL . "("; - } - $comaSet = 0; - foreach ($line as $fieldName => $fieldValue) - { - if ($comaSet == 0) - { - $dump .= $this->mysql_escape($fieldValue); - } - else - { - $dump .= ", " . $this->mysql_escape( - $fieldValue - ); - } - $comaSet++; - } - $dump .= ")"; - $coma++; - } - $dump .= ";"; - - // return build dump query - return $dump; - } - } - } - - return false; + return CFactory::_('Model.Sqldump')->key($tables, $view, $view_id); } /** @@ -5714,28 +1762,19 @@ class Get * @param string $value the value to escape * * @return string on success with escaped string - * + * @deprecated 3.3 */ public function mysql_escape($value) { - // if array then return maped - if (ArrayHelper::check($value)) - { - return array_map(__METHOD__, $value); - } - // if string make sure it is correctly escaped - if (StringHelper::check($value) && !is_numeric($value)) - { - return $this->db->quote($value); - } - // if empty value return place holder - if (empty($value)) - { - return "''"; - } - - // if not array or string then return number - return $value; + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + JText::sprintf('

%s Warning

', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + JText::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); } /** @@ -5744,22 +1783,11 @@ class Get * @param string $code The planed code * * @return string The unique code - * + * @deprecated 3.3 use Unique::code($code); */ public function uniqueCode($code) { - if (!isset($this->uniquecodes[CFactory::_('Config')->build_target]) - || !in_array( - $code, $this->uniquecodes[CFactory::_('Config')->build_target] - )) - { - $this->uniquecodes[CFactory::_('Config')->build_target][] = $code; - - return $code; - } - - // make sure it is unique - return $this->uniqueCode($code . $this->uniquekey(1)); + return Unique::code($code); } /** @@ -5768,36 +1796,13 @@ class Get * @param int $size The key size * * @return string The unique localkey - * + * @deprecated 3.3 use Unique::get($size); */ public function uniquekey($size, $random = false, $newBag = "vvvvvvvvvvvvvvvvvvv" ) { - if ($random) - { - $bag - = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ"; - } - else - { - $bag = $newBag; - } - $key = array(); - $bagsize = strlen((string) $bag) - 1; - for ($i = 0; $i < $size; $i++) - { - $get = rand(0, $bagsize); - $key[] = $bag[$get]; - } - $key = implode($key); - while (in_array($key, $this->uniquekeys)) - { - $key++; - } - $this->uniquekeys[] = $key; - - return $key; + return Unique::get($size); } /** @@ -5806,7 +1811,7 @@ class Get * @param string $content The content to check * * @return boolean True if found - * + * @deprecated 3.3 */ public function getFootableScripts($content) { @@ -5824,7 +1829,7 @@ class Get * @param string $content The content to check * * @return boolean True if found - * + * @deprecated 3.3 */ public function getGetModule($content) { @@ -5842,7 +1847,7 @@ class Get * @param string $content The content to check * * @return boolean True if found - * + * @deprecated 3.3 */ public function getGoogleChart($content) { @@ -6060,9 +2065,7 @@ class Get $query->where( $this->db->quoteName('a.source') . ' IN (' . implode( ',', array_map( - function ($a) { - return $this->db->quote($a); - }, $values + fn($a) => $this->db->quote($a), $values ) ) . ')' ); @@ -6400,9 +2403,7 @@ class Get $query->where( $this->db->quoteName('a.source') . ' NOT IN (' . implode( ',', array_map( - function ($a) { - return $this->db->quote($a); - }, $values + fn($a) => $this->db->quote($a), $values ) ) . ')' ); @@ -6669,769 +2670,11 @@ class Get * set the Joomla modules * * @return true - * + * @deprecated 3.3 Use CFactory::_('Joomlamodule.Data')->set($id); */ public function setJoomlaModule($id, &$component) { - if (isset($this->joomlaModules[$id])) - { - return true; - } - else - { - // Create a new query object. - $query = $this->db->getQuery(true); - - $query->select('a.*'); - $query->select( - $this->db->quoteName( - array( - 'f.addfiles', - 'f.addfolders', - 'f.addfilesfullpath', - 'f.addfoldersfullpath', - 'f.addurls', - 'u.version_update', - 'u.id' - ), array( - 'addfiles', - 'addfolders', - 'addfilesfullpath', - 'addfoldersfullpath', - 'addurls', - 'version_update', - 'version_update_id' - ) - ) - ); - // from these tables - $query->from('#__componentbuilder_joomla_module AS a'); - $query->join( - 'LEFT', $this->db->quoteName( - '#__componentbuilder_joomla_module_updates', 'u' - ) . ' ON (' . $this->db->quoteName('a.id') . ' = ' - . $this->db->quoteName('u.joomla_module') . ')' - ); - $query->join( - 'LEFT', $this->db->quoteName( - '#__componentbuilder_joomla_module_files_folders_urls', 'f' - ) . ' ON (' . $this->db->quoteName('a.id') . ' = ' - . $this->db->quoteName('f.joomla_module') . ')' - ); - $query->where($this->db->quoteName('a.id') . ' = ' . (int) $id); - $query->where($this->db->quoteName('a.published') . ' >= 1'); - $this->db->setQuery($query); - $this->db->execute(); - if ($this->db->getNumRows()) - { - // get the module data - $module = $this->db->loadObject(); - // tweak system to set stuff to the module domain - $_backup_target = CFactory::_('Config')->build_target; - $_backup_lang = CFactory::_('Config')->lang_target; - $_backup_langPrefix = CFactory::_('Config')->lang_prefix; - // set some keys - $module->target_type = 'M0dU|3'; - $module->key = $module->id . '_' . $module->target_type; - // update to point to module - CFactory::_('Config')->build_target = $module->key; - CFactory::_('Config')->lang_target = $module->key; - // set version if not set - if (empty($module->module_version)) - { - $module->module_version = '1.0.0'; - } - // set target client - if ($module->target == 2) - { - $module->target_client = 'administrator'; - } - else - { - // default is site area - $module->target_client = 'site'; - } - // set GUI mapper - $guiMapper = array('table' => 'joomla_module', - 'id' => (int) $id, 'type' => 'php'); - // update the name if it has dynamic values - $module->name = CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update($module->name) - ); - // set safe class function name - $module->code_name - = ClassfunctionHelper::safe( - $module->name - ); - // alias of code name - $module->class_name = $module->code_name; - // set official name - $module->official_name = StringHelper::safe( - $module->name, 'W' - ); - // set langPrefix - $this->langPrefix = 'MOD_' . strtoupper((string) $module->code_name); - CFactory::_('Config')->set('lang_prefix', $this->langPrefix); - // set lang prefix - $module->lang_prefix = CFactory::_('Config')->lang_prefix; - // set module class name - $module->class_helper_name = 'Mod' . ucfirst((string) $module->code_name) - . 'Helper'; - $module->class_data_name = 'Mod' . ucfirst((string) $module->code_name) - . 'Data'; - // set module install class name - $module->installer_class_name = 'mod_' . ucfirst( - (string) $module->code_name - ) . 'InstallerScript'; - // set module folder name - $module->folder_name = 'mod_' . strtolower((string) $module->code_name); - // set the zip name - $module->zip_name = $module->folder_name . '_v' . str_replace( - '.', '_', (string) $module->module_version - ) . '__J' . CFactory::_('Config')->joomla_version; - // set module file name - $module->file_name = $module->folder_name; - // set module context - $module->context = $module->file_name . '.' . $module->id; - // set official_name lang strings - CFactory::_('Language')->set( - $module->key, CFactory::_('Config')->lang_prefix, $module->official_name - ); - // set some placeholder for this module - CFactory::_('Placeholder')->set('Module_name', $module->official_name); - CFactory::_('Placeholder')->set('Module', ucfirst( - (string) $module->code_name - )); - CFactory::_('Placeholder')->set('module', strtolower( - (string) $module->code_name - )); - CFactory::_('Placeholder')->set('module.version', $module->module_version); - CFactory::_('Placeholder')->set('module_version', str_replace( - '.', '_', (string) $module->module_version - )); - // set description (TODO) add description field to module - if (!isset($module->description) - || !StringHelper::check( - $module->description - )) - { - $module->description = ''; - } - else - { - $module->description = CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update($module->description) - ); - CFactory::_('Language')->set( - $module->key, $module->lang_prefix . '_DESCRIPTION', - $module->description - ); - $module->description = '

' . $module->description - . '

'; - } - $module->xml_description = "

" . $module->official_name - . " (v." . $module->module_version - . ")

" - . $module->description . "

Created by " . trim( - (string) JFilterOutput::cleanText($component->author) - ) . "
Development started " - . JFactory::getDate($module->created)->format("jS F, Y") - . "

"; - // set xml description - CFactory::_('Language')->set( - $module->key, $module->lang_prefix . '_XML_DESCRIPTION', - $module->xml_description - ); - // update the readme if set - if ($module->addreadme == 1 && !empty($module->readme)) - { - $module->readme = CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update(base64_decode((string) $module->readme)) - ); - } - else - { - $module->addreadme = 0; - unset($module->readme); - } - // get the custom_get - $module->custom_get = (isset($module->custom_get) - && JsonHelper::check($module->custom_get)) - ? json_decode((string) $module->custom_get, true) : null; - if (ArrayHelper::check($module->custom_get)) - { - $module->custom_get = $this->setGetData( - $module->custom_get, $module->key, $module->key - ); - } - else - { - $module->custom_get = false; - } - // set helper class details - if ($module->add_class_helper >= 1 - && StringHelper::check( - $module->class_helper_code - )) - { - if ($module->add_class_helper_header == 1 - && StringHelper::check( - $module->class_helper_header - )) - { - // set GUI mapper field - $guiMapper['field'] = 'class_helper_header'; - // base64 Decode code - $module->class_helper_header = PHP_EOL - . CFactory::_('Customcode.Gui')->set( - CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update( - base64_decode( - (string) $module->class_helper_header - ) - ) - ), - $guiMapper - ) . PHP_EOL; - } - else - { - $module->add_class_helper_header = 0; - $module->class_helper_header = ''; - } - // set GUI mapper field - $guiMapper['field'] = 'class_helper_code'; - // base64 Decode code - $module->class_helper_code = CFactory::_('Customcode.Gui')->set( - CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update( - base64_decode((string) $module->class_helper_code) - ) - ), - $guiMapper - ); - // set class type - if ($module->add_class_helper == 2) - { - $module->class_helper_type = 'abstract class '; - } - else - { - $module->class_helper_type = 'class '; - } - } - else - { - $module->add_class_helper = 0; - $module->class_helper_code = ''; - $module->class_helper_header = ''; - } - // base64 Decode mod_code - if (isset($module->mod_code) - && StringHelper::check($module->mod_code)) - { - // set GUI mapper field - $guiMapper['field'] = 'mod_code'; - $module->mod_code = CFactory::_('Customcode.Gui')->set( - CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update( - base64_decode((string) $module->mod_code) - ) - ), - $guiMapper - ); - } - else - { - $module->mod_code = "// get the module class sfx"; - $module->mod_code .= PHP_EOL - . "\$moduleclass_sfx = htmlspecialchars(\$params->get('moduleclass_sfx'), ENT_COMPAT, 'UTF-8');"; - $module->mod_code .= PHP_EOL . "// load the default Tmpl"; - $module->mod_code .= PHP_EOL - . "require JModuleHelper::getLayoutPath('mod_" - . strtolower((string) $module->code_name) - . "', \$params->get('layout', 'default'));"; - } - // base64 Decode default header - if (isset($module->default_header) - && StringHelper::check( - $module->default_header - )) - { - // set GUI mapper field - $guiMapper['field'] = 'default_header'; - $module->default_header = CFactory::_('Customcode.Gui')->set( - CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update( - base64_decode((string) $module->default_header) - ) - ), - $guiMapper - ); - } - else - { - $module->default_header = ''; - } - // base64 Decode default - if (isset($module->default) - && StringHelper::check($module->default)) - { - // set GUI mapper field - $guiMapper['field'] = 'default'; - $guiMapper['type'] = 'html'; - $module->default = CFactory::_('Customcode.Gui')->set( - CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update( - base64_decode((string) $module->default) - ) - ), - $guiMapper - ); - } - else - { - $module->default = '

No Tmpl set

'; - } - // start the config array - $module->config_fields = array(); - // create the form arrays - $module->form_files = array(); - $module->fieldsets_label = array(); - $module->fieldsets_paths = array(); - $module->add_rule_path = array(); - $module->add_field_path = array(); - // set global fields rule to default component path - $module->fields_rules_paths = 1; - // set the fields data - $module->fields = (isset($module->fields) - && JsonHelper::check($module->fields)) - ? json_decode((string) $module->fields, true) : null; - if (ArrayHelper::check($module->fields)) - { - // ket global key - $key = $module->key; - $dynamic_fields = array('fieldset' => 'basic', - 'fields_name' => 'params', - 'file' => 'config'); - foreach ($module->fields as $n => &$form) - { - if (isset($form['fields']) - && ArrayHelper::check( - $form['fields'] - )) - { - // make sure the dynamic_field is set to dynamic_value by default - foreach ( - $dynamic_fields as $dynamic_field => - $dynamic_value - ) - { - if (!isset($form[$dynamic_field]) - || !StringHelper::check( - $form[$dynamic_field] - )) - { - $form[$dynamic_field] = $dynamic_value; - } - else - { - if ('fields_name' === $dynamic_field - && strpos((string) $form[$dynamic_field], '.') - !== false) - { - $form[$dynamic_field] - = $form[$dynamic_field]; - } - else - { - $form[$dynamic_field] - = StringHelper::safe( - $form[$dynamic_field] - ); - } - } - } - // check if field is external form file - if (!isset($form['module']) || $form['module'] != 1) - { - // now build the form key - $unique = $form['file'] . $form['fields_name'] - . $form['fieldset']; - } - else - { - // now build the form key - $unique = $form['fields_name'] - . $form['fieldset']; - } - // set global fields rule path switches - if ($module->fields_rules_paths == 1 - && isset($form['fields_rules_paths']) - && $form['fields_rules_paths'] == 2) - { - $module->fields_rules_paths = 2; - } - // set where to path is pointing - $module->fieldsets_paths[$unique] - = $form['fields_rules_paths']; - // check for extra rule paths - if (isset($form['addrulepath']) - && ArrayHelper::check($form['addrulepath'])) - { - foreach ($form['addrulepath'] as $add_rule_path) - { - if (StringHelper::check($add_rule_path['path'])) - { - $module->add_rule_path[$unique] = $add_rule_path['path']; - } - } - } - // check for extra field paths - if (isset($form['addfieldpath']) - && ArrayHelper::check($form['addfieldpath'])) - { - foreach ($form['addfieldpath'] as $add_field_path) - { - if (StringHelper::check($add_field_path['path'])) - { - $module->add_field_path[$unique] = $add_field_path['path']; - } - } - } - // add the label if set to lang - if (isset($form['label']) - && StringHelper::check( - $form['label'] - )) - { - $module->fieldsets_label[$unique] - = CFactory::_('Language')->key($form['label']); - } - // build the fields - $form['fields'] = array_map( - function ($field) use ($key, $unique) { - // make sure the alias and title is 0 - $field['alias'] = 0; - $field['title'] = 0; - // set the field details - CFactory::_('Field')->set( - $field, $key, $key, $unique - ); - // update the default if set - if (StringHelper::check( - $field['custom_value'] - ) - && isset($field['settings'])) - { - if (($old_default - = GetHelper::between( - $field['settings']->xml, - 'default="', '"', false - )) !== false) - { - // replace old default - $field['settings']->xml - = str_replace( - 'default="' . $old_default - . '"', 'default="' - . $field['custom_value'] . '"', - (string) $field['settings']->xml - ); - } - else - { - // add the default (hmmm not ideal but okay it should work) - $field['settings']->xml - = 'default="' - . $field['custom_value'] . '" ' - . $field['settings']->xml; - } - } - unset($field['custom_value']); - - // return field - return $field; - }, array_values($form['fields']) - ); - // check if field is external form file - if (!isset($form['module']) || $form['module'] != 1) - { - // load the form file - if (!isset($module->form_files[$form['file']])) - { - $module->form_files[$form['file']] - = array(); - } - if (!isset($module->form_files[$form['file']][$form['fields_name']])) - { - $module->form_files[$form['file']][$form['fields_name']] - = array(); - } - if (!isset($module->form_files[$form['file']][$form['fields_name']][$form['fieldset']])) - { - $module->form_files[$form['file']][$form['fields_name']][$form['fieldset']] - = array(); - } - // do some house cleaning (for fields) - foreach ($form['fields'] as $field) - { - // so first we lock the field name in - CFactory::_('Field.Name')->get( - $field, $module->key, $unique - ); - // add the fields to the global form file builder - $module->form_files[$form['file']][$form['fields_name']][$form['fieldset']][] - = $field; - } - // remove form - unset($module->fields[$n]); - } - else - { - // load the config form - if (!isset($module->config_fields[$form['fields_name']])) - { - $module->config_fields[$form['fields_name']] - = array(); - } - if (!isset($module->config_fields[$form['fields_name']][$form['fieldset']])) - { - $module->config_fields[$form['fields_name']][$form['fieldset']] - = array(); - } - // do some house cleaning (for fields) - foreach ($form['fields'] as $field) - { - // so first we lock the field name in - CFactory::_('Field.Name')->get( - $field, $module->key, $unique - ); - // add the fields to the config builder - $module->config_fields[$form['fields_name']][$form['fieldset']][] - = $field; - } - // remove form - unset($module->fields[$n]); - } - } - else - { - unset($module->fields[$n]); - } - } - } - unset($module->fields); - // set the add targets - $addArray = array('files' => 'files', - 'folders' => 'folders', - 'urls' => 'urls', - 'filesfullpath' => 'files', - 'foldersfullpath' => 'folders'); - foreach ($addArray as $addTarget => $targetHere) - { - // set the add target data - $module->{'add' . $addTarget} = (isset( - $module->{'add' . $addTarget} - ) - && JsonHelper::check( - $module->{'add' . $addTarget} - )) ? json_decode((string) $module->{'add' . $addTarget}, true) - : null; - if (ArrayHelper::check( - $module->{'add' . $addTarget} - )) - { - if (isset($module->{$targetHere}) - && ArrayHelper::check( - $module->{$targetHere} - )) - { - foreach ($module->{'add' . $addTarget} as $taget) - { - $module->{$targetHere}[] = $taget; - } - } - else - { - $module->{$targetHere} = array_values( - $module->{'add' . $addTarget} - ); - } - } - unset($module->{'add' . $addTarget}); - } - // make sure json become array - if (JsonHelper::check($module->libraries)) - { - $module->libraries = json_decode((string) $module->libraries, true); - } - // if we have an array add it - if (ArrayHelper::check($module->libraries)) - { - foreach ($module->libraries as $library) - { - if (!CFactory::_('Registry')->exists('builder.library_manager.' . - CFactory::_('Config')->build_target . '.' . $module->code_name . '.' . (int) $library)) - { - if ($this->getMediaLibrary((int) $library)) - { - CFactory::_('Registry')->set('builder.library_manager.' . - CFactory::_('Config')->build_target . '.' . $module->code_name . '.' . (int) $library, true); - } - } - } - } - elseif (is_numeric($module->libraries) - && !CFactory::_('Registry')->exists('builder.library_manager.' . - CFactory::_('Config')->build_target . '.' . $module->code_name . '.' . (int) $module->libraries)) - { - if ($this->getMediaLibrary((int) $module->libraries)) - { - CFactory::_('Registry')->set('builder.library_manager.' . - CFactory::_('Config')->build_target . '.' . $module->code_name . '.' . (int) $module->libraries, true); - } - } - // add PHP in module install - $module->add_install_script = false; - $addScriptMethods = array('php_preflight', - 'php_postflight', - 'php_method'); - $addScriptTypes = array('install', 'update', - 'uninstall'); - // the next are php placeholders - $guiMapper['type'] = 'php'; - foreach ($addScriptMethods as $scriptMethod) - { - foreach ($addScriptTypes as $scriptType) - { - if (isset( - $module->{'add_' . $scriptMethod . '_' - . $scriptType} - ) - && $module->{'add_' . $scriptMethod . '_' - . $scriptType} == 1 - && StringHelper::check( - $module->{$scriptMethod . '_' . $scriptType} - )) - { - // set GUI mapper field - $guiMapper['field'] = $scriptMethod . '_' - . $scriptType; - $module->{$scriptMethod . '_' . $scriptType} = CFactory::_('Customcode.Gui')->set( - CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update( - base64_decode( - (string) $module->{$scriptMethod . '_' - . $scriptType} - ) - ) - ), - $guiMapper - ); - $module->add_install_script = true; - } - else - { - unset($module->{$scriptMethod . '_' . $scriptType}); - $module->{'add_' . $scriptMethod . '_' - . $scriptType} - = 0; - } - } - } - // add_sql - if ($module->add_sql == 1 - && StringHelper::check($module->sql)) - { - $module->sql = CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update(base64_decode((string) $module->sql)) - ); - } - else - { - unset($module->sql); - $module->add_sql = 0; - } - // add_sql_uninstall - if ($module->add_sql_uninstall == 1 - && StringHelper::check( - $module->sql_uninstall - )) - { - $module->sql_uninstall = CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update( - base64_decode((string) $module->sql_uninstall) - ) - ); - } - else - { - unset($module->sql_uninstall); - $module->add_sql_uninstall = 0; - } - // update the URL of the update_server if set - if ($module->add_update_server == 1 - && StringHelper::check( - $module->update_server_url - )) - { - $module->update_server_url = CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update($module->update_server_url) - ); - } - // add the update/sales server FTP details if that is the expected protocol - $serverArray = array('update_server', 'sales_server'); - foreach ($serverArray as $server) - { - if ($module->{'add_' . $server} == 1 - && is_numeric( - $module->{$server} - ) - && $module->{$server} > 0) - { - // get the server protocol - $module->{$server . '_protocol'} - = GetHelper::var( - 'server', (int) $module->{$server}, 'id', 'protocol' - ); - } - else - { - $module->{$server} = 0; - // only change this for sales server (update server can be added loacaly to the zip file) - if ('sales_server' === $server) - { - $module->{'add_' . $server} = 0; - } - $module->{$server . '_protocol'} = 0; - } - } - // set the update server stuff (TODO) - // update_server_xml_path - // update_server_xml_file_name - - // rest globals - CFactory::_('Config')->build_target = $_backup_target; - CFactory::_('Config')->lang_target = $_backup_lang; - $this->langPrefix = $_backup_langPrefix; - CFactory::_('Config')->lang_prefix = $_backup_langPrefix; - - CFactory::_('Placeholder')->remove('Module_name'); - CFactory::_('Placeholder')->remove('Module'); - CFactory::_('Placeholder')->remove('module'); - CFactory::_('Placeholder')->remove('module.version'); - CFactory::_('Placeholder')->remove('module_version'); - - $this->joomlaModules[$id] = $module; - - return true; - } - } - - return false; + return CFactory::_('Joomlamodule.Data')->set($id); } /** @@ -7550,689 +2793,11 @@ class Get * set the Joomla plugins * * @return true - * + * @deprecated 3.3 Use CFactory::_('Joomlamodule.Data')->set($id); */ public function setJoomlaPlugin($id, &$component) { - if (isset($this->joomlaPlugins[$id])) - { - return true; - } - else - { - // Create a new query object. - $query = $this->db->getQuery(true); - - $query->select('a.*'); - $query->select( - $this->db->quoteName( - array( - 'g.name', - 'e.name', - 'e.head', - 'e.comment', - 'e.id', - 'f.addfiles', - 'f.addfolders', - 'f.addfilesfullpath', - 'f.addfoldersfullpath', - 'f.addurls', - 'u.version_update', - 'u.id' - ), array( - 'group', - 'extends', - 'class_head', - 'comment', - 'class_id', - 'addfiles', - 'addfolders', - 'addfilesfullpath', - 'addfoldersfullpath', - 'addurls', - 'version_update', - 'version_update_id' - ) - ) - ); - // from these tables - $query->from('#__componentbuilder_joomla_plugin AS a'); - $query->join( - 'LEFT', $this->db->quoteName( - '#__componentbuilder_joomla_plugin_group', 'g' - ) . ' ON (' . $this->db->quoteName('a.joomla_plugin_group') - . ' = ' . $this->db->quoteName('g.id') . ')' - ); - $query->join( - 'LEFT', - $this->db->quoteName('#__componentbuilder_class_extends', 'e') - . ' ON (' . $this->db->quoteName('a.class_extends') . ' = ' - . $this->db->quoteName('e.id') . ')' - ); - $query->join( - 'LEFT', $this->db->quoteName( - '#__componentbuilder_joomla_plugin_updates', 'u' - ) . ' ON (' . $this->db->quoteName('a.id') . ' = ' - . $this->db->quoteName('u.joomla_plugin') . ')' - ); - $query->join( - 'LEFT', $this->db->quoteName( - '#__componentbuilder_joomla_plugin_files_folders_urls', 'f' - ) . ' ON (' . $this->db->quoteName('a.id') . ' = ' - . $this->db->quoteName('f.joomla_plugin') . ')' - ); - $query->where($this->db->quoteName('a.id') . ' = ' . (int) $id); - $query->where($this->db->quoteName('a.published') . ' >= 1'); - $this->db->setQuery($query); - $this->db->execute(); - if ($this->db->getNumRows()) - { - // get the plugin data - $plugin = $this->db->loadObject(); - // tweak system to set stuff to the plugin domain - $_backup_target = CFactory::_('Config')->build_target; - $_backup_lang = CFactory::_('Config')->lang_target; - $_backup_langPrefix = CFactory::_('Config')->lang_prefix; - // set some keys - $plugin->target_type = 'P|uG!n'; - $plugin->key = $plugin->id . '_' . $plugin->target_type; - // update to point to plugin - CFactory::_('Config')->build_target = $plugin->key; - CFactory::_('Config')->lang_target = $plugin->key; - // set version if not set - if (empty($plugin->plugin_version)) - { - $plugin->plugin_version = '1.0.0'; - } - // set GUI mapper - $guiMapper = array('table' => 'joomla_plugin', - 'id' => (int) $id, 'type' => 'php'); - // update the name if it has dynamic values - $plugin->name = CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update($plugin->name) - ); - // update the name if it has dynamic values - $plugin->code_name - = ClassfunctionHelper::safe( - $plugin->name - ); - // set official name - $plugin->official_name = ucwords( - $plugin->group . ' - ' . $plugin->name - ); - // set lang prefix - $plugin->lang_prefix = PluginHelper::safeLangPrefix( - $plugin->code_name, - $plugin->group - ); - // set langPrefix - CFactory::_('Config')->lang_prefix = $plugin->lang_prefix; - $this->langPrefix = $plugin->lang_prefix; - // set plugin class name - $plugin->class_name - = PluginHelper::safeClassName( - $plugin->code_name, - $plugin->group - ); - // set plugin install class name - $plugin->installer_class_name - = PluginHelper::safeInstallClassName( - $plugin->code_name, - $plugin->group - ); - // set plugin folder name - $plugin->folder_name - = PluginHelper::safeFolderName( - $plugin->code_name, - $plugin->group - ); - // set the zip name - $plugin->zip_name = $plugin->folder_name . '_v' . str_replace( - '.', '_', (string) $plugin->plugin_version - ) . '__J' . CFactory::_('Config')->joomla_version; - // set plugin file name - $plugin->file_name = strtolower((string) $plugin->code_name); - // set plugin context - $plugin->context = $plugin->folder_name . '.' . $plugin->id; - // set official_name lang strings - CFactory::_('Language')->set( - $plugin->key, CFactory::_('Config')->lang_prefix, $plugin->official_name - ); - // set some placeholder for this plugin - CFactory::_('Placeholder')->set('Plugin_name', $plugin->official_name); - CFactory::_('Placeholder')->set('PLUGIN_NAME', $plugin->official_name); - CFactory::_('Placeholder')->set('Plugin', ucfirst((string) $plugin->code_name)); - CFactory::_('Placeholder')->set('plugin', strtolower((string) $plugin->code_name)); - CFactory::_('Placeholder')->set('Plugin_group', ucfirst((string) $plugin->group)); - CFactory::_('Placeholder')->set('plugin_group', strtolower((string) $plugin->group)); - CFactory::_('Placeholder')->set('plugin.version', $plugin->plugin_version); - CFactory::_('Placeholder')->set('VERSION', $plugin->plugin_version); - CFactory::_('Placeholder')->set('plugin_version', str_replace( - '.', '_', (string) $plugin->plugin_version - )); - // set description - CFactory::_('Placeholder')->set('DESCRIPTION', ''); - if (!isset($plugin->description) - || !StringHelper::check( - $plugin->description - )) - { - $plugin->description = ''; - } - else - { - $plugin->description = CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update($plugin->description) - ); - CFactory::_('Language')->set( - $plugin->key, $plugin->lang_prefix . '_DESCRIPTION', - $plugin->description - ); - // set description - CFactory::_('Placeholder')->set('DESCRIPTION', $plugin->description); - $plugin->description = '

' . $plugin->description . '

'; - } - $plugin->xml_description = "

" . $plugin->official_name - . " (v." . $plugin->plugin_version - . ")

" - . $plugin->description . "

Created by " . trim( - (string) JFilterOutput::cleanText($component->author) - ) . "
Development started " - . JFactory::getDate($plugin->created)->format("jS F, Y") - . "

"; - // set xml discription - CFactory::_('Language')->set( - $plugin->key, $plugin->lang_prefix . '_XML_DESCRIPTION', - $plugin->xml_description - ); - // update the readme if set - if ($plugin->addreadme == 1 && !empty($plugin->readme)) - { - $plugin->readme = CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update(base64_decode((string) $plugin->readme)) - ); - } - else - { - $plugin->addreadme = 0; - unset($plugin->readme); - } - // open some base64 strings - if (!empty($plugin->main_class_code)) - { - // set GUI mapper field - $guiMapper['field'] = 'main_class_code'; - // base64 Decode main_class_code. - $plugin->main_class_code = CFactory::_('Customcode.Gui')->set( - CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update( - base64_decode((string) $plugin->main_class_code) - ) - ), - $guiMapper - ); - } - // set the head :) - if ($plugin->add_head == 1 && !empty($plugin->head)) - { - // set GUI mapper field - $guiMapper['field'] = 'head'; - // base64 Decode head. - $plugin->head = CFactory::_('Customcode.Gui')->set( - CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update( - base64_decode((string) $plugin->head) - ) - ), - $guiMapper - ); - } - elseif (!empty($plugin->class_head)) - { - // base64 Decode head. - $plugin->head = CFactory::_('Customcode.Gui')->set( - CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update( - base64_decode((string) $plugin->class_head) - ) - ), - array( - 'table' => 'class_extends', - 'field' => 'head', - 'id' => (int) $plugin->class_id, - 'type' => 'php') - ); - } - unset($plugin->class_head); - // set the comment - if (!empty($plugin->comment)) - { - // base64 Decode comment. - $plugin->comment = CFactory::_('Customcode.Gui')->set( - CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update( - base64_decode((string) $plugin->comment) - ) - ), - array( - 'table' => 'class_extends', - 'field' => 'comment', - 'id' => (int) $plugin->class_id, - 'type' => 'php') - ); - } - // start the config array - $plugin->config_fields = array(); - // create the form arrays - $plugin->form_files = array(); - $plugin->fieldsets_label = array(); - $plugin->fieldsets_paths = array(); - $plugin->add_rule_path = array(); - $plugin->add_field_path = array(); - // set global fields rule to default component path - $plugin->fields_rules_paths = 1; - // set the fields data - $plugin->fields = (isset($plugin->fields) - && JsonHelper::check($plugin->fields)) - ? json_decode((string) $plugin->fields, true) : null; - if (ArrayHelper::check($plugin->fields)) - { - // ket global key - $key = $plugin->key; - $dynamic_fields = array('fieldset' => 'basic', - 'fields_name' => 'params', - 'file' => 'config'); - foreach ($plugin->fields as $n => &$form) - { - if (isset($form['fields']) - && ArrayHelper::check( - $form['fields'] - )) - { - // make sure the dynamic_field is set to dynamic_value by default - foreach ( - $dynamic_fields as $dynamic_field => - $dynamic_value - ) - { - if (!isset($form[$dynamic_field]) - || !StringHelper::check( - $form[$dynamic_field] - )) - { - $form[$dynamic_field] = $dynamic_value; - } - else - { - if ('fields_name' === $dynamic_field - && strpos((string) $form[$dynamic_field], '.') - !== false) - { - $form[$dynamic_field] - = $form[$dynamic_field]; - } - else - { - $form[$dynamic_field] - = StringHelper::safe( - $form[$dynamic_field] - ); - } - } - } - // check if field is external form file - if (!isset($form['plugin']) || $form['plugin'] != 1) - { - // now build the form key - $unique = $form['file'] . $form['fields_name'] - . $form['fieldset']; - } - else - { - // now build the form key - $unique = $form['fields_name'] - . $form['fieldset']; - } - // set global fields rule path switchs - if ($plugin->fields_rules_paths == 1 - && isset($form['fields_rules_paths']) - && $form['fields_rules_paths'] == 2) - { - $plugin->fields_rules_paths = 2; - } - // set where to path is pointing - $plugin->fieldsets_paths[$unique] - = $form['fields_rules_paths']; - // add the label if set to lang - if (isset($form['label']) - && StringHelper::check( - $form['label'] - )) - { - $plugin->fieldsets_label[$unique] - = CFactory::_('Language')->key($form['label']); - } - // check for extra rule paths - if (isset($form['addrulepath']) - && ArrayHelper::check($form['addrulepath'])) - { - foreach ($form['addrulepath'] as $add_rule_path) - { - if (StringHelper::check($add_rule_path['path'])) - { - $plugin->add_rule_path[$unique] = $add_rule_path['path']; - } - } - } - // check for extra field paths - if (isset($form['addfieldpath']) - && ArrayHelper::check($form['addfieldpath'])) - { - foreach ($form['addfieldpath'] as $add_field_path) - { - if (StringHelper::check($add_field_path['path'])) - { - $plugin->add_field_path[$unique] = $add_field_path['path']; - } - } - } - // build the fields - $form['fields'] = array_map( - function ($field) use ($key, $unique) { - // make sure the alias and title is 0 - $field['alias'] = 0; - $field['title'] = 0; - // set the field details - CFactory::_('Field')->set( - $field, $key, $key, $unique - ); - // update the default if set - if (StringHelper::check( - $field['custom_value'] - ) - && isset($field['settings'])) - { - if (($old_default - = GetHelper::between( - $field['settings']->xml, - 'default="', '"', false - )) !== false) - { - // replace old default - $field['settings']->xml - = str_replace( - 'default="' . $old_default - . '"', 'default="' - . $field['custom_value'] . '"', - (string) $field['settings']->xml - ); - } - else - { - // add the default (hmmm not ideal but okay it should work) - $field['settings']->xml - = 'default="' - . $field['custom_value'] . '" ' - . $field['settings']->xml; - } - } - unset($field['custom_value']); - - // return field - return $field; - }, array_values($form['fields']) - ); - // check if field is external form file - if (!isset($form['plugin']) || $form['plugin'] != 1) - { - // load the form file - if (!isset($plugin->form_files[$form['file']])) - { - $plugin->form_files[$form['file']] - = array(); - } - if (!isset($plugin->form_files[$form['file']][$form['fields_name']])) - { - $plugin->form_files[$form['file']][$form['fields_name']] - = array(); - } - if (!isset($plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']])) - { - $plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']] - = array(); - } - // do some house cleaning (for fields) - foreach ($form['fields'] as $field) - { - // so first we lock the field name in - CFactory::_('Field.Name')->get( - $field, $plugin->key, $unique - ); - // add the fields to the global form file builder - $plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']][] - = $field; - } - // remove form - unset($plugin->fields[$n]); - } - else - { - // load the config form - if (!isset($plugin->config_fields[$form['fields_name']])) - { - $plugin->config_fields[$form['fields_name']] - = array(); - } - if (!isset($plugin->config_fields[$form['fields_name']][$form['fieldset']])) - { - $plugin->config_fields[$form['fields_name']][$form['fieldset']] - = array(); - } - // do some house cleaning (for fields) - foreach ($form['fields'] as $field) - { - // so first we lock the field name in - CFactory::_('Field.Name')->get( - $field, $plugin->key, $unique - ); - // add the fields to the config builder - $plugin->config_fields[$form['fields_name']][$form['fieldset']][] - = $field; - } - // remove form - unset($plugin->fields[$n]); - } - } - else - { - unset($plugin->fields[$n]); - } - } - } - unset($plugin->fields); - // set the add targets - $addArray = array('files' => 'files', - 'folders' => 'folders', - 'urls' => 'urls', - 'filesfullpath' => 'files', - 'foldersfullpath' => 'folders'); - foreach ($addArray as $addTarget => $targetHere) - { - // set the add target data - $plugin->{'add' . $addTarget} = (isset( - $plugin->{'add' . $addTarget} - ) - && JsonHelper::check( - $plugin->{'add' . $addTarget} - )) ? json_decode((string) $plugin->{'add' . $addTarget}, true) - : null; - if (ArrayHelper::check( - $plugin->{'add' . $addTarget} - )) - { - if (isset($plugin->{$targetHere}) - && ArrayHelper::check( - $plugin->{$targetHere} - )) - { - foreach ($plugin->{'add' . $addTarget} as $taget) - { - $plugin->{$targetHere}[] = $taget; - } - } - else - { - $plugin->{$targetHere} = array_values( - $plugin->{'add' . $addTarget} - ); - } - } - unset($plugin->{'add' . $addTarget}); - } - // add PHP in plugin install - $plugin->add_install_script = false; - $addScriptMethods = array('php_preflight', - 'php_postflight', - 'php_method'); - $addScriptTypes = array('install', 'update', - 'uninstall'); - foreach ($addScriptMethods as $scriptMethod) - { - foreach ($addScriptTypes as $scriptType) - { - if (isset( - $plugin->{'add_' . $scriptMethod . '_' - . $scriptType} - ) - && $plugin->{'add_' . $scriptMethod . '_' - . $scriptType} == 1 - && StringHelper::check( - $plugin->{$scriptMethod . '_' . $scriptType} - )) - { - // set GUI mapper field - $guiMapper['field'] = $scriptMethod . '_' - . $scriptType; - $plugin->{$scriptMethod . '_' . $scriptType} - = CFactory::_('Customcode.Gui')->set( - CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update( - base64_decode( - (string) $plugin->{$scriptMethod . '_' - . $scriptType} - ) - ) - ), - $guiMapper - ); - $plugin->add_install_script = true; - } - else - { - unset($plugin->{$scriptMethod . '_' . $scriptType}); - $plugin->{'add_' . $scriptMethod . '_' - . $scriptType} - = 0; - } - } - } - // add_sql - if ($plugin->add_sql == 1 - && StringHelper::check($plugin->sql)) - { - $plugin->sql = CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update(base64_decode((string) $plugin->sql)) - ); - } - else - { - unset($plugin->sql); - $plugin->add_sql = 0; - } - // add_sql_uninstall - if ($plugin->add_sql_uninstall == 1 - && StringHelper::check( - $plugin->sql_uninstall - )) - { - $plugin->sql_uninstall = CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update( - base64_decode((string) $plugin->sql_uninstall) - ) - ); - } - else - { - unset($plugin->sql_uninstall); - $plugin->add_sql_uninstall = 0; - } - // update the URL of the update_server if set - if ($plugin->add_update_server == 1 - && StringHelper::check( - $plugin->update_server_url - )) - { - $plugin->update_server_url = CFactory::_('Placeholder')->update_( - CFactory::_('Customcode')->update($plugin->update_server_url) - ); - } - // add the update/sales server FTP details if that is the expected protocol - $serverArray = array('update_server', 'sales_server'); - foreach ($serverArray as $server) - { - if ($plugin->{'add_' . $server} == 1 - && is_numeric( - $plugin->{$server} - ) - && $plugin->{$server} > 0) - { - // get the server protocol - $plugin->{$server . '_protocol'} - = GetHelper::var( - 'server', (int) $plugin->{$server}, 'id', 'protocol' - ); - } - else - { - $plugin->{$server} = 0; - // only change this for sales server (update server can be added locally to the zip file) - if ('sales_server' === $server) - { - $plugin->{'add_' . $server} = 0; - } - $plugin->{$server . '_protocol'} = 0; - } - } - // set the update server stuff (TODO) - // update_server_xml_path - // update_server_xml_file_name - - // rest globals - CFactory::_('Config')->build_target = $_backup_target; - CFactory::_('Config')->lang_target = $_backup_lang; - $this->langPrefix = $_backup_langPrefix; - CFactory::_('Config')->set('lang_prefix', $_backup_langPrefix); - - CFactory::_('Placeholder')->remove('Plugin_name'); - CFactory::_('Placeholder')->remove('Plugin'); - CFactory::_('Placeholder')->remove('plugin'); - CFactory::_('Placeholder')->remove('Plugin_group'); - CFactory::_('Placeholder')->remove('plugin_group'); - CFactory::_('Placeholder')->remove('plugin.version'); - CFactory::_('Placeholder')->remove('plugin_version'); - CFactory::_('Placeholder')->remove('VERSION'); - CFactory::_('Placeholder')->remove('DESCRIPTION'); - CFactory::_('Placeholder')->remove('PLUGIN_NAME'); - - $this->joomlaPlugins[$id] = $plugin; - - return true; - } - } - - return false; + return CFactory::_('Joomlaplugin.Data')->set($id); } /** diff --git a/admin/helpers/compiler/b_Structure.php b/admin/helpers/compiler/b_Structure.php index 88258ec34..4970a6fb7 100644 --- a/admin/helpers/compiler/b_Structure.php +++ b/admin/helpers/compiler/b_Structure.php @@ -28,15 +28,16 @@ use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; /** * Structure class + * @deprecated 3.3 */ class Structure extends Get { - /** * The folder counter * * @var int + * @deprecated 3.3 Use CFactory::_('Counter')->folder; */ public $folderCount = 0; @@ -44,6 +45,7 @@ class Structure extends Get * The file counter * * @var int + * @deprecated 3.3 Use CFactory::_('Counter')->file; */ public $fileCount = 0; @@ -51,6 +53,7 @@ class Structure extends Get * The page counter * * @var int + * @deprecated 3.3 */ public $pageCount = 0; @@ -58,6 +61,8 @@ class Structure extends Get * The line counter * * @var int + * @deprecated 3.3 + * @deprecated 3.3 Use CFactory::_('Counter')->line; */ public $lineCount = 0; @@ -65,6 +70,7 @@ class Structure extends Get * The field counter * * @var int + * @deprecated 3.3 */ public $fieldCount = 0; @@ -72,6 +78,7 @@ class Structure extends Get * The seconds counter * * @var int + * @deprecated 3.3 */ public $seconds = 0; @@ -79,6 +86,7 @@ class Structure extends Get * The actual seconds counter * * @var int + * @deprecated 3.3 */ public $actualSeconds = 0; @@ -86,6 +94,7 @@ class Structure extends Get * The folder seconds counter * * @var int + * @deprecated 3.3 */ public $folderSeconds = 0; @@ -93,6 +102,7 @@ class Structure extends Get * The file seconds counter * * @var int + * @deprecated 3.3 */ public $fileSeconds = 0; @@ -100,6 +110,7 @@ class Structure extends Get * The line seconds counter * * @var int + * @deprecated 3.3 */ public $lineSeconds = 0; @@ -107,6 +118,7 @@ class Structure extends Get * The seconds debugging counter * * @var int + * @deprecated 3.3 */ public $secondsDebugging = 0; @@ -114,6 +126,7 @@ class Structure extends Get * The seconds planning counter * * @var int + * @deprecated 3.3 */ public $secondsPlanning = 0; @@ -121,6 +134,7 @@ class Structure extends Get * The seconds mapping counter * * @var int + * @deprecated 3.3 */ public $secondsMapping = 0; @@ -128,6 +142,7 @@ class Structure extends Get * The seconds office counter * * @var int + * @deprecated 3.3 */ public $secondsOffice = 0; @@ -135,6 +150,7 @@ class Structure extends Get * The total hours counter * * @var int + * @deprecated 3.3 */ public $totalHours = 0; @@ -142,6 +158,7 @@ class Structure extends Get * The debugging hours counter * * @var int + * @deprecated 3.3 */ public $debuggingHours = 0; @@ -149,6 +166,7 @@ class Structure extends Get * The planning hours counter * * @var int + * @deprecated 3.3 */ public $planningHours = 0; @@ -156,6 +174,7 @@ class Structure extends Get * The mapping hours counter * * @var int + * @deprecated 3.3 */ public $mappingHours = 0; @@ -163,6 +182,7 @@ class Structure extends Get * The office hours counter * * @var int + * @deprecated 3.3 */ public $officeHours = 0; @@ -170,6 +190,7 @@ class Structure extends Get * The actual Total Hours counter * * @var int + * @deprecated 3.3 */ public $actualTotalHours = 0; @@ -177,6 +198,7 @@ class Structure extends Get * The actual hours spent counter * * @var int + * @deprecated 3.3 */ public $actualHoursSpent = 0; @@ -184,6 +206,7 @@ class Structure extends Get * The actual days spent counter * * @var int + * @deprecated 3.3 */ public $actualDaysSpent = 0; @@ -191,6 +214,7 @@ class Structure extends Get * The total days counter * * @var int + * @deprecated 3.3 */ public $totalDays = 0; @@ -198,6 +222,7 @@ class Structure extends Get * The actual Total Days counter * * @var int + * @deprecated 3.3 */ public $actualTotalDays = 0; @@ -205,6 +230,7 @@ class Structure extends Get * The project week time counter * * @var int + * @deprecated 3.3 */ public $projectWeekTime = 0; @@ -212,6 +238,7 @@ class Structure extends Get * The project month time counter * * @var int + * @deprecated 3.3 */ public $projectMonthTime = 0; @@ -378,11 +405,11 @@ class Structure extends Get */ public function __construct() { - // first we run the perent constructor + // first we run the parent constructor if (parent::__construct()) { // set the standard admin file - $this->stdRootFiles[] = $this->componentData->name_code . '.php'; + $this->stdRootFiles[] = CFactory::_('Component')->get('name_code') . '.php'; // set incase no extra admin folder are loaded CFactory::_('Content')->set('EXSTRA_ADMIN_FOLDERS', ''); // set incase no extra site folder are loaded @@ -395,22 +422,20 @@ class Structure extends Get CFactory::_('Content')->set('EXSTRA_SITE_FILES', ''); // set incase no extra media files are loaded CFactory::_('Content')->set('EXSTRA_MEDIA_FILES', ''); - // run global updater - ComponentbuilderHelper::runGlobalUpdater(); // set the template path $this->templatePath = CFactory::_('Config')->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/joomla_' - . $this->joomlaVersions[CFactory::_('Config')->joomla_version]['folder_key']; + . CFactory::_('Config')->joomla_versions[CFactory::_('Config')->joomla_version]['folder_key']; // set some default names $this->componentSalesName = 'com_' - . $this->componentData->sales_name . '__J' + . CFactory::_('Component')->get('sales_name') . '__J' . CFactory::_('Config')->joomla_version; $this->componentBackupName = 'com_' - . $this->componentData->sales_name . '_v' . str_replace( - '.', '_', (string) $this->componentData->component_version + . CFactory::_('Component')->get('sales_name') . '_v' . str_replace( + '.', '_', (string) CFactory::_('Component')->get('component_version') ) . '__J' . CFactory::_('Config')->joomla_version; $this->componentFolderName = 'com_' - . $this->componentData->name_code . '_v' . str_replace( - '.', '_', (string) $this->componentData->component_version + . CFactory::_('Component')->get('name_code') . '_v' . str_replace( + '.', '_', (string) CFactory::_('Component')->get('component_version') ) . '__J' . CFactory::_('Config')->joomla_version; // set component folder path $this->componentPath = CFactory::_('Config')->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/' @@ -526,7 +551,7 @@ class Structure extends Get ); $this->newFiles[$power->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; if (!isset($htaccess[$power->path_jcb])) { // set the htaccess data @@ -547,7 +572,7 @@ class Structure extends Get ); $this->newFiles[$power->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; // now we must add the htaccess.txt file where the zip package my not get the [.] files $fileDetails = array('path' => $power->full_path_jcb . '/htaccess.txt', 'name' => 'htaccess.txt', @@ -557,7 +582,7 @@ class Structure extends Get ); $this->newFiles[$power->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; // now we must add the web.config file $fileDetails = array('path' => $power->full_path_jcb . '/web.config', 'name' => 'web.config', @@ -574,7 +599,7 @@ class Structure extends Get ); $this->newFiles[$power->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; // we set these files only once $htaccess[$power->path_jcb] = true; } @@ -591,16 +616,17 @@ class Structure extends Get */ private function buildModules() { - if (ArrayHelper::check($this->joomlaModules)) + if (CFactory::_('Joomlamodule.Data')->exists()) { // for plugin event TODO change event api signatures $component_context = CFactory::_('Config')->component_context; + $modules = CFactory::_('Joomlamodule.Data')->get(); // Trigger Event: jcb_ce_onBeforeSetModules CFactory::_('Event')->trigger( 'jcb_ce_onBeforeBuildModules', - array(&$component_context, &$this->joomlaModules) + array(&$component_context, &$modules) ); - foreach ($this->joomlaModules as $module) + foreach ($modules as $module) { if (ObjectHelper::check($module) && isset($module->folder_name) @@ -633,7 +659,7 @@ class Structure extends Get ); $this->newFiles[$module->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; // set custom_get if ($module->custom_get) { @@ -661,7 +687,7 @@ class Structure extends Get ); $this->newFiles[$module->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } // set helper file if ($module->add_class_helper >= 1) @@ -683,7 +709,7 @@ class Structure extends Get ); $this->newFiles[$module->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } // set main xml file $fileDetails = array('path' => $module->folder_path . '/' @@ -696,7 +722,7 @@ class Structure extends Get ); $this->newFiles[$module->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; // set tmpl folder $this->createFolder($module->folder_path . '/tmpl'); // set default file @@ -715,7 +741,7 @@ class Structure extends Get ); $this->newFiles[$module->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; // set install script if needed if ($module->add_install_script) { @@ -736,7 +762,7 @@ class Structure extends Get ); $this->newFiles[$module->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } // set readme if found if ($module->addreadme) @@ -748,7 +774,7 @@ class Structure extends Get $this->writeFile($fileDetails['path'], $module->readme); $this->newFiles[$module->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } // set the folders target path $target_path = ''; @@ -784,7 +810,7 @@ class Structure extends Get ); $this->newFiles[$module->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; // add the field script $field_script_bucket[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Custom CSS"; @@ -819,7 +845,7 @@ class Structure extends Get ); $this->newFiles[$module->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; // add the field script $field_script_bucket[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Custom JS"; @@ -851,7 +877,7 @@ class Structure extends Get ); $this->newFiles[$module->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } } // set rules folders if needed @@ -1048,7 +1074,7 @@ class Structure extends Get $this->writeFile($fileDetails['path'], $xml); $this->newFiles[$module->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } } // set SQL stuff if needed @@ -1068,7 +1094,7 @@ class Structure extends Get $module->sql ); // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } // now set the uninstall file if ($module->add_sql_uninstall) @@ -1079,7 +1105,7 @@ class Structure extends Get $module->sql_uninstall ); // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } } // creat the language folder @@ -1095,10 +1121,10 @@ class Structure extends Get // add to component files foreach ($module->files as $file) { - // set the path finder + // set the pathfinder $file['target_type'] = $module->target_type; $file['target_id'] = $module->id; - $this->componentData->files[] = $file; + CFactory::_('Component')->appendArray('files', $file); } } // check if this lib has folders @@ -1108,10 +1134,10 @@ class Structure extends Get // add to component folders foreach ($module->folders as $folder) { - // set the path finder + // set the pathfinder $folder['target_type'] = $module->target_type; $folder['target_id'] = $module->id; - $this->componentData->folders[] = $folder; + CFactory::_('Component')->appendArray('folders', $folder); } } // check if this module has urls @@ -1157,7 +1183,7 @@ class Structure extends Get // write data to path $this->writeFile($url['path'], $data); // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } } } @@ -1174,16 +1200,17 @@ class Structure extends Get */ private function buildPlugins() { - if (ArrayHelper::check($this->joomlaPlugins)) + if (CFactory::_('Joomlaplugin.Data')->exists()) { // for plugin event TODO change event api signatures $component_context = CFactory::_('Config')->component_context; + $plugins = CFactory::_('Joomlaplugin.Data')->get(); // Trigger Event: jcb_ce_onBeforeSetPlugins CFactory::_('Event')->trigger( 'jcb_ce_onBeforeBuildPlugins', - array(&$component_context, &$this->joomlaPlugins) + array(&$component_context, &$plugins) ); - foreach ($this->joomlaPlugins as $plugin) + foreach ($plugins as $plugin) { if (ObjectHelper::check($plugin) && isset($plugin->folder_name) @@ -1216,7 +1243,7 @@ class Structure extends Get ); $this->newFiles[$plugin->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; // set main xml file $fileDetails = array('path' => $plugin->folder_path . '/' . $plugin->file_name . '.xml', @@ -1228,7 +1255,7 @@ class Structure extends Get ); $this->newFiles[$plugin->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; // set install script if needed if ($plugin->add_install_script) { @@ -1249,7 +1276,7 @@ class Structure extends Get ); $this->newFiles[$plugin->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } // set readme if found if ($plugin->addreadme) @@ -1261,7 +1288,7 @@ class Structure extends Get $this->writeFile($fileDetails['path'], $plugin->readme); $this->newFiles[$plugin->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } // set fields & rules folders if needed if (isset($plugin->fields_rules_paths) @@ -1441,7 +1468,7 @@ class Structure extends Get $this->writeFile($fileDetails['path'], $xml); $this->newFiles[$plugin->key][] = $fileDetails; // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } } // set SQL stuff if needed @@ -1461,7 +1488,7 @@ class Structure extends Get $plugin->sql ); // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } // now set the uninstall file if ($plugin->add_sql_uninstall) @@ -1472,7 +1499,7 @@ class Structure extends Get $plugin->sql_uninstall ); // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } } // creat the language folder path @@ -1491,7 +1518,7 @@ class Structure extends Get // set the path finder $file['target_type'] = $plugin->target_type; $file['target_id'] = $plugin->id; - $this->componentData->files[] = $file; + CFactory::_('Component')->appendArray('files', $file); } } // check if this lib has folders @@ -1504,7 +1531,7 @@ class Structure extends Get // set the path finder $folder['target_type'] = $plugin->target_type; $folder['target_id'] = $plugin->id; - $this->componentData->folders[] = $folder; + CFactory::_('Component')->appendArray('folders', $folder); } } // check if this plugin has urls @@ -1550,7 +1577,7 @@ class Structure extends Get // write data to path $this->writeFile($url['path'], $data); // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } } } @@ -1576,7 +1603,7 @@ class Structure extends Get $path ); // count the folder created - $this->folderCount++; + CFactory::_('Counter')->folder++; // add index.html (boring I know) $this->indexHTML( $path, '' @@ -1592,7 +1619,7 @@ class Structure extends Get */ private function setLibraries() { - if (($libraries_ = CFactory::_('Registry')->extract('builder.libraries')) !== null) + if (($libraries_ = CFactory::_('Registry')->get('builder.libraries')) !== null) { // for plugin event TODO change event api signatures $component_context = CFactory::_('Config')->component_context; @@ -1606,7 +1633,7 @@ class Structure extends Get { Folder::create($this->componentPath); // count the folder created - $this->folderCount++; + CFactory::_('Counter')->folder++; $this->indexHTML(''); } // create media path if not set @@ -1622,7 +1649,7 @@ class Structure extends Get // add to component files foreach ($library->files as $file) { - $this->componentData->files[] = $file; + CFactory::_('Component')->appendArray('files', $file); } } // check if this lib has folders @@ -1634,7 +1661,7 @@ class Structure extends Get // add to component folders foreach ($library->folders as $folder) { - $this->componentData->folders[] = $folder; + CFactory::_('Component')->appendArray('folders', $folder); } } // check if this lib has urls @@ -1699,7 +1726,7 @@ class Structure extends Get // write data to path $this->writeFile($path, $data); // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } } // only add if local @@ -1719,15 +1746,13 @@ class Structure extends Get foreach ($library->config as $cofig) { $found = array_filter( - $this->componentData->config, - function ($item) use ($cofig) { - return $item['field'] == $cofig['field']; - } + CFactory::_('Component')->get('config'), + fn($item) => $item['field'] == $cofig['field'] ); // set the config data if not found if (!ArrayHelper::check($found)) { - $this->componentData->config[] = $cofig; + CFactory::_('Component')->appendArray('config', $cofig); } } } @@ -1747,16 +1772,13 @@ class Structure extends Get private function setDynamicDashboard() { // only add the dynamic dashboard if all checks out - if (isset($this->componentData->dashboard_type) - && 2 == $this->componentData->dashboard_type - && isset($this->componentData->dashboard) - && StringHelper::check( - $this->componentData->dashboard - ) - && strpos((string) $this->componentData->dashboard, '_') !== false) + if (CFactory::_('Component')->get('dashboard_type', 0) == 2 + && ($dashboard_ = CFactory::_('Component')->get('dashboard')) !== null + && StringHelper::check($dashboard_) + && strpos((string) $dashboard_, '_') !== false) { // set the default view - $getter = explode('_', (string) $this->componentData->dashboard); + $getter = explode('_', (string) $dashboard_); if (count((array) $getter) == 2 && is_numeric($getter[1])) { // the pointers @@ -1777,14 +1799,12 @@ class Structure extends Get $targets[$t], 'w' ); // set the dynamic dash - if (isset($this->componentData->{$targets[$t]}) - && ArrayHelper::check( - $this->componentData->{$targets[$t]} - )) + if (($target_ = CFactory::_('Component')->get($targets[$t])) !== null + && ArrayHelper::check($target_)) { // search the target views $dashboard = (array) array_filter( - $this->componentData->{$targets[$t]}, + $target_, function ($view) use ($id, $t, $types) { if (isset($view[$types[$t]]) && $id == $view[$types[$t]]) @@ -1821,7 +1841,7 @@ class Structure extends Get $this->app->enqueueMessage( JText::sprintf( 'The %s (%s) is not available in your component! Please insure to only used %s, for a dynamic dashboard, that are still linked to your component.', - $names[$t], $this->componentData->dashboard, + $names[$t], $dashboard_, $type_names ), 'Error' ); @@ -1836,7 +1856,7 @@ class Structure extends Get $this->app->enqueueMessage( JText::sprintf( 'The %s (%s) is not available in your component! Please insure to only used %s, for a dynamic dashboard, that are still linked to your component.', - $names[$t], $this->componentData->dashboard, + $names[$t], $dashboard_, $type_names ), 'Error' ); @@ -1851,7 +1871,7 @@ class Structure extends Get $this->app->enqueueMessage( JText::sprintf( 'The %s value for the dynamic dashboard is invalid.', - $this->componentData->dashboard + $dashboard_ ), 'Error' ); } @@ -1865,7 +1885,7 @@ class Structure extends Get $this->app->enqueueMessage( JText::sprintf( 'The %s value for the dynamic dashboard is invalid.', - $this->componentData->dashboard + $dashboard_ ), 'Error' ); } @@ -1873,8 +1893,8 @@ class Structure extends Get if (StringHelper::check($this->dynamicDashboard)) { // dynamic dashboard is used - $this->componentData->dashboard_tab = ''; - $this->componentData->php_dashboard_methods = ''; + CFactory::_('Component')->remove('dashboard_tab'); + CFactory::_('Component')->remove('php_dashboard_methods'); } } } @@ -1907,7 +1927,7 @@ class Structure extends Get { Folder::create($this->componentPath); // count the folder created - $this->folderCount++; + CFactory::_('Counter')->folder++; $this->indexHTML(''); } // now build all folders needed for this component @@ -2072,7 +2092,7 @@ class Structure extends Get $this->notNew[] = 'LICENSE.txt'; // do license check $LICENSE = false; - $licenseChecker = strtolower((string) $this->componentData->license); + $licenseChecker = strtolower((string) CFactory::_('Component')->get('license', '')); if (strpos($licenseChecker, 'gnu') !== false && strpos( $licenseChecker, '2' @@ -2088,7 +2108,7 @@ class Structure extends Get // do README check $README = false; // add the README file if needed - if ($this->componentData->addreadme) + if (CFactory::_('Component')->get('addreadme', false)) { $README = true; } @@ -2188,7 +2208,7 @@ class Structure extends Get // move the file to its place File::copy($currentFullPath, $packageFullPath); // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; // store the new files if (!in_array($ftem, $this->notNew)) { @@ -2241,7 +2261,7 @@ class Structure extends Get $currentFullPath, $packageFullPath, '', true ); // count the folder created - $this->folderCount++; + CFactory::_('Counter')->folder++; } } // only add if no target found since those belong to plugins and modules @@ -2322,19 +2342,16 @@ class Structure extends Get && ObjectHelper::check( $this->joomlaVersionData->move->dynamic )) - && (isset($this->componentData->admin_views) - && ArrayHelper::check( - $this->componentData->admin_views - ))) + && CFactory::_('Component')->isArray('admin_views')) { if (!StringHelper::check($this->dynamicDashboard)) { // setup dashboard - $target = array('admin' => $this->componentData->name_code); + $target = array('admin' => CFactory::_('Component')->get('name_code')); $this->buildDynamique($target, 'dashboard'); } // now the rest of the views - foreach ($this->componentData->admin_views as $nr => $view) + foreach (CFactory::_('Component')->get('admin_views') as $nr => $view) { if (ObjectHelper::check($view['settings'])) { @@ -2389,13 +2406,10 @@ class Structure extends Get && ObjectHelper::check( $this->joomlaVersionData->move->dynamic )) - && (isset($this->componentData->site_views) - && ArrayHelper::check( - $this->componentData->site_views - ))) + && CFactory::_('Component')->isArray('site_views')) { - foreach ($this->componentData->site_views as $nr => $view) + foreach (CFactory::_('Component')->get('site_views') as $nr => $view) { $created = $this->getCreatedDate($view); $modified = $this->getLastModifiedDate($view); @@ -2424,12 +2438,9 @@ class Structure extends Get && ObjectHelper::check( $this->joomlaVersionData->move->dynamic )) - && (isset($this->componentData->custom_admin_views) - && ArrayHelper::check( - $this->componentData->custom_admin_views - ))) + && CFactory::_('Component')->isArray('custom_admin_views')) { - foreach ($this->componentData->custom_admin_views as $nr => $view) + foreach (CFactory::_('Component')->get('custom_admin_views') as $nr => $view) { $created = $this->getCreatedDate($view); $modified = $this->getLastModifiedDate($view); @@ -2789,7 +2800,7 @@ class Structure extends Get Folder::create($path); $this->indexHTML($zipPath); // count the folder created - $this->folderCount++; + CFactory::_('Counter')->folder++; } // do the file renaming if ($details->rename) @@ -2824,7 +2835,7 @@ class Structure extends Get $path . '/' . $new ); // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } // setup array for new file $newFIle = array('path' => $path . '/' . $new, @@ -2878,37 +2889,35 @@ class Structure extends Get $footable = CFactory::_('Config')->get('footable', false); $add_eximport = CFactory::_('Config')->get('add_eximport', false); // add custom folders - if ((isset($this->componentData->folders) - && ArrayHelper::check( - $this->componentData->folders - )) || $add_eximport || $uikit || $footable) + if (CFactory::_('Component')->isArray('folders') + || $add_eximport || $uikit || $footable) { if ($add_eximport) { // move the import view folder in place - $this->componentData->folders[] = array('folder' => 'importViews', + CFactory::_('Component')->appendArray('folders', array('folder' => 'importViews', 'path' => 'admin/views/import', - 'rename' => 1); + 'rename' => 1)); // move the phpspreadsheet Folder (TODO we must move this to a library package) - $this->componentData->folders[] = array('folderpath' => 'JPATH_LIBRARIES/phpspreadsheet/vendor', + CFactory::_('Component')->appendArray('folders', array('folderpath' => 'JPATH_LIBRARIES/phpspreadsheet/vendor', 'path' => '/libraries/phpspreadsheet/', - 'rename' => 0); + 'rename' => 0)); } // set uikit if (2 == $uikit || 1 == $uikit) { // move the UIKIT Folder into place - $this->componentData->folders[] = array('folder' => 'uikit-v2', + CFactory::_('Component')->appendArray('folders', array('folder' => 'uikit-v2', 'path' => 'media', - 'rename' => 0); + 'rename' => 0)); } if (2 == $uikit || 3 == $uikit) { // move the UIKIT-3 Folder into place - $this->componentData->folders[] = array('folder' => 'uikit-v3', + CFactory::_('Component')->appendArray('folders', array('folder' => 'uikit-v3', 'path' => 'media', - 'rename' => 0); + 'rename' => 0)); } // set footable @@ -2916,21 +2925,21 @@ class Structure extends Get if ($footable && 2 == $footable_version) { // move the footable folder into place - $this->componentData->folders[] = array('folder' => 'footable-v2', + CFactory::_('Component')->appendArray('folders', array('folder' => 'footable-v2', 'path' => 'media', - 'rename' => 0); + 'rename' => 0)); } elseif ($footable && 3 == $footable_version) { // move the footable folder into place - $this->componentData->folders[] = array('folder' => 'footable-v3', + CFactory::_('Component')->appendArray('folders', array('folder' => 'footable-v3', 'path' => 'media', - 'rename' => 0); + 'rename' => 0)); } // pointer tracker $pointer_tracker = 'h'; - foreach ($this->componentData->folders as $custom) + foreach (CFactory::_('Component')->get('folders') as $custom) { // check type of target type $_target_type = 'c0mp0n3nt'; @@ -3026,31 +3035,29 @@ class Structure extends Get 'type' => $custom['target_type']); } } - unset($this->componentData->folders); + CFactory::_('Component')->remove('folders'); unset($custom); } // get the google chart switch $google_chart = CFactory::_('Config')->get('google_chart', false); // add custom files - if ((isset($this->componentData->files) - && ArrayHelper::check( - $this->componentData->files - )) || $google_chart) + if (CFactory::_('Component')->isArray('files') + || $google_chart) { if ($google_chart) { // move the google chart files - $this->componentData->files[] = array('file' => 'google.jsapi.js', + CFactory::_('Component')->appendArray('files', array('file' => 'google.jsapi.js', 'path' => 'media/js', - 'rename' => 0); - $this->componentData->files[] = array('file' => 'chartbuilder.php', + 'rename' => 0)); + CFactory::_('Component')->appendArray('files', array('file' => 'chartbuilder.php', 'path' => 'admin/helpers', - 'rename' => 0); + 'rename' => 0)); } // pointer tracker $pointer_tracker = 'h'; - foreach ($this->componentData->files as $custom) + foreach (CFactory::_('Component')->get('files') as $custom) { // check type of target type $_target_type = 'c0mp0n3nt'; @@ -3158,7 +3165,7 @@ class Structure extends Get $this->updateFileContent[$key_pointer] = true; } } - unset($this->componentData->files); + CFactory::_('Component')->remove('files'); unset($custom); } @@ -3211,7 +3218,7 @@ class Structure extends Get $root . $path . '/index.html' ); // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } else { @@ -3219,7 +3226,7 @@ class Structure extends Get $this->templatePath . '/index.html', $root . '/index.html' ); // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; } } diff --git a/admin/helpers/compiler/c_Fields.php b/admin/helpers/compiler/c_Fields.php index d026a53b9..7f8f30bb8 100644 --- a/admin/helpers/compiler/c_Fields.php +++ b/admin/helpers/compiler/c_Fields.php @@ -25,6 +25,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; /** * Compiler class + * @deprecated 3.3 */ class Fields extends Structure { @@ -657,7 +658,7 @@ class Fields extends Structure $fieldSet[] = Indent::_(3) . 'readonly="true"'; $fieldSet[] = Indent::_(2) . "/>"; // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // if created is not set if (!isset($this->fieldsNames[$nameSingleCode]['created'])) @@ -680,7 +681,7 @@ class Fields extends Structure $fieldSet[] = Indent::_(3) . "filter=" . '"user_utc"'; $fieldSet[] = Indent::_(2) . "/>"; // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // if created_by is not set if (!isset($this->fieldsNames[$nameSingleCode]['created_by'])) @@ -700,7 +701,7 @@ class Fields extends Structure . '_CREATED_BY_DESC"'; $fieldSet[] = Indent::_(2) . "/>"; // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // if published is not set if (!isset($this->fieldsNames[$nameSingleCode]['published'])) @@ -727,7 +728,7 @@ class Fields extends Structure $fieldSet[] = Indent::_(4) . "JTRASHED"; $fieldSet[] = Indent::_(2) . ""; // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // if modified is not set if (!isset($this->fieldsNames[$nameSingleCode]['modified'])) @@ -742,7 +743,7 @@ class Fields extends Structure $fieldSet[] = Indent::_(3) . 'size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />'; // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // if modified_by is not set if (!isset($this->fieldsNames[$nameSingleCode]['modified_by'])) @@ -760,7 +761,7 @@ class Fields extends Structure $fieldSet[] = Indent::_(3) . 'filter="unset"'; $fieldSet[] = Indent::_(2) . "/>"; // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // check if view has access if (isset($this->accessBuilder[$nameSingleCode]) @@ -783,7 +784,7 @@ class Fields extends Structure $fieldSet[] = Indent::_(3) . 'required="false"'; $fieldSet[] = Indent::_(2) . "/>"; // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // if ordering is not set if (!isset($this->fieldsNames[$nameSingleCode]['ordering'])) @@ -806,7 +807,7 @@ class Fields extends Structure $fieldSet[] = Indent::_(3) . 'required="false"'; $fieldSet[] = Indent::_(2) . "/>"; // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // if version is not set if (!isset($this->fieldsNames[$nameSingleCode]['version'])) @@ -826,7 +827,7 @@ class Fields extends Structure $fieldSet[] = Indent::_(3) . 'filter="unset"'; $fieldSet[] = Indent::_(2) . "/>"; // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // check if metadata is added to this view if (isset($this->metadataBuilder[$nameSingleCode]) @@ -850,7 +851,7 @@ class Fields extends Structure $fieldSet[] = Indent::_(3) . 'cols="30"'; $fieldSet[] = Indent::_(2) . "/>"; // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // metadesc if (!isset($this->fieldsNames[$nameSingleCode]['metadesc'])) @@ -868,7 +869,7 @@ class Fields extends Structure $fieldSet[] = Indent::_(3) . 'cols="30"'; $fieldSet[] = Indent::_(2) . "/>"; // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } } // fix the permissions field "title" issue gh-629 @@ -895,7 +896,7 @@ class Fields extends Structure . $nameSingleCode . '"'; $fieldSet[] = Indent::_(2) . "/>"; // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; // setup needed field values for layout $field_array = array(); $field_array['order_edit'] = 0; @@ -956,7 +957,7 @@ class Fields extends Structure . ''; $fieldSet[] = Indent::_(3) . ''; // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // author if (!isset($this->fieldsNames[$nameSingleCode]['author'])) @@ -971,7 +972,7 @@ class Fields extends Structure $fieldSet[] = Indent::_(4) . 'size="20"'; $fieldSet[] = Indent::_(3) . "/>"; // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // rights if (!isset($this->fieldsNames[$nameSingleCode]['rights'])) @@ -986,7 +987,7 @@ class Fields extends Structure $fieldSet[] = Indent::_(4) . 'cols="30" rows="2"'; $fieldSet[] = Indent::_(3) . "/>"; // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } $fieldSet[] = Indent::_(2) . ""; $fieldSet[] = Indent::_(1) . ""; @@ -1083,7 +1084,7 @@ class Fields extends Structure $fieldXML = $fieldSetXML->addChild('field'); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // if created is not set if (!isset($this->fieldsNames[$nameSingleCode]['created'])) @@ -1105,7 +1106,7 @@ class Fields extends Structure $fieldXML = $fieldSetXML->addChild('field'); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // if created_by is not set if (!isset($this->fieldsNames[$nameSingleCode]['created_by'])) @@ -1124,7 +1125,7 @@ class Fields extends Structure $fieldXML = $fieldSetXML->addChild('field'); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // if published is not set if (!isset($this->fieldsNames[$nameSingleCode]['published'])) @@ -1142,7 +1143,7 @@ class Fields extends Structure $fieldXML = $fieldSetXML->addChild('field'); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; foreach ( array('JPUBLISHED' => 1, 'JUNPUBLISHED' => 0, 'JARCHIVED' => 2, 'JTRASHED' => -2) as $text => $value @@ -1174,7 +1175,7 @@ class Fields extends Structure $fieldXML = $fieldSetXML->addChild('field'); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // if modified_by is not set if (!isset($this->fieldsNames[$nameSingleCode]['modified_by'])) @@ -1195,7 +1196,7 @@ class Fields extends Structure $fieldXML = $fieldSetXML->addChild('field'); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // check if view has access if (isset($this->accessBuilder[$nameSingleCode]) @@ -1220,7 +1221,7 @@ class Fields extends Structure $fieldXML = $fieldSetXML->addChild('field'); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // if ordering is not set if (!isset($this->fieldsNames[$nameSingleCode]['ordering'])) @@ -1243,7 +1244,7 @@ class Fields extends Structure $fieldXML = $fieldSetXML->addChild('field'); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // if version is not set if (!isset($this->fieldsNames[$nameSingleCode]['version'])) @@ -1265,7 +1266,7 @@ class Fields extends Structure $fieldXML = $fieldSetXML->addChild('field'); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // check if metadata is added to this view if (isset($this->metadataBuilder[$nameSingleCode]) @@ -1293,7 +1294,7 @@ class Fields extends Structure $fieldXML, $attributes ); // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // metadesc if (!isset($this->fieldsNames[$nameSingleCode]['metadesc'])) @@ -1310,7 +1311,7 @@ class Fields extends Structure $fieldXML, $attributes ); // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } } // fix the permissions field "title" issue gh-629 @@ -1345,7 +1346,7 @@ class Fields extends Structure $fieldXML = $fieldSetXML->addChild('field'); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; // setup needed field values for layout $field_array = array(); $field_array['order_edit'] = 0; @@ -1408,7 +1409,7 @@ class Fields extends Structure $robots, $attributes ); // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; $options = array( 'JGLOBAL_USE_GLOBAL' => '', 'JGLOBAL_INDEX_FOLLOW' => 'index, follow', @@ -1442,7 +1443,7 @@ class Fields extends Structure $author, $attributes ); // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } // rights if (!isset($this->fieldsNames[$nameSingleCode]['rights'])) @@ -1466,7 +1467,7 @@ class Fields extends Structure $rights, $attributes ); // count the static field created - $this->fieldCount++; + CFactory::_('Counter')->field++; } } } @@ -1890,7 +1891,7 @@ class Fields extends Structure &$optionArray, $custom = null, $taber = '' ) { // count the dynamic fields created - $this->fieldCount++; + CFactory::_('Counter')->field++; // check what type of field builder to use if (CFactory::_('Config')->get('field_builder_type', 2) == 1) { @@ -4780,13 +4781,8 @@ class Fields extends Structure // load to list builder if ($listSwitch) { - // check if it does not exists - if (!CFactory::_('Registry')->exists('builder.list.' . $nameListCode)) - { - CFactory::_('Registry')->set('builder.list.' . $nameListCode, []); - } // append values - CFactory::_('Registry')->append('builder.list.' . $nameListCode, [ + CFactory::_('Registry')->appendArray('builder.list.' . $nameListCode, [ 'id' => (int) $field['field'], 'type' => $typeName, 'code' => $name, diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index e514e1fd8..2eca6b18a 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -29,6 +29,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Utilities\Minify; /** * Compiler class + * @deprecated 3.3 */ class Interpretation extends Fields { @@ -266,8 +267,7 @@ class Interpretation extends Fields */ public function addEmailHelper() { - if (isset($this->componentData->add_email_helper) - && $this->componentData->add_email_helper) + if (CFactory::_('Component')->get('add_email_helper')) { // set email helper in place with component name $component = CFactory::_('Config')->component_code_name; @@ -293,8 +293,7 @@ class Interpretation extends Fields */ public function setLockLicense() { - if ($this->componentData->add_license - && $this->componentData->license_type == 3) + if (CFactory::_('Component')->get('add_license', 0) == 3) { if (!CFactory::_('Content')->exist('HELPER_SITE_LICENSE_LOCK')) { @@ -328,7 +327,7 @@ class Interpretation extends Fields */ public function setLockLicensePer(&$view, $target) { - if ($this->componentData->add_license && $this->componentData->license_type == 3) + if (CFactory::_('Component')->get('add_license', 0) == 3) { if (!CFactory::_('Content')->exist_($view, 'BOOLMETHOD')) { @@ -499,28 +498,25 @@ class Interpretation extends Fields public function setWHMCSCryption() { // make sure we have the correct file - if (isset($this->componentData->whmcs_key) - && StringHelper::check( - $this->componentData->whmcs_key - )) + if (CFactory::_('Component')->isString('whmcs_key')) { // Get the basic encryption. $basickey = ComponentbuilderHelper::getCryptKey('basic'); + $key = CFactory::_('Component')->get('whmcs_key'); + // Get the encryption object. $basic = new FOFEncryptAes($basickey); - if (!empty($this->componentData->whmcs_key) && $basickey - && !is_numeric($this->componentData->whmcs_key) - && $this->componentData->whmcs_key === base64_encode( - base64_decode((string) $this->componentData->whmcs_key, true) + if ($basickey && $key === base64_encode( + base64_decode((string) $key, true) )) { // basic decrypt data whmcs_key. - $this->componentData->whmcs_key = rtrim( - (string) $basic->decryptString($this->componentData->whmcs_key), "\0" + $key = rtrim( + (string) $basic->decryptString($key), "\0" ); // set the needed string to connect to whmcs - $key["kasier"] = $this->componentData->whmcs_url; - $key["geheim"] = $this->componentData->whmcs_key; + $key["kasier"] = CFactory::_('Component')->get('whmcs_url', ''); + $key["geheim"] = $key; $key["onthou"] = 1; // prep the call info $theKey = base64_encode(serialize($key)); @@ -816,11 +812,11 @@ class Interpretation extends Fields && ArrayHelper::check( $this->whmcsFieldModeling )) - || $this->componentData->add_license) + || CFactory::_('Component')->get('add_license')) { if (isset($this->whmcsFieldModeling) && ArrayHelper::check($this->whmcsFieldModeling) - || $this->componentData->add_license) + || CFactory::_('Component')->get('add_license')) { // set whmcs encrypt file into place $target = array('admin' => 'whmcs'); @@ -912,7 +908,7 @@ class Interpretation extends Fields // add the whmcs option if (isset($this->whmcsFieldModeling) && ArrayHelper::check($this->whmcsFieldModeling) - || $this->componentData->add_license) + || CFactory::_('Component')->get('add_license')) { $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " WHMCS Encryption Type"; @@ -1053,15 +1049,12 @@ class Interpretation extends Fields */ public function setVersionController() { - if (ArrayHelper::check( - $this->componentData->version_update - ) + if (CFactory::_('Component')->isArray('version_update') || ArrayHelper::check($this->updateSQLBuilder)) { $updateXML = array(); // add the update server - if ($this->componentData->add_update_server - && $this->componentData->update_server_target != 3) + if (CFactory::_('Component')->get('update_server_target', 3) != 3) { $updateXML[] = ''; } @@ -1069,18 +1062,14 @@ class Interpretation extends Fields // add the dynamic sql switch $addDynamicSQL = true; $addActive = true; - if (ArrayHelper::check( - $this->componentData->version_update - )) + if (CFactory::_('Component')->isArray('version_update')) { - foreach ( - $this->componentData->version_update as $nr => &$update - ) + foreach (CFactory::_('Component')->get('version_update') as $nr => &$update) { $this->setUpdateXMLSQL($update, $updateXML, $addDynamicSQL); if ($update['version'] - == $this->componentData->component_version) + == CFactory::_('Component')->get('component_version')) { $addActive = false; } @@ -1105,14 +1094,13 @@ class Interpretation extends Fields $this->setDynamicUpdateXMLSQL($updateXML, $addActive); } // add the update server file - if ($this->componentData->add_update_server - && $this->componentData->update_server_target != 3) + if (CFactory::_('Component')->get('add_update_server', 3) != 3) { $updateXML[] = ''; // UPDATE_SERVER_XML $name = substr( - (string) $this->componentData->update_server_url, - strrpos((string) $this->componentData->update_server_url, '/') + (string) CFactory::_('Component')->get('update_server_url'), + strrpos((string) CFactory::_('Component')->get('update_server_url'), '/') + 1 ); $name = explode('.xml', $name)[0]; @@ -1125,11 +1113,8 @@ class Interpretation extends Fields } } // add the update server link to component XML - if ($this->componentData->add_update_server - && isset($this->componentData->update_server_url) - && StringHelper::check( - $this->componentData->update_server_url - )) + if (CFactory::_('Component')->get('add_update_server') + && CFactory::_('Component')->isString('update_server_url')) { // UPDATESERVER $updateServer = array(); @@ -1137,7 +1122,7 @@ class Interpretation extends Fields $updateServer[] = Indent::_(2) . '' . $this->componentData->update_server_url + . CFactory::_('Content')->get('Component_name') . '">' . CFactory::_('Component')->get('update_server_url') . ''; $updateServer[] = Indent::_(1) . ''; // return the array to string @@ -1155,7 +1140,7 @@ class Interpretation extends Fields { $buket = array(); $nr = 0; - foreach ($this->componentData->version_update as $values) + foreach (CFactory::_('Component')->get('version_update') as $values) { $buket['version_update' . $nr] = $values; $nr++; @@ -1164,7 +1149,7 @@ class Interpretation extends Fields $newJ = array(); $newJ['id'] = (int) CFactory::_('Config')->component_id; $newJ['component_version'] - = $this->componentData->component_version; + = CFactory::_('Component')->get('component_version'); // update the component with the new dynamic SQL $modelJ = ComponentbuilderHelper::getModel('joomla_component'); $modelJ->save($newJ); // <-- to insure the history is also updated @@ -1173,10 +1158,9 @@ class Interpretation extends Fields // update the component update table $newU = array(); - if (isset($this->componentData->version_update_id) - && $this->componentData->version_update_id > 0) + if (CFactory::_('Component')->get('version_update_id', 0) > 0) { - $newU['id'] = (int) $this->componentData->version_update_id; + $newU['id'] = (int) CFactory::_('Component')->get('version_update_id', 0); } else { @@ -1203,7 +1187,7 @@ class Interpretation extends Fields if ($current_version) { // setup new version - $update_['version'] = $this->componentData->component_version; + $update_['version'] = CFactory::_('Component')->get('component_version'); // setup SQL $update_['mysql'] = ''; // setup URL @@ -1212,7 +1196,7 @@ class Interpretation extends Fields else { // setup new version - $update_['version'] = $this->componentData->old_component_version; + $update_['version'] = CFactory::_('Component')->get('old_component_version'); // setup SQL $update_['mysql'] = trim( implode(PHP_EOL . PHP_EOL, $this->updateSQLBuilder) @@ -1221,21 +1205,21 @@ class Interpretation extends Fields if (isset($this->lastupdateURL)) { $paceholders = array( - $this->componentData->component_version => $this->componentData->old_component_version, + CFactory::_('Component')->get('component_version') => CFactory::_('Component')->get('old_component_version'), str_replace( - '.', '-', (string) $this->componentData->component_version + '.', '-', (string) CFactory::_('Component')->get('component_version') ) => str_replace( - '.', '-', (string) $this->componentData->old_component_version + '.', '-', (string) CFactory::_('Component')->get('old_component_version') ), str_replace( - '.', '_', (string) $this->componentData->component_version + '.', '_', (string) CFactory::_('Component')->get('component_version') ) => str_replace( - '.', '_', (string) $this->componentData->old_component_version + '.', '_', (string) CFactory::_('Component')->get('old_component_version') ), str_replace( - '.', '', (string) $this->componentData->component_version + '.', '', (string) CFactory::_('Component')->get('component_version') ) => str_replace( - '.', '', (string) $this->componentData->old_component_version + '.', '', (string) CFactory::_('Component')->get('old_component_version') ) ); $update_['url'] = CFactory::_('Placeholder')->update( @@ -1249,8 +1233,8 @@ class Interpretation extends Fields } } // stop it from being added double - $addDynamicSQL = false; - $this->componentData->version_update[] = $update_; + $addDynamicSQL = false; + CFactory::_('Component')->appendArray('version_update', $update_); // add dynamic SQL $this->setUpdateXMLSQL($update_, $updateXML, $addDynamicSQL); } @@ -1278,10 +1262,7 @@ class Interpretation extends Fields if ($addDynamicSQL && ArrayHelper::check( $this->updateSQLBuilder - ) - && (isset($this->componentData->old_component_version) - && $this->componentData->old_component_version - == $update['version'])) + ) && CFactory::_('Component')->get('old_component_version') == $update['version']) { $searchMySQL = preg_replace('/\s+/', '', (string) $update['mysql']); // add the updates to the SQL only if not found @@ -1298,7 +1279,7 @@ class Interpretation extends Fields $addDynamicSQL = false; } // setup import files - if ($update['version'] != $this->componentData->component_version) + if ($update['version'] != CFactory::_('Component')->get('component_version')) { $name = StringHelper::safe($update['version']); $target = array('admin' => $name); @@ -1315,8 +1296,7 @@ class Interpretation extends Fields $this->lastupdateURL = $update['url']; } // add the update server - if ($this->componentData->add_update_server - && $this->componentData->update_server_target != 3) + if (CFactory::_('Component')->get('add_update_server', 3) != 3) { // we set the defaults $u_element = 'com_' . CFactory::_('Config')->component_code_name; @@ -5479,7 +5459,7 @@ class Interpretation extends Fields CFactory::_('Content')->set_($viewCodeName, 'SITE_BOTTOM_BUTTON', 'toolbar->render(); ?>'); break; case 5: - // set buttons to buttom left of the view + // set buttons to custom placement of the view CFactory::_('Placeholder')->set_('SITE_TOOLBAR', 'toolbar->render(); ?>'); break; @@ -6514,7 +6494,7 @@ class Interpretation extends Fields } // load the components need if ((2 == CFactory::_('Config')->uikit || 1 == CFactory::_('Config')->uikit) - && ($data_ = CFactory::_('Registry')->extract('builder.uikit_comp.' . + && ($data_ = CFactory::_('Registry')->get('builder.uikit_comp.' . $view['settings']->code)) !== null) { $setter .= PHP_EOL . PHP_EOL . $tabV . Indent::_(2) . "//" @@ -7629,17 +7609,14 @@ class Interpretation extends Fields public function setComponentToContentTypes($action) { $script = ''; - if (isset($this->componentData->admin_views) - && ArrayHelper::check( - $this->componentData->admin_views - )) + if (CFactory::_('Component')->isArray('admin_views')) { // set component name $component = CFactory::_('Config')->component_code_name; // reset $dbStuff = array(); // start loading the content type data - foreach ($this->componentData->admin_views as $viewData) + foreach (CFactory::_('Component')->get('admin_views') as $viewData) { // set main keys $view = StringHelper::safe( @@ -7880,10 +7857,7 @@ class Interpretation extends Fields $script .= CFactory::_('Customcode.Dispenser')->get( 'php_postflight', 'update', PHP_EOL . PHP_EOL, null, true ); - if (isset($this->componentData->admin_views) - && ArrayHelper::check( - $this->componentData->admin_views - )) + if (CFactory::_('Component')->isArray('admin_views')) { $script .= PHP_EOL . Indent::_(3) . 'echo \'componentData->add_license - && $this->componentData->license_type == 3) + if (CFactory::_('Component')->get('add_license') + && CFactory::_('Component')->get('license_type') == 3) { CFactory::_('Language')->set( 'admin', 'NIE_REG_NIE', "

License not set for " . $componentName . ".

Notify your administrator!
The license can be obtained from
" - . $this->componentData->companyname . ".

" + . CFactory::_('Component')->get('whmcs_buy_link') . "' target='_blank'>" + . CFactory::_('Component')->get('companyname') . ".

" ); } // add the langug files needed to import and export data @@ -10901,7 +10876,8 @@ class Interpretation extends Fields public function setLangSite() { // add final list of needed lang strings - $componentName = JFilterOutput::cleanText($this->componentData->name); + $componentName = CFactory::_('Component')->get('name'); + $componentName = JFilterOutput::cleanText($componentName); // for plugin event TODO change event api signatures $langContent = CFactory::_('Language')->getTarget('site'); $component_context = CFactory::_('Config')->component_context; @@ -11001,7 +10977,8 @@ class Interpretation extends Fields public function setLangSiteSys() { // add final list of needed lang strings - $componentName = JFilterOutput::cleanText($this->componentData->name); + $componentName = CFactory::_('Component')->get('name'); + $componentName = JFilterOutput::cleanText($componentName); // for plugin event TODO change event api signatures $langContent = CFactory::_('Language')->getTarget('sitesys'); $component_context = CFactory::_('Config')->component_context; @@ -11062,7 +11039,8 @@ class Interpretation extends Fields public function setLangAdminSys() { // add final list of needed lang strings - $componentName = JFilterOutput::cleanText($this->componentData->name); + $componentName = CFactory::_('Component')->get('name'); + $componentName = JFilterOutput::cleanText($componentName); // for plugin event TODO change event api signatures $langContent = CFactory::_('Language')->getTarget('adminsys'); $component_context = CFactory::_('Config')->component_context; @@ -11111,14 +11089,9 @@ class Interpretation extends Fields public function setCustomAdminViewListLink($view, $nameListCode) { - if (isset($this->componentData->custom_admin_views) - && ArrayHelper::check( - $this->componentData->custom_admin_views - )) + if (CFactory::_('Component')->isArray('custom_admin_views')) { - foreach ( - $this->componentData->custom_admin_views as $custom_admin_view - ) + foreach (CFactory::_('Component')->get('custom_admin_views') as $custom_admin_view) { if (isset($custom_admin_view['adminviews']) && ArrayHelper::check( @@ -13620,7 +13593,7 @@ class Interpretation extends Fields extract($args, EXTR_PREFIX_SAME, "oops"); $single = ''; $name_list_code = ''; - foreach ($this->componentData->admin_views as $array) + foreach (CFactory::_('Component')->get('admin_views') as $array) { if ($array['adminview'] == $viewId) { @@ -18638,8 +18611,9 @@ class Interpretation extends Fields protected function setDefaultBatchHelper(&$batch, &$nameSingleCode) { // set component name + $COPMONENT = CFactory::_('Component')->get('name_code'); $COPMONENT = StringHelper::safe( - $this->componentData->name_code, 'U' + $COPMONENT, 'U' ); // set batch $batch[] = PHP_EOL . Indent::_(2) @@ -18698,9 +18672,8 @@ class Interpretation extends Fields && isset($this->categoryBuilder[$nameListCode]['extension'])) { // set component name - $COPMONENT = StringHelper::safe( - $this->componentData->name_code, 'U' - ); + $COPMONENT = CFactory::_('Component')->get('name_code'); + $COPMONENT = StringHelper::safe($COPMONENT, 'U'); // set filter $batch[] = PHP_EOL . Indent::_(2) . "if (\$this->canBatch && \$this->canCreate && \$this->canEdit)"; @@ -19347,7 +19320,7 @@ class Interpretation extends Fields $getForm[] = Indent::_(3) . "return false;"; $getForm[] = Indent::_(2) . "}"; // load license locker - if ($this->componentData->add_license && $this->componentData->license_type == 3 + if (CFactory::_('Component')->get('add_license') && CFactory::_('Component')->get('license_type') == 3 && CFactory::_('Content')->exist_($nameSingleCode, 'BOOLMETHOD')) { $getForm[] = $this->checkStatmentLicenseLocked( @@ -22600,15 +22573,12 @@ class Interpretation extends Fields public function setDashboardIcons() { - if (isset($this->componentData->admin_views) - && ArrayHelper::check( - $this->componentData->admin_views - )) + if (CFactory::_('Component')->isArray('admin_views')) { $icons = ''; $counter = 0; $catArray = array(); - foreach ($this->componentData->admin_views as $view) + foreach (CFactory::_('Component')->get('admin_views') as $view) { $name_single = StringHelper::safe( $view['settings']->name_single @@ -22825,21 +22795,20 @@ class Interpretation extends Fields public function setDashboardModelMethods() { - if (isset($this->componentData->php_dashboard_methods) - && StringHelper::check( - $this->componentData->php_dashboard_methods - )) + if (CFactory::_('Component')->isString('php_dashboard_methods')) { + // get hte value + $php_dashboard_methods = CFactory::_('Component')->get('php_dashboard_methods'); // get all the mothods that should load date to the view $this->DashboardGetCustomData = GetHelper::allBetween( - $this->componentData->php_dashboard_methods, + $php_dashboard_methods, 'public function get', '()' ); // return the methods return PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( - $this->componentData->php_dashboard_methods + $php_dashboard_methods ); } @@ -22881,13 +22850,10 @@ class Interpretation extends Fields $tab = Indent::_(1); $loadTabs = false; // check if we have custom tabs - if (isset($this->componentData->dashboard_tab) - && ArrayHelper::check( - $this->componentData->dashboard_tab - )) + if (CFactory::_('Component')->isArray('dashboard_tab')) { // build the tabs and accordians - foreach ($this->componentData->dashboard_tab as $data) + foreach (CFactory::_('Component')->get('dashboard_tab') as $data) { $builder[$data['name']][$data['header']] = CFactory::_('Placeholder')->update_( @@ -23016,12 +22982,9 @@ class Interpretation extends Fields public function addCustomDashboardIcons(&$view, &$counter) { $icon = ''; - if (isset($this->componentData->custom_admin_views) - && ArrayHelper::check( - $this->componentData->custom_admin_views - )) + if (CFactory::_('Component')->isArray('custom_admin_views')) { - foreach ($this->componentData->custom_admin_views as $nr => $menu) + foreach (CFactory::_('Component')->get('custom_admin_views') as $nr => $menu) { if (!isset($this->customAdminAdded[$menu['settings']->code]) && isset($menu['dashboard_list']) @@ -23092,12 +23055,9 @@ class Interpretation extends Fields } } // see if we should have custom menus - if (isset($this->componentData->custommenus) - && ArrayHelper::check( - $this->componentData->custommenus - )) + if (CFactory::_('Component')->isArray('custommenus')) { - foreach ($this->componentData->custommenus as $nr => $menu) + foreach (CFactory::_('Component')->get('custommenus') as $nr => $menu) { $nr = $nr + 100; $nameList = StringHelper::safe( @@ -23208,10 +23168,7 @@ class Interpretation extends Fields public function setSubMenus() { - if (isset($this->componentData->admin_views) - && ArrayHelper::check( - $this->componentData->admin_views - )) + if (CFactory::_('Component')->isArray('admin_views')) { $menus = ''; // main lang prefix @@ -23231,7 +23188,7 @@ class Interpretation extends Fields } $catArray = array(); // loop over all the admin views - foreach ($this->componentData->admin_views as $view) + foreach (CFactory::_('Component')->get('admin_views') as $view) { // set custom menu $menus .= $this->addCustomSubMenu( @@ -23395,12 +23352,9 @@ class Interpretation extends Fields { // see if we should have custom menus $custom = ''; - if (isset($this->componentData->custom_admin_views) - && ArrayHelper::check( - $this->componentData->custom_admin_views - )) + if (CFactory::_('Component')->isArray('custom_admin_views')) { - foreach ($this->componentData->custom_admin_views as $nr => $menu) + foreach (CFactory::_('Component')->get('custom_admin_views') as $nr => $menu) { if (!isset($this->customAdminAdded[$menu['settings']->code])) { @@ -23413,12 +23367,9 @@ class Interpretation extends Fields } } } - if (isset($this->componentData->custommenus) - && ArrayHelper::check( - $this->componentData->custommenus - )) + if (CFactory::_('Component')->isArray('custommenus')) { - foreach ($this->componentData->custommenus as $nr => $menu) + foreach (CFactory::_('Component')->get('custommenus') as $nr => $menu) { if (($_custom = $this->setCustomAdminSubMenu( $view, $codeName, $lang, $nr, $menu, 'customMenu' @@ -23607,10 +23558,7 @@ class Interpretation extends Fields public function setMainMenus() { - if (isset($this->componentData->admin_views) - && ArrayHelper::check( - $this->componentData->admin_views - )) + if (CFactory::_('Component')->isArray('admin_views')) { $menus = ''; // main lang prefix @@ -23620,19 +23568,13 @@ class Interpretation extends Fields // default prefix is none $prefix = ''; // check if local is set - if (isset($this->componentData->add_menu_prefix) - && is_numeric( - $this->componentData->add_menu_prefix - )) + if (CFactory::_('Component')->isNumeric('add_menu_prefix')) { // set main menu prefix switch - $addPrefix = $this->componentData->add_menu_prefix; - if ($addPrefix == 1 && isset($this->componentData->menu_prefix) - && StringHelper::check( - $this->componentData->menu_prefix - )) + $addPrefix = CFactory::_('Component')->get('add_menu_prefix'); + if ($addPrefix == 1 && CFactory::_('Component')->isString('menu_prefix')) { - $prefix = trim((string) $this->componentData->menu_prefix) . ' '; + $prefix = trim((string) CFactory::_('Component')->get('menu_prefix')) . ' '; } } else @@ -23649,17 +23591,17 @@ class Interpretation extends Fields if ($addPrefix == 1) { CFactory::_('Language')->set( - 'adminsys', $lang, $prefix . $this->componentData->name + 'adminsys', $lang, $prefix . CFactory::_('Component')->get('name') ); } else { CFactory::_('Language')->set( - 'adminsys', $lang, $this->componentData->name + 'adminsys', $lang, CFactory::_('Component')->get('name') ); } // loop over the admin views - foreach ($this->componentData->admin_views as $view) + foreach (CFactory::_('Component')->get('admin_views') as $view) { // set custom menu $menus .= $this->addCustomMainMenu($view, $codeName, $lang); @@ -23702,12 +23644,9 @@ class Interpretation extends Fields { $customMenu = ''; // see if we should have custom admin views - if (isset($this->componentData->custom_admin_views) - && ArrayHelper::check( - $this->componentData->custom_admin_views - )) + if (CFactory::_('Component')->isArray('custom_admin_views')) { - foreach ($this->componentData->custom_admin_views as $nr => $menu) + foreach (CFactory::_('Component')->get('custom_admin_views') as $nr => $menu) { if (!isset($this->customAdminAdded[$menu['settings']->code])) { @@ -23741,12 +23680,9 @@ class Interpretation extends Fields } } // see if we should have custom menus - if (isset($this->componentData->custommenus) - && ArrayHelper::check( - $this->componentData->custommenus - )) + if (CFactory::_('Component')->isArray('custommenus')) { - foreach ($this->componentData->custommenus as $nr => $menu) + foreach (CFactory::_('Component')->get('custommenus') as $nr => $menu) { $nr = $nr + 100; if (isset($menu['mainmenu']) && $menu['mainmenu'] == 1 @@ -23889,18 +23825,15 @@ class Interpretation extends Fields { // start loading Global params $autorName = StringHelper::html( - $this->componentData->author + CFactory::_('Component')->get('author') ); $autorEmail = StringHelper::html( - $this->componentData->email + CFactory::_('Component')->get('email') ); $this->extensionsParams[] = '"autorName":"' . $autorName . '","autorEmail":"' . $autorEmail . '"'; // set the custom fields - if (isset($this->componentData->config) - && ArrayHelper::check( - $this->componentData->config - )) + if (CFactory::_('Component')->isArray('config')) { // set component code name $component = CFactory::_('Config')->component_code_name; @@ -23912,11 +23845,11 @@ class Interpretation extends Fields = CFactory::_('Config')->component_code_name; $placeholders[Placefix::_h('Component')] = StringHelper::safe( - $this->componentData->name_code, 'F' + CFactory::_('Component')->get('name_code'), 'F' ); $placeholders[Placefix::_h('COMPONENT')] = StringHelper::safe( - $this->componentData->name_code, 'U' + CFactory::_('Component')->get('name_code'), 'U' ); $placeholders[Placefix::_h('view')] = $nameSingleCode; @@ -23941,17 +23874,21 @@ class Interpretation extends Fields $viewType = 0; // set the custom table key $dbkey = 'g'; + // TODO: change plubin signature + $config_ = CFactory::_('Component')->get('config'); // Trigger Event: jcb_ce_onBeforeSetConfigFieldsets CFactory::_('Event')->trigger( 'jcb_ce_onBeforeSetConfigFieldsets', array(&$component_context, &$timer, &$this->configFieldSets, &$this->configFieldSetsCustomField, - &$this->componentData->config, + &$config_, &$this->extensionsParams, &$placeholders) ); + // update global values + CFactory::_('Component')->set('config', $config_); // build the config fields - foreach ($this->componentData->config as $field) + foreach ($config_ as $field) { // get the xml string $xmlField = $this->getFieldXMLString( @@ -24020,15 +23957,18 @@ class Interpretation extends Fields { // for plugin event TODO change event api signatures $placeholders = CFactory::_('Placeholder')->active; + $config_ = CFactory::_('Component')->get('config'); // Trigger Event: jcb_ce_onBeforeSetConfigFieldsets CFactory::_('Event')->trigger( 'jcb_ce_onBeforeSetConfigFieldsets', array(&$component_context, &$timer, &$this->configFieldSets, &$this->configFieldSetsCustomField, - &$this->componentData->config, &$this->extensionsParams, + &$config_, &$this->extensionsParams, &$placeholders) ); + // update global values + CFactory::_('Component')->set('config', $config_); // these field sets can only be added after admin view is build $this->setGroupControlConfigFieldsets($lang); // these can be added anytime really (but looks best after groups @@ -24054,13 +23994,10 @@ class Interpretation extends Fields { $front_end = array(); // do quick build of front-end views - if (isset($this->componentData->site_views) - && ArrayHelper::check( - $this->componentData->site_views - )) + if (CFactory::_('Component')->isArray('site_views')) { // load the names only to link the page params - foreach ($this->componentData->site_views as $siteView) + foreach (CFactory::_('Component')->get('site_views') as $siteView) { // now load the view name to the front-end array $front_end[] = $siteView['settings']->name; @@ -24491,13 +24428,10 @@ class Interpretation extends Fields // set if contributors were added $langCont = $lang . '_CONTRIBUTOR'; if (CFactory::_('Config')->get('add_contributors', false) - && isset($this->componentData->contributors) - && ArrayHelper::check( - $this->componentData->contributors - )) + && CFactory::_('Component')->isArray('contributors')) { foreach ( - $this->componentData->contributors as $counter => $contributor + CFactory::_('Component')->get('contributors') as $counter => $contributor ) { // make sure we dont use 0 @@ -24633,7 +24567,7 @@ class Interpretation extends Fields } } // add more contributors if required - if (1 == $this->componentData->emptycontributors) + if (1 == CFactory::_('Component')->get('emptycontributors', 0)) { if (isset($counter)) { @@ -24644,7 +24578,7 @@ class Interpretation extends Fields { $min = 1; } - $max = $min + $this->componentData->number - 1; + $max = $min + CFactory::_('Component')->get('number') - 1; $moreContributerFields = range($min, $max, 1); foreach ($moreContributerFields as $counter) { @@ -24741,7 +24675,7 @@ class Interpretation extends Fields } } if (CFactory::_('Config')->get('add_contributors', false) - || $this->componentData->emptycontributors == 1) + || CFactory::_('Component')->get('emptycontributors', 0) == 1) { // setup lang CFactory::_('Language')->set( @@ -25044,8 +24978,7 @@ for developing fast and powerful web interfaces. For more info visit componentData->add_email_helper) - && $this->componentData->add_email_helper) + if (CFactory::_('Component')->get('add_email_helper')) { // main lang prefix $lang = $lang . ''; @@ -26407,7 +26340,7 @@ function vdm_dkim() { if (CFactory::_('Config')->basic_encryption || CFactory::_('Config')->whmcs_encryption || CFactory::_('Config')->medium_encryption - || $this->componentData->add_license + || CFactory::_('Component')->get('add_license') || (isset($this->configFieldSetsCustomField['Encryption Settings']) && ArrayHelper::check( $this->configFieldSetsCustomField['Encryption Settings'] @@ -26427,8 +26360,8 @@ function vdm_dkim() { if ((CFactory::_('Config')->basic_encryption || CFactory::_('Config')->medium_encryption || CFactory::_('Config')->whmcs_encryption) - && $this->componentData->add_license - && $this->componentData->license_type == 3) + && CFactory::_('Component')->get('add_license') + && CFactory::_('Component')->get('license_type', 0) == 3) { CFactory::_('Language')->set( CFactory::_('Config')->lang_target, $lang . '_ENCRYPTION_LABEL', @@ -26444,8 +26377,8 @@ function vdm_dkim() { elseif ((CFactory::_('Config')->basic_encryption || CFactory::_('Config')->medium_encryption || CFactory::_('Config')->whmcs_encryption) - && $this->componentData->add_license - && $this->componentData->license_type == 2) + && CFactory::_('Component')->get('add_license') + && CFactory::_('Component')->get('license_type', 0) == 2) { CFactory::_('Language')->set( CFactory::_('Config')->lang_target, $lang . '_ENCRYPTION_LABEL', @@ -26458,8 +26391,8 @@ function vdm_dkim() { // add the next dynamic option $dynamicAddFields[] = "Update & Encryption Settings"; } - elseif ($this->componentData->add_license - && $this->componentData->license_type == 3) + elseif (CFactory::_('Component')->get('add_license') + && CFactory::_('Component')->get('license_type', 0) == 3) { CFactory::_('Language')->set( CFactory::_('Config')->lang_target, $lang . '_ENCRYPTION_LABEL', "License Settings" @@ -26471,8 +26404,8 @@ function vdm_dkim() { // add the next dynamic option $dynamicAddFields[] = "License Settings"; } - elseif ($this->componentData->add_license - && $this->componentData->license_type == 2) + elseif (CFactory::_('Component')->get('add_license') + && CFactory::_('Component')->get('license_type', 0) == 2) { CFactory::_('Language')->set( CFactory::_('Config')->lang_target, $lang . '_ENCRYPTION_LABEL', "Update Settings" @@ -26574,61 +26507,61 @@ function vdm_dkim() { ); } if (CFactory::_('Config')->whmcs_encryption - || $this->componentData->add_license) + || CFactory::_('Component')->get('add_license')) { // set field lang label and description - if ($this->componentData->add_license - && $this->componentData->license_type == 3) + if (CFactory::_('Component')->get('add_license') + && CFactory::_('Component')->get('license_type', 0) == 3) { CFactory::_('Language')->set( CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_LABEL', - $this->componentData->companyname . " License Key" + CFactory::_('Component')->get('companyname', '') . " License Key" ); CFactory::_('Language')->set( CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_DESC', "Add the license key you recieved from " - . $this->componentData->companyname . " here." + . CFactory::_('Component')->get('companyname', '') . " here." ); } - elseif ($this->componentData->add_license - && $this->componentData->license_type == 2) + elseif (CFactory::_('Component')->get('add_license') + && CFactory::_('Component')->get('license_type', 0) == 2) { CFactory::_('Language')->set( CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_LABEL', - $this->componentData->companyname . " Update Key" + CFactory::_('Component')->get('companyname', '') . " Update Key" ); CFactory::_('Language')->set( CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_DESC', "Add the update key you recieved from " - . $this->componentData->companyname . " here." + . CFactory::_('Component')->get('companyname', '') . " here." ); } else { CFactory::_('Language')->set( CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_LABEL', - $this->componentData->companyname . " Key" + CFactory::_('Component')->get('companyname', '') . " Key" ); CFactory::_('Language')->set( CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_DESC', "Add the key you recieved from " - . $this->componentData->companyname . " here." + . CFactory::_('Component')->get('companyname', '') . " here." ); } // ajust the notice based on license - if ($this->componentData->license_type == 3) + if (CFactory::_('Component')->get('license_type',0) == 3) { CFactory::_('Language')->set( CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_NOTE_LABEL', - "Your " . $this->componentData->companyname + "Your " . CFactory::_('Component')->get('companyname','') . " License Key" ); } - elseif ($this->componentData->license_type == 2) + elseif (CFactory::_('Component')->get('license_type',0) == 2) { CFactory::_('Language')->set( CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_NOTE_LABEL', - "Your " . $this->componentData->companyname + "Your " . CFactory::_('Component')->get('companyname','') . " Update Key" ); } @@ -26638,7 +26571,7 @@ function vdm_dkim() { { CFactory::_('Language')->set( CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_NOTE_LABEL', - "Your " . $this->componentData->companyname + "Your " . CFactory::_('Component')->get('companyname','') . " Field Encryption Key" ); } @@ -26646,7 +26579,7 @@ function vdm_dkim() { { CFactory::_('Language')->set( CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_NOTE_LABEL', - "Your " . $this->componentData->companyname . " Key" + "Your " . CFactory::_('Component')->get('companyname','') . " Key" ); } } @@ -26656,11 +26589,11 @@ function vdm_dkim() { CFactory::_('Language')->set( CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_NOTE_DESC', "You need to get this key from get('whmcs_buy_link','') . "' target='_blank'>" - . $this->componentData->companyname + . CFactory::_('Component')->get('companyname','') . ".
When using the " - . $this->componentData->companyname + . CFactory::_('Component')->get('companyname','') . " field encryption you can never change this key once it is set! DATA WILL GET CORRUPTED IF YOU DO!" ); } @@ -26669,9 +26602,9 @@ function vdm_dkim() { CFactory::_('Language')->set( CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_NOTE_DESC', "You need to get this key from get('whmcs_buy_link','') . "' target='_blank'>" - . $this->componentData->companyname . "." + . CFactory::_('Component')->get('companyname','') . "." ); } // set the fields @@ -26911,13 +26844,10 @@ function vdm_dkim() { $menuControllers = array('access', 'submenu', 'dashboard_list', 'dashboard_add'); // set the custom admin views permissions - if (isset($this->componentData->custom_admin_views) - && ArrayHelper::check( - $this->componentData->custom_admin_views - )) + if (CFactory::_('Component')->isArray('custom_admin_views')) { foreach ( - $this->componentData->custom_admin_views as $custom_admin_view + CFactory::_('Component')->get('custom_admin_views') as $custom_admin_view ) { // new custom permissions to access this view @@ -26997,12 +26927,9 @@ function vdm_dkim() { } } // set the site views permissions - if (isset($this->componentData->site_views) - && ArrayHelper::check( - $this->componentData->site_views - )) + if (CFactory::_('Component')->isArray('site_views')) { - foreach ($this->componentData->site_views as $site_view) + foreach (CFactory::_('Component')->get('site_views') as $site_view) { // new custom permissions to access this view $siteName = $site_view['settings']->name; @@ -27049,12 +26976,9 @@ function vdm_dkim() { ); } } - if (isset($this->componentData->admin_views) - && ArrayHelper::check( - $this->componentData->admin_views - )) + if (CFactory::_('Component')->isArray('admin_views')) { - foreach ($this->componentData->admin_views as $view) + foreach (CFactory::_('Component')->get('admin_views') as $view) { // set view name $nameView = StringHelper::safe( @@ -27989,21 +27913,18 @@ function vdm_dkim() { )) { $lang = array_map( - function ($langstring, $placeholder) { - return $placeholder . '="' . $langstring - . '"'; - }, array_values($languageStrings), + fn($langstring, $placeholder) => $placeholder . '="' . $langstring . '"', + array_values($languageStrings), array_keys($languageStrings) ); // set path - $path = $module->folder_path . '/language/' . $tag - . '/'; + $path = $module->folder_path . '/language/' . $tag . '/'; // create path if not exist if (!Folder::exists($path)) { Folder::create($path); // count the folder created - $this->folderCount++; + CFactory::_('Counter')->folder++; } // add to language files (for now we add all to both TODO) $this->writeFile( @@ -28016,7 +27937,7 @@ function vdm_dkim() { implode(PHP_EOL, $lang) ); // set the line counter - $this->lineCount = $this->lineCount + count( + CFactory::_('Counter')->line += count( (array) $lang ); unset($lang); @@ -28383,10 +28304,8 @@ function vdm_dkim() { )) { $lang = array_map( - function ($langstring, $placeholder) { - return $placeholder . '="' . $langstring - . '"'; - }, array_values($languageStrings), + fn($langstring, $placeholder) => $placeholder . '="' . $langstring . '"', + array_values($languageStrings), array_keys($languageStrings) ); // set path @@ -28397,7 +28316,7 @@ function vdm_dkim() { { Folder::create($path); // count the folder created - $this->folderCount++; + CFactory::_('Counter')->folder++; } // add to language file $this->writeFile( @@ -28413,7 +28332,7 @@ function vdm_dkim() { implode(PHP_EOL, $lang) ); // set the line counter - $this->lineCount = $this->lineCount + count( + CFactory::_('Counter')->line += count( (array) $lang ); unset($lang); diff --git a/admin/helpers/compiler/f_Infusion.php b/admin/helpers/compiler/f_Infusion.php index 5720c8a31..d26137175 100644 --- a/admin/helpers/compiler/f_Infusion.php +++ b/admin/helpers/compiler/f_Infusion.php @@ -27,6 +27,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Utilities\Minify; /** * Infusion class + * @deprecated 3.3 */ class Infusion extends Interpretation { @@ -73,10 +74,7 @@ class Infusion extends Interpretation */ protected function buildFileContent() { - if (isset($this->componentData->admin_views) - && ArrayHelper::check( - $this->componentData->admin_views - )) + if (CFactory::_('Component')->isArray('admin_views')) { // for plugin event TODO change event api signatures $placeholders = CFactory::_('Placeholder')->active; @@ -104,13 +102,14 @@ class Infusion extends Interpretation CFactory::_('Content')->set('component', CFactory::_('Placeholder')->get('component')); // COMPANYNAME + $companyname = CFactory::_('Component')->get('companyname'); CFactory::_('Content')->set('COMPANYNAME', trim( - (string) JFilterOutput::cleanText($this->componentData->companyname) + (string) JFilterOutput::cleanText($companyname) )); // CREATIONDATE CFactory::_('Content')->set('CREATIONDATE', - JFactory::getDate($this->componentData->created)->format( + JFactory::getDate(CFactory::_('Component')->get('created'))->format( 'jS F, Y' )); CFactory::_('Content')->set('GLOBALCREATIONDATE', @@ -122,24 +121,25 @@ class Infusion extends Interpretation CFactory::_('Content')->get('BUILDDATE')); // AUTHOR + $author = CFactory::_('Component')->get('author'); CFactory::_('Content')->set('AUTHOR', trim( - (string) JFilterOutput::cleanText($this->componentData->author) + (string) JFilterOutput::cleanText($author) )); // AUTHOREMAIL - CFactory::_('Content')->set('AUTHOREMAIL', trim((string) $this->componentData->email)); + CFactory::_('Content')->set('AUTHOREMAIL', trim((string) CFactory::_('Component')->get('email', ''))); // AUTHORWEBSITE - CFactory::_('Content')->set('AUTHORWEBSITE', trim((string) $this->componentData->website)); + CFactory::_('Content')->set('AUTHORWEBSITE', trim((string) CFactory::_('Component')->get('website', ''))); // COPYRIGHT - CFactory::_('Content')->set('COPYRIGHT', trim((string) $this->componentData->copyright)); + CFactory::_('Content')->set('COPYRIGHT', trim((string) CFactory::_('Component')->get('copyright', ''))); // LICENSE - CFactory::_('Content')->set('LICENSE', trim((string) $this->componentData->license)); + CFactory::_('Content')->set('LICENSE', trim((string) CFactory::_('Component')->get('license', ''))); // VERSION - CFactory::_('Content')->set('VERSION', trim((string) $this->componentData->component_version)); + CFactory::_('Content')->set('VERSION', trim((string) CFactory::_('Component')->get('component_version', ''))); // set the actual global version CFactory::_('Content')->set('ACTUALVERSION', CFactory::_('Content')->get('VERSION')); @@ -154,7 +154,7 @@ class Infusion extends Interpretation if (isset($versionArray) && ArrayHelper::check( $versionArray - ) && $this->componentData->mvc_versiondate == 2) + ) && CFactory::_('Component')->get('mvc_versiondate', 0) == 2) { CFactory::_('Content')->set('VERSION', $versionArray[0] . '.' . $versionArray[1] . '.x'); } @@ -162,7 +162,7 @@ class Infusion extends Interpretation elseif (isset($versionArray) && ArrayHelper::check( $versionArray - ) && $this->componentData->mvc_versiondate == 3) + ) && CFactory::_('Component')->get('mvc_versiondate', 0) == 3) { CFactory::_('Content')->set('VERSION', $versionArray[0] . '.x.x'); } @@ -175,20 +175,22 @@ class Infusion extends Interpretation CFactory::_('Content')->set('XMLVERSION', $this->joomlaVersions[CFactory::_('Config')->joomla_version]['xml_version']); // Component_name - CFactory::_('Content')->set('Component_name', JFilterOutput::cleanText($this->componentData->name)); + $name = CFactory::_('Component')->get('name'); + CFactory::_('Content')->set('Component_name', JFilterOutput::cleanText($name)); // SHORT_DISCRIPTION + $short_description = CFactory::_('Component')->get('short_description'); CFactory::_('Content')->set('SHORT_DESCRIPTION', trim( (string) JFilterOutput::cleanText( - $this->componentData->short_description + $short_description ) )); // DESCRIPTION - CFactory::_('Content')->set('DESCRIPTION', trim((string) $this->componentData->description)); + CFactory::_('Content')->set('DESCRIPTION', trim((string) CFactory::_('Component')->get('description'))); // COMP_IMAGE_TYPE - CFactory::_('Content')->set('COMP_IMAGE_TYPE', $this->setComponentImageType($this->componentData->image)); + CFactory::_('Content')->set('COMP_IMAGE_TYPE', $this->setComponentImageType(CFactory::_('Component')->get('image'))); // ACCESS_SECTIONS CFactory::_('Content')->set('ACCESS_SECTIONS', $this->setAccessSections()); @@ -247,7 +249,7 @@ class Infusion extends Interpretation CFactory::_('Content')->set('ADMIN_GLOBAL_EVENT_HELPER', ''); } // now load the data for the global event if needed - if ($this->componentData->add_admin_event == 1) + if (CFactory::_('Component')->get('add_admin_event', 0) == 1) { // ADMIN_GLOBAL_EVENT CFactory::_('Content')->add('ADMIN_GLOBAL_EVENT', PHP_EOL . PHP_EOL . '// Trigger the Global Admin Event'); @@ -272,7 +274,7 @@ class Infusion extends Interpretation } // now load the readme file if needed - if ($this->componentData->addreadme == 1) + if (CFactory::_('Component')->get('addreadme', 0) == 1) { CFactory::_('Content')->add('EXSTRA_ADMIN_FILES', PHP_EOL . Indent::_(3) @@ -282,7 +284,7 @@ class Infusion extends Interpretation // HELPER_CREATEUSER CFactory::_('Content')->add('HELPER_CREATEUSER', $this->setCreateUserHelperMethod( - $this->componentData->creatuserhelper + CFactory::_('Component')->get('creatuserhelper') )); // HELP @@ -310,7 +312,7 @@ class Infusion extends Interpretation $viewarray = array(); $site_edit_view_array = array(); // start dynamic build - foreach ($this->componentData->admin_views as $view) + foreach (CFactory::_('Component')->get('admin_views') as $view) { // set the target CFactory::_('Config')->build_target = 'admin'; @@ -1041,15 +1043,12 @@ class Infusion extends Interpretation $this->setCustomViewLayouts(); // setup custom_admin_views and all needed stuff for the site - if (isset($this->componentData->custom_admin_views) - && ArrayHelper::check( - $this->componentData->custom_admin_views - )) + if (CFactory::_('Component')->isArray('custom_admin_views')) { CFactory::_('Config')->build_target = 'custom_admin'; CFactory::_('Config')->lang_target = 'admin'; // start dynamic build - foreach ($this->componentData->custom_admin_views as $view) + foreach (CFactory::_('Component')->get('custom_admin_views') as $view) { // for single views CFactory::_('Content')->set_($view['settings']->code, 'SView', $view['settings']->Code); @@ -1455,14 +1454,11 @@ class Infusion extends Interpretation CFactory::_('Config')->lang_target = $keepLang; // setup front-views and all needed stuff for the site - if (isset($this->componentData->site_views) - && ArrayHelper::check( - $this->componentData->site_views - )) + if (CFactory::_('Component')->isArray('site_views')) { CFactory::_('Config')->build_target = 'site'; // start dynamic build - foreach ($this->componentData->site_views as $view) + foreach (CFactory::_('Component')->get('site_views') as $view) { // for list views CFactory::_('Content')->set_($view['settings']->code, 'SViews', $view['settings']->Code); @@ -1725,7 +1721,7 @@ class Infusion extends Interpretation CFactory::_('Content')->set('SITE_GLOBAL_EVENT_HELPER', ''); } // now load the data for the global event if needed - if ($this->componentData->add_site_event == 1) + if (CFactory::_('Component')->get('add_site_event', 0) == 1) { CFactory::_('Content')->add('SITE_GLOBAL_EVENT', PHP_EOL . PHP_EOL . '// Trigger the Global Site Event'); CFactory::_('Content')->add('SITE_GLOBAL_EVENT', @@ -1796,9 +1792,9 @@ class Infusion extends Interpretation } // README - if ($this->componentData->addreadme) + if (CFactory::_('Component')->get('addreadme')) { - CFactory::_('Content')->set('README', $this->componentData->readme); + CFactory::_('Content')->set('README', CFactory::_('Component')->get('readme')); } // Infuse POWERS @@ -1809,9 +1805,9 @@ class Infusion extends Interpretation $_backup_lang = CFactory::_('Config')->lang_target; $_backup_langPrefix = CFactory::_('Config')->lang_prefix; // infuse module data if set - if (ArrayHelper::check($this->joomlaModules)) + if (CFactory::_('Joomlamodule.Data')->exists()) { - foreach ($this->joomlaModules as $module) + foreach (CFactory::_('Joomlamodule.Data')->get() as $module) { if (ObjectHelper::check($module)) { @@ -1877,9 +1873,9 @@ class Infusion extends Interpretation } } // infuse plugin data if set - if (ArrayHelper::check($this->joomlaPlugins)) + if (CFactory::_('Joomlaplugin.Data')->exists()) { - foreach ($this->joomlaPlugins as $plugin) + foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin) { if (ObjectHelper::check($plugin)) { @@ -1946,7 +1942,7 @@ class Infusion extends Interpretation CFactory::_('Event')->trigger( 'jcb_ce_onAfterBuildFilesContent', array(&$component_context, &$this->componentData, - &$fileContentStatic, &$this->fileContentDynamic, + &$fileContentStatic, &$fileContentDynamic, &$placeholders, &$this->hhh) ); unset($fileContentStatic); @@ -2153,17 +2149,16 @@ class Infusion extends Interpretation { Folder::create($path); // count the folder created - $this->folderCount++; + CFactory::_('Counter')->folder++; } // move the file to its place File::copy($getPAth, $path . $file_name); // count the file created - $this->fileCount++; + CFactory::_('Counter')->file++; // add content to it $lang = array_map( - function ($langstring, $placeholder) { - return $placeholder . '="' . $langstring . '"'; - }, array_values($languageStrings), + fn($langstring, $placeholder) => $placeholder . '="' . $langstring . '"', + array_values($languageStrings), array_keys($languageStrings) ); // add to language file @@ -2171,7 +2166,7 @@ class Infusion extends Interpretation $path . $file_name, implode(PHP_EOL, $lang) ); // set the line counter - $this->lineCount = $this->lineCount + count( + CFactory::_('Counter')->line += count( (array) $lang ); unset($lang); diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.ini b/admin/language/en-GB/en-GB.com_componentbuilder.ini index 17be2d5fc..46a7109b5 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.ini @@ -5605,6 +5605,7 @@ COM_COMPONENTBUILDER_HR_HTHREECUSTOM_CODES_WARNINGHTHREE="

Custom Codes COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_ERRORHTHREE="

External Code Error

" COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_NOTICEHTHREE="

External Code Notice

" COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_WARNINGHTHREE="

External Code Warning

" +COM_COMPONENTBUILDER_HR_HTHREEFIELD_NOTICEHTHREE="

Field Notice

" COM_COMPONENTBUILDER_HTHREEPLACEHOLDER_REMOVEDHTHREEPBTHISB_CUSTOM_CODE_CAN_ONLY_BE_USED_IN_BOTHERB_CUSTOM_CODE_NOT_IN_IT_SELF_SINCE_THAT_WILL_CAUSE_A_INFINITE_LOOP_IN_THE_COMPILERP="

Placeholder Removed!

This custom code can only be used in other custom code, not in it self! Since that will cause a infinite loop in the compiler.

" COM_COMPONENTBUILDER_HTHREESHTHREEPCUSTOM_CODE_CAN_ONLY_BE_USED_IN_OTHER_CUSTOM_CODE_IF_SET_AS_BJCB_MANUALB_YOU_CAN_NOT_ADD_THEM_TO_EMHASH_AUTOMATIONEM_CODE_AT_THIS_POINTP="

%s

Custom code can only be used in other custom code if set as JCB (manual), you can not add them to Hash (Automation) code at this point.

" COM_COMPONENTBUILDER_HTHREES_NAMESPACE_ERROR_SHTHREEPYOU_MUST_ATLEAST_HAVE_TWO_SECTIONS_IN_YOUR_NAMESPACE_YOU_JUST_HAVE_ONE_S_THIS_IS_AN_UNACCEPTABLE_ACTION_PLEASE_SEE_A_HREFS_PSRFOURA_FOR_MORE_INFOPPTHIS_S_WAS_THEREFORE_REMOVED_A_HREFSCLICK_HEREA_TO_FIX_THIS_ISSUEP="

%s namespace error (%s)

You must at-least have two sections in your namespace, you just have one (%s). This is an unacceptable action, please see psr-4 for more info.

This %s was therefore removed, click here to fix this issue.

" diff --git a/admin/models/forms/power.xml b/admin/models/forms/power.xml index a39a81ab1..f8a8058d1 100644 --- a/admin/models/forms/power.xml +++ b/admin/models/forms/power.xml @@ -425,9 +425,8 @@ buttons="add,remove,move" description="COM_COMPONENTBUILDER_POWER_USE_SELECTION_DESCRIPTION" icon="list" - max="30" - min="0" - showon="type!:interface"> + max="100" + min="0">