OSDN Git Service

original file
[nucleus-jp/nucleus-plugins.git] / trunk / NP_TreeMenu / NP_TreeMenu.php
1 <?php
2
3 class NP_TreeMenu extends NucleusPlugin {
4
5         function getName()              { return 'JavaScript Tree Menu'; }
6         function getAuthor()    { return 'nakahara21'; }
7         function getURL()               { return 'http://nakahara21.com/'; }
8         function getVersion()   { return '0.5'; }
9         function getDescription() { return 'JavaScript DHTML navigation';       }
10
11         function supportsFeature($what) {
12                 switch($what)
13                 { case 'SqlTablePrefix':
14                                 return 1;
15                         default:
16                                 return 0; }
17         }
18
19         function install() {
20         }
21         
22         function unInstall() {
23         }
24
25
26         function doSkinVar($skinType){
27                 global $CONF, $manager;
28                 $fileName = $CONF['ActionURL'].'?action=plugin&name=TreeMenu&type=f';
29 ?>
30 <script language="JavaScript" src="<?php echo $this->getAdminURL(); ?>ua.js"></script>
31 <script language="JavaScript" src="<?php echo $this->getAdminURL(); ?>ftiens4.js"></script>
32 <script language="JavaScript" src="<?php echo $fileName; ?>"></script>
33
34 <a style="display:none;" href="http://www.treemenu.net/" target=_blank>Menu</a>
35
36 <span class=TreeviewSpanArea>
37 <script>initializeDocument()</script>
38 <a style="font-size:7pt;text-decoration:none;color:silver" href="http://www.treemenu.net/" target=_blank>* By treemenu.net</a>
39
40 <noscript>
41 A tree for site navigation will open here if you enable JavaScript in your browser.
42 </noscript>
43 </span>
44 <?php
45
46
47
48         }
49
50         function doAction($type) {
51                 if($type == 'f'){
52                 global $manager, $CONF;
53                 $aurl = $this->getAdminURL();
54
55 echo <<<EOD
56
57 // You can find instructions for this file at http://www.treeview.net
58
59 //Environment variables are usually set at the top of this file.
60 USETEXTLINKS = 1
61 STARTALLOPEN = 0
62 USEFRAMES = 0
63 USEICONS = 1
64 WRAPTEXT = 1
65 PRESERVESTATE = 1
66
67 ICONPATH = '{$aurl}icons/'
68 HIGHLIGHT = 1
69 HIGHLIGHT_COLOR = ''
70 HIGHLIGHT_BG    = 'silver'
71 BUILDALL = 0
72 GLOBALTARGET = "S" // variable only applicable for addChildren uses
73
74 foldersTree = gFld("Home", "{$CONF['IndexURL']}")
75
76 EOD;
77
78 echo <<<EOD
79
80 // You can find instructions for this file at http://www.treeview.net
81
82 //Environment variables are usually set at the top of this file.
83 USETEXTLINKS = 1
84 STARTALLOPEN = 0
85 USEFRAMES = 0
86 USEICONS = 1
87 WRAPTEXT = 1
88 PRESERVESTATE = 1
89 ICONPATH = '{$aurl}icons/'
90
91 foldersTree = gFld("Home", "{$CONF['IndexURL']}")
92
93 EOD;
94
95                 $query = 'SELECT bnumber as blogid, bname as blogname, burl as blogurl, bshortname, bdesc as blogdesc';
96                 $query .= ' FROM '.sql_table('blog').' b';
97                 $query .= ' ORDER BY bnumber';
98
99                 $res = sql_query($query);
100                 $bn=1;
101                 while ($o = mysql_fetch_object($res)) {
102                         $this->bid = $o->blogid;
103                         $burl = createBlogidLink($o->blogid);
104                         echo 'blog'.$bn.' = insFld(foldersTree, gFld("'.$o->blogname.'", "'.$burl.'"))'."\n";
105                         $cquery = 'SELECT c.catid as catid, c.cname as catname, c.cdesc as catdesc'
106                                 .' FROM '.sql_table('category').' as c'
107                                 .' WHERE c.cblog='.$o->blogid
108                                 .' ORDER BY c.catid';
109                         $cres = sql_query($cquery);
110                         $cn = 1;
111                         while ($co = mysql_fetch_object($cres)) {
112                                 $curl = createBlogidLink($this->bid, array('catid'=>$co->catid));
113                                 echo 'cat'.$cn.' = insFld(blog'.$bn.', gFld("'.$co->catname.'", "'.$curl.'"))'."\n";
114                                 if ($manager->pluginInstalled('NP_MultipleCategories')) {
115                                 $sres = sql_query("SELECT scatid as subcatid, sname as subname, sdesc as subdesc FROM ".sql_table('plug_multiple_categories_sub')." WHERE catid=".$co->catid." AND parentid=0");
116                                 if (mysql_num_rows($sres) > 0) {
117                                         $sn = 1;
118                                         while ($so =  mysql_fetch_object($sres)) {
119                                                 $surl = createBlogidLink($this->bid, array('catid'=>$co->catid, 'subcatid'=>$so->subcatid));
120                                                 $nodeName = 'scat'.$sn;
121                                                 echo $nodeName.' = insFld(cat'.$cn.', gFld("'.$so->subname.'", "'.$surl.'"))'."\n";
122                                                 $this->did = 100;
123                                                 echo $this->scanChild($nodeName, $so->subcatid, $co->catid);
124                                                 $sn++;
125                                         }
126                                 }
127                                 }
128                         $cn++;
129                         }
130                 $bn++;
131                 }
132
133
134
135 /*
136 echo <<<EOD
137
138   aux1 = insFld(foldersTree, gFld("Expand for example with pics and flags", "javascript:undefined"))
139     aux2 = insFld(aux1, gFld("United States", "demoFrameless.html?pic=%22beenthere_unitedstates%2Egif%22"))
140                         insDoc(aux2, gLnk("S", "Boston", "demoFrameless.html?pic=%22beenthere_boston%2Ejpg%22"))
141                         insDoc(aux2, gLnk("S", "Tiny pic of New York City", "demoFrameless.html?pic=%22beenthere_newyork%2Ejpg%22"))
142                         insDoc(aux2, gLnk("S", "Washington", "demoFrameless.html?pic=%22beenthere_washington%2Ejpg%22"))
143     aux2 = insFld(aux1, gFld("php", "http://nakahara21.com/000/index.php?catid=2"))
144       insDoc(aux2, gLnk("S", "London", "demoFrameless.html?pic=%22beenthere_london%2Ejpg%22"))
145       insDoc(aux2, gLnk("S", "Lisbon", "demoFrameless.html?pic=%22beenthere_lisbon%2Ejpg%22"))
146   aux1 = insFld(foldersTree, gFld("Types of node", "javascript:undefined"))
147     aux2 = insFld(aux1, gFld("Expandable with link", "demoFrameless.html?pic=%22beenthere_europe%2Egif%22"))
148       insDoc(aux2, gLnk("S", "London", "demoFrameless.html?pic=%22beenthere_london%2Ejpg%22"))
149     aux2 = insFld(aux1, gFld("Expandable without link", "javascript:undefined"))
150                         insDoc(aux2, gLnk("S", "NYC", "demoFrameless.html?pic=%22beenthere_newyork%2Ejpg%22"))
151     insDoc(aux1, gLnk("B", "Opens in new window", "http://www.treeview.net/treemenu/demopics/beenthere_pisa.jpg"))
152
153
154 EOD;
155 */
156                 }else{
157                         return;
158                 }
159         }
160
161         function scanChild($nodeName, $sid=0, $catid){
162                                 $sres = sql_query("SELECT scatid as subcatid, sname as subname, sdesc as subdesc FROM ".sql_table('plug_multiple_categories_sub')." WHERE parentid=".$sid);
163                                 if (mysql_num_rows($sres) > 0) {
164                                         $ssn = 0;
165                                         while ($so =  mysql_fetch_object($sres)) {
166 //                                              $surl = createCategoryLink($catid, array('subcatid'=>$so->subcatid));
167                                                 $surl = createBlogidLink($this->bid, array('catid'=>$catid, 'subcatid'=>$so->subcatid));
168                                                 $this->did++;
169                                                 $snode = 'sscat'.$this->did;
170                                                 $out .= $snode.' = insFld('.$nodeName.', gFld("'.$so->subname.'", "'.$surl.'"))'."\n";
171                                                 $out .= $this->scanChild($snode, $so->subcatid, $catid);
172                                         }
173                                 }
174                 return $out;
175         }
176
177 }
178 ?>