00001 <?php 00042 class ApplicationHelper extends BaseApplication implements ManageableApplication, Registerable { 00046 private $appVersion = ""; 00047 00051 private $appName = ""; 00052 00056 private $shortName = ""; 00057 00061 private $masterTemplate = "admin_main"; 00062 00066 private $controllerInstance = null; 00067 00071 private static $thisInstance = null; 00072 00078 protected function __construct () { 00079 // Call parent constructor 00080 parent::__construct(__CLASS__); 00081 } 00082 00088 public final static function getInstance () { 00089 // Is the instance there? 00090 if (is_null(self::$thisInstance)) { 00091 self::$thisInstance = new ApplicationHelper(); 00092 } 00093 00094 // Return the instance 00095 return self::$thisInstance; 00096 } 00097 00103 public final function getAppVersion () { 00104 return $this->appVersion; 00105 } 00106 00113 public final function setAppVersion ($appVersion) { 00114 // Cast and set it 00115 $appVersion = (string) $appVersion; 00116 $this->appVersion = $appVersion; 00117 } 00118 00124 public final function getAppName () { 00125 return $this->appName; 00126 } 00127 00134 public final function setAppName ($appName) { 00135 // Cast and set it 00136 $appName = (string) $appName; 00137 $this->appName = $appName; 00138 } 00139 00145 public final function getAppShortName () { 00146 return $this->shortName; 00147 } 00148 00155 public final function setAppShortName ($shortName) { 00156 // Cast and set it 00157 $shortName = (string) $shortName; 00158 $this->shortName = $shortName; 00159 } 00160 00166 public final function getMasterTemplate () { 00167 return $this->masterTemplate; 00168 } 00169 00175 public final function entryPoint () { 00176 // Create a new request object 00177 $requestInstance = ObjectFactory::createObjectByName('HttpRequest'); 00178 00179 // Default response is HTTP (HTML page) and type is "Web" 00180 $response = "http"; 00181 $responseType = "web"; 00182 00183 // Do we have another response? 00184 if ($requestInstance->isRequestElementSet('request')) { 00185 // Then use it 00186 $response = strtolower($requestInstance->getRequestElement('request')); 00187 $responseType = $response; 00188 } // END - if 00189 00190 // ... and a new response object 00191 $responseInstance = ObjectFactory::createObjectByName(ucfirst($response)."Response", array($this)); 00192 00193 // Remember both in this application 00194 $this->setRequestInstance($requestInstance); 00195 $this->setResponseInstance($responseInstance); 00196 00197 // Get the parameter from the request 00198 $commandName = $requestInstance->getRequestElement('page'); 00199 00200 // If it is null then get default command 00201 if (is_null($commandName)) { 00202 $commandName = $responseInstance->getDefaultCommand(); 00203 } // END - if 00204 00205 // Get a resolver 00206 $resolverInstance = ObjectFactory::createObjectByName(ucfirst($responseType)."ControllerResolver", array($commandName, $this)); 00207 00208 // Get a controller instance as well 00209 $this->controllerInstance = $resolverInstance->resolveController(); 00210 00211 // Handle the request 00212 $this->controllerInstance->handleRequest($requestInstance, $responseInstance); 00213 } 00214 00222 public function handleFatalMessages (array $messageList) { 00223 // Walk through all messages 00224 foreach ($messageList as $message) { 00225 print("MSG:".$message."<br />\n"); 00226 } // END - if 00227 } 00228 00235 public function assignExtraTemplateData (CompileableTemplate $templateInstance) { 00236 // Assign charset 00237 $templateInstance->assignConfigVariable('header_charset'); 00238 } 00239 } 00240 00241 // [EOF] 00242 ?>
1.5.6