Source for file AApplication.php

Documentation is available at AApplication.php

  1. <?php
  2. /**
  3.  * Contains the AApplication class
  4.  * @author Jordan CM Wambaugh <jordan.wambaugh@forrent.com>
  5.  * @package Alia
  6.  * @subpackage Core
  7.  */
  8.  
  9.  
  10. /**
  11.  * AApplication
  12.  * 
  13.  * Provides application-level services for alia applications
  14.  * @package Alia
  15.  * @subpackage Core
  16.  * @version $id$
  17.  * @author Jordan CM Wambaugh <jordan.wambaugh@forrent.com>
  18.  * @license
  19.  */
  20. {
  21.     /**
  22.      * @var string 
  23.      */
  24.     private $frontURL="/front.php";
  25.  
  26.     /**
  27.      * 
  28.      *
  29.      * @var AWidget 
  30.      */
  31.     private $mainWidget;
  32.  
  33.  
  34.     static private $instanceObject=null;
  35.  
  36.  
  37.     /**
  38.      * constructs the Alia object
  39.      *
  40.      */
  41.     private function __construct(){
  42.     
  43.  
  44.     }
  45.  
  46.     /**
  47.      * returns the instance of the AAplication object
  48.      *
  49.      * @return AApplication 
  50.      */
  51.     public function instance(){
  52.         if(self::$instanceObject==null){
  53.             self::$instanceObject new AApplication();
  54.         }
  55.         return self::$instanceObject;
  56.     }
  57.  
  58.     /**
  59.      * returns the HTML necisarry for Alia's AJAX support
  60.      * @returnstring the generated HTML
  61.      */
  62.     public function getHeaders(){
  63.         //echo count (AConnectionRegistry::instance()->getConnections());
  64.         
  65.         
  66.         return "<script src = '{$this->frontURL}?jscript[]=jquery-1.2.3.min.js&jscript[]=Alia.js&jscript[]=validator.js'></script>
  67. ";
  68.     }
  69.     
  70.     private function output($string){
  71.         $script = AJScriptBuffer::instance()->getJScript();        
  72.         $buffer"<head>";
  73.         $buffer.=$this->getHeaders();
  74.         $buffer.="</head>
  75. <body>$string
  76. <script>
  77. var AliaFrontURL = '$this->frontURL';
  78. $script
  79. </script>
  80. </body>";
  81.  
  82.         return $buffer;
  83.     }
  84.  
  85.     /**
  86.      * runs the application
  87.      */
  88.     public function run(){
  89.         echo $this->output($this->mainWidget->render());
  90.     }
  91.     
  92.     
  93.     /**
  94.      * Sets the main application widget.
  95.      * @param AWidget the main widget for the application
  96.      */
  97.     public function setMainWidget(AWidget $widget){
  98.         $this->mainWidget=$widget;
  99.     }
  100.  
  101.     /**
  102.      * Sets the url to alia's front controller
  103.      */
  104.     public function setFrontURL($url){
  105.         $this->frontURL $url;
  106.     }
  107.  
  108.     /**
  109.      * returns the URL to the front controller
  110.      */
  111.     public function getFrontURL(){
  112.         return $this->frontURL;
  113.     }
  114.  
  115.     public function getMainWidget(){
  116.     return $this->mainWidget;    
  117.     }
  118.  
  119. } // end of AApplication

Documentation generated on Fri, 11 Jul 2008 13:28:38 -0400 by phpDocumentor 1.4.2