Index: tags/extensions/SemanticInternalObjects/REL_0_6/SemanticInternalObjects.php |
— | — | @@ -0,0 +1,47 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Initialization file for SemanticInternalObjects |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup SemanticInternalObjects |
| 8 | + * @author Yaron Koren |
| 9 | + */ |
| 10 | + |
| 11 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
| 12 | + |
| 13 | +define( 'SIO_VERSION', '0.6' ); |
| 14 | + |
| 15 | +$wgExtensionCredits['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['smwDeleteSemanticData'][] = 'SIOHandler::updateData'; |
| 28 | +$wgHooks['smwUpdatePropertySubjects'][] = 'SIOHandler::handleUpdatingOfInternalObjects'; |
| 29 | +$wgHooks['smwRefreshDataJobs'][] = 'SIOHandler::handleRefreshingOfInternalObjects'; |
| 30 | +$wgHooks['smwAddToRDFExport'][] = 'SIOSQLStore::createRDF'; |
| 31 | + |
| 32 | +$siogIP = dirname( __FILE__ ); |
| 33 | +$wgExtensionMessagesFiles['SemanticInternalObjects'] = $siogIP . '/SemanticInternalObjects.i18n.php'; |
| 34 | +$wgAutoloadClasses['SIOHandler'] = $siogIP . '/SemanticInternalObjects_body.php'; |
| 35 | +$wgAutoloadClasses['SIOSQLStore'] = $siogIP . '/SemanticInternalObjects_body.php'; |
| 36 | + |
| 37 | +function siofRegisterParserFunctions( &$parser ) { |
| 38 | + $parser->setFunctionHook( 'set_internal', array( 'SIOHandler', 'doSetInternal' ) ); |
| 39 | + return true; // always return true, in order not to stop MW's hook processing! |
| 40 | +} |
| 41 | + |
| 42 | +function siofLanguageGetMagic( &$magicWords, $langCode = "en" ) { |
| 43 | + switch ( $langCode ) { |
| 44 | + default: |
| 45 | + $magicWords['set_internal'] = array ( 0, 'set_internal' ); |
| 46 | + } |
| 47 | + return true; |
| 48 | +} |
Property changes on: tags/extensions/SemanticInternalObjects/REL_0_6/SemanticInternalObjects.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 49 | + native |
Index: tags/extensions/SemanticInternalObjects/REL_0_6/README |
— | — | @@ -0,0 +1,89 @@ |
| 2 | +Semantic Internal Objects Extension |
| 3 | + |
| 4 | + Version 0.6 |
| 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/README |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 91 | + native |
Index: tags/extensions/SemanticInternalObjects/REL_0_6/SemanticInternalObjects.i18n.magic.php |
— | — | @@ -0,0 +1,19 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +$magicWords = array(); |
| 5 | + |
| 6 | +$magicWords['en'] = array( |
| 7 | + 'set_internal' => array( 0, 'set_internal' ), |
| 8 | +); |
| 9 | + |
| 10 | +$magicWords['ar'] = array( |
| 11 | + 'set_internal' => array( '0', 'ضبط_داخلي', 'set_internal' ), |
| 12 | +); |
| 13 | + |
| 14 | +$magicWords['arz'] = array( |
| 15 | + 'set_internal' => array( '0', 'ضبط_داخلي', 'set_internal' ), |
| 16 | +); |
| 17 | + |
| 18 | +$magicWords['nl'] = array( |
| 19 | + 'set_internal' => array( '0', 'intern_instellen', 'set_internal' ), |
| 20 | +); |
Property changes on: tags/extensions/SemanticInternalObjects/REL_0_6/SemanticInternalObjects.i18n.magic.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 21 | + native |
Index: tags/extensions/SemanticInternalObjects/REL_0_6/SemanticInternalObjects_body.php |
— | — | @@ -0,0 +1,379 @@ |
| 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 getIDsForDeletion( $pageName, $namespace ) { |
| 111 | + $ids = array(); |
| 112 | + |
| 113 | + $iw = ''; |
| 114 | + $db = wfGetDB( DB_SLAVE ); |
| 115 | + $res = $db->select( 'smw_ids', array( 'smw_id' ), 'smw_title LIKE ' . $db->addQuotes( $pageName . '#%' ) . ' AND ' . 'smw_namespace=' . $db->addQuotes( $namespace ) . ' AND smw_iw=' . $db->addQuotes( $iw ), 'SIO::getSMWPageObjectIDs', array() ); |
| 116 | + while ( $row = $db->fetchObject( $res ) ) { |
| 117 | + $ids[] = $row->smw_id; |
| 118 | + } |
| 119 | + return $ids; |
| 120 | + } |
| 121 | + |
| 122 | + function getStorageSQL( $internalObject ) { |
| 123 | + $ioID = $this->makeSMWPageID( $internalObject->getName(), $internalObject->getNamespace(), '' ); |
| 124 | + $upRels2 = array(); |
| 125 | + $upAtts2 = array(); |
| 126 | + $upText2 = array(); |
| 127 | + $upCoords = array(); |
| 128 | + // set all the properties pointing from this internal object |
| 129 | + foreach ( $internalObject->getPropertyValuePairs() as $propertyValuePair ) { |
| 130 | + list( $property, $value ) = $propertyValuePair; |
| 131 | + // handling changed in SMW 1.5 |
| 132 | + if ( method_exists( 'SMWSQLStore2', 'findPropertyTableID' ) ) { |
| 133 | + $tableid = SMWSQLStore2::findPropertyTableID( $property ); |
| 134 | + $isRelation = ( $tableid == 'smw_rels2' ); |
| 135 | + $isAttribute = ( $tableid == 'smw_atts2' ); |
| 136 | + $isText = ( $tableid == 'smw_text2' ); |
| 137 | + // new with SMW 1.5.1 / SM 0.6 |
| 138 | + $isCoords = ( $tableid == 'smw_coords' ); |
| 139 | + } else { |
| 140 | + $mode = SMWSQLStore2::getStorageMode( $property->getPropertyTypeID() ); |
| 141 | + $isRelation = ( $mode == SMW_SQL2_RELS2 ); |
| 142 | + $isAttribute = ( $mode == SMW_SQL2_ATTS2 ); |
| 143 | + $isText = ( $mode == SMW_SQL2_TEXT2 ); |
| 144 | + $isCoords = false; |
| 145 | + } |
| 146 | + if ( $isRelation ) { |
| 147 | + $upRels2[] = array( |
| 148 | + 's_id' => $ioID, |
| 149 | + 'p_id' => $this->makeSMWPropertyID( $property ), |
| 150 | + 'o_id' => $this->makeSMWPageID( $value->getDBkey(), $value->getNamespace(), $value->getInterwiki() ) |
| 151 | + ); |
| 152 | + } elseif ( $isAttribute ) { |
| 153 | + $keys = $value->getDBkeys(); |
| 154 | + if ( method_exists( $value, 'getValueKey' ) ) { |
| 155 | + $valueNum = $value->getValueKey(); |
| 156 | + } else { |
| 157 | + $valueNum = $value->getNumericValue(); |
| 158 | + } |
| 159 | + $upAtts2[] = array( |
| 160 | + 's_id' => $ioID, |
| 161 | + 'p_id' => $this->makeSMWPropertyID( $property ), |
| 162 | + 'value_unit' => $value->getUnit(), |
| 163 | + 'value_xsd' => $keys[0], |
| 164 | + 'value_num' => $valueNum |
| 165 | + ); |
| 166 | + } elseif ( $isText ) { |
| 167 | + $keys = $value->getDBkeys(); |
| 168 | + $upText2[] = array( |
| 169 | + 's_id' => $ioID, |
| 170 | + 'p_id' => $this->makeSMWPropertyID( $property ), |
| 171 | + 'value_blob' => $keys[0] |
| 172 | + ); |
| 173 | + } elseif ( $isCoords ) { |
| 174 | + $keys = $value->getDBkeys(); |
| 175 | + $upCoords[] = array( |
| 176 | + 's_id' => $ioID, |
| 177 | + 'p_id' => $this->makeSMWPropertyID( $property ), |
| 178 | + 'lat' => $keys[0], |
| 179 | + 'lon' => $keys[1], |
| 180 | + ); |
| 181 | + } |
| 182 | + } |
| 183 | + return array( $upRels2, $upAtts2, $upText2, $upCoords ); |
| 184 | + } |
| 185 | + |
| 186 | + static function createRDF( $title, $rdfDataArray, $fullexport = true, $backlinks = false ) { |
| 187 | + // if it's not a full export, don't add internal object data |
| 188 | + if ( !$fullexport ) { |
| 189 | + return true; |
| 190 | + } |
| 191 | + |
| 192 | + $pageName = $title->getDBkey(); |
| 193 | + $namespace = $title->getNamespace(); |
| 194 | + |
| 195 | + // go through all SIOs for the current page, create RDF for |
| 196 | + // each one, and add it to the general array |
| 197 | + $iw = ''; |
| 198 | + $db = wfGetDB( DB_SLAVE ); |
| 199 | + $res = $db->select( 'smw_ids', array( 'smw_id', 'smw_namespace', 'smw_title' ), 'smw_title LIKE ' . $db->addQuotes( $pageName . '#%' ) . ' AND ' . 'smw_namespace=' . $db->addQuotes( $namespace ) . ' AND smw_iw=' . $db->addQuotes( $iw ), 'SIO::getSMWPageObjectIDs', array() ); |
| 200 | + while ( $row = $db->fetchObject( $res ) ) { |
| 201 | + $value = new SIOInternalObjectValue( $row->smw_title, $row->smw_namespace ); |
| 202 | + $semdata = new SMWSemanticData( $value, false ); |
| 203 | + $propertyTables = SMWSQLStore2::getPropertyTables(); |
| 204 | + foreach ( $propertyTables as $tableName => $propertyTable ) { |
| 205 | + $data = smwfGetStore()->fetchSemanticData( $row->smw_id, null, $propertyTable ); |
| 206 | + foreach ( $data as $d ) { |
| 207 | + $semdata->addPropertyStubValue( reset( $d ), end( $d ) ); |
| 208 | + } |
| 209 | + } |
| 210 | + $rdfDataArray[] = SMWExporter::makeExportData( $semdata, null ); |
| 211 | + } |
| 212 | + return true; |
| 213 | + } |
| 214 | +} |
| 215 | + |
| 216 | +/** |
| 217 | + * Class for hook functions for creating and storing information |
| 218 | + */ |
| 219 | +class SIOHandler { |
| 220 | + |
| 221 | + static $mCurPageFullName = ''; |
| 222 | + static $mInternalObjectIndex = 1; |
| 223 | + static $mInternalObjects = array(); |
| 224 | + static $mHandledPages = array(); |
| 225 | + |
| 226 | + public static function clearState( &$parser ) { |
| 227 | + // For some reason, the #set_internal calls on a page are |
| 228 | + // sometimes called twice (or more?). Ideally, there would |
| 229 | + // be a way to prevent that, but until then, we use the |
| 230 | + // $mHandledPages array to store pages whose internal objects |
| 231 | + // have already been created - if doSetInternal() is called |
| 232 | + // on a page whose name is already is in this array, the |
| 233 | + // page is ignored. |
| 234 | + if ( ! empty( self::$mCurPageFullName ) ) { |
| 235 | + self::$mHandledPages[] = self::$mCurPageFullName; |
| 236 | + } |
| 237 | + self::$mCurPageFullName = ''; |
| 238 | + self::$mInternalObjectIndex = 1; |
| 239 | + return true; |
| 240 | + } |
| 241 | + |
| 242 | + public static function doSetInternal( &$parser ) { |
| 243 | + $title = $parser->getTitle(); |
| 244 | + $mainPageFullName = $title->getText(); |
| 245 | + if ( ( $nsText = $title->getNsText() ) != '' ) { |
| 246 | + $mainPageFullName = $nsText . ':' . $mainPageFullName; |
| 247 | + } |
| 248 | + |
| 249 | + if ( in_array( $mainPageFullName, self::$mHandledPages ) ) { |
| 250 | + // The #set_internal calls for this page have already |
| 251 | + // been processed! Skip it. |
| 252 | + return; |
| 253 | + } |
| 254 | + |
| 255 | + if ( $mainPageFullName == self::$mCurPageFullName ) { |
| 256 | + self::$mInternalObjectIndex++; |
| 257 | + } else { |
| 258 | + self::$mCurPageFullName = $mainPageFullName; |
| 259 | + self::$mInternalObjectIndex = 1; |
| 260 | + } |
| 261 | + $curObjectNum = self::$mInternalObjectIndex; |
| 262 | + $params = func_get_args(); |
| 263 | + array_shift( $params ); // we already know the $parser... |
| 264 | + $internalObject = new SIOInternalObject( $title, $curObjectNum ); |
| 265 | + $objToPagePropName = array_shift( $params ); |
| 266 | + $internalObject->addPropertyAndValue( $objToPagePropName, self::$mCurPageFullName ); |
| 267 | + foreach ( $params as $param ) { |
| 268 | + $parts = explode( "=", trim( $param ), 2 ); |
| 269 | + if ( count( $parts ) == 2 ) { |
| 270 | + $key = $parts[0]; |
| 271 | + $value = $parts[1]; |
| 272 | + // if the property name ends with '#list', it's |
| 273 | + // a comma-delimited group of values |
| 274 | + if ( substr( $key, - 5 ) == '#list' ) { |
| 275 | + $key = substr( $key, 0, strlen( $key ) - 5 ); |
| 276 | + $listValues = explode( ',', $value ); |
| 277 | + foreach ( $listValues as $listValue ) { |
| 278 | + $internalObject->addPropertyAndValue( $key, trim( $listValue ) ); |
| 279 | + } |
| 280 | + } else { |
| 281 | + $internalObject->addPropertyAndValue( $key, $value ); |
| 282 | + } |
| 283 | + } |
| 284 | + } |
| 285 | + self::$mInternalObjects[] = $internalObject; |
| 286 | + } |
| 287 | + |
| 288 | + public static function updateData( $subject ) { |
| 289 | + $sioSQLStore = new SIOSQLStore(); |
| 290 | + // Find all "pages" in the SMW IDs table that are internal |
| 291 | + // objects for this page, and delete their properties from |
| 292 | + // the SMW tables. |
| 293 | + // Then save the current contents of the $mInternalObjects |
| 294 | + // array. |
| 295 | + $pageName = $subject->getDBKey(); |
| 296 | + $namespace = $subject->getNamespace(); |
| 297 | + $idsForDeletion = SIOSQLStore::getIDsForDeletion( $pageName, $namespace ); |
| 298 | + |
| 299 | + $allRels2Inserts = array(); |
| 300 | + $allAtts2Inserts = array(); |
| 301 | + $allText2Inserts = array(); |
| 302 | + $allCoordsInserts = array(); |
| 303 | + foreach ( self::$mInternalObjects as $internalObject ) { |
| 304 | + list( $upRels2, $upAtts2, $upText2, $upCoords ) = $sioSQLStore->getStorageSQL( $internalObject ); |
| 305 | + $allRels2Inserts = array_merge( $allRels2Inserts, $upRels2 ); |
| 306 | + $allAtts2Inserts = array_merge( $allAtts2Inserts, $upAtts2 ); |
| 307 | + $allText2Inserts = array_merge( $allText2Inserts, $upText2 ); |
| 308 | + $allCoordsInserts = array_merge( $allCoordsInserts, $upCoords ); |
| 309 | + } |
| 310 | + |
| 311 | + // now save everything to the database, in a single transaction |
| 312 | + $db = wfGetDB( DB_MASTER ); |
| 313 | + $db->begin( 'SIO::updatePageData' ); |
| 314 | + if ( count( $idsForDeletion ) > 0 ) { |
| 315 | + $idsString = '(' . implode ( ', ', $idsForDeletion ) . ')'; |
| 316 | + $db->delete( 'smw_rels2', array( "(s_id IN $idsString) OR (o_id IN $idsString)" ), 'SIO::deleteRels2Data' ); |
| 317 | + $db->delete( 'smw_atts2', array( "s_id IN $idsString" ), 'SIO::deleteAtts2Data' ); |
| 318 | + $db->delete( 'smw_text2', array( "s_id IN $idsString" ), 'SIO::deleteText2Data' ); |
| 319 | + // handle the sm_coords table only if the Semantic |
| 320 | + // Maps extension is installed and uses sm_coords |
| 321 | + if ( defined( 'SM_VERSION' ) && version_compare( SM_VERSION, '0.6' ) >= 0 ) { |
| 322 | + $db->delete( 'sm_coords', array( "s_id IN $idsString" ), 'SIO::deleteCoordsData' ); |
| 323 | + } |
| 324 | + } |
| 325 | + |
| 326 | + if ( count( $allRels2Inserts ) > 0 ) { |
| 327 | + $db->insert( 'smw_rels2', $allRels2Inserts, 'SIO::updateRels2Data' ); |
| 328 | + } |
| 329 | + if ( count( $allAtts2Inserts ) > 0 ) { |
| 330 | + $db->insert( 'smw_atts2', $allAtts2Inserts, 'SIO::updateAtts2Data' ); |
| 331 | + } |
| 332 | + if ( count( $allText2Inserts ) > 0 ) { |
| 333 | + $db->insert( 'smw_text2', $allText2Inserts, 'SIO::updateText2Data' ); |
| 334 | + } |
| 335 | + if ( count( $allCoordsInserts ) > 0 ) { |
| 336 | + $db->insert( 'sm_coords', $allCoordsInserts, 'SIO::updateCoordsData' ); |
| 337 | + } |
| 338 | + // end transaction |
| 339 | + $db->commit( 'SIO::updatePageData' ); |
| 340 | + self::$mInternalObjects = array(); |
| 341 | + return true; |
| 342 | + } |
| 343 | + |
| 344 | + /** |
| 345 | + * Takes a set of SMW "update jobs", and keeps only the unique, actual |
| 346 | + * titles among them - this is useful if there are any internal objects |
| 347 | + * among the group; a set of names like "Page name#1", "Page name#2" |
| 348 | + * etc. should be turned into just "Page name". |
| 349 | + */ |
| 350 | + static function handleUpdatingOfInternalObjects( &$jobs ) { |
| 351 | + $uniqueTitles = array(); |
| 352 | + foreach ( $jobs as $i => $job ) { |
| 353 | + $title = Title::makeTitleSafe( $job->title->getNamespace(), $job->title->getText() ); |
| 354 | + $id = $title->getArticleID(); |
| 355 | + $uniqueTitles[$id] = $title; |
| 356 | + } |
| 357 | + $jobs = array(); |
| 358 | + foreach ( $uniqueTitles as $id => $title ) { |
| 359 | + $jobs[] = new SMWUpdateJob( $title ); |
| 360 | + } |
| 361 | + return true; |
| 362 | + } |
| 363 | + |
| 364 | + /** |
| 365 | + * Takes a set of SMW "update jobs" generated by refresh data and removes |
| 366 | + * any job with a fragment (in other words a job trying to update a SIO object) |
| 367 | + * We aren't guaranteed that all the jobs related to a single page using SIO |
| 368 | + * will be in a single one of these batches so we remove everything updating |
| 369 | + * a SIO object instead of filtering them down to unique titles. |
| 370 | + */ |
| 371 | + static function handleRefreshingOfInternalObjects( &$jobs ) { |
| 372 | + $allJobs = $jobs; |
| 373 | + $jobs = array(); |
| 374 | + foreach ( $allJobs as $job ) { |
| 375 | + if ( strpos( $job->title->getText(), '#' ) === false ) |
| 376 | + $jobs[] = $job; |
| 377 | + } |
| 378 | + return true; |
| 379 | + } |
| 380 | +} |
Property changes on: tags/extensions/SemanticInternalObjects/REL_0_6/SemanticInternalObjects_body.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 381 | + native |
Index: tags/extensions/SemanticInternalObjects/REL_0_6/SemanticInternalObjects.i18n.php |
— | — | @@ -0,0 +1,305 @@ |
| 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 | + */ |
| 76 | +$messages['de'] = array( |
| 77 | + 'semanticinternalobjects-desc' => 'Einstellung interner Objekte in Semantic MediaWiki', |
| 78 | +); |
| 79 | + |
| 80 | +/** Lower Sorbian (Dolnoserbski) |
| 81 | + * @author Michawiki |
| 82 | + */ |
| 83 | +$messages['dsb'] = array( |
| 84 | + 'semanticinternalobjects-desc' => 'Nastajenje internych objektow w Semantic MediaWiki', |
| 85 | +); |
| 86 | + |
| 87 | +/** Greek (Ελληνικά) |
| 88 | + * @author Omnipaedista |
| 89 | + */ |
| 90 | +$messages['el'] = array( |
| 91 | + 'semanticinternalobjects-desc' => 'Ρυθμίσεις εσωτερικών αντικειμένων στη Σημασιολογική MediaWiki', |
| 92 | +); |
| 93 | + |
| 94 | +/** Spanish (Español) |
| 95 | + * @author Crazymadlover |
| 96 | + */ |
| 97 | +$messages['es'] = array( |
| 98 | + 'semanticinternalobjects-desc' => 'Configuración de objetos internos en Semantic MediaWiki', |
| 99 | +); |
| 100 | + |
| 101 | +/** Finnish (Suomi) |
| 102 | + * @author Centerlink |
| 103 | + * @author Crt |
| 104 | + */ |
| 105 | +$messages['fi'] = array( |
| 106 | + 'semanticinternalobjects-desc' => 'Sisäisten objektien asetukset semanttisessa MediaWikissä.', |
| 107 | +); |
| 108 | + |
| 109 | +/** French (Français) |
| 110 | + * @author Crochet.david |
| 111 | + */ |
| 112 | +$messages['fr'] = array( |
| 113 | + 'semanticinternalobjects-desc' => 'Réglage des objets internes dans Semantic MediaWiki', |
| 114 | +); |
| 115 | + |
| 116 | +/** Galician (Galego) |
| 117 | + * @author Toliño |
| 118 | + */ |
| 119 | +$messages['gl'] = array( |
| 120 | + 'semanticinternalobjects-desc' => 'Configuracións de obxectos internos en Semantic MediaWiki', |
| 121 | +); |
| 122 | + |
| 123 | +/** Swiss German (Alemannisch) |
| 124 | + * @author Als-Holder |
| 125 | + */ |
| 126 | +$messages['gsw'] = array( |
| 127 | + 'semanticinternalobjects-desc' => 'Intärni Objäkt in Semantic MediaWiki yysetze', |
| 128 | +); |
| 129 | + |
| 130 | +/** Hebrew (עברית) |
| 131 | + * @author Rotemliss |
| 132 | + * @author YaronSh |
| 133 | + */ |
| 134 | +$messages['he'] = array( |
| 135 | + 'semanticinternalobjects-desc' => 'הגדרות העצמים הפנימיים במדיה־ויקי הסמנטי', |
| 136 | +); |
| 137 | + |
| 138 | +/** Hiligaynon (Ilonggo) |
| 139 | + * @author Tagimata |
| 140 | + */ |
| 141 | +$messages['hil'] = array( |
| 142 | + 'semanticinternalobjects-desc' => 'Pagplastar sang internal na mga bagay sa Semantik MedyaWiki', |
| 143 | +); |
| 144 | + |
| 145 | +/** Upper Sorbian (Hornjoserbsce) |
| 146 | + * @author Michawiki |
| 147 | + */ |
| 148 | +$messages['hsb'] = array( |
| 149 | + 'semanticinternalobjects-desc' => 'Nastajenje internych objektow w Semantic MediaWiki', |
| 150 | +); |
| 151 | + |
| 152 | +/** Hungarian (Magyar) |
| 153 | + * @author Glanthor Reviol |
| 154 | + */ |
| 155 | +$messages['hu'] = array( |
| 156 | + 'semanticinternalobjects-desc' => 'Belső objektumok beállítása a szemantikus MediaWikiben', |
| 157 | +); |
| 158 | + |
| 159 | +/** Interlingua (Interlingua) |
| 160 | + * @author McDutchie |
| 161 | + */ |
| 162 | +$messages['ia'] = array( |
| 163 | + 'semanticinternalobjects-desc' => 'Configuration de objectos interne in Semantic MediaWiki', |
| 164 | +); |
| 165 | + |
| 166 | +/** Indonesian (Bahasa Indonesia) |
| 167 | + * @author Bennylin |
| 168 | + */ |
| 169 | +$messages['id'] = array( |
| 170 | + 'semanticinternalobjects-desc' => 'Seting untuk objek internal pada Semantic MediaWiki', |
| 171 | +); |
| 172 | + |
| 173 | +/** Italian (Italiano) |
| 174 | + * @author Gianfranco |
| 175 | + */ |
| 176 | +$messages['it'] = array( |
| 177 | + 'semanticinternalobjects-desc' => 'Configurazione degli oggetti interni in Semantic MediaWiki', |
| 178 | +); |
| 179 | + |
| 180 | +/** Japanese (日本語) |
| 181 | + * @author Fryed-peach |
| 182 | + */ |
| 183 | +$messages['ja'] = array( |
| 184 | + 'semanticinternalobjects-desc' => 'Semantic MediaWiki の内部オブジェクトの設定', |
| 185 | +); |
| 186 | + |
| 187 | +/** Colognian (Ripoarisch) |
| 188 | + * @author Purodha |
| 189 | + */ |
| 190 | +$messages['ksh'] = array( |
| 191 | + 'semanticinternalobjects-desc' => 'De ennere Objäkte vum Semantesch MedijaWiki enschtälle.', |
| 192 | +); |
| 193 | + |
| 194 | +/** Luxembourgish (Lëtzebuergesch) |
| 195 | + * @author Robby |
| 196 | + */ |
| 197 | +$messages['lb'] = array( |
| 198 | + 'semanticinternalobjects-desc' => 'Astellung vun internen Objeten a Semantic MediaWiki', |
| 199 | +); |
| 200 | + |
| 201 | +/** Macedonian (Македонски) |
| 202 | + * @author Bjankuloski06 |
| 203 | + */ |
| 204 | +$messages['mk'] = array( |
| 205 | + 'semanticinternalobjects-desc' => 'Поставање на внатрешни објекти во Semantic MediaWiki', |
| 206 | +); |
| 207 | + |
| 208 | +/** Dutch (Nederlands) |
| 209 | + * @author Siebrand |
| 210 | + */ |
| 211 | +$messages['nl'] = array( |
| 212 | + 'semanticinternalobjects-desc' => 'Interne objecten in Semantic MediaWiki instellen', |
| 213 | +); |
| 214 | + |
| 215 | +/** Norwegian (bokmål) (Norsk (bokmål)) |
| 216 | + * @author Nghtwlkr |
| 217 | + */ |
| 218 | +$messages['no'] = array( |
| 219 | + 'semanticinternalobjects-desc' => 'Innstilling for interne objekt i Semantic MediaWiki', |
| 220 | +); |
| 221 | + |
| 222 | +/** Occitan (Occitan) |
| 223 | + * @author Cedric31 |
| 224 | + */ |
| 225 | +$messages['oc'] = array( |
| 226 | + 'semanticinternalobjects-desc' => 'Reglatge dels objèctes intèrnes dins Semantic MediaWiki', |
| 227 | +); |
| 228 | + |
| 229 | +/** Polish (Polski) |
| 230 | + * @author Sp5uhe |
| 231 | + */ |
| 232 | +$messages['pl'] = array( |
| 233 | + 'semanticinternalobjects-desc' => 'Ustawianie wewnętrznych obiektów Semantic MediaWiki.', |
| 234 | +); |
| 235 | + |
| 236 | +/** Piedmontese (Piemontèis) |
| 237 | + * @author Dragonòt |
| 238 | + */ |
| 239 | +$messages['pms'] = array( |
| 240 | + 'semanticinternalobjects-desc' => "Ampostassion d'oget intern an drinta a Semantic MediaWiki", |
| 241 | +); |
| 242 | + |
| 243 | +/** Portuguese (Português) |
| 244 | + * @author Hamilton Abreu |
| 245 | + * @author Indech |
| 246 | + */ |
| 247 | +$messages['pt'] = array( |
| 248 | + 'semanticinternalobjects-desc' => 'Configuração de objetos internos no MediaWiki Semântico', |
| 249 | +); |
| 250 | + |
| 251 | +/** Brazilian Portuguese (Português do Brasil) |
| 252 | + * @author Eduardo.mps |
| 253 | + */ |
| 254 | +$messages['pt-br'] = array( |
| 255 | + 'semanticinternalobjects-desc' => 'Definição de objetos internos no Semantic MediaWiki', |
| 256 | +); |
| 257 | + |
| 258 | +/** Tarandíne (Tarandíne) |
| 259 | + * @author Joetaras |
| 260 | + */ |
| 261 | +$messages['roa-tara'] = array( |
| 262 | + 'semanticinternalobjects-desc' => "'Mboste le oggette inderne jndr'à MediaUicchi Semandiche", |
| 263 | +); |
| 264 | + |
| 265 | +/** Russian (Русский) |
| 266 | + * @author Александр Сигачёв |
| 267 | + */ |
| 268 | +$messages['ru'] = array( |
| 269 | + 'semanticinternalobjects-desc' => 'Установка внутренних объектов в Semantic MediaWiki', |
| 270 | +); |
| 271 | + |
| 272 | +/** Slovak (Slovenčina) |
| 273 | + * @author Helix84 |
| 274 | + */ |
| 275 | +$messages['sk'] = array( |
| 276 | + 'semanticinternalobjects-desc' => 'Nastavenie vnútorných objektov v Semantic MediaWiki', |
| 277 | +); |
| 278 | + |
| 279 | +/** Swedish (Svenska) |
| 280 | + * @author Per |
| 281 | + */ |
| 282 | +$messages['sv'] = array( |
| 283 | + 'semanticinternalobjects-desc' => 'Inställning för interna objekt i Semantic MediaWiki', |
| 284 | +); |
| 285 | + |
| 286 | +/** Tagalog (Tagalog) |
| 287 | + * @author AnakngAraw |
| 288 | + */ |
| 289 | +$messages['tl'] = array( |
| 290 | + 'semanticinternalobjects-desc' => 'Pagtatakda ng panloob na mga bagay sa Semantic MediaWiki', |
| 291 | +); |
| 292 | + |
| 293 | +/** Turkish (Türkçe) |
| 294 | + * @author Vito Genovese |
| 295 | + */ |
| 296 | +$messages['tr'] = array( |
| 297 | + 'semanticinternalobjects-desc' => "Anlamsal MediaWiki'deki iç nesnelerin ayarlanması", |
| 298 | +); |
| 299 | + |
| 300 | +/** Vietnamese (Tiếng Việt) |
| 301 | + * @author Minh Nguyen |
| 302 | + */ |
| 303 | +$messages['vi'] = array( |
| 304 | + 'semanticinternalobjects-desc' => 'Thiết kế các đối tượng nội bộ trong Semantic MediaWiki', |
| 305 | +); |
| 306 | + |
Property changes on: tags/extensions/SemanticInternalObjects/REL_0_6/SemanticInternalObjects.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 307 | + native |