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

Source for file api.php

Documentation is available at api.php

  1. <?php
  2. /**
  3.   * API streamline
  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.   *
  36.   * @subpackage System
  37.   * @version 1.0
  38.   */
  39. class srm_api extends GLStream {
  40.  
  41.     /**
  42.       * Check if this stream is valid for handling this action
  43.       *
  44.       */
  45.     public function is_valid({
  46.         if (isset($this->headers['X-GLOO-API'])) return true;
  47.         if (isset($this->parameters['m'])) {
  48.             if ($this->parameters['m'== 'api'return true;    
  49.         }
  50.         if (isset($this->variables['m'])) {
  51.             if ($this->variables['m'== 'api'return true;    
  52.         }
  53.         return false;
  54.     }
  55.     
  56.     public function initialize({
  57.         // Initialize stream
  58.         GL::$stream new GLDataset();
  59.     
  60.         // Initialize stream variables
  61.         GL::$stream->headers array(
  62.             'js' => array(),
  63.             'css' => array(),
  64.             'meta' => array(),
  65.         );
  66.         GL::$stream->inline array(
  67.             'js' => array(),
  68.             'css' => array()
  69.         );        
  70.         GL::$stream->title 'GLOO Test';    
  71.     }
  72.     
  73.     public function post_initialize({
  74.         GLOOLink::initialize(false);    
  75.     }
  76.     
  77.     public function process({
  78.         if (isset($this->variables['id'])) {
  79.             if ($this->variables['id'>= 0{
  80.                 $obj GLOOLink::get_object($this->variables['id']);
  81.                 if (method_exists($obj$this->variables['f'])) {
  82.                     call_user_func_array(array($obj$this->variables['f'])$this->variables['d']);
  83.                 else {
  84.                     GLError::trigger('There is no function '.$this->variables['f'].' for the object '.get_class($obj));
  85.                 }
  86.             }
  87.         }
  88.         
  89.         //**** REMOVE THEESE :        
  90.         
  91.         $ui GLOOLink::get_object(0);
  92.     
  93.         $panel1 GLOOLink::get_object_by_id('player_panel_1');
  94.         $panels GLOOLink::get_objects_by_name('GLUIPanel');
  95.         $panel2 $panels[1];
  96.         
  97.         $panel2->front();
  98.         $panel2->text '<b>Request:</b> '.($_SESSION['req']++);
  99.         $panel2->moveto($panel1->left+200$panel1->top+20);
  100.         $panel2->animate(array(
  101.             'left' => $panel1->left+500,
  102.             'top' => $panel1->top+20,
  103.             'width' => 250+sin($_SESSION['req'pi(18)*100,
  104.             'height' => 200+sin($_SESSION['req'pi(18)*100
  105.         ));
  106.         //$panel2->nudge();
  107.         
  108.     }
  109.     
  110.     public function render({
  111.         // Create the GLOOLink message data
  112.         $buffer json_encode(array(
  113.             'msg' => GLOOLink::peek_messages()
  114.         ));
  115.         
  116.         // Unescape special strings
  117.         //$buffer = preg_replace('/[\'"]#(.+?)#[\'"]/', '\\1', $buffer);
  118.         
  119.         // Return buffer
  120.         return $buffer;
  121.         
  122.     }
  123.     
  124. }
  125.  
  126. ?>

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