Library manager implementation #195

Merged
Llewellyn merged 24 commits from staging into master 2017-12-12 13:31:16 +00:00
1 changed files with 21 additions and 7 deletions
Showing only changes of commit fa83ea7bc9 - Show all commits

View File

@ -1660,11 +1660,12 @@ class Interpretation extends Fields
{
// build decoder string
if(!$runplugins) {
$runplugins = PHP_EOL."\t".$tab."\tJPluginHelper::importPlugin('content');\n";
$runplugins .= PHP_EOL."\t".$tab."\t".'$dispatcher = JEventDispatcher::getInstance();';
$runplugins = PHP_EOL.$tab."\t//".$this->setLine(__LINE__)." Load the JEvent Dispatcher";
$runplugins .= PHP_EOL.$tab."\tJPluginHelper::importPlugin('content');";
$runplugins .= PHP_EOL.$tab."\t".'$this->_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($this->_context,&'.$string.'->'.$field.',$item->params));';
$fieldUikit .= PHP_EOL."\t".$tab."\t".'$this->_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)
{
@ -1673,7 +1674,10 @@ class Interpretation extends Fields
}
}
}
return ($runplugins?:'').$fieldUikit;
// load dispatcher
$this->JEventDispatcher = array('###DISPATCHER###' => ($runplugins?:''));
// return UIKIT fix
return $fieldUikit;
}
public function setCustomViewCustomJoin(&$gets,$string,$code,&$asBucket,$tab = '')
@ -2128,6 +2132,8 @@ class Interpretation extends Fields
$getItem .= PHP_EOL."\t".$tab."\t\treturn false;";
}
$getItem .= PHP_EOL."\t".$tab."\t}";
// dispatcher placholder
$getItem .= "###DISPATCHER###";
if (ComponentbuilderHelper::checkArray($get->main_get))
{
$asBucket = array();
@ -2208,7 +2214,8 @@ class Interpretation extends Fields
$getItem .= PHP_EOL.PHP_EOL."\t".$tab."\t//".$this->setLine(__LINE__)." set data object to item.";
$getItem .= PHP_EOL."\t".$tab."\t\$this->_item[\$pk] = \$data;";
}
return $getItem;
// check if the dispather should be added
return str_replace(array_keys($this->JEventDispatcher), array_values($this->JEventDispatcher), $getItem);
}
return PHP_EOL."\t".$tab."\t//".$this->setLine(__LINE__)."add your custom code here.";
}
@ -2531,6 +2538,8 @@ class Interpretation extends Fields
$methods .= PHP_EOL.PHP_EOL."\t\t//".$this->setLine(__LINE__)." check if there was data returned";
$methods .= PHP_EOL."\t\tif (\$db->getNumRows())";
$methods .= PHP_EOL."\t\t{";
// set dispatcher placeholder
$methods .= "###DISPATCHER###";
// set decoding of needed fields
if (isset($this->siteFieldData['decode'][$default['code']][$get['key']][$default['as']]))
{
@ -2634,13 +2643,15 @@ class Interpretation extends Fields
$script .= PHP_EOL."\t\t//".$this->setLine(__LINE__)." Get the encryption object.";
$script .= PHP_EOL."\t\t\$advanced = new FOFEncryptAes(\$advancedkey, 256);".PHP_EOL;
}
$methods = str_replace('###CRYPT###',$script,$methods);
$methods = str_replace('###CRYPT###', $script, $methods);
}
}
// insure the crypt placeholder is removed
$methods = str_replace('###CRYPT###','',$methods);
}
}
return $methods.PHP_EOL;
// check if the dispatcher must be set
return str_replace(array_keys($this->JEventDispatcher), array_values($this->JEventDispatcher), $methods).PHP_EOL;
}
public function setCustomViewMethodDefaults($get,$code)
@ -2739,6 +2750,7 @@ class Interpretation extends Fields
$getItem .= PHP_EOL.PHP_EOL."\t\t//".$this->setLine(__LINE__)." Convert the parameter fields into objects.";
$getItem .= PHP_EOL."\t\tif (".$Component."Helper::checkArray(\$items))";
$getItem .= PHP_EOL."\t\t{";
$getItem .= "###DISPATCHER###";
$getItem .= PHP_EOL."\t\t\tforeach (\$items as \$nr => &\$item)";
$getItem .= PHP_EOL."\t\t\t{";
$getItem .= PHP_EOL."\t\t\t\t//".$this->setLine(__LINE__)." Always create a slug for sef URL's";
@ -2778,6 +2790,8 @@ class Interpretation extends Fields
$asBucket[] = $main_get['as'];
}
}
// check if we should load the dispatcher
$getItem = str_replace(array_keys($this->JEventDispatcher), array_values($this->JEventDispatcher), $getItem);
// setup Globals
$getItem .= $this->setCustomViewGlobals($get->global,'$item',$asBucket,"\t\t");
// setup the custom gets that returns multipal values