Here is the code from core\model\modx\processors\element\tv\renders\getinputs.class.php:
/**
* Simulate the TV manager controller to get TV input renders
*
* @package modx
*/
class TvInputManagerController extends modManagerController {
public $loadFooter = false;
public $loadHeader = false;
public function checkPermissions() {
return $this->modx->hasPermission('view_tv');
}
public function loadCustomCssJs() {}
public function process(array $scriptProperties = array()) {}
public function getPageTitle() {return '';}
public function getTemplateFile() {
return 'empty.tpl';
}
public function getLanguageTopics() {return array();}
}
class modElementTvRendersGetInputsProcessor extends modProcessor {
...
public function process() {
$context = $this->getProperty('context',$this->modx->context->get('key'));
/* simulate controller with the faux class above */
$c = new TvInputManagerController($this->modx);
$this->modx->controller = call_user_func_array(array($c,'getInstance'),array($this->modx,'TvInputManagerController'));
$this->modx->controller->render();
$renderDirectories = array(
dirname(__FILE__).'/'.$context.'/input/',
);
/* allow for custom directories */
$pluginResult = $this->modx->invokeEvent('OnTVInputRenderList',array(
'context' => $context,
));
if (!is_array($pluginResult) && !empty($pluginResult)) { $pluginResult = array($pluginResult); }
if (!empty($pluginResult)) {
$renderDirectories = array_merge($renderDirectories,$pluginResult);
}
/* search directories */
$types = array();
foreach ($renderDirectories as $renderDirectory) {
if (empty($renderDirectory) || !is_dir($renderDirectory)) continue;
try {
$dirIterator = new DirectoryIterator($renderDirectory);
foreach ($dirIterator as $file) {
if (!$file->isReadable() || !$file->isFile()) continue;
$type = str_replace(array('.php','.class','.class.php'),'',$file->getFilename());
$types[$type] = array(
'name' => $this->modx->lexicon($type),
'value' => $type,
);
}
} catch (UnexpectedValueException $e) {}
}
/* sort types */
asort($types);
$otypes = array();
foreach ($types as $type) {
$otypes[] = $type;
}
return $this->outputArray($otypes);
}
}
I do not understand why is there modManagerController!
Take a look at the modManagerController render() method:
public function render() {
...
$this->modx->invokeEvent('OnBeforeManagerPageInit',array(
'action' => $this->config,
));
...
$this->modx->invokeEvent('OnManagerPageBeforeRender',array('controller' => &$this));
...
$this->firePreRenderEvents();
...
}
$this->firePostRenderEvents();
$this->modx->invokeEvent('OnManagerPageAfterRender',array('controller' => &$this));
return $this->content;
}
Same problem with getinputproperties processor.
So, this invokes a number of wrong events. This is cause of bugs in my extra ( AjaxManager )
Have any thoughts? And how can we fix it?