[ Index ]
 

Code source de Horde 3.1.3

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/Horde/ -> Editor.php (source)

   1  <?php
   2  /**
   3   * Editor Class
   4   *
   5   * The Editor:: package provides an rte editor for the Horde
   6   * Application Framework.
   7   *
   8   * $Horde: framework/Editor/Editor.php,v 1.8.10.8 2006/01/01 21:28:14 jan Exp $
   9   *
  10   * Copyright 2003-2006 Nuno Loureiro <nuno@co.sapo.pt>
  11   *
  12   * See the enclosed file COPYING for license information (LGPL). If you
  13   * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  14   *
  15   * @author  Nuno Loureiro <nuno@co.sapo.pt>
  16   * @since   Horde 3.0
  17   * @package Horde_Editor
  18   */
  19  class Horde_Editor {
  20  
  21      /**
  22       * Constructor.
  23       */
  24      function Horde_Editor($params = array())
  25      {
  26      }
  27  
  28      /**
  29       * Attempts to return a concrete Horde_Editor instance based on $driver.
  30       *
  31       * @param mixed $driver  The type of concrete Horde_Editor subclass to
  32       *                       return. If $driver is an array, then we will look
  33       *                       in $driver[0]/lib/Driver/ for the subclass
  34       *                       implementation named $driver[1].php.
  35       * @param array $params  A hash containing any additional configuration or
  36       *                       connection parameters a subclass might need.
  37       *
  38       * @return Horde_Editor  The newly created concrete Horde_Editor instance,
  39       *                       or false on error.
  40       */
  41      function &factory($driver, $params = null)
  42      {
  43          if (is_array($driver)) {
  44              $app = $driver[0];
  45              $driver = $driver[1];
  46          }
  47  
  48          $driver = basename($driver);
  49          if (empty($driver) || $driver == 'none') {
  50              $editor = &new Horde_Editor($params);
  51              return $editor;
  52          }
  53  
  54          if (is_null($params) && class_exists('Horde')) {
  55              $params = Horde::getDriverConfig('editor', $driver);
  56          }
  57  
  58          if (!empty($app)) {
  59              global $registry;
  60              require_once $registry->get('fileroot', $app) . '/lib/Editor/' . $driver . '.php';
  61          } elseif (@file_exists(dirname(__FILE__) . '/Editor/' . $driver . '.php')) {
  62              require_once dirname(__FILE__) . '/Editor/' . $driver . '.php';
  63          } else {
  64              @include_once 'Horde/Editor/' . $driver . '.php';
  65          }
  66  
  67          $class = 'Horde_Editor_' . $driver;
  68          if (class_exists($class)) {
  69              $editor = &new $class($params);
  70          } else {
  71              $editor = PEAR::raiseError('Class definition of ' . $class . ' not found.');
  72          }
  73  
  74          return $editor;
  75      }
  76  
  77      /**
  78       * Attempts to return a reference to a concrete Horde_Editor
  79       * instance based on $driver. It will only create a new instance
  80       * if no Horde_Editor instance with the same parameters currently
  81       * exists.
  82       *
  83       * This should be used if multiple cache backends (and, thus,
  84       * multiple Horde_Editor instances) are required.
  85       *
  86       * This method must be invoked as:
  87       * $var = &Horde_Editor::singleton()
  88       *
  89       * @param mixed $driver  The type of concrete Horde_Editor subclass to
  90       *                       return. If $driver is an array, then we will look
  91       *                       in $driver[0]/lib/Editor/ for the subclass
  92       *                       implementation named $driver[1].php.
  93       * @param array $params  A hash containing any additional configuration or
  94       *                       connection parameters a subclass might need.
  95       *
  96       * @since Horde 2.2
  97       *
  98       * @return Horde_Editor  The concrete Horde_Editor reference, or false on
  99       *                       error.
 100       */
 101      function &singleton($driver, $params = null)
 102      {
 103          static $instances;
 104  
 105          if (!isset($instances)) {
 106              $instances = array();
 107          }
 108  
 109          if (is_null($params) && class_exists('Horde')) {
 110              $params = Horde::getDriverConfig('cache', $driver);
 111          }
 112  
 113          $signature = serialize(array($driver, $params));
 114          if (!array_key_exists($signature, $instances)) {
 115              $instances[$signature] = &Horde_Editor::factory($driver, $params);
 116          }
 117  
 118          return $instances[$signature];
 119      }
 120  
 121  }


Généré le : Sun Feb 25 18:01:28 2007 par Balluche grâce à PHPXref 0.7