Nucleus CMS日本語版用プラグインのうち、日本語版開発者がサポートしているもの
Revision | ba7f57d45b913593cb7b7458dfee041c090fdeb9 (tree) |
---|---|
Time | 2006-11-04 23:06:35 |
Author | shizuki <shizuki@1ca2...> |
Commiter | shizuki |
bug fix
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@474 1ca29b6e-896d-4ea0-84a5-967f57386b96
@@ -1,21 +1,46 @@ | ||
1 | 1 | <?php |
2 | -class NP_SearchResultsEX extends NucleusPlugin { | |
3 | - function getName() { return 'SearchResults EX'; } | |
4 | - function getAuthor() { return 'Taka + nakahara21 + Andy + shizuki'; } | |
5 | - function getURL() { return 'http://shizuki.kinezumi.net/NucleusCMS/Plugins/SearchResultsEX/'; } | |
6 | - function getVersion() { return '0.01'; } | |
7 | - function getDescription() { | |
2 | +class NP_SearchResultsEX extends NucleusPlugin | |
3 | +{ | |
4 | + function getName() | |
5 | + { | |
6 | + return 'SearchResults EX'; | |
7 | + } | |
8 | + | |
9 | + function getAuthor() | |
10 | + { | |
11 | + return 'Taka + nakahara21 + Andy + shizuki'; | |
12 | + } | |
13 | + | |
14 | + function getURL() | |
15 | + { | |
16 | + return 'http://shizuki.kinezumi.net/NucleusCMS/Plugins/SearchResultsEX/'; | |
17 | + } | |
18 | + | |
19 | + function getVersion() | |
20 | + { | |
21 | + return '0.03'; | |
22 | + } | |
23 | + | |
24 | + function getDescription() | |
25 | + { | |
8 | 26 | return 'This plugin replace <%searchresults()%> with page switch<br /> |
9 | 27 | Usage: <%SearchResultsEX(default/index,15,,2,500)%><br /> |
10 | 28 | Requered NP_ExtensibleSearch'; |
11 | 29 | } |
12 | 30 | |
13 | - function getEventList() { return array('PreSearchResults'); } | |
31 | + function getEventList() | |
32 | + { | |
33 | + return array('PreSearchResults'); | |
34 | + } | |
14 | 35 | |
15 | - function getPluginDep() { return array('NP_ExtensibleSearch'); } | |
36 | + function getPluginDep() | |
37 | + { | |
38 | + return array('NP_ExtensibleSearch'); | |
39 | + } | |
16 | 40 | |
17 | - function supportsFeature($what) { | |
18 | - switch($what){ | |
41 | + function supportsFeature($what) | |
42 | + { | |
43 | + switch ($what) { | |
19 | 44 | case 'SqlTablePrefix': |
20 | 45 | return 1; |
21 | 46 | default: |
@@ -23,48 +48,64 @@ class NP_SearchResultsEX extends NucleusPlugin { | ||
23 | 48 | } |
24 | 49 | } |
25 | 50 | |
26 | - function install() { | |
27 | - $this->createOption("srex_ads1", "[Ads code] code displayed under first and second item of the page", "textarea",''."\n"); | |
28 | - $this->createOption("srex_ads2", "[Ads code] code displayed under second and third item of the page", "textarea",''."\n"); | |
51 | + function install() | |
52 | + { | |
53 | + $this->createOption("srex_ads1", | |
54 | + "[Ads code] code displayed under first and second item of the page", | |
55 | + "textarea", | |
56 | + ""); | |
57 | + $this->createOption("srex_ads2", | |
58 | + "[Ads code] code displayed under second and third item of the page", | |
59 | + "textarea", | |
60 | + ""); | |
29 | 61 | } |
30 | 62 | |
31 | - function event_PreSearchResults(&$data) { // Orign NP_CommentSearch by Andy | |
63 | + function event_PreSearchResults(&$data) | |
64 | + { // Orign NP_CommentSearch by Andy | |
32 | 65 | global $blog, $manager; |
33 | - $blogs = $data['blogs']; | |
34 | - $query = $data['query']; | |
35 | - $items = & $data['items']; | |
66 | + $blogs = $data['blogs']; | |
67 | + $query = $data['query']; | |
68 | + $items = & $data['items']; | |
36 | 69 | $searchclass =& new SEARCH($query); |
37 | 70 | |
38 | - $sqlquery = 'SELECT i.inumber as itemid FROM '; | |
39 | - $tables = sql_table('item').' as i '; | |
71 | + $sqlquery = 'SELECT i.inumber as itemid FROM '; | |
72 | + $tables = sql_table('item') . ' as i '; | |
40 | 73 | $where_str = 'xxx.cm.cbody'; |
41 | 74 | // if ($manager->pluginInstalled('NP_TagEX')) { |
42 | -// $tables .= ' left join '.sql_table('plug_tagex').' as tag on i.inumber = tag.inum'; | |
75 | +// $tables .= ' left join ' . sql_table('plug_tagex') . ' as tag on i.inumber = tag.inum'; | |
43 | 76 | // $where_str .= ',xxx.tag.itags'; |
44 | 77 | // } |
45 | 78 | if ($manager->pluginInstalled('NP_TrackBack')) { |
46 | - $tables .= ' left join '.sql_table('plugin_tb').' as t on i.inumber = t.tb_id'; | |
79 | + $tables .= ' left join '.sql_table('plugin_tb').' as t on i.inumber = t.tb_id'; | |
47 | 80 | $where_str .= ',xxx.t.title,xxx.t.excerpt'; |
48 | 81 | } |
49 | - $sqlquery .= $tables.' left join '.sql_table('comment').' as cm on i.inumber = cm.citem '; | |
50 | - $where = $searchclass->boolean_sql_where($where_str); | |
51 | - $where = strtr($where, array('i.xxx.'=> '')); | |
52 | - $sqlquery .= ' WHERE i.idraft = 0 and i.itime <= '.mysqldate($blog -> getCorrectTime()) | |
53 | - .' and i.iblog in (' . implode(',', $blogs) . ') ' | |
54 | - .' and '.$where; | |
55 | - $res = sql_query($sqlquery); | |
56 | - $array = array(); | |
82 | + $sqlquery .= $tables . ' left join ' . sql_table('comment') . ' as cm on i.inumber = cm.citem '; | |
83 | + $where = $searchclass->boolean_sql_where($where_str); | |
84 | + $where = strtr($where, array('i.xxx.'=> '')); | |
85 | + $sqlquery .= ' WHERE i.idraft = 0 and i.itime <= ' . mysqldate($blog -> getCorrectTime()) | |
86 | + . ' and i.iblog in (' . implode(',', $blogs) . ') ' | |
87 | + . ' and ' . $where; | |
88 | + $res = sql_query($sqlquery); | |
89 | + $array = array(); | |
57 | 90 | while ($itemid = mysql_fetch_row($res)) { |
58 | 91 | array_push($array, $itemid[0]); |
59 | 92 | } |
60 | 93 | $data['items'] = array_unique(array_merge($items,$array)); |
61 | 94 | } |
62 | 95 | |
63 | - function doSkinVar($skinType, $template = 'default/index', $p_amount = 10, $type = 1, $bmode = 'all', $maxresults = '') { | |
96 | + function doSkinVar($skinType, | |
97 | + $template = 'default/index', // display template | |
98 | + $p_amount = 10, // amount par page | |
99 | + $type = 1, // page switch type | |
100 | + $bmode = 'all', // blog mode | |
101 | + $maxresults = '') // max results | |
102 | + { | |
64 | 103 | global $manager, $CONF, $blog, $query, $amount, $startpos; |
65 | 104 | $this->maxamount = ($maxresults) ? $maxresults : 0; |
66 | 105 | |
67 | -// if (!$manager->pluginInstalled('NP_ExtensibleSearch') && getNucleusVersion() < ???) return; // Future | |
106 | +// if (!$manager->pluginInstalled('NP_ExtensibleSearch') && getNucleusVersion() < ???) { | |
107 | +// return; // Future | |
108 | +// } | |
68 | 109 | $type = floatval($type); |
69 | 110 | $typeExp = intval(($type - floor($type))*10); //0 or 1 or 9 |
70 | 111 | list($pageamount, $offset) = sscanf($p_amount, '%d(%d)'); |
@@ -88,13 +129,16 @@ class NP_SearchResultsEX extends NucleusPlugin { | ||
88 | 129 | |
89 | 130 | if ($template == 'form') { |
90 | 131 | $q = getVar('query'); |
91 | - echo "<form method=\"get\" action=\"",createBlogidLink($nowbid)."\">\n"; | |
92 | - echo "\t<div class=\"searchform\">\n"; | |
93 | - echo "\t\t<input name=\"query\" class=\"formfield\" size=\"10\" maxlength=\"60\" accesskey=\"4\" value=\"".$q."\" />\n"; | |
94 | - echo "\t\t<br />\n"; | |
95 | - echo "\t\t<input type=\"submit\" value=\"_SEARCHFORM_SUBMIT\" class=\"formbutton\" />\n"; | |
96 | - echo "\t</div>\n"; | |
97 | - echo "</form>\n"; | |
132 | + echo '<form method="get" action="' . createBlogidLink($nowbid) . '">' . "\n"; | |
133 | + echo "\t" . '<div class="searchform">' . "\n"; | |
134 | + echo "\t\t"; | |
135 | + echo '<input name="query" class="formfield" size="10" maxlength="60"'; | |
136 | + echo ' accesskey="4" value="' . $q . '" />' . "\n"; | |
137 | + echo "\t\t" . '<br />' . "\n"; | |
138 | + echo "\t\t" . '<input type="submit" value="' . _SEARCHFORM_SUBMIT . '" '; | |
139 | + echo 'class="formbutton" />' . "\n"; | |
140 | + echo "\t" . '</div>' . "\n"; | |
141 | + echo '</form>' . "\n"; | |
98 | 142 | return; |
99 | 143 | } |
100 | 144 |
@@ -153,13 +197,17 @@ class NP_SearchResultsEX extends NucleusPlugin { | ||
153 | 197 | } |
154 | 198 | } |
155 | 199 | |
156 | - function _showUsingQuery($template, $showQuery, $highlight, $q_startpos, $q_amount, $b) { | |
200 | + function _showUsingQuery($template, $showQuery, $highlight, $q_startpos, $q_amount, $b) | |
201 | + { | |
157 | 202 | $onlyone_query = $showQuery . ' LIMIT ' . intval($q_startpos) .', 1'; |
158 | 203 | $b->showUsingQuery($template, $onlyone_query, intval($highlight), 1, 1); |
159 | 204 | echo $this->getOption('srex_ads1'); |
160 | 205 | |
161 | 206 | $q_startpos++; |
162 | 207 | $q_amount--; |
208 | + if ($q_amount < 0) { | |
209 | + return; | |
210 | + } | |
163 | 211 | $onlyone_query = $showQuery . ' LIMIT ' . intval($q_startpos) .', 1'; |
164 | 212 | $b->showUsingQuery($template, $onlyone_query, intval($highlight), 1, 1); |
165 | 213 | if (mysql_num_rows(sql_query($onlyone_query))) { |
@@ -168,11 +216,14 @@ class NP_SearchResultsEX extends NucleusPlugin { | ||
168 | 216 | |
169 | 217 | $q_startpos++; |
170 | 218 | $q_amount--; |
171 | - $second_query = $showQuery . ' LIMIT ' . intval($q_startpos) . ',' . intval($q_amount); | |
219 | + if ($q_amount < 0) { | |
220 | + return; | |
221 | + } $second_query = $showQuery . ' LIMIT ' . intval($q_startpos) . ',' . intval($q_amount); | |
172 | 222 | $b->showUsingQuery($template, $second_query, intval($highlight), 1, 1); |
173 | 223 | } |
174 | 224 | |
175 | - function PageSwitch($type, $pageamount, $offset, $entries, $b) { // Orign NP_ShowBlogs by Taka + nakahara21 | |
225 | + function PageSwitch($type, $pageamount, $offset, $entries, $b) | |
226 | + { // Orign NP_ShowBlogs by Taka + nakahara21 | |
176 | 227 | global $CONF, $startpos; |
177 | 228 | $startpos = intval($startpos); |
178 | 229 | $pageamount = intval($pageamount); |
@@ -308,7 +359,8 @@ class NP_SearchResultsEX extends NucleusPlugin { | ||
308 | 359 | } |
309 | 360 | } |
310 | 361 | |
311 | - function doTemplateVar(&$item, $maxLength = 250, $addHighlight = 1) { // Orign NP_ChoppedDisc.php by nakahara21 | |
362 | + function doTemplateVar(&$item, $maxLength = 250, $addHighlight = 1) | |
363 | + { // Orign NP_ChoppedDisc.php by nakahara21 | |
312 | 364 | global $CONF, $manager, $member, $catid; |
313 | 365 | |
314 | 366 | $item_id = intval($item->itemid); |
@@ -388,7 +440,8 @@ class NP_SearchResultsEX extends NucleusPlugin { | ||
388 | 440 | } |
389 | 441 | } |
390 | 442 | |
391 | - function getQueryStrings() { | |
443 | + function getQueryStrings() | |
444 | + { | |
392 | 445 | global $query; |
393 | 446 | // if (requestVar('query')) { |
394 | 447 | $q = 'query'; |
@@ -411,7 +464,8 @@ class NP_SearchResultsEX extends NucleusPlugin { | ||
411 | 464 | // } |
412 | 465 | } |
413 | 466 | |
414 | - function _rawdecode($str){ | |
467 | + function _rawdecode($str) | |
468 | + { | |
415 | 469 | $str = rawurldecode($str); |
416 | 470 | if(_CHERSET != 'UTF-8') { |
417 | 471 | $str = mb_convert_encoding($str, _CHARSET, "UTF-8"); |