• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-plugins: Commit

Nucleus CMS日本語版用プラグインのうち、日本語版開発者がサポートしているもの


Commit MetaInfo

Revisionba7f57d45b913593cb7b7458dfee041c090fdeb9 (tree)
Time2006-11-04 23:06:35
Authorshizuki <shizuki@1ca2...>
Commitershizuki

Log Message

bug fix

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@474 1ca29b6e-896d-4ea0-84a5-967f57386b96

Change Summary

Incremental Difference

--- a/trunk/NP_SearchResultsEX-0.0.1/NP_SearchResultsEX.php
+++ b/trunk/NP_SearchResultsEX-0.0.1/NP_SearchResultsEX.php
@@ -1,21 +1,46 @@
11 <?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+ {
826 return 'This plugin replace &lt;%searchresults()%&gt; with page switch<br />
927 Usage: &lt;%SearchResultsEX(default/index,15,,2,500)%&gt;<br />
1028 Requered NP_ExtensibleSearch';
1129 }
1230
13- function getEventList() { return array('PreSearchResults'); }
31+ function getEventList()
32+ {
33+ return array('PreSearchResults');
34+ }
1435
15- function getPluginDep() { return array('NP_ExtensibleSearch'); }
36+ function getPluginDep()
37+ {
38+ return array('NP_ExtensibleSearch');
39+ }
1640
17- function supportsFeature($what) {
18- switch($what){
41+ function supportsFeature($what)
42+ {
43+ switch ($what) {
1944 case 'SqlTablePrefix':
2045 return 1;
2146 default:
@@ -23,48 +48,64 @@ class NP_SearchResultsEX extends NucleusPlugin {
2348 }
2449 }
2550
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+ "");
2961 }
3062
31- function event_PreSearchResults(&$data) { // Orign NP_CommentSearch by Andy
63+ function event_PreSearchResults(&$data)
64+ { // Orign NP_CommentSearch by Andy
3265 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'];
3669 $searchclass =& new SEARCH($query);
3770
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 ';
4073 $where_str = 'xxx.cm.cbody';
4174 // 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';
4376 // $where_str .= ',xxx.tag.itags';
4477 // }
4578 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';
4780 $where_str .= ',xxx.t.title,xxx.t.excerpt';
4881 }
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();
5790 while ($itemid = mysql_fetch_row($res)) {
5891 array_push($array, $itemid[0]);
5992 }
6093 $data['items'] = array_unique(array_merge($items,$array));
6194 }
6295
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+ {
64103 global $manager, $CONF, $blog, $query, $amount, $startpos;
65104 $this->maxamount = ($maxresults) ? $maxresults : 0;
66105
67-// if (!$manager->pluginInstalled('NP_ExtensibleSearch') && getNucleusVersion() < ???) return; // Future
106+// if (!$manager->pluginInstalled('NP_ExtensibleSearch') && getNucleusVersion() < ???) {
107+// return; // Future
108+// }
68109 $type = floatval($type);
69110 $typeExp = intval(($type - floor($type))*10); //0 or 1 or 9
70111 list($pageamount, $offset) = sscanf($p_amount, '%d(%d)');
@@ -88,13 +129,16 @@ class NP_SearchResultsEX extends NucleusPlugin {
88129
89130 if ($template == 'form') {
90131 $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";
98142 return;
99143 }
100144
@@ -153,13 +197,17 @@ class NP_SearchResultsEX extends NucleusPlugin {
153197 }
154198 }
155199
156- function _showUsingQuery($template, $showQuery, $highlight, $q_startpos, $q_amount, $b) {
200+ function _showUsingQuery($template, $showQuery, $highlight, $q_startpos, $q_amount, $b)
201+ {
157202 $onlyone_query = $showQuery . ' LIMIT ' . intval($q_startpos) .', 1';
158203 $b->showUsingQuery($template, $onlyone_query, intval($highlight), 1, 1);
159204 echo $this->getOption('srex_ads1');
160205
161206 $q_startpos++;
162207 $q_amount--;
208+ if ($q_amount < 0) {
209+ return;
210+ }
163211 $onlyone_query = $showQuery . ' LIMIT ' . intval($q_startpos) .', 1';
164212 $b->showUsingQuery($template, $onlyone_query, intval($highlight), 1, 1);
165213 if (mysql_num_rows(sql_query($onlyone_query))) {
@@ -168,11 +216,14 @@ class NP_SearchResultsEX extends NucleusPlugin {
168216
169217 $q_startpos++;
170218 $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);
172222 $b->showUsingQuery($template, $second_query, intval($highlight), 1, 1);
173223 }
174224
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
176227 global $CONF, $startpos;
177228 $startpos = intval($startpos);
178229 $pageamount = intval($pageamount);
@@ -308,7 +359,8 @@ class NP_SearchResultsEX extends NucleusPlugin {
308359 }
309360 }
310361
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
312364 global $CONF, $manager, $member, $catid;
313365
314366 $item_id = intval($item->itemid);
@@ -388,7 +440,8 @@ class NP_SearchResultsEX extends NucleusPlugin {
388440 }
389441 }
390442
391- function getQueryStrings() {
443+ function getQueryStrings()
444+ {
392445 global $query;
393446 // if (requestVar('query')) {
394447 $q = 'query';
@@ -411,7 +464,8 @@ class NP_SearchResultsEX extends NucleusPlugin {
411464 // }
412465 }
413466
414- function _rawdecode($str){
467+ function _rawdecode($str)
468+ {
415469 $str = rawurldecode($str);
416470 if(_CHERSET != 'UTF-8') {
417471 $str = mb_convert_encoding($str, _CHARSET, "UTF-8");
Show on old repository browser