We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39194
    • 149 Posts
    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?
      • 22303 MODX Staff
      • 10,725 Posts
      Can you be more specific? What wrong events are being invoked? This looks valid to me.
        • 39194
        • 149 Posts
        OnBeforeManagerPageInit, OnManagerPageBeforeRender, OnManagerPageAfterRender. These events are expected to be triggered on Manager page rendering, not TV input properties rendering. And most unexpected is getting these events on TV input list (just a json array) retreiving. What is the purpose of using of the modManagerController here?
          • 22303 MODX Staff
          • 10,725 Posts
          Thanks for the clarification; understand now. But I'm not sure of the answer. Can you or have you filed this in the tracker?