[Phpslash-commit] CVS: phpslash-ft/class Block.class,1.4,1.5
Brought to you by:
joestewart,
nhruby
From: Joe S. <joe...@us...> - 2001-11-07 19:39:34
|
Update of /cvsroot/phpslash/phpslash-ft/class In directory usw-pr-cvs1:/tmp/cvs-serv9901 Modified Files: Block.class Log Message: housekeeping Index: Block.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/Block.class,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Block.class 2001/06/15 15:49:25 1.4 --- Block.class 2001/11/07 19:39:31 1.5 *************** *** 1,6 **** <?php /** ! * Block.class -> Primary methods for manipulating blocks ! * @version $Id$ */ --- 1,10 ---- <?php + /* @version $Id$ */ + /** ! * Database Level access to the PHPSlash Block Engine. ! * ! * This object is how we retrieve block data from the database. It also ! * provides the db interface for block management. */ *************** *** 9,28 **** /** * Atributes of the base block methods ! * @var string $db ! * @var string $block_info ! * @var string $parser * @var string $parsedData ! * @var string $parser_arr ! * @var string $block_ary */ /* Var's to be constructed in constructor */ ! var $db, $block_info, $parser, $parsedData, $parser_arr, $block_ary; function Block() { /* Constructor: Create sub-objects here, etc... */ $this->db = new slashDB; $this->db->Auto_Free = 1; /* Array to store block info in */ $this->block_info = array(); --- 13,54 ---- /** * Atributes of the base block methods ! * @var object $db ! * @var array $block_info ! * @var object $parser * @var string $parsedData ! * @var array $parser_arr ! * @var array $block_ary ! * @var array $psl */ /* Var's to be constructed in constructor */ ! var $db, $block_info, $parser, $parsedData, $parser_arr, $block_ary, $_PSL; + /** + * Block - constructor for the Block class + * + * Atributes of the base block methods setup here + * + * @var object $db + * @var array $block_info + * @var object $parser + * @var string $parsedData + * @var array $parser_arr + * @var array $block_ary + * @var array $psl + * + * @access private + * + */ + function Block() { /* Constructor: Create sub-objects here, etc... */ + global $_PSL; + $this->db = new slashDB; $this->db->Auto_Free = 1; + $this->psl = $_PSL; + /* Array to store block info in */ $this->block_info = array(); *************** *** 30,45 **** $this->block_array = array(); /* String for finally parsed data */ $this->parsedData = ""; } function reset() { ! /* Resets object to empty values */ unset($this->block_info); unset($this->parser); } function getTypes() { - /* Gets all the known types of Block data and returns an array */ $types = array(); $this->db->query("SELECT * FROM psl_block_type ORDER BY name"); --- 56,85 ---- $this->block_array = array(); + $this->parser = array(); + /* String for finally parsed data */ $this->parsedData = ""; } + /** + * reset - Resets object to empty values + * + * @access public + * + */ function reset() { ! unset($this->block_info); unset($this->parser); } + /** + * getTypes - Gets all the known types of Block data and returns an array + * + * @access public + * + * @return array types + */ function getTypes() { $types = array(); $this->db->query("SELECT * FROM psl_block_type ORDER BY name"); *************** *** 50,55 **** } function putType($type) { - /* Stores a block Type */ $id = generateID("psl_blocktype_seq"); $type = addslashes($type); --- 90,102 ---- } + /** + * putType - Stores a block Type + * + * @param string type + * + * @access public + * + */ function putType($type) { $id = generateID("psl_blocktype_seq"); $type = addslashes($type); *************** *** 63,67 **** /** ! * returns a block from an id * * @param integer id --- 110,114 ---- /** ! * getBlock - returns a block from an id * * @param integer id *************** *** 71,75 **** * @return array this->block_info */ - function getBlock($id) { /* Gets all data in db for block $id */ --- 118,121 ---- *************** *** 119,124 **** } function putBlock($block_array) { - /* Puts the array into the db as a block */ if(is_array($block_array)) { --- 165,177 ---- } + /** + * putBlock - Puts the array into the db as a block + * + * @param array block_array + * + * @access public + * + */ function putBlock($block_array) { if(is_array($block_array)) { *************** *** 201,205 **** if(is_array($section_id_ary) ) { while ( list( $key, $val ) = each( $section_id_ary ) ) { ! $lut_id = generateID("psl_section_lut_seq"); $lut_insert = "INSERT INTO psl_section_block_lut (lut_id, --- 254,258 ---- if(is_array($section_id_ary) ) { while ( list( $key, $val ) = each( $section_id_ary ) ) { ! $lut_id = generateID("psl_section_block_lut_seq"); $lut_insert = "INSERT INTO psl_section_block_lut (lut_id, *************** *** 231,236 **** } function checkTime() { - /* Check the refresh time and return true if the stored data is ok */ $last = intval($this->block_info["last_update"]); $update = intval($this->block_info["expire_length"]); --- 284,296 ---- } + /** + * checkTime - Check the refresh time and return true + * if the stored data is ok + * + * @access private + * + */ + function checkTime() { $last = intval($this->block_info["last_update"]); $update = intval($this->block_info["expire_length"]); *************** *** 249,253 **** } ! /* Takes an id and does stuff to create a block */ function doBlock($id, $column="") { --- 309,322 ---- } ! /** ! * doBlock - Takes an id and does stuff to create a block ! * ! * @param integer id ! * @param string column ! * ! * @access public ! * ! * return string html formatted block ! */ function doBlock($id, $column="") { *************** *** 299,304 **** } function getParser($mytype) { - global $classdir; /* Start a new object to render info */ --- 368,381 ---- } + /** + * getParser - get parser method for Block_render type + * + * @param string mytpe + * + * @access private + * + * return object this->parser + */ function getParser($mytype) { /* Start a new object to render info */ *************** *** 309,364 **** if( !$parser_arr[$mytype]) { - - include($classdir .'/'. $parserFile); - $parser_arr[$mytype] = new $parserName; } $this->parser = $parser_arr[$mytype]; ! } ! ! function doParse($autoStore) { ! /* Render the data we got, use $render if we can, or make new */ ! ! if (!is_object($this->parser)) { ! $type = $this->block_info["type"]; ! if (!$type) { /* if we don't have a type then don't even try to */ ! return; /* parse the block. */ ! } ! $this->getParser($this->block_info["type"]); ! } ! if ($this->parser->getType() != $this->block_info["type"]) { ! $this->getParser($this->block_info["type"]); ! } ! ! if ($this->parser->getType() == $this->block_info["type"]) { ! ! # echo "<B>Before: ParsedData: </B>$this->parsedData<BR>\n"; $this->parser->parse($this->block_info); $this->parsedData = $this->parser->getFinal(); ! # echo "<B>After: ParsedData: </B>$this->parsedData<BR>\n"; ! if ( $this->parsedData == "Error") { ! /* TODO: Insert errorlog function here -nh */ ! if ($this->debug) { ! $this->block_info["cache_data"] .= "<br>Parser error<br>"; ! } ! } else { ! /* Store in the current array */ ! $this->block_info["cache_data"] = $this->parsedData; ! if ($autoStore) { ! $this->storeParsed(); ! } ! } } else { ! if ($this->debug) { ! echo "Warning: Block Data is old and needs refeshing.<br>\n"; ! echo "Delaying becasue current parser isn't my type.<br>\n"; ! } } } ! function storeParsed() { - /* Store the pre-rendered data (minus fancybox) in db */ $this->parsedData = addslashes($this->parsedData); $id = $this->block_info["id"]; --- 386,433 ---- if( !$parser_arr[$mytype]) { + if( @file_exists($this->psl['classdir'] .'/'. $parserFile)) { + include($this->psl['classdir'] .'/'. $parserFile); + $parser_arr[$mytype] = new $parserName; + } else { + $parser_arr[$mytype] = false; + } } $this->parser = $parser_arr[$mytype]; ! return $parser_arr[$mytype]; } ! ! /** ! * doParse - parse the block, storing the parsedData in the db cache ! * ! * @param string autoStore ( deprecated) ! * ! * @access private ! * ! * return boolean success ! */ ! function doParse($autoStore="") { ! ! if ($this->getParser($this->block_info["type"])) { ! $thistype = $this->block_info["type"]; $this->parser->parse($this->block_info); $this->parsedData = $this->parser->getFinal(); ! $this->block_info["cache_data"] = $this->parsedData; ! $this->storeParsed(); ! return true; } else { ! $this->block_info["cache_data"] = "type = $this->block_info[type]<br>"; ! return false; } } ! ! /** ! * storeParsed - Store the pre-rendered data (minus fancybox) in db ! * ! * @access private ! * ! */ function storeParsed() { $this->parsedData = addslashes($this->parsedData); $id = $this->block_info["id"]; *************** *** 378,381 **** --- 447,459 ---- } + /** + * delBlock - delete a Block + * + * @param integer id + * + * @access private + * + * return boolean success + */ function delBlock($id) { *************** *** 463,469 **** $this->block_info = $this->block_ary[$i]; ! $this->doParse('1'); ! $this->block_ary[$i][cache_data] = $this->block_info["cache_data"]; ! } --- 541,547 ---- $this->block_info = $this->block_ary[$i]; ! if ($this->doParse('1')) { ! $this->block_ary[$i][cache_data] = $this->block_info["cache_data"]; ! } } |