phpDocumentor GloryLands
System
[ class tree: GloryLands ] [ index: GloryLands ] [ all elements ]

Source for file glassemblyline.php

Documentation is available at glassemblyline.php

  1. <?php
  2. /**
  3.   * GloryLands Assembly Line
  4.   *
  5.   * <pre>
  6.   * GloryLands, a Web-Based, Massive Multiplayer Online RPG/Strategy Game
  7.   * Copyright (C) 2008-09  John Haralampidis <jïhnys2[at]gmail.cïm>
  8.   *
  9.   * This program is free software: you can redistribute it and/or modify
  10.   * it under the terms of the GNU General Public License as published by
  11.   * the Free Software Foundation, either version 3 of the License, or
  12.   * (at your option) any later version.
  13.   *
  14.   * This program is distributed in the hope that it will be useful,
  15.   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.   * GNU General Public License for more details.
  18.   *
  19.   * You should have received a copy of the GNU General Public License
  20.   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  21.   *
  22.   * For any help/suggestions or troubleshooting you can see the
  23.   * project community website at <http://www.glorylands.gr>
  24.   * </pre>
  25.   *
  26.   * @license GNU/GPLv3 GNU General Public License version 3
  27.   * @package GloryLands
  28.   * @subpackage System
  29.   * @author John Haralampidis <jïhnys2[at]gmail.cïm>
  30.   * @copyright Copyright (C) 2007-2009, John Haralampidis
  31.   * @version 1.0
  32.   */
  33.  
  34. /**
  35.   * GLREQ_ROOT Flag
  36.   * This flag means that the request is root-type.
  37.   * Root-type request means that the PHP-JS objects will be rebuilt
  38.   * and the content will be resynced.
  39.   *
  40.   * The reply is an HTML document with the desired layout that
  41.   * contans the syncronization script.
  42.   */ 
  43. define(GLREQ_ROOT1);
  44.  
  45. /**
  46.   * GLREQ_EXT Flag
  47.   * This flag means that the request is external.
  48.   * An external request is performed when the browser wants to run a module action
  49.   * that does not require a DOM structure.
  50.   *
  51.   * The reply is an HTML document with the desired layout that
  52.   * contans the response data of the executed script.
  53.   */ 
  54. define(GLREQ_EXT2);
  55.  
  56. /**
  57.   * GLREQ_API Flag
  58.   * This flag means that the request is made from GLOO JS API.
  59.   * Theese requests, that are performed by the GL.call() function, do not
  60.   * destroy the PHP-side of the DOM. This means that all the classes that
  61.   * were instanced (and utilized the JS that made this request) are still availab.e
  62.   *
  63.   * The reply format depends on the X-GLOO-API value, and it varies between
  64.   * a JSON-Encoded variable dump, an XML document, a url-encoded request or
  65.   * an other form, defined and handled by interrupts.
  66.   *
  67.   * However, each data reply contains:
  68.   * - The elementary stream that contains the response to the call
  69.   * - The secondary stram that holds all the queued requests/updates to the interface.
  70.   */ 
  71. define(GLREQ_API3);
  72.  
  73. /**
  74.   * GloryLands Assembly Line
  75.   *
  76.   *
  77.   *
  78.   */
  79. class GLAssemblyLine {
  80.         
  81.     /**
  82.       * The active stream that handles the request
  83.       * @var GLStream 
  84.       */
  85.     static private $stream;
  86.  
  87.     /**
  88.       * The request format
  89.       * @var array 
  90.       */
  91.     static private $streams;
  92.  
  93.     /**
  94.       * The request headers
  95.       * @var array 
  96.       */
  97.     static public $headers;
  98.  
  99.     /**
  100.       * A Server-independant function to get the request headers
  101.       *
  102.       * @return array    The headers in key-name - value format
  103.       */
  104.     static private function get_headers({
  105.         $headers array();
  106.         foreach ($_SERVER as $k => $v{
  107.         if (substr($k05== "HTTP_"{
  108.             $k str_replace('_'' 'substr($k5));
  109.             $k str_replace(' ''-'ucwords(strtolower($k)));
  110.             $headers[$k$v;
  111.             }
  112.         }
  113.         return $headers;    
  114.     }
  115.     
  116.     static private function get_processing_stream({
  117.         foreach (self::$streams as $stream{
  118.             if ($stream->is_valid()) {
  119.                 return $stream;
  120.             }
  121.         }
  122.         return false;
  123.     }    
  124.     
  125.     /**
  126.       * Initialize the assembly line
  127.       */
  128.     static public function initialize({
  129.     
  130.         // Fetch headers
  131.         self::$headers self::get_headers();
  132.         
  133.         // Initialize streams
  134.         $exts new GLDBOrderedConfig('extensions_streams');
  135.         while ($plugin $exts->next()) {
  136.             include_once(GLConfig::$root->file($plugin->file));
  137.             $stream $plugin->class;
  138.             $s new $stream(self::$headers$_GET,$_POST);
  139.             $s->pre_initialize();
  140.             self::$streams[$s;
  141.         }        
  142.  
  143.         // Fetch and initialize active stream
  144.         self::$stream self::get_processing_stream();
  145.         self::$stream->initialize();
  146.     }
  147.     
  148.     static public function post_initialize({
  149.         self::$stream->post_initialize();
  150.     }
  151.  
  152.     static public function process({
  153.         self::$stream->process();
  154.     }
  155.  
  156.     static public function render({
  157.         return self::$stream->render();
  158.     }
  159.  
  160.     static public function finalize({
  161.         self::$stream->finalize();
  162.     }
  163.     
  164. }
  165.  
  166. ?>

Documentation generated on Tue, 13 Oct 2009 23:48:57 +0300 by phpDocumentor 1.4.1