• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-plugins: Commit

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


Commit MetaInfo

Revision2e079ac4fe2bfc01a8bb232dac14fd6820177c99 (tree)
Time2006-10-04 15:30:20
Authorshizuki <shizuki@1ca2...>
Commitershizuki

Log Message

fix & customize createPageLink

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

Change Summary

Incremental Difference

--- a/trunk/NP_ShowBlogs/NP_ShowBlogs.php
+++ b/trunk/NP_ShowBlogs/NP_ShowBlogs.php
@@ -31,7 +31,8 @@ class NP_ShowBlogs extends NucleusPlugin
3131 {
3232 function getName()
3333 {
34- return 'Show Blogs'; }
34+ return 'Show Blogs';
35+ }
3536
3637 function getMinNucleusVersion()
3738 {
@@ -50,7 +51,7 @@ class NP_ShowBlogs extends NucleusPlugin
5051
5152 function getVersion()
5253 {
53- return '2.63';
54+ return '2.64';
5455 }
5556
5657 function getDescription()
@@ -88,7 +89,8 @@ class NP_ShowBlogs extends NucleusPlugin
8889 // $this->createOption('catnametoshow', _CATNAME_SHOW, 'text', '0');
8990 $this->createOption('stickmode', _STICKMODE, 'text', '1');
9091 $this->createOption('ads', _ADCODE_1, 'textarea', '' . "\n");
91-// $this->createOption('ads2', _ADCODE_2, 'textarea', '' . "\n");
92+ $this->createOption('ads2', _ADCODE_2, 'textarea', '' . "\n");
93+ $this->createOption('tagMode', 'TagEX narrow mode(0 or 1 or 2)', 'select', '2', 'all blogs|0|currentblog only|1|narrowed with catid/subcatid|2');
9294 /* todo can't install ? only warning ?
9395 * douyatte 'desc' ni keikoku wo daseba iinoka wakaranai desu
9496 $ver_min = (getNucleusVersion() < $this->getMinNucleusVersion());
@@ -114,9 +116,9 @@ class NP_ShowBlogs extends NucleusPlugin
114116 {
115117 global $manager, $CONF, $blog, $blogid, $catid, $itemid, $archive;
116118
117-/***************************************
118- extra setting
119-***************************************/
119+//***************************************
120+// extra setting
121+//***************************************
120122 /* blogid(blogshortname) you want to hide
121123 example:
122124 $hide =array(5)
@@ -127,11 +129,7 @@ class NP_ShowBlogs extends NucleusPlugin
127129 $hide = array();
128130 //show blogID
129131 $show = array();
130-/* limit number of pages(months)
131- Please delete the character '//' of the head of the following.
132-*/
133-//$pagelimit = 10;
134-//$monthlimit = 12;
132+// limit number of pages(months)
135133 $pagelimit = 0;
136134 $monthlimit = 0;
137135 $catformat = $this->getOption('catformat');
@@ -219,7 +217,6 @@ $monthlimit = 0;
219217 $hidden = '';
220218 $temp = $y = $m = $d = '';
221219 if ($archive) {
222-// $hidden .= '<input type="hidden" name="archive" value="' . htmlspecialchars($archive) . '" />' . "\n";
223220 sscanf($archive, '%d-%d-%d', $y, $m, $d);
224221 if ($d) {
225222 $timestamp_start = mktime(0, 0, 0, $m, $d, $y);
@@ -241,47 +238,16 @@ $monthlimit = 0;
241238 $where .= ' AND i.itime <= ' . mysqldate($b->getCorrectTime());
242239 }
243240
244- if (isset($catid)) {
245-// $hidden .= '<input type="hidden" name="catid" value="' . intval($catid) . '" />' . "\n";
241+ if (!empty($catid)) {
246242 if ($manager->pluginInstalled('NP_MultipleCategories')) {
247- $where .= ' AND ((i.inumber = p.item_id AND (p.categories REGEXP "(^|,)'
248- . intval($catid) . '(,|$)" OR i.icat = ' . intval($catid) . ')) OR (i.icat = '
249- . intval($catid) . ' AND p.item_id IS NULL))';
250- $mtable = ' LEFT JOIN ' . sql_table('plug_multiple_categories') .
251- ' as p ON i.inumber = p.item_id';
252- $mplugin =& $manager->getPlugin('NP_MultipleCategories');
253- if (method_exists($mplugin, 'getRequestName')) {
254- $mplugin->event_PreSkinParse(array());
255- global $subcatid;
256- if ($subcatid) {
257-
258- $tres = sql_query('SELECT * FROM ' . sql_table('plug_multiple_categories_sub')
259- . ' WHERE scatid = ' . intval($subcatid));
260- $ra = mysql_fetch_array($tres, MYSQL_ASSOC);
261- if (array_key_exists('parentid', $ra)) {
262- $Children = array();
263- $Children = explode('/', intval($subcatid) . $this->getChildren(intval($subcatid)));
264- }
265- if ($Children[1]) {
266- for ($i=0;$i<count($Children);$i++) {
267- $temp_whr[] = ' p.subcategories REGEXP "(^|,)' . intval($Children[$i]) . '(,|$)" ';
268- }
269- $where .= ' AND ( ';
270- $where .= join(' OR ', $temp_whr);
271- $where .= ' )';
272- } else {
273- $where .= ' AND p.subcategories REGEXP "(^|,)' . intval($subcatid) . '(,|$)"';
274- }
275- }
276- }
243+ $mcat_query = $this->_getSubcategoriesWhere($catid);
244+ $mtable = $mcat_query['m'];
245+ $where .= $mcat_query['w'];
277246 } else {
278247 $where .= ' AND i.icat=' . intval($catid);
279248 }
280249 $linkparams['catid'] = $todayparams['catid'] = intval($catid);
281250 }
282-// if ($blogid) {
283-// $hidden .= '<input type="hidden" name="blogid" value="' . intval($blogid) . '" />'."\n";
284-// }
285251
286252 if ($type >= 1) {
287253 $page_switch = $this->PageSwitch($type, $pageamount, $offset, $where, $sort, $mtable);
@@ -289,49 +255,51 @@ $monthlimit = 0;
289255 echo $page_switch['buf'];
290256 }
291257 }
258+ }
292259
293- $sh_query = 'SELECT i.inumber as itemid, i.ititle as title, i.ibody as body, m.mname as author,' .
294- ' m.mrealname as authorname, UNIX_TIMESTAMP(i.itime) as timestamp, i.itime,' .
295- ' i.imore as more, m.mnumber as authorid,';
296- if (!$catblogname) {
297- $sh_query .= ' c.cname as category,';
298- } else {
299- $sh_query .= ' concat(' . $catformat . ') as category,';
300- }
301- $sh_query .= ' i.icat as catid, i.iclosed as closed';
302- $sh_query .= ' FROM '
303- . sql_table('member') . ' as m, '
304- . sql_table('category') . ' as c, '
305- . sql_table('item') . ' as i';
306- if ($bmode == 'all') {
307- $sh_query .= ', ' . sql_table('blog') . ' as b ';
308- }
309- $sh_query .= ' WHERE i.iauthor = m.mnumber AND i.icat = c.catid';
310- if ($bmode == 'all') {
311- $sh_query .= ' AND b.bnumber = c.cblog';
312- }
313- if ($page_switch['startpos'] == 0 && !$catid && $sticky != '') {
314- $ads = 1;
315- foreach ($stickys as $stickynumber) {
316- $tempblogid = getBlogIDFromItemID($stickynumber);
317- if ($bmode != 'all') {
318- $sh_query .= ' AND i.iblog = ' . $nowbid;
319- }
320- $sh_query .= ' AND i.inumber = ' . intval($stickynumber);
321- $sh_query .= ' AND i.itime <= ' . mysqldate($b->getCorrectTime());
322- $sh_query .= ' AND i.idraft = 0';
323- if ($this->getOption('stickmode') == 1 && intval($nowbid) == $tempblogid) {
324- $b->showUsingQuery($sticktemplate, $sh_query, 0, 1, 0);
325- } elseif (!$this->getOption('stickmode')) {
326- $b->showUsingQuery($sticktemplate, $sh_query, 0, 1, 0);
327- }
328- if ($ads == 1) {
329- echo $this->getOption('ads');
330- } elseif ($ads ==2) {
331- echo $this->getOption('ads2');
332- }
333- $ads++;
260+ $sh_query = 'SELECT i.inumber as itemid, i.ititle as title, i.ibody as body,' .
261+ ' m.mname as author, m.mrealname as authorname,' .
262+ ' UNIX_TIMESTAMP(i.itime) as timestamp, i.itime,' .
263+ ' i.imore as more, m.mnumber as authorid,';
264+ if (!$catblogname) {
265+ $sh_query .= ' c.cname as category,';
266+ } else {
267+ $sh_query .= ' concat(' . $catformat . ') as category,';
268+ }
269+ $sh_query .= ' i.icat as catid, i.iclosed as closed';
270+ $sh_query .= ' FROM '
271+ . sql_table('member') . ' as m, '
272+ . sql_table('category') . ' as c, '
273+ . sql_table('item') . ' as i';
274+ if ($bmode == 'all') {
275+ $sh_query .= ', ' . sql_table('blog') . ' as b ';
276+ }
277+ $sh_query .= ' WHERE i.iauthor = m.mnumber AND i.icat = c.catid';
278+ if ($bmode == 'all') {
279+ $sh_query .= ' AND b.bnumber = c.cblog';
280+ }
281+
282+ if ($page_switch['startpos'] == 0 && !$catid && $sticky != '' && $skinType != 'item') {
283+ $ads = 1;
284+ foreach ($stickys as $stickynumber) {
285+ $tempblogid = getBlogIDFromItemID($stickynumber);
286+ if ($bmode != 'all') {
287+ $sh_query .= ' AND i.iblog = ' . $nowbid;
288+ }
289+ $sh_query .= ' AND i.inumber = ' . intval($stickynumber);
290+ $sh_query .= ' AND i.itime <= ' . mysqldate($b->getCorrectTime());
291+ $sh_query .= ' AND i.idraft = 0';
292+ if ($this->getOption('stickmode') == 1 && intval($nowbid) == $tempblogid) {
293+ $b->showUsingQuery($sticktemplate, $sh_query, 0, 1, 0);
294+ } elseif (!$this->getOption('stickmode')) {
295+ $b->showUsingQuery($sticktemplate, $sh_query, 0, 1, 0);
296+ }
297+ if ($ads == 1) {
298+ echo $this->getOption('ads');
299+ } elseif ($ads ==2) {
300+ echo $this->getOption('ads2');
334301 }
302+ $ads++;
335303 }
336304 }
337305
@@ -361,21 +329,21 @@ $monthlimit = 0;
361329 $onlyone_query = $showQuery . ' LIMIT ' . intval($q_startpos) .', 1';
362330 $b->showUsingQuery($template, $onlyone_query, 0, 1, 1);
363331 if ($q_startpos == 0 && !$catid && $sticky != '') {
364-// $ads = 1;
332+ $ads = 1;
365333 if ($stickys == 1) {
366334 echo $this->getOption('ads2');
367335 }
368336 //------------SECOND AD CODE-------------
369-// } else {
370-// echo $this->getOption('ads');
337+ } else {
338+ echo $this->getOption('ads');
371339 }
372-/* $q_startpos++;
340+ $q_startpos++;
373341 $q_amount--;
374342 $onlyone_query = $showQuery . ' LIMIT ' . intval($q_startpos) . ', 1';
375343 $b->showUsingQuery($template, $onlyone_query, 0, 1, 1);
376344 if (mysql_num_rows(sql_query($onlyone_query)) && empty($ads)) {
377345 echo $this->getOption('ads2');
378- }*/
346+ }
379347 //------------SECOND AD CODE END-------------
380348 $q_startpos++;
381349 $q_amount--;
@@ -383,60 +351,97 @@ $monthlimit = 0;
383351 $b->showUsingQuery($template, $second_query, 0, 1, 1);
384352 }
385353
386- function PageSwitch($type, $pageamount, $offset, $where, $sort, $mtable = '') //, $b) //, $hidden = '')
354+ function event_parseURL($data)
387355 {
388- global $CONF, $manager, $archive;
356+ global $CONF;
357+ $usePathInfo = ($CONF['URLMode'] == 'pathinfo');
358+ if (serverVar('REQUEST_URI') == '') {
359+ $uri = (serverVar('QUERY_STRING')) ?
360+ serverVar('SCRIPT_NAME') . serverVar('QUERY_STRING') : serverVar('SCRIPT_NAME');
361+ } else {
362+ $uri = serverVar('REQUEST_URI');
363+ }
364+ $this->page_str = ($usePathInfo) ? 'page/' : 'page=';
365+ list($org_uri, $currentpage) = explode($this->page_str, $uri, 2);
366+ $this->currentpage = intval($currentpage);
367+ $_REQUEST['page'] = $this->currentpage;
368+ }
369+
370+ function PageSwitch($type, $pageamount, $offset, $where, $sort, $mtable = '')
371+ {
372+ global $CONF, $manager, $archive, $catid, $subcatid;
373+
374+// initialize
389375 $startpos = 0;
376+ $catid = intval($catid);
377+ $subcatid = intval($subcatid);
378+ $usePathInfo = ($CONF['URLMode'] == 'pathinfo');
390379 $pageamount = intval($pageamount);
391380 $offset = intval($offset);
392- if ($_SERVER['REQUEST_URI']=='') {
393- $uri = (serverVar("QUERY_STRING"))?
394- sprintf("%s%s%s?%s","http://", serverVar("HTTP_HOST"), serverVar("SCRIPT_NAME"), serverVar("QUERY_STRING")):
395- sprintf("%s%s%s","http://", serverVar("HTTP_HOST"), serverVar("SCRIPT_NAME"));
396- } else {
397- $uri = sprintf("%s%s%s", "http://", serverVar("HTTP_HOST"), serverVar("REQUEST_URI"));
381+ if ($archive) {
382+ $y = $m = $d = '';
383+ sscanf($archive, '%d-%d-%d', $y, $m, $d);
384+ if (!empty($d)) {
385+ $archive = sprintf('%04d-%02d-%02d', $y, $m, $d);
386+ } else {
387+ $archive = sprintf('%04d-%02d', $y, $m);
388+ }
389+ }
390+
391+ $page_str = $this->page_str;
392+ $currentpage = $this->currentpage;
393+
394+// createBaseURL
395+ if (!empty($catid)) {
396+ $catrequest = ($usePathInfo) ? $CONF['CategoryKey'] : 'catid';
397+ if (!empty($subcatid)) {
398+ $mplugin =& $manager->getPlugin('NP_MultipleCategories');
399+ $subrequest = $mplugin->getRequestName(array());
400+ if (!empty($archive)) {
401+ $pagelink = createArchiveLink($archive, array($catrequest => $catid, $subrequest => $subcatid));
402+ } else {
403+ $pagelink = createCategoryLink($catid, array($subrequest => $subcatid));
404+ }
405+ } else {
406+ if (!empty($archive)) {
407+ $pagelink = createArchiveLink($archive, array($catrequest => $catid));
408+ } else {
409+ $pagelink = createCategoryLink($catid);
410+ }
411+ }
412+ } else {
413+ if (!empty($archive)) {
414+ $pagelink = createArchiveLink($archive);
415+ } else {
416+ $pagelink = $CONF['BlogURL'];
417+ }
398418 }
399- $page_str = ($CONF['URLMode'] == 'pathinfo') ? 'page/' : 'page=';
400- list($pagelink, $currentpage) = explode($page_str,$uri);
401- $currentpage = intval($currentpage);
402- $pagelink = preg_replace('|[^a-z0-9-~+_.?#=&;,/:@%]|i', '', $pagelink);
403419 if ($manager->pluginInstalled('NP_TagEX')) {
404420 $tplugin =& $manager->getPlugin('NP_TagEX');
405421 $requestTag = $tplugin->getNoDecodeQuery('tag');
406422 if (!empty($requestTag)) {
407- $pagelink = $tplugin->creatTagLink($requestTag);
408- } else {
409- $pagelink = rawurldecode($pagelink);
410- $pagelink = stripslashes($pagelink);
423+ $pagelink = $tplugin->creatTagLink($requestTag, $this->getOption('tagMode'));
411424 }
412- } else {
413- $pagelink = rawurldecode($pagelink);
414- $pagelink = stripslashes($pagelink);
415425 }
426+ $uri = parse_url($pagelink);
427+ if (!$usePathInfo) {
428+ if ($pagelink == $CONF['BlogURL']) { // add
429+ $pagelink .= '?';
430+ } elseif ($uri['query']) {
431+ $pagelink .= '&amp;';
432+ }
433+ $pagelink = str_replace('&amp;&amp;', '&amp;', $pagelink);
434+ } elseif ($usePathInfo && substr($pagelink, -1) != '/') {
435+ $pagelink .= '/';
436+ if (strstr ($pagelink, '//')) $link = preg_replace("/([^:])\/\//", "$1/", $pagelink);
437+ }
438+
416439 if ($currentpage>0) {
417440 $startpos = ($currentpage-1) * $pageamount;
418441 } else {
419442 $currentpage = 1;
420- $uri = parse_url($pagelink);
421- if ($pagelink == $CONF['BlogURL'] && $CONF['URLMode'] != 'pathinfo') { // add
422-// $pagelink = $b->getURL();
423- if ($uri['query']) {
424- $pagelink .= '?' . $uri['query'];
425- $uri['query'] = true;
426- }
427- }
428- if ($uri['query']) {
429-// $pagelink .= '&';
430- $pagelink .= '&amp;';
431-// $pagelink = str_replace('&&', '&', $pagelink);
432- $pagelink = str_replace('&amp;&amp;','&amp;',$pagelink);
433- } elseif (strpos('?', $pagelink) && $CONF['URLMode'] != 'pathinfo') {
434- $pagelink .= '?';
435- }
436- }
437- if ($CONF['URLMode'] == 'pathinfo' && substr($pagelink, -1) != '/') {
438- $pagelink .= '/';
439443 }
444+
440445 // $pagelink = htmlspecialchars($pagelink);
441446
442447 $totalamount = 0;
@@ -483,18 +488,11 @@ $monthlimit = 0;
483488 // $lastpagelink .= '.html';
484489
485490 if ($type >= 1) {
486- if($CONF['URLMode'] == 'pathinfo'){
487-// $buf = '<form method="get" action="'.substr($pagelink,0,-1).'">'."\n";
488- $buf .= '<div class="pageswitch">'."\n";
489- }else{
490-// $buf = '<form method="get" action="'.$CONF['Self'].'">'."\n";
491- $buf .= '<div class="pageswitch">'."\n";
492-// $buf .= $hidden;
493- }
494-// $buf .= "<a rel=\"first\" title=\"first page\" href=\"{$firstpagelink}\">&lt;TOP&gt;</a> | \n";
495- if ($prevpage) {
491+ $buf .= '<div class="pageswitch">' . "\n";
492+// $buf .= "<a rel=\"first\" title=\"first page\" href=\"{$firstpagelink}\">&lt;TOP&gt;</a> |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n";
493+ if (!empty($prevpage)) {
496494 $prevpagelink = $pagelink . $page_str . $prevpage;
497- $prevpagelink .= '.html';
495+// $prevpagelink .= '.html';
498496 $buf .= "\n<a href=\"{$prevpagelink}\" title=\"Previous page\" rel=\"Prev\">&laquo;Prev</a> |";
499497 } elseif ($type >= 2) {
500498 $buf .= "\n&laquo;Prev |";
@@ -522,9 +520,6 @@ $monthlimit = 0;
522520 }
523521 $buf = rtrim($buf);
524522 }
525-// if($totalpages>=10){
526-// $buf .= '<input type="text" name="page" size="1" maxlength="3" title="Input page number and press Enter" style="width:20px;" />'."\n";
527-// }
528523 if (intval($type) == 3) {
529524 $buf .= "|";
530525 $sepstr = '&middot;';
@@ -533,7 +528,7 @@ $monthlimit = 0;
533528 // $i_pagelink .= '.html';
534529 $paging = 5;
535530 if ($i == $currentpage) {
536- $buf .= " <strong>{$i}</strong> {$sepstr}\n";
531+ $buf .= " <strong>{$currentpage}</strong> {$sepstr}\n";
537532 } elseif ($totalpages < 10 || (($i < ($currentpage + $paging)) && (($currentpage - $paging) < $i))) {
538533 $buf .= " <a href=\"{$i_pagelink}\" title=\"Page No.{$i}\">{$i}</a> {$sepstr}\n";
539534 } elseif ($currentpage - $paging == $i) {
@@ -553,13 +548,51 @@ $monthlimit = 0;
553548 } elseif ($type >= 2) {
554549 $buf .= "| Next&raquo;\n";
555550 }
556-// $buf .= " | <a rel=\"last\" title=\"Last page\" href=\"{$lastpagelink}\">&lt;LAST&gt;</a>\n";
551+// $buf .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| <a rel=\"last\" title=\"Last page\" href=\"{$lastpagelink}\">&lt;LAST&gt;</a>\n";
557552 $buf .= "</div>\n";
558-// $buf .= "</form>\n";
559553 return array('buf' => $buf, 'startpos' => intval($startpos));
560554 }
561555 }
562556
557+ function _getSubcategoriesWhere($catid)
558+ {
559+ global $manager;
560+ $mwhere = '';
561+ $mwhere = ' AND ((i.inumber = p.item_id' .
562+ ' AND (p.categories REGEXP "(^|,)' . intval($catid) . '(,|$)" OR i.icat = ' . intval($catid) . '))' .
563+ ' OR (i.icat = ' . intval($catid) . ' AND p.item_id IS NULL))';
564+ $mtable = ' LEFT JOIN ' . sql_table('plug_multiple_categories') . ' as p' .
565+ ' ON i.inumber = p.item_id';
566+ $mplugin =& $manager->getPlugin('NP_MultipleCategories');
567+ if (method_exists($mplugin, 'getRequestName')) {
568+ $mplugin->event_PreSkinParse(array());
569+ global $subcatid;
570+ if ($subcatid) {
571+
572+ $mque = 'SELECT * FROM %s WHERE scatid = %d';
573+ $tres = sql_query(sprintf($mque, sql_table('plug_multiple_categories_sub'), intval($subcatid)));
574+// $tres = sql_query('SELECT * FROM ' . sql_table('plug_multiple_categories_sub') .
575+// ' WHERE scatid = ' . intval($subcatid));
576+ $ra = mysql_fetch_array($tres, MYSQL_ASSOC);
577+ if (array_key_exists('parentid', $ra)) {
578+ $Children = array();
579+ $Children = explode('/', intval($subcatid) . $this->getChildren(intval($subcatid)));
580+ }
581+ if ($Children[1]) {
582+ for ($i=0;$i<count($Children);$i++) {
583+ $temp_whr[] = ' p.subcategories REGEXP "(^|,)' . intval($Children[$i]) . '(,|$)" ';
584+ }
585+ $mwhere .= ' AND ( ';
586+ $mwhere .= join(' OR ', $temp_whr);
587+ $mwhere .= ' )';
588+ } else {
589+ $mwhere .= ' AND p.subcategories REGEXP "(^|,)' . intval($subcatid) . '(,|$)"';
590+ }
591+ }
592+ }
593+ return array(w => $mwhere, m => $mtable);
594+ }
595+
563596 function getParents($subcat_id)
564597 {
565598 $que = 'SELECT scatid, parentid, sname FROM %s WHERE scatid = %d';
Show on old repository browser