• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-plugins: Commit

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


Commit MetaInfo

Revision21965e082cb66498a5b7689bee6034f7ed75aa49 (tree)
Time2006-11-05 17:25:13
Authorshizuki <shizuki@1ca2...>
Commitershizuki

Log Message

fix page switch link

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@476 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
@@ -71,15 +71,16 @@ class NP_SearchResultsEX extends NucleusPlugin
7171 $sqlquery = 'SELECT i.inumber as itemid FROM ';
7272 $tables = sql_table('item') . ' as i ';
7373 $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+// }
7878 if ($manager->pluginInstalled('NP_TrackBack')) {
7979 $tables .= ' left join '.sql_table('plugin_tb').' as t on i.inumber = t.tb_id';
8080 $where_str .= ',xxx.t.title,xxx.t.excerpt';
8181 }
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 ';
8384 $where = $searchclass->boolean_sql_where($where_str);
8485 $where = strtr($where, array('i.xxx.'=> ''));
8586 $sqlquery .= ' WHERE i.idraft = 0 and i.itime <= ' . mysqldate($blog -> getCorrectTime())
@@ -224,44 +225,69 @@ class NP_SearchResultsEX extends NucleusPlugin
224225
225226 function PageSwitch($type, $pageamount, $offset, $entries, $b)
226227 { // Orign NP_ShowBlogs by Taka + nakahara21
227- global $CONF, $startpos;
228+ global $CONF, $manager, $startpos, $query;
228229 $startpos = intval($startpos);
229230 $pageamount = intval($pageamount);
230231 $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');
235236 } 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_';
237248 }
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');
240251 $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 . '/';
246261 } 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 .= '&amp;amount=' . intGetVar('amount');
265+ }
266+ $pagelink .= '&amp;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 .= '&amp;';
255274 }
275+ $pagelink = str_replace('&amp;&amp;', '&amp;', $pagelink);
276+ } elseif ($usePathInfo && substr($pagelink, -1) != '/') {
256277 if ($uri['query']) {
257278 $pagelink .= '&amp;';
258- $pagelink = str_replace('&&','&',$pagelink);
259- $pagelink = str_replace('&amp;&amp;','&amp;',$pagelink);
260- } elseif (strpos('?', $uri)) {
261- $pagelink .= '?';
279+ $page_str = 'page=';
280+ } else {
281+ $pagelink .= '/';
282+ if (strstr ($pagelink, '//')) $link = preg_replace("/([^:])\/\//", "$1/", $pagelink);
262283 }
263284 }
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+ }
265291
266292 $totalamount = 0;
267293 if (is_array($entries)) {
@@ -288,16 +314,22 @@ class NP_SearchResultsEX extends NucleusPlugin
288314 $prevpage = ($currentpage > 1) ? $currentpage - 1 : 0;
289315 $nextpage = $currentpage + 1;
290316 $firstpagelink = $pagelink . $page_str . '1';
291-// $firstpagelink .= '.html';
317+ if ($page_str = 'page_') {
318+ $firstpagelink .= '.html';
319+ }
292320 $lastpagelink = $pagelink . $page_str . $totalpages;
293-// $lastpagelink .= '.html';
321+ if ($page_str = 'page_') {
322+ $firstpagelink .= '.html';
323+ }
294324
295325 if ($type >= 1) {
296326 $buf .= '<div class="pageswitch">'."\n";
297327 if ($prevpage) {
298328 $buf .= "<link rel=\"first\" title=\"first page\" href=\"{$firstpagelink}\" />\n";
299329 $prevpagelink = $pagelink . $page_str . $prevpage;
300-// $prevpagelink .= '.html';
330+ if ($page_str = 'page_') {
331+ $firstpagelink .= '.html';
332+ }
301333 $buf .= "\n<a href=\"{$prevpagelink}\" title=\"Previous page\" rel=\"Prev\">&laquo;Prev</a> |";
302334 } elseif ($type >= 2) {
303335 $buf .= "\n&laquo;Prev |";
@@ -307,7 +339,9 @@ class NP_SearchResultsEX extends NucleusPlugin
307339 $buf .= "|";
308340 for ($i=1; $i<=$totalpages; $i++) {
309341 $i_pagelink = $pagelink . $page_str . $i;
310-// $i_pagelink .= '.html';
342+ if ($page_str = 'page_') {
343+ $firstpagelink .= '.html';
344+ }
311345 if ($i == $currentpage) {
312346 $buf .= " <strong>{$currentpage}</strong> |\n";
313347 } elseif ($totalpages<10 || $i<4 || $i>$totalpages-3) {
@@ -348,7 +382,9 @@ class NP_SearchResultsEX extends NucleusPlugin
348382 }
349383 if ($totalpages >= $nextpage) {
350384 $nextpagelink = $pagelink . $page_str . $nextpage;
351-// $nextpagelink .= '.html';
385+ if ($page_str = 'page_') {
386+ $firstpagelink .= '.html';
387+ }
352388 $buf .= "| <a href=\"{$nextpagelink}\" title=\"Next page\" rel=\"Next\">Next&raquo;</a>\n";
353389 $buf .= "<link rel=\"last\" title=\"Last page\" href=\"{$lastpagelink}\" />\n";
354390 } elseif ($type >= 2) {
Show on old repository browser