r99269 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99268‎ | r99269 | r99270 >
Date:21:51, 7 October 2011
Author:yaron
Status:deferred
Tags:
Comment:
Added more checks to code, improved some comments
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_PageSchemas.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_PageSchemas.php
@@ -150,16 +150,24 @@
151151 $template_all = $psSchemaObj->getTemplates();
152152 foreach ( $template_all as $template ) {
153153 $field_all = $template->getFields();
154 - foreach( $field_all as $field ) {
 154+ foreach ( $field_all as $field ) {
155155 $smw_array = $field->getObject('semanticmediawiki_Property');
156 - if ( array_key_exists( 'smw', $smw_array ) ) {
157 - $prop_array = $smw_array['smw'];
158 - $title = Title::makeTitleSafe( SMW_NS_PROPERTY, $prop_array['name'] );
159 - $key_title = PageSchemas::titleString( $title );
160 - if(in_array( $key_title, $toGenPageList )){
161 - self::createProperty( $prop_array['name'], $prop_array['Type'], $prop_array['allowed_values'] ) ;
162 - }
 156+ if ( !array_key_exists( 'smw', $smw_array ) ) {
 157+ continue;
163158 }
 159+ $prop_array = $smw_array['smw'];
 160+ if ( !array_key_exists( 'name', $prop_array ) ) {
 161+ continue;
 162+ }
 163+ if ( empty( $prop_array['name'] ) ) {
 164+ continue;
 165+ }
 166+ $title = Title::makeTitleSafe( SMW_NS_PROPERTY, $prop_array['name'] );
 167+ $key_title = PageSchemas::titleString( $title );
 168+ if ( !in_array( $key_title, $toGenPageList ) ) {
 169+ continue;
 170+ }
 171+ self::createProperty( $prop_array['name'], $prop_array['Type'], $prop_array['allowed_values'] ) ;
164172 }
165173 }
166174 return true;
@@ -171,11 +179,12 @@
172180 $type_tag = "[[{$prop_labels['_TYPE']}::$property_type]]";
173181 $text = wfMsgForContent( 'ps-property-isproperty', $type_tag );
174182 if ( $allowed_values != null) {
175 - // replace the comma substitution character that has no chance of
176 - // being included in the values list - namely, the ASCII beep
 183+ // Replace the comma with a substitution character
 184+ // that has no chance of being included in the values
 185+ // list - namely, the ASCII beep.
177186 $text .= "\n\n" . wfMsgExt( 'ps-property-allowedvals', array( 'parsemag', 'content' ), count( $allowed_values ) );
178187 foreach ( $allowed_values as $i => $value ) {
179 - // replace beep back with comma, trim
 188+ // Replace beep back with comma, trim.
180189 $value = str_replace( "\a",',' , trim( $value ) );
181190 if ( method_exists( $smwgContLang, 'getPropertyLabels' ) ) {
182191 $prop_labels = $smwgContLang->getPropertyLabels();