Extension menu file in ext. folder, added support for gettext in extensions.
[fa-stable.git] / frontaccounting.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         include_once('applications/application.php');
13         include_once('applications/customers.php');
14         include_once('applications/suppliers.php');
15         include_once('applications/inventory.php');
16         include_once('applications/manufacturing.php');
17         include_once('applications/dimensions.php');
18         include_once('applications/generalledger.php');
19         include_once('applications/setup.php');
20         include_once('installed_extensions.php');
21         $path_to_root=".";
22         include_once($path_to_root . "/includes/session.inc");
23
24         class front_accounting
25                 {
26                 var $user;
27                 var $settings;
28                 var $applications;
29                 var $selected_application;
30                 // GUI
31                 var $menu;
32                 //var $renderer;
33                 function front_accounting()
34                 {
35                         //$this->renderer =& new renderer();
36                 }
37                 function add_application($app)
38                                 {
39                                                         $this->applications[$app->id] = &$app;
40                                 }
41                 function get_application($id)
42                                 {
43                                  if (isset($this->applications[$id]))
44                                         return $this->applications[$id];
45                                  return null;
46                                 }
47                 function get_selected_application()
48                 {
49                         if (isset($this->selected_application))
50                                  return $this->applications[$this->selected_application];
51                         foreach ($this->applications as $application)
52                                 return $application;
53                         return null;
54                 }
55                 function display()
56                 {
57                         global $path_to_root;
58                         include($path_to_root . "/themes/".user_theme()."/renderer.php");
59                         $this->init();
60                         $rend = new renderer();
61                         $rend->wa_header();
62                         //$rend->menu_header($this->menu);
63                         $rend->display_applications($this);
64                         //$rend->menu_footer($this->menu);
65                         $rend->wa_footer();
66                 }
67                 function init()
68                 {
69                         global $installed_extensions, $applications, $path_to_root;
70                         $this->menu = new menu(_("Main  Menu"));
71                         $this->menu->add_item(_("Main  Menu"), "index.php");
72                         $this->menu->add_item(_("Logout"), "/account/access/logout.php");
73                         $this->applications = array();
74                         $this->add_application(new customers_app());
75                         $this->add_application(new suppliers_app());
76                         $this->add_application(new inventory_app());
77                         $this->add_application(new manufacturing_app());
78                         $this->add_application(new dimensions_app());
79                         $this->add_application(new general_ledger_app());
80                         if (count($installed_extensions) > 0)
81                         {
82                                 foreach ($installed_extensions as $ext)
83                                 {
84                                         get_text::add_domain($_SESSION['language']->code, 
85                                                 $ext['folder']."/lang");
86                                         include_once($ext['folder']."/".$ext['app_file']);
87                                         $class = $ext['name']."_app";
88                                         $this->add_application(new $class());
89                                         get_text::add_domain($_SESSION['language']->code, 
90                                                 $path_to_root."/lang");
91                                 }
92                         }       
93                         
94                         $this->add_application(new setup_app());
95                         }
96 }
97 ?>