Nucleus CMS日本語版用プラグインのうち、日本語版開発者がサポートしているもの
Revision | 2e079ac4fe2bfc01a8bb232dac14fd6820177c99 (tree) |
---|---|
Time | 2006-10-04 15:30:20 |
Author | shizuki <shizuki@1ca2...> |
Commiter | shizuki |
fix & customize createPageLink
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@415 1ca29b6e-896d-4ea0-84a5-967f57386b96
@@ -31,7 +31,8 @@ class NP_ShowBlogs extends NucleusPlugin | ||
31 | 31 | { |
32 | 32 | function getName() |
33 | 33 | { |
34 | - return 'Show Blogs'; } | |
34 | + return 'Show Blogs'; | |
35 | + } | |
35 | 36 | |
36 | 37 | function getMinNucleusVersion() |
37 | 38 | { |
@@ -50,7 +51,7 @@ class NP_ShowBlogs extends NucleusPlugin | ||
50 | 51 | |
51 | 52 | function getVersion() |
52 | 53 | { |
53 | - return '2.63'; | |
54 | + return '2.64'; | |
54 | 55 | } |
55 | 56 | |
56 | 57 | function getDescription() |
@@ -88,7 +89,8 @@ class NP_ShowBlogs extends NucleusPlugin | ||
88 | 89 | // $this->createOption('catnametoshow', _CATNAME_SHOW, 'text', '0'); |
89 | 90 | $this->createOption('stickmode', _STICKMODE, 'text', '1'); |
90 | 91 | $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'); | |
92 | 94 | /* todo can't install ? only warning ? |
93 | 95 | * douyatte 'desc' ni keikoku wo daseba iinoka wakaranai desu |
94 | 96 | $ver_min = (getNucleusVersion() < $this->getMinNucleusVersion()); |
@@ -114,9 +116,9 @@ class NP_ShowBlogs extends NucleusPlugin | ||
114 | 116 | { |
115 | 117 | global $manager, $CONF, $blog, $blogid, $catid, $itemid, $archive; |
116 | 118 | |
117 | -/*************************************** | |
118 | - extra setting | |
119 | -***************************************/ | |
119 | +//*************************************** | |
120 | +// extra setting | |
121 | +//*************************************** | |
120 | 122 | /* blogid(blogshortname) you want to hide |
121 | 123 | example: |
122 | 124 | $hide =array(5) |
@@ -127,11 +129,7 @@ class NP_ShowBlogs extends NucleusPlugin | ||
127 | 129 | $hide = array(); |
128 | 130 | //show blogID |
129 | 131 | $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) | |
135 | 133 | $pagelimit = 0; |
136 | 134 | $monthlimit = 0; |
137 | 135 | $catformat = $this->getOption('catformat'); |
@@ -219,7 +217,6 @@ $monthlimit = 0; | ||
219 | 217 | $hidden = ''; |
220 | 218 | $temp = $y = $m = $d = ''; |
221 | 219 | if ($archive) { |
222 | -// $hidden .= '<input type="hidden" name="archive" value="' . htmlspecialchars($archive) . '" />' . "\n"; | |
223 | 220 | sscanf($archive, '%d-%d-%d', $y, $m, $d); |
224 | 221 | if ($d) { |
225 | 222 | $timestamp_start = mktime(0, 0, 0, $m, $d, $y); |
@@ -241,47 +238,16 @@ $monthlimit = 0; | ||
241 | 238 | $where .= ' AND i.itime <= ' . mysqldate($b->getCorrectTime()); |
242 | 239 | } |
243 | 240 | |
244 | - if (isset($catid)) { | |
245 | -// $hidden .= '<input type="hidden" name="catid" value="' . intval($catid) . '" />' . "\n"; | |
241 | + if (!empty($catid)) { | |
246 | 242 | 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']; | |
277 | 246 | } else { |
278 | 247 | $where .= ' AND i.icat=' . intval($catid); |
279 | 248 | } |
280 | 249 | $linkparams['catid'] = $todayparams['catid'] = intval($catid); |
281 | 250 | } |
282 | -// if ($blogid) { | |
283 | -// $hidden .= '<input type="hidden" name="blogid" value="' . intval($blogid) . '" />'."\n"; | |
284 | -// } | |
285 | 251 | |
286 | 252 | if ($type >= 1) { |
287 | 253 | $page_switch = $this->PageSwitch($type, $pageamount, $offset, $where, $sort, $mtable); |
@@ -289,49 +255,51 @@ $monthlimit = 0; | ||
289 | 255 | echo $page_switch['buf']; |
290 | 256 | } |
291 | 257 | } |
258 | + } | |
292 | 259 | |
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'); | |
334 | 301 | } |
302 | + $ads++; | |
335 | 303 | } |
336 | 304 | } |
337 | 305 |
@@ -361,21 +329,21 @@ $monthlimit = 0; | ||
361 | 329 | $onlyone_query = $showQuery . ' LIMIT ' . intval($q_startpos) .', 1'; |
362 | 330 | $b->showUsingQuery($template, $onlyone_query, 0, 1, 1); |
363 | 331 | if ($q_startpos == 0 && !$catid && $sticky != '') { |
364 | -// $ads = 1; | |
332 | + $ads = 1; | |
365 | 333 | if ($stickys == 1) { |
366 | 334 | echo $this->getOption('ads2'); |
367 | 335 | } |
368 | 336 | //------------SECOND AD CODE------------- |
369 | -// } else { | |
370 | -// echo $this->getOption('ads'); | |
337 | + } else { | |
338 | + echo $this->getOption('ads'); | |
371 | 339 | } |
372 | -/* $q_startpos++; | |
340 | + $q_startpos++; | |
373 | 341 | $q_amount--; |
374 | 342 | $onlyone_query = $showQuery . ' LIMIT ' . intval($q_startpos) . ', 1'; |
375 | 343 | $b->showUsingQuery($template, $onlyone_query, 0, 1, 1); |
376 | 344 | if (mysql_num_rows(sql_query($onlyone_query)) && empty($ads)) { |
377 | 345 | echo $this->getOption('ads2'); |
378 | - }*/ | |
346 | + } | |
379 | 347 | //------------SECOND AD CODE END------------- |
380 | 348 | $q_startpos++; |
381 | 349 | $q_amount--; |
@@ -383,60 +351,97 @@ $monthlimit = 0; | ||
383 | 351 | $b->showUsingQuery($template, $second_query, 0, 1, 1); |
384 | 352 | } |
385 | 353 | |
386 | - function PageSwitch($type, $pageamount, $offset, $where, $sort, $mtable = '') //, $b) //, $hidden = '') | |
354 | + function event_parseURL($data) | |
387 | 355 | { |
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 | |
389 | 375 | $startpos = 0; |
376 | + $catid = intval($catid); | |
377 | + $subcatid = intval($subcatid); | |
378 | + $usePathInfo = ($CONF['URLMode'] == 'pathinfo'); | |
390 | 379 | $pageamount = intval($pageamount); |
391 | 380 | $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 | + } | |
398 | 418 | } |
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); | |
403 | 419 | if ($manager->pluginInstalled('NP_TagEX')) { |
404 | 420 | $tplugin =& $manager->getPlugin('NP_TagEX'); |
405 | 421 | $requestTag = $tplugin->getNoDecodeQuery('tag'); |
406 | 422 | 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')); | |
411 | 424 | } |
412 | - } else { | |
413 | - $pagelink = rawurldecode($pagelink); | |
414 | - $pagelink = stripslashes($pagelink); | |
415 | 425 | } |
426 | + $uri = parse_url($pagelink); | |
427 | + if (!$usePathInfo) { | |
428 | + if ($pagelink == $CONF['BlogURL']) { // add | |
429 | + $pagelink .= '?'; | |
430 | + } elseif ($uri['query']) { | |
431 | + $pagelink .= '&'; | |
432 | + } | |
433 | + $pagelink = str_replace('&&', '&', $pagelink); | |
434 | + } elseif ($usePathInfo && substr($pagelink, -1) != '/') { | |
435 | + $pagelink .= '/'; | |
436 | + if (strstr ($pagelink, '//')) $link = preg_replace("/([^:])\/\//", "$1/", $pagelink); | |
437 | + } | |
438 | + | |
416 | 439 | if ($currentpage>0) { |
417 | 440 | $startpos = ($currentpage-1) * $pageamount; |
418 | 441 | } else { |
419 | 442 | $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 .= '&'; | |
431 | -// $pagelink = str_replace('&&', '&', $pagelink); | |
432 | - $pagelink = str_replace('&&','&',$pagelink); | |
433 | - } elseif (strpos('?', $pagelink) && $CONF['URLMode'] != 'pathinfo') { | |
434 | - $pagelink .= '?'; | |
435 | - } | |
436 | - } | |
437 | - if ($CONF['URLMode'] == 'pathinfo' && substr($pagelink, -1) != '/') { | |
438 | - $pagelink .= '/'; | |
439 | 443 | } |
444 | + | |
440 | 445 | // $pagelink = htmlspecialchars($pagelink); |
441 | 446 | |
442 | 447 | $totalamount = 0; |
@@ -483,18 +488,11 @@ $monthlimit = 0; | ||
483 | 488 | // $lastpagelink .= '.html'; |
484 | 489 | |
485 | 490 | 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}\"><TOP></a> | \n"; | |
495 | - if ($prevpage) { | |
491 | + $buf .= '<div class="pageswitch">' . "\n"; | |
492 | +// $buf .= "<a rel=\"first\" title=\"first page\" href=\"{$firstpagelink}\"><TOP></a> | \n"; | |
493 | + if (!empty($prevpage)) { | |
496 | 494 | $prevpagelink = $pagelink . $page_str . $prevpage; |
497 | - $prevpagelink .= '.html'; | |
495 | +// $prevpagelink .= '.html'; | |
498 | 496 | $buf .= "\n<a href=\"{$prevpagelink}\" title=\"Previous page\" rel=\"Prev\">«Prev</a> |"; |
499 | 497 | } elseif ($type >= 2) { |
500 | 498 | $buf .= "\n«Prev |"; |
@@ -522,9 +520,6 @@ $monthlimit = 0; | ||
522 | 520 | } |
523 | 521 | $buf = rtrim($buf); |
524 | 522 | } |
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 | -// } | |
528 | 523 | if (intval($type) == 3) { |
529 | 524 | $buf .= "|"; |
530 | 525 | $sepstr = '·'; |
@@ -533,7 +528,7 @@ $monthlimit = 0; | ||
533 | 528 | // $i_pagelink .= '.html'; |
534 | 529 | $paging = 5; |
535 | 530 | if ($i == $currentpage) { |
536 | - $buf .= " <strong>{$i}</strong> {$sepstr}\n"; | |
531 | + $buf .= " <strong>{$currentpage}</strong> {$sepstr}\n"; | |
537 | 532 | } elseif ($totalpages < 10 || (($i < ($currentpage + $paging)) && (($currentpage - $paging) < $i))) { |
538 | 533 | $buf .= " <a href=\"{$i_pagelink}\" title=\"Page No.{$i}\">{$i}</a> {$sepstr}\n"; |
539 | 534 | } elseif ($currentpage - $paging == $i) { |
@@ -553,13 +548,51 @@ $monthlimit = 0; | ||
553 | 548 | } elseif ($type >= 2) { |
554 | 549 | $buf .= "| Next»\n"; |
555 | 550 | } |
556 | -// $buf .= " | <a rel=\"last\" title=\"Last page\" href=\"{$lastpagelink}\"><LAST></a>\n"; | |
551 | +// $buf .= " | <a rel=\"last\" title=\"Last page\" href=\"{$lastpagelink}\"><LAST></a>\n"; | |
557 | 552 | $buf .= "</div>\n"; |
558 | -// $buf .= "</form>\n"; | |
559 | 553 | return array('buf' => $buf, 'startpos' => intval($startpos)); |
560 | 554 | } |
561 | 555 | } |
562 | 556 | |
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 | + | |
563 | 596 | function getParents($subcat_id) |
564 | 597 | { |
565 | 598 | $que = 'SELECT scatid, parentid, sname FROM %s WHERE scatid = %d'; |