steffen: server/kolab-horde-framework/kolab-horde-framework/Search Search.php, NONE, 1.1 package.xml, NONE, 1.1

cvs at intevation.de cvs at intevation.de
Fri Oct 14 16:33:13 CEST 2005


Author: steffen

Update of /kolabrepository/server/kolab-horde-framework/kolab-horde-framework/Search
In directory doto:/tmp/cvs-serv28903/kolab-horde-framework/kolab-horde-framework/Search

Added Files:
	Search.php package.xml 
Log Message:
Separated Horde Framework from kolab-resource-handlers

--- NEW FILE: Search.php ---
<?php
/**
 * The Horde_Search:: class provides an abstracted interface into
 * various searching APIs.
 *
 * $Horde: framework/Search/Search.php,v 1.4 2004/01/25 19:07:01 chuck Exp $
 *
 * Copyright 2003-2004 Chuck Hagenbuch <chuck at horde.org>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  Chuck Hagenbuch <chuck at horde.org>
 * @version $Revision: 1.1 $
 * @since   Horde 3.0
 * @package Horde_Search
 */
class Horde_Search {

    /**
     * Attempts to return a concrete Horde_Search instance based on
     * $driver.
     *
     * @access public
     *
     * @param mixed $driver           The type of concrete Horde_Search subclass to
     *                                return. This is based on the storage
     *                                driver ($driver). The code is
     *                                dynamically included. If $driver is an
     *                                array, then we will look in
     *                                $driver[0]/lib/Search/ for the subclass
     *                                implementation named $driver[1].php.
     * @param optional array $params  A hash containing any additional
     *                                configuration or connection parameters a
     *                                subclass might need.
     *
     * @return object Horde_Search  The newly created concrete Horde_Search instance,
     *                              or false on error.
     */
    function &factory($driver, $params = null)
    {
        if (is_array($driver)) {
            $app = $driver[0];
            $driver = $driver[1];
        }

        if (is_null($params) && class_exists('Horde')) {
            $params = Horde::getDriverConfig('search', $driver);
        }

        if (!empty($app)) {
            global $registry;
            require_once $registry->getParam('fileroot', $app) . '/lib/Search/' . $driver . '.php';
        } elseif (file_exists(dirname(__FILE__) . '/Search/' . $driver . '.php')) {
            require_once dirname(__FILE__) . '/Search/' . $driver . '.php';
        } else {
            @include_once 'Horde/Search/' . $driver . '.php';
        }
        $class = 'Horde_Search_' . $driver;
        if (class_exists($class)) {
            return $ret = &new $class($params);
        } else {
            return PEAR::raiseError('Class definition of ' . $class . ' not found.');
        }
    }

    /**
     * Attempts to return a reference to a concrete Horde_Search
     * instance based on $driver. It will only create a new instance
     * if no Horde_Search instance with the same parameters currently
     * exists.
     *
     * This should be used if multiple search backends (and, thus,
     * multiple Horde_Search instances) are required.
     *
     * This method must be invoked as:
     * $var = &Horde_Search::singleton()
     *
     * @access public
     *
     * @param mixed $driver           The type of concrete Horde_Search subclass to
     *                                return. This is based on the storage
     *                                driver ($driver). The code is
     *                                dynamically included. If $driver is an
     *                                array, then we will look in
     *                                $driver[0]/lib/Search/ for the subclass
     *                                implementation named $driver[1].php.
     * @param optional array $params  A hash containing any additional
     *                                configuration or connection parameters a
     *                                subclass might need.
     *
     * @since Horde 2.2
     *
     * @return object Horde_Search  The concrete Horde_Search reference,
     *                              or false on error.
     */
    function &singleton($driver, $params = null)
    {
        static $instances;

        if (!isset($instances)) {
            $instances = array();
        }

        if (is_null($params) && class_exists('Horde')) {
            $params = Horde::getDriverConfig('search', $driver);
        }

        $signature = serialize(array($driver, $params));
        if (!array_key_exists($signature, $instances)) {
            $instances[$signature] = &Horde_Search::factory($driver, $params);
        }

        return $instances[$signature];
    }

}

--- NEW FILE: package.xml ---
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- $Horde: framework/Search/package.xml,v 1.1 2004/01/25 19:21:30 chuck Exp $ -->
<!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.1">
<package version="1.0">
  <name>Horde_Search</name>
  <summary>Horde Search API</summary>
  <description>
    The Horde_Search:: API tries to provide a generic API to several remote search services.
  </description>
  <license>LGPL</license>

  <maintainers>
    <maintainer>
      <user>chuck</user>
      <role>lead</role>
      <name>Chuck Hagenbuch</name>
      <email>chuck at horde.org</email>
    </maintainer>
  </maintainers>

  <release>
    <version>0.0.1</version>
    <state>alpha</state>
    <date>2004-01-25</date>
    <notes>Initial packaging</notes>

    <filelist>
      <file baseinstalldir="/Horde" role="php" name="Search.php" />
      <dir baseinstalldir="/Horde" role="php" name="Search">
        <file name="google.php" />
      </dir>
    </filelist>

    <provides type="class" name="Horde_Search" />
    <provides type="class" name="Horde_Search_google" />

    <deps>
      <dep type="pkg" rel="has">Horde_Framework</dep>
    </deps>
  </release>

  <changelog>
    <release>
      <version>0.0.1</version>
      <state>alpha</state>
      <date>2004-01-25</date>
      <notes>Initial release as a PEAR package</notes>
    </release>
  </changelog>
</package>





More information about the commits mailing list