Source for file REPClasses.class.php

Documentation is available at REPClasses.class.php

  1. <?php
  2. /**
  3.  * Módosítva: 2010.03.06.
  4.  *
  5.  * @author Takács Ákos (Rimelek), programmer [at] rimelek [dot] hu
  6.  * @copyright Copyright (C) 2010, Takács Ákos
  7.  * @version 1.0
  8.  * @package REPagination
  9.  */
  10.  
  11. /**
  12.  * A lapozóhoz tartozó osztályok telepítését, és
  13.  * lekérdezését végző osztály.
  14.  *
  15.  * @author Takács Ákos (Rimelek), programmer [at] rimelek [dot] hu
  16.  * @copyright Copyright (C) 2010, Takács Ákos
  17.  * @package REPagination
  18.  */
  19. class REPClasses
  20. {
  21.     /**
  22.      * Ennek az osztálynak pontos útvonala
  23.      * @var string 
  24.      */
  25.     private static $PATH = __FILE__;
  26.     /**
  27.      * A telepített osztályok útvonalai.
  28.      * @var array 
  29.      */
  30.     private static $classes array();
  31.     /**
  32.      * Ha már lefutott egyszer a {@link runInstall()} metódus, akkor true.
  33.      * Egyébként false
  34.      * @var bool 
  35.      */
  36.     private static $installed false;
  37.     /**
  38.      * A telepített osztályok nevei.
  39.      * Index a kisbetűs formátum.
  40.      * @var array 
  41.      */
  42.     private static $lower array();
  43.     /**
  44.      * Ennek az osztálynak a könyvtárneve.
  45.      * @return string 
  46.      */
  47.     public static function dir()
  48.     {
  49.         return dirname(self::$PATH).'/';
  50.     }
  51.     /**
  52.      * Egy osztály telepítése a lapozóba.
  53.      * @param string $class {@link import()}-ban használható név
  54.      * @param string $path Az telepítendő osztály útvonala ennek az osztálynak
  55.      *                 az könyvtárszintjétől számítva.
  56.      */
  57.     public static function install($class,$path)
  58.     {
  59.         $lower strtolower($class);
  60.         if (isset(self::$lower[$lower]))
  61.         {
  62.             throw new Exception("Osztálynév ütközés");
  63.         }
  64.         $classpath self::dir().ltrim($path,'/');
  65.         if (!file_exists($classpath))
  66.         {
  67.             throw new Exception("Nincs ilyen osztály. ($class$classpath) Nem telepíthető");
  68.         }
  69.         self::$classes[$class$path;
  70.         self::$lower[$lower$class;
  71.     }
  72.  
  73.     /**
  74.      * Egy osztály importálása.
  75.      * @param string $class Importálandó osztály telepített neve.
  76.      */
  77.     public static function import($class)
  78.     {
  79.         $lower strtolower($class);
  80.         if (!isset(self::$lower[$lower]))
  81.         {
  82.             throw new Exception("Nincs ilyen osztály. ($class) Nem importálható");
  83.         }
  84.         require_once self::dir().self::$classes[self::$lower[$lower]];
  85.     }
  86.     /**
  87.      * Az install.php -ben levő osztályok telepítésének elindítása
  88.      * @return <type> 
  89.      */
  90.     public static function runInstall()
  91.     {
  92.         if (self::$installedreturn;
  93.         require_once REPClasses::dir().'/../install.php';
  94.         self::$installed true;
  95.     }
  96.     /**
  97.      * A telepített osztályok nevei és útvonalai.
  98.      * Asszociatív tömb
  99.      * @return array 
  100.      */
  101.     public static function installedClasses()
  102.     {
  103.         return self::$classes;
  104.     }
  105. }
  106. /**
  107.  * Telepítés indítása az osztály importálásakor
  108.  */
  109. REPClasses::runInstall();
  110. ?>

Documentation generated on Sat, 06 Mar 2010 22:00:16 +0100 by phpDocumentor 1.4.1