• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisión4b4d73d6ecd12cbc4991d387674cebb06bf6853e (tree)
Tiempo2004-08-12 23:56:22
Autorhenoheno <henoheno>
Commiterhenoheno

Log Message

Shrink. Added spaces

Cambiar Resumen

Diferencia incremental

--- a/plugin/ls2.inc.php
+++ b/plugin/ls2.inc.php
@@ -2,7 +2,7 @@
22 /////////////////////////////////////////////////
33 // PukiWiki - Yet another WikiWikiWeb clone.
44 //
5-// $Id: ls2.inc.php,v 1.20 2004/08/12 14:26:58 henoheno Exp $
5+// $Id: ls2.inc.php,v 1.21 2004/08/12 14:56:22 henoheno Exp $
66 //
77
88 /*
@@ -34,7 +34,7 @@ action
3434 LS2_LIST_COMPACTがTRUEの時は無効(変化しない)
3535
3636 - タイトル
37-見出しのタイトルを指定する
37+見出しのタイトルを指定する (linkを指定した時のみ)
3838
3939 */
4040
@@ -53,8 +53,7 @@ function plugin_ls2_action()
5353 global $_ls2_msg_title;
5454
5555 $params = array();
56- foreach (array('title', 'include', 'reverse') as $key)
57- {
56+ foreach (array('title', 'include', 'reverse') as $key) {
5857 $params[$key] = isset($vars[$key]);
5958 }
6059 $prefix = isset($vars['prefix']) ? $vars['prefix'] : '';
@@ -71,21 +70,6 @@ function plugin_ls2_convert()
7170 global $script, $vars;
7271 global $_ls2_msg_title;
7372
74- $prefix = '';
75- if (func_num_args())
76- {
77- $args = func_get_args();
78- $prefix = array_shift($args);
79- }
80- else
81- {
82- $args = array();
83- }
84- if ($prefix == '')
85- {
86- $prefix = strip_bracket($vars['page']) . '/';
87- }
88-
8973 $params = array(
9074 'link' => FALSE,
9175 'title' => FALSE,
@@ -95,116 +79,107 @@ function plugin_ls2_convert()
9579 '_args' => array(),
9680 '_done' => FALSE
9781 );
82+
83+ $args = array();
84+ $prefix = '';
85+ if (func_num_args()) {
86+ $args = func_get_args();
87+ $prefix = array_shift($args);
88+ }
89+ if ($prefix == '') {
90+ $prefix = strip_bracket($vars['page']) . '/';
91+ }
92+
9893 array_walk($args, 'ls2_check_arg', & $params);
9994
100- $title = (count($params['_args']) > 0) ?
101- htmlspecialchars(join(',', $params['_args'])) :
102- str_replace('$1', htmlspecialchars($prefix), $_ls2_msg_title);
95+ $title = (! empty($params['_args'])) ?
96+ htmlspecialchars(join(',', $params['_args'])) : // Manual
97+ str_replace('$1', htmlspecialchars($prefix), $_ls2_msg_title); // Auto
10398
104- if ($params['link'])
105- {
99+ if ($params['link']) {
106100 $tmp = array();
107101 $tmp[] = 'plugin=ls2&amp;prefix=' . rawurlencode($prefix);
108- if (isset($params['title']))
109- {
102+ if (isset($params['title'])) {
110103 $tmp[] = 'title=1';
111104 }
112- if (isset($params['include']))
113- {
105+ if (isset($params['include'])) {
114106 $tmp[] = 'include=1';
115107 }
116108 return '<p><a href="' . $script . '?' . join('&amp;', $tmp) . '">' . $title . '</a></p>' . "\n";
109+ } else {
110+ return ls2_show_lists($prefix, $params);
117111 }
118- return ls2_show_lists($prefix, $params);
119112 }
120113
121-function ls2_show_lists($prefix, &$params)
114+function ls2_show_lists($prefix, & $params)
122115 {
123116 global $_ls2_err_nopages;
124117
125- if (strlen($prefix))
126- {
127- $pages = array();
128- foreach (get_existpages() as $_page)
129- {
118+ $pages = array();
119+ if (strlen($prefix)) {
120+ foreach (get_existpages() as $_page) {
130121 if (strpos($_page, $prefix) === 0)
131- {
132122 $pages[] = $_page;
133- }
134123 }
135- }
136- else
137- {
124+ } else {
138125 $pages = get_existpages();
139126 }
127+
140128 natcasesort($pages);
129+ if ($params['reverse']) $pages = array_reverse($pages);
141130
142- if ($params['reverse'])
143- {
144- $pages = array_reverse($pages);
145- }
146- foreach ($pages as $page)
147- {
131+ foreach ($pages as $page) {
148132 $params["page_$page"] = 0;
149133 }
150- if (count($pages) == 0)
151- {
152- return str_replace('$1', htmlspecialchars($prefix), $_ls2_err_nopages);
153- }
154134
155- $params['result'] = array();
156- $params['saved'] = array();
157- foreach ($pages as $page)
158- {
159- ls2_get_headings($page, $params, 1);
135+ if (count($pages) == 0) {
136+ return str_replace('$1', htmlspecialchars($prefix), $_ls2_err_nopages);
137+ } else {
138+ $params['result'] = $params['saved'] = array();
139+ foreach ($pages as $page) {
140+ ls2_get_headings($page, $params, 1);
141+ }
142+ return join("\n", $params['result']) . join("\n", $params['saved']);
160143 }
161- return join("\n", $params['result']) . join("\n", $params['saved']);
162144 }
163145
164-function ls2_get_headings($page, &$params, $level, $include = FALSE)
146+function ls2_get_headings($page, & $params, $level, $include = FALSE)
165147 {
166148 global $script;
167149 static $_ls2_anchor = 0;
168150
169- $is_done = (isset($params["page_$page"]) and $params["page_$page"] > 0); //ページが表示済みのときTrue
170-
171- if (!$is_done)
172- {
173- $params["page_$page"] = ++$_ls2_anchor;
174- }
151+ // ページが未表示のとき
152+ $is_done = (isset($params["page_$page"]) && $params["page_$page"] > 0);
153+ if (! $is_done) $params["page_$page"] = ++$_ls2_anchor;
175154
176155 $r_page = rawurlencode($page);
177156 $s_page = htmlspecialchars($page);
178- $title = $s_page . ' ' . get_pg_passage($page, FALSE);
179- $href = $script . '?cmd=read&amp;page=' . $r_page;
157+ $title = $s_page . ' ' . get_pg_passage($page, FALSE);
158+ $href = $script . '?cmd=read&amp;page=' . $r_page;
180159
181160 ls2_list_push($params, $level);
182161 $ret = $include ? '<li>include ' : '<li>';
183- if ($params['title'] and $is_done)
184- {
162+
163+ if ($params['title'] && $is_done) {
185164 $ret .= "<a href=\"$href\" title=\"$title\">$s_page</a> ";
186165 $ret .= "<a href=\"#list_{$params["page_$page"]}\"><sup>&uarr;</sup></a>";
187166 array_push($params['result'], $ret);
188167 return;
189168 }
190- else
191- {
192- $ret .= "<a id=\"list_{$params["page_$page"]}\" href=\"$href\" title=\"$title\">$s_page</a>";
193- array_push($params['result'], $ret);
194- }
169+
170+ $ret .= "<a id=\"list_{$params["page_$page"]}\" href=\"$href\" title=\"$title\">$s_page</a>";
171+ array_push($params['result'], $ret);
195172
196173 $anchor = LS2_ANCHOR_ORIGIN;
197- foreach (get_source($page) as $line)
198- {
199- if ($params['title'] and preg_match('/^(\*{1,3})/', $line, $matches))
200- {
201- $id = make_heading($line);
174+ $matches = array();
175+ foreach (get_source($page) as $line) {
176+ if ($params['title'] && preg_match('/^(\*{1,3})/', $line, $matches)) {
177+ $id = make_heading($line);
202178 $level = strlen($matches[1]);
203- $id = LS2_CONTENT_HEAD . $anchor++;
179+ $id = LS2_CONTENT_HEAD . $anchor++;
204180 ls2_list_push($params, $level + strlen($level));
205181 array_push($params['result'], "<li><a href=\"$href$id\">$line</a>");
206- }
207- else if ($params['include']
182+ } else if ($params['include']
208183 and preg_match('/^#include\((.+)\)/', $line, $matches) and is_page($matches[1]))
209184 {
210185 ls2_get_headings($matches[1], $params, $level + 1, TRUE);
@@ -213,75 +188,63 @@ function ls2_get_headings($page, &$params, $level, $include = FALSE)
213188 }
214189
215190 //リスト構造を構築する
216-function ls2_list_push(&$params, $level)
191+function ls2_list_push(& $params, $level)
217192 {
218193 global $_ul_left_margin, $_ul_margin, $_list_pad_str;
219194
220- $result =& $params['result'];
221- $saved =& $params['saved'];
195+ $result = & $params['result'];
196+ $saved = & $params['saved'];
222197 $cont = TRUE;
223- $open = "<ul%s>";
198+ $open = '<ul%s>';
224199 $close = '</li></ul>';
225200
226- while (count($saved) > $level or
227- (count($saved) > 0 and $saved[0] != $close))
228- {
201+ while (count($saved) > $level ||
202+ (! empty($saved) && $saved[0] != $close)) {
229203 array_push($result, array_shift($saved));
230204 }
231205
232206 $margin = $level - count($saved);
233207
234- while (count($saved) < ($level - 1))
235- {
208+ while (count($saved) < ($level - 1)) {
236209 array_unshift($saved, ''); //count($saved)を増やすためのdummy
237210 }
238211
239- if (count($saved) < $level)
240- {
212+ if (count($saved) < $level) {
241213 $cont = FALSE;
242214 array_unshift($saved, $close);
243215
244216 $left = ($level == $margin) ? $_ul_left_margin : 0;
245- if ($params['compact'])
246- {
247- // マージンを固定
248- $left += $_ul_margin;
249- // レベルを修正
250- $level -= ($margin - 1);
251- }
252- else
253- {
217+ if (isset($params['compact'])) {
218+ $left += $_ul_margin; // マージンを固定
219+ $level -= ($margin - 1); // レベルを修正
220+ } else {
254221 $left += $margin * $_ul_margin;
255222 }
256223 $str = sprintf($_list_pad_str, $level, $left, $left);
257224 array_push($result, sprintf($open, $str));
258225 }
259- if ($cont)
260- {
261- array_push($result, '</li>');
262- }
226+
227+ if ($cont) array_push($result, '</li>');
263228 }
264229
265230 //オプションを解析する
266-function ls2_check_arg($val, $key, &$params)
231+function ls2_check_arg($value, $key, & $params)
267232 {
268- if ($val == '')
269- {
233+ if ($value == '') {
270234 $params['_done'] = TRUE;
271235 return;
272236 }
273- if (!$params['_done'])
274- {
275- foreach (array_keys($params) as $key)
276- {
277- if (strpos($key, strtolower($val)) === 0)
278- {
279- $params[$key] = TRUE;
237+
238+ if (! $params['_done']) {
239+ foreach (array_keys($params) as $param) {
240+ if (strpos($param, strtolower($value)) === 0) {
241+ $params[$param] = TRUE;
280242 return;
281243 }
282244 }
283245 $params['_done'] = TRUE;
284246 }
285- $params['_args'][] = $val;
247+
248+ $params['_args'][] = $value;
286249 }
287250 ?>