* @copyright 2004 by http://wombat.exit0.net * @package wombatSite * @subpackage cmHtml */ /** * Dialog interface * * @todo check user before display! * * @version 0.2.0 * @package wombatSite * @subpackage cmHtml */ class wbDialogController { /** * patSession object * @var object $_sess */ var $_sess; /** * patTemplate object * @var object $_tmpl */ var $_tmpl; /** * authentication handler object * @var object $_auth */ var $_auth; /** * dialog object * @var object $_dlg */ var $_dlg; /** * html * @var string $_html */ var $_html; /** * constructor * * @access public */ function __construct() { $this->_sess =& wbFactory::singleton( 'patSession' ); $params = array( 'tmplDir' => wbFactory::getParam( 'systemDir' ) . '/'. wbFactory::getParam( 'adminDir' ) . '/templates/SiteMaker' ); $this->_tmpl =& wbFactory::singleton( 'patTemplate', $params ); $this->_auth =& wbFactory::singleton( 'wbAuth' ); $this->_options['self'] = $_SERVER['PHP_SELF'] . '?' . $this->_sess->getQueryString(); wbFactory::includeClass( 'wbJSTools' ); wbJSTools::includeJavascript( 'prototype.js' ); } /** * constructor wrapper for PHP4 * * @access public * @see __construct() */ function wbDialogController() { $this->__construct(); } /** * load concrete dialog tool * * @access public * @param string $html html to be displayed, or null to get it from template * @return boolean $result true */ function start( $dlg ) { $this->_dlg =& wbFactory::singleton( 'wbDialog_' . $dlg ); if( patErrorManager::isError( $this->_dlg ) ) { return $this->_dlg; } $this->_dlg->setSelection( $_GET['s'] ); return true; } /** * process dialog * * @access public * @param string $html html to be displayed, or null to get it from template * @return boolean $result true */ function process() { if( patErrorManager::isError( $this->_dlg ) ) { return $this->_dlg; } $this->_html = $this->_dlg->process(); return true; } /** * display dialog * * @access public * @return boolean $result true */ function display() { if( !$this->_auth->isAuthenticated() ) { die( 'User not logged in!' ); } $this->_tmpl->readTemplatesFromInput( 'cmHtml/dialog.tmpl' ); $this->_tmpl->addGlobalVars( $this->_dlg->getOptions() ); $code = wbJSTools::getCode(); $this->_tmpl->addGlobalVar( 'javascript_code', $code['code'] ); $this->_tmpl->addGlobalVar( 'javascript_onload', $code['onload'] ); $this->_tmpl->addVar( 'cmHtml_Dialog', 'dialog', $this->_html ); $this->_tmpl->displayParsedTemplate( 'cmHtml_Dialog' ); if( wbDebugger::isActive() ) { wbDebugger::addMsg( WBSITE_DEBUG_SECTION, $this->_sess->getCounter() . ' requests', 'Session' ); wbDebugger::addMsg( WBSITE_DEBUG_SECTION, 'Total processing time: ' . wbDebugger::getUtime( 'genesis', 1000, 6 ) . ' ms', 'Stopwatch' ); wbDebugger::printMsg(); } return true; } } ?>