OSDN Git Service

8edeb457017511f71300e307c9952a351f280f24
[nucleus-jp/nucleus-plugins.git] / trunk / NP_Dtree / NP_Dtree.php
1 <?php
2 /**
3   *
4   * 0.94 bug fix
5   *       add language files
6   *       configuration by option
7   * 0.93 sec fix
8   *       subcategory link bug fix
9   *
10   */
11
12 class NP_Dtree extends NucleusPlugin
13 {
14
15     function getName()
16     {
17         return 'Navigation Tree'; 
18     }
19
20     function getAuthor()
21     { 
22         return 'nakahara21 + shizuki'; 
23     }
24
25     function getURL()
26     {
27         return 'http://nakahara21.com/'; 
28     }
29
30     function getVersion()
31     {
32         return '0.94'; 
33     }
34
35     function getDescription()
36     { 
37         return _DTREE_DESCRIPTION;  //'Show Navigation Tree. Usage: &lt;%Dtree()%&gt;';
38     }
39
40     function supportsFeature($what)
41     {
42         switch($what){
43             case 'SqlTablePrefix':
44                 return 1;
45             default:
46                 return 0;
47         }
48     }
49
50     function install()
51     {
52         $this->createOption('folderLinks',    _DTREE_DIR_LINK,  'yesno', 'yes');
53         $this->createOption('useSelection',   _DTREE_SELECTION, 'yesno', 'no');
54         $this->createOption('useCookies',     _DTREE_COOKIE,    'yesno', 'no');
55         $this->createOption('useLines',       _DTREE_LINE,      'yesno', 'yes');
56         $this->createOption('useIcons',       _DTREE_ICON,      'yesno', 'yes');
57         $this->createOption('useStatusText',  _DTREE_ST_TEXT,   'yesno', 'no');
58         $this->createOption('closeSameLevel', _DTREE_CL_SLEVEL, 'yesno', 'no');
59         $this->createOption('inOrder',        _DTREE_IN_ORDER,  'yesno', 'no');
60     }
61
62     function init()
63     {
64         global $admin;
65         $language = ereg_replace( '[\\|/]', '', getLanguageName());
66         if (file_exists($this->getDirectory().'language/'.$language.'.php')) {
67             include_once($this->getDirectory().'language/'.$language.'.php');
68         }else {
69             include_once($this->getDirectory().'language/english.php');
70         }
71     }
72
73     function doSkinVar($skinType, $itemid = 0)
74     { 
75         global $blogid, $catid, $subcatid;
76         $adminURL = htmlspecialchars($this->getAdminURL(), ENT_QUOTES, _CHARSET);
77         if (is_numeric($blogid)) {
78             $blogid = intval($blogid);
79         } else {
80             $id     = getBlogIDFromName($blogid);
81             $blogid = intval($id);
82         }
83         $itemid   = intval($itemid);
84         $catid    = intval($catid);
85         $subcatid = intval($subcatid);
86         
87 //      $randomID = 'tree' . uniqid(rand());
88         $randomID = 'tree' . preg_replace('|[^0-9a-f]|i', '', uniqid(rand()));
89
90         echo '<script type="text/javascript" src="' . $adminURL . 'dtree.php"></script>' . "\n";
91
92         if ($skinType == 'template') {
93             $data = '<script type="text/javascript"' . ' src="' . $adminURL
94                     . 'dtreedata.php?'
95                     . 'o=' . $randomID . 'a'
96                     . '&amp;'
97                     . 'bid=' . $blogid
98                     . '&amp;'
99                     . 'id=' . $itemid
100                     . '"></script>' . "\n";
101             echo $data;
102             $data = '<a href="javascript: ' . $randomID . 'a.openAll();">' . _DTREE_OPENALL . '</a>' . "\n"
103                   . ' | ' . "\n"
104                   . '<a href="javascript: ' . $randomID . 'a.closeAll();">' . _DTREE_CLOSEALL . '</a>' . "\n";
105             echo $data;
106             return;
107         }
108
109         $eq = '';
110         if (!empty($catid)) {
111         }   $eq .= '&amp;cid=' . $catid;
112         if (!empty($subcatid)) {
113             $eq .= '&amp;sid=' . $subcatid;
114         }
115
116         $data = '<script type="text/javascript" src="' . $adminURL
117                 . 'dtreedata.php?'
118                 . 'o=' . $randomID . 'd'
119                 . '&amp;'
120                 . 'bid=' . $blogid . $eq . '">'
121                 . '</script>';
122         echo $data;
123         $data = '<a href="javascript: ' . $randomID . 'd.openAll();">' . _DTREE_OPENALL . '</a>' . "\n"
124               . ' | ' . "\n"
125               . '<a href="javascript: ' . $randomID . 'd.closeAll();">' . _DTREE_CLOSEALL . '</a>' . "\n";
126         echo $data;
127
128     }
129
130     function doTemplateVar(&$item)
131     {
132         $this->doSkinVar('template', $item->itemid);
133     }
134
135 }
136 ?>