OSDN Git Service

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@865 1ca29b6e-896d...
[nucleus-jp/nucleus-plugins.git] / NP_ItemNaviEX / trunk / NP_ItemNaviEX.php
1 <?php
2 /**
3  *
4  * BreadCrumbsList PLUG-IN FOR NucleusCMS
5  * PHP versions 4 and 5
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * (see nucleus/documentation/index.html#license for more info)
12  *
13  * @author     Original Author nakahara21
14  * @copyright  2005-2006 nakahara21
15  * @license     http://www.gnu.org/licenses/gpl.txt  GNU GENERAL PUBLIC LICENSE Version 2, June 1991
16  * @version    0.992
17  * @link       http://japan.nucleuscms.org/wiki/plugins:itemnaviex
18  *
19  * 0.993  Henceforth to template
20  * 0.992  display mode '0' fix
21  * 0.991  add sub-blog home mode
22  * 0.99   sec fix
23  *
24  **************************************************************************
25  *
26  * THESE PLUG-INS ARE DEDICATED TO ALL THOSE NucleusCMS USERS
27  * WHO FIGHT CORRUPTION AND IRRATIONAL IN EVERY DAY OF THEIR LIVES.
28  *
29  **************************************************************************/
30
31 class NP_ItemNaviEX extends NucleusPlugin
32 {
33         function getName()
34         {
35                 return 'Navigation Bar'; 
36         }
37
38         function getAuthor()
39         { 
40                 return 'nakahara21 + shizuki'; 
41         }
42
43         function getURL()
44         {
45                 return 'http://japan.nucleuscms.org/wiki/plugins:itemnaviex'; 
46         }
47
48         function getVersion()
49         {
50                 return '0.993'; 
51         }
52
53         function getDescription()
54         {
55                 // include language file for this plugin 
56                 $language = ereg_replace( '[\\|/]', '', getLanguageName()); 
57                 if (file_exists($this->getDirectory() . $language . '.php')) {
58                         include_once($this->getDirectory() . $language . '.php'); 
59                 } else {
60                         include_once($this->getDirectory() . 'english.php');
61                 }
62                 $description = _NP_INEX_DESC;
63 //              $description = 'Add link to prev item and next item. '
64 //                                       . 'Usage: &lt;%ItemNaviEX%&gt; or &lt;%ItemNaviEX(0)%&gt;'
65 //                                       . ' or &lt;%ItemNaviEX(1)%&gt; or  &lt;%ItemNaviEX(2)%&gt;';
66                 return $description;
67         }
68
69         function supportsFeature($what)
70         {
71                 switch ($what) {
72                         case 'SqlTablePrefix':
73                                 return 1;
74                         default:
75                                 return 0;
76                 }
77         }
78
79         function scanEndKey($array)
80         {
81                 $keys = array_keys($array);
82                 rsort($keys);
83                 return $keys[0];
84         }
85
86         function createNaviLink($unitArray)
87         {
88                 if ($unitArray[1]) {
89                         $tempLink = '<a href="' . htmlspecialchars($unitArray[1], ENT_QUOTES, _CHARSET) . '">'
90                                           . htmlspecialchars($unitArray[0], ENT_QUOTES, _CHARSET) . '</a>';
91                 } else {
92                         $tempLink = htmlspecialchars($unitArray[0], ENT_QUOTES, _CHARSET);
93                 }
94                 return $tempLink;
95         }
96
97         function checkParent()
98         {
99                 global $manager; 
100 //              if ($manager->pluginInstalled('NP_MultipleCategories')) {
101 //                      $mplugin =& $manager->getPlugin('NP_MultipleCategories');
102 //                      if (method_exists($mplugin,"getRequestName")) {
103                                 $query = 'SHOW FIELDS FROM ' . sql_table('plug_multiple_categories_sub');
104                                 $res   = sql_query($query);
105                                 while ($co = mysql_fetch_assoc($res)) {
106                                         if ($co['Field'] == 'parentid') {
107                                                 return TRUE;
108                                         }
109                                 }
110 //                      }
111 //              }
112         }
113
114         function doSkinVar($skinType, $showHome = 1)
115         { 
116                 global $manager, $CONF, $blog, $itemid, $itemidprev, $itemidnext;
117                 global $catid, $subcatid, $archive, $archiveprev, $archivenext, $param; 
118
119 // sanitize
120                 $y = $m = $d = '';
121                 $itemid     = intval($itemid);
122                 $catid      = intval($catid);
123                 $subcatid   = intval($subcatid);
124                 $itemidprev = intval($itemidprev);
125                 $itemidnext = intval($itemidnext);
126                 if (isset($archive)) {
127                         sscanf($archive,'%d-%d-%d', $y, $m, $d);
128                         if ($y && $m && !empty($d)) {
129                                 $archive = sprintf('%04d-%02d-%02d', $y, $m, $d);
130                         } elseif ($y && $m && empty($d)) {
131                                 $archive = sprintf('%04d-%02d',      $y, $m);
132                         }                       
133                 }
134                 if (isset($archiveprev)) {
135                         sscanf($archiveprev,'%d-%d-%d', $y, $m, $d);
136                         if ($y && $m && !empty($d)) {
137                                 $archiveprev = sprintf('%04d-%02d-%02d', $y, $m, $d);
138                         } elseif ($y && $m && empty($d)) {
139                                 $archiveprev = sprintf('%04d-%02d',      $y, $m);
140                         }                       
141                 }
142                 if (isset($archiveprev)) {
143                         sscanf($archiveprev,'%d-%d-%d', $y, $m, $d);
144                         if ($y && $m && !empty($d)) {
145                                 $archiveprev = sprintf('%04d-%02d-%02d', $y, $m, $d);
146                         } elseif ($y && $m && empty($d)) {
147                                 $archiveprev = sprintf('%04d-%02d',      $y, $m);
148                         }                       
149                 }
150                 if ($showHome == '') {
151                         $showHome = 1;
152                 } else {
153                         $showHome = intval($showHome);
154                 }
155
156                 if ($catid) { 
157                         $blogid = getBlogIDFromCatID($catid);
158                         $b =& $manager->getBlog($blogid); 
159                 } elseif ($blog) { 
160                         $b =& $blog; 
161                 } else { 
162                         $b =& $manager->getBlog($CONF['DefaultBlog']); 
163                 } 
164                 $blogid = intval($b->getID());
165
166                 $abuf   = '';
167                 $mtable = '';
168                 $where .= ' and i.iblog=' . $blogid;
169                 if (!empty($catid)) {
170                         if ($manager->pluginInstalled('NP_MultipleCategories')) {
171                                 $where .= ' and ((i.inumber = p.item_id'
172                                                 . ' and (p.categories REGEXP "(^|,)' . $catid . '(,|$)"'
173                                                 . ' or i.icat = ' . $catid . '))'
174                                                 . ' or (i.icat = ' . $catid
175                                                 . ' and p.item_id IS NULL))';
176                                 $mtable = ' LEFT JOIN ' . sql_table('plug_multiple_categories') . ' as p'
177                                                 . ' ON  i.inumber = p.item_id';
178                                 $mplugin =& $manager->getPlugin('NP_MultipleCategories');
179                                 if ($subcatid && method_exists($mplugin, 'getRequestName')) {
180 //family
181                                         if ($this->checkParent()) {
182                                                 $Children = array();
183                                                 $Children = explode('/', $subcatid . $this->getChildren($subcatid));
184                                         }
185                                         if ($Children[1]) {
186                                                 for ($i=0;$i<count($Children);$i++) {
187                                                         $temp_whr[] = ' p.subcategories REGEXP "(^|,)' . intval($Children[$i]) . '(,|$)" ';
188                                                 }
189                                                 $where .= ' and ';
190                                                 $where .= ' ( ';
191                                                 $where .= join(' or ', $temp_whr);
192                                                 $where .= ' )';
193                                         }else{
194                                                 $where .= ' and p.subcategories REGEXP "(^|,)' . $subcatid . '(,|$)"';
195                                         }
196 //family end
197                                 }
198                         } else {
199                                 $where .= ' and i.icat=' . $catid;
200                         }
201                 }
202                 $naviUnit         = array();
203                 $subNaviUnit      = array();
204                 $this->linkparams = array();
205                 $nextLabel        = $this->getOption('PNNextLabel');
206                 $prevLabel        = $this->getOption('PNPrevLabel');
207 //store Home =====================================
208 //*// comment out this block when HOME is sub-blog top
209       if ($showHome == 1) {
210 //         $defBlogid  =intval($CONF['DefaultBlog']);
211          $tempBlog =& $manager->getBlog(intval($CONF['DefaultBlog']));
212          $naviUnit[] = array(
213             0 => 'Home',
214 //            1 => createBlogidLink($defBlogid),
215             1 => $tempBlog->getURL(),
216             2 => createArchiveListLink($blogid)
217          );
218       }
219 //*/
220 //store Blog =====================================
221                 if ($showHome == 1 && ($blogid <> $CONF['DefaultBlog'])) {
222                         $naviUnit[] = array(
223                                 0 => getBlogNameFromID($blogid),
224                                 1 => createBlogidLink($blogid),
225                                 2 => createArchiveListLink($blogid)
226                         );
227                 } elseif ($showHome >= 2 || ($showHome == 0 && ($catid || $itemid))) {
228                         $naviUnit[] = array(
229                                 0 => 'Home',                          // when HOME is sub-blog top
230                                 1 => createBlogidLink($blogid),       // when HOME is sub-blog top
231                                 2 => createArchiveListLink($blogid)
232                         );
233                 }
234
235 //store Category =====================================
236                 if (!empty($catid)) {
237                         $this->linkparams['catid'] = $catid;
238                         $naviUnit[] = array(
239                                 0 => $b->getCategoryName($catid),
240                                 1 => createCategoryLink($catid),
241 //                              1 => createBlogidLink($blogid, $this->linkparams),
242                                 2 => createArchiveListLink($blogid, $this->linkparams)
243                         );
244                 }
245
246 //store subCategory =====================================
247                 if (!empty($subcatid)) {
248                         if ($manager->pluginInstalled('NP_MultipleCategories')) {
249                                 $mplugin =& $manager->getPlugin('NP_MultipleCategories');
250                                 if (method_exists($mplugin, 'getRequestName')) {
251                                         $subrequest = $mplugin->getRequestName(array());
252                                         $this->linkparams[$subrequest] = $subcatid;
253                                         if ($this->checkParent()) {
254                                                 $tog = $this->getParenta($subcatid, $blogid);
255                                                 for ($i=0; $i<count($this->r); $i++) {
256                                                         $naviUnit[] = $this->r[$i];
257                                                 }
258                                                 $naviUnit[] = $tog;
259                                         } else {
260                                                 $naviUnit[] = array(
261                                                         0 => $mplugin->_getScatNameFromID($subcatid),
262                                                         1 => createCategoryLink($catid, array($subrequest => $subcatid)),
263 //                                                      1 => createCategoryLink($catid, array('subcatid' => $subcatid)),
264 //                                                      1 => createBlogidLink($blogid, $this->linkparams),
265                                                         2 => createArchiveListLink($blogid, $this->linkparams)
266                                                 );
267                                         }
268                                 }
269                         }
270                 }
271
272 //store Page ===================================== todo How to get PageNo. ? ...cookie... 
273                 if (intRequestVar('page') != 0) {
274                         $naviUnit[] = array(
275                                 0 => 'Page.' . intRequestVar('page'),
276                                 2 => createArchiveListLink($blogid, $this->linkparams)
277                         );
278                 }
279
280 //store Item =====================================
281                 if ($skinType == 'item') {
282                         $item =& $manager->getItem($itemid, 0, 0);
283                         $naviUnit[] = array(
284                                 0 => $item['title']
285                         );
286
287                         $query = 'SELECT i.ititle, i.inumber'
288                                    . ' FROM ' . sql_table('item') . ' as i' . $mtable
289                                    . ' WHERE i.idraft = 0'
290                                    . " and i.itime < '" . $item['itime'] . "' " . $where
291                                    . ' ORDER BY i.itime DESC'; 
292                         $res   = sql_query($query);
293                         if ($ares = mysql_fetch_row($res)) {
294                                 $alink          = createItemLink($ares[1], $this->linkparams);
295                                 $subNaviUnit[1] = '<a href="'
296                                                                 . htmlspecialchars($alink, ENT_QUOTES, _CHARSET)
297                                                                 . '" rel="prev"> ' . $prevLabel . ' '
298                                                                 . shorten($ares[0], 14, '...')
299                                                                 . '</a>';
300                         }
301
302                         $query = 'SELECT i.ititle, i.inumber'
303                                    . ' FROM ' . sql_table('item') . ' as i' . $mtable
304                                    . ' WHERE i.idraft = 0'
305                                    . " and i.itime > '" . $item['itime'] . "' " . $where
306                                    . ' ORDER BY i.itime ASC'; 
307                         $res   = sql_query($query);
308                         if ($ares = mysql_fetch_row($res)) {
309                                 $alink          = createItemLink($ares[1], $this->linkparams);
310                                 $subNaviUnit[2] = '<a href="'
311                                                                 . htmlspecialchars($alink, ENT_QUOTES, _CHARSET)
312                                                                 . '" rel="next"> '
313                                                                 . shorten($ares[0], 14, '...')
314                                                                 . ' ' . $nextLabel . '</a>';
315                         }
316
317                 }
318
319 //store ArchiveList =====================================
320                 if ($skinType == 'archivelist' || $skinType == 'archive') {
321                         $naviUnit[] = array(
322                                 0 => $this->getOption('archivelinkLabel'),
323 //                              0 => 'ArchiveList',
324                                 1 => createArchiveListLink($blogid, $this->linkparams)
325                         );
326                 }
327
328                 if ($skinType == 'archive') {
329                         sscanf($archive,'%d-%d-%d', $y, $m, $d);
330 //store ArchiveMonth
331                         $archiveMonth = $y . '-' . $m;
332                                 $naviUnit[] = array(
333                                         0 => $archiveMonth,
334                                         1 => createArchiveLink($blogid, $archiveMonth, $this->linkparams)
335                                 );
336                         if (empty($d)) {
337                                 $timestamp_start = mktime(0, 0, 0, $m,   1, $y);
338                                 $timestamp_end   = mktime(0, 0, 0, $m+1, 1, $y);
339                                 $date_str        = 'SUBSTRING(i.itime, 1, 7)';
340                         } else {
341                                 $timestamp_start = mktime(0, 0, 0, $m, $d,   $y);
342                                 $timestamp_end   = mktime(0, 0, 0, $m, $d+1, $y);
343                                 $date_str        = 'SUBSTRING(i.itime, 1, 10)';
344 //store ArchiveDay
345                                 $naviUnit[] = array(
346                                         0 => $y . '-' . $m . '-' . $d,
347                                         1 => createArchiveLink($blogid, $archive, $this->linkparams)
348                                 );
349                         }
350
351 //=============================
352                         $query = 'SELECT ' . $date_str . ' as Date'
353                                    . ' FROM ' . sql_table('item') . ' as i' . $mtable
354                                    . ' WHERE i.idraft = 0'
355                                    . ' and i.itime < ' . mysqldate($timestamp_start) . $where
356                                    . ' GROUP BY Date'
357                                    . ' ORDER BY i.itime DESC'; 
358                         $res   = sql_query($query);
359                         if ($ares = mysql_fetch_row($res)) {
360 //                              $prev_date = $ares[0];
361                                 sscanf($ares[0], '%d-%d-%d', $y, $m, $d);
362                                 if (empty($d)) {
363                                         $prev_date = sprintf('%04d-%02d',      $y, $m);
364                                 } else {
365                                         $prev_date = sprintf('%04d-%02d-%02d', $y, $m, $d);
366                                 }
367                                 $prev_alink = createArchiveLink($blogid, $prev_date, $this->linkparams);
368                                 $subNaviUnit[1] = '<a href="'
369                                                                 . htmlspecialchars($prev_alink, ENT_QUOTES, _CHARSET)
370                                                                 . '" class="prevlink" rel="prev">'
371                                                                 . ' ' . $prevLabel . ' '
372                                                                 . htmlspecialchars($prev_date, ENT_QUOTES, _CHARSET)
373                                                                 . '</a>';
374 //                              $abuf .= '<a href="'.$prev_alink.'" class="prevlink" rel="prev">'.$prev_date.'</a>';
375 //                      } else {
376 //                              $today_link = createBlogidLink($b->getID(), $this->linkparams);
377 //                              $abuf .= '  ( <a href="'.$today_link.'">Today</a> )';
378                         }
379                         $abuf .= ' | <strong>' . htmlspecialchars($archive, ENT_QUOTES, _CHARSET) . '</strong> ';
380 //=============================
381                         $query = 'SELECT ' . $date_str . ' as Date'
382                                    . ' FROM ' . sql_table('item') . ' as i' . $mtable
383                                    . ' WHERE i.idraft = 0'
384                                    . ' and i.itime < ' . mysqldate($b->getCorrectTime())
385                                    . ' and i.itime >= ' . mysqldate($timestamp_end) . $where
386                                    . ' GROUP BY Date'
387                                    . ' ORDER BY i.itime ASC'; 
388                         $res   = sql_query($query);
389                         if ($ares = mysql_fetch_row($res)) {
390 //                              $next_date = $ares[0];
391                                 sscanf($ares[0],'%d-%d-%d', $y, $m, $d);
392                                 if (empty($d)) {
393                                         $next_date = sprintf('%04d-%02d',      $y, $m);
394                                 } else {
395                                         $next_date = sprintf('%04d-%02d-%02d', $y, $m, $d);
396                                 }
397                                 $next_alink     = createArchiveLink($blogid, $next_date, $this->linkparams);
398                                 $subNaviUnit[2] = '<a href="'
399                                                                 . htmlspecialchars($next_alink, ENT_QUOTES, _CHARSET)
400                                                                 . '" class="nextlink" rel="next">'
401                                                                 . htmlspecialchars($next_date, ENT_QUOTES, _CHARSET)
402                                                                 . ' ' . $nextLabel . '</a>';
403 //                              $a2buf = ' | <a href="'.$next_alink.'" class="nextlink" rel="next">'.$next_date.'</a>';
404 //                      } else {
405 //                              $today_link = createBlogidLink($b->getID(), $this->linkparams);
406 //                              $a2buf .= ' | ( <a href="'.$today_link.'">Today</a> )';
407                         }
408                 }
409 //============================= // end of archive(s)
410
411 // Print subNavi
412 // todo Henceforth to template
413 //              echo ' <div style="text-align: center;">';
414 //              echo ' <span style="text-align:right;">';
415 //              echo ' <span class="prevnextnavi">';
416                 $endKey = $this->scanEndKey($naviUnit);
417 //              if ($skinType != 'archivelist' && $skinType != 'archive' && $skinType != 'item') {
418 //                      echo '<a href="' . $naviUnit[$endKey][2] . '">&raquo; ArchiveList</a>';
419 //              }
420 //              echo @join(' :: ', $subNaviUnit);
421 //              echo '</div>';
422 //              echo '</span>';
423 ///
424
425 /*
426 <%subnavi%>     --> prev. and next link
427 <%archivedata%> --> ArchiveList link
428 */
429
430                 $subNaviData['subnavi'] = implode($this->getOption('PNSeparator'), $subNaviUnit);
431                 if ($skinType != 'archivelist' && $skinType != 'archive' && $skinType != 'item') {
432                         if (!empty($naviUnit)) {
433                                 $subNaviData['archivedata'] .= '<a href="'
434                                                                                  . $naviUnit[$endKey][2]
435                                                                                  . '">' . $this->getOption('archivelinkLabel') . '</a>';
436                         }
437                 }
438                 $subnaviTemplate              = $this->getOption('subnaviTemplate');
439                 $navigateData['subnaviblock'] = TEMPLATE::fill($subnaviTemplate, $subNaviData);
440 //              echo TEMPLATE::fill($subnaviTemplate, $subNaviData);
441 //*/
442 // Print mainNavi
443                 unset($naviUnit[$endKey][1]);
444                 $naviVar = array_map(array(&$this, 'createNaviLink'), $naviUnit);
445
446 //              echo '<span class="breadcrumbslist">', @join(' &gt; ', $naviVar);
447
448                 $topicPathData['topicpath'] = implode($this->getOption('topicPathSeparator'), $naviVar);
449
450 //add Taginfo =====================================
451 // display selected TAGs whith link mod by shizuki
452                 if ($manager->pluginInstalled('NP_TagEX')) {
453 //                      if (requestVar('tag')) {
454                         $tagPlugin =& $manager->getPlugin('NP_TagEX');
455                         $requestT  =  $tagPlugin->getNoDecodeQuery('tag');
456                         if (!empty($requestT)) {
457                                 $requestTarray = $tagPlugin->splitRequestTags($requestT);
458                                 $reqAND        = array_map(array(&$tagPlugin, "_rawdecode"), $requestTarray['and']);
459                                 if ($requestTarray['or']) {
460                                         $reqOR = array_map(array(&$tagPlugin, "_rawdecode"), $requestTarray['or']);
461                                 }
462                                 if ($reqOR) {
463                                         $reqTags = array_merge($reqAND, $reqOR);
464                                 } else {
465                                         $reqTags = $reqAND;
466                                 }
467                                 for ($i=0;$i<count($reqTags);$i++) {
468                                         $tag = trim($reqTags[$i]);
469                                         $taglist[$i] = '<a href="' . $tagPlugin->creatTagLink($tag, 0) . '">'
470                                                                  . htmlspecialchars($tag, ENT_QUOTES, _CHARSET) . '</a>';
471                                 }
472 //                              echo ' <small style="font-family:Tahoma;">';
473 //                              echo ' (Tag for "'.$tagPlugin->_rawdecode(requestVar('tag')).'")';
474 //                              echo ' (Tag for "' . @join(' / ', $taglist) . '")';
475 //                              echo '</small>';
476 /*
477 <%tags%> --> selected TAGs with own link
478 */
479                                 $tagsData['tags']         = implode(' / ', $taglist);
480                                 $tagListTemplate          = $this->getOption('tagListTemplate');
481                                 $topicPathData['taglist'] = TEMPLATE::fill($tagListTemplate, $tagsData);
482 //*/
483                         }
484                 }
485 /*
486 <%topicpath%> --> topicpath
487 <%taglist%>   --> selected TAG list
488 */
489                 $topicPathTemplate              = $this->getOption('topicPathTemplate');
490                 $navigateData['topicpathblock'] = TEMPLATE::fill($topicPathTemplate, $topicPathData);
491 //              echo TEMPLATE::fill($topicPathTemplate, $topicPathData);
492                 $navigateBlockTemplate          = $this->getOption('ItemNaviTemplate');
493 /*
494 <%subnaviblock%>
495 <%topicpathblock%>
496 */
497                 echo TEMPLATE::fill($navigateBlockTemplate, $navigateData);
498 //*/
499 //              echo '</span>';
500
501         }
502
503     function getParenta($subcat_id, $blogid=0)
504     {
505         $subcat_id = intval($subcat_id);
506         $blogid    = intval($blogid);
507         $r         = array();
508         $que       = 'SELECT scatid, parentid, sname, catid FROM %s WHERE scatid = %d';
509         $que       = sprintf($que, sql_table('plug_multiple_categories_sub'), $subcat_id);
510         $res       = sql_query($que);
511         list ($sid, $parent, $sname, $cat_id) = mysql_fetch_row($res);
512                 if (intval($parent) != 0) {
513                         $this->r[]                  =  $this->getParenta(intval($parent), $blogid);
514                         $this->linkparams[subcatid] = $sid;
515                         $r =  array(
516                                 0 => $sname,
517                                 1 => createBlogidLink($blogid, $this->linkparams),
518                                 2 => createArchiveListLink($blogid, $this->linkparams)
519                         );
520                 } else {
521                         $this->linkparams[subcatid] = $sid;
522                         $r =  array(
523                                 0 => $sname,
524                                 1 => createBlogidLink($blogid, $this->linkparams),
525                                 2 => createArchiveListLink($blogid, $this->linkparams)
526                         );
527                 }
528         return $r;
529     }
530
531         function getParent($subcat_id)
532     {
533         $subcat_id = intval($subcat_id);
534         $que       = 'SELECT scatid, parentid, sname FROM %s WHERE scatid = %d';
535         $que       = sprintf($que, sql_table('plug_multiple_categories_sub'), $subcat_id);
536         $res       = sql_query($que);
537         list ($sid, $parent, $sname) = mysql_fetch_row($res);
538         if (intval($parent) != 0) {
539                 $r = $this->getParent(intval($parent)) . " -> <a href=$subcat_id>$sname</a>";
540         } else {
541                 $r = "<a href=$subcat_id>" . htmlspecialchars($sname) . "</a>";
542         }
543         return $r;
544     }
545
546     function getChildren($subcat_id)
547     {
548         $subcat_id = intval($subcat_id);
549         $que       = 'SELECT scatid, parentid, sname FROM %s WHERE parentid = %d';
550         $que       = sprintf($que, sql_table('plug_multiple_categories_sub'), $subcat_id);
551         $res       = sql_query($que);
552                 while ($so =  mysql_fetch_object($res)) {
553                         $r .= $this->getChildren($so->scatid) . '/' . intval($so->scatid);
554                 }
555         return $r;
556     }
557
558         function install()
559         {
560                 // include language file for this plugin 
561                 $language = ereg_replace( '[\\|/]', '', getLanguageName()); 
562                 if (file_exists($this->getDirectory() . $language . '.php')) {
563                         include_once($this->getDirectory() . $language . '.php'); 
564                 } else {
565                         include_once($this->getDirectory() . 'english.php');
566                 }
567                 $sub  = '<div style="text-align:right;"><%archivedata%><%subnavi%></div>';
568                 $path = '<div style="text-align:left;"><%topicpath%><%taglist%></div>';
569                 $tags = ' (Selected TAG(s) : <small style="font-family:Tahoma;"><%tags%></small>)';
570                 $navi = '<div class="itemnaviex"><%subnaviblock%><%topicpathblock%></div>';
571                 $this->createOption('subnaviTemplate',    _INEXOP_SUB,  'text', $sub);
572                 $this->createOption('PNSeparator',        _INEXOP_PNSP, 'tect', ' :: ');
573                 $this->createOption('PNNextLabel',        _INEXOP_PNNX, 'tect', '&raquo;');
574                 $this->createOption('PNPrevLabel',        _INEXOP_PNPR, 'tect', '&laquo;');
575                 $this->createOption('topicPathTemplate',  _INEXOP_PATH, 'text', $path);
576                 $this->createOption('topicPathSeparator', _INEXOP_PSEP, 'text', ' &gt; ');
577                 $this->createOption('tagListTemplate',    _INEXOP_TAGS, 'text', $tags);
578                 $this->createOption('ItemNaviTemplate',   _INEXOP_NAVI, 'text', $navi);
579                 $this->createOption('archivelinkLabel',   _INEXOP_ALBL, 'text', '&raquo; ArchiveList');
580         }
581
582 }