Update of /cvsroot/owp/owp/inc/startup
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11500/inc/startup
Modified Files:
owp.inc
Log Message:
Made compilations routine of owp objects
Index: owp.inc
===================================================================
RCS file: /cvsroot/owp/owp/inc/startup/owp.inc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** owp.inc 14 Apr 2006 01:59:43 -0000 1.1
--- owp.inc 19 Apr 2006 02:26:32 -0000 1.2
***************
*** 29,32 ****
--- 29,38 ----
*/
+ /**Name of atrribut used to determine object name*/
+ @ define('owp_element_attribut','element');
+
+ /**Name of handler used by the smarty compiler*/
+ @ define('owp_handlers_get_php','_get_php');
+
/**This is a handler for carrying about owp tags in Smarty
* @param bool $open is it an open or close tag?
***************
*** 35,38 ****
--- 41,103 ----
*/
function process_owp($open,$tag_args,&$smarty){
+ //array to know where we are
+ static $push_array = array();
+
+ $params = $smarty->_parse_attrs($tag_args);//parsing parameters
+
+ if($open&&empty($params)){//first init tag
+
+ //if owp object was not created yet
+ if(!is_object($smarty->parent->owp)){
+ include_once 'towp.class';
+ $smarty->parent->owp = &new towp($_SESSION);
+ //creating main object, todo!
+ }//\\if
+
+ //file name
+ $params = array('resource_name'=>$smarty->_current_file);
+ $smarty->parent->_parse_resource_name($params);
+ $file_name = $params['resource_name'];
+
+ //loading page data
+ $page_name = $smarty->parent->owp->create_page_using_template($file_name);
+
+ //reseting our push array to page name
+ $push_array = array($page_name);
+
+ return '';//nothing to return for init tag
+ }//\\if
+
+ if(!isset($params[owp_element_attribut]))//nothing to do
+ return '';
+
+
+ $element = $smarty->_dequote($params[owp_element_attribut]);
+
+
+ #processing current element
+ //building access string
+ $access_string = implode('->',$push_array);
+
+ $rarray = array();//init
+ //I know, but without it won't work:-/
+ eval('$rarray = $smarty->parent->owp->elements->'.$access_string.'->'.$element.'->'.owp_handlers_get_php.'($open,$access_string);');
+
+ //checking if we need to push this tag
+ if($rarray['push']){
+ $smarty->_push_tag('owp');
+ array_push($push_array,$element);
+ }//\\if(push)
+
+ //checking if we need to pop this tag
+ if($rarray['pop']){
+ $smarty->_pop_tag('owp');
+ $close_element = array_pop($push_array);
+ if($close_element!=$element)
+ trigger_error("OWP Error: mismatched close tag $close_element",E_USER_ERROR);
+ }//\\if(pop)
+
+ return $rarray['code'];
+
}//\\process_owp
|