Re: Smarty + DataObject and DataObjectDebugger's console...

From: Date: Mon, 11 Oct 2004 18:27:43 +0000
Subject: Re: Smarty + DataObject and DataObjectDebugger's console...
References: 1 2  Groups: php.pear.general php.smarty.general 
Request: Send a blank email to pear-general+get-14849@lists.php.net to get a copy of this message
On Mon, 11 Oct 2004 14:26:50 +0400, Denis Gerasimov <denis.gerasimov@vekos.ru> wrote: > > Hello, > > Let me explain a couple of things... > > First, the screenshot > (http://www.vekos.ru/images/DataObjectDebugger_Consonle.png) is not a 'drawn > picture'; that is REALLY working debug console... > > Yes, Justin, we are smart enough ;-) and know about callback function - that > is the way how we do collect debug info. Here is a snip from our > database.cfg.ini file: > I didn't mean to talk down to you, it just seemed that this was what you were asking. You didn't ask any specific questions and so I assumed you needed help from the beginning. > ... > ;debug = 0 > debug = DATAOBJECTDEBUGGER_debug > ; default debugging level > ... > > Then, we have the following debugger class (still beta since our troubles > aren't solved yet): > > <?php > > require_once "DB/DataObject.php"; > > /** > * DataObject Debugger class. > * > * Copyright (c) VEKOS, Ltd., 2004 > * > * @author Denis Gerasimov <denis.gerasimov@vekos.ru> > * @author Roman Bondarenko <roman.bondarenko@vekos.ru> > * @package DataObjectDebugger > * @access public > * @version 1.0 > */ > > $_DATAOBJECTDEBUGGER_DEBUG_INFO = array(); > > class DataObjectDebugger > { > > // FIX > public static function debug($strClass, $strMessage, $strLogType = 0, > $intLevel = 1) > { > global $_DATAOBJECTDEBUGGER_DEBUG_INFO; > > $arrLineEnd = array("\r", "\n", "\r\n", > "\n\r"); > > // FIX > if ($intLevel > 1) return; > > $_DATAOBJECTDEBUGGER_DEBUG_INFO[] = array( > 'class' => str_replace("\r\n", ' ', > nl2br(htmlspecialchars($strClass))), > 'message' => str_replace($arrLineEnd, ' ', > htmlspecialchars($strMessage)), > 'type' => str_replace("\r\n", ' ', > nl2br(htmlspecialchars($strLogType)))); > } > > public static function dump() > { > global $_DATAOBJECTDEBUGGER_DEBUG_INFO; > > $strDebug = ''; > > if (!ini_get('html_errors')) { > foreach ($_DATAOBJECTDEBUGGER_DEBUG_INFO as $arrValue) { > $strDebug .= " {$arrValue['class']} : > {$arrValue['type']} : > {$arrValue['message']}<br>"; > } > } else { > foreach ($_DATAOBJECTDEBUGGER_DEBUG_INFO as $arrValue) { > $strDebug .= "<code><B>{$arrValue['class']} : > {$arrValue['type']} : > </B>{$arrValue['message']}</code><br>"; > } > } > > return $strDebug; > } > > } > > // BTW why does not DO support calling static class methods? > function DATAOBJECTDEBUGGER_debug($strClass, $strMessage, $strLogType = 0, > $intLevel = 1) > { > DataObjectDebugger::debug($strClass, $strMessage, $strLogType, > $intLevel); > } > > ?> > > So know we have all debug info gathered into the global array > $_DATAOBJECTDEBUGGER_DEBUG_INFO. > > Now, the second issue: > > We tried to use this Smarty plug-in for opening debug console popup window: > > <?php > > /* > * Smarty plugin > */ > > function smarty_prefilter_debug($strSource, $objSmarty) > { > global $_DATAOBJECTDEBUGGER_DEBUG_INFO; > $arrFileContent = File(DIR_TPL . 'DataObjectDebug.tpl.html'); > $strFileContent = join('', $arrFileContent); - What are these two lines for? You don't seem to be using these variables > > $objSmarty->assign('arrDebug', $_DATAOBJECTDEBUGGER_DEBUG_INFO); > > return $strSource; > } - $strSource is passed in and returned without being used anywhere in this function - $objSmarty is passed in by value. If you're using PHP4, the assign call won't do anything. > > ?> > > (As for DataObjectDebug.tpl.html template, you can easily imagine how it > looks like.) > > It seems to be OK but it really doesn't... the thing is that debug info will > be inserted after EACH template (i.e. also after included templates), not > after the whole page HTML. > > So, here is the question: how should we deal with that? > > Please, DO NOT suggest modifying Smarty's debug.tpl - that seems to be the > wrong way... also because we want Smarty debug info and DO debug info to be > shown independently (i.e. only Smarty console or only DO console or both). When are you calling that function above and with what arguments? What exactly is happening? Do you get multiple DO debug windows? Are the Smarty and DO windows combined? Are you seeing the DO messages multiple times? > > Thank you very much. > > Best regards, Denis Gerasimov > Outsourcing Services Manager, > VEKOS, Ltd. > www.vekos.ru > > > > > -----Original Message----- > > From: Justin Patrin [mailto:papercrane@gmail.com] > > Sent: Thursday, October 07, 2004 9:10 PM > > To: Denis Gerasimov > > Cc: PEAR General ML; Smarty General ML > > Subject: Re: [PEAR] Smarty + DataObject and DataObjectDebugger's > > console... > > > > On Thu, 7 Oct 2004 19:30:57 +0400, Denis Gerasimov > > <denis.gerasimov@vekos.ru> wrote: > > > > > > Hello all > > > > > > We are trying to develop debugging console for PEAR DB_DataObject that > > > should be similar to "internal" Smarty debug console. > > > > > > For example, look at this screenshot > > > > > > http://www.vekos.ru/images/DataObjectDebugger_Consonle.png > > > > > > However we have some troubles that seem to be difficult to solve. Does > > > anybody know how we can implement Smarty-like debugging console for our > > own > > > needs (it should be based on Smarty)? > > > > > > > The best way might be to create a listener callback which outputs JS > > which changes the "console". You can do this by setting the debug > > option to a valid callback instead of "1". JS is actually how Smarty > > does it (see the debug.tpl in the Smarty distribution). > > > > -- > > paperCrane --Justin Patrin-- > -- paperCrane --Justin Patrin--

« previous php.pear.general (#14849) next »