assign( $var, $val ); } function sm_display ( $tpl = '' ) { if ($GLOBALS['debug']) { $GLOBALS['smarty']->clear_cache($tpl); } global $sm_display_varspec; foreach( $sm_display_varspec as $varname => $format) { eval("global \$$varname; sm_set( '$varname', \$$varname );"); } if ($tpl == '') { // default to the same name as the script global $HTTP_SERVER_VARS; ereg( $GLOBALS['site_base'] . "(.*)\.php", $HTTP_SERVER_VARS['SCRIPT_FILENAME'], $match ); $tpl = "$match[1].tpl"; } return $GLOBALS['smarty']->display( $tpl ); } function sm_page_contract( $argspec, $varspec ) { //argspec is a description of the arguments required by the page // varspec is a description of the variables returned to the template foreach( $argspec as $varname => $format ) { global $HTTP_POST_VARS; global $HTTP_GET_VARS; global $HTTP_COOKIE_VARS; if( isset( $HTTP_POST_VARS["$varname"] )) { $tmpvar = $HTTP_POST_VARS["$varname"]; } elseif( isset( $HTTP_GET_VARS["$varname"] )) { $tmpvar = $HTTP_GET_VARS["$varname"]; } elseif( isset( $HTTP_COOKIE_VARS["$varname"] )) { $tmpvar = $HTTP_COOKIE_VARS["$varname"]; } else { // if there is a default, use it - if it's required, return an error } eval( "global \$$varname; \$$varname = \$tmpvar;" ); } // this gets processed at display time global $sm_display_varspec; $sm_display_varspec = $varspec; } # XXX TODO : create an export_vars function, which can auto-detect arrays and export appropriately # - hmm, how will it be associated with a form without being part of an ad_form... it could be query string (bleh) or session (complicated) or a tpl tag (but it should be in the php)... ?>