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

Source for file xmlconfig.php

Documentation is available at xmlconfig.php

  1. <?php
  2. /**
  3.   * GloryLands Compatibility Optimizer
  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.   * XML Configuration file optimizer
  36.   *
  37.   * This optimizer provides faster access to XML configs, by
  38.   * caching the XML file into a PHP-Array-Encoded format.
  39.   *
  40.   * This greatly minimizes the parsing time.
  41.   *
  42.   * @subpackage Optimizer
  43.   * @version 1.0
  44.   */
  45.  
  46. class opt_xmlconfig extends GLOptimizerModule {
  47.  
  48.     public function is_valid($categories$string{
  49.         if (in_array('xmlconfig',$categories)) return true;
  50.         return false;
  51.     }
  52.     
  53.     public function optimize_file($file$options{        
  54.         $name md5(dirname($file)).'.'.urlencode(basename($file));
  55.         $cache $this->allocate_cache('xmlconfig'$name);
  56.         if ($this->should_update($cachefilemtime($file))) {            
  57.             $xml simplexml_load_file($file);
  58.             $config GLTools::serialize_xml($xml);
  59.             $buffer '<?'.'php // XML Config cache, parsed from '.$file."\nreturn "var_export($config,true)."\n?".'>';
  60.             file_put_contents($cache$buffer);
  61.         }
  62.         return new GLDynamicPath($cache);
  63.     }
  64.  
  65. }
  66.  
  67. ?>

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