. * */ /** * Vvveb. * * Copyright (C) 2022 Ziadin Givan * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ class VtplDebug { private $enabled = false; private $debugLog = []; private $debugHtml; function enabled() { return $this->enabled; } function enable($switch) { $this->enabled = $switch; } function log($type,$message) { if ($this->enabled) { $this->debugLog[][$type]= $message; } } function addDebugHtmlLine($command, $parameters, $break = '
') { $this->debugHtml .= " $command $parameters$break"; } function debugLogToHtml() { foreach ($this->debugLog as $line) { $type = key($line); $message = $line[$type]; switch ($type) { case 'LOAD': $this->addDebugHtmlLine('LOAD',$message); break; case 'SAVE': $this->addDebugHtmlLine('SAVE',$message); break; case 'SELECTOR': $this->addDebugHtmlLine('SELECTOR', /*$this->cssToXpath($message) . */" $message", ''); break; case 'SELECTOR_STRING': $this->addDebugHtmlLine('INJECT STRING',$message); break; case 'SELECTOR_PHP': $this->addDebugHtmlLine('INJECT PHP',htmlentities($message)); break; case 'SELECTOR_VARIABLE': $this->addDebugHtmlLine('INJECT VARIABLE',$message); break; case 'SELECTOR_FROM': $this->addDebugHtmlLine('EXTERNAL HTML',$message); break; case 'CSS_XPATH_TRANSFORM': if (VTPL_DEBUG_SHOW_XPATH) { $this->addDebugHtmlLine('RESULTED XPATH', " $message"); } break; case 'CSS_SELECTOR': $this->addDebugHtmlLine('INVALID CSS SELECTOR',htmlentities($message)); break; default: $this->addDebugHtmlLine('',$message); break; } } } function printLog() { $this->debugLogToHtml(); echo << function vtplSelectorOver(selector) { jQuery(selector).addClass('vtpl_selected'); return false; } function vtplSelectorOut(selector) { jQuery(selector).removeClass('vtpl_selected'); return false; } //this needs firebug or equivalent function vtplSelectorClick(selector) { console.log(jQuery(selector)); return false; } function vtplHide(selector) { if (jQuery(".vtpl_console_log_content").css('display') == 'none') { jQuery(".vtpl_console_log").css({height:"350px"}); } else { jQuery(".vtpl_console_log").css({height:"30px"}); } jQuery(".vtpl_console_log_content").toggle("slow"); return false; } function vtplClose() { jQuery(".vtpl_console_log").remove(); return false; }
Toggle Close
$this->debugHtml;
HTML; } }