00001 <?php
00002
00016 class SMWDeclare {
00017
00027 public static function render( Parser &$parser, PPFrame $frame, array $args ) {
00028 if ( $frame->isTemplate() ) {
00029 foreach ( $args as $arg )
00030 if ( trim( $arg ) !== '' ) {
00031 $expanded = trim( $frame->expand( $arg ) );
00032 $parts = explode( '=', $expanded, 2 );
00033
00034 if ( count( $parts ) == 1 ) {
00035 $propertystring = $expanded;
00036 $argumentname = $expanded;
00037 } else {
00038 $propertystring = $parts[0];
00039 $argumentname = $parts[1];
00040 }
00041
00042 $property = SMWPropertyValue::makeUserProperty( $propertystring );
00043 $argument = $frame->getArgument( $argumentname );
00044 $valuestring = $frame->expand( $argument );
00045
00046 if ( $property->isValid() ) {
00047 $type = $property->getPropertyTypeID();
00048
00049 if ( $type == '_wpg' ) {
00050 $matches = array();
00051 preg_match_all( '/\[\[([^\[\]]*)\]\]/u', $valuestring, $matches );
00052 $objects = $matches[1];
00053
00054 if ( count( $objects ) == 0 ) {
00055 if ( trim( $valuestring ) !== '' ) {
00056 SMWParseData::addProperty( $propertystring, $valuestring, false, $parser, true );
00057 }
00058 } else {
00059 foreach ( $objects as $object ) {
00060 SMWParseData::addProperty( $propertystring, $object, false, $parser, true );
00061 }
00062 }
00063 } elseif ( trim( $valuestring ) !== '' ) {
00064 SMWParseData::addProperty( $propertystring, $valuestring, false, $parser, true );
00065 }
00066
00067
00068
00069 }
00070 }
00071 } else {
00072
00073 }
00074
00075 global $wgTitle;
00076 if ( !is_null( $wgTitle ) && $wgTitle->isSpecialPage() ) {
00077 global $wgOut;
00078 SMWOutputs::commitToOutputPage( $wgOut );
00079 }
00080 else {
00081 SMWOutputs::commitToParser( $parser );
00082 }
00083
00084 return '';
00085 }
00086
00087 }