*/ require_once('lib/debug/debugger-ext.php'); /** * \brief Debugger command to list smatry vars */ class DbgSList extends DebuggerCommand { /// \b Must have function to announce command name in debugger console public function name() { return 'slist'; } /// \b Must have function to provide help to debugger console public function description() { return 'Display list of Smarty variables. Better to specify partial name or very long list of vars will returns.'; } /// \b Must have function to provide help to debugger console public function syntax() { return 'slist [partial-name]'; } /// \b Must have function to show example of usage of given command public function example() { return 'slist' . "\n" . 'slist auth' . "\n" . 'slist ^wiki' . "\n" . 'slist .+admin.*'; } /// Execute command with given set of arguments. public function execute($params) { $this->set_result_type(HTML_RESULT); // Is regex to match against var name given? $p = explode(' ', trim($params)); $mask = count($p) > 0 ? str_replace('$', '', trim($p[0])) : ''; // Get list of vars $smarty = TikiLib::lib('smarty'); $tpl_vars = $smarty->getTemplateVars(); // convert to vector of names and sort $vars = []; $len = strlen($mask); foreach ($tpl_vars as $key => $val) { if (! $len || $len && preg_match('/' . $mask . '/', $key)) { $vars[] = $key; } } sort($vars); // $result = '
| $' . $var . ' | '; $idx = 1; } else { $row .= '$' . $var . ' | '; $idx++; } } $result .= '