/** * Call method of the module passed as first parameter, * which name is passed as third parameter. * You can pass additional arguments. * Attention: do not pass the result of this function by one module to another module. * * @param module $m child module * @param mixed $args arguments * @param string $function_name function to call (get output from), if user has enought privileges. * @return mixed if access denied returns false, else string */ public final function get_html_of_module(&$m, $args = null, $function_name = null) { $this_path = $this->get_path(); if (!$m) { trigger_error('Arument 0 for display_module is null.', E_USER_ERROR); } if ($this_path != $m->get_parent_path()) { return false; } if (!isset($function_name)) { $function_name = 'body'; } if (!method_exists($m, $function_name)) { trigger_error('Invalid method name (' . get_class($m) . '::' . $function_name . ') given as argument 2 for display_module.', E_USER_ERROR); } if ($m->displayed()) { trigger_error('You can\'t display the same module twice, path:' . $m->get_path() . '.', E_USER_ERROR); } if (!$m->check_access($function_name)) { return false; } //we cannot trigger error here, couse logout doesn't work //trigger_error('Method given as argument 2 for display_module inaccessible.<br>$'.$this->get_type().'->display_module(\''.$m->get_type().'\','.$args.',\''.$function_name.'\');',E_USER_ERROR); $s =& $m->get_module_variable('__shared_unique_vars__', array()); foreach ($s as $k => $v) { $_REQUEST[$m->create_unique_key($k)] =& $_REQUEST[$v]; } if (MODULE_TIMES) { $time = microtime(true); } //define key in array so it is before its children $path = $m->get_path(); if ($this->is_inline_display()) { $m->set_inline_display(); } if (!$m->is_inline_display()) { Epesi::$content[$path]['span'] = $this_path . '|' . $this->children_count_display . 'content'; $this->children_count_display++; } Epesi::$content[$path]['module'] =& $m; if (!REDUCING_TRANSFER || (!$m->is_fast_process() || isset($_REQUEST['__action_module__']) && strpos($_REQUEST['__action_module__'], $path) === 0 || !isset($_SESSION['client']['__module_content__'][$path]))) { if ($args === null) { $args = array(); } elseif (!is_array($args)) { $args = array($args); } ob_start(); $callbacks = array_reverse($m->get_module_variable('__callbacks__', array()), true); $skip_display = false; foreach ($callbacks as $name => $c) { $ret = $m->get_module_variable_or_unique_href_variable($name); if ($ret == '1') { $func = $c['func']; if (is_array($func)) { if ($func[0] === null) { $func[0] =& $m; } if (!method_exists($func[0], $func[1])) { trigger_error('Invalid method passed as callback: ' . (is_string($func[0]) ? $func[0] : $func[0]->get_type()) . '::' . $func[1], E_USER_ERROR); } } $r = call_user_func_array($func, $c['args']); if ($r) { $skip_display = true; break; } else { $m->unset_module_variable($name); } } } if (!$skip_display) { $m->display_func = true; call_user_func_array(array($m, $function_name), $args); $m->display_func = false; } if (STRIP_OUTPUT) { require_once 'libs/minify/Minify/HTML.php'; Epesi::$content[$path]['value'] = Minify_HTML::minify(ob_get_contents()); } else { Epesi::$content[$path]['value'] = ob_get_contents(); } ob_end_clean(); Epesi::$content[$path]['js'] = $m->get_jses(); } else { Epesi::$content[$path]['value'] = $_SESSION['client']['__module_content__'][$path]['value']; Epesi::$content[$path]['js'] = $_SESSION['client']['__module_content__'][$path]['js']; if (DEBUG) { Epesi::debug('Fast process of ' . $path); } } if (MODULE_TIMES) { Epesi::$content[$path]['time'] = microtime(true) - $time; } $m->mark_displayed(); if ($m->is_inline_display()) { $ret = Epesi::$content[$path]['value']; Epesi::$content[$path]['value'] = ''; return $ret; } return '<span id="' . Epesi::$content[$path]['span'] . '"></span>'; }