r76071 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76070‎ | r76071 | r76072 >
Date:02:08, 5 November 2010
Author:yaron
Status:ok
Tags:
Comment:
Tag for version 0.6.2
Modified paths:
  • /tags/extensions/SemanticInternalObjects/REL_0_6_2 (added) (history)

Diff [purge]

Index: tags/extensions/SemanticInternalObjects/REL_0_6_2/SemanticInternalObjects.php
@@ -0,0 +1,51 @@
 2+<?php
 3+/**
 4+ * Initialization file for Semantic Internal Objects.
 5+ *
 6+ * @file
 7+ * @ingroup SemanticInternalObjects
 8+ * @author Yaron Koren
 9+ */
 10+
 11+if ( !defined( 'MEDIAWIKI' ) ) die();
 12+
 13+define( 'SIO_VERSION', '0.6.2' );
 14+
 15+$wgExtensionCredits[defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 'parserhook'][] = array(
 16+ 'path' => __FILE__,
 17+ 'name' => 'Semantic Internal Objects',
 18+ 'version' => SIO_VERSION,
 19+ 'author' => 'Yaron Koren',
 20+ 'url' => 'http://www.mediawiki.org/wiki/Extension:Semantic_Internal_Objects',
 21+ 'descriptionmsg' => 'semanticinternalobjects-desc',
 22+);
 23+
 24+$wgHooks['ParserFirstCallInit'][] = 'siofRegisterParserFunctions';
 25+$wgHooks['LanguageGetMagic'][] = 'siofLanguageGetMagic';
 26+$wgHooks['ParserClearState'][] = 'SIOHandler::clearState';
 27+$wgHooks['SMWSQLStore2::updateDataAfter'][] = 'SIOHandler::updateData';
 28+$wgHooks['SMWSQLStore2::deleteSubjectAfter'][] = 'SIOHandler::deleteData';
 29+$wgHooks['smwUpdatePropertySubjects'][] = 'SIOHandler::handleUpdatingOfInternalObjects';
 30+$wgHooks['TitleMoveComplete'][] = 'SIOHandler::handlePageMove';
 31+$wgHooks['smwRefreshDataJobs'][] = 'SIOHandler::handleRefreshingOfInternalObjects';
 32+$wgHooks['smwAddToRDFExport'][] = 'SIOSQLStore::createRDF';
 33+
 34+$siogIP = dirname( __FILE__ );
 35+$wgExtensionMessagesFiles['SemanticInternalObjects'] = $siogIP . '/SemanticInternalObjects.i18n.php';
 36+$wgAutoloadClasses['SIOHandler'] = $siogIP . '/SemanticInternalObjects_body.php';
 37+$wgAutoloadClasses['SIOSQLStore'] = $siogIP . '/SemanticInternalObjects_body.php';
 38+
 39+function siofRegisterParserFunctions( &$parser ) {
 40+ $parser->setFunctionHook( 'set_internal', array( 'SIOHandler', 'doSetInternal' ) );
 41+ $parser->setFunctionHook( 'set_internal_recurring_event', array( 'SIOHandler', 'doSetInternalRecurringEvent' ) );
 42+ return true; // always return true, in order not to stop MW's hook processing!
 43+}
 44+
 45+function siofLanguageGetMagic( &$magicWords, $langCode = 'en' ) {
 46+ switch ( $langCode ) {
 47+ default:
 48+ $magicWords['set_internal'] = array ( 0, 'set_internal' );
 49+ $magicWords['set_internal_recurring_event'] = array ( 0, 'set_internal_recurring_event' );
 50+ }
 51+ return true;
 52+}
Property changes on: tags/extensions/SemanticInternalObjects/REL_0_6_2/SemanticInternalObjects.php
___________________________________________________________________
Added: svn:eol-style
153 + native
Index: tags/extensions/SemanticInternalObjects/REL_0_6_2/README
@@ -0,0 +1,89 @@
 2+Semantic Internal Objects Extension
 3+
 4+ Version 0.6.2
 5+ Yaron Koren
 6+
 7+This is free software licensed under the GNU General Public License. Please
 8+see http://www.gnu.org/copyleft/gpl.html for further details, including the
 9+full text and terms of the license.
 10+
 11+== Overview ==
 12+
 13+Semantic Internal Objects is an extension to MediaWiki that defines a
 14+parser function, '#set_internal', that is used to define "internal objects"
 15+within the Semantic MediaWiki system. There are complex types of
 16+information sometimes known as 'n-ary relations' that involve more than one
 17+data value associated together. A simple example is in a cooking recipe; a
 18+recipe may call for 1 cup of flour, and the values "1", "cup" and "flour"
 19+must be encoded together; by themselves, the values are not meaningful (the
 20+third value has meaning, though not all of the meaning it could have). Such
 21+information can be stored already in SMW using multi-valued properties,
 22+though this approach is not flexible and currently leads to querying problems.
 23+Instead, #set_internal can be used to define "internal objects" within a page,
 24+which can then be queried as normal SMW pages would; a row of a recipe would
 25+be a good example of data that could be defined using #set_internal.
 26+
 27+The syntax of #set_internal is as follows:
 28+
 29+{{#set_internal:object_to_page_property
 30+|property1=value1
 31+|property2=value2
 32+...
 33+}}
 34+
 35+A sample call to #set_internal would be:
 36+
 37+{{#set_internal:Has recipe
 38+|Has quantity=1
 39+|Has unit=cup
 40+|Has ingredient=flour
 41+}}
 42+
 43+This call would be placed in a page for a recipe, and it would define an object
 44+that had an automatically-generated name; if it were in a page called "Carrot
 45+cake", for instance, the object would be called "Carrot cake#1". If that page
 46+had subsequent calls to #set_internal, the objects that those calls generated
 47+would be called "Carrot cake#2", "Carrot cake#3", etc.
 48+
 49+It should be noted that #set_internal does not display anything to the screen;
 50+display of the values has to be handled separately (this can be done easily
 51+if the function is called from a template).
 52+
 53+Internal objects, once stored, can be queried as if they were wiki pages. So
 54+the following query would show a table of all the recipes that contain more
 55+than 1/2 a cup of flour, and the number of cups they contain:
 56+
 57+{{#ask:[[Has recipe::+]][[Has ingredient::flour]][[Has unit::cup]][[Has quantity::>.5]]
 58+|mainlabel=-
 59+|? Has recipe
 60+|? Has quantity
 61+}}
 62+
 63+Note the "mainlabel=-" parameter in the query: that hides the names of the
 64+internal objects from users, since those names are meaningless.
 65+
 66+For more information, see the extension homepage at:
 67+http://www.mediawiki.org/wiki/Extension:Semantic_Internal_Objects
 68+
 69+== Requirements ==
 70+
 71+This version of the Semantic Internal Objects extension requires MediaWiki 1.8
 72+or higher and Semantic MediaWiki 1.4 or higher.
 73+
 74+== Installation ==
 75+
 76+To install the extension, place the entire 'SemanticInternalObjects' directory
 77+within your MediaWiki 'extensions' directory, then add the following
 78+line to your 'LocalSettings.php' file:
 79+
 80+ require_once( "$IP/extensions/SemanticInternalObjects/SemanticInternalObjects.php" );
 81+
 82+== Contact ==
 83+
 84+Most comments, questions, suggestions and bug reports should be sent to
 85+the Semantic MediaWiki mailing list:
 86+
 87+ https://lists.sourceforge.net/lists/listinfo/semediawiki-user
 88+
 89+If possible, please add "[SIO]" at the beginning of the subject line, to
 90+clarify the subject matter.
Property changes on: tags/extensions/SemanticInternalObjects/REL_0_6_2/README
___________________________________________________________________
Added: svn:eol-style
191 + native
Index: tags/extensions/SemanticInternalObjects/REL_0_6_2/SemanticInternalObjects.i18n.magic.php
@@ -0,0 +1,28 @@
 2+<?php
 3+
 4+$magicWords = array();
 5+
 6+/** English (English) */
 7+$magicWords['en'] = array(
 8+ 'set_internal' => array( 0, 'set_internal' ),
 9+);
 10+
 11+/** Arabic (العربية) */
 12+$magicWords['ar'] = array(
 13+ 'set_internal' => array( 0, 'ضبط_داخلي', 'set_internal' ),
 14+);
 15+
 16+/** Egyptian Spoken Arabic (مصرى) */
 17+$magicWords['arz'] = array(
 18+ 'set_internal' => array( 0, 'ضبط_داخلي', 'set_internal' ),
 19+);
 20+
 21+/** Japanese (日本語) */
 22+$magicWords['ja'] = array(
 23+ 'set_internal' => array( 0, '内部設定' ),
 24+);
 25+
 26+/** Dutch (Nederlands) */
 27+$magicWords['nl'] = array(
 28+ 'set_internal' => array( 0, 'intern_instellen' ),
 29+);
\ No newline at end of file
Property changes on: tags/extensions/SemanticInternalObjects/REL_0_6_2/SemanticInternalObjects.i18n.magic.php
___________________________________________________________________
Added: svn:eol-style
130 + native
Index: tags/extensions/SemanticInternalObjects/REL_0_6_2/SemanticInternalObjects_body.php
@@ -0,0 +1,487 @@
 2+<?php
 3+/**
 4+ * @author Yaron Koren
 5+ */
 6+
 7+if ( !defined( 'MEDIAWIKI' ) ) die();
 8+
 9+/**
 10+ * Class that holds information on a single internal object, including all
 11+ * its properties.
 12+ */
 13+class SIOInternalObject {
 14+ protected $mMainTitle;
 15+ protected $mIndex;
 16+ protected $mPropertyValuePairs;
 17+
 18+ public function SIOInternalObject( $mainTitle, $index ) {
 19+ $this->mMainTitle = $mainTitle;
 20+ $this->mIndex = $index;
 21+ $this->mPropertyValuePairs = array();
 22+ }
 23+
 24+ public function addPropertyAndValue( $propName, $value ) {
 25+ $property = SMWPropertyValue::makeUserProperty( $propName );
 26+ $dataValue = SMWDataValueFactory::newPropertyObjectValue( $property, $value );
 27+ if ( $dataValue->isValid() ) {
 28+ $this->mPropertyValuePairs[] = array( $property, $dataValue );
 29+ } // else - show an error message?
 30+ }
 31+
 32+ public function getPropertyValuePairs() {
 33+ return $this->mPropertyValuePairs;
 34+ }
 35+
 36+ public function getName() {
 37+ return $this->mMainTitle->getDBkey() . '#' . $this->mIndex;
 38+ }
 39+
 40+ public function getNamespace() {
 41+ return $this->mMainTitle->getNamespace();
 42+ }
 43+}
 44+
 45+/**
 46+ * The SIOTitle and SIOInternalObjectValue exist for only one reason: in order
 47+ * to be used by SIOSQLStore::createRDF(), to spoof Semantic MediaWiki's
 48+ * RDF-exporting code into thinking that it's dealing with actual wiki pages.
 49+ */
 50+class SIOTitle {
 51+ function __construct ($name, $namespace) {
 52+ $this->mName = $name;
 53+ $this->mNamespace = $namespace;
 54+ }
 55+
 56+ /**
 57+ * Based on functions in Title class
 58+ */
 59+ function getPrefixedName() {
 60+ $s = '';
 61+ if ( 0 != $this->mNamespace ) {
 62+ global $wgContLang;
 63+ $s .= $wgContLang->getNsText( $this->mNamespace ) . ':';
 64+ }
 65+ $s .= $this->mName;
 66+ return $s;
 67+ }
 68+
 69+ function getPrefixedURL() {
 70+ $s = $this->getPrefixedName();
 71+ return wfUrlencode( str_replace( ' ', '_', $s ) );
 72+ }
 73+}
 74+
 75+class SIOInternalObjectValue extends SMWWikiPageValue {
 76+ function __construct($name, $namespace) {
 77+ $this->mSIOTitle = new SIOTitle( $name, $namespace );
 78+ }
 79+ function getExportData() {
 80+ global $smwgNamespace;
 81+ return new SMWExpData( new SMWExpResource( SIOExporter::getResolverURL() . $this->mSIOTitle->getPrefixedURL() ) );
 82+ }
 83+
 84+ function getTitle() {
 85+ return $this->mSIOTitle;
 86+ }
 87+
 88+ function getWikiValue() {
 89+ return $this->mSIOTitle->getPrefixedName();
 90+ }
 91+}
 92+
 93+/**
 94+ * Class to work around the fact that SMWExporter::$m_ent_wiki is protected.
 95+ **/
 96+class SIOExporter extends SMWExporter {
 97+
 98+ static function getResolverURL() {
 99+ return SMWExporter::$m_ent_wiki;
 100+ }
 101+}
 102+
 103+/**
 104+ * Class for all database-related actions.
 105+ * This class exists mostly because SMWSQLStore2's functions makeSMWPageID()
 106+ * and makeSMWPropertyID(), which are needed for the DB access, are both
 107+ * protected, and thus can't be accessed externally.
 108+ */
 109+class SIOSQLStore extends SMWSQLStore2 {
 110+ static function deleteDataForPage( $subject ) {
 111+ $pageName = $subject->getDBKey();
 112+ $namespace = $subject->getNamespace();
 113+ $idsForDeletion = array();
 114+
 115+ // Get the set of IDs for internal objects to be deleted.
 116+ $iw = '';
 117+ $db = wfGetDB( DB_SLAVE );
 118+ $res = $db->select(
 119+ 'smw_ids',
 120+ array( 'smw_id' ),
 121+ 'smw_title LIKE ' . $db->addQuotes( $pageName . '#%' ) . ' AND ' . 'smw_namespace=' . $db->addQuotes( $namespace ) . ' AND smw_iw=' . $db->addQuotes( $iw ),
 122+ 'SIO::getSMWPageObjectIDs'
 123+ );
 124+ while ( $row = $db->fetchObject( $res ) ) {
 125+ $idsForDeletion[] = $row->smw_id;
 126+ }
 127+
 128+ if ( count( $idsForDeletion ) == 0 ) {
 129+ return;
 130+ }
 131+
 132+ // Now, do the deletion.
 133+ $db = wfGetDB( DB_MASTER );
 134+ $idsString = '(' . implode ( ', ', $idsForDeletion ) . ')';
 135+ $db->delete( 'smw_rels2', array( "(s_id IN $idsString) OR (o_id IN $idsString)" ), 'SIO::deleteRels2Data' );
 136+ $db->delete( 'smw_atts2', array( "s_id IN $idsString" ), 'SIO::deleteAtts2Data' );
 137+ $db->delete( 'smw_text2', array( "s_id IN $idsString" ), 'SIO::deleteText2Data' );
 138+ // Handle the sm_coords table only if the Semantic Maps
 139+ // extension is installed and uses sm_coords.
 140+ if ( defined( 'SM_VERSION' ) && version_compare( SM_VERSION, '0.6' ) >= 0 ) {
 141+ $db->delete( 'sm_coords', array( "s_id IN $idsString" ), 'SIO::deleteCoordsData' );
 142+ }
 143+ }
 144+
 145+ /**
 146+ * Returns the set of SQL values needed to insert the data for this
 147+ * internal object into the database.
 148+ */
 149+ function getStorageSQL( $internalObject ) {
 150+ $ioID = $this->makeSMWPageID( $internalObject->getName(), $internalObject->getNamespace(), '' );
 151+ $upRels2 = array();
 152+ $upAtts2 = array();
 153+ $upText2 = array();
 154+ $upCoords = array();
 155+ // set all the properties pointing from this internal object
 156+ foreach ( $internalObject->getPropertyValuePairs() as $propertyValuePair ) {
 157+ list( $property, $value ) = $propertyValuePair;
 158+ // handling changed in SMW 1.5
 159+ if ( method_exists( 'SMWSQLStore2', 'findPropertyTableID' ) ) {
 160+ $tableid = SMWSQLStore2::findPropertyTableID( $property );
 161+ $isRelation = ( $tableid == 'smw_rels2' );
 162+ $isAttribute = ( $tableid == 'smw_atts2' );
 163+ $isText = ( $tableid == 'smw_text2' );
 164+ // new with SMW 1.5.1 / SM 0.6
 165+ $isCoords = ( $tableid == 'smw_coords' );
 166+ } else {
 167+ $mode = SMWSQLStore2::getStorageMode( $property->getPropertyTypeID() );
 168+ $isRelation = ( $mode == SMW_SQL2_RELS2 );
 169+ $isAttribute = ( $mode == SMW_SQL2_ATTS2 );
 170+ $isText = ( $mode == SMW_SQL2_TEXT2 );
 171+ $isCoords = false;
 172+ }
 173+ if ( $isRelation ) {
 174+ $upRels2[] = array(
 175+ 's_id' => $ioID,
 176+ 'p_id' => $this->makeSMWPropertyID( $property ),
 177+ 'o_id' => $this->makeSMWPageID( $value->getDBkey(), $value->getNamespace(), $value->getInterwiki() )
 178+ );
 179+ } elseif ( $isAttribute ) {
 180+ $keys = $value->getDBkeys();
 181+ if ( method_exists( $value, 'getValueKey' ) ) {
 182+ $valueNum = $value->getValueKey();
 183+ } else {
 184+ $valueNum = $value->getNumericValue();
 185+ }
 186+ $upAtts2[] = array(
 187+ 's_id' => $ioID,
 188+ 'p_id' => $this->makeSMWPropertyID( $property ),
 189+ 'value_unit' => $value->getUnit(),
 190+ 'value_xsd' => $keys[0],
 191+ 'value_num' => $valueNum
 192+ );
 193+ } elseif ( $isText ) {
 194+ $keys = $value->getDBkeys();
 195+ $upText2[] = array(
 196+ 's_id' => $ioID,
 197+ 'p_id' => $this->makeSMWPropertyID( $property ),
 198+ 'value_blob' => $keys[0]
 199+ );
 200+ } elseif ( $isCoords ) {
 201+ $keys = $value->getDBkeys();
 202+ $upCoords[] = array(
 203+ 's_id' => $ioID,
 204+ 'p_id' => $this->makeSMWPropertyID( $property ),
 205+ 'lat' => $keys[0],
 206+ 'lon' => $keys[1],
 207+ );
 208+ }
 209+ }
 210+ return array( $upRels2, $upAtts2, $upText2, $upCoords );
 211+ }
 212+
 213+ static function createRDF( $title, $rdfDataArray, $fullexport = true, $backlinks = false ) {
 214+ // if it's not a full export, don't add internal object data
 215+ if ( !$fullexport ) {
 216+ return true;
 217+ }
 218+
 219+ $pageName = $title->getDBkey();
 220+ $namespace = $title->getNamespace();
 221+
 222+ // go through all SIOs for the current page, create RDF for
 223+ // each one, and add it to the general array
 224+ $iw = '';
 225+ $db = wfGetDB( DB_SLAVE );
 226+ $res = $db->select(
 227+ 'smw_ids',
 228+ array( 'smw_id', 'smw_namespace', 'smw_title' ),
 229+ 'smw_title LIKE ' . $db->addQuotes( $pageName . '#%' ) . ' AND ' . 'smw_namespace=' . $db->addQuotes( $namespace ) . ' AND smw_iw=' . $db->addQuotes( $iw ),
 230+ 'SIO::getSMWPageObjectIDs'
 231+ );
 232+ while ( $row = $db->fetchObject( $res ) ) {
 233+ $value = new SIOInternalObjectValue( $row->smw_title, $row->smw_namespace );
 234+ $semdata = new SMWSemanticData( $value, false );
 235+ $propertyTables = SMWSQLStore2::getPropertyTables();
 236+ foreach ( $propertyTables as $tableName => $propertyTable ) {
 237+ $data = smwfGetStore()->fetchSemanticData( $row->smw_id, null, $propertyTable );
 238+ foreach ( $data as $d ) {
 239+ $semdata->addPropertyStubValue( reset( $d ), end( $d ) );
 240+ }
 241+ }
 242+ $rdfDataArray[] = SMWExporter::makeExportData( $semdata, null );
 243+ }
 244+ return true;
 245+ }
 246+}
 247+
 248+/**
 249+ * Class for hook functions for creating and storing information
 250+ */
 251+class SIOHandler {
 252+
 253+ static $mCurPageFullName = '';
 254+ static $mInternalObjectIndex = 1;
 255+ static $mInternalObjects = array();
 256+ static $mHandledPages = array();
 257+
 258+ /**
 259+ * Called with the 'ParserClearState' hook, when more than one page
 260+ * is parsed in a single action.
 261+ */
 262+ public static function clearState( &$parser ) {
 263+ // For some reason, the #set_internal calls on a page are
 264+ // sometimes called twice (or more?). Ideally, there would
 265+ // be a way to prevent that, but until then, we use the
 266+ // $mHandledPages array to store pages whose internal objects
 267+ // have already been created - if doSetInternal() is called
 268+ // on a page whose name is already is in this array, the
 269+ // page is ignored.
 270+ if ( ! empty( self::$mCurPageFullName ) ) {
 271+ self::$mHandledPages[] = self::$mCurPageFullName;
 272+ }
 273+ self::$mCurPageFullName = '';
 274+ self::$mInternalObjectIndex = 1;
 275+ return true;
 276+ }
 277+
 278+ /**
 279+ * Handle the #set_internal parser function.
 280+ */
 281+ public static function doSetInternal( &$parser ) {
 282+ $title = $parser->getTitle();
 283+ $mainPageFullName = $title->getText();
 284+ if ( ( $nsText = $title->getNsText() ) != '' ) {
 285+ $mainPageFullName = $nsText . ':' . $mainPageFullName;
 286+ }
 287+
 288+ if ( in_array( $mainPageFullName, self::$mHandledPages ) ) {
 289+ // The #set_internal calls for this page have already
 290+ // been processed! Skip it.
 291+ return;
 292+ }
 293+
 294+ if ( $mainPageFullName == self::$mCurPageFullName ) {
 295+ self::$mInternalObjectIndex++;
 296+ } else {
 297+ self::$mCurPageFullName = $mainPageFullName;
 298+ self::$mInternalObjectIndex = 1;
 299+ }
 300+ $curObjectNum = self::$mInternalObjectIndex;
 301+ $params = func_get_args();
 302+ array_shift( $params ); // we already know the $parser...
 303+ $internalObject = new SIOInternalObject( $title, $curObjectNum );
 304+ $objToPagePropName = array_shift( $params );
 305+ $internalObject->addPropertyAndValue( $objToPagePropName, self::$mCurPageFullName );
 306+ foreach ( $params as $param ) {
 307+ $parts = explode( "=", trim( $param ), 2 );
 308+ if ( count( $parts ) == 2 ) {
 309+ $key = $parts[0];
 310+ $value = $parts[1];
 311+ // if the property name ends with '#list', it's
 312+ // a comma-delimited group of values
 313+ if ( substr( $key, - 5 ) == '#list' ) {
 314+ $key = substr( $key, 0, strlen( $key ) - 5 );
 315+ $listValues = explode( ',', $value );
 316+ foreach ( $listValues as $listValue ) {
 317+ $internalObject->addPropertyAndValue( $key, trim( $listValue ) );
 318+ }
 319+ } else {
 320+ $internalObject->addPropertyAndValue( $key, $value );
 321+ }
 322+ }
 323+ }
 324+ self::$mInternalObjects[] = $internalObject;
 325+ }
 326+
 327+ /**
 328+ * Handle the #set_internal_recurring_event parser function.
 329+ */
 330+ public static function doSetInternalRecurringEvent( &$parser ) {
 331+ $params = func_get_args();
 332+ array_shift( $params ); // We already know the $parser ...
 333+
 334+ // first param should be a standalone property name
 335+ $objToPagePropName = array_shift( $params );
 336+
 337+ $results = SMWParserExtensions::getDatesForRecurringEvent( $params );
 338+ if ( $results == null ) {
 339+ return null;
 340+ }
 341+
 342+ list( $property, $all_date_strings, $unused_params ) = $results;
 343+
 344+ // Mimic a call to #set_internal for each date.
 345+ foreach ( $all_date_strings as $date_string ) {
 346+ $first_params = array(
 347+ $parser,
 348+ $objToPagePropName,
 349+ "$property=$date_string"
 350+ );
 351+ $cur_params = array_merge( $first_params, $unused_params );
 352+ call_user_func_array( 'SIOHandler::doSetInternal', $cur_params );
 353+ }
 354+ }
 355+
 356+ /**
 357+ * Called when a page is deleted.
 358+ */
 359+ public static function deleteData( $sqlStore, $subject ) {
 360+ SIOSQLStore::deleteDataForPage( $subject );
 361+ return true;
 362+ }
 363+
 364+ /**
 365+ * Called when a page's semantic data is updated - either it's been
 366+ * modified, or one of its templates has been modified, or an SMW
 367+ * "refresh data" action has been called.
 368+ */
 369+ public static function updateData( $sqlStore, $data ) {
 370+ $sioSQLStore = new SIOSQLStore();
 371+ // Find all "pages" in the SMW IDs table that are internal
 372+ // objects for this page, and delete their properties from
 373+ // the SMW tables.
 374+ // Then save the current contents of the $mInternalObjects
 375+ // array.
 376+ $subject = $data->getSubject();
 377+ SIOSQLStore::deleteDataForPage( $subject );
 378+
 379+ $allRels2Inserts = array();
 380+ $allAtts2Inserts = array();
 381+ $allText2Inserts = array();
 382+ $allCoordsInserts = array();
 383+ foreach ( self::$mInternalObjects as $internalObject ) {
 384+ list( $upRels2, $upAtts2, $upText2, $upCoords ) = $sioSQLStore->getStorageSQL( $internalObject );
 385+ $allRels2Inserts = array_merge( $allRels2Inserts, $upRels2 );
 386+ $allAtts2Inserts = array_merge( $allAtts2Inserts, $upAtts2 );
 387+ $allText2Inserts = array_merge( $allText2Inserts, $upText2 );
 388+ $allCoordsInserts = array_merge( $allCoordsInserts, $upCoords );
 389+ }
 390+
 391+ // now save everything to the database, in a single transaction
 392+ $db = wfGetDB( DB_MASTER );
 393+ $db->begin( 'SIO::updatePageData' );
 394+
 395+ if ( count( $allRels2Inserts ) > 0 ) {
 396+ $db->insert( 'smw_rels2', $allRels2Inserts, 'SIO::updateRels2Data' );
 397+ }
 398+ if ( count( $allAtts2Inserts ) > 0 ) {
 399+ $db->insert( 'smw_atts2', $allAtts2Inserts, 'SIO::updateAtts2Data' );
 400+ }
 401+ if ( count( $allText2Inserts ) > 0 ) {
 402+ $db->insert( 'smw_text2', $allText2Inserts, 'SIO::updateText2Data' );
 403+ }
 404+ if ( count( $allCoordsInserts ) > 0 ) {
 405+ $db->insert( 'sm_coords', $allCoordsInserts, 'SIO::updateCoordsData' );
 406+ }
 407+ // end transaction
 408+ $db->commit( 'SIO::updatePageData' );
 409+ self::$mInternalObjects = array();
 410+ return true;
 411+ }
 412+
 413+ /**
 414+ * Called after a page is moved - renames all the internal objects
 415+ * named "Old page#x" to "New page#x".
 416+ */
 417+ static public function handlePageMove( &$old_title, &$new_title, &$user, $page_id, $redir_id ) {
 418+ $oldPageName = $old_title->getDBkey();
 419+ $oldNamespace = $old_title->getNamespace();
 420+ $newPageName = $new_title->getDBkey();
 421+ $newNamespace = $new_title->getNamespace();
 422+ $iw = '';
 423+ $sioNames = array();
 424+ $db = wfGetDB( DB_SLAVE );
 425+ // Unfortunately, there's no foolproof way to do the replacement
 426+ // with a single SQL call, using regexps and wildcards -
 427+ // instead, we first get the set of all matching entries in
 428+ // the 'smw_ids' table, then call an explicit update on each
 429+ // one.
 430+ $res = $db->select(
 431+ 'smw_ids',
 432+ array( 'smw_title' ),
 433+ 'smw_title LIKE ' . $db->addQuotes( $oldPageName . '#%' ) . ' AND ' . 'smw_namespace=' . $db->addQuotes( $oldNamespace ) . ' AND smw_iw=' . $db->addQuotes( $iw ),
 434+ 'SIO::getTitlesForPageMove'
 435+ );
 436+ while ( $row = $db->fetchObject( $res ) ) {
 437+ $sioNames[] = $row->smw_title;
 438+ }
 439+ foreach ( $sioNames as $sioName ) {
 440+ // update the name, and possibly the namespace as well
 441+ $newSIOName = str_replace( $oldPageName, $newPageName, $sioName );
 442+ $db->update(
 443+ 'smw_ids',
 444+ array( 'smw_title' => $newSIOName, 'smw_namespace' => $newNamespace ),
 445+ array( 'smw_title' => $sioName, 'smw_namespace' => $oldNamespace ),
 446+ 'SIO::updateTitlesForPageMove'
 447+ );
 448+ }
 449+ return true;
 450+ }
 451+
 452+ /**
 453+ * Takes a set of SMW "update jobs", and keeps only the unique, actual
 454+ * titles among them - this is useful if there are any internal objects
 455+ * among the group; a set of names like "Page name#1", "Page name#2"
 456+ * etc. should be turned into just "Page name".
 457+ */
 458+ static function handleUpdatingOfInternalObjects( &$jobs ) {
 459+ $uniqueTitles = array();
 460+ foreach ( $jobs as $i => $job ) {
 461+ $title = Title::makeTitleSafe( $job->title->getNamespace(), $job->title->getText() );
 462+ $id = $title->getArticleID();
 463+ $uniqueTitles[$id] = $title;
 464+ }
 465+ $jobs = array();
 466+ foreach ( $uniqueTitles as $id => $title ) {
 467+ $jobs[] = new SMWUpdateJob( $title );
 468+ }
 469+ return true;
 470+ }
 471+
 472+ /**
 473+ * Takes a set of SMW "update jobs" generated by refresh data and removes
 474+ * any job with a fragment (in other words a job trying to update a SIO object)
 475+ * We aren't guaranteed that all the jobs related to a single page using SIO
 476+ * will be in a single one of these batches so we remove everything updating
 477+ * a SIO object instead of filtering them down to unique titles.
 478+ */
 479+ static function handleRefreshingOfInternalObjects( &$jobs ) {
 480+ $allJobs = $jobs;
 481+ $jobs = array();
 482+ foreach ( $allJobs as $job ) {
 483+ if ( strpos( $job->title->getText(), '#' ) === false )
 484+ $jobs[] = $job;
 485+ }
 486+ return true;
 487+ }
 488+}
Property changes on: tags/extensions/SemanticInternalObjects/REL_0_6_2/SemanticInternalObjects_body.php
___________________________________________________________________
Added: svn:eol-style
1489 + native
Index: tags/extensions/SemanticInternalObjects/REL_0_6_2/SemanticInternalObjects.i18n.php
@@ -0,0 +1,306 @@
 2+<?php
 3+/**
 4+ * Internationalization file for Semantic Internal Objects
 5+ *
 6+ * @file
 7+ * @ingroup Language
 8+ * @ingroup I18n
 9+ * @ingroup SemanticInternalObjects
 10+ */
 11+
 12+// FIXME: Can be enabled when new style magic words are used (introduced in r52503)
 13+// require_once( dirname( __FILE__ ) . '/SemanticInternalObjects.i18n.magic.php' );
 14+
 15+$messages = array();
 16+
 17+/** English
 18+ * @author Yaron Koren
 19+ */
 20+$messages['en'] = array(
 21+ 'semanticinternalobjects-desc' => 'Setting of internal objects in Semantic MediaWiki',
 22+);
 23+
 24+/** Message documentation (Message documentation)
 25+ * @author Yaron Koren
 26+ */
 27+$messages['qqq'] = array(
 28+ 'semanticinternalobjects-desc' => '{{desc}}',
 29+);
 30+
 31+/** Gheg Albanian (Gegë)
 32+ * @author Mdupont
 33+ */
 34+$messages['aln'] = array(
 35+ 'semanticinternalobjects-desc' => 'Vendosja e objekteve të brendshëm në Semantic MediaWiki',
 36+);
 37+
 38+/** Arabic (العربية)
 39+ * @author Meno25
 40+ */
 41+$messages['ar'] = array(
 42+ 'semanticinternalobjects-desc' => 'ضبط الأشياء الداخلية في ميدياويكي الدلالي',
 43+);
 44+
 45+/** Belarusian (Taraškievica orthography) (Беларуская (тарашкевіца))
 46+ * @author EugeneZelenko
 47+ */
 48+$messages['be-tarask'] = array(
 49+ 'semanticinternalobjects-desc' => "Устаноўкі ўнутраных аб'ектаў у Semantic MediaWiki",
 50+);
 51+
 52+/** Breton (Brezhoneg)
 53+ * @author Fulup
 54+ */
 55+$messages['br'] = array(
 56+ 'semanticinternalobjects-desc' => 'Kefluniadur traezoù diabarzh e Semanctic MediaWiki',
 57+);
 58+
 59+/** Bosnian (Bosanski)
 60+ * @author CERminator
 61+ */
 62+$messages['bs'] = array(
 63+ 'semanticinternalobjects-desc' => 'Postavljanje unutrašnjih objekata u Semantic MediaWiki',
 64+);
 65+
 66+/** Catalan (Català)
 67+ * @author Toniher
 68+ */
 69+$messages['ca'] = array(
 70+ 'semanticinternalobjects-desc' => "Definició d'objectes interns en el Semantic MediaWiki",
 71+);
 72+
 73+/** German (Deutsch)
 74+ * @author Imre
 75+ * @author Kghbln
 76+ */
 77+$messages['de'] = array(
 78+ 'semanticinternalobjects-desc' => 'Ermöglicht die Definition interner Datenobjekte für Semantic MediaWiki mit Hilfe einer Parserfunktion',
 79+);
 80+
 81+/** Lower Sorbian (Dolnoserbski)
 82+ * @author Michawiki
 83+ */
 84+$messages['dsb'] = array(
 85+ 'semanticinternalobjects-desc' => 'Nastajenje internych objektow w Semantic MediaWiki',
 86+);
 87+
 88+/** Greek (Ελληνικά)
 89+ * @author Omnipaedista
 90+ */
 91+$messages['el'] = array(
 92+ 'semanticinternalobjects-desc' => 'Ρυθμίσεις εσωτερικών αντικειμένων στη Σημασιολογική MediaWiki',
 93+);
 94+
 95+/** Spanish (Español)
 96+ * @author Crazymadlover
 97+ */
 98+$messages['es'] = array(
 99+ 'semanticinternalobjects-desc' => 'Configuración de objetos internos en Semantic MediaWiki',
 100+);
 101+
 102+/** Finnish (Suomi)
 103+ * @author Centerlink
 104+ * @author Crt
 105+ */
 106+$messages['fi'] = array(
 107+ 'semanticinternalobjects-desc' => 'Sisäisten objektien asetukset semanttisessa MediaWikissä.',
 108+);
 109+
 110+/** French (Français)
 111+ * @author Crochet.david
 112+ */
 113+$messages['fr'] = array(
 114+ 'semanticinternalobjects-desc' => 'Réglage des objets internes dans Semantic MediaWiki',
 115+);
 116+
 117+/** Galician (Galego)
 118+ * @author Toliño
 119+ */
 120+$messages['gl'] = array(
 121+ 'semanticinternalobjects-desc' => 'Configuracións de obxectos internos en Semantic MediaWiki',
 122+);
 123+
 124+/** Swiss German (Alemannisch)
 125+ * @author Als-Holder
 126+ */
 127+$messages['gsw'] = array(
 128+ 'semanticinternalobjects-desc' => 'Intärni Objäkt in Semantic MediaWiki yysetze',
 129+);
 130+
 131+/** Hebrew (עברית)
 132+ * @author Rotemliss
 133+ * @author YaronSh
 134+ */
 135+$messages['he'] = array(
 136+ 'semanticinternalobjects-desc' => 'הגדרות העצמים הפנימיים במדיה־ויקי הסמנטי',
 137+);
 138+
 139+/** Hiligaynon (Ilonggo)
 140+ * @author Tagimata
 141+ */
 142+$messages['hil'] = array(
 143+ 'semanticinternalobjects-desc' => 'Pagplastar sang internal na mga bagay sa Semantik MedyaWiki',
 144+);
 145+
 146+/** Upper Sorbian (Hornjoserbsce)
 147+ * @author Michawiki
 148+ */
 149+$messages['hsb'] = array(
 150+ 'semanticinternalobjects-desc' => 'Nastajenje internych objektow w Semantic MediaWiki',
 151+);
 152+
 153+/** Hungarian (Magyar)
 154+ * @author Glanthor Reviol
 155+ */
 156+$messages['hu'] = array(
 157+ 'semanticinternalobjects-desc' => 'Belső objektumok beállítása a szemantikus MediaWikiben',
 158+);
 159+
 160+/** Interlingua (Interlingua)
 161+ * @author McDutchie
 162+ */
 163+$messages['ia'] = array(
 164+ 'semanticinternalobjects-desc' => 'Configuration de objectos interne in Semantic MediaWiki',
 165+);
 166+
 167+/** Indonesian (Bahasa Indonesia)
 168+ * @author Bennylin
 169+ */
 170+$messages['id'] = array(
 171+ 'semanticinternalobjects-desc' => 'Seting untuk objek internal pada Semantic MediaWiki',
 172+);
 173+
 174+/** Italian (Italiano)
 175+ * @author Gianfranco
 176+ */
 177+$messages['it'] = array(
 178+ 'semanticinternalobjects-desc' => 'Configurazione degli oggetti interni in Semantic MediaWiki',
 179+);
 180+
 181+/** Japanese (日本語)
 182+ * @author Fryed-peach
 183+ */
 184+$messages['ja'] = array(
 185+ 'semanticinternalobjects-desc' => 'Semantic MediaWiki の内部オブジェクトの設定',
 186+);
 187+
 188+/** Colognian (Ripoarisch)
 189+ * @author Purodha
 190+ */
 191+$messages['ksh'] = array(
 192+ 'semanticinternalobjects-desc' => 'De ennere Objäkte vum Semantesch MedijaWiki enschtälle.',
 193+);
 194+
 195+/** Luxembourgish (Lëtzebuergesch)
 196+ * @author Robby
 197+ */
 198+$messages['lb'] = array(
 199+ 'semanticinternalobjects-desc' => 'Astellung vun internen Objeten a Semantic MediaWiki',
 200+);
 201+
 202+/** Macedonian (Македонски)
 203+ * @author Bjankuloski06
 204+ */
 205+$messages['mk'] = array(
 206+ 'semanticinternalobjects-desc' => 'Поставање на внатрешни објекти во Semantic MediaWiki',
 207+);
 208+
 209+/** Dutch (Nederlands)
 210+ * @author Siebrand
 211+ */
 212+$messages['nl'] = array(
 213+ 'semanticinternalobjects-desc' => 'Interne objecten in Semantic MediaWiki instellen',
 214+);
 215+
 216+/** Norwegian (bokmål)‬ (‪Norsk (bokmål)‬)
 217+ * @author Nghtwlkr
 218+ */
 219+$messages['no'] = array(
 220+ 'semanticinternalobjects-desc' => 'Innstilling for interne objekt i Semantic MediaWiki',
 221+);
 222+
 223+/** Occitan (Occitan)
 224+ * @author Cedric31
 225+ */
 226+$messages['oc'] = array(
 227+ 'semanticinternalobjects-desc' => 'Reglatge dels objèctes intèrnes dins Semantic MediaWiki',
 228+);
 229+
 230+/** Polish (Polski)
 231+ * @author Sp5uhe
 232+ */
 233+$messages['pl'] = array(
 234+ 'semanticinternalobjects-desc' => 'Ustawianie wewnętrznych obiektów Semantic MediaWiki.',
 235+);
 236+
 237+/** Piedmontese (Piemontèis)
 238+ * @author Dragonòt
 239+ */
 240+$messages['pms'] = array(
 241+ 'semanticinternalobjects-desc' => "Ampostassion d'oget intern an drinta a Semantic MediaWiki",
 242+);
 243+
 244+/** Portuguese (Português)
 245+ * @author Hamilton Abreu
 246+ * @author Indech
 247+ */
 248+$messages['pt'] = array(
 249+ 'semanticinternalobjects-desc' => 'Configuração de objetos internos no MediaWiki Semântico',
 250+);
 251+
 252+/** Brazilian Portuguese (Português do Brasil)
 253+ * @author Eduardo.mps
 254+ */
 255+$messages['pt-br'] = array(
 256+ 'semanticinternalobjects-desc' => 'Definição de objetos internos no Semantic MediaWiki',
 257+);
 258+
 259+/** Tarandíne (Tarandíne)
 260+ * @author Joetaras
 261+ */
 262+$messages['roa-tara'] = array(
 263+ 'semanticinternalobjects-desc' => "'Mboste le oggette inderne jndr'à MediaUicchi Semandiche",
 264+);
 265+
 266+/** Russian (Русский)
 267+ * @author Александр Сигачёв
 268+ */
 269+$messages['ru'] = array(
 270+ 'semanticinternalobjects-desc' => 'Установка внутренних объектов в Semantic MediaWiki',
 271+);
 272+
 273+/** Slovak (Slovenčina)
 274+ * @author Helix84
 275+ */
 276+$messages['sk'] = array(
 277+ 'semanticinternalobjects-desc' => 'Nastavenie vnútorných objektov v Semantic MediaWiki',
 278+);
 279+
 280+/** Swedish (Svenska)
 281+ * @author Per
 282+ */
 283+$messages['sv'] = array(
 284+ 'semanticinternalobjects-desc' => 'Inställning för interna objekt i Semantic MediaWiki',
 285+);
 286+
 287+/** Tagalog (Tagalog)
 288+ * @author AnakngAraw
 289+ */
 290+$messages['tl'] = array(
 291+ 'semanticinternalobjects-desc' => 'Pagtatakda ng panloob na mga bagay sa Semantic MediaWiki',
 292+);
 293+
 294+/** Turkish (Türkçe)
 295+ * @author Vito Genovese
 296+ */
 297+$messages['tr'] = array(
 298+ 'semanticinternalobjects-desc' => "Anlamsal MediaWiki'deki iç nesnelerin ayarlanması",
 299+);
 300+
 301+/** Vietnamese (Tiếng Việt)
 302+ * @author Minh Nguyen
 303+ */
 304+$messages['vi'] = array(
 305+ 'semanticinternalobjects-desc' => 'Thiết kế các đối tượng nội bộ trong Semantic MediaWiki',
 306+);
 307+
Property changes on: tags/extensions/SemanticInternalObjects/REL_0_6_2/SemanticInternalObjects.i18n.php
___________________________________________________________________
Added: svn:eol-style
1308 + native

Status & tagging log