Location: PHPKode > projects > Movim > movim-0.5/system/Datajar/loader.php
<?php
/**
 * @file loader.php
 *
 * @brief Loads up classes and stuff for Datajar.
 *
 * Copyright © 2012 Guillaume Pasquet
 *
 * This file is part of Datajar.
 *
 * Datajar is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of
 * the License, or (at your option) any later version.
 *
 * Datajar is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Datajar.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * Tests each driver for the presence of its backend.
 * @returns false if no backend was found.
 */
function datajar_test_backends()
{
    $base = dirname(__FILE__).'/';
    if($drivers_dir = opendir($base.'drivers')) {
        $backend_ok = false;
        while($driver = readdir($drivers_dir)) {
            if(preg_match('/^DatajarEngine.+\.php$/', $driver)) {
                $drivername = substr($driver, 0, strlen($driver) - 4);
                require_once($base.'drivers/'.$driver);
                $backend_ok = ($backend_ok || call_user_class(array($drivername, 'test_backend')));
            }
        }

        return $backend_ok;
    } else {
        return false;
    }
}

//* Function to easily load a Datajar Engine.
function datajar_load_driver($drivername)
{
    $base = dirname(__FILE__).'/';
    require_once($base."drivers/DatajarEngine".ucfirst(strtolower($drivername)).".php");
}

function load_datajar(array $drivers)
{
    $base = dirname(__FILE__).'/';

    require($base.'DatajarBase.php');
    require($base.'DatajarSQL.php');
    require($base.'DatajarCollection.php');
    require($base.'DatajarEngineBase.php');
    require($base.'DatajarEngineWrapper.php');
    require($base.'DatajarException.php');
    require($base.'DatajarSchema.php');
    require($base.'DatajarTypeBase.php');
    require($base.'DatajarType.php');
    require($base.'DatajarQuery.php');

    // Now loading the drivers.
    foreach($drivers as $driver) {
        $driver_init = $base.'drivers/'.$driver.'/init.php';
        if(file_exists($driver_init)) {
            require($driver_init);
        }
    }
}

?>
Return current item: Movim