Index: trunk/extensions/ArrayExtension/ArrayExtension.php |
— | — | @@ -38,7 +38,6 @@ |
39 | 39 | 'author' => array ( 'Li Ding', 'Jie Bao', 'Daniel Werner' ), |
40 | 40 | 'description' => 'Store and compute named arrays', |
41 | 41 | 'version' => ArrayExtension::VERSION, |
42 | | - |
43 | 42 | ); |
44 | 43 | |
45 | 44 | $wgHooks['LanguageGetMagic'][] = 'efArrayExtensionLanguageGetMagic'; |
— | — | @@ -49,7 +48,7 @@ |
50 | 49 | */ |
51 | 50 | class ArrayExtension { |
52 | 51 | |
53 | | - const VERSION = '1.3.2'; |
| 52 | + const VERSION = '1.3.3'; |
54 | 53 | |
55 | 54 | var $mArrayExtension = array(); |
56 | 55 | |
— | — | @@ -77,20 +76,22 @@ |
78 | 77 | * see also: http://us2.php.net/manual/en/function.preg-split.php |
79 | 78 | */ |
80 | 79 | function arraydefine( &$parser, $arrayid, $value = '', $delimiter = '/\s*,\s*/', $options = '', $delimiter2 = ', ', $search = '@@@@', $subject = '@@@@', $frame = null ) { |
81 | | - if ( !isset( $arrayid ) ) |
82 | | - return ''; |
| 80 | + if ( !isset( $arrayid ) ) { |
| 81 | + return ''; |
| 82 | + } |
83 | 83 | |
84 | 84 | // normalize |
85 | 85 | $value = trim( $value ); |
86 | 86 | $delimiter = trim( $delimiter ); |
87 | 87 | |
88 | | - if ( !$this->is_non_empty ( $value ) ) { |
| 88 | + if ( !$this->is_non_empty( $value ) ) { |
89 | 89 | $this->mArrayExtension[$arrayid] = array(); |
90 | 90 | } else if ( !$this->is_non_empty( $delimiter ) ) { |
91 | 91 | $this->mArrayExtension[$arrayid] = array( $value ); |
92 | 92 | } else { |
93 | | - if ( !$this->isValidRegEx( $delimiter ) ) |
94 | | - $delimiter = '/\s*' . preg_quote( $delimiter, '/' ) . '\s*/'; // Anpassung von Daniel Werner (preg_quote) |
| 93 | + if ( !$this->isValidRegEx( $delimiter ) ) { |
| 94 | + $delimiter = '/\s*' . preg_quote( $delimiter, '/' ) . '\s*/'; // Anpassung von Daniel Werner (preg_quote) |
| 95 | + } |
95 | 96 | |
96 | 97 | $this->mArrayExtension[$arrayid] = preg_split( $delimiter, $value ); |
97 | 98 | |
— | — | @@ -103,23 +104,32 @@ |
104 | 105 | // now parse the options, and do posterior process on the created array |
105 | 106 | $ary_option = $this->parse_options( $options ); |
106 | 107 | |
| 108 | + if ( !array_key_exists( 'empty', $ary_option ) ) { |
| 109 | + foreach ( $this->mArrayExtension[$arrayid] as $key => $value ) { |
| 110 | + if ( trim( $value ) == '' ) { |
| 111 | + unset( $this->mArrayExtension[$arrayid][$key] ); |
| 112 | + } |
| 113 | + } |
| 114 | + } |
| 115 | + |
107 | 116 | // make it unique if option is set |
108 | | - if ( FALSE !== array_key_exists( 'unique', $ary_option ) ) { |
109 | | - $this->arrayunique( $parser, $arrayid ); |
| 117 | + if ( array_key_exists( 'unique', $ary_option ) ) { |
| 118 | + $this->arrayunique( $parser, $arrayid ); |
110 | 119 | } |
111 | 120 | |
112 | 121 | // sort array if the option is set |
113 | | - $this->arraysort( $parser, $arrayid, $this->get_array_value( $ary_option, "sort" ) ); |
| 122 | + $this->arraysort( $parser, $arrayid, $this->get_array_value( $ary_option, 'sort' ) ); |
114 | 123 | |
115 | 124 | // print the array upon request |
116 | | - if ( strcmp( "list", $this->get_array_value( $ary_option, "print" ) ) === 0 ) { |
| 125 | + if ( strcmp( 'list', $this->get_array_value( $ary_option, 'print' ) ) === 0 ) { |
117 | 126 | return $this->arrayprint( $parser, $arrayid ); |
118 | | - } else if ( strcmp( "full", $this->get_array_value( $ary_option, "print" ) ) === 0 ) { |
| 127 | + } |
| 128 | + else if ( strcmp( 'full', $this->get_array_value( $ary_option, 'print' ) ) === 0 ) { |
119 | 129 | return $this->arrayprint( $parser, $arrayid, $delimiter2, $search, $subject, $frame ); |
120 | 130 | } |
121 | | - } |
| 131 | + } |
122 | 132 | |
123 | | - return ''; |
| 133 | + return ''; |
124 | 134 | } |
125 | 135 | |
126 | 136 | |