Skip to content

Commit

Permalink
Added autoloader for LS library and base exception class.
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@10940 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Tim Klingenberg committed Sep 3, 2011
1 parent 9eb5779 commit d08d060
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
23 changes: 23 additions & 0 deletions application/libraries/LS/Exception.php
@@ -0,0 +1,23 @@
<?php
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id$
*/

/**
* LS Base Exception Class
*
* @author mot
*/
class LS_Exception extends Exception
{
}
39 changes: 39 additions & 0 deletions application/libraries/LS/LS.php
@@ -0,0 +1,39 @@
<?php
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id$
*
* LS Library bootstrap file, work in progress.
*
* Currently requires require_once to use the library.
*/

/**
* LS Library autoloader
*
* @param string $class
*/
function LS_autoload($class)
{
$namespace = 'LS';
$separator = '_';
if (0 !== strpos($class, $namespace.$separator))
return;

$translated = str_replace($separator, DIRECTORY_SEPARATOR, $class);
$libpath = dirname(dirname(__FILE__));
$file = $libpath.DIRECTORY_SEPARATOR.$translated.'.php';

require $file; # provoke fatal error if file does not exists.
}

spl_autoload_register('LS_autoload');

0 comments on commit d08d060

Please sign in to comment.