Index: trunk/extensions/SemanticMediaWiki/includes/SMW_PageSchemas.php |
— | — | @@ -41,11 +41,18 @@ |
42 | 42 | $field_all = $template->getFields(); |
43 | 43 | foreach( $field_all as $field ) { |
44 | 44 | $smw_array = $field->getObject('semanticmediawiki_Property'); |
45 | | - if ( array_key_exists( 'smw', $smw_array ) ) { |
46 | | - $prop_array = $smw_array['smw']; |
47 | | - $title = Title::makeTitleSafe( SMW_NS_PROPERTY, $prop_array['name'] ); |
48 | | - $genPageList[] = $title; |
| 45 | + if ( !array_key_exists( 'smw', $smw_array ) ) { |
| 46 | + continue; |
49 | 47 | } |
| 48 | + $prop_array = $smw_array['smw']; |
| 49 | + if ( !array_key_exists( 'name', $prop_array ) ) { |
| 50 | + continue; |
| 51 | + } |
| 52 | + if ( empty( $prop_array['name'] ) ) { |
| 53 | + continue; |
| 54 | + } |
| 55 | + $title = Title::makeTitleSafe( SMW_NS_PROPERTY, $prop_array['name'] ); |
| 56 | + $genPageList[] = $title; |
50 | 57 | } |
51 | 58 | } |
52 | 59 | return true; |
— | — | @@ -148,30 +155,14 @@ |
149 | 156 | * Creates the property page for each property specified in the |
150 | 157 | * passed-in Page Schemas XML object. |
151 | 158 | */ |
152 | | - function generatePages( $psSchemaObj, $toGenPageList ) { |
153 | | - // Get the SMW info from every field in every template |
154 | | - $template_all = $psSchemaObj->getTemplates(); |
155 | | - foreach ( $template_all as $template ) { |
156 | | - $field_all = $template->getFields(); |
157 | | - foreach ( $field_all as $field ) { |
158 | | - $smw_array = $field->getObject('semanticmediawiki_Property'); |
159 | | - if ( !array_key_exists( 'smw', $smw_array ) ) { |
160 | | - continue; |
161 | | - } |
162 | | - $prop_array = $smw_array['smw']; |
163 | | - if ( !array_key_exists( 'name', $prop_array ) ) { |
164 | | - continue; |
165 | | - } |
166 | | - if ( empty( $prop_array['name'] ) ) { |
167 | | - continue; |
168 | | - } |
169 | | - $title = Title::makeTitleSafe( SMW_NS_PROPERTY, $prop_array['name'] ); |
170 | | - $key_title = PageSchemas::titleString( $title ); |
171 | | - if ( !in_array( $key_title, $toGenPageList ) ) { |
172 | | - continue; |
173 | | - } |
174 | | - self::createProperty( $prop_array['name'], $prop_array['Type'], $prop_array['allowed_values'] ) ; |
| 159 | + function generatePages( $psSchemaObj, $selectedPageList ) { |
| 160 | + $genPageList = array(); |
| 161 | + self::getPageList( $psSchemaObj , &$genPageList ); |
| 162 | + foreach ( $genPageList as $generatedPage ) { |
| 163 | + if ( !in_array( $generatedPage, $selectedPageList ) ) { |
| 164 | + continue; |
175 | 165 | } |
| 166 | + self::createProperty( $prop_array['name'], $prop_array['Type'], $prop_array['allowed_values'] ) ; |
176 | 167 | } |
177 | 168 | return true; |
178 | 169 | } |