]> git.mxchange.org Git - hub.git/blob - application/hub/class_ApplicationHelper.php
466ff6d83a5e61443e033dfe6bbf52e2a0e1e727
[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                 // Set description
72                 $this->setObjectDescription("Application-Helper");
73
74                 // Create an unique ID
75                 $this->createUniqueID();
76
77                 // Tidy up a little
78                 $this->removeSystemArray();
79         }
80
81         /**
82          * Getter for an instance of this class
83          *
84          * @return      $thisInstance           An instance of this class
85          */
86         public final static function getInstance () {
87                 // Is the instance there?
88                 if (is_null(self::$thisInstance)) {
89                         self::$thisInstance = new ApplicationHelper();
90                 }
91
92                 // Return the instance
93                 return self::$thisInstance;
94         }
95
96         /**
97          * Getter for the version number
98          *
99          * @return      $appVersion     The application's version number
100          */
101         public final function getAppVersion () {
102                 return $this->appVersion;
103         }
104         /**
105          * Setter for the version number
106          *
107          * @param               $appVersion     The application's version number
108          * @return      void
109          */
110         public final function setAppVersion ($appVersion) {
111                 // Cast and set it
112                 $appVersion = (string) $appVersion;
113                 $this->appVersion = $appVersion;
114         }
115
116         /**
117          * Getter for human-readable name
118          *
119          * @return      $appName        The application's human-readable name
120          */
121         public final function getAppName () {
122                 return $this->appName;
123         }
124
125         /**
126          * Setter for human-readable name
127          *
128          * @param               $appName        The application's human-readable name
129          * @return      void
130          */
131         public final function setAppName ($appName) {
132                 // Cast and set it
133                 $appName = (string) $appName;
134                 $this->appName = $appName;
135         }
136
137         /**
138          * Getter for short uni*-like name
139          *
140          * @return      $shortName      The application's short uni*-like name
141          */
142         public final function getAppShortName () {
143                 return $this->shortName;
144         }
145
146         /**
147          * Setter for short uni*-like name
148          *
149          * @param               $shortName      The application's short uni*-like name
150          * @return      void
151          */
152         public final function setAppShortName ($shortName) {
153                 // Cast and set it
154                 $shortName = (string) $shortName;
155                 $this->shortName = $shortName;
156         }
157
158         /**
159          * Launches the hub system
160          *
161          * @return      void
162          */
163         public final function entryPoint () {
164                 // Get a core loop instance
165                 $hubInstance = HubCoreLoop::createHubCoreLoop();
166
167                 // Output some text
168                 $hubInstance->outputIntro();
169
170                 // Contact the master hub
171                 $hubInstance->contactMasterHub();
172
173                 // The main loop begins here
174                 $hubInstance->coreLoop();
175
176                 // Shutdown the hub
177                 $hubInstance->shutdownHub();
178         }
179
180         /**
181          * Getter for master template name
182          *
183          * @return      $masterTemplate         Name of the master template
184          */
185         public final function getMasterTemplate () {
186                 return "hub_main";
187         }
188
189         /**
190          * Handle the indexed array of fatal messages and puts them out in an
191          * acceptable fasion
192          *
193          * @param       $messageList    An array of fatal messages
194          * @return      void
195          */
196         public function handleFatalMessages (array $messageList) {
197                 // Walk through all messages
198                 foreach ($messageList as $message) {
199                         die("MSG:".$message);
200                 }
201         }
202 }
203
204 // [EOF]
205 ?>