Index: trunk/extensions/SemanticMediaWiki/includes/SMW_PageSchemas.php |
— | — | @@ -15,9 +15,8 @@ |
16 | 16 | function parseFieldElements( $field_xml, &$text_object ) { |
17 | 17 | foreach ( $field_xml->children() as $tag => $child ) { |
18 | 18 | if ( $tag == "semanticmediawiki_Property" ) { |
19 | | - $text = ""; |
20 | | - $text = PageSchemas::tableMessageRowHTML( "paramAttr", "SemanticMediaWiki", (string)$tag ); |
21 | | - $propName = $child->attributes()->name; |
| 19 | + $text = PageSchemas::tableMessageRowHTML( "paramAttr", wfMsg( 'specialpages-group-smw_group' ), wfMsg( 'smw_pp_type' ) ); |
| 20 | + $propName = $child->attributes()->name; |
22 | 21 | // this means object has already been initialized by some other extension. |
23 | 22 | $text .= PageSchemas::tableMessageRowHTML( "paramAttrMsg", "name", (string)$propName ); |
24 | 23 | foreach ( $child->children() as $prop => $value ) { |
— | — | @@ -29,14 +28,16 @@ |
30 | 29 | return true; |
31 | 30 | } |
32 | 31 | |
| 32 | + /** |
| 33 | + * Returns the list of property pages defined by the passed-in |
| 34 | + * Page Schemas XML object. |
| 35 | + */ |
33 | 36 | function getPageList( $psSchemaObj , &$genPageList ) { |
34 | 37 | $template_all = $psSchemaObj->getTemplates(); |
35 | 38 | foreach ( $template_all as $template ) { |
36 | 39 | $field_all = $template->getFields(); |
37 | | - $field_count = 0; //counts the number of fields |
38 | | - foreach( $field_all as $field ) { //for each Field, retrieve smw properties and fill $prop_name , $prop_type |
39 | | - $field_count++; |
40 | | - $smw_array = $field->getObject('semanticmediawiki_Property'); //this returns an array with property values filled |
| 40 | + foreach( $field_all as $field ) { |
| 41 | + $smw_array = $field->getObject('semanticmediawiki_Property'); |
41 | 42 | if ( array_key_exists( 'smw', $smw_array ) ) { |
42 | 43 | $prop_array = $smw_array['smw']; |
43 | 44 | $title = Title::makeTitleSafe( SMW_NS_PROPERTY, $prop_array['name'] ); |
— | — | @@ -81,6 +82,10 @@ |
82 | 83 | return true; |
83 | 84 | } |
84 | 85 | |
| 86 | + /** |
| 87 | + * Returns the HTML necessary for getting information about the |
| 88 | + * semantic property within the Page Schemas 'editschema' page. |
| 89 | + */ |
85 | 90 | function getFieldHTML( $field, &$text_extensions ) { |
86 | 91 | global $smwgContLang; |
87 | 92 | |
— | — | @@ -88,7 +93,7 @@ |
89 | 94 | $prop_array = array(); |
90 | 95 | $hasExistingValues = false; |
91 | 96 | if ( !is_null( $field ) ) { |
92 | | - $smw_array = $field->getObject('semanticmediawiki_Property'); //this returns an array with property values filled |
| 97 | + $smw_array = $field->getObject('semanticmediawiki_Property'); |
93 | 98 | if ( array_key_exists( 'smw', $smw_array ) ) { |
94 | 99 | $prop_array = $smw_array['smw']; |
95 | 100 | $hasExistingValues = true; |
— | — | @@ -136,17 +141,19 @@ |
137 | 142 | return true; |
138 | 143 | } |
139 | 144 | |
| 145 | + /** |
| 146 | + * Creates the property page for each property specified in the |
| 147 | + * passed-in Page Schemas XML object. |
| 148 | + */ |
140 | 149 | function generatePages( $psSchemaObj, $toGenPageList ) { |
141 | 150 | // Get the SMW info from every field in every template |
142 | 151 | $template_all = $psSchemaObj->getTemplates(); |
143 | 152 | foreach ( $template_all as $template ) { |
144 | 153 | $field_all = $template->getFields(); |
145 | | - $field_count = 0; |
146 | 154 | foreach( $field_all as $field ) { |
147 | | - $field_count++; |
148 | 155 | $smw_array = $field->getObject('semanticmediawiki_Property'); |
149 | | - $prop_array = $smw_array['smw']; |
150 | | - if($prop_array != null){ |
| 156 | + if ( array_key_exists( 'smw', $smw_array ) ) { |
| 157 | + $prop_array = $smw_array['smw']; |
151 | 158 | $title = Title::makeTitleSafe( SMW_NS_PROPERTY, $prop_array['name'] ); |
152 | 159 | $key_title = PageSchemas::titleString( $title ); |
153 | 160 | if(in_array( $key_title, $toGenPageList )){ |
— | — | @@ -185,25 +192,25 @@ |
186 | 193 | function createProperty( $prop_name, $prop_type, $allowed_values ) { |
187 | 194 | global $wgUser; |
188 | 195 | $title = Title::makeTitleSafe( SMW_NS_PROPERTY, $prop_name ); |
189 | | - $text = self::createPropertyText( $prop_type, $allowed_values ); |
190 | | - $jobs = array(); |
191 | 196 | $params = array(); |
192 | 197 | $params['user_id'] = $wgUser->getId(); |
193 | | - $params['page_text'] = $text; |
| 198 | + $params['page_text'] = self::createPropertyText( $prop_type, $allowed_values ); |
| 199 | + $jobs = array(); |
194 | 200 | $jobs[] = new PSCreatePageJob( $title, $params ); |
195 | 201 | Job::batchInsert( $jobs ); |
196 | 202 | return true; |
197 | 203 | } |
198 | 204 | |
199 | 205 | /** |
200 | | - * Returns the property based on the XML passed from the Page Schemas extension |
| 206 | + * Returns the property based on the XML passed from the Page Schemas |
| 207 | + * extension. |
201 | 208 | */ |
202 | 209 | function createPageSchemasObject( $objectName, $xmlForField, &$object ) { |
203 | 210 | $smw_array = array(); |
204 | 211 | if ( $objectName == "semanticmediawiki_Property" ) { |
205 | 212 | foreach ( $xmlForField->children() as $tag => $child ) { |
206 | 213 | if ( $tag == $objectName ) { |
207 | | - $propName = $child->attributes()->name; |
| 214 | + $propName = $child->attributes()->name; |
208 | 215 | $smw_array['name'] = (string)$propName; |
209 | 216 | $allowed_values = array(); |
210 | 217 | $count = 0; |