diff options
Diffstat (limited to 'type/Default.class.php')
-rw-r--r-- | type/Default.class.php | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/type/Default.class.php b/type/Default.class.php index e4d3dec..57d0bf3 100644 --- a/type/Default.class.php +++ b/type/Default.class.php | |||
@@ -197,24 +197,26 @@ class Type_Default { | |||
197 | # use data_sources as sources | 197 | # use data_sources as sources |
198 | $sources = $this->data_sources; | 198 | $sources = $this->data_sources; |
199 | } | 199 | } |
200 | $this->fill_ds_names($sources); | 200 | $this->parse_ds_names($sources); |
201 | return $sources; | 201 | return $sources; |
202 | } | 202 | } |
203 | 203 | ||
204 | function fill_ds_names($sources) { | 204 | function parse_ds_names($sources) { |
205 | # fill ds_names if not defined by plugin | ||
206 | if (!is_array($this->ds_names)) | ||
207 | $this->ds_names = array_combine($sources, $sources); | ||
208 | |||
209 | # detect length of longest ds_name | ||
205 | $max = 0; | 210 | $max = 0; |
206 | foreach ($sources as $source) { | 211 | foreach ($this->ds_names as $ds_name) { |
207 | if(strlen($source) > $max) { | 212 | if(strlen((string)$ds_name) > $max) |
208 | $max = strlen($source); | 213 | $max = strlen((string)$ds_name); |
209 | } | ||
210 | } | 214 | } |
211 | if($max > 0) { | 215 | |
212 | $fmt = sprintf("%%-%ds", $max); | 216 | # make all ds_names equal in lenght |
213 | foreach ($sources as $source) { | 217 | $format = sprintf("%%-%ds", $max); |
214 | if(!isset($this->ds_names[$source])) { | 218 | foreach ($this->ds_names as $index => $value) { |
215 | $this->ds_names[$source] = sprintf($fmt, $source); | 219 | $this->ds_names[$index] = sprintf($format, $value); |
216 | } | ||
217 | } | ||
218 | } | 220 | } |
219 | } | 221 | } |
220 | 222 | ||