OSDN Git Service

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@859 1ca29b6e-896d...
[nucleus-jp/nucleus-plugins.git] / NP_Milionic / NP_Milionic.php
1 <?php
2
3 class NP_Milionic extends NucleusPlugin {
4
5         function getName()              { return 'DHTML Tree Menu'; }
6         function getAuthor()    { return 'nakahara21'; }
7         function getURL()               { return 'http://nakahara21.com/'; }
8         function getVersion()   { return '0.8'; }
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, $blogid, $catid, $subcatid;
28                 
29                 
30                 
31                 $fileName = $CONF['ActionURL'].'?action=plugin&name=Milionic&type=f&st='.$skinType;
32                 $fileName .= '&bid='.$blogid;
33                 if($catid) $fileName .= '&cid='.$catid;
34                 if($subcatid) $fileName .= '&sid='.$subcatid;
35
36
37 ?>
38
39 <script type="text/javascript" src="<?php echo $this->getAdminURL(); ?>milonic_src.js"></script>
40 <div class=milonic><a href="http://www.milonic.com/">JavaScript Menu, DHTML Menu Powered By Milonic</a></div>
41 <script type="text/javascript">
42         <!--
43         if(ns4)_d.write("<scr"+"ipt type=text/javascript src='<?php echo $this->getAdminURL(); ?>mmenuns4.js'><\/scr"+"ipt>");
44           else _d.write("<scr"+"ipt type=text/javascript src='<?php echo $this->getAdminURL(); ?>mmenudom.js'><\/scr"+"ipt>");
45         -->
46 </script>
47 <script type="text/javascript" src="<?php echo $fileName; ?>"></script>
48 <table>
49 <td>
50 <script type="text/javascript">
51         <!--
52 drawMenus();
53         -->
54 </script>
55 <noscript>
56 Site navigation will open here if you enable JavaScript in your browser.
57 </noscript>
58 </td>
59 </table>
60
61
62 <?php
63         }
64
65         function doAction($type) {
66                 if($type == 'f'){
67                 global $manager, $CONF;
68                 $aurl = $this->getAdminURL().'icons/';
69                 $blogid = intRequestVar('bid');
70                 $catid = intRequestVar('cid');
71                 $subcatid = intRequestVar('sid');
72                 $skinType = requestVar('st');
73
74 //++++++++++++++++++++++++++++++++++++++
75 $pathToCodeFiles=$aurl;               // The www root to where the menu code files are located
76
77 /// The following is only changed if the name of the menu code files have been changed.
78 $menuVars=array();
79 $menuData="";
80
81 //++++++++++++++++++++++++++++++++++++++
82
83 echo <<<EOD
84
85 _menuCloseDelay=150;
86 _menuOpenDelay=10;
87 _subOffsetTop=0;
88 _subOffsetLeft=2;
89
90 with(submenuStyle=new mm_style()){
91 fontfamily="Verdana";
92 fontsize="80%";
93 fontstyle="normal";
94 high3dcolor="#ffffff";
95 low3dcolor="#336633";
96 offbgcolor="#DFDFBF";
97 offborder="1px solid #BDBDA2";
98 offcolor="#000000";
99 onbgcolor="#878774";
100 onborder="2px outset #CBCBAE";
101 oncolor="#ffffff";
102 onsubimage="{$aurl}white_arrow.gif";
103 padding=4;
104 separatorcolor="#a0c0a0";
105 separatorsize=1;
106 subimage="{$aurl}arrow.gif";
107 subimagepadding=4;
108 image='{$aurl}grey-bar.gif';
109 pageimage="{$aurl}grey-bar-select.gif";
110 pagematch="";
111 }
112
113 with(menuStyle=new mm_style()){
114 fontfamily="Verdana";
115 fontsize="80%";
116 fontstyle="normal";
117 high3dcolor="#ffffff";
118 low3dcolor="#336633";
119 offbgcolor="#DFDFBF";
120 offborder="1px solid #BDBDA2";
121 offcolor="000000";
122 onbgcolor="#878774";
123 onborder="2px outset #CBCBAE";
124 oncolor="#ffffff";
125 onsubimage="{$aurl}white_arrow.gif";
126 padding=4;
127 separatorcolor="#336600";
128 separatorsize=1;
129 subimage="{$aurl}arrow.gif";
130 subimagepadding=4;
131 itemwidth=100;
132 image='{$aurl}grey-bar.gif';
133 pageimage="{$aurl}grey-bar-select.gif";
134 pagematch="";
135 }
136
137 with(milonic=new menuname("Main Menu")){
138 alwaysvisible=1;
139 orientation="Vertical";
140 position="relative";
141 style=menuStyle;
142 aI("status=Back To Home Page;text=HOME;url=http://www.milonic.com/;");
143 aI("showmenu=Categores;text=Categores;pagematch=catid=;");
144 aI("showmenu=Archives;text=Archives;pagematch=archive;");
145 aI("showmenu=Remarks;text=Remarks;");
146 aI("showmenu=Links;text=LINKS;");
147 aI("showmenu=Search;text=¸¡º÷;");
148 aI("showmenu=Login;text=Login;");
149 aI("showmenu=Otherblog;fontsize=xx-small;fontfamily=Tahoma;text=`<small>Other Blog</small>`;pageimage=;");
150 }
151
152
153 with(milonic=new menuname("Links")){
154 style=submenuStyle;
155 aI("status=Apache Web Server, the basis of Milonic's Web Site;text=Apache Server;url=http://www.apache.org/;");
156 aI("status=MySQL, Milonic's Prefered Choice of Database Server;text=MySQL Database Server;url=http://ww.mysql.com/;");
157 aI("status=PHP - Web Server Scripting as used by Milonic;text=PHP - Development;url=http://www.php.net/;");
158 aI("status=PHP Based Web Forum, Milonic's Recommended Forum Software;text=phpBB Web Forum System;url=http://www.phpbb.net/;");
159 aI("showmenu=Anti Spam;status=Anti Spam Solutions, as used by Milonic;text=Anti Spam;");
160 }
161
162 with(milonic=new menuname("Anti Spam")){
163 style=submenuStyle;
164 aI("text=Spam Cop;url=http://www.spamcop.net/;");
165 aI("text=Mime Defang;url=http://www.mimedefang.org/;");
166 aI("text=Spam Assassin;url=http://www.spamassassin.org/;");
167 }
168
169
170 EOD;
171 //++++++++++++++++++++++++++++++++++++++
172 $menuVars=array();
173 $menuData="";
174 //++(SEARCH)++++++++++++++++++++++++++++++++++++
175                 $mmMenu=new mMenu();
176                 $mmMenu->style="submenuStyle";
177                 $searchForm = $this->doParse('<%searchform%>',$skinType);
178                 $mmMenu->addItemFromText('text=`' . $searchForm . '`;type=form;align=center;onbgcolor=;onborder=;image=;');
179                 $mmMenu->createMenu("Search");
180
181 //++(Login)++++++++++++++++++++++++++++++++++++
182                 $mmMenu=new mMenu();
183                 $mmMenu->style="submenuStyle";
184                 $searchForm = $this->doParse('<%loginform%>',$skinType);
185                 $mmMenu->addItemFromText('text=`' . $searchForm . '`;type=form;align=center;onbgcolor=;onborder=;image=;');
186                 
187                 $mmMenu->addItemFromText('text=Jump to Admin Page;url='.$CONF['AdminURL'].';align=center;onbgcolor=;onborder=;image=;');
188                 $mmMenu->createMenu("Login");
189
190 //++(other blog)++++++++++++++++++++++++++++++++++++
191
192                 $query = 'SELECT bnumber as blogid, bname as blogname, burl as blogurl, bshortname, bdesc as blogdesc';
193                 $query .= ' FROM '.sql_table('blog');
194                 $query .= ' WHERE bnumber <>'.$blogid;
195                 $query .= ' ORDER BY bnumber';
196
197                 $res = sql_query($query);
198                 $bn=1;
199                 $mmMenu=new mMenu();
200                 $mmMenu->style="submenuStyle";
201                 while ($o = mysql_fetch_object($res)) {
202                         $this->bid = $o->blogid;
203                         $burl = createBlogidLink($o->blogid);
204                         $mmMenu->addItemFromText("text=".$o->blogname.";url=".$burl.";pageimage=;");
205                 }
206                 $mmMenu->createMenu("Otherblog");
207
208
209 //++(archives)++++++++++++++++++++++++++++++++++++
210                 if($amTemp = $this->_getArchiveList('month', 0, $blogid, $catid, $subcatid)){
211 //                      print_r($amTemp);
212                         $archiveYears = array_keys($amTemp);
213                         $mmMenu=new mMenu();
214                         $mmMenu->style="submenuStyle";
215                         $mmMenu->overflow="scroll";
216                         for($i=0;$i<count($archiveYears);$i++){
217                                 $mmMenu->addItemFromText("showmenu=ay" . $archiveYears[$i] . ";text=" . $archiveYears[$i] . ";pagematch=" . $archiveYears[$i] . ";");
218                         }
219                         $mmMenu->createMenu("Archives");
220                                 
221                                 
222                         foreach($amTemp as $ay => $values){
223                                 $mmMenu=new mMenu();
224                                 $mmMenu->style="submenuStyle";
225                                 $mmMenu->overflow="scroll";
226                                 for($i=0;$i<count($values);$i++){
227                                         $mmMenu->addItemFromText("showmenu=am" . $values[$i]['archivedate'] . ";text=" . $values[$i]['archivedate'] . ";url=" . $values[$i]['archivelink'] . ";pagematch=" . $values[$i]['archivedate'] . ";");
228                                 }
229                                 $mmMenu->createMenu("ay".$ay);
230                         }
231
232                         $adTemp = $this->_getArchiveList('day', 0, $blogid, $catid, $subcatid);
233                         foreach($adTemp as $archiveMonth => $Values){
234                                 $mmMenu=new mMenu();
235                                 $mmMenu->style="submenuStyle";
236                                 $mmMenu->overflow="scroll";
237                                 for($i=0;$i<count($Values);$i++){
238                                         $mmMenu->addItemFromText("text=" . $Values[$i]['archivedate'] . ";url=" . $Values[$i]['archivelink'] . ";pagematch=" . $Values[$i]['archivedate'] . ";");
239                                 }
240                                 $mmMenu->createMenu($archiveMonth);
241                         }
242                         
243                 }else{
244                         $mmMenu=new mMenu();
245                         $mmMenu->style="submenuStyle";
246                         $mmMenu->addItemFromText("text=(No archives);image=;");
247                         $mmMenu->createMenu("Archives");
248                 }
249 //++(category)++++++++++++++++++++++++++++++++++++
250                 $cquery = 'SELECT catid as catid, cname as catname, cdesc as catdesc FROM '.sql_table('category').' WHERE cblog='.$blogid.' ORDER BY catid';
251                 $cres = sql_query($cquery);
252                 $mmMenu=new mMenu();
253                 $mmMenu->style="submenuStyle";
254                 while ($co = mysql_fetch_object($cres)) {
255                         $curl = $this->_de(createBlogidLink($blogid, array('catid'=>$co->catid)));
256                         $chkFlg = $this->checkMSCVersion();
257                         $menuExtra = "";
258                         if($chkFlg > 1){
259                                 $keyName = 'catid'.$co->catid;
260                                 if($subcatArray[$keyName] = $this->_getScatsFromCatid($co->catid, $chkFlg)){
261                                         $menuExtra = "showmenu=catid" . $co->catid.";";
262                                 }
263                         }
264                         $mmMenu->addItemFromText($menuExtra . "text=" . $co->catname . ";url=" . $curl . ";pagematch=catid=" . $co->catid . ";");
265                 } //end of storing catid item
266                 $mmMenu->createMenu("Categores");
267
268 //              print_r($subcatArray);
269                 if($subcatArray){
270                         foreach($subcatArray as $keyName=>$valueArray){
271                                 if($valueArray){
272                                 $cid = str_replace('catid','',$keyName);
273                                 $mmMenu=new mMenu();
274                                 $mmMenu->style="submenuStyle";
275                                 for($i=0;$i<count($valueArray);$i++){
276                                         $sid = $valueArray[$i]['scatid'];
277                                         $surl = $this->_de(createBlogidLink($blogid, array('catid'=>$cid, 'subcatid'=>$sid)));
278                                         if($this->checkMSCVersion() > 2){
279                                                 $this->getDescendantFromScatid($sid, 0);
280                                                 $extra = ($this->r[$sid])? 'showmenu=sid'.$sid.';' : '';
281                                                 $mmMenu->addItemFromText($extra."text=" . $valueArray[$i]['sname'] . ";url=" . $surl . ";pagematch=catid=" . $cid ."&subcatid=".$sid.";");
282                                         }else{
283                                                 $mmMenu->addItemFromText("text=" . $valueArray[$i]['sname'] . ";url=" . $surl . ";pagematch=catid=" . $cid ."&subcatid=".$sid.";");
284                                         }
285                                 }
286                                 $mmMenu->createMenu("$keyName");
287                                 }
288                         }
289                 }
290
291                 if($this->r){
292                         foreach($this->r as $sid=>$valueArray){
293                                 $mmMenu=new mMenu();
294                                 $mmMenu->style="submenuStyle";
295                                 for($i=0;$i<count($valueArray);$i++){
296                                         $ssid = $valueArray[$i];
297                                         $sname = $this->mplugin->_getScatNameFromID($ssid);
298                                         $surl = createBlogidLink($blogid, array('catid'=>$cid, 'subcatid'=>$ssid));
299                                         $extra = ($this->r[$ssid])? 'showmenu=sid'.$ssid.';' : '';
300                                                 $mmMenu->addItemFromText($extra."text=" . $sname . ";url=" . $this->_de($surl) . ";pagematch=catid=" . $cid ."&subcatid=".$ssid.";");
301                                 }
302                                 
303                                 $mmMenu->createMenu("sid".$sid);
304                         }
305                 }
306 //++(Remarks)++++++++++++++++++++++++++++++++++++
307                 $mmMenu=new mMenu();
308                 $mmMenu->style="submenuStyle";
309
310                 if($remarks = $this->_getRemarks($blogid, $catid, $subcatid, $mode='both')){
311                         $mmMenu->divides=3;
312                         $mmMenu->overflow="scroll";
313                         for($i=0;$i<count($remarks);$i++){
314                                 $text =  '<b>'.$remarks[$i][name] . "</b>(" . $remarks[$i][date] . ")<br />" . $remarks[$i][shortentext];
315                                 $mmMenu->addItemFromText("text=" . $this->removeN($text) . ";url=" . $remarks[$i][linkurl] . "#c" . $remarks[$i][commentid] .";pagematch=itemid=".$remarks[$i][itemid].";image=;");
316                         }
317                 }else{
318                         $mmMenu->addItemFromText("text=(No remarks);image=;");
319                 }
320                 $mmMenu->createMenu("Remarks");
321
322
323
324
325
326
327                 commitMenus();
328 //++++++++++++++++++++++++++++++++++++++
329                 }else{
330                         return;
331                 }
332         }       //end of function doAction
333
334         
335         function removeN($var) {
336                 return preg_replace("/[\r\n]/","",$var); 
337         }
338         
339         function doParse($content,$type='') {
340                 global $CONF;
341                 $sType = $type;
342                 if ($type == 'pageparser') {
343                         $type = 'index';
344                 }
345                 $handler = new ACTIONS($sType);
346                 $parser = new PARSER(SKIN::getAllowedActionsForType($type), $handler);
347                 $handler->parser =& $parser;
348                 ob_start();
349                         $parser->parse($content);
350                         $res = ob_get_contents();
351                 ob_end_clean();
352                 $res = str_replace('"',"'",$res);
353                 $res = str_replace("\r\n","",$res);
354
355                 return $res;
356         }
357
358         function _getRemarks($blogid, $catid, $subcatid, $mode='both'){
359                 global $manager; 
360                 $numberOfCharacters = 60;
361                 $numberOfTitleCharacters = 40;
362                 $toadd = "...";
363
364                 if(!is_numeric($numberOfWritebacks)){
365                         $filter = $numberOfWritebacks;
366                         $numberOfWritebacks   = 5; // defaults to 5
367                 }
368
369                 $mtable = '';
370                 if($catid){
371                         $linkparams[catid] = $catid;
372                         if ($manager->pluginInstalled('NP_MultipleCategories')) {
373                                 $where .= ' and ((i.inumber=p.item_id and (p.categories REGEXP "(^|,)'.intval($catid).'(,|$)" or i.icat='.intval($catid).')) or (i.icat='.intval($catid).' and p.item_id IS NULL))';
374                                 $mtable = ' LEFT JOIN '.sql_table('plug_multiple_categories').' as p ON  i.inumber=p.item_id';
375                                 $mplugin =& $manager->getPlugin('NP_MultipleCategories');
376                                 if ($subcatid && method_exists($mplugin,"getRequestName")) {
377                                         $linkparams[subcatid] = $subcatid;
378 //family
379                                         if($this->checkMSCVersion() >2){
380                                                 $Children = array();
381                                                 $Children = explode('/',intval($subcatid).$this->getDescendantFromScatid(intval($subcatid), 1));
382                                         }
383                                         if($Children[1]){
384                                                 for($i=0;$i<count($Children);$i++){
385                                                         $temp_whr[] = ' p.subcategories REGEXP "(^|,)'.intval($Children[$i]).'(,|$)" ';
386                                                 }
387                                                 $where .= ' and ';
388                                                 $where .= ' ( ';
389                                                 $where .= join(' or ', $temp_whr);
390                                                 $where .= ' )';
391                                         }else{
392                                                 $where .= ' and p.subcategories REGEXP "(^|,)'.intval($subcatid).'(,|$)"';
393                                         }
394 //family end
395                                 }
396                         } else {
397                                 $where .= ' and i.icat='.intval($catid);
398                         }
399                 }
400
401                 // select
402                 $query = "SELECT c.cnumber, c.cuser, c.cbody, c.citem, c.cmember, c.ctime ,UNIX_TIMESTAMP(c.ctime) as ctimest";
403                 $query .= " FROM ".sql_table('comment').' as c, ' . sql_table('item').' as i'.$mtable;
404                 $query .= " WHERE c.citem=i.inumber and i.iblog=".$blogid.$where;
405                 if($filter){
406                         $query .= $filter;
407                 }
408                 $query .= " ORDER by c.ctime DESC LIMIT 0,".$numberOfWritebacks;
409
410                 $comments = mysql_query($query);
411                 
412                 if(mysql_num_rows($comments)){
413                         while($row = mysql_fetch_object($comments)) {
414                                 $temp = array();
415                                 $temp[itemid] = $cid  = $row->citem;
416                                 $temp[commentid] = $cid  = $row->cnumber;
417                                 $temp[timestamp] = $ct  = $row->ctimest;
418                                 $temp[date] = $ctst  = date("y-m-d H:i",strtotime($row->ctime));
419                                 $temp[fulltext] = $text  = strip_tags($row->cbody);
420                                 $temp[shortentext] = $ctext = shorten($text,$numberOfCharacters,$toadd);
421
422                                 if (!$row->cmember) $temp[name] = $myname = $row->cuser;
423                                 else {
424                                         $mem = new MEMBER;
425                                         $mem->readFromID(intval($row->cmember));
426                                         $temp[name] = $myname = $mem->getDisplayName();
427                                 }
428
429                                 $temp[linkurl] = $itemlink = $this->_de(createItemLink($row->citem, $linkparams));
430                                 $resultArray[] = $temp;
431                         }
432                 }
433                 return $resultArray;
434         }
435
436         function _de($url){
437                 return str_replace("&amp;",'&',$url);
438         }
439
440         function getDescendantFromScatid($subcat_id, $mode=0){
441                 $res = sql_query("select scatid, parentid, sname from ".sql_table('plug_multiple_categories_sub')." where parentid = '$subcat_id'");
442                 if($mode >0){
443                         while ($so =  mysql_fetch_object($res)) {
444                                 $r .= $this->getDescendantFromScatid($so->scatid, 1) . '/' . $so->scatid;
445                         }
446                         return $r;
447                 }else{
448                         while ($so =  mysql_fetch_object($res)) {
449                                 $this->r[$subcat_id][] = $this->getDescendantFromScatid($so->scatid, 0);
450                         }
451                         return $subcat_id;
452                 }
453         }
454
455         function checkMSCVersion(){
456         global $manager; 
457                 if ($manager->pluginInstalled('NP_MultipleCategories')) {
458                         $this->mplugin =& $manager->getPlugin('NP_MultipleCategories');
459                         if (method_exists($this->mplugin,"getRequestName")) {
460                                 $res = sql_query("SHOW FIELDS from ".sql_table('plug_multiple_categories_sub') );
461                                 while ($co = mysql_fetch_assoc($res)) {
462                                         if($co['Field'] == 'parentid') return 3;
463                                 }
464                                 return 2;
465                         }else{
466                                 return 1;
467                         }
468                 }else{
469                         return 0;
470                 }
471         }
472
473
474         function _getScatsFromCatid($catid, $version=0){
475                 if($version==0)return;
476                 $aResult = array();     
477                 $query = 'SELECT * FROM '.sql_table('plug_multiple_categories_sub').' WHERE catid=' . intval($catid);
478                 if($version>2) $query .= ' AND parentid=0';
479                 $res = sql_query($query);
480                 while ($a = mysql_fetch_assoc($res)){
481                         array_push($aResult,$a);
482                 } 
483                 return $aResult;
484         }
485
486         function _getArchiveList($mode = 'month', $limit = 0, $blogid, $catid=0, $subcatid=0) {
487                 global $CONF, $manager;
488                 
489                 if(!$blogid) $blogid = $CONF['DefaultBlog'];
490
491                 $b =& $manager->getBlog($blogid);
492                 if ($catid) 
493                         $linkparams = array('catid' => $catid);
494
495                 $query = 'SELECT i.itime, SUBSTRING(i.itime,1,4) AS Year, SUBSTRING(i.itime,6,2) AS Month, SUBSTRING(i.itime,9,2) as Day FROM '.sql_table('item').' as i';
496                 if ($catid) {
497                         $query .= ' LEFT JOIN '.sql_table('plug_multiple_categories').' as p ON i.inumber=p.item_id';
498                 }
499                 $query .= ' WHERE i.iblog=' . $blogid
500                 . ' and i.itime <=' . mysqldate($b->getCorrectTime())   // don't show future items!
501                 . ' and i.idraft=0'; // don't show draft items
502                 
503                 if ($catid) {
504                         $query .= ' and ((i.inumber=p.item_id and (p.categories REGEXP "(^|,)'.intval($catid).'(,|$)" or i.icat='.intval($catid).')) or (i.icat='.intval($catid).' and p.item_id IS NULL))';
505                         $linkparams = array('catid' => $catid);
506                 }
507                 if ($subcatid) {
508                         if($this->checkMSCVersion() >2){
509                                         $Children = array();
510                                         $Children = explode('/',intval($subcatid).$this->getDescendantFromScatid(intval($subcatid), 1) );
511                         }
512                         if($Children[1]){
513                                         for($i=0;$i<count($Children);$i++){
514                                                 $temp_whr[] = ' p.subcategories REGEXP "(^|,)'.intval($Children[$i]).'(,|$)" ';
515                                         }
516                                         $where .= ' and ';
517                                         $where .= ' ( ';
518                                         $where .= join(' or ', $temp_whr);
519                                         $where .= ' )';
520                         }else{
521                                 $query .= ' and p.subcategories REGEXP "(^|,)'.intval($subcatid).'(,|$)"';
522                         }
523                         $linkparams['subcatid'] = $subcatid;
524                 }
525                 
526                 $query .= ' GROUP BY Year, Month';
527                 if ($mode == 'day')
528                         $query .= ', Day';
529                 
530                 $query .= ' ORDER BY i.itime ASC';
531                 
532                 if ($limit > 0) 
533                         $query .= ' LIMIT ' . intval($limit);
534                 
535                 $res = sql_query($query);
536
537                 while ($current = mysql_fetch_object($res)) {
538                         $current->itime = strtotime($current->itime);   // string time -> unix timestamp
539                         $archivedate = ($mode == 'day')? date('Y-m-d',$current->itime): date('Y-m',$current->itime);
540
541                         $data['year'] = $y = date('Y',$current->itime);
542                         $data['month'] = date('m',$current->itime);
543                         if ($mode == 'day') $data['day'] = date('d',$current->itime);
544                         $data['archivedate'] = $archivedate;
545                         $data['archivelink'] = $this->_de(createArchiveLink($blogid,$archivedate,$linkparams));
546                         if($mode == 'day'){
547                                 $menuname = 'am'.date('Y-m',$current->itime);
548                                 $temp[$menuname][] = $data;
549                         }else{
550                                 $temp[$y][] = $data;
551                         }
552                 }
553                 mysql_free_result($res);
554                 return $temp;
555         }
556
557
558 }       //end of CLASS
559
560 class mmenuStyle
561 {
562         
563         function createMenuStyle($styleName)
564         {
565                 global $menuData;
566                 $styleArray=get_object_vars($this);
567                 $menuData.="with($styleName=new mm_style()){\n";
568                 
569                 foreach ($styleArray as $fieldName => $fieldValue) 
570                 {
571                         if(ereg("color",$fieldName))
572                         {
573                                 if(substr($fieldValue,0,1)!="#" && is_numeric($fieldValue))$fieldValue="#".$fieldValue;
574                         }
575                         
576                         $menuData.= "$fieldName=\"$fieldValue\";\n";
577                 }
578    
579                 $menuData.= "}\n\n";
580         }
581 }
582
583
584 class mMenu{
585         var $menuItems;
586         function createMenu($menuName){
587                 global $menuData;
588                 $menuArray=get_object_vars($this);
589
590                 $menuData.= "with(milonic=new menuname(\"$menuName\")){\n";
591                 $tempMenuItems="";
592                 foreach ($menuArray as $fieldName => $fieldValue) {
593                         global $menuData;
594                         if($fieldName!="menuItems")
595                         {
596                                 if($fieldName=="style")
597                                 {
598                                         $menuData.= "$fieldName=$fieldValue;\n";
599                                 }
600                                 else
601                                 {
602                                         $menuData.= "$fieldName=\"$fieldValue\";\n";
603                                 }
604                                 
605                         }
606                         else
607                         {
608                                 if($fieldName=="menuItems")$tempMenuItems=$fieldValue;
609                         }
610                 }
611    
612                 $menuData.= $tempMenuItems."\n";
613                 $menuData.= "}\n\n";
614         }
615         
616         
617         function addItemFromText($itemText){
618                 global $menuData;
619                 $this->menuItems.="aI(\"".$itemText . "\");\n"; 
620         }
621
622         function addItemFromItem($menuItem){
623                 global $menuData;
624                 $tempVar="";
625                 foreach ($menuItem as $fieldName => $fieldValue) {
626                         if(ereg("color",$fieldName)){
627                                 if(substr($fieldValue,0,1)!="#")$fieldValue="#".$fieldValue;
628                         }
629                         
630                         $tempVar.="$fieldName=$fieldValue;";
631                 }
632                 $this->menuItems.="aI(\"".$tempVar . "\");\n";  
633         }       
634         
635 }
636
637
638 class mItem{
639         function addItemElement($mtype,$mval){
640                 $this->$mtype=$mval;
641         }
642 }
643
644
645 function commitMenus(){
646         global $menuData,$menuVars;
647
648 echo $menuData;
649
650 }
651
652
653
654
655 ?>