Index: trunk/extensions/SemanticMediaWiki/includes/SMW_PageSchemas.php |
— | — | @@ -83,18 +83,18 @@ |
84 | 84 | |
85 | 85 | function getFieldHTML( $field, &$text_extensions ) { |
86 | 86 | global $smwgContLang; |
| 87 | + |
87 | 88 | $datatype_labels = $smwgContLang->getDatatypeLabels(); |
88 | 89 | $prop_array = array(); |
| 90 | + $hasExistingValues = false; |
89 | 91 | if ( !is_null( $field ) ) { |
90 | 92 | $smw_array = $field->getObject('semanticmediawiki_Property'); //this returns an array with property values filled |
91 | 93 | if ( array_key_exists( 'smw', $smw_array ) ) { |
92 | 94 | $prop_array = $smw_array['smw']; |
93 | 95 | $hasExistingValues = true; |
94 | | - } else { |
95 | | - $hasExistingValues = false; |
96 | 96 | } |
97 | 97 | } |
98 | | - $html_text = '<p>Property name: '; |
| 98 | + $html_text = '<p>' . wfMsg( 'ps-optional-name' ) . ' '; |
99 | 99 | if ( array_key_exists( 'name', $prop_array ) ) { |
100 | 100 | $propName = $prop_array['name']; |
101 | 101 | } else { |
— | — | @@ -124,8 +124,8 @@ |
125 | 125 | $allowedValsInputAttrs = array( |
126 | 126 | 'size' => 80 |
127 | 127 | ); |
128 | | - if ( array_key_exists( 'allowed_value_array', $prop_array ) ) { |
129 | | - $allowed_val_string = implode( ', ', $prop_array['allowed_value_array'] ); |
| 128 | + if ( array_key_exists( 'allowed_values', $prop_array ) ) { |
| 129 | + $allowed_val_string = implode( ', ', $prop_array['allowed_values'] ); |
130 | 130 | } else { |
131 | 131 | $allowed_val_string = ''; |
132 | 132 | } |
— | — | @@ -137,19 +137,20 @@ |
138 | 138 | } |
139 | 139 | |
140 | 140 | function generatePages( $psSchemaObj, $toGenPageList ) { |
| 141 | + // Get the SMW info from every field in every template |
141 | 142 | $template_all = $psSchemaObj->getTemplates(); |
142 | 143 | foreach ( $template_all as $template ) { |
143 | 144 | $field_all = $template->getFields(); |
144 | | - $field_count = 0; //counts the number of fields |
145 | | - foreach( $field_all as $field ) { //for each Field, retrieve smw properties and fill $prop_name , $prop_type |
| 145 | + $field_count = 0; |
| 146 | + foreach( $field_all as $field ) { |
146 | 147 | $field_count++; |
147 | | - $smw_array = $field->getObject('semanticmediawiki_Property'); //this returns an array with property values filled |
| 148 | + $smw_array = $field->getObject('semanticmediawiki_Property'); |
148 | 149 | $prop_array = $smw_array['smw']; |
149 | 150 | if($prop_array != null){ |
150 | 151 | $title = Title::makeTitleSafe( SMW_NS_PROPERTY, $prop_array['name'] ); |
151 | 152 | $key_title = PageSchemas::titleString( $title ); |
152 | 153 | if(in_array( $key_title, $toGenPageList )){ |
153 | | - self::createProperty( $prop_array['name'], $prop_array['Type'], $prop_array['allowed_value_array'] ) ; |
| 154 | + self::createProperty( $prop_array['name'], $prop_array['Type'], $prop_array['allowed_values'] ) ; |
154 | 155 | } |
155 | 156 | } |
156 | 157 | } |
— | — | @@ -157,16 +158,16 @@ |
158 | 159 | return true; |
159 | 160 | } |
160 | 161 | |
161 | | - function createPropertyText( $property_type, $allowed_value_array ) { |
| 162 | + function createPropertyText( $property_type, $allowed_values ) { |
162 | 163 | global $smwgContLang; |
163 | 164 | $prop_labels = $smwgContLang->getPropertyLabels(); |
164 | 165 | $type_tag = "[[{$prop_labels['_TYPE']}::$property_type]]"; |
165 | 166 | $text = wfMsgForContent( 'ps-property-isproperty', $type_tag ); |
166 | | - if ( $allowed_value_array != null) { |
| 167 | + if ( $allowed_values != null) { |
167 | 168 | // replace the comma substitution character that has no chance of |
168 | 169 | // being included in the values list - namely, the ASCII beep |
169 | | - $text .= "\n\n" . wfMsgExt( 'ps-property-allowedvals', array( 'parsemag', 'content' ), count( $allowed_value_array ) ); |
170 | | - foreach ( $allowed_value_array as $i => $value ) { |
| 170 | + $text .= "\n\n" . wfMsgExt( 'ps-property-allowedvals', array( 'parsemag', 'content' ), count( $allowed_values ) ); |
| 171 | + foreach ( $allowed_values as $i => $value ) { |
171 | 172 | // replace beep back with comma, trim |
172 | 173 | $value = str_replace( "\a",',' , trim( $value ) ); |
173 | 174 | if ( method_exists( $smwgContLang, 'getPropertyLabels' ) ) { |
— | — | @@ -181,10 +182,10 @@ |
182 | 183 | return $text; |
183 | 184 | } |
184 | 185 | |
185 | | - function createProperty( $prop_name, $prop_type, $allowed_value_array ) { |
| 186 | + function createProperty( $prop_name, $prop_type, $allowed_values ) { |
186 | 187 | global $wgUser; |
187 | 188 | $title = Title::makeTitleSafe( SMW_NS_PROPERTY, $prop_name ); |
188 | | - $text = self::createPropertyText( $prop_type, $allowed_value_array ); |
| 189 | + $text = self::createPropertyText( $prop_type, $allowed_values ); |
189 | 190 | $jobs = array(); |
190 | 191 | $params = array(); |
191 | 192 | $params['user_id'] = $wgUser->getId(); |
— | — | @@ -203,18 +204,17 @@ |
204 | 205 | foreach ( $xmlForField->children() as $tag => $child ) { |
205 | 206 | if ( $tag == $objectName ) { |
206 | 207 | $propName = $child->attributes()->name; |
207 | | - //this means object has already been initialized by some other extension. |
208 | | - $smw_array['name']=(string)$propName; |
209 | | - $allowed_value_array = array(); |
| 208 | + $smw_array['name'] = (string)$propName; |
| 209 | + $allowed_values = array(); |
210 | 210 | $count = 0; |
211 | 211 | foreach ( $child->children() as $prop => $value ) { |
212 | 212 | if ( $prop == "AllowedValue" ) { |
213 | | - $allowed_value_array[$count++] = $value; |
| 213 | + $allowed_values[$count++] = $value; |
214 | 214 | } else { |
215 | 215 | $smw_array[$prop] = (string)$value; |
216 | 216 | } |
217 | 217 | } |
218 | | - $smw_array['allowed_value_array'] = $allowed_value_array; |
| 218 | + $smw_array['allowed_values'] = $allowed_values; |
219 | 219 | $object['smw'] = $smw_array; |
220 | 220 | return true; |
221 | 221 | } |
— | — | @@ -223,4 +223,3 @@ |
224 | 224 | return true; |
225 | 225 | } |
226 | 226 | } |
227 | | - |