@@ -16,17 +16,17 @@ discard block |
||
16 | 16 | ?> |
17 | 17 | <?php |
18 | 18 | |
19 | - $sort_by = isset($_GET['order']) ? $_GET['order'] : NULL; |
|
20 | - $sort_order = isset($_GET['sort']) ? $_GET['sort'] : 'asc'; |
|
19 | +$sort_by = isset($_GET['order']) ? $_GET['order'] : NULL; |
|
20 | +$sort_order = isset($_GET['sort']) ? $_GET['sort'] : 'asc'; |
|
21 | 21 | |
22 | - $team_forum_id = arg(4); |
|
22 | +$team_forum_id = arg(4); |
|
23 | 23 | |
24 | - $topics = $rows; |
|
24 | +$topics = $rows; |
|
25 | 25 | |
26 | - // Get the count of topics on this page |
|
27 | - $topic_count = count($topics); |
|
28 | - $topic_index = 0; |
|
29 | - $first_non_sticky = FALSE; |
|
26 | +// Get the count of topics on this page |
|
27 | +$topic_count = count($topics); |
|
28 | +$topic_index = 0; |
|
29 | +$first_non_sticky = FALSE; |
|
30 | 30 | |
31 | 31 | ?> |
32 | 32 | |
@@ -44,27 +44,27 @@ discard block |
||
44 | 44 | <tbody> |
45 | 45 | <?php foreach ($topics as $topic): ?> |
46 | 46 | <?php |
47 | - $topic = (object) $topic; |
|
48 | - $author = user_load($topic->uid); |
|
49 | - $topic_index++; |
|
50 | - $row_class = 'topic ' . $topic->zebra; |
|
51 | - if ($topic_index == 1) { |
|
52 | - $row_class .= ' first'; |
|
53 | - } |
|
54 | - if ($topic->sticky=="True") { |
|
55 | - $row_class .= ' sticky'; |
|
56 | - } |
|
57 | - elseif (!$first_non_sticky AND !($topic->sticky=="True")) { |
|
58 | - $row_class .= ' first-non-sticky'; |
|
59 | - $first_non_sticky = TRUE; |
|
60 | - } |
|
61 | - if ($topic_index == $topic_count) { |
|
62 | - $row_class .= ' last'; |
|
63 | - } |
|
64 | - if ($topic->timestamp=="new" OR $topic->new_comments) { |
|
65 | - $row_class .= ' updated'; |
|
66 | - } |
|
67 | - ?> |
|
47 | + $topic = (object) $topic; |
|
48 | + $author = user_load($topic->uid); |
|
49 | + $topic_index++; |
|
50 | + $row_class = 'topic ' . $topic->zebra; |
|
51 | + if ($topic_index == 1) { |
|
52 | + $row_class .= ' first'; |
|
53 | + } |
|
54 | + if ($topic->sticky=="True") { |
|
55 | + $row_class .= ' sticky'; |
|
56 | + } |
|
57 | + elseif (!$first_non_sticky AND !($topic->sticky=="True")) { |
|
58 | + $row_class .= ' first-non-sticky'; |
|
59 | + $first_non_sticky = TRUE; |
|
60 | + } |
|
61 | + if ($topic_index == $topic_count) { |
|
62 | + $row_class .= ' last'; |
|
63 | + } |
|
64 | + if ($topic->timestamp=="new" OR $topic->new_comments) { |
|
65 | + $row_class .= ' updated'; |
|
66 | + } |
|
67 | + ?> |
|
68 | 68 | <tr class="<?php print $row_class;?>"> |
69 | 69 | <td class="icon"><?php //print $topic->icon; ?> |
70 | 70 | <?php if ($topic->sticky=="True"): ?> |
@@ -84,37 +84,37 @@ discard block |
||
84 | 84 | <div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix<?php echo ($first_page) ? '' : ' not-first-page'; ?>"> |
85 | 85 | |
86 | 86 | <?php |
87 | - if ($page) { |
|
88 | - // Set topic title as page title |
|
89 | - drupal_set_title($title); |
|
90 | - $subtitle = array(); |
|
91 | - $team_forum_id = db_result(db_query(" |
|
87 | + if ($page) { |
|
88 | + // Set topic title as page title |
|
89 | + drupal_set_title($title); |
|
90 | + $subtitle = array(); |
|
91 | + $team_forum_id = db_result(db_query(" |
|
92 | 92 | SELECT tfid FROM {boincteam_forum_node} WHERE nid = %d", $node->nid |
93 | - )); |
|
94 | - $team_forum = boincteam_forum_load($team_forum_id); |
|
95 | - // Grab a sample forum topic node to get the forum vocabulary name |
|
96 | - $sample = db_result(db_query(" |
|
93 | + )); |
|
94 | + $team_forum = boincteam_forum_load($team_forum_id); |
|
95 | + // Grab a sample forum topic node to get the forum vocabulary name |
|
96 | + $sample = db_result(db_query(" |
|
97 | 97 | SELECT nid FROM {node} WHERE type = 'forum' LIMIT 1" |
98 | - )); |
|
99 | - $forum_node = node_load($sample); |
|
100 | - // Get vocabulary name and taxonomy name for subtitle breadcrumbs |
|
101 | - $taxonomy = taxonomy_get_term($forum_node->tid); |
|
98 | + )); |
|
99 | + $forum_node = node_load($sample); |
|
100 | + // Get vocabulary name and taxonomy name for subtitle breadcrumbs |
|
101 | + $taxonomy = taxonomy_get_term($forum_node->tid); |
|
102 | + if (module_exists('internationalization')) { |
|
103 | + $imv = i18ntaxonomy_localize_terms(array($taxonomy)); |
|
104 | + $taxonomy = reset($imv); |
|
105 | + } |
|
106 | + if ($forum_vocab = taxonomy_vocabulary_load($taxonomy->vid)) { |
|
102 | 107 | if (module_exists('internationalization')) { |
103 | - $imv = i18ntaxonomy_localize_terms(array($taxonomy)); |
|
104 | - $taxonomy = reset($imv); |
|
105 | - } |
|
106 | - if ($forum_vocab = taxonomy_vocabulary_load($taxonomy->vid)) { |
|
107 | - if (module_exists('internationalization')) { |
|
108 | - $forum_vocab->name = i18ntaxonomy_translate_vocabulary_name($forum_vocab); |
|
109 | - } |
|
110 | - $subtitle[] = l($forum_vocab->name, 'community/forum'); |
|
108 | + $forum_vocab->name = i18ntaxonomy_translate_vocabulary_name($forum_vocab); |
|
111 | 109 | } |
112 | - if ($team_forum) { |
|
113 | - $subtitle[] = l($team_forum->title, "community/teams/{$team_forum->nid}/forum/{$team_forum->tfid}"); |
|
114 | - } |
|
115 | - $subtitle = implode(' › ', $subtitle); |
|
110 | + $subtitle[] = l($forum_vocab->name, 'community/forum'); |
|
111 | + } |
|
112 | + if ($team_forum) { |
|
113 | + $subtitle[] = l($team_forum->title, "community/teams/{$team_forum->nid}/forum/{$team_forum->tfid}"); |
|
116 | 114 | } |
117 | - ?> |
|
115 | + $subtitle = implode(' › ', $subtitle); |
|
116 | + } |
|
117 | +?> |
|
118 | 118 | |
119 | 119 | <h2 class="title"><?php print $subtitle; ?></h2> |
120 | 120 | |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | <?php endif; ?> |
124 | 124 | |
125 | 125 | <?php |
126 | - if (!$oldest_post_first) { |
|
127 | - print comment_render($node); |
|
128 | - } |
|
129 | - ?> |
|
126 | + if (!$oldest_post_first) { |
|
127 | + print comment_render($node); |
|
128 | + } |
|
129 | +?> |
|
130 | 130 | <?php // Only show this post on the first or last page, depending on sort ?> |
131 | 131 | <?php if (($oldest_post_first AND $first_page) OR (!$oldest_post_first AND $last_page)): ?> |
132 | 132 | |
@@ -142,23 +142,23 @@ discard block |
||
142 | 142 | |
143 | 143 | <div class="user"> |
144 | 144 | <?php |
145 | - $account = user_load(array('uid' => $uid)); |
|
146 | - $user_image = boincuser_get_user_profile_image($uid); |
|
147 | - if ($user_image) { |
|
148 | - print '<div class="picture">'; |
|
149 | - if (is_array($user_image) AND $user_image['image']['filepath']) { |
|
150 | - //print theme('imagecache', 'thumbnail', $user_image['image']['filepath'], $user_image['alt'], $user_image['alt']); |
|
151 | - print theme('imagefield_image', $user_image['image'], $user_image['alt'], $user_image['alt'], array(), false); |
|
152 | - } |
|
153 | - elseif (is_string($user_image)) { |
|
154 | - print '<img src="' . $user_image . '"/>'; |
|
155 | - } |
|
156 | - print '</div>'; |
|
145 | + $account = user_load(array('uid' => $uid)); |
|
146 | + $user_image = boincuser_get_user_profile_image($uid); |
|
147 | + if ($user_image) { |
|
148 | + print '<div class="picture">'; |
|
149 | + if (is_array($user_image) AND $user_image['image']['filepath']) { |
|
150 | + //print theme('imagecache', 'thumbnail', $user_image['image']['filepath'], $user_image['alt'], $user_image['alt']); |
|
151 | + print theme('imagefield_image', $user_image['image'], $user_image['alt'], $user_image['alt'], array(), false); |
|
152 | + } |
|
153 | + elseif (is_string($user_image)) { |
|
154 | + print '<img src="' . $user_image . '"/>'; |
|
157 | 155 | } |
158 | - // Generate ignore user link |
|
159 | - $ignore_link = ignore_user_link('node', $node); |
|
160 | - //echo '<pre>' . print_r($node->links, TRUE) . '</pre>'; |
|
161 | - ?> |
|
156 | + print '</div>'; |
|
157 | + } |
|
158 | + // Generate ignore user link |
|
159 | + $ignore_link = ignore_user_link('node', $node); |
|
160 | + //echo '<pre>' . print_r($node->links, TRUE) . '</pre>'; |
|
161 | + ?> |
|
162 | 162 | <div class="name"><?php print $name; ?></div> |
163 | 163 | <?php if ($account->uid): ?> |
164 | 164 | <div class="join-date">Joined: <?php print date('j M y', $account->created); ?></div> |
@@ -168,15 +168,15 @@ discard block |
||
168 | 168 | |
169 | 169 | <div class="user-links"> |
170 | 170 | <div class="ignore-link"><?php print l($ignore_link['ignore_user']['title'], |
171 | - $ignore_link['ignore_user']['href'], |
|
172 | - array('query' => $ignore_link['ignore_user']['query'])); ?> |
|
171 | + $ignore_link['ignore_user']['href'], |
|
172 | + array('query' => $ignore_link['ignore_user']['query'])); ?> |
|
173 | 173 | </div> |
174 | 174 | <div class="pm-link"><?php |
175 | - if ($user->uid AND ($user->uid != $account->uid)) { |
|
176 | - print l(bts('Send message'), |
|
177 | - privatemsg_get_link(array($account)), |
|
178 | - array('query' => drupal_get_destination())); |
|
179 | - } ?> |
|
175 | + if ($user->uid AND ($user->uid != $account->uid)) { |
|
176 | + print l(bts('Send message'), |
|
177 | + privatemsg_get_link(array($account)), |
|
178 | + array('query' => drupal_get_destination())); |
|
179 | + } ?> |
|
180 | 180 | </div> |
181 | 181 | </div> |
182 | 182 | <?php endif; ?> |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | <?php endif; // page with topic starter post ?> |
223 | 223 | |
224 | 224 | <?php |
225 | - if ($oldest_post_first) { |
|
226 | - print comment_render($node); |
|
227 | - } |
|
228 | - ?> |
|
225 | + if ($oldest_post_first) { |
|
226 | + print comment_render($node); |
|
227 | + } |
|
228 | +?> |
|
229 | 229 | |
230 | 230 | </div> <!-- /.node --> |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | <tr class="<?php print $count % 2 == 0 ? 'odd' : 'even'; ?> <?php print $row->class ?>"> |
22 | 22 | <?php |
23 | 23 | switch ($row->row_type): |
24 | - case 'field': ?> |
|
24 | + case 'field': ?> |
|
25 | 25 | <td> |
26 | 26 | <?php print $row->indentation; ?> |
27 | 27 | <span class="<?php print $row->label_class; ?>"><?php print $row->label; ?></span> |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | <td><?php print $row->type; ?></td> |
32 | 32 | <td><?php print $row->configure; ?> <?php print $row->remove; ?></td> |
33 | 33 | <?php break; |
34 | - case 'group': ?> |
|
34 | + case 'group': ?> |
|
35 | 35 | <td> |
36 | 36 | <?php print $row->indentation; ?> |
37 | 37 | <span class="<?php print $row->label_class; ?>"><?php print $row->label; ?></span> |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | <td><?php print $row->group_type; ?></td> |
42 | 42 | <td><?php print $row->configure; ?> <?php print $row->remove; ?></td> |
43 | 43 | <?php break; |
44 | - case 'extra': ?> |
|
44 | + case 'extra': ?> |
|
45 | 45 | <td> |
46 | 46 | <?php print $row->indentation; ?> |
47 | 47 | <span class="<?php print $row->label_class; ?>"><?php print $row->label; ?></span> |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | <td colspan="2"><?php print $row->description; ?></td> |
51 | 51 | <td><?php print $row->configure; ?> <?php print $row->remove; ?></td> |
52 | 52 | <?php break; |
53 | - case 'separator': ?> |
|
53 | + case 'separator': ?> |
|
54 | 54 | <td colspan="5" class="region"><?php print t('Add'); ?></td> |
55 | 55 | <?php break; |
56 | - case 'add_new_field': ?> |
|
56 | + case 'add_new_field': ?> |
|
57 | 57 | <td> |
58 | 58 | <?php print $row->indentation; ?> |
59 | 59 | <div class="<?php print $row->label_class; ?>"> |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | <td><div class="content-new"> </div><?php print $row->type; ?></td> |
67 | 67 | <td><div class="content-new"> </div><?php print $row->widget_type; ?></td> |
68 | 68 | <?php break; |
69 | - case 'add_existing_field': ?> |
|
69 | + case 'add_existing_field': ?> |
|
70 | 70 | <td> |
71 | 71 | <?php print $row->indentation; ?> |
72 | 72 | <div class="<?php print $row->label_class; ?>"> |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | <td colspan="2"><div class="content-new"> </div><?php print $row->field_name; ?></td> |
79 | 79 | <td><div class="content-new"> </div><?php print $row->widget_type; ?></td> |
80 | 80 | <?php break; |
81 | - case 'add_new_group': ?> |
|
81 | + case 'add_new_group': ?> |
|
82 | 82 | <td> |
83 | 83 | <?php print $row->indentation; ?> |
84 | 84 | <div class="<?php print $row->label_class; ?>"> |
@@ -19,18 +19,18 @@ |
||
19 | 19 | <tr class="<?php print $count % 2 == 0 ? 'odd' : 'even'; ?>"> |
20 | 20 | <?php |
21 | 21 | switch ($row->row_type): |
22 | - case 'field': ?> |
|
22 | + case 'field': ?> |
|
23 | 23 | <td><?php print $row->checkbox; ?></td> |
24 | 24 | <td><?php print $row->indentation; ?><span class="<?php print $row->label_class; ?>"><?php print $row->human_name; ?></span></td> |
25 | 25 | <td><?php print $row->field_name; ?></td> |
26 | 26 | <td><?php print $row->type; ?></td> |
27 | 27 | <?php break; |
28 | - case 'group': ?> |
|
28 | + case 'group': ?> |
|
29 | 29 | <td><?php print $row->checkbox; ?></td> |
30 | 30 | <td><?php print $row->indentation; ?><span class="<?php print $row->label_class; ?>"><?php print $row->human_name; ?></span></td> |
31 | 31 | <td colspan="2"><?php print $row->group_name; ?></td> |
32 | 32 | <?php break; |
33 | - endswitch; ?> |
|
33 | + endswitch; ?> |
|
34 | 34 | </tr> |
35 | 35 | <?php $count++; |
36 | 36 | endforeach; ?> |
@@ -216,12 +216,12 @@ |
||
216 | 216 | } // defer |
217 | 217 | switch ($contents) { |
218 | 218 | // check for shorthand content model forms |
219 | - case 'Empty': |
|
220 | - return array('empty', ''); |
|
221 | - case 'Inline': |
|
222 | - return array('optional', 'Inline | #PCDATA'); |
|
223 | - case 'Flow': |
|
224 | - return array('optional', 'Flow | #PCDATA'); |
|
219 | + case 'Empty': |
|
220 | + return array('empty', ''); |
|
221 | + case 'Inline': |
|
222 | + return array('optional', 'Inline | #PCDATA'); |
|
223 | + case 'Flow': |
|
224 | + return array('optional', 'Flow | #PCDATA'); |
|
225 | 225 | } |
226 | 226 | list($content_model_type, $content_model) = explode(':', $contents); |
227 | 227 | $content_model_type = strtolower(trim($content_model_type)); |
@@ -576,10 +576,10 @@ |
||
576 | 576 | } |
577 | 577 | $lenc = strtolower($encoding); |
578 | 578 | switch ($lenc) { |
579 | - case 'shift_jis': |
|
580 | - return array("\xC2\xA5" => '\\', "\xE2\x80\xBE" => '~'); |
|
581 | - case 'johab': |
|
582 | - return array("\xE2\x82\xA9" => '\\'); |
|
579 | + case 'shift_jis': |
|
580 | + return array("\xC2\xA5" => '\\', "\xE2\x80\xBE" => '~'); |
|
581 | + case 'johab': |
|
582 | + return array("\xE2\x82\xA9" => '\\'); |
|
583 | 583 | } |
584 | 584 | if (strpos($lenc, 'iso-8859-') === 0) { |
585 | 585 | return array(); |
@@ -181,34 +181,34 @@ |
||
181 | 181 | $lclass = strtolower($class); |
182 | 182 | $class .= '('; |
183 | 183 | switch ($lclass) { |
184 | - case 'enum': |
|
185 | - $values = array(); |
|
186 | - foreach ($obj->valid_values as $value => $bool) { |
|
187 | - $values[] = $value; |
|
188 | - } |
|
189 | - $class .= implode(', ', $values); |
|
190 | - break; |
|
191 | - case 'css_composite': |
|
192 | - $values = array(); |
|
193 | - foreach ($obj->defs as $def) { |
|
194 | - $values[] = $this->getClass($def, $sec_prefix); |
|
195 | - } |
|
196 | - $class .= implode(', ', $values); |
|
197 | - break; |
|
198 | - case 'css_multiple': |
|
199 | - $class .= $this->getClass($obj->single, $sec_prefix) . ', '; |
|
200 | - $class .= $obj->max; |
|
201 | - break; |
|
202 | - case 'css_denyelementdecorator': |
|
203 | - $class .= $this->getClass($obj->def, $sec_prefix) . ', '; |
|
204 | - $class .= $obj->element; |
|
205 | - break; |
|
206 | - case 'css_importantdecorator': |
|
207 | - $class .= $this->getClass($obj->def, $sec_prefix); |
|
208 | - if ($obj->allow) { |
|
209 | - $class .= ', !important'; |
|
210 | - } |
|
211 | - break; |
|
184 | + case 'enum': |
|
185 | + $values = array(); |
|
186 | + foreach ($obj->valid_values as $value => $bool) { |
|
187 | + $values[] = $value; |
|
188 | + } |
|
189 | + $class .= implode(', ', $values); |
|
190 | + break; |
|
191 | + case 'css_composite': |
|
192 | + $values = array(); |
|
193 | + foreach ($obj->defs as $def) { |
|
194 | + $values[] = $this->getClass($def, $sec_prefix); |
|
195 | + } |
|
196 | + $class .= implode(', ', $values); |
|
197 | + break; |
|
198 | + case 'css_multiple': |
|
199 | + $class .= $this->getClass($obj->single, $sec_prefix) . ', '; |
|
200 | + $class .= $obj->max; |
|
201 | + break; |
|
202 | + case 'css_denyelementdecorator': |
|
203 | + $class .= $this->getClass($obj->def, $sec_prefix) . ', '; |
|
204 | + $class .= $obj->element; |
|
205 | + break; |
|
206 | + case 'css_importantdecorator': |
|
207 | + $class .= $this->getClass($obj->def, $sec_prefix); |
|
208 | + if ($obj->allow) { |
|
209 | + $class .= ', !important'; |
|
210 | + } |
|
211 | + break; |
|
212 | 212 | } |
213 | 213 | $class .= ')'; |
214 | 214 | return $class; |
@@ -23,105 +23,105 @@ |
||
23 | 23 | // Note: if code "breaks" from the switch, it triggers a generic |
24 | 24 | // exception to be thrown. Specific errors can be specifically |
25 | 25 | // done here. |
26 | - case self::MIXED: |
|
27 | - case self::ISTRING: |
|
28 | - case self::STRING: |
|
29 | - case self::TEXT: |
|
30 | - case self::ITEXT: |
|
31 | - return $var; |
|
32 | - case self::INT: |
|
33 | - if (is_string($var) && ctype_digit($var)) { |
|
34 | - $var = (int)$var; |
|
26 | + case self::MIXED: |
|
27 | + case self::ISTRING: |
|
28 | + case self::STRING: |
|
29 | + case self::TEXT: |
|
30 | + case self::ITEXT: |
|
31 | + return $var; |
|
32 | + case self::INT: |
|
33 | + if (is_string($var) && ctype_digit($var)) { |
|
34 | + $var = (int)$var; |
|
35 | + } |
|
36 | + return $var; |
|
37 | + case self::FLOAT: |
|
38 | + if ((is_string($var) && is_numeric($var)) || is_int($var)) { |
|
39 | + $var = (float)$var; |
|
40 | + } |
|
41 | + return $var; |
|
42 | + case self::BOOL: |
|
43 | + if (is_int($var) && ($var === 0 || $var === 1)) { |
|
44 | + $var = (bool)$var; |
|
45 | + } elseif (is_string($var)) { |
|
46 | + if ($var == 'on' || $var == 'true' || $var == '1') { |
|
47 | + $var = true; |
|
48 | + } elseif ($var == 'off' || $var == 'false' || $var == '0') { |
|
49 | + $var = false; |
|
50 | + } else { |
|
51 | + throw new HTMLPurifier_VarParserException("Unrecognized value '$var' for $type"); |
|
35 | 52 | } |
36 | - return $var; |
|
37 | - case self::FLOAT: |
|
38 | - if ((is_string($var) && is_numeric($var)) || is_int($var)) { |
|
39 | - $var = (float)$var; |
|
53 | + } |
|
54 | + return $var; |
|
55 | + case self::ALIST: |
|
56 | + case self::HASH: |
|
57 | + case self::LOOKUP: |
|
58 | + if (is_string($var)) { |
|
59 | + // special case: technically, this is an array with |
|
60 | + // a single empty string item, but having an empty |
|
61 | + // array is more intuitive |
|
62 | + if ($var == '') { |
|
63 | + return array(); |
|
40 | 64 | } |
41 | - return $var; |
|
42 | - case self::BOOL: |
|
43 | - if (is_int($var) && ($var === 0 || $var === 1)) { |
|
44 | - $var = (bool)$var; |
|
45 | - } elseif (is_string($var)) { |
|
46 | - if ($var == 'on' || $var == 'true' || $var == '1') { |
|
47 | - $var = true; |
|
48 | - } elseif ($var == 'off' || $var == 'false' || $var == '0') { |
|
49 | - $var = false; |
|
50 | - } else { |
|
51 | - throw new HTMLPurifier_VarParserException("Unrecognized value '$var' for $type"); |
|
52 | - } |
|
65 | + if (strpos($var, "\n") === false && strpos($var, "\r") === false) { |
|
66 | + // simplistic string to array method that only works |
|
67 | + // for simple lists of tag names or alphanumeric characters |
|
68 | + $var = explode(',', $var); |
|
69 | + } else { |
|
70 | + $var = preg_split('/(,|[\n\r]+)/', $var); |
|
53 | 71 | } |
54 | - return $var; |
|
55 | - case self::ALIST: |
|
56 | - case self::HASH: |
|
57 | - case self::LOOKUP: |
|
58 | - if (is_string($var)) { |
|
59 | - // special case: technically, this is an array with |
|
60 | - // a single empty string item, but having an empty |
|
61 | - // array is more intuitive |
|
62 | - if ($var == '') { |
|
63 | - return array(); |
|
64 | - } |
|
65 | - if (strpos($var, "\n") === false && strpos($var, "\r") === false) { |
|
66 | - // simplistic string to array method that only works |
|
67 | - // for simple lists of tag names or alphanumeric characters |
|
68 | - $var = explode(',', $var); |
|
69 | - } else { |
|
70 | - $var = preg_split('/(,|[\n\r]+)/', $var); |
|
71 | - } |
|
72 | - // remove spaces |
|
73 | - foreach ($var as $i => $j) { |
|
74 | - $var[$i] = trim($j); |
|
75 | - } |
|
76 | - if ($type === self::HASH) { |
|
77 | - // key:value,key2:value2 |
|
78 | - $nvar = array(); |
|
79 | - foreach ($var as $keypair) { |
|
80 | - $c = explode(':', $keypair, 2); |
|
81 | - if (!isset($c[1])) { |
|
82 | - continue; |
|
83 | - } |
|
84 | - $nvar[trim($c[0])] = trim($c[1]); |
|
85 | - } |
|
86 | - $var = $nvar; |
|
87 | - } |
|
72 | + // remove spaces |
|
73 | + foreach ($var as $i => $j) { |
|
74 | + $var[$i] = trim($j); |
|
88 | 75 | } |
89 | - if (!is_array($var)) { |
|
90 | - break; |
|
91 | - } |
|
92 | - $keys = array_keys($var); |
|
93 | - if ($keys === array_keys($keys)) { |
|
94 | - if ($type == self::ALIST) { |
|
95 | - return $var; |
|
96 | - } elseif ($type == self::LOOKUP) { |
|
97 | - $new = array(); |
|
98 | - foreach ($var as $key) { |
|
99 | - $new[$key] = true; |
|
76 | + if ($type === self::HASH) { |
|
77 | + // key:value,key2:value2 |
|
78 | + $nvar = array(); |
|
79 | + foreach ($var as $keypair) { |
|
80 | + $c = explode(':', $keypair, 2); |
|
81 | + if (!isset($c[1])) { |
|
82 | + continue; |
|
100 | 83 | } |
101 | - return $new; |
|
102 | - } else { |
|
103 | - break; |
|
84 | + $nvar[trim($c[0])] = trim($c[1]); |
|
104 | 85 | } |
86 | + $var = $nvar; |
|
105 | 87 | } |
106 | - if ($type === self::ALIST) { |
|
107 | - trigger_error("Array list did not have consecutive integer indexes", E_USER_WARNING); |
|
108 | - return array_values($var); |
|
88 | + } |
|
89 | + if (!is_array($var)) { |
|
90 | + break; |
|
91 | + } |
|
92 | + $keys = array_keys($var); |
|
93 | + if ($keys === array_keys($keys)) { |
|
94 | + if ($type == self::ALIST) { |
|
95 | + return $var; |
|
96 | + } elseif ($type == self::LOOKUP) { |
|
97 | + $new = array(); |
|
98 | + foreach ($var as $key) { |
|
99 | + $new[$key] = true; |
|
100 | + } |
|
101 | + return $new; |
|
102 | + } else { |
|
103 | + break; |
|
109 | 104 | } |
110 | - if ($type === self::LOOKUP) { |
|
111 | - foreach ($var as $key => $value) { |
|
112 | - if ($value !== true) { |
|
113 | - trigger_error( |
|
114 | - "Lookup array has non-true value at key '$key'; " . |
|
115 | - "maybe your input array was not indexed numerically", |
|
116 | - E_USER_WARNING |
|
117 | - ); |
|
118 | - } |
|
119 | - $var[$key] = true; |
|
105 | + } |
|
106 | + if ($type === self::ALIST) { |
|
107 | + trigger_error("Array list did not have consecutive integer indexes", E_USER_WARNING); |
|
108 | + return array_values($var); |
|
109 | + } |
|
110 | + if ($type === self::LOOKUP) { |
|
111 | + foreach ($var as $key => $value) { |
|
112 | + if ($value !== true) { |
|
113 | + trigger_error( |
|
114 | + "Lookup array has non-true value at key '$key'; " . |
|
115 | + "maybe your input array was not indexed numerically", |
|
116 | + E_USER_WARNING |
|
117 | + ); |
|
120 | 118 | } |
119 | + $var[$key] = true; |
|
121 | 120 | } |
122 | - return $var; |
|
123 | - default: |
|
124 | - $this->errorInconsistent(__CLASS__, $type); |
|
121 | + } |
|
122 | + return $var; |
|
123 | + default: |
|
124 | + $this->errorInconsistent(__CLASS__, $type); |
|
125 | 125 | } |
126 | 126 | $this->errorGeneric($var, $type); |
127 | 127 | } |
@@ -30,23 +30,23 @@ |
||
30 | 30 | // process primary subtag : $subtags[0] |
31 | 31 | $length = strlen($subtags[0]); |
32 | 32 | switch ($length) { |
33 | - case 0: |
|
33 | + case 0: |
|
34 | + return false; |
|
35 | + case 1: |
|
36 | + if (!($subtags[0] == 'x' || $subtags[0] == 'i')) { |
|
34 | 37 | return false; |
35 | - case 1: |
|
36 | - if (!($subtags[0] == 'x' || $subtags[0] == 'i')) { |
|
37 | - return false; |
|
38 | - } |
|
39 | - break; |
|
40 | - case 2: |
|
41 | - case 3: |
|
42 | - if (!ctype_alpha($subtags[0])) { |
|
43 | - return false; |
|
44 | - } elseif (!ctype_lower($subtags[0])) { |
|
45 | - $subtags[0] = strtolower($subtags[0]); |
|
46 | - } |
|
47 | - break; |
|
48 | - default: |
|
38 | + } |
|
39 | + break; |
|
40 | + case 2: |
|
41 | + case 3: |
|
42 | + if (!ctype_alpha($subtags[0])) { |
|
49 | 43 | return false; |
44 | + } elseif (!ctype_lower($subtags[0])) { |
|
45 | + $subtags[0] = strtolower($subtags[0]); |
|
46 | + } |
|
47 | + break; |
|
48 | + default: |
|
49 | + return false; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $new_string = $subtags[0]; |