Index: tags/extensions/SemanticInternalObjects/REL_0_6_1/SemanticInternalObjects.php |
— | — | @@ -0,0 +1,49 @@ |
| 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.1' ); |
| 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['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 | + $parser->setFunctionHook( 'set_internal_recurring_event', array( 'SIOHandler', 'doSetInternalRecurringEvent' ) ); |
| 40 | + return true; // always return true, in order not to stop MW's hook processing! |
| 41 | +} |
| 42 | + |
| 43 | +function siofLanguageGetMagic( &$magicWords, $langCode = 'en' ) { |
| 44 | + switch ( $langCode ) { |
| 45 | + default: |
| 46 | + $magicWords['set_internal'] = array ( 0, 'set_internal' ); |
| 47 | + $magicWords['set_internal_recurring_event'] = array ( 0, 'set_internal_recurring_event' ); |
| 48 | + } |
| 49 | + return true; |
| 50 | +} |
Property changes on: tags/extensions/SemanticInternalObjects/REL_0_6_1/SemanticInternalObjects.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 51 | + native |
Index: tags/extensions/SemanticInternalObjects/REL_0_6_1/README |
— | — | @@ -0,0 +1,89 @@ |
| 2 | +Semantic Internal Objects Extension |
| 3 | + |
| 4 | + Version 0.6.1 |
| 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_1/README |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 91 | + native |
Index: tags/extensions/SemanticInternalObjects/REL_0_6_1/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_1/SemanticInternalObjects.i18n.magic.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 21 | + native |
Index: tags/extensions/SemanticInternalObjects/REL_0_6_1/SemanticInternalObjects_body.php |
— | — | @@ -0,0 +1,406 @@ |
| 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 doSetInternalRecurringEvent( &$parser ) { |
| 289 | + $params = func_get_args(); |
| 290 | + array_shift( $params ); // We already know the $parser ... |
| 291 | + |
| 292 | + // first param should be a standalone property name |
| 293 | + $objToPagePropName = array_shift( $params ); |
| 294 | + |
| 295 | + $results = SMWParserExtensions::getDatesForRecurringEvent( $params ); |
| 296 | + if ( $results == null ) { |
| 297 | + return null; |
| 298 | + } |
| 299 | + |
| 300 | + list( $property, $all_date_strings, $unused_params ) = $results; |
| 301 | + |
| 302 | + // Mimic a call to #set_internal for each date. |
| 303 | + foreach ( $all_date_strings as $date_string ) { |
| 304 | + $first_params = array( |
| 305 | + $parser, |
| 306 | + $objToPagePropName, |
| 307 | + "$property=$date_string" |
| 308 | + ); |
| 309 | + $cur_params = array_merge( $first_params, $unused_params ); |
| 310 | + call_user_func_array( 'SIOHandler::doSetInternal', $cur_params ); |
| 311 | + } |
| 312 | + } |
| 313 | + |
| 314 | + public static function updateData( $sqlStore, $data ) { |
| 315 | + $sioSQLStore = new SIOSQLStore(); |
| 316 | + // Find all "pages" in the SMW IDs table that are internal |
| 317 | + // objects for this page, and delete their properties from |
| 318 | + // the SMW tables. |
| 319 | + // Then save the current contents of the $mInternalObjects |
| 320 | + // array. |
| 321 | + $subject = $data->getSubject(); |
| 322 | + $pageName = $subject->getDBKey(); |
| 323 | + $namespace = $subject->getNamespace(); |
| 324 | + $idsForDeletion = SIOSQLStore::getIDsForDeletion( $pageName, $namespace ); |
| 325 | + |
| 326 | + $allRels2Inserts = array(); |
| 327 | + $allAtts2Inserts = array(); |
| 328 | + $allText2Inserts = array(); |
| 329 | + $allCoordsInserts = array(); |
| 330 | + foreach ( self::$mInternalObjects as $internalObject ) { |
| 331 | + list( $upRels2, $upAtts2, $upText2, $upCoords ) = $sioSQLStore->getStorageSQL( $internalObject ); |
| 332 | + $allRels2Inserts = array_merge( $allRels2Inserts, $upRels2 ); |
| 333 | + $allAtts2Inserts = array_merge( $allAtts2Inserts, $upAtts2 ); |
| 334 | + $allText2Inserts = array_merge( $allText2Inserts, $upText2 ); |
| 335 | + $allCoordsInserts = array_merge( $allCoordsInserts, $upCoords ); |
| 336 | + } |
| 337 | + |
| 338 | + // now save everything to the database, in a single transaction |
| 339 | + $db = wfGetDB( DB_MASTER ); |
| 340 | + $db->begin( 'SIO::updatePageData' ); |
| 341 | + if ( count( $idsForDeletion ) > 0 ) { |
| 342 | + $idsString = '(' . implode ( ', ', $idsForDeletion ) . ')'; |
| 343 | + $db->delete( 'smw_rels2', array( "(s_id IN $idsString) OR (o_id IN $idsString)" ), 'SIO::deleteRels2Data' ); |
| 344 | + $db->delete( 'smw_atts2', array( "s_id IN $idsString" ), 'SIO::deleteAtts2Data' ); |
| 345 | + $db->delete( 'smw_text2', array( "s_id IN $idsString" ), 'SIO::deleteText2Data' ); |
| 346 | + // handle the sm_coords table only if the Semantic |
| 347 | + // Maps extension is installed and uses sm_coords |
| 348 | + if ( defined( 'SM_VERSION' ) && version_compare( SM_VERSION, '0.6' ) >= 0 ) { |
| 349 | + $db->delete( 'sm_coords', array( "s_id IN $idsString" ), 'SIO::deleteCoordsData' ); |
| 350 | + } |
| 351 | + } |
| 352 | + |
| 353 | + if ( count( $allRels2Inserts ) > 0 ) { |
| 354 | + $db->insert( 'smw_rels2', $allRels2Inserts, 'SIO::updateRels2Data' ); |
| 355 | + } |
| 356 | + if ( count( $allAtts2Inserts ) > 0 ) { |
| 357 | + $db->insert( 'smw_atts2', $allAtts2Inserts, 'SIO::updateAtts2Data' ); |
| 358 | + } |
| 359 | + if ( count( $allText2Inserts ) > 0 ) { |
| 360 | + $db->insert( 'smw_text2', $allText2Inserts, 'SIO::updateText2Data' ); |
| 361 | + } |
| 362 | + if ( count( $allCoordsInserts ) > 0 ) { |
| 363 | + $db->insert( 'sm_coords', $allCoordsInserts, 'SIO::updateCoordsData' ); |
| 364 | + } |
| 365 | + // end transaction |
| 366 | + $db->commit( 'SIO::updatePageData' ); |
| 367 | + self::$mInternalObjects = array(); |
| 368 | + return true; |
| 369 | + } |
| 370 | + |
| 371 | + /** |
| 372 | + * Takes a set of SMW "update jobs", and keeps only the unique, actual |
| 373 | + * titles among them - this is useful if there are any internal objects |
| 374 | + * among the group; a set of names like "Page name#1", "Page name#2" |
| 375 | + * etc. should be turned into just "Page name". |
| 376 | + */ |
| 377 | + static function handleUpdatingOfInternalObjects( &$jobs ) { |
| 378 | + $uniqueTitles = array(); |
| 379 | + foreach ( $jobs as $i => $job ) { |
| 380 | + $title = Title::makeTitleSafe( $job->title->getNamespace(), $job->title->getText() ); |
| 381 | + $id = $title->getArticleID(); |
| 382 | + $uniqueTitles[$id] = $title; |
| 383 | + } |
| 384 | + $jobs = array(); |
| 385 | + foreach ( $uniqueTitles as $id => $title ) { |
| 386 | + $jobs[] = new SMWUpdateJob( $title ); |
| 387 | + } |
| 388 | + return true; |
| 389 | + } |
| 390 | + |
| 391 | + /** |
| 392 | + * Takes a set of SMW "update jobs" generated by refresh data and removes |
| 393 | + * any job with a fragment (in other words a job trying to update a SIO object) |
| 394 | + * We aren't guaranteed that all the jobs related to a single page using SIO |
| 395 | + * will be in a single one of these batches so we remove everything updating |
| 396 | + * a SIO object instead of filtering them down to unique titles. |
| 397 | + */ |
| 398 | + static function handleRefreshingOfInternalObjects( &$jobs ) { |
| 399 | + $allJobs = $jobs; |
| 400 | + $jobs = array(); |
| 401 | + foreach ( $allJobs as $job ) { |
| 402 | + if ( strpos( $job->title->getText(), '#' ) === false ) |
| 403 | + $jobs[] = $job; |
| 404 | + } |
| 405 | + return true; |
| 406 | + } |
| 407 | +} |
Property changes on: tags/extensions/SemanticInternalObjects/REL_0_6_1/SemanticInternalObjects_body.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 408 | + native |
Index: tags/extensions/SemanticInternalObjects/REL_0_6_1/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_1/SemanticInternalObjects.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 308 | + native |