Index: trunk/extensions/SemanticInternalObjects/SemanticInternalObjects.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | |
11 | 11 | if ( !defined( 'MEDIAWIKI' ) ) die(); |
12 | 12 | |
13 | | -define( 'SIO_VERSION', '0.4.1' ); |
| 13 | +define( 'SIO_VERSION', '0.5' ); |
14 | 14 | |
15 | 15 | $wgExtensionCredits['parserhook'][] = array( |
16 | 16 | 'path' => __FILE__, |
— | — | @@ -26,9 +26,12 @@ |
27 | 27 | $wgHooks['smwDeleteSemanticData'][] = 'SIOHandler::updateData'; |
28 | 28 | $wgHooks['smwUpdatePropertySubjects'][] = 'SIOHandler::handleUpdatingOfInternalObjects'; |
29 | 29 | $wgHooks['smwRefreshDataJobs'][] = 'SIOHandler::handleRefreshingOfInternalObjects'; |
| 30 | +$wgHooks['smwAddToRDFExport'][] = 'SIOSQLStore::createRDF'; |
30 | 31 | |
31 | | -$wgExtensionMessagesFiles['SemanticInternalObjects'] = dirname( __FILE__ ) . '/SemanticInternalObjects.i18n.php'; |
32 | | -$wgAutoloadClasses['SIOHandler'] = dirname( __FILE__ ) . '/SemanticInternalObjects_body.php'; |
| 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'; |
33 | 36 | |
34 | 37 | function siofRegisterParserFunctions( &$parser ) { |
35 | 38 | $parser->setFunctionHook( 'set_internal', array( 'SIOHandler', 'doSetInternal' ) ); |
Index: trunk/extensions/SemanticInternalObjects/README |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | Semantic Internal Objects Extension |
3 | 3 | |
4 | | - Version 0.4.1 |
| 4 | + Version 0.5 |
5 | 5 | Yaron Koren |
6 | 6 | |
7 | 7 | This is free software licensed under the GNU General Public License. Please |
Index: trunk/extensions/SemanticInternalObjects/SemanticInternalObjects_body.php |
— | — | @@ -10,10 +10,9 @@ |
11 | 11 | * its properties. |
12 | 12 | */ |
13 | 13 | class SIOInternalObject { |
14 | | - public $mPropertyValuePairs; |
15 | | - |
16 | 14 | protected $mMainTitle; |
17 | 15 | protected $mIndex; |
| 16 | + protected $mPropertyValuePairs; |
18 | 17 | |
19 | 18 | public function SIOInternalObject( $mainTitle, $index ) { |
20 | 19 | $this->mMainTitle = $mainTitle; |
— | — | @@ -24,98 +23,175 @@ |
25 | 24 | public function addPropertyAndValue( $propName, $value ) { |
26 | 25 | $property = SMWPropertyValue::makeUserProperty( $propName ); |
27 | 26 | $dataValue = SMWDataValueFactory::newPropertyObjectValue( $property, $value ); |
28 | | - |
29 | 27 | if ( $dataValue->isValid() ) { |
30 | 28 | $this->mPropertyValuePairs[] = array( $property, $dataValue ); |
31 | 29 | } // else - show an error message? |
32 | 30 | } |
33 | 31 | |
| 32 | + public function getPropertyValuePairs() { |
| 33 | + return $this->mPropertyValuePairs; |
| 34 | + } |
| 35 | + |
34 | 36 | public function getName() { |
35 | 37 | return $this->mMainTitle->getDBkey() . '#' . $this->mIndex; |
36 | 38 | } |
37 | 39 | } |
38 | 40 | |
39 | 41 | /** |
| 42 | + * The SIOTitle and SIOInternalObjectValue exist for only one reason: in order |
| 43 | + * to be used by SIOSQLStore::createRDF(), to spoof Semantic MediaWiki's |
| 44 | + * RDF-exporting code into thinking that it's dealing with actual wiki pages. |
| 45 | + */ |
| 46 | +class SIOTitle { |
| 47 | + function __construct ($name, $namespace) { |
| 48 | + $this->mName = $name; |
| 49 | + $this->mNamespace = $namespace; |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * Based on functions in Title class |
| 54 | + */ |
| 55 | + function getPrefixedName() { |
| 56 | + $s = ''; |
| 57 | + if ( 0 != $this->mNamespace ) { |
| 58 | + global $wgContLang; |
| 59 | + $s .= $wgContLang->getNsText( $this->mNamespace ) . ':'; |
| 60 | + } |
| 61 | + $s .= $this->mName; |
| 62 | + return $s; |
| 63 | + } |
| 64 | + |
| 65 | + function getPrefixedURL() { |
| 66 | + $s = $this->getPrefixedName(); |
| 67 | + return wfUrlencode( str_replace( ' ', '_', $s ) ); |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | +class SIOInternalObjectValue extends SMWWikiPageValue { |
| 72 | + function __construct($name, $namespace) { |
| 73 | + $this->mSIOTitle = new SIOTitle( $name, $namespace ); |
| 74 | + } |
| 75 | + function getExportData() { |
| 76 | + global $smwgNamespace; |
| 77 | + return new SMWExpData( new SMWExpResource( null ) ); |
| 78 | + } |
| 79 | + |
| 80 | + function getTitle() { |
| 81 | + return $this->mSIOTitle; |
| 82 | + } |
| 83 | + |
| 84 | + function getWikiValue() { |
| 85 | + return $this->mSIOTitle->getPrefixedName(); |
| 86 | + } |
| 87 | +} |
| 88 | + |
| 89 | +/** |
40 | 90 | * Class for all database-related actions. |
41 | 91 | * This class exists mostly because SMWSQLStore2's functions makeSMWPageID() |
42 | 92 | * and makeSMWPropertyID(), which are needed for the DB access, are both |
43 | 93 | * protected, and thus can't be accessed externally. |
44 | 94 | */ |
45 | 95 | class SIOSQLStore extends SMWSQLStore2 { |
46 | | - function getIDsForDeletion( $page_name, $namespace ) { |
| 96 | + static function getIDsForDeletion( $pageName, $namespace ) { |
47 | 97 | $ids = array(); |
48 | 98 | |
49 | 99 | $iw = ''; |
50 | 100 | $db = wfGetDB( DB_SLAVE ); |
51 | | - $res = $db->select( 'smw_ids', array( 'smw_id' ), 'smw_title LIKE ' . $db->addQuotes( $page_name . '#%' ) . ' AND ' . 'smw_namespace=' . $db->addQuotes( $namespace ) . ' AND smw_iw=' . $db->addQuotes( $iw ), 'SIO::getSMWPageObjectIDs', array() ); |
52 | | - |
| 101 | + $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() ); |
53 | 102 | while ( $row = $db->fetchObject( $res ) ) { |
54 | 103 | $ids[] = $row->smw_id; |
55 | 104 | } |
56 | | - |
57 | 105 | return $ids; |
58 | 106 | } |
59 | 107 | |
60 | | - function getStorageSQL( $main_page_name, $namespace, $internal_object ) { |
61 | | - $main_page_id = $this->makeSMWPageID( $main_page_name, $namespace, '' ); |
62 | | - $io_id = $this->makeSMWPageID( $internal_object->getName(), $namespace, '' ); |
63 | | - |
64 | | - $up_rels2 = array(); |
65 | | - $up_atts2 = array(); |
66 | | - $up_text2 = array(); |
67 | | - |
| 108 | + function getStorageSQL( $mainPageName, $namespace, $internalObject ) { |
| 109 | + $mainPageID = $this->makeSMWPageID( $mainPageName, $namespace, '' ); |
| 110 | + $ioID = $this->makeSMWPageID( $internalObject->getName(), $namespace, '' ); |
| 111 | + $upRels2 = array(); |
| 112 | + $upAtts2 = array(); |
| 113 | + $upText2 = array(); |
| 114 | + $upCoords = array(); |
68 | 115 | // set all the properties pointing from this internal object |
69 | | - foreach ( $internal_object->mPropertyValuePairs as $property_value_pair ) { |
70 | | - list( $property, $value ) = $property_value_pair; |
71 | | - |
| 116 | + foreach ( $internalObject->getPropertyValuePairs() as $propertyValuePair ) { |
| 117 | + list( $property, $value ) = $propertyValuePair; |
72 | 118 | // handling changed in SMW 1.5 |
73 | 119 | if ( method_exists( 'SMWSQLStore2', 'findPropertyTableID' ) ) { |
74 | 120 | $tableid = SMWSQLStore2::findPropertyTableID( $property ); |
75 | | - $is_relation = ( $tableid == 'smw_rels2' ); |
76 | | - $is_attribute = ( $tableid == 'smw_atts2' ); |
77 | | - $is_text = ( $tableid == 'smw_text2' ); |
| 121 | + $isRelation = ( $tableid == 'smw_rels2' ); |
| 122 | + $isAttribute = ( $tableid == 'smw_atts2' ); |
| 123 | + $isText = ( $tableid == 'smw_text2' ); |
| 124 | + // new with SMW 1.5.1 / SM 0.6 |
| 125 | + $isCoords = ( $tableid == 'smw_coords' ); |
78 | 126 | } else { |
79 | 127 | $mode = SMWSQLStore2::getStorageMode( $property->getPropertyTypeID() ); |
80 | | - $is_relation = ( $mode == SMW_SQL2_RELS2 ); |
81 | | - $is_attribute = ( $mode == SMW_SQL2_ATTS2 ); |
82 | | - $is_text = ( $mode == SMW_SQL2_TEXT2 ); |
| 128 | + $isRelation = ( $mode == SMW_SQL2_RELS2 ); |
| 129 | + $isAttribute = ( $mode == SMW_SQL2_ATTS2 ); |
| 130 | + $isText = ( $mode == SMW_SQL2_TEXT2 ); |
| 131 | + $isCoords = false; |
83 | 132 | } |
84 | | - |
85 | | - if ( $is_relation ) { |
86 | | - $up_rels2[] = array( |
87 | | - 's_id' => $io_id, |
| 133 | + if ( $isRelation ) { |
| 134 | + $upRels2[] = array( |
| 135 | + 's_id' => $ioID, |
88 | 136 | 'p_id' => $this->makeSMWPropertyID( $property ), |
89 | 137 | 'o_id' => $this->makeSMWPageID( $value->getDBkey(), $value->getNamespace(), $value->getInterwiki() ) |
90 | 138 | ); |
91 | | - } elseif ( $is_attribute ) { |
| 139 | + } elseif ( $isAttribute ) { |
92 | 140 | $keys = $value->getDBkeys(); |
93 | | - |
94 | 141 | if ( method_exists( $value, 'getValueKey' ) ) { |
95 | | - $value_num = $value->getValueKey(); |
| 142 | + $valueNum = $value->getValueKey(); |
96 | 143 | } else { |
97 | | - $value_num = $value->getNumericValue(); |
| 144 | + $valueNum = $value->getNumericValue(); |
98 | 145 | } |
99 | | - |
100 | | - $up_atts2[] = array( |
101 | | - 's_id' => $io_id, |
| 146 | + $upAtts2[] = array( |
| 147 | + 's_id' => $ioID, |
102 | 148 | 'p_id' => $this->makeSMWPropertyID( $property ), |
103 | 149 | 'value_unit' => $value->getUnit(), |
104 | | - 'value_xsd' => $keys[0], // FIXME: this fails for all datatypes with more then one value field |
105 | | - 'value_num' => $value_num |
| 150 | + 'value_xsd' => $keys[0], |
| 151 | + 'value_num' => $valueNum |
106 | 152 | ); |
107 | | - } elseif ( $is_text ) { |
| 153 | + } elseif ( $isText ) { |
108 | 154 | $keys = $value->getDBkeys(); |
109 | | - |
110 | | - $up_text2[] = array( |
111 | | - 's_id' => $io_id, |
| 155 | + $upText2[] = array( |
| 156 | + 's_id' => $ioID, |
112 | 157 | 'p_id' => $this->makeSMWPropertyID( $property ), |
113 | | - 'value_blob' => $keys[0] // FIXME: this fails for all datatypes with more then one value field |
| 158 | + 'value_blob' => $keys[0] |
114 | 159 | ); |
| 160 | + } elseif ( $isCoords ) { |
| 161 | + $keys = $value->getDBkeys(); |
| 162 | + $upCoords[] = array( |
| 163 | + 's_id' => $ioID, |
| 164 | + 'p_id' => $this->makeSMWPropertyID( $property ), |
| 165 | + 'lat' => $keys[0], |
| 166 | + 'lon' => $keys[1], |
| 167 | + ); |
115 | 168 | } |
116 | 169 | } |
117 | | - |
118 | | - return array( $up_rels2, $up_atts2, $up_text2 ); |
| 170 | + return array( $upRels2, $upAtts2, $upText2, $upCoords ); |
119 | 171 | } |
| 172 | + |
| 173 | + static function createRDF( $title, $rdfDataArray ) { |
| 174 | + $pageName = $title->getText(); |
| 175 | + $namespace = $title->getNamespace(); |
| 176 | + |
| 177 | + // go through all SIOs for the current page, create RDF for |
| 178 | + // each one, and add it to the general array |
| 179 | + $iw = ''; |
| 180 | + $db = wfGetDB( DB_SLAVE ); |
| 181 | + $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() ); |
| 182 | + while ( $row = $db->fetchObject( $res ) ) { |
| 183 | + $value = new SIOInternalObjectValue( $row->smw_title, $row->smw_namespace ); |
| 184 | + $semdata = new SMWSemanticData( $value, false ); |
| 185 | + $propertyTables = SMWSQLStore2::getPropertyTables(); |
| 186 | + foreach ( $propertyTables as $tableName => $propertyTable ) { |
| 187 | + $data = smwfGetStore()->fetchSemanticData( $row->smw_id, null, $propertyTable ); |
| 188 | + foreach ( $data as $d ) { |
| 189 | + $semdata->addPropertyStubValue( reset( $d ), end( $d ) ); |
| 190 | + } |
| 191 | + } |
| 192 | + $rdfDataArray[] = SMWExporter::makeExportData( $semdata, null ); |
| 193 | + } |
| 194 | + return true; |
| 195 | + } |
120 | 196 | } |
121 | 197 | |
122 | 198 | /** |
— | — | @@ -123,124 +199,109 @@ |
124 | 200 | */ |
125 | 201 | class SIOHandler { |
126 | 202 | |
127 | | - static $cur_page_name = ''; |
128 | | - static $cur_page_namespace = 0; |
129 | | - static $internal_object_index = 1; |
130 | | - static $internal_objects = array(); |
| 203 | + static $mCurPageName = ''; |
| 204 | + static $mCurPageNamespace = 0; |
| 205 | + static $mInternalObjectIndex = 1; |
| 206 | + static $mInternalObjects = array(); |
131 | 207 | |
132 | 208 | public static function clearState( &$parser ) { |
133 | | - self::$cur_page_name = ''; |
134 | | - self::$cur_page_namespace = 0; |
135 | | - self::$internal_object_index = 1; |
136 | | - |
| 209 | + self::$mCurPageName = ''; |
| 210 | + self::$mCurPageNamespace = 0; |
| 211 | + self::$mInternalObjectIndex = 1; |
137 | 212 | return true; |
138 | 213 | } |
139 | 214 | |
140 | 215 | public static function doSetInternal( &$parser ) { |
141 | | - $main_page_name = $parser->getTitle()->getDBKey(); |
142 | | - $main_page_namespace = $parser->getTitle()->getNamespace(); |
143 | | - |
144 | | - if ( $main_page_name == self::$cur_page_name && |
145 | | - $main_page_namespace == self::$cur_page_namespace ) { |
146 | | - self::$internal_object_index++; |
| 216 | + $mainPageName = $parser->getTitle()->getDBKey(); |
| 217 | + $mainPageNamespace = $parser->getTitle()->getNamespace(); |
| 218 | + if ( $mainPageName == self::$mCurPageName && |
| 219 | + $mainPageNamespace == self::$mCurPageNamespace ) { |
| 220 | + self::$mInternalObjectIndex++; |
147 | 221 | } else { |
148 | | - self::$cur_page_name = $main_page_name; |
149 | | - self::$cur_page_namespace = $main_page_namespace; |
150 | | - self::$internal_object_index = 1; |
| 222 | + self::$mCurPageName = $mainPageName; |
| 223 | + self::$mCurPageNamespace = $mainPageNamespace; |
| 224 | + self::$mInternalObjectIndex = 1; |
151 | 225 | } |
152 | | - |
153 | | - $cur_object_num = self::$internal_object_index; |
154 | | - |
| 226 | + $curObjectNum = self::$mInternalObjectIndex; |
155 | 227 | $params = func_get_args(); |
156 | 228 | array_shift( $params ); // we already know the $parser... |
157 | | - |
158 | | - $internal_object = new SIOInternalObject( $parser->getTitle(), $cur_object_num ); |
159 | | - $obj_to_page_prop_name = array_shift( $params ); |
160 | | - $main_page_name = $parser->getTitle()->getText(); |
161 | | - |
162 | | - if ( ( $ns_text = $parser->getTitle()->getNsText() ) != '' ) { |
163 | | - $main_page_name = $ns_text . ':' . $main_page_name; |
| 229 | + $internalObject = new SIOInternalObject( $parser->getTitle(), $curObjectNum ); |
| 230 | + $objToPagePropName = array_shift( $params ); |
| 231 | + $mainPageName = $parser->getTitle()->getText(); |
| 232 | + if ( ( $nsText = $parser->getTitle()->getNsText() ) != '' ) { |
| 233 | + $mainPageName = $nsText . ':' . $mainPageName; |
164 | 234 | } |
165 | | - |
166 | | - $internal_object->addPropertyAndValue( $obj_to_page_prop_name, $main_page_name ); |
167 | | - |
| 235 | + $internalObject->addPropertyAndValue( $objToPagePropName, $mainPageName ); |
168 | 236 | foreach ( $params as $param ) { |
169 | | - $parts = explode( '=', trim( $param ), 2 ); |
170 | | - |
| 237 | + $parts = explode( "=", trim( $param ), 2 ); |
171 | 238 | if ( count( $parts ) == 2 ) { |
172 | 239 | $key = $parts[0]; |
173 | 240 | $value = $parts[1]; |
174 | | - |
175 | 241 | // if the property name ends with '#list', it's |
176 | 242 | // a comma-delimited group of values |
177 | 243 | if ( substr( $key, - 5 ) == '#list' ) { |
178 | 244 | $key = substr( $key, 0, strlen( $key ) - 5 ); |
179 | | - $list_values = explode( ',', $value ); |
180 | | - |
181 | | - foreach ( $list_values as $list_value ) { |
182 | | - $internal_object->addPropertyAndValue( $key, trim( $list_value ) ); |
| 245 | + $listValues = explode( ',', $value ); |
| 246 | + foreach ( $listValues as $listValue ) { |
| 247 | + $internalObject->addPropertyAndValue( $key, trim( $listValue ) ); |
183 | 248 | } |
184 | 249 | } else { |
185 | | - $internal_object->addPropertyAndValue( $key, $value ); |
| 250 | + $internalObject->addPropertyAndValue( $key, $value ); |
186 | 251 | } |
187 | 252 | } |
188 | 253 | } |
189 | | - |
190 | | - self::$internal_objects[] = $internal_object; |
| 254 | + self::$mInternalObjects[] = $internalObject; |
191 | 255 | } |
192 | 256 | |
193 | 257 | public static function updateData( $subject ) { |
194 | | - $sio_sql_store = new SIOSQLStore(); |
195 | | - |
| 258 | + $sioSQLStore = new SIOSQLStore(); |
196 | 259 | // Find all "pages" in the SMW IDs table that are internal |
197 | 260 | // objects for this page, and delete their properties from |
198 | 261 | // the SMW tables. |
199 | | - // Then save the current contents of the $internal_objects |
| 262 | + // Then save the current contents of the $mInternalObjects |
200 | 263 | // array. |
201 | | - $page_name = $subject->getDBKey(); |
| 264 | + $pageName = $subject->getDBKey(); |
202 | 265 | $namespace = $subject->getNamespace(); |
203 | | - $ids_for_deletion = $sio_sql_store->getIDsForDeletion( $page_name, $namespace ); |
| 266 | + $idsForDeletion = SIOSQLStore::getIDsForDeletion( $pageName, $namespace ); |
204 | 267 | |
205 | | - $all_rels2_inserts = array(); |
206 | | - $all_atts2_inserts = array(); |
207 | | - $all_text2_inserts = array(); |
208 | | - |
209 | | - foreach ( self::$internal_objects as $internal_object ) { |
210 | | - list( $up_rels2, $up_atts2, $up_text2 ) = $sio_sql_store->getStorageSQL( $page_name, $namespace, $internal_object ); |
211 | | - |
212 | | - $all_rels2_inserts = array_merge( $all_rels2_inserts, $up_rels2 ); |
213 | | - $all_atts2_inserts = array_merge( $all_atts2_inserts, $up_atts2 ); |
214 | | - $all_text2_inserts = array_merge( $all_text2_inserts, $up_text2 ); |
| 268 | + $allRels2Inserts = array(); |
| 269 | + $allAtts2Inserts = array(); |
| 270 | + $allText2Inserts = array(); |
| 271 | + $allCoordsInserts = array(); |
| 272 | + foreach ( self::$mInternalObjects as $internalObject ) { |
| 273 | + list( $upRels2, $upAtts2, $upText2, $upCoords ) = $sioSQLStore->getStorageSQL( $pageName, $namespace, $internalObject ); |
| 274 | + $allRels2Inserts = array_merge( $allRels2Inserts, $upRels2 ); |
| 275 | + $allAtts2Inserts = array_merge( $allAtts2Inserts, $upAtts2 ); |
| 276 | + $allText2Inserts = array_merge( $allText2Inserts, $upText2 ); |
| 277 | + $allCoordsInserts = array_merge( $allCoordsInserts, $upCoords ); |
215 | 278 | } |
216 | 279 | |
217 | 280 | // now save everything to the database, in a single transaction |
218 | 281 | $db = wfGetDB( DB_MASTER ); |
219 | 282 | $db->begin( 'SIO::updatePageData' ); |
220 | | - |
221 | | - if ( count( $ids_for_deletion ) > 0 ) { |
222 | | - $ids_string = '(' . implode ( ', ', $ids_for_deletion ) . ')'; |
223 | | - $db->delete( 'smw_rels2', array( "(s_id IN $ids_string) OR (o_id IN $ids_string)" ), 'SIO::deleteRels2Data' ); |
224 | | - $db->delete( 'smw_atts2', array( "s_id IN $ids_string" ), 'SIO::deleteAtts2Data' ); |
225 | | - $db->delete( 'smw_text2', array( "s_id IN $ids_string" ), 'SIO::deleteText2Data' ); |
| 283 | + if ( count( $idsForDeletion ) > 0 ) { |
| 284 | + $idsString = '(' . implode ( ', ', $idsForDeletion ) . ')'; |
| 285 | + $db->delete( 'smw_rels2', array( "(s_id IN $idsString) OR (o_id IN $idsString)" ), 'SIO::deleteRels2Data' ); |
| 286 | + $db->delete( 'smw_atts2', array( "s_id IN $idsString" ), 'SIO::deleteAtts2Data' ); |
| 287 | + $db->delete( 'smw_text2', array( "s_id IN $idsString" ), 'SIO::deleteText2Data' ); |
| 288 | + $db->delete( 'sm_coords', array( "s_id IN $idsString" ), 'SIO::deleteCoordsData' ); |
226 | 289 | } |
227 | 290 | |
228 | | - if ( count( $all_rels2_inserts ) > 0 ) { |
229 | | - $db->insert( 'smw_rels2', $all_rels2_inserts, 'SIO::updateRels2Data' ); |
| 291 | + if ( count( $allRels2Inserts ) > 0 ) { |
| 292 | + $db->insert( 'smw_rels2', $allRels2Inserts, 'SIO::updateRels2Data' ); |
230 | 293 | } |
231 | | - |
232 | | - if ( count( $all_atts2_inserts ) > 0 ) { |
233 | | - $db->insert( 'smw_atts2', $all_atts2_inserts, 'SIO::updateAtts2Data' ); |
| 294 | + if ( count( $allAtts2Inserts ) > 0 ) { |
| 295 | + $db->insert( 'smw_atts2', $allAtts2Inserts, 'SIO::updateAtts2Data' ); |
234 | 296 | } |
235 | | - |
236 | | - if ( count( $all_text2_inserts ) > 0 ) { |
237 | | - $db->insert( 'smw_text2', $all_text2_inserts, 'SIO::updateText2Data' ); |
| 297 | + if ( count( $allText2Inserts ) > 0 ) { |
| 298 | + $db->insert( 'smw_text2', $allText2Inserts, 'SIO::updateText2Data' ); |
238 | 299 | } |
239 | | - |
| 300 | + if ( count( $allCoordsInserts ) > 0 ) { |
| 301 | + $db->insert( 'sm_coords', $allCoordsInserts, 'SIO::updateCoordsData' ); |
| 302 | + } |
240 | 303 | // end transaction |
241 | 304 | $db->commit( 'SIO::updatePageData' ); |
242 | | - |
243 | | - self::$internal_objects = array(); |
244 | | - |
| 305 | + self::$mInternalObjects = array(); |
245 | 306 | return true; |
246 | 307 | } |
247 | 308 | |
— | — | @@ -251,20 +312,16 @@ |
252 | 313 | * etc. should be turned into just "Page name". |
253 | 314 | */ |
254 | 315 | static function handleUpdatingOfInternalObjects( &$jobs ) { |
255 | | - $unique_titles = array(); |
256 | | - |
| 316 | + $uniqueTitles = array(); |
257 | 317 | foreach ( $jobs as $i => $job ) { |
258 | 318 | $title = Title::makeTitleSafe( $job->title->getNamespace(), $job->title->getText() ); |
259 | 319 | $id = $title->getArticleID(); |
260 | | - $unique_titles[$id] = $title; |
| 320 | + $uniqueTitles[$id] = $title; |
261 | 321 | } |
262 | | - |
263 | 322 | $jobs = array(); |
264 | | - |
265 | | - foreach ( $unique_titles as $id => $title ) { |
| 323 | + foreach ( $uniqueTitles as $id => $title ) { |
266 | 324 | $jobs[] = new SMWUpdateJob( $title ); |
267 | 325 | } |
268 | | - |
269 | 326 | return true; |
270 | 327 | } |
271 | 328 | |
— | — | @@ -276,16 +333,12 @@ |
277 | 334 | * a SIO object instead of filtering them down to unique titles. |
278 | 335 | */ |
279 | 336 | static function handleRefreshingOfInternalObjects( &$jobs ) { |
280 | | - $all_jobs = $jobs; |
| 337 | + $allJobs = $jobs; |
281 | 338 | $jobs = array(); |
282 | | - |
283 | | - foreach ( $all_jobs as $job ) { |
284 | | - if ( strpos( $job->title->getText(), '#' ) === false ) { |
| 339 | + foreach ( $allJobs as $job ) { |
| 340 | + if ( strpos( $job->title->getText(), '#' ) === false ) |
285 | 341 | $jobs[] = $job; |
286 | | - } |
287 | 342 | } |
288 | | - |
289 | | - return true; |
290 | | - } |
291 | | - |
292 | | -} |
\ No newline at end of file |
| 343 | + return true; |
| 344 | + } |
| 345 | +} |