Index: trunk/extensions/SemanticMediaWiki/includes/SMW_PageSchemas.php |
— | — | @@ -32,15 +32,15 @@ |
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | | - * Returns the list of property pages defined by the passed-in |
37 | | - * Page Schemas XML object. |
| 36 | + * Returns the set of SMW property data from the entire page schema. |
38 | 37 | */ |
39 | | - function getPageList( $psSchemaObj , &$genPageList ) { |
40 | | - $template_all = $psSchemaObj->getTemplates(); |
41 | | - foreach ( $template_all as $template ) { |
42 | | - $field_all = $template->getFields(); |
43 | | - foreach( $field_all as $field ) { |
44 | | - $smw_array = $field->getObject('semanticmediawiki_Property'); |
| 38 | + static function getAllPropertyData( $psSchemaObj ) { |
| 39 | + $propertyDataArray = array(); |
| 40 | + $psTemplates = $psSchemaObj->getTemplates(); |
| 41 | + foreach ( $psTemplates as $psTemplate ) { |
| 42 | + $psTemplateFields = $psTemplate->getFields(); |
| 43 | + foreach ( $psTemplateFields as $psTemplateField ) { |
| 44 | + $smw_array = $psTemplateField->getObject('semanticmediawiki_Property'); |
45 | 45 | if ( !array_key_exists( 'smw', $smw_array ) ) { |
46 | 46 | continue; |
47 | 47 | } |
— | — | @@ -51,10 +51,22 @@ |
52 | 52 | if ( empty( $prop_array['name'] ) ) { |
53 | 53 | continue; |
54 | 54 | } |
55 | | - $title = Title::makeTitleSafe( SMW_NS_PROPERTY, $prop_array['name'] ); |
56 | | - $genPageList[] = $title; |
| 55 | + $propertyDataArray[] = $prop_array; |
57 | 56 | } |
58 | 57 | } |
| 58 | + return $propertyDataArray; |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * Sets the list of property pages defined by the passed-in |
| 63 | + * Page Schemas XML object. |
| 64 | + */ |
| 65 | + function getPageList( $psSchemaObj , &$genPageList ) { |
| 66 | + $propertyDataArray = self::getAllPropertyData( $psSchemaObj ); |
| 67 | + foreach ( $propertyDataArray as $propertyData ) { |
| 68 | + $title = Title::makeTitleSafe( SMW_NS_PROPERTY, $propertyData['name'] ); |
| 69 | + $genPageList[] = $title; |
| 70 | + } |
59 | 71 | return true; |
60 | 72 | } |
61 | 73 | |
— | — | @@ -96,7 +108,7 @@ |
97 | 109 | * Returns the HTML necessary for getting information about the |
98 | 110 | * semantic property within the Page Schemas 'editschema' page. |
99 | 111 | */ |
100 | | - function getFieldHTML( $field, &$text_extensions ) { |
| 112 | + function getFieldHTML( $field, &$fieldHTMLFromExtensions ) { |
101 | 113 | global $smwgContLang; |
102 | 114 | |
103 | 115 | $prop_array = array(); |
— | — | @@ -146,7 +158,7 @@ |
147 | 159 | } |
148 | 160 | $html_text .= '<p>' . Html::input( 'smw_values_num', $allowed_val_string, 'text', $allowedValsInputAttrs ) . "</p>\n"; |
149 | 161 | |
150 | | - $text_extensions['smw'] = array( 'Semantic property', '#DEF', $html_text, $hasExistingValues ); |
| 162 | + $fieldHTMLFromExtensions['smw'] = array( 'Semantic property', '#DEF', $html_text, $hasExistingValues ); |
151 | 163 | |
152 | 164 | return true; |
153 | 165 | } |
— | — | @@ -156,17 +168,20 @@ |
157 | 169 | * passed-in Page Schemas XML object. |
158 | 170 | */ |
159 | 171 | function generatePages( $psSchemaObj, $selectedPageList ) { |
160 | | - $genPageList = array(); |
161 | | - self::getPageList( $psSchemaObj , &$genPageList ); |
162 | | - foreach ( $genPageList as $generatedPage ) { |
163 | | - if ( !in_array( $generatedPage, $selectedPageList ) ) { |
| 172 | + $propertyDataArray = self::getAllPropertyData( $psSchemaObj ); |
| 173 | + foreach ( $propertyDataArray as $propertyData ) { |
| 174 | + $title = Title::makeTitleSafe( SMW_NS_PROPERTY, $propertyData['name'] ); |
| 175 | + if ( !in_array( $title, $selectedPageList ) ) { |
164 | 176 | continue; |
165 | 177 | } |
166 | | - self::createProperty( $prop_array['name'], $prop_array['Type'], $prop_array['allowed_values'] ) ; |
| 178 | + self::createProperty( $propertyData['name'], $propertyData['Type'], $propertyData['allowed_values'] ); |
167 | 179 | } |
168 | 180 | return true; |
169 | 181 | } |
170 | 182 | |
| 183 | + /** |
| 184 | + * Creates the text for a property page. |
| 185 | + */ |
171 | 186 | function createPropertyText( $property_type, $allowed_values ) { |
172 | 187 | global $smwgContLang; |
173 | 188 | $prop_labels = $smwgContLang->getPropertyLabels(); |
— | — | @@ -194,6 +209,7 @@ |
195 | 210 | |
196 | 211 | function createProperty( $prop_name, $prop_type, $allowed_values ) { |
197 | 212 | global $wgUser; |
| 213 | + |
198 | 214 | $title = Title::makeTitleSafe( SMW_NS_PROPERTY, $prop_name ); |
199 | 215 | $params = array(); |
200 | 216 | $params['user_id'] = $wgUser->getId(); |