Files
luos/workflow/engine/classes/class.triggerLibrary.php

170 lines
4.3 KiB
PHP
Raw Normal View History

2010-12-02 23:34:41 +00:00
<?php
/**
2012-10-09 13:26:07 -04:00
*
2010-12-02 23:34:41 +00:00
* @author Hugo Loza <hugo@colosa.com>
*
2012-10-09 13:26:07 -04:00
* This class Helps registering and implementing Wizard for Triggers
2010-12-02 23:34:41 +00:00
*/
2012-10-09 13:26:07 -04:00
/**
*
* @package workflow.engine.ProcessMaker
*/
class triggerLibrary
{
private $_aTriggerClasses_ = array ();
private static $instance = NULL;
/**
* __construct
*
* @return void
*/
function __construct ()
{
//Initialize the Library and register the Default
$this->registerFunctionsFileToLibrary( PATH_CORE . "classes" . PATH_SEP . "class.pmFunctions.php", "ProcessMaker Functions" );
//Register all registered PLugin Functions
if (class_exists( 'folderData' )) {
//$folderData = new folderData($sProUid, $proFields['PRO_TITLE'], $sAppUid, $Fields['APP_TITLE'], $sUsrUid);
$oPluginRegistry = &PMPluginRegistry::getSingleton();
$aAvailablePmFunctions = $oPluginRegistry->getPmFunctions();
$oPluginRegistry->setupPlugins(); //Get and setup enabled plugins
2012-10-09 13:26:07 -04:00
foreach ($aAvailablePmFunctions as $key => $class) {
$filePlugin = PATH_PLUGINS . $class . PATH_SEP . 'classes' . PATH_SEP . 'class.pmFunctions.php';
if (file_exists( $filePlugin ) && ! is_dir( $filePlugin )) {
$this->registerFunctionsFileToLibrary( $filePlugin, "ProcessMaker Functions" );
}
}
}
//Add External Triggers
$dir = G::ExpandPath( "classes" ) . 'triggers';
$filesArray = array ();
if (file_exists( $dir )) {
if ($handle = opendir( $dir )) {
while (false !== ($file = readdir( $handle ))) {
if ($file != "." && $file != ".." && ! is_dir( $dir . PATH_SEP . $file )) {
$this->registerFunctionsFileToLibrary( $dir . PATH_SEP . $file, "ProcessMaker External Functions" );
}
}
closedir( $handle );
}
}
2012-10-09 13:26:07 -04:00
}
2010-12-02 23:34:41 +00:00
2012-10-09 13:26:07 -04:00
/**
* &getSingleton
*
* @return self::$instance;
*/
function &getSingleton ()
{
if (self::$instance == NULL) {
self::$instance = new triggerLibrary();
}
return self::$instance;
}
/**
* serializeInstance
*
* @return serialize ( self::$instance );
*/
function serializeInstance ()
{
return serialize( self::$instance );
2010-12-02 23:34:41 +00:00
}
2012-10-09 13:26:07 -04:00
/**
* unSerializeInstance
*
* @param integer $serialized
* @return void
*/
function unSerializeInstance ($serialized)
{
if (self::$instance == NULL) {
self::$instance = new PMPluginRegistry();
}
2012-10-09 13:26:07 -04:00
$instance = unserialize( $serialized );
self::$instance = $instance;
2010-12-02 23:34:41 +00:00
}
2012-10-09 13:26:07 -04:00
/**
* registerFunctionsFileToLibrary
*
* @param string $filePath
* @param string $libraryName
* @return void
*/
function registerFunctionsFileToLibrary ($filePath, $libraryName)
{
$aLibrary = $this->getMethodsFromLibraryFile( $filePath );
$aLibrary->libraryFile = $filePath;
$aLibrary->libraryName = $libraryName;
if (isset( $aLibrary->info['className'] )) {
$this->_aTriggerClasses_[$aLibrary->info['className']] = $aLibrary;
}
}
/**
* getMethodsFromLibraryFile
*
* @param string $file
* @return object(PHPClass) $parsedLibrary
*/
function getMethodsFromLibraryFile ($file)
{
// parse class comments from file
$parsedLibrary = new PHPClass();
//$success = $parsedLibrary->parseFromFile ( PATH_CORE . "classes" . PATH_SEP . $file );
$success = $parsedLibrary->parseFromFile( $file );
return $parsedLibrary;
2010-12-02 23:34:41 +00:00
}
2012-10-09 13:26:07 -04:00
/**
* getRegisteredClasses
*
* @return array ($this->_aTriggerClasses_)
*/
function getRegisteredClasses ()
{
return ($this->_aTriggerClasses_);
2010-12-02 23:34:41 +00:00
}
2012-10-09 13:26:07 -04:00
/**
* getLibraryDefinition
*
* @param string $libraryClassName
* @return array ($this->_aTriggerClasses_[$libraryClassName])
*/
function getLibraryDefinition ($libraryClassName)
{
return ($this->_aTriggerClasses_[$libraryClassName]);
2010-12-02 23:34:41 +00:00
}
2012-10-09 13:26:07 -04:00
/**
* __destruct
*
* @return void
*/
function __destruct ()
{
//TODO - Insert your code here
}
2010-12-02 23:34:41 +00:00
}
?>