Created
December 17, 2011 03:05
-
-
Save og-shawn-crigger/1489001 to your computer and use it in GitHub Desktop.
Loader for my Content Management system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( !defined('BASE') ) die('No Direct Script Access'); | |
/** | |
* Loader Class for VMS Content Management System | |
* | |
* @author Shawn Crigger <[email protected]> | |
* @version 1.0.5 | |
* @copyright (c) 2010 - 2012 S-Vizion Software & Eagle Web Designs | |
* @package VisionManagementSystems | |
* @subpackage AssetLoader | |
* @since version 3.0BE | |
* @license DBAD <http://philsturgeon.co.uk/code/dbad-license> | |
* | |
*/ | |
class Loader { | |
function __construct() | |
{ | |
} | |
/** | |
* Private function used in loader to check if file exists and is a actual file to load | |
* | |
* @param string $file Full path to file to check for existance | |
* | |
* @return boolean True or False depending on if file exists | |
*/ | |
private function _isfile ( $file ) | |
{ | |
return ( file_exists ( $file ) && is_file ( $file ) ); | |
} | |
/** | |
* Function used to load model files | |
* | |
* @param string $sCoreName Model Name | |
* @param mixed $sParams Params to Pass to Model | |
* | |
* @return object Object Loaded | |
*/ | |
public function model( $sCoreName , $sParams = NULL ) | |
{ | |
$sModelFile = $sCoreName . '_model.php'; | |
if ( is_object ( $sCoreName ) === true ) | |
return false; | |
if ( $this->_isfile ( $sModelFile ) ) | |
include_once($sModelFile); | |
else | |
return false; | |
return new $sCoreName( $sParams ); | |
} | |
/** | |
* Function used to load controller files | |
* | |
* @param string $sCoreName Controller Name | |
* @param mixed $sParams Params to Pass to Controller | |
* | |
* @return object Object Loaded | |
*/ | |
public function controller( $sCoreName, $sParams = NULL ) | |
{ | |
$sControllerFile = $sCoreName . '_controller.php'; | |
if ( is_object ( $sCoreName ) === true ) | |
return false; | |
if ( $this->_isfile ( $sControllerFile ) ) | |
include_once($sControllerFile); | |
return new $sCoreName( $sParams ); | |
} | |
/** | |
* Function used to load Library Class files | |
* | |
* @param string $sCoreName Class Name | |
* @param mixed $sParams Params to Pass to Model | |
* | |
* @return object Object Loaded | |
*/ | |
public function library ( $sCoreName, $sParams = NULL ) | |
{ | |
$sCoreFile = CLS_DIR . $sCoreName . '.class.php'; | |
if ( is_object ( $sCoreName ) === true ) | |
return false; | |
if ( $this->_isfile ( $sCoreFile )) | |
include_once($sCoreFile); | |
else | |
return false; | |
return new $sCoreName( $sParams ); | |
} | |
/** | |
* Function used to load Helper files | |
* | |
* @param string $sCoreName Helper Name | |
* @param mixed $sParams Params to Pass to Model | |
* | |
* @return object Object Loaded | |
*/ | |
public function helper ( $sCoreName, $sParams = NULL ) | |
{ | |
$sCoreFile = HLP_DIR . $sCoreName . '_helper.php'; | |
if ( is_array ( $sParams) ) | |
{ | |
extract ( $sParams ); | |
unset ( $sParams ); | |
} | |
if ( $this->_isfile ( $sCoreFile )) | |
require($sCoreFile); | |
else | |
return false; | |
} | |
/** | |
* Function used to load Module files | |
* | |
* @param string $sCoreName Module Name | |
* @param mixed $sParams Params to Pass to Model | |
* | |
* @return object Object Loaded | |
*/ | |
public function module ( $sCoreName, $sParams = NULL ) | |
{ | |
$sCoreFile = MDS_DIR . $sCoreName . '.inc.php'; | |
if ( $this->_isfile ( $sCoreFile )) | |
include_once($sCoreFile); | |
else | |
return false; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment