Fixed translation for extensions menu options.
[fa-stable.git] / applications / application.php
1 <?php
2 /**********************************************************************
3     Copyright (C) FrontAccounting, LLC.
4         Released under the terms of the GNU General Public License, GPL, 
5         as published by the Free Software Foundation, either version 3 
6         of the License, or (at your option) any later version.
7     This program is distributed in the hope that it will be useful,
8     but WITHOUT ANY WARRANTY; without even the implied warranty of
9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
10     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12         class menu_item 
13         {
14                 var $label;
15                 var $link;
16                 
17                 function menu_item($label, $link) 
18                 {
19                         $this->label = $label;
20                         $this->link = $link;
21                 }
22         }
23
24         class menu 
25         {
26                 var $title;
27                 var $items;
28                 
29                 function menu($title) 
30                 {
31                         $this->title = $title;
32                         $this->items = array();
33                 }
34                 
35                 function add_item($label, $link) 
36                 {
37                         $item = new menu_item($label,$link);
38                         array_push($this->items,$item);
39                         return $item;
40                 }
41                 
42         }
43
44         class app_function 
45         {
46                 var $label;
47                 var $link;
48                 var $access;
49                 
50                 function app_function($label,$link,$access='SA_OPEN') 
51                 {
52                         $this->label = $label;
53                         $this->link = $link;
54                         $this->access = $access;
55                 }
56         }
57
58         class module 
59         {
60                 var $name;
61                 var $icon;
62                 var $lappfunctions;
63                 var $rappfunctions;
64                 
65                 function module($name,$icon = null) 
66                 {
67                         $this->name = $name;
68                         $this->icon = $icon;
69                         $this->lappfunctions = array();
70                         $this->rappfunctions = array();
71                 }
72                 
73                 function add_lapp_function($label,$link="",$access='SA_OPEN') 
74                 {
75                         $appfunction = new app_function($label,$link,$access);
76                         //array_push($this->lappfunctions,$appfunction);
77                         $this->lappfunctions[] = $appfunction;
78                         return $appfunction;
79                 }
80
81                 function add_rapp_function($label,$link="",$access='SA_OPEN') 
82                 {
83                         $appfunction = new app_function($label,$link,$access);
84                         //array_push($this->rappfunctions,$appfunction);
85                         $this->rappfunctions[] = $appfunction;
86                         return $appfunction;
87                 }
88                 
89                 
90         }
91
92         class application 
93         {
94                 var $id;
95                 var $name;
96                 var $help_context;
97                 var $modules;
98                 var $enabled;
99                 
100                 function application($id, $name, $enabled=true) 
101                 {
102                         $this->id = $id;
103                         $this->name = $name;
104                         $this->enabled = $enabled;
105                         $this->modules = array();
106                 }
107                 
108                 function add_module($name, $icon = null) 
109                 {
110                         $module = new module($name,$icon);
111                         //array_push($this->modules,$module);
112                         $this->modules[] = $module;
113                         return $module;
114                 }
115                 
116                 function add_lapp_function($level, $label,$link="",$access='SA_OPEN') 
117                 {
118                         $this->modules[$level]->lappfunctions[] = new app_function($label, $link, $access);
119                 }
120                 
121                 function add_rapp_function($level, $label,$link="",$access='SA_OPEN') 
122                 {
123                         $this->modules[$level]->rappfunctions[] = new app_function($label, $link, $access);
124                 }
125                 
126                 function add_extensions()
127                 {
128                         global $installed_extensions, $path_to_root;
129
130                         foreach ($installed_extensions as $mod)
131                         {
132                                 if (@$mod['active'] && isset($mod['entries']))
133                                         foreach($mod['entries'] as $entry) {
134                                                 if ($entry['tab_id'] == $this->id) {
135                                                         $_SESSION['get_text']->add_domain($_SESSION['language']->code, 
136                                                                 $mod['path']."/lang");
137
138                                                         $this->add_rapp_function(
139                                                                 isset($entry['section']) ? $entry['section'] : 2,
140                                                                 _($entry['title']), $path_to_root.'/'.$mod['path'].'/'.$entry['url'],
141                                                                 isset($entry["access"]) ? $entry["access"] : 'SA_OPEN' );
142
143                                                         $_SESSION['get_text']->add_domain($_SESSION['language']->code, 
144                                                                 $path_to_root."/lang", $_SESSION['language']->version);
145                                                 }
146                                         }
147                         }
148                 }
149                 //
150                 // Helper returning link to report class added by extension module.
151                 //
152                 function report_class_url($class)
153                 {
154                         global $installed_extensions;
155
156                         // TODO : konwencja lub ?
157                         $classno = 7;
158 //                      if (file_exists($path_to_root.'/'.$mod['path'].'/'.$entry['url']
159 //                                      .'/'.'reporting/reports_custom.php'))
160                                 return "reporting/reports_main.php?Class=".$class;
161 //                      else
162 //                              return '';
163                 }
164         }
165
166
167 ?>