From b10b01949404aab8f0ace9334ae4e617cfe43031 Mon Sep 17 00:00:00 2001 From: Michael Richey Date: Sun, 3 Dec 2017 19:24:53 -0600 Subject: [PATCH 1/4] Implement onContentPrepare --- admin/helpers/compiler/e_Interpretation.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index 9374bc27e..d954cdeb3 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -1658,8 +1658,12 @@ class Interpretation extends Fields if (strpos($get['selection']['select'], $field) !== false) { // build decoder string - $fieldUikit .= PHP_EOL."\t".$tab."\t//".$this->setLine(__LINE__)." Make sure the content prepare plugins fire on ".$field." (TODO)"; - $fieldUikit .= PHP_EOL."\t".$tab."\t".$string."->".$field." = JHtml::_('content.prepare',".$string."->".$field.");"; + if(!$runplugins) { + $runplugins = PHP_EOL."\t".$tab."\tJPluginHelper::importPlugin('content');\n"; + $runplugins .= PHP_EOL."\t".$tab."\t".'$dispatcher = JEventDispatcher::getInstance();'; + } + $fieldUikit .= PHP_EOL."\t".$tab."\t//".$this->setLine(__LINE__)." Make sure the content prepare plugins fire on ".$field; + $fieldUikit .= PHP_EOL."\t".$tab."\t".'$dispatcher->trigger("onContentPrepare",array("com_'.$this->fileContentStatic['###component###'].'.'.$this->fileContentStatic['###view###'].'",&'.$string.'->'.$field.',$item->params));'; // only load for uikit version 2 (TODO) we may need to add another check here if (2 == $this->uikit || 1 == $this->uikit) { @@ -1668,7 +1672,7 @@ class Interpretation extends Fields } } } - return $fieldUikit; + return ($runplugins?:'').$fieldUikit; } public function setCustomViewCustomJoin(&$gets,$string,$code,&$asBucket,$tab = '') -- 2.40.1 From 102ed837c2bb576f8ec6a2cd32b4ac65f65870f7 Mon Sep 17 00:00:00 2001 From: Michael Richey Date: Sun, 3 Dec 2017 19:43:45 -0600 Subject: [PATCH 2/4] automatic context based on available vars --- admin/helpers/compiler/e_Interpretation.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index d954cdeb3..ce5b4e68b 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -1653,6 +1653,13 @@ class Interpretation extends Fields public function setCustomViewFieldUikitChecker(&$get, $checker, $string, $code, $tab = '') { $fieldUikit = ''; + $runplugins = false; + $context = array(); + foreach(array('###component###','###view###') as $key) { + if(array_key_exists($key,$this->fileContentStatic)) { + $context[] = $this->fileContentStatic[$key]; + } + } foreach ($checker as $field => $array) { if (strpos($get['selection']['select'], $field) !== false) @@ -1663,7 +1670,7 @@ class Interpretation extends Fields $runplugins .= PHP_EOL."\t".$tab."\t".'$dispatcher = JEventDispatcher::getInstance();'; } $fieldUikit .= PHP_EOL."\t".$tab."\t//".$this->setLine(__LINE__)." Make sure the content prepare plugins fire on ".$field; - $fieldUikit .= PHP_EOL."\t".$tab."\t".'$dispatcher->trigger("onContentPrepare",array("com_'.$this->fileContentStatic['###component###'].'.'.$this->fileContentStatic['###view###'].'",&'.$string.'->'.$field.',$item->params));'; + $fieldUikit .= PHP_EOL."\t".$tab."\t".'$dispatcher->trigger("onContentPrepare",array("com_'.implode('.',$context).'",&'.$string.'->'.$field.',$item->params));'; // only load for uikit version 2 (TODO) we may need to add another check here if (2 == $this->uikit || 1 == $this->uikit) { -- 2.40.1 From 9a6ad66e32812fcba53e94afa1d9ffd8325d1921 Mon Sep 17 00:00:00 2001 From: Michael Richey Date: Sun, 3 Dec 2017 19:53:05 -0600 Subject: [PATCH 3/4] Fixed context --- admin/helpers/compiler/e_Interpretation.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index ce5b4e68b..36a075a7d 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -1654,12 +1654,6 @@ class Interpretation extends Fields { $fieldUikit = ''; $runplugins = false; - $context = array(); - foreach(array('###component###','###view###') as $key) { - if(array_key_exists($key,$this->fileContentStatic)) { - $context[] = $this->fileContentStatic[$key]; - } - } foreach ($checker as $field => $array) { if (strpos($get['selection']['select'], $field) !== false) @@ -1670,7 +1664,7 @@ class Interpretation extends Fields $runplugins .= PHP_EOL."\t".$tab."\t".'$dispatcher = JEventDispatcher::getInstance();'; } $fieldUikit .= PHP_EOL."\t".$tab."\t//".$this->setLine(__LINE__)." Make sure the content prepare plugins fire on ".$field; - $fieldUikit .= PHP_EOL."\t".$tab."\t".'$dispatcher->trigger("onContentPrepare",array("com_'.implode('.',$context).'",&'.$string.'->'.$field.',$item->params));'; + $fieldUikit .= PHP_EOL."\t".$tab."\t".'$dispatcher->trigger("onContentPrepare",array($this->_context,&'.$string.'->'.$field.',$item->params));'; // only load for uikit version 2 (TODO) we may need to add another check here if (2 == $this->uikit || 1 == $this->uikit) { -- 2.40.1 From 7a16692501f007b5a3127cdcde769ff6e6538e93 Mon Sep 17 00:00:00 2001 From: Michael Richey Date: Mon, 4 Dec 2017 09:29:31 -0600 Subject: [PATCH 4/4] removed newline --- admin/helpers/compiler/e_Interpretation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index 36a075a7d..e25f159d6 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -1660,7 +1660,7 @@ class Interpretation extends Fields { // build decoder string if(!$runplugins) { - $runplugins = PHP_EOL."\t".$tab."\tJPluginHelper::importPlugin('content');\n"; + $runplugins = PHP_EOL."\t".$tab."\tJPluginHelper::importPlugin('content');"; $runplugins .= PHP_EOL."\t".$tab."\t".'$dispatcher = JEventDispatcher::getInstance();'; } $fieldUikit .= PHP_EOL."\t".$tab."\t//".$this->setLine(__LINE__)." Make sure the content prepare plugins fire on ".$field; -- 2.40.1