Ferreteria/archive/smw-base.php: Difference between revisions
(required files for schema versions) |
(→Notes: more accurately) |
||
Line 1: | Line 1: | ||
==Notes== | ==Notes== | ||
* '''Requires''': {{l/same|smw-base-v2.php}} | * '''Requires''': {{l/same|smw-base-v2.php}} or {{l/same|smw-base-v3.php}}, depending on what version of SMW is in use | ||
==Code== | ==Code== | ||
<php> | <php> |
Revision as of 02:33, 13 February 2013
Notes
- Requires: smw-base-v2.php or smw-base-v3.php, depending on what version of SMW is in use
Code
<php> <?php /*
PURPOSE: Semantic MediaWiki interface classes The existing class library is poorly documented, lacking a stable API, and difficult to use. This class set goes directly to the data structures -- which may change over time, but the changes should be easier to puzzle out than changes to the SMW class library. REQUIRES: data.php USAGE: set SMW_DATA_VERSION to 2 or 3 before including this file TODO: this goes directly to the DatabaseMysql class for some functions; needs to be generalized to use abstract wrappers. HISTORY: 2012-01-22 started 2012-09-17 useful pieces working 2013-01-24 moved clsMWData and clsDataResult_MW from to mw-base.php 2013-02-12 splitting some classes off into v2 and v3 versions in separate files, to handle different SMW data schemas
- /
define('WZL_SMW',TRUE); // flag to let other libraries know these classes are available // is this actually needed?
clsLibMgr::AddClass('clsMWData','mw-base'); // 'mw-base' must be defined by caller
// include the schema-appropriate ancestor class if (SMW_DATA_VERSION > 2) {
require('smw-base-v3.php');
} else {
require('smw-base-v2.php');
}
class clsSMWData extends clsSMWData_version {
/*---- ACTION: Convert title into normalized DB-key format */ static public function NormalizeTitle($iTitle,$iNameSpace) {
$strTitle = Sanitizer::decodeCharReferencesAndNormalize($iTitle); // convert HTML entities $strTitle = Title::capitalize($strTitle,$iNameSpace); // initial caps, if needed $strTitle = str_replace( ' ', '_',$strTitle); // convert spaces to underscores return $strTitle;
} /*---- ACTION: convert DB-key formatted title into display format
Basically, just convert underscores to spaces.
*/ static public function VisualizeTitle($iTitle) {
$strTitle = str_replace('_',' ',$iTitle); // convert spaces to underscores return $strTitle;
}
}
// is this class necessary? class clsDataResult_SMW extends clsDataResult {
public function is_okay() { } /*---- ACTION: set the record pointer so the first row in the set will be read next */ public function do_rewind() { } /*---- ACTION: Fetch the first/next row of data from a result set */ public function get_next() { } /*---- ACTION: Return the number of rows in the result set */ public function get_count() { } /*---- ACTION: Return whether row currently has data. */ public function is_filled() { }
} </php>