[Owp-cvs] owp/inc/classes towp.class,NONE,1.1 twebobject.class,NONE,1.1
Status: Inactive
Brought to you by:
scader
From: <owp...@li...> - 2006-04-19 02:26:36
|
Update of /cvsroot/owp/owp/inc/classes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11500/inc/classes Added Files: towp.class twebobject.class Log Message: Made compilations routine of owp objects --- NEW FILE: towp.class --- <?php /* Copyright (c) 2006, 2realities Group All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the 2realities Group nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * Contains towp class and requered data for it. * @package owp * @author Artem Sidorenko <ar...@2r...> * @version $Id: towp.class,v 1.1 2006/04/19 02:26:32 scader Exp $ * @copyright (c) 2004-2006 2realities Group (www.2realities.com) */ /**functions for working with paths*/ include_once 'path_functions.inc'; /**Extension of OWP files*/ @ define('files_ext_owp','owp'); /**Name of session var, used by the OWP*/ @ define('owp_session_var','owp'); /**Upper value of level, security issue because of overflow possibility*/ @ define('owp_max_level',6); /**Name of onload event, called after unserializing*/ @ define('owp_events_onload','_onload'); /**Name of onshow event, called before collecting HTML code*/ @ define('owp_events_onshow','onshow'); /**Name of input data handler*/ @ define('owp_handlers_input','_process_input'); /**Name of handler that returns html code*/ @ define('owp_handlers_get_html','_get_html'); class elements_container{} class towp{ /**pointer to the session * @var array */ var $session = false; /**pointer to the part of session, contains serialized objects*/ var $session_data = false; /**Object, that contains all page objects * @var towp_elements */ var $elements = false; /**List of files, contains classes * @var array */ var $includes = false; /**Constructor * @param array $session pointer to the array, that contains session data * @param string $file path to the owp file * @param string $data data process to */ function towp(&$session){ //link to the session $this->session = &$session[owp_tag]; if(empty($this->session))//requered to init session $this->session = array('includes'=>array(),); $this->includes = &$this->session['includes'];//link $this->session_data = &$this->session['data'];//link $this->elements = &new elements_container(); }//\\towp /**calls create_page() with file, build from templaate filename * @param string $file path to the template file * @return string result of create_page() */ function create_page_using_template($file){ $pathinfo = pathinfo($file); $file = build_path($pathinfo['dirname'],basename($pathinfo['basename'],'.'.$pathinfo['extension']).'.'.files_ext_owp); return $this->create_page($file); }//\\create_page_using_template /**creates a page and created requered pages * @param string $file path to the file * @access private * @return string name of page */ function create_page($file){ $rfile = realpath($file); if(!$rfile) trigger_error("OWP Error: File '$file' doesn't exists",E_USER_ERROR); $file = $rfile; if(!in_array($file,$this->includes))//if this file isn't exists in list, adding it $this->includes[]=$file; $page_name = $this->get_class_name($file); if(isset($this->elements->$page_name))//if already exists ignoring return $page_name; /** @ignore*/ include_once $file; $this->elements->$page_name = &new $page_name($this,$this,$this); //foreach($this->elements->$page_name->requered as $v) // $this->create_page($v); return $page_name; }//\\create_page /**returns a page class name in the file * @access private * @param string $file file path * @return string */ function get_class_name($file){ $pathinfo = pathinfo($file); return basename($pathinfo['basename'],".".$pathinfo['extension']); }//\\get_class_name /**loads a saved data * @access private */ function load_serialized(){ //loading files with our classes foreach($this->includes as $v) include_once $v; //unserializing data $this->elements = unserialize($this->session_data); //calling events $this->process_event($this->elements,owp_events_onload); }//\\load_serialized /**Function processes events * @param object $object object process to * @param string $function_name name of event(function) * @param integer $level security issue * @access private */ function process_event(&$object,$function_name,$level=0){ //security issue if($level>=owp_max_level) return false; //if event exists, running it if(method_exists($object,$function_name)) $object->$function_name(); //processing child objects foreach($object as $k=>$v) if(is_object($v)) process_event($object->$k,$function_name,$level+1);//recursion }//\\process_onload }//\\towp ?> --- NEW FILE: twebobject.class --- <?php /* Copyright (c) 2006, 2realities Group All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the 2realities Group nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * Contains root class for all owp classes * @package owp * @author Artem Sidorenko <ar...@2r...> * @version $Id: twebobject.class,v 1.1 2006/04/19 02:26:32 scader Exp $ * @copyright (c) 2004-2006 2realities Group (www.2realities.com) */ class twebobject{ /**owner of this object * @var twebobject */ var $owner = false; /**link to the page, contained this object * @var twebpage */ var $page = false; /**link to the root, in simple case it will be form * @var twebobjectscontainer */ var $root = false; /**name of current object * @var string */ var $name = false; /**created now? * @var bool */ var $new = true; /**Constructor * @param twebobject $owner owner of this object * @param twebpage $page link to the page, contained this object * @param twebobjectscontainer $root link to the root * @param string $name name of this object, if not given using class name */ function twebobject(&$owner,&$page,&$root,$name=false){ //setting our links $this->owner = &$owner; $this->page = &$page; $this->root = &$root; //if name given then using it, otherwise class name if($name) $this->name = $name; else $this->name = get_class($this); //calling event $this->oncreate(); }//\\twebobject #standard events /**called by the creation of object*/ function oncreate(){ }//\\oncreate /**internal event * @access private */ function _onload(){ $this->new = false; $this->onload();//calling event }//\\_onload /**called by the loading from session*/ function onload(){ }//\\onload /**returns php code, used by the Smarty compiler */ function _get_php($open,$access_string){ $rarray = array( 'push'=>false, 'pop'=>false, 'code'=>false, ); return $rarray; }//\\_get_php }//\\twebobject ?> |