Nucleus CMS日本語版用プラグインのうち、日本語版開発者がサポートしているもの
Revision | 21965e082cb66498a5b7689bee6034f7ed75aa49 (tree) |
---|---|
Time | 2006-11-05 17:25:13 |
Author | shizuki <shizuki@1ca2...> |
Commiter | shizuki |
fix page switch link
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@476 1ca29b6e-896d-4ea0-84a5-967f57386b96
@@ -71,15 +71,16 @@ class NP_SearchResultsEX extends NucleusPlugin | ||
71 | 71 | $sqlquery = 'SELECT i.inumber as itemid FROM '; |
72 | 72 | $tables = sql_table('item') . ' as i '; |
73 | 73 | $where_str = 'xxx.cm.cbody'; |
74 | -// if ($manager->pluginInstalled('NP_TagEX')) { | |
75 | -// $tables .= ' left join ' . sql_table('plug_tagex') . ' as tag on i.inumber = tag.inum'; | |
76 | -// $where_str .= ',xxx.tag.itags'; | |
77 | -// } | |
74 | +// if ($manager->pluginInstalled('NP_TagEX')) { | |
75 | +// $tables .= ' left join ' . sql_table('plug_tagex') . ' as tag on i.inumber = tag.inum'; | |
76 | +// $where_str .= ',xxx.tag.itags'; | |
77 | +// } | |
78 | 78 | if ($manager->pluginInstalled('NP_TrackBack')) { |
79 | 79 | $tables .= ' left join '.sql_table('plugin_tb').' as t on i.inumber = t.tb_id'; |
80 | 80 | $where_str .= ',xxx.t.title,xxx.t.excerpt'; |
81 | 81 | } |
82 | - $sqlquery .= $tables . ' left join ' . sql_table('comment') . ' as cm on i.inumber = cm.citem '; | |
82 | + $sqlquery .= $tables . ' left join ' . sql_table('comment') | |
83 | + . ' as cm on i.inumber = cm.citem '; | |
83 | 84 | $where = $searchclass->boolean_sql_where($where_str); |
84 | 85 | $where = strtr($where, array('i.xxx.'=> '')); |
85 | 86 | $sqlquery .= ' WHERE i.idraft = 0 and i.itime <= ' . mysqldate($blog -> getCorrectTime()) |
@@ -224,44 +225,69 @@ class NP_SearchResultsEX extends NucleusPlugin | ||
224 | 225 | |
225 | 226 | function PageSwitch($type, $pageamount, $offset, $entries, $b) |
226 | 227 | { // Orign NP_ShowBlogs by Taka + nakahara21 |
227 | - global $CONF, $startpos; | |
228 | + global $CONF, $manager, $startpos, $query; | |
228 | 229 | $startpos = intval($startpos); |
229 | 230 | $pageamount = intval($pageamount); |
230 | 231 | $offset = intval($offset); |
231 | - if($_SERVER['REQUEST_URI']==''){ | |
232 | - $uri = (serverVar("QUERY_STRING"))? | |
233 | - sprintf("%s%s%s?%s","http://",serverVar("HTTP_HOST"),serverVar("SCRIPT_NAME"),serverVar("QUERY_STRING")): | |
234 | - sprintf("%s%s%s","http://",serverVar("HTTP_HOST"),serverVar("SCRIPT_NAME")); | |
232 | + $usePathInfo = ($CONF['URLMode'] == 'pathinfo'); | |
233 | + if (serverVar('REQUEST_URI') == '') { | |
234 | + $uri = (serverVar('QUERY_STRING')) ? | |
235 | + serverVar('SCRIPT_NAME') . serverVar('QUERY_STRING') : serverVar('SCRIPT_NAME'); | |
235 | 236 | } else { |
236 | - $uri = sprintf("%s%s%s","http://",serverVar("HTTP_HOST"),serverVar("REQUEST_URI")); | |
237 | + $uri = serverVar('REQUEST_URI'); | |
238 | + } | |
239 | + $page_str = ($usePathInfo) ? 'page/' : 'page='; | |
240 | + $blogID = intval($b->getID()); | |
241 | + $installedCustomURL = ($manager->pluginInstalled('NP_CustomURL')); | |
242 | + if ($installedCustomURL) { | |
243 | + $plugCustomURL = $tplugin =& $manager->getPlugin('NP_CustomURL'); | |
244 | + $customFlag = ($plugCustomURL->getBlogOption(intval($blogID), 'use_customurl') == 'yes'); | |
245 | + $redirectFlag = ($plugCustomURL->getBlogOption(intval($blogID), 'redirect_normal') == 'yes'); | |
246 | + $redirectSFlag = ($plugCustomURL->getBlogOption(intval($blogID), 'redirect_search') == 'yes'); | |
247 | + $page_str = 'page_'; | |
237 | 248 | } |
238 | - $page_str = ($CONF['URLMode'] == 'pathinfo') ? 'page/' : 'page='; | |
239 | - list($pagelink, $currentpage) = explode($page_str,$uri); | |
249 | + list($pagelink, $currentpage) = explode($page_str, $uri); | |
250 | + if (getVar('page')) $currentpage = intGetVar('page'); | |
240 | 251 | $currentpage = intval($currentpage); |
241 | - $pagelink = preg_replace('|[^a-z0-9-~+_.?#=&;,/:@%]|i', '', $pagelink); | |
242 | -// $pagelink = rawurldecode($pagelink); | |
243 | -// $pagelink = stripslashes($pagelink); | |
244 | - if ($currentpage>0) { | |
245 | - $startpos = ($currentpage-1) * $pageamount; | |
252 | + $pagelink = createBlogidLink($blogID); | |
253 | + if ($installedCustomURL && $customFlag && $redirectSFlag) { | |
254 | + $que_str = $query; | |
255 | + $que_str = htmlspecialchars($que_str); | |
256 | + $que_str = mb_eregi_replace('/', 'ssslllaaassshhh', $que_str); | |
257 | + $que_str = mb_eregi_replace("'", 'qqquuuooottt', $que_str); | |
258 | + $que_str = mb_eregi_replace('&', 'aaammmppp', $que_str); | |
259 | + $que_str = urlencode($que_str); | |
260 | + $pagelink .= 'search' . $que_str . '/'; | |
246 | 261 | } else { |
247 | - $currentpage = 1; | |
248 | - $uri = parse_url($pagelink); | |
249 | - if ($pagelink == $CONF['IndexURL'] && $CONF['URLMode'] != 'pathinfo') { // add | |
250 | - $pagelink = $b->getURL(); | |
251 | - if ($uri['query']) { | |
252 | - $pagelink .= '?'.$uri['query']; | |
253 | - $uri['query'] = true; | |
254 | - } | |
262 | + $pagelink .= '?query=' . $query; | |
263 | + if (is_numeric(getVar('amount')) && intGetVar('amount') >= 0) { | |
264 | + $pagelink .= '&amount=' . intGetVar('amount'); | |
265 | + } | |
266 | + $pagelink .= '&blogid=' . $blogID; | |
267 | + } | |
268 | + $uri = parse_url($pagelink); | |
269 | + if (!$usePathInfo) { | |
270 | + if ($pagelink == $CONF['BlogURL']) { // add | |
271 | + $pagelink .= '?'; | |
272 | + } elseif ($uri['query']) { | |
273 | + $pagelink .= '&'; | |
255 | 274 | } |
275 | + $pagelink = str_replace('&&', '&', $pagelink); | |
276 | + } elseif ($usePathInfo && substr($pagelink, -1) != '/') { | |
256 | 277 | if ($uri['query']) { |
257 | 278 | $pagelink .= '&'; |
258 | - $pagelink = str_replace('&&','&',$pagelink); | |
259 | - $pagelink = str_replace('&&','&',$pagelink); | |
260 | - } elseif (strpos('?', $uri)) { | |
261 | - $pagelink .= '?'; | |
279 | + $page_str = 'page='; | |
280 | + } else { | |
281 | + $pagelink .= '/'; | |
282 | + if (strstr ($pagelink, '//')) $link = preg_replace("/([^:])\/\//", "$1/", $pagelink); | |
262 | 283 | } |
263 | 284 | } |
264 | - if ($CONF['URLMode'] == 'pathinfo' && substr($pagelink, -1) != '/') $pagelink .= '/'; | |
285 | + | |
286 | + if ($currentpage > 0) { | |
287 | + $startpos = ($currentpage - 1) * $pageamount; | |
288 | + } else { | |
289 | + $currentpage = 1; | |
290 | + } | |
265 | 291 | |
266 | 292 | $totalamount = 0; |
267 | 293 | if (is_array($entries)) { |
@@ -288,16 +314,22 @@ class NP_SearchResultsEX extends NucleusPlugin | ||
288 | 314 | $prevpage = ($currentpage > 1) ? $currentpage - 1 : 0; |
289 | 315 | $nextpage = $currentpage + 1; |
290 | 316 | $firstpagelink = $pagelink . $page_str . '1'; |
291 | -// $firstpagelink .= '.html'; | |
317 | + if ($page_str = 'page_') { | |
318 | + $firstpagelink .= '.html'; | |
319 | + } | |
292 | 320 | $lastpagelink = $pagelink . $page_str . $totalpages; |
293 | -// $lastpagelink .= '.html'; | |
321 | + if ($page_str = 'page_') { | |
322 | + $firstpagelink .= '.html'; | |
323 | + } | |
294 | 324 | |
295 | 325 | if ($type >= 1) { |
296 | 326 | $buf .= '<div class="pageswitch">'."\n"; |
297 | 327 | if ($prevpage) { |
298 | 328 | $buf .= "<link rel=\"first\" title=\"first page\" href=\"{$firstpagelink}\" />\n"; |
299 | 329 | $prevpagelink = $pagelink . $page_str . $prevpage; |
300 | -// $prevpagelink .= '.html'; | |
330 | + if ($page_str = 'page_') { | |
331 | + $firstpagelink .= '.html'; | |
332 | + } | |
301 | 333 | $buf .= "\n<a href=\"{$prevpagelink}\" title=\"Previous page\" rel=\"Prev\">«Prev</a> |"; |
302 | 334 | } elseif ($type >= 2) { |
303 | 335 | $buf .= "\n«Prev |"; |
@@ -307,7 +339,9 @@ class NP_SearchResultsEX extends NucleusPlugin | ||
307 | 339 | $buf .= "|"; |
308 | 340 | for ($i=1; $i<=$totalpages; $i++) { |
309 | 341 | $i_pagelink = $pagelink . $page_str . $i; |
310 | -// $i_pagelink .= '.html'; | |
342 | + if ($page_str = 'page_') { | |
343 | + $firstpagelink .= '.html'; | |
344 | + } | |
311 | 345 | if ($i == $currentpage) { |
312 | 346 | $buf .= " <strong>{$currentpage}</strong> |\n"; |
313 | 347 | } elseif ($totalpages<10 || $i<4 || $i>$totalpages-3) { |
@@ -348,7 +382,9 @@ class NP_SearchResultsEX extends NucleusPlugin | ||
348 | 382 | } |
349 | 383 | if ($totalpages >= $nextpage) { |
350 | 384 | $nextpagelink = $pagelink . $page_str . $nextpage; |
351 | -// $nextpagelink .= '.html'; | |
385 | + if ($page_str = 'page_') { | |
386 | + $firstpagelink .= '.html'; | |
387 | + } | |
352 | 388 | $buf .= "| <a href=\"{$nextpagelink}\" title=\"Next page\" rel=\"Next\">Next»</a>\n"; |
353 | 389 | $buf .= "<link rel=\"last\" title=\"Last page\" href=\"{$lastpagelink}\" />\n"; |
354 | 390 | } elseif ($type >= 2) { |