ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/WEBCONDDB/php_CondDB/utils/menuViewer.php
Revision: 1.1
Committed: Fri Jun 29 07:53:08 2007 UTC (17 years, 10 months ago) by kdziedzi
Branch: MAIN
CVS Tags: V01-01-02, V01-01-01, V1_01_00, V01-01-00, V1_00_01, HEAD
Log Message:
Introducing new order in project

File Contents

# Content
1 <?php
2 /*
3 * Created on Sep 14, 2006
4 * by Katarzyna Maria Dziedziniewicz
5 * Contains:
6 * Left menu
7 */
8 ////session_start();
9
10 class menuViewer
11 {
12 var $int; // no of current subpage
13 var $pages_list = array(); // subpage list
14 var $is_in_subpage;
15 var $is_in_maintainer;
16 var $act_tag;
17 var $menu='';
18 var $DB_pages_list = array();
19 var $DBmenu='';
20 var $DBint;
21 var $is_in_DBpage;
22
23 function menuViewer()
24 {
25 $int = 0;
26 $DBint = 0; // no of current subpage
27 $pages_list = array(); // subpage list
28 $is_in_subpage = 0;
29 $is_in_maintainer = 0;
30 $is_in_DBpage = 0;
31 $DB_pages_list = array();
32 }
33
34 function tag_start($parser, $attr, $params)
35 {
36
37 if($attr == 'SUBPAGE' && $this->is_in_subpage == 1)
38 {
39 die('Configuration Error: Subpages tags cannot be nested :]<br>');
40 }
41 elseif($attr == 'SUBPAGE' && $this->is_in_subpage == 0)
42 {
43 $this->pages_list[$this->int] = new subpage($params['ID']);
44 $this->pages_list[$this->int]->name = $params['NAME'];
45 $this->pages_list[$this->int]->file = $params['FILE'];
46 $this->is_in_subpage = 1;
47 }
48 /* if($attr == 'MAINTAINER' && $this->is_in_maintainer == 1)
49 {
50 die('Configuration Error: maintainers tags cannot be nested :]<br>');
51 }
52 elseif($attr == 'MAINTAINER' && $this->is_in_maintainer == 0)
53 {
54 $_SESSION['maintainer_name'] = $params['NAME'];
55 $_SESSION['maintainer_email'] = $params['EMAIL'];
56 $this->is_in_maintainer = 1;
57 }
58 */ if($attr == 'DB_SUBPAGE' && $this->is_in_DBpage == 1)
59 {
60 die('Configuration Error: DB_Subpages tags cannot be nested :]<br>');
61 }
62 elseif($attr == 'DB_SUBPAGE' && $this->is_in_DBpage == 0)
63 {
64 $this->DB_pages_list[$this->DBint] = new subpage($params['ID']);
65 $this->DB_pages_list[$this->DBint]->name = $params['NAME'];
66 $this->DB_pages_list[$this->DBint]->file = $params['FILE'];
67 $this->is_in_DBpage = 1;
68 }
69 }
70
71 function tag_end($parser, $attr)
72 {
73 if($attr == 'SUBPAGE' && $this->is_in_subpage == 1)
74 {
75 $this->int++;
76 $this->is_in_subpage = 0;
77 }
78 if($attr == 'MAINTAINER' && $this->is_in_maintainer == 1)
79 {
80 $this->is_in_maintainer = 0;
81 }
82 if($attr == 'DB_SUBPAGE' && $this->is_in_DBpage == 1)
83 {
84 $this->DBint++;
85 $this->is_in_DBpage = 0;
86 }
87 }
88
89 function parse()
90 {
91 $this->menu='';
92 $this->DBmenu='';
93 $parser = xml_parser_create();
94 xml_set_object ( $parser, $this );
95 xml_set_element_handler ( $parser, 'tag_start', 'tag_end' );
96
97 if(!($fp = fopen('configuration/subpages.xml', 'r')))
98 {
99 if(!($fp = fopen('../configuration/subpages.xml', 'r')))
100 {
101 die('Configuration file subpages.xml cannot be open. Person responsible was contacted');
102 }
103 }
104
105 while($data = fread($fp, 4096))
106 {
107 if(!xml_parse($parser, $data, feof($fp)))
108 {
109 die(sprintf("Configuration error : %s in line %d",
110 xml_error_string(xml_get_error_code($parser)),
111 xml_get_current_line_number($parser)));
112 }
113 }
114 xml_parser_free($parser);
115
116 }
117
118 function getMenu()
119 {
120 echo '<script> function footerMenuText(){
121 return [';
122 $i=1;
123 foreach ($this->pages_list as $el)
124 {
125 echo '{title: "'.$el->name.'", link: "'.$el->file.'", label: "'.$el->name.'"}';
126 $i+=1;
127 if ($i <= count($this->pages_list))
128 echo ',';
129
130 }
131 echo ']
132 }</script>';
133 return $this->pages_list;
134
135 }
136
137 function getDBMenu()
138 {
139 return $this->DB_pages_list;
140 }
141 }
142
143 class subpage
144 {
145 var $name;
146 var $file;
147 var $id;
148
149 function subpage($id)
150 {
151 $this -> id = $id;
152 $this -> name = '';
153 $this -> file = '';
154 }
155
156 }
157
158
159 ?>
160
161
162