diff --git a/README.md b/README.md
index ad18f9cb6..53a4587a1 100644
--- a/README.md
+++ b/README.md
@@ -146,12 +146,12 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
-+ *Last Build*: 18th June, 2019
++ *Last Build*: 22nd June, 2019
+ *Version*: 2.9.20
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
-+ *Line count*: **206959**
-+ *Field count*: **1141**
++ *Line count*: **206973**
++ *Field count*: **1142**
+ *File count*: **1346**
+ *Folder count*: **209**
diff --git a/admin/README.txt b/admin/README.txt
index ad18f9cb6..53a4587a1 100644
--- a/admin/README.txt
+++ b/admin/README.txt
@@ -146,12 +146,12 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
-+ *Last Build*: 18th June, 2019
++ *Last Build*: 22nd June, 2019
+ *Version*: 2.9.20
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
-+ *Line count*: **206959**
-+ *Field count*: **1141**
++ *Line count*: **206973**
++ *Field count*: **1142**
+ *File count*: **1346**
+ *Folder count*: **209**
diff --git a/admin/compiler/joomla_3/router.php b/admin/compiler/joomla_3/router.php
index c3084c95a..272e42940 100644
--- a/admin/compiler/joomla_3/router.php
+++ b/admin/compiler/joomla_3/router.php
@@ -143,6 +143,8 @@ class ###Component###Router extends JComponentRouterBase
{
$getTable = '#__categories';
$query->from($db->quoteName($getTable));
+ // we need this to target the components categories (TODO will keep an eye on this)
+ $query->where($db->quoteName('extension') . ' LIKE '. $db->quote((string)'com_' . $main . '%'));
}
else
{
diff --git a/admin/config.xml b/admin/config.xml
index 220ced4d6..b976865fa 100644
--- a/admin/config.xml
+++ b/admin/config.xml
@@ -57,6 +57,16 @@
folder="editors"
filter="cmd"
/>
+
+
diff --git a/admin/helpers/compiler.php b/admin/helpers/compiler.php
index 08e3a672a..96a740dd2 100644
--- a/admin/helpers/compiler.php
+++ b/admin/helpers/compiler.php
@@ -253,6 +253,8 @@ class Compiler extends Infusion
*/
protected function setFileContent(&$name, &$path, &$bom, $view = null)
{
+ // Trigger Event: jcb_ce_onBeforeSetFileContent
+ $this->triggerEvent('jcb_ce_onBeforeSetFileContent', array(&$name, &$path, &$bom, &$view));
// set the file name
$this->fileContentStatic[$this->hhh . 'FILENAME' . $this->hhh] = $name;
// check if the file should get PHP opening
@@ -263,6 +265,8 @@ class Compiler extends Infusion
}
// get content of the file
$string = ComponentbuilderHelper::getFileContents($path);
+ // Trigger Event: jcb_ce_onGetFileContents
+ $this->triggerEvent('jcb_ce_onGetFileContents', array(&$string, &$name, &$path, &$bom, &$view));
// see if we should add a BOM
if (strpos($string, $this->hhh . 'BOM' . $this->hhh) !== false)
{
@@ -281,6 +285,8 @@ class Compiler extends Infusion
{
$answer = $this->setDynamicValues($answer);
}
+ // Trigger Event: jcb_ce_onBeforeSetFileContent
+ $this->triggerEvent('jcb_ce_onBeforeWriteFileContent', array(&$answer, &$name, &$path, &$bom, &$view));
// add answer back to file
$this->writeFile($path, $answer);
// count the file lines
diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php
index 4283c3073..d257f2aac 100644
--- a/admin/helpers/compiler/a_Get.php
+++ b/admin/helpers/compiler/a_Get.php
@@ -736,6 +736,13 @@ class Get
*/
public $mysqlTableSetting = array();
+ /**
+ * event plugin trigger switch
+ *
+ * @var boolean
+ */
+ protected $active_plugins = false;
+
/**
* Constructor
*/
@@ -748,6 +755,21 @@ class Get
$this->app = JFactory::getApplication();
// Set the params
$this->params = JComponentHelper::getParams('com_componentbuilder');
+ // get active plugins
+ if (($plugins = $this->params->get('compiler_plugin', false)) !== false)
+ {
+ foreach ($plugins as $plugin)
+ {
+ // get posible plugins
+ if (\JPluginHelper::isEnabled('extension', $plugin))
+ {
+ // Import the appropriate plugin group.
+ \JPluginHelper::importPlugin('extension', $plugin);
+ // activate events
+ $this->active_plugins = true;
+ }
+ }
+ }
// set the minfy switch of the JavaScript
$this->minify = (isset($config['minify']) && $config['minify'] != 2) ? $config['minify'] : $this->params->get('minify', 0);
// set the global language
@@ -866,6 +888,40 @@ class Get
return '';
}
+ /**
+ * Trigger events
+ *
+ * @param string $event The event to trigger
+ * @param mix $data The values to pass to the event/plugin
+ *
+ * @return string
+ *
+ */
+ public function triggerEvent($event, $data)
+ {
+ // only exicute if plugins were loaded (active)
+ if ($this->active_plugins)
+ {
+ // Get the dispatcher.
+ $dispatcher = \JEventDispatcher::getInstance();
+
+ // Trigger the form preparation event.
+ $results = $dispatcher->trigger($event, $data);
+
+ // Check for errors encountered while trigger the event
+ if (count($results) && in_array(false, $results, true))
+ {
+ // Get the last error.
+ $error = $dispatcher->getError();
+
+ if (!($error instanceof \Exception))
+ {
+ throw new \Exception($error);
+ }
+ }
+ }
+ }
+
/**
* get all System Placeholders
*
@@ -963,12 +1019,18 @@ class Get
$query->join('LEFT', $this->db->quoteName('#__componentbuilder_component_placeholders', 'k') . ' ON (' . $this->db->quoteName('a.id') . ' = ' . $this->db->quoteName('k.joomla_component') . ')');
$query->where($this->db->quoteName('a.id') . ' = ' . (int) $this->componentID);
+ // Trigger Event: jcb_ce_onBeforeQueryComponentData
+ $this->triggerEvent('jcb_ce_onBeforeQueryComponentData', array(&$this->componentID, &$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
+ $this->triggerEvent('jcb_ce_onBeforeModelComponentData', array(&$component));
+
// set upater
$updater = array(
'unique' => array(
@@ -1510,6 +1572,9 @@ class Get
$component->toignore = array('.git');
}
+ // Trigger Event: jcb_ce_onAfterModelComponentData
+ $this->triggerEvent('jcb_ce_onAfterModelComponentData', array(&$component));
+
// return the found component data
return $component;
}
@@ -1556,6 +1621,9 @@ class Get
$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);
+ // Trigger Event: jcb_ce_onBeforeQueryViewData
+ $this->triggerEvent('jcb_ce_onBeforeQueryViewData', array(&$id, &$query, &$this->db));
+
// Reset the query using our newly populated query object.
$this->db->setQuery($query);
@@ -1611,6 +1679,10 @@ class Get
$this->placeholders[$this->bbb . 'Views' . $this->ddd] = $this->placeholders[$this->hhh . 'Views' . $this->hhh];
$this->placeholders[$this->bbb . 'VIEW' . $this->ddd] = $this->placeholders[$this->hhh . 'VIEW' . $this->hhh];
$this->placeholders[$this->bbb . 'VIEWS' . $this->ddd] = $this->placeholders[$this->hhh . 'VIEWS' . $this->hhh];
+
+ // Trigger Event: jcb_ce_onBeforeModelViewData
+ $this->triggerEvent('jcb_ce_onBeforeModelViewData', array(&$view, &$this->placeholders));
+
// add the tables
$view->addtables = (isset($view->addtables) && ComponentbuilderHelper::checkJson($view->addtables)) ? json_decode($view->addtables, true) : null;
if (ComponentbuilderHelper::checkArray($view->addtables))
@@ -2205,6 +2277,10 @@ class Get
// remove the table values since we moved to another object
unset($view->{'mysql_table_' . $_mysqlTableKey});
}
+
+ // Trigger Event: jcb_ce_onAfterModelViewData
+ $this->triggerEvent('jcb_ce_onAfterModelViewData', array(&$view, &$this->placeholders));
+
// clear placeholders
unset($this->placeholders[$this->hhh . 'view' . $this->hhh]);
unset($this->placeholders[$this->hhh . 'views' . $this->hhh]);
@@ -2244,11 +2320,18 @@ class Get
$query->from('#__componentbuilder_' . $table . ' AS a');
$query->where($this->db->quoteName('a.id') . ' = ' . (int) $id);
+ // Trigger Event: jcb_ce_onBeforeQueryCustomViewData
+ $this->triggerEvent('jcb_ce_onBeforeQueryCustomViewData', array(&$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();
+
+ // Trigger Event: jcb_ce_onBeforeModelCustomViewData
+ $this->triggerEvent('jcb_ce_onBeforeModelCustomViewData', array(&$view, &$id, &$table));
+
if ($table === 'site_view')
{
$this->lang = 'site';
@@ -2485,6 +2568,10 @@ class Get
}
unset($view->custom_button);
}
+
+ // Trigger Event: jcb_ce_onAfterModelCustomViewData
+ $this->triggerEvent('jcb_ce_onAfterModelCustomViewData', array(&$view));
+
// return the found view data
return $view;
}
@@ -2513,6 +2600,9 @@ class Get
$query->join('LEFT', $this->db->quoteName('#__componentbuilder_fieldtype', 'c') . ' ON (' . $this->db->quoteName('a.fieldtype') . ' = ' . $this->db->quoteName('c.id') . ')');
$query->where($this->db->quoteName('a.id') . ' = ' . $this->db->quote($id));
+ // Trigger Event: jcb_ce_onBeforeQueryFieldData
+ $this->triggerEvent('jcb_ce_onBeforeQueryFieldData', array(&$id, &$query, &$this->db));
+
// Reset the query using our newly populated query object.
$this->db->setQuery($query);
$this->db->execute();
@@ -2521,6 +2611,9 @@ class Get
// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$field = $this->db->loadObject();
+ // Trigger Event: jcb_ce_onBeforeModelFieldData
+ $this->triggerEvent('jcb_ce_onBeforeModelFieldData', array(&$field));
+
// adding a fix for the changed name of type to fieldtype
$field->type = $field->fieldtype;
@@ -2596,6 +2689,9 @@ class Get
// get the last used version
$field->history = $this->getHistoryWatch('field', $id);
+ // Trigger Event: jcb_ce_onAfterModelFieldData
+ $this->triggerEvent('jcb_ce_onAfterModelFieldData', array(&$field));
+
$this->_fieldData[$id] = $field;
}
else
diff --git a/admin/helpers/compiler/b_Structure.php b/admin/helpers/compiler/b_Structure.php
index e883bc40f..71752637d 100644
--- a/admin/helpers/compiler/b_Structure.php
+++ b/admin/helpers/compiler/b_Structure.php
@@ -367,6 +367,8 @@ class Structure extends Get
$this->setLibaries();
// set the Joomla Version Data
$this->joomlaVersionData = $this->setJoomlaVersionData();
+ // Trigger Event: jcb_ce_onAfterSetJoomlaVersionData
+ $this->triggerEvent('jcb_ce_onAfterSetJoomlaVersionData', array(&$this->joomlaVersionData));
// set the dashboard
$this->setDynamicDashboard();
// set the new folders
@@ -416,6 +418,8 @@ class Structure extends Get
{
if (ComponentbuilderHelper::checkArray($this->libraries))
{
+ // Trigger Event: jcb_ce_onBeforeSetLibaries
+ $this->triggerEvent('jcb_ce_onBeforeSetLibaries', array(&$this->libraries));
// creat the main component folder
if (!JFolder::exists($this->componentPath))
{
diff --git a/admin/helpers/compiler/c_Fields.php b/admin/helpers/compiler/c_Fields.php
index 179c8dedb..ae9178e61 100644
--- a/admin/helpers/compiler/c_Fields.php
+++ b/admin/helpers/compiler/c_Fields.php
@@ -456,11 +456,15 @@ class Fields extends Structure
$dynamicFields = '';
// set the custom table key
$dbkey = 'g';
+ // Trigger Event: jcb_ce_onBeforeBuildFields
+ $this->triggerEvent('jcb_ce_onBeforeBuildFields', array(&$dynamicFields, &$readOnly, &$dbkey, &$view, &$component, &$view_name_single, &$view_name_list, &$this->placeholders, &$langView, &$langViews));
// TODO we should add the global and local view switch if field for front end
foreach ($view['settings']->fields as $field)
{
$dynamicFields .= $this->setDynamicField($field, $view, $view['settings']->type, $langView, $view_name_single, $view_name_list, $this->placeholders, $dbkey, true);
}
+ // Trigger Event: jcb_ce_onAfterBuildFields
+ $this->triggerEvent('jcb_ce_onAfterBuildFields', array(&$dynamicFields, &$readOnly, &$dbkey, &$view, &$component, &$view_name_single, &$view_name_list, &$this->placeholders, &$langView, &$langViews));
// set the default fields
$fieldSet = array();
$fieldSet[] = '