diff --git a/componentbuilderactionlogcompiler.php b/componentbuilderactionlogcompiler.php index 2e99a1a..5ae54ab 100644 --- a/componentbuilderactionlogcompiler.php +++ b/componentbuilderactionlogcompiler.php @@ -17,12 +17,17 @@ use Joomla\CMS\Plugin\CMSPlugin; use Joomla\Registry\Registry; JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'); + +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; /** * Extension - Componentbuilder ActionLog Compiler plugin. * * @package ComponentbuilderActionLogCompiler - * @since 1.0.3 + * @since 1.1.0 */ class PlgExtensionComponentbuilderActionLogCompiler extends CMSPlugin { @@ -41,34 +46,6 @@ class PlgExtensionComponentbuilderActionLogCompiler extends CMSPlugin */ protected $languageArray = array(); - /** - * The hash placeholder - * - * @var string - */ - protected $hhh = '#' . '#' . '#'; - - /** - * The open bracket placeholder - * - * @var string - */ - protected $bbb = '[' . '[' . '['; - - /** - * The close bracket placeholder - * - * @var string - */ - protected $ddd = ']' . ']' . ']'; - - /* - * The line numbers Switch - * - * @var boolean - */ - protected $debugLinenr = false; - /** * The Scripts * @@ -76,25 +53,6 @@ class PlgExtensionComponentbuilderActionLogCompiler extends CMSPlugin */ protected $scriptsArray = array('POSTINSTALLSCRIPT' => array(), 'POSTUPDATESCRIPT' => array(), 'UNINSTALLSCRIPT' => array()); - /** - * Event Triggered in the compiler [on Before Get Component Data] - * - * @return void - * - * @since 1.0 - */ - public function jcb_ce_onBeforeGetComponentData(&$context, $compiler) - { - if ($this->componentActive($context)) - { - // sync needed compiler class properties with this plugin class - $this->debugLinenr = $compiler->debugLinenr; - $this->hhh = $compiler->hhh; - $this->bbb = $compiler->bbb; - $this->ddd = $compiler->ddd; - } - } - /** * Event Triggered in the compiler [on After Get Component Data] * @@ -108,7 +66,7 @@ class PlgExtensionComponentbuilderActionLogCompiler extends CMSPlugin { foreach($this->languageArray as $key => $string) { - $compiler->setLangContent('admin', $key, $string); + CFactory::_('Language')->set('admin', $key, $string); } } } @@ -128,11 +86,11 @@ class PlgExtensionComponentbuilderActionLogCompiler extends CMSPlugin foreach ($this->scriptsArray as $target => &$bucket) { // add the component main target script - $fileContentStatic[$hhh. $target . $hhh] .= $this->{'getMain' . $target}($placeholders); + CFactory::_('Content')->add($target, $this->{'getMain' . $target}()); // add the component views target scripts if (ComponentbuilderHelper::checkArray($bucket)) { - $fileContentStatic[$hhh. $target . $hhh] .= implode('', $bucket); + CFactory::_('Content')->add($target, implode('', $bucket)); } } } @@ -172,28 +130,30 @@ class PlgExtensionComponentbuilderActionLogCompiler extends CMSPlugin } } } - // none title set - $placeholders['<<>>'] = ''; + // if found update placeholder if (isset($title_holder)) { // set main title - $placeholders['<<>>'] = $title_holder; + CFactory::_('Placeholder')->set('<<>>', $title_holder, false); } else { // fall back on ID - $placeholders['<<>>'] = 'id'; + CFactory::_('Placeholder')->set('<<>>', 'id', false); } + // now load the script strings foreach ($this->scriptsArray as $target => &$bucket) { - $bucket[] = $this->{'getView' . $target}($placeholders); + $bucket[] = $this->{'getView' . $target}(); } + // just remove it again - unset($placeholders['<<>>']); + CFactory::_('Placeholder')->remove('<<>>'); + // set language string - $this->languageArray[$placeholders[$this->bbb . "LANG_PREFIX" . $this->ddd] . '_TYPE_' . $placeholders[$this->bbb . "VIEW" . $this->ddd]] = $view->name_single; + $this->languageArray[CFactory::_('Placeholder')->get_("LANG_PREFIX") . '_TYPE_' . CFactory::_('Placeholder')->get_("VIEW")] = $view->name_single; } } @@ -203,22 +163,22 @@ class PlgExtensionComponentbuilderActionLogCompiler extends CMSPlugin * @return string * */ - protected function getMainPOSTINSTALLSCRIPT(&$placeholders) + protected function getMainPOSTINSTALLSCRIPT() { - $script = PHP_EOL . PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Set db if not set already."; - $script .= PHP_EOL . $this->_t(3) . "if (!isset(\$db))"; - $script .= PHP_EOL . $this->_t(3) . "{"; - $script .= PHP_EOL . $this->_t(4) . "\$db = JFactory::getDbo();"; - $script .= PHP_EOL . $this->_t(3) . "}"; + $script = PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " Set db if not set already."; + $script .= PHP_EOL . Indent::_(3) . "if (!isset(\$db))"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "\$db = JFactory::getDbo();"; + $script .= PHP_EOL . Indent::_(3) . "}"; - $script .= PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Create the " . $this->bbb . "component" . $this->ddd . " action logs extensions object."; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "component" . $this->ddd . "_action_logs_extensions = new stdClass();"; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "component" . $this->ddd . "_action_logs_extensions->extension = 'com_" . $this->bbb . "component" . $this->ddd . "';"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " Create the " . Placefix::_("component") . " action logs extensions object."; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("component") . "_action_logs_extensions = new stdClass();"; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("component") . "_action_logs_extensions->extension = 'com_" . Placefix::_("component") . "';"; - $script .= PHP_EOL . PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Set the object into the action logs extensions table."; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "component" . $this->ddd . "_action_logs_extensions_Inserted = \$db->insertObject('#__action_logs_extensions', \$" . $this->bbb . "component" . $this->ddd . "_action_logs_extensions);"; + $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " Set the object into the action logs extensions table."; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("component") . "_action_logs_extensions_Inserted = \$db->insertObject('#__action_logs_extensions', \$" . Placefix::_("component") . "_action_logs_extensions);"; - return str_replace(array_keys($placeholders), array_values($placeholders), $script); + return CFactory::_('Placeholder')->update_($script); } /** @@ -227,27 +187,27 @@ class PlgExtensionComponentbuilderActionLogCompiler extends CMSPlugin * @return string * */ - protected function getViewPOSTINSTALLSCRIPT(&$placeholders) + protected function getViewPOSTINSTALLSCRIPT() { - $script = PHP_EOL . PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Set db if not set already."; - $script .= PHP_EOL . $this->_t(3) . "if (!isset(\$db))"; - $script .= PHP_EOL . $this->_t(3) . "{"; - $script .= PHP_EOL . $this->_t(4) . "\$db = JFactory::getDbo();"; - $script .= PHP_EOL . $this->_t(3) . "}"; + $script = PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " Set db if not set already."; + $script .= PHP_EOL . Indent::_(3) . "if (!isset(\$db))"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "\$db = JFactory::getDbo();"; + $script .= PHP_EOL . Indent::_(3) . "}"; - $script .= PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Create the " . $this->bbb . "view" . $this->ddd . " action log config object."; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config = new stdClass();"; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config->type_title = '" . $this->bbb . "VIEW" . $this->ddd . "';"; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config->type_alias = 'com_" . $this->bbb . "component" . $this->ddd . "." . $this->bbb . "view" . $this->ddd . "';"; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config->id_holder = 'id';"; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config->title_holder = '<<>>';"; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config->table_name = '#__" . $this->bbb . "component" . $this->ddd . "_" . $this->bbb . "view" . $this->ddd . "';"; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config->text_prefix = '" . $this->bbb . "LANG_PREFIX" . $this->ddd . "';"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " Create the " . Placefix::_("view") . " action log config object."; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("view") . "_action_log_config = new stdClass();"; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("view") . "_action_log_config->type_title = '" . Placefix::_("VIEW") . "';"; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("view") . "_action_log_config->type_alias = 'com_" . Placefix::_("component") . "." . Placefix::_("view") . "';"; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("view") . "_action_log_config->id_holder = 'id';"; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("view") . "_action_log_config->title_holder = '<<>>';"; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("view") . "_action_log_config->table_name = '#__" . Placefix::_("component") . "_" . Placefix::_("view") . "';"; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("view") . "_action_log_config->text_prefix = '" . Placefix::_("LANG_PREFIX") . "';"; - $script .= PHP_EOL . PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Set the object into the action log config table."; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "view" . $this->ddd . "_Inserted = \$db->insertObject('#__action_log_config', \$" . $this->bbb . "view" . $this->ddd . "_action_log_config);"; + $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " Set the object into the action log config table."; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("view") . "_Inserted = \$db->insertObject('#__action_log_config', \$" . Placefix::_("view") . "_action_log_config);"; - return str_replace(array_keys($placeholders), array_values($placeholders), $script); + return CFactory::_('Placeholder')->update_($script); } /** @@ -256,33 +216,33 @@ class PlgExtensionComponentbuilderActionLogCompiler extends CMSPlugin * @return string * */ - protected function getMainPOSTUPDATESCRIPT(&$placeholders) + protected function getMainPOSTUPDATESCRIPT() { - $script = PHP_EOL . PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Set db if not set already."; - $script .= PHP_EOL . $this->_t(3) . "if (!isset(\$db))"; - $script .= PHP_EOL . $this->_t(3) . "{"; - $script .= PHP_EOL . $this->_t(4) . "\$db = JFactory::getDbo();"; - $script .= PHP_EOL . $this->_t(3) . "}"; + $script = PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " Set db if not set already."; + $script .= PHP_EOL . Indent::_(3) . "if (!isset(\$db))"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "\$db = JFactory::getDbo();"; + $script .= PHP_EOL . Indent::_(3) . "}"; - $script .= PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Create the " . $this->bbb . "component" . $this->ddd . " action logs extensions object."; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "component" . $this->ddd . "_action_logs_extensions = new stdClass();"; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "component" . $this->ddd . "_action_logs_extensions->extension = 'com_" . $this->bbb . "component" . $this->ddd . "';"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " Create the " . Placefix::_("component") . " action logs extensions object."; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("component") . "_action_logs_extensions = new stdClass();"; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("component") . "_action_logs_extensions->extension = 'com_" . Placefix::_("component") . "';"; - $script .= PHP_EOL . PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Check if " . $this->bbb . "component" . $this->ddd . " action log extension is already in action logs extensions DB."; - $script .= PHP_EOL . $this->_t(3) . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . $this->_t(3) . "\$query->select(\$db->quoteName(array('id')));"; - $script .= PHP_EOL . $this->_t(3) . "\$query->from(\$db->quoteName('#__action_logs_extensions'));"; - $script .= PHP_EOL . $this->_t(3) . "\$query->where(\$db->quoteName('extension') . ' LIKE '. \$db->quote(\$" . $this->bbb . "component" . $this->ddd . "_action_logs_extensions->extension));"; - $script .= PHP_EOL . $this->_t(3) . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . $this->_t(3) . "\$db->execute();"; + $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " Check if " . Placefix::_("component") . " action log extension is already in action logs extensions DB."; + $script .= PHP_EOL . Indent::_(3) . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(3) . "\$query->select(\$db->quoteName(array('id')));"; + $script .= PHP_EOL . Indent::_(3) . "\$query->from(\$db->quoteName('#__action_logs_extensions'));"; + $script .= PHP_EOL . Indent::_(3) . "\$query->where(\$db->quoteName('extension') . ' LIKE '. \$db->quote(\$" . Placefix::_("component") . "_action_logs_extensions->extension));"; + $script .= PHP_EOL . Indent::_(3) . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(3) . "\$db->execute();"; - $script .= PHP_EOL . PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Set the object into the action logs extensions table if not found."; - $script .= PHP_EOL . $this->_t(3) . "if (!\$db->getNumRows())"; - $script .= PHP_EOL . $this->_t(3) . "{"; - $script .= PHP_EOL . $this->_t(4) . "\$" . $this->bbb . "component" . $this->ddd . "_action_logs_extensions_Inserted = \$db->insertObject('#__action_logs_extensions', \$" . $this->bbb . "component" . $this->ddd . "_action_logs_extensions);"; - $script .= PHP_EOL . $this->_t(3) . "}"; + $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " Set the object into the action logs extensions table if not found."; + $script .= PHP_EOL . Indent::_(3) . "if (!\$db->getNumRows())"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "\$" . Placefix::_("component") . "_action_logs_extensions_Inserted = \$db->insertObject('#__action_logs_extensions', \$" . Placefix::_("component") . "_action_logs_extensions);"; + $script .= PHP_EOL . Indent::_(3) . "}"; - return str_replace(array_keys($placeholders), array_values($placeholders), $script); + return CFactory::_('Placeholder')->update_($script); } /** @@ -291,44 +251,44 @@ class PlgExtensionComponentbuilderActionLogCompiler extends CMSPlugin * @return string * */ - protected function getViewPOSTUPDATESCRIPT(&$placeholders) + protected function getViewPOSTUPDATESCRIPT() { - $script = PHP_EOL . PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Set db if not set already."; - $script .= PHP_EOL . $this->_t(3) . "if (!isset(\$db))"; - $script .= PHP_EOL . $this->_t(3) . "{"; - $script .= PHP_EOL . $this->_t(4) . "\$db = JFactory::getDbo();"; - $script .= PHP_EOL . $this->_t(3) . "}"; + $script = PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " Set db if not set already."; + $script .= PHP_EOL . Indent::_(3) . "if (!isset(\$db))"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "\$db = JFactory::getDbo();"; + $script .= PHP_EOL . Indent::_(3) . "}"; - $script .= PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Create the " . $this->bbb . "view" . $this->ddd . " action log config object."; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config = new stdClass();"; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config->id = null;"; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config->type_title = '" . $this->bbb . "VIEW" . $this->ddd . "';"; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config->type_alias = 'com_" . $this->bbb . "component" . $this->ddd . "." . $this->bbb . "view" . $this->ddd . "';"; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config->id_holder = 'id';"; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config->title_holder = '<<>>';"; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config->table_name = '#__" . $this->bbb . "component" . $this->ddd . "_" . $this->bbb . "view" . $this->ddd . "';"; - $script .= PHP_EOL . $this->_t(3) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config->text_prefix = '" . $this->bbb . "LANG_PREFIX" . $this->ddd . "';"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " Create the " . Placefix::_("view") . " action log config object."; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("view") . "_action_log_config = new stdClass();"; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("view") . "_action_log_config->id = null;"; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("view") . "_action_log_config->type_title = '" . Placefix::_("VIEW") . "';"; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("view") . "_action_log_config->type_alias = 'com_" . Placefix::_("component") . "." . Placefix::_("view") . "';"; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("view") . "_action_log_config->id_holder = 'id';"; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("view") . "_action_log_config->title_holder = '<<>>';"; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("view") . "_action_log_config->table_name = '#__" . Placefix::_("component") . "_" . Placefix::_("view") . "';"; + $script .= PHP_EOL . Indent::_(3) . "\$" . Placefix::_("view") . "_action_log_config->text_prefix = '" . Placefix::_("LANG_PREFIX") . "';"; - $script .= PHP_EOL . PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Check if " . $this->bbb . "view" . $this->ddd . " action log config is already in action_log_config DB."; - $script .= PHP_EOL . $this->_t(3) . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . $this->_t(3) . "\$query->select(\$db->quoteName(array('id')));"; - $script .= PHP_EOL . $this->_t(3) . "\$query->from(\$db->quoteName('#__action_log_config'));"; - $script .= PHP_EOL . $this->_t(3) . "\$query->where(\$db->quoteName('type_alias') . ' LIKE '. \$db->quote(\$" . $this->bbb . "view" . $this->ddd . "_action_log_config->type_alias));"; - $script .= PHP_EOL . $this->_t(3) . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . $this->_t(3) . "\$db->execute();"; + $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " Check if " . Placefix::_("view") . " action log config is already in action_log_config DB."; + $script .= PHP_EOL . Indent::_(3) . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(3) . "\$query->select(\$db->quoteName(array('id')));"; + $script .= PHP_EOL . Indent::_(3) . "\$query->from(\$db->quoteName('#__action_log_config'));"; + $script .= PHP_EOL . Indent::_(3) . "\$query->where(\$db->quoteName('type_alias') . ' LIKE '. \$db->quote(\$" . Placefix::_("view") . "_action_log_config->type_alias));"; + $script .= PHP_EOL . Indent::_(3) . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(3) . "\$db->execute();"; - $script .= PHP_EOL . PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Set the object into the content types table."; - $script .= PHP_EOL . $this->_t(3) . "if (\$db->getNumRows())"; - $script .= PHP_EOL . $this->_t(3) . "{"; - $script .= PHP_EOL . $this->_t(4) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config->id = \$db->loadResult();"; - $script .= PHP_EOL . $this->_t(4) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config_Updated = \$db->updateObject('#__action_log_config', \$" . $this->bbb . "view" . $this->ddd . "_action_log_config, 'id');"; - $script .= PHP_EOL . $this->_t(3) . "}"; - $script .= PHP_EOL . $this->_t(3) . "else"; - $script .= PHP_EOL . $this->_t(3) . "{"; - $script .= PHP_EOL . $this->_t(4) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config_Inserted = \$db->insertObject('#__action_log_config', \$" . $this->bbb . "view" . $this->ddd . "_action_log_config);"; - $script .= PHP_EOL . $this->_t(3) . "}"; + $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " Set the object into the content types table."; + $script .= PHP_EOL . Indent::_(3) . "if (\$db->getNumRows())"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "\$" . Placefix::_("view") . "_action_log_config->id = \$db->loadResult();"; + $script .= PHP_EOL . Indent::_(4) . "\$" . Placefix::_("view") . "_action_log_config_Updated = \$db->updateObject('#__action_log_config', \$" . Placefix::_("view") . "_action_log_config, 'id');"; + $script .= PHP_EOL . Indent::_(3) . "}"; + $script .= PHP_EOL . Indent::_(3) . "else"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "\$" . Placefix::_("view") . "_action_log_config_Inserted = \$db->insertObject('#__action_log_config', \$" . Placefix::_("view") . "_action_log_config);"; + $script .= PHP_EOL . Indent::_(3) . "}"; - return str_replace(array_keys($placeholders), array_values($placeholders), $script); + return CFactory::_('Placeholder')->update_($script); } /** @@ -337,36 +297,36 @@ class PlgExtensionComponentbuilderActionLogCompiler extends CMSPlugin * @return string * */ - protected function getMainUNINSTALLSCRIPT(&$placeholders) + protected function getMainUNINSTALLSCRIPT() { - $script = PHP_EOL . PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Set db if not set already."; - $script .= PHP_EOL . $this->_t(2) . "if (!isset(\$db))"; - $script .= PHP_EOL . $this->_t(2) . "{"; - $script .= PHP_EOL . $this->_t(3) . "\$db = JFactory::getDbo();"; - $script .= PHP_EOL . $this->_t(2) . "}"; - $script .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Set app if not set already."; - $script .= PHP_EOL . $this->_t(2) . "if (!isset(\$app))"; - $script .= PHP_EOL . $this->_t(2) . "{"; - $script .= PHP_EOL . $this->_t(3) . "\$app = JFactory::getApplication();"; - $script .= PHP_EOL . $this->_t(2) . "}"; + $script = PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Set db if not set already."; + $script .= PHP_EOL . Indent::_(2) . "if (!isset(\$db))"; + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "\$db = JFactory::getDbo();"; + $script .= PHP_EOL . Indent::_(2) . "}"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Set app if not set already."; + $script .= PHP_EOL . Indent::_(2) . "if (!isset(\$app))"; + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "\$app = JFactory::getApplication();"; + $script .= PHP_EOL . Indent::_(2) . "}"; - $script .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Remove " . $this->bbb . "Component" . $this->ddd . " from the action_logs_extensions table"; - $script .= PHP_EOL . $this->_t(2) . "\$" . $this->bbb . "component" . $this->ddd . "_action_logs_extensions = array( \$db->quoteName('extension') . ' = ' . \$db->quote('com_" . $this->bbb . "component" . $this->ddd . "') );"; - $script .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Create a new query object."; - $script .= PHP_EOL . $this->_t(2) . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . $this->_t(2) . "\$query->delete(\$db->quoteName('#__action_logs_extensions'));"; - $script .= PHP_EOL . $this->_t(2) . "\$query->where(\$" . $this->bbb . "component" . $this->ddd . "_action_logs_extensions);"; - $script .= PHP_EOL . $this->_t(2) . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Remove " . Placefix::_("Component") . " from the action_logs_extensions table"; + $script .= PHP_EOL . Indent::_(2) . "\$" . Placefix::_("component") . "_action_logs_extensions = array( \$db->quoteName('extension') . ' = ' . \$db->quote('com_" . Placefix::_("component") . "') );"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Create a new query object."; + $script .= PHP_EOL . Indent::_(2) . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(2) . "\$query->delete(\$db->quoteName('#__action_logs_extensions'));"; + $script .= PHP_EOL . Indent::_(2) . "\$query->where(\$" . Placefix::_("component") . "_action_logs_extensions);"; + $script .= PHP_EOL . Indent::_(2) . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Execute the query to remove " . $this->bbb . "Component" . $this->ddd . ""; - $script .= PHP_EOL . $this->_t(2) . "\$" . $this->bbb . "component" . $this->ddd . "_removed_done = \$db->execute();"; - $script .= PHP_EOL . $this->_t(2) . "if (\$" . $this->bbb . "component" . $this->ddd . "_removed_done)"; - $script .= PHP_EOL . $this->_t(2) . "{"; - $script .= PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " If successfully remove " . $this->bbb . "Component" . $this->ddd . " add queued success message."; - $script .= PHP_EOL . $this->_t(3) . "\$app->enqueueMessage(JTe" . "xt::_('The com_" . $this->bbb . "component" . $this->ddd . " extension was removed from the #__action_logs_extensions table'));"; - $script .= PHP_EOL . $this->_t(2) . "}"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Execute the query to remove " . Placefix::_("Component") . ""; + $script .= PHP_EOL . Indent::_(2) . "\$" . Placefix::_("component") . "_removed_done = \$db->execute();"; + $script .= PHP_EOL . Indent::_(2) . "if (\$" . Placefix::_("component") . "_removed_done)"; + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " If successfully remove " . Placefix::_("Component") . " add queued success message."; + $script .= PHP_EOL . Indent::_(3) . "\$app->enqueueMessage(JTe" . "xt::_('The com_" . Placefix::_("component") . " extension was removed from the #__action_logs_extensions table'));"; + $script .= PHP_EOL . Indent::_(2) . "}"; - return str_replace(array_keys($placeholders), array_values($placeholders), $script); + return CFactory::_('Placeholder')->update_($script); } /** @@ -375,67 +335,37 @@ class PlgExtensionComponentbuilderActionLogCompiler extends CMSPlugin * @return string * */ - protected function getViewUNINSTALLSCRIPT(&$placeholders) + protected function getViewUNINSTALLSCRIPT() { - $script = PHP_EOL . PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Set db if not set already."; - $script .= PHP_EOL . $this->_t(2) . "if (!isset(\$db))"; - $script .= PHP_EOL . $this->_t(2) . "{"; - $script .= PHP_EOL . $this->_t(3) . "\$db = JFactory::getDbo();"; - $script .= PHP_EOL . $this->_t(2) . "}"; - $script .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Set app if not set already."; - $script .= PHP_EOL . $this->_t(2) . "if (!isset(\$app))"; - $script .= PHP_EOL . $this->_t(2) . "{"; - $script .= PHP_EOL . $this->_t(3) . "\$app = JFactory::getApplication();"; - $script .= PHP_EOL . $this->_t(2) . "}"; + $script = PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Set db if not set already."; + $script .= PHP_EOL . Indent::_(2) . "if (!isset(\$db))"; + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "\$db = JFactory::getDbo();"; + $script .= PHP_EOL . Indent::_(2) . "}"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Set app if not set already."; + $script .= PHP_EOL . Indent::_(2) . "if (!isset(\$app))"; + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "\$app = JFactory::getApplication();"; + $script .= PHP_EOL . Indent::_(2) . "}"; - $script .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Remove " . $this->bbb . "Component" . $this->ddd . " " . $this->bbb . "View" . $this->ddd . " from the action_log_config table"; - $script .= PHP_EOL . $this->_t(2) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config = array( \$db->quoteName('type_alias') . ' = '. \$db->quote('com_" . $this->bbb . "component" . $this->ddd . "." . $this->bbb . "view" . $this->ddd . "') );"; - $script .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Create a new query object."; - $script .= PHP_EOL . $this->_t(2) . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . $this->_t(2) . "\$query->delete(\$db->quoteName('#__action_log_config'));"; - $script .= PHP_EOL . $this->_t(2) . "\$query->where(\$" . $this->bbb . "view" . $this->ddd . "_action_log_config);"; - $script .= PHP_EOL . $this->_t(2) . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Execute the query to remove com_" . $this->bbb . "component" . $this->ddd . "." . $this->bbb . "view" . $this->ddd . ""; - $script .= PHP_EOL . $this->_t(2) . "\$" . $this->bbb . "view" . $this->ddd . "_action_log_config_done = \$db->execute();"; - $script .= PHP_EOL . $this->_t(2) . "if (\$" . $this->bbb . "view" . $this->ddd . "_action_log_config_done)"; - $script .= PHP_EOL . $this->_t(2) . "{"; - $script .= PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " If successfully removed " . $this->bbb . "Component" . $this->ddd . " " . $this->bbb . "View" . $this->ddd . " add queued success message."; - $script .= PHP_EOL . $this->_t(3) . "\$app->enqueueMessage(JTe" . "xt::_('The com_" . $this->bbb . "component" . $this->ddd . "." . $this->bbb . "view" . $this->ddd . " type alias was removed from the #__action_log_config table'));"; - $script .= PHP_EOL . $this->_t(2) . "}"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Remove " . Placefix::_("Component") . " " . Placefix::_("View") . " from the action_log_config table"; + $script .= PHP_EOL . Indent::_(2) . "\$" . Placefix::_("view") . "_action_log_config = array( \$db->quoteName('type_alias') . ' = '. \$db->quote('com_" . Placefix::_("component") . "." . Placefix::_("view") . "') );"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Create a new query object."; + $script .= PHP_EOL . Indent::_(2) . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(2) . "\$query->delete(\$db->quoteName('#__action_log_config'));"; + $script .= PHP_EOL . Indent::_(2) . "\$query->where(\$" . Placefix::_("view") . "_action_log_config);"; + $script .= PHP_EOL . Indent::_(2) . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Execute the query to remove com_" . Placefix::_("component") . "." . Placefix::_("view") . ""; + $script .= PHP_EOL . Indent::_(2) . "\$" . Placefix::_("view") . "_action_log_config_done = \$db->execute();"; + $script .= PHP_EOL . Indent::_(2) . "if (\$" . Placefix::_("view") . "_action_log_config_done)"; + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " If successfully removed " . Placefix::_("Component") . " " . Placefix::_("View") . " add queued success message."; + $script .= PHP_EOL . Indent::_(3) . "\$app->enqueueMessage(JTe" . "xt::_('The com_" . Placefix::_("component") . "." . Placefix::_("view") . " type alias was removed from the #__action_log_config table'));"; + $script .= PHP_EOL . Indent::_(2) . "}"; - return str_replace(array_keys($placeholders), array_values($placeholders), $script); + return CFactory::_('Placeholder')->update_($script); } - /** - * Set the line number in comments - * - * @param int $nr The line number - * - * @return void - * - */ - protected function setLine($nr) - { - if ($this->debugLinenr) - { - return ' [Plugin-ActionLog-Compiler ' . $nr . ']'; - } - return ''; - } - - /** - * Set the tab/space - * - * @param int $nr The number of tag/space - * - * @return string - * - */ - protected function _t($nr) - { - // use global method for conformity - return ComponentbuilderHelper::_t($nr); - } /** * The array of active components diff --git a/componentbuilderactionlogcompiler.xml b/componentbuilderactionlogcompiler.xml index 96331f9..32b916f 100644 --- a/componentbuilderactionlogcompiler.xml +++ b/componentbuilderactionlogcompiler.xml @@ -1,13 +1,13 @@ PLG_EXTENSION_COMPONENTBUILDERACTIONLOGCOMPILER - 13th November, 2022 + 5th February, 2023 Llewellyn van der Merwe joomla@vdm.io https://dev.vdm.io Copyright (C) 2015 Vast Development Method. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt - 1.0.3 + 1.1.0 PLG_EXTENSION_COMPONENTBUILDERACTIONLOGCOMPILER_XML_DESCRIPTION diff --git a/language/en-GB/en-GB.plg_extension_componentbuilderactionlogcompiler.ini b/language/en-GB/en-GB.plg_extension_componentbuilderactionlogcompiler.ini index 431942d..af8b0ce 100644 --- a/language/en-GB/en-GB.plg_extension_componentbuilderactionlogcompiler.ini +++ b/language/en-GB/en-GB.plg_extension_componentbuilderactionlogcompiler.ini @@ -1,6 +1,6 @@ PLG_EXTENSION_COMPONENTBUILDERACTIONLOGCOMPILER="Extension - Componentbuilder ActionLog Compiler" PLG_EXTENSION_COMPONENTBUILDERACTIONLOGCOMPILER_DESCRIPTION="This plugin is used to improve your action log integration with Joomla for your component during compilation. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field." -PLG_EXTENSION_COMPONENTBUILDERACTIONLOGCOMPILER_XML_DESCRIPTION="

Extension - Componentbuilder ActionLog Compiler (v.1.0.3)

This plugin is used to improve your action log integration with Joomla for your component during compilation. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.

Created by Llewellyn van der Merwe
Development started 27th August, 2019

" +PLG_EXTENSION_COMPONENTBUILDERACTIONLOGCOMPILER_XML_DESCRIPTION="

Extension - Componentbuilder ActionLog Compiler (v.1.1.0)

This plugin is used to improve your action log integration with Joomla for your component during compilation. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.

Created by Llewellyn van der Merwe
Development started 27th August, 2019

" PLG_EXTENSION_COMPONENTBUILDERACTIONLOGCOMPILER_COMPONENT_ACTIVATION="Component Activation" PLG_EXTENSION_COMPONENTBUILDERACTIONLOGCOMPILER_ACTIVATE_OPTION_LABEL="Activate Options" PLG_EXTENSION_COMPONENTBUILDERACTIONLOGCOMPILER_ACTIVATE_OPTION_DESCRIPTION="You can select the kind of activation control you would like to use. All will target all components, and Selected will let you select only those you want to be active." diff --git a/language/en-GB/en-GB.plg_extension_componentbuilderactionlogcompiler.sys.ini b/language/en-GB/en-GB.plg_extension_componentbuilderactionlogcompiler.sys.ini index 431942d..af8b0ce 100644 --- a/language/en-GB/en-GB.plg_extension_componentbuilderactionlogcompiler.sys.ini +++ b/language/en-GB/en-GB.plg_extension_componentbuilderactionlogcompiler.sys.ini @@ -1,6 +1,6 @@ PLG_EXTENSION_COMPONENTBUILDERACTIONLOGCOMPILER="Extension - Componentbuilder ActionLog Compiler" PLG_EXTENSION_COMPONENTBUILDERACTIONLOGCOMPILER_DESCRIPTION="This plugin is used to improve your action log integration with Joomla for your component during compilation. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field." -PLG_EXTENSION_COMPONENTBUILDERACTIONLOGCOMPILER_XML_DESCRIPTION="

Extension - Componentbuilder ActionLog Compiler (v.1.0.3)

This plugin is used to improve your action log integration with Joomla for your component during compilation. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.

Created by Llewellyn van der Merwe
Development started 27th August, 2019

" +PLG_EXTENSION_COMPONENTBUILDERACTIONLOGCOMPILER_XML_DESCRIPTION="

Extension - Componentbuilder ActionLog Compiler (v.1.1.0)

This plugin is used to improve your action log integration with Joomla for your component during compilation. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.

Created by Llewellyn van der Merwe
Development started 27th August, 2019

" PLG_EXTENSION_COMPONENTBUILDERACTIONLOGCOMPILER_COMPONENT_ACTIVATION="Component Activation" PLG_EXTENSION_COMPONENTBUILDERACTIONLOGCOMPILER_ACTIVATE_OPTION_LABEL="Activate Options" PLG_EXTENSION_COMPONENTBUILDERACTIONLOGCOMPILER_ACTIVATE_OPTION_DESCRIPTION="You can select the kind of activation control you would like to use. All will target all components, and Selected will let you select only those you want to be active."