]> git.mxchange.org Git - hub.git/blob - application/hub/class_ApplicationHelper.php
Code syncronized with shipsimu code base
[hub.git] / application / hub / class_ApplicationHelper.php
1 <?php
2 /**
3  * A class holding general data about the application and some methods for
4  * the management including the entry point.
5  *
6  * E.g.:
7  *
8  * index.php?app=my_app
9  *
10  * You need to create a folder in the folder "application" named "my_app"
11  * (without the quotes) and create a include file called
12  * class_ApplicationHelper.php. You have to write the same class for your
13  * application and implement the same interface called ManageableApplication
14  * because this class include file will be searched for.
15  *
16  * It is good when you avoid more GET parameters to keep URLs short and sweet.
17  * But sometimes you need some GET paramerers e.g. for your imprint or info page
18  * or other linked pages which you have to create and state some informations.
19  *
20  * Please remember that this include file is being loaded *before* the class
21  * loader is loading classes from "exceptions", "interfaces" and "main"!
22  *
23  * @author              Roland Haeder <webmaster@ship-simu.org>
24  * @version             0.0
25  * @copyright   Copyright(c) 2007, 2008 Roland Haeder, this is free software
26  * @license             GNU GPL 3.0 or any newer version
27  *
28  * This program is free software: you can redistribute it and/or modify
29  * it under the terms of the GNU General Public License as published by
30  * the Free Software Foundation, either version 3 of the License, or
31  * (at your option) any later version.
32  *
33  * This program is distributed in the hope that it will be useful,
34  * but WITHOUT ANY WARRANTY; without even the implied warranty of
35  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
36  * GNU General Public License for more details.
37  *
38  * You should have received a copy of the GNU General Public License
39  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
40  */
41 class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplication {
42         /**
43          * The version number of this application
44          */
45         private $appVersion = "";
46
47         /**
48          * The human-readable name for this application
49          */
50         private $appName = "";
51
52         /**
53          * The short uni*-like name for this application
54          */
55         private $shortName = "";
56
57         /**
58          * An instance of this class
59          */
60         private static $thisInstance = null;
61
62         /**
63          * Private constructor
64          *
65          * @return      void
66          */
67         protected function __construct () {
68                 // Call parent constructor
69                 parent::__construct(__CLASS__);
70
71                 // Tidy up a little
72                 $this->removeSystemArray();
73                 $this->removeNumberFormaters();
74         }
75
76         /**
77          * Getter for an instance of this class
78          *
79          * @return      $thisInstance           An instance of this class
80          */
81         public final static function getInstance () {
82                 // Is the instance there?
83                 if (is_null(self::$thisInstance)) {
84                         self::$thisInstance = new ApplicationHelper();
85                 }
86
87                 // Return the instance
88                 return self::$thisInstance;
89         }
90
91         /**
92          * Getter for the version number
93          *
94          * @return      $appVersion     The application's version number
95          */
96         public final function getAppVersion () {
97                 return $this->appVersion;
98         }
99         /**
100          * Setter for the version number
101          *
102          * @param               $appVersion     The application's version number
103          * @return      void
104          */
105         public final function setAppVersion ($appVersion) {
106                 // Cast and set it
107                 $appVersion = (string) $appVersion;
108                 $this->appVersion = $appVersion;
109         }
110
111         /**
112          * Getter for human-readable name
113          *
114          * @return      $appName        The application's human-readable name
115          */
116         public final function getAppName () {
117                 return $this->appName;
118         }
119
120         /**
121          * Setter for human-readable name
122          *
123          * @param               $appName        The application's human-readable name
124          * @return      void
125          */
126         public final function setAppName ($appName) {
127                 // Cast and set it
128                 $appName = (string) $appName;
129                 $this->appName = $appName;
130         }
131
132         /**
133          * Getter for short uni*-like name
134          *
135          * @return      $shortName      The application's short uni*-like name
136          */
137         public final function getAppShortName () {
138                 return $this->shortName;
139         }
140
141         /**
142          * Setter for short uni*-like name
143          *
144          * @param               $shortName      The application's short uni*-like name
145          * @return      void
146          */
147         public final function setAppShortName ($shortName) {
148                 // Cast and set it
149                 $shortName = (string) $shortName;
150                 $this->shortName = $shortName;
151         }
152
153         /**
154          * Launches the hub system
155          *
156          * @return      void
157          */
158         public final function entryPoint () {
159                 // Get a core loop instance
160                 $hubInstance = HubCoreLoop::createHubCoreLoop();
161
162                 // Output some text
163                 $hubInstance->outputIntro();
164
165                 // Contact the master hub
166                 $hubInstance->contactMasterHub();
167
168                 // The main loop begins here
169                 $hubInstance->coreLoop();
170
171                 // Shutdown the hub
172                 $hubInstance->shutdownHub();
173         }
174
175         /**
176          * Getter for master template name
177          *
178          * @return      $masterTemplate         Name of the master template
179          */
180         public final function getMasterTemplate () {
181                 return "hub_main";
182         }
183
184         /**
185          * Handle the indexed array of fatal messages and puts them out in an
186          * acceptable fasion
187          *
188          * @param       $messageList    An array of fatal messages
189          * @return      void
190          */
191         public function handleFatalMessages (array $messageList) {
192                 // Walk through all messages
193                 foreach ($messageList as $message) {
194                         die("MSG:".$message);
195                 }
196         }
197 }
198
199 // [EOF]
200 ?>