History of ClassStructure
Version 2 | Current version | |
---|---|---|
Some detail: A new class structure is defined from which all Tiki classes inherit. The existing lib/* directory structure will be maintiained, and all existing libs can stay in place as migration takes place. The basic class inheritance looks like:
An instantiated class should typically represent a single object, such as a wiki page or article. Aggregate data functions are currently in the same class. Perhaps a derived TikiFeatureGroup class might be designed, but this is uncertain for now. A few rules of thumb:
Example: imaginary TikiFeature derived class, see TikiPage for real example class TikiFeature extends TikiBase { // member var that hold corresponding data var mRow; function TikiFeature( $iFeatureID = NULL ) { // be sure to call base constructor!!! TikiBase::TikiBase(); $this->mFeatureID = $iFeatureID; } function load() { if( $this->mFeatureID ) { $this->mRow = {... select data from db where feature_id=$this->mFeatureID ...} } return( count( $this->mErrors ) == 0 ); } // This verifies data integrity. NOTE: pass by reference is crucial, because // some modifications might be necessary (length truncation, etc.); function verify( &$inParams ) { // clean up variables foreach( array_keys($inParams) as $key ) { $inParams[$key] = trim( $inParams[$key] ); } if( empty( $inParams['required_column'] ) ) { $this->mErrors['required_column'] = SOME_ERROR_MESSAGE; } elseif( strlen( $inParams['required_column'] ) > FEATURE_LENGTH ) { $inParams['required_column'] = substring( $inParams['required_column'], 0, FEATURE_LENGTH ); } {... continue testing hash values various conditions ...} return( count( $this->mErrors ) == 0 ); } // this method stores the data. function store( &$inParams ) { // ALWAYS call our verify first to ensure data is safe to go into db if( $this->verify( $inParams ) ) { $this->mDB->StartTrans(); if( data exists ) { {... update existing rows ...} } else { {... insert new row ...} } $this->mDB->CompleteTrans(); } return( count( $this->mErrors ) == 0 ); } funciton expunge() { {... delete appropriate rows for this feature in all necessary tables ...} return( count( $this->mErrors ) == 0 ); } } | Some detail: All bitweaver classes follow the same structure. The basic class inheritance looks like:
An instantiated class should typically represent a single object, such as a wiki page or article. Aggregate data functions are currently in the same class. Perhaps a derived BitFeatureGroup class might be designed, but this is uncertain for now. A few rules of thumb:
Example: imaginary BitFeature derived class, see BitPage for real example
|