(no commit message)
[shipsimu.git] / application / selector / 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 <roland __NOSPAM__ [at] __REMOVE_ME__ mxchange [dot] org>
24  * @version    0.1
25  */
26 class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplication {
27         /**
28          * The version number of this application
29          */
30         private $appVersion = "";
31
32         /**
33          * The human-readable name for this application
34          */
35         private $appName = "";
36
37         /**
38          * The short uni*-like name of this application
39          */
40         private $shortName = "";
41
42         /**
43          * An instance of this class
44          */
45         private static $thisInstance = null;
46
47         /**
48          * Private constructor
49          *
50          * @return      void
51          */
52         private function __construct () {
53                 // Call parent constructor
54                 parent::constructor(__CLASS__);
55
56                 // Set description
57                 $this->setPartDescr("Application-Helper");
58
59                 // Create an unique ID
60                 $this->createUniqueID();
61
62                 // Tidy up a little
63                 $this->removeSystemArray();
64         }
65
66         /**
67          * Getter for an instance of this class
68          *
69          * @return      $thisInstance           An instance of this class
70          */
71         public final static function getInstance () {
72                 // Is the instance there?
73                 if (is_null(self::$thisInstance)) {
74                         self::$thisInstance = new ApplicationHelper();
75                 }
76
77                 // Return the instance
78                 return self::$thisInstance;
79         }
80
81         /**
82          * Getter for the version number
83          *
84          * @return      $appVersion     The application's version number
85          */
86         public final function getAppVersion () {
87                 return $this->appVersion;
88         }
89
90         /**
91          * Setter for the version number
92          *
93          * @param               $appVersion     The application's version number
94          * @return      void
95          */
96         public final function setAppVersion ($appVersion) {
97                 // Cast and set it
98                 $appVersion = (string) $appVersion;
99                 $this->appVersion = $appVersion;
100         }
101
102         /**
103          * Getter for human-readable name
104          *
105          * @return      $appName        The application's human-readable name
106          */
107         public final function getAppName () {
108                 return $this->appName;
109         }
110
111         /**
112          * Setter for human-readable name
113          *
114          * @param               $appName        The application's human-readable name
115          * @return      void
116          */
117         public final function setAppName ($appName) {
118                 // Cast and set it
119                 $appName = (string) $appName;
120                 $this->appName = $appName;
121         }
122
123         /**
124          * Getter for short uni*-like name
125          *
126          * @return      $shortName      The application's short uni*-like name
127          */
128         public final function getAppShortName () {
129                 return $this->shortName;
130         }
131
132         /**
133          * Setter for short uni*-like name
134          *
135          * @param               $shortName      The application's short uni*-like name
136          * @return      void
137          */
138         public final function setAppShortName ($shortName) {
139                 // Cast and set it
140                 $shortName = (string) $shortName;
141                 $this->shortName = $shortName;
142         }
143
144         /**
145          * Launcher for the application selector
146          *
147          * @return      void
148          * @see         ApplicationSelector
149          */
150         public final function entryPoint () {
151                 // Get a prepared instance of ApplicationSelector
152                 $selInstance = ApplicationSelector::createApplicationSelector(LanguageSystem::getInstance(), FileIOHandler::getInstance());
153
154                 // Remove the ignore list from the object
155                 $selInstance->removeDirIgnoreList();
156
157                 // Next load all templates for the respective short app names
158                 $selInstance->loadApplicationTemplates();
159
160                 // Then load the selector's own template
161                 $selInstance->loadSelectorTemplate();
162
163                 // Insert all application templates
164                 $selInstance->insertApplicationTemplates();
165         }
166 }
167
168 // [EOF]
169 ?>