diff options
| -rwxr-xr-x | LibertySystem.php | 181 |
1 files changed, 107 insertions, 74 deletions
diff --git a/LibertySystem.php b/LibertySystem.php index ed8ee44..c2d17c2 100755 --- a/LibertySystem.php +++ b/LibertySystem.php @@ -3,7 +3,7 @@ * System class for handling the liberty package * * @package liberty -* @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertySystem.php,v 1.29 2006/07/03 19:55:09 squareing Exp $ +* @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertySystem.php,v 1.30 2006/07/11 15:09:20 squareing Exp $ * @author spider <spider@steelsun.com> */ @@ -22,10 +22,12 @@ /** * Local base defines */ +// Plugin Definitions define( 'STORAGE_PLUGIN', 'storage' ); define( 'FORMAT_PLUGIN', 'format' ); define( 'DATA_PLUGIN', 'data' ); +// Service Definitions define( 'LIBERTY_SERVICE_ACCESS_CONTROL', 'access_control' ); define( 'LIBERTY_SERVICE_CATEGORIZATION', 'categorization' ); define( 'LIBERTY_SERVICE_COMMERCE', 'commerce' ); @@ -40,9 +42,10 @@ define( 'LIBERTY_SERVICE_CONTENT_TEMPLATES', 'content_templates'); define( 'LIBERTY_TEXT_AREA', 'editliberty'); define( 'LIBERTY_UPLOAD', 'upload'); +// Set of default acceptable HTML tags define( 'DEFAULT_ACCEPTABLE_TAGS', '<a><br><b><blockquote><cite><code><div><dd><dl><dt><em><h1><h2><h3><h4><hr>' - .' <i><it><img><li><ol><p><pre><span><strong><table><tbody><div><tr><td><th><u><ul>' - .' <button><fieldset><form><label><input><option><select><textarea>' ); + .'<i><it><img><li><ol><p><pre><span><strong><table><tbody><div><tr><td><th><u><ul>' + .'<button><fieldset><form><label><input><option><select><textarea>' ); /** * Link to base class @@ -80,6 +83,7 @@ class LibertySystem extends LibertyBase { } } + // ****************************** Plugin Functions /** * Load plugins from database * @@ -136,6 +140,87 @@ class LibertySystem extends LibertyBase { } /** + * Check to see if a given plugin is activ or not + * + * @param $pPluginGuid Plugin GUID of the plugin you want to check + * @return TRUE if the plugin is active, FALSE if it's not + **/ + function isPluginActive( $pPluginGuid ) { + return( isset( $this->mPlugins[$pGuid] ) && ($this->mPlugins[$pGuid] == 'y') ); + } + + /** + * Allow data plugins to register their tag + * + * @param string $pTag Tag of plugin, e.g.: TOC + * @param string $pPluginGuid GUID of plugin, e.g.: PLUGIN_GUID_TOC + * @access public + * @return void + */ + function registerDataTag( $pTag, $pPluginGuid ) { + $this->mDataTags[strtolower($pTag)] = $pPluginGuid; + } + + /** + * Allow plugins to register themselves using this function. Data is added directly to the list of existing plugins + * + * @param $pGuid GUID of plugin + * @param $pPluginParams Set of plugin parameters (see treasury/plugins/mime.*.php for example) + * @return none + * @access public + **/ + function registerPlugin( $pGuid, $pPluginParams ) { + if( isset($this->mPlugins[$pGuid] ) ) { + $this->mPlugins[$pGuid]['verified'] = TRUE; + } else { + $this->mPlugins[$pGuid]['verified'] = FALSE; + } + $this->mPlugins[$pGuid] = array_merge( $this->mPlugins[$pGuid], $pPluginParams ); + } + + // @parameter pPluginGuids an array of all the plugin guids that are active. Any left out are *inactive*! + function setActivePlugins( $pPluginGuids ) { + if( is_array( $pPluginGuids ) ) { + $sql = "UPDATE `".BIT_DB_PREFIX.$this->mPluginsTable."` SET `is_active`='n' WHERE `is_active`!='x'"; + $this->mDb->query( $sql ); + foreach( array_keys( $this->mPlugins ) as $guid ) { + $this->mPlugins[$guid]['is_active'] = 'n'; + } + + foreach( array_keys( $pPluginGuids ) as $guid ) { + $sql = "UPDATE `".BIT_DB_PREFIX.$this->mPluginsTable."` SET `is_active`='y' WHERE `plugin_guid`=?"; + $this->mDb->query( $sql, array( $guid ) ); + $this->mPlugins[$guid]['is_active'] = 'y'; + } + // we just ran some SQL - let's flush the loadPlugins query cache + $this->loadPlugins( 0 ); + } + } + + function getPluginInfo( $pGuid ) { + $ret = NULL; + if( !empty( $pGuid ) + && !empty( $this->mPlugins[$pGuid] ) + ) { + $ret = $this->mPlugins[$pGuid]; + } + return $ret; + } + + function getPluginFunction( $pGuid, $pFunctionName ) { + $ret = NULL; + if( !empty( $pGuid ) + && !empty( $this->mPlugins[$pGuid] ) + && !empty( $this->mPlugins[$pGuid][$pFunctionName] ) + && function_exists( $this->mPlugins[$pGuid][$pFunctionName] ) + ) { + $ret = $this->mPlugins[$pGuid][$pFunctionName]; + } + return $ret; + } + + // ****************************** Content Type Functions + /** * Load all available content types into $this->mContentTypes * * @return none @@ -185,6 +270,7 @@ class LibertySystem extends LibertyBase { return $ret; } + // ****************************** Service Functions /** * Get the service details of a given package * @@ -243,79 +329,15 @@ class LibertySystem extends LibertyBase { return $ret; } + // ****************************** Miscellaneous Functions /** - * Check to see if a given plugin is activ or not - * - * @param $pPluginGuid Plugin GUID of the plugin you want to check - * @return TRUE if the plugin is active, FALSE if it's not - **/ - function isPluginActive( $pPluginGuid ) { - return( isset( $this->mPlugins[$pGuid] ) && ($this->mPlugins[$pGuid] == 'y') ); - } - - function registerDataTag( $pTag, $pPluginGuid ) { - $this->mDataTags[strtolower($pTag)] = $pPluginGuid; - } - - /** - * Allow plugins to register themselves using this function. Data is added directly to the list of existing plugins - * - * @param $pGuid GUID of plugin - * @param $pPluginParams Set of plugin parameters (see treasury/plugins/mime.*.php for example) - * @return none + * Get the URL to the icon for the mime type passed in. This should probably check for files of multiple image types instead of just jpg + * + * @param string $pMimeType Mime type of the file + * @param string $pExt Extension of the file - used to get backup mime icon * @access public - **/ - function registerPlugin( $pGuid, $pPluginParams ) { - if( isset($this->mPlugins[$pGuid] ) ) { - $this->mPlugins[$pGuid]['verified'] = TRUE; - } else { - $this->mPlugins[$pGuid]['verified'] = FALSE; - } - $this->mPlugins[$pGuid] = array_merge( $this->mPlugins[$pGuid], $pPluginParams ); - } - - // @parameter pPluginGuids an array of all the plugin guids that are active. Any left out are *inactive*! - function setActivePlugins( $pPluginGuids ) { - if( is_array( $pPluginGuids ) ) { - $sql = "UPDATE `".BIT_DB_PREFIX.$this->mPluginsTable."` SET `is_active`='n' WHERE `is_active`!='x'"; - $this->mDb->query( $sql ); - foreach( array_keys( $this->mPlugins ) as $guid ) { - $this->mPlugins[$guid]['is_active'] = 'n'; - } - - foreach( array_keys( $pPluginGuids ) as $guid ) { - $sql = "UPDATE `".BIT_DB_PREFIX.$this->mPluginsTable."` SET `is_active`='y' WHERE `plugin_guid`=?"; - $this->mDb->query( $sql, array( $guid ) ); - $this->mPlugins[$guid]['is_active'] = 'y'; - } - // we just ran some SQL - let's flush the loadPlugins query cache - $this->loadPlugins( 0 ); - } - } - - function getPluginInfo( $pGuid ) { - $ret = NULL; - if( !empty( $pGuid ) - && !empty( $this->mPlugins[$pGuid] ) - ) { - $ret = $this->mPlugins[$pGuid]; - } - return $ret; - } - - function getPluginFunction( $pGuid, $pFunctionName ) { - $ret = NULL; - if( !empty( $pGuid ) - && !empty( $this->mPlugins[$pGuid] ) - && !empty( $this->mPlugins[$pGuid][$pFunctionName] ) - && function_exists( $this->mPlugins[$pGuid][$pFunctionName] ) - ) { - $ret = $this->mPlugins[$pGuid][$pFunctionName]; - } - return $ret; - } - - // Get the URL to the icon for the mime type passed in. This should probably check for files of multiple image types instead of just jpg + * @return Full image HTML tag to mime icon + */ function getMimeThumbnailURL($pMimeType, $pExt=NULL) { $ret = NULL; $parts = split('/',$pMimeType); @@ -343,6 +365,17 @@ class LibertySystem extends LibertyBase { } } +/** + * This crazy function will parse all the data plugin stuff found within any + * parsed text section + * + * @param array $data Data to be parsed + * @param array $preparsed + * @param array $noparsed + * @param array $pParser + * @access public + * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + */ function parse_data_plugins( &$data, &$preparsed, &$noparsed, &$pParser ) { global $gLibertySystem; // Find the plugins |
