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

Source for file gltools.php

Documentation is available at gltools.php

  1. <?php
  2. /**
  3.   * GloryLands Tools and helpers
  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 Optimizer
  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.   * Global Tools Wrapper
  36.   *
  37.   * This static class acts as a wrapper of the commonly used
  38.   * tool functions.
  39.   *
  40.   * @subpackage Optimizer
  41.   * @version 1.0
  42.   */
  43.  
  44. class GLTools {
  45.  
  46.     public static function serialize_xml($simplexml{
  47.         $value trim((string)$simplexml);
  48.         $name $simplexml->getName();
  49.         $attrib array();
  50.         foreach ($simplexml->attributes(as $n => $v{
  51.             $attrib[$n= (string)$v;
  52.         }
  53.         
  54.         // Render each one of our children. Each child is an array.
  55.         // That's the difference with the attributes, where each attribute is 
  56.         // a static variable
  57.         $vars array();
  58.         foreach ($simplexml->children(as $name => $c{
  59.             if (!isset($vars[$name])) $vars[$namearray();
  60.             $vars[$name][self::serialize_xml($c);
  61.         }
  62.         
  63.         // If vars are still empty, check for value-only node
  64.         if (sizeof($vars== 0{
  65.             if ($value != ''{
  66.                 return $value;
  67.             }
  68.         }
  69.         
  70.         // Append my atrib
  71.         $vars array_merge($attrib$vars);
  72.         
  73.         // Return this stack
  74.         return $vars;
  75.     }
  76.  
  77. }
  78.  
  79. ?>

Documentation generated on Tue, 13 Oct 2009 23:49:11 +0300 by phpDocumentor 1.4.1