r82382 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82381‎ | r82382 | r82383 >
Date:07:06, 18 February 2011
Author:yaron
Status:deferred
Tags:
Comment:
Further changes for the modifications to the form syntax
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php
@@ -686,16 +686,13 @@
687687 }
688688 } elseif ( $sub_components[0] == 'autocomplete on property' ) {
689689 $property_name = $sub_components[1];
690 - $propValue = SMWPropertyValue::makeUserProperty( $this->semantic_property );
691 - if ( $propValue->getPropertyID() == '_wpg' ) {
 690+ $propValue = SMWPropertyValue::makeUserProperty( $property_name );
 691+ if ( $propValue->getPropertyTypeID() == '_wpg' ) {
692692 $field_args['autocomplete field type'] = 'relation';
693693 } else {
694694 $field_args['autocomplete field type'] = 'attribute';
695695 }
696696 $field_args['autocompletion source'] = $sub_components[1];
697 - } elseif ( $sub_components[0] == 'autocomplete on' ) { // for backwards-compatibility
698 - $field_args['autocomplete field type'] = 'category';
699 - $field_args['autocompletion source'] = $sub_components[1];
700697 } elseif ( $sub_components[0] == 'autocomplete on category' ) {
701698 $field_args['autocomplete field type'] = 'category';
702699 $field_args['autocompletion source'] = $sub_components[1];
@@ -718,23 +715,27 @@
719716 // remove whitespaces, and un-escape characters
720717 $possible_values = array_map( 'trim', explode( ',', $sub_components[1] ) );
721718 $possible_values = array_map( 'htmlspecialchars_decode', $possible_values );
 719+ } elseif ( $sub_components[0] == 'values from property' ) {
 720+ $propertyName = $sub_components[1];
 721+ $propValue = SMWPropertyValue::makeUserProperty( $propertyName );
 722+ $isRelation = $propValue->getPropertyTypeID() == '_wpg';
 723+ $possible_values = SFAutocompleteAPI::getAllValuesForProperty( $isRelation, $propertyName );
722724 } elseif ( $sub_components[0] == 'values from category' ) {
723725 $category_name = ucfirst( $sub_components[1] );
724726 $possible_values = SFUtils::getAllPagesForCategory( $category_name, 10 );
725727 } elseif ( $sub_components[0] == 'values from concept' ) {
726728 $possible_values = SFUtils::getAllPagesForConcept( $sub_components[1] );
 729+ } elseif ( $sub_components[0] == 'values from namespace' ) {
 730+ $possible_values = SFUtils::getAllPagesForNamespace( $sub_components[1] );
727731 } elseif ( $sub_components[0] == 'property' ) {
728732 $semantic_property = $sub_components[1];
729733 } elseif ( $sub_components[0] == 'default filename' ) {
730734 $default_filename = str_replace( '<page name>', $page_name, $sub_components[1] );
731735 $field_args['default filename'] = $default_filename;
732 - } else {
733 - $field_args[$sub_components[0]] = $sub_components[1];
734736 }
735 - // for backwards compatibility
736 - if ( $sub_components[0] == 'autocomplete on' && $sub_components[1] == null ) {
737 - $field_args['no autocomplete'] = true;
738 - }
 737+
 738+ // Also set each value as its own entry in $field_args
 739+ $field_args[$sub_components[0]] = $sub_components[1];
739740 }
740741 }
741742 } // end for
@@ -1420,8 +1421,9 @@
14211422 $other_args = $form_field->getArgumentsForInputCall();
14221423 // special call to ensure that a list input is the right default size
14231424 if ( $form_field->is_list ) {
1424 - if ( ! array_key_exists( 'size', $other_args ) )
 1425+ if ( ! array_key_exists( 'size', $other_args ) ) {
14251426 $other_args['size'] = 100;
 1427+ }
14261428 }
14271429 $text = SFTextInput::getHTML( $cur_value, $form_field->input_name, $form_field->is_mandatory, $form_field->is_disabled, $other_args );
14281430 }