summaryrefslogtreecommitdiff
path: root/NexusSystem.php
blob: 2e614fed8f005a4c7d28ff74ecf5a20701c20818 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
/**
 * @version      $Header: /cvsroot/bitweaver/_bit_nexus/NexusSystem.php,v 1.8 2006/10/13 12:46:07 lsces Exp $
 *
 * @author       xing  <xing@synapse.plus.com>
 * @version      $Revision: 1.8 $
 * created      Monday Jul 03, 2006   11:06:47 CEST
 * @package      nexus
 * @copyright    2003-2006 bitweaver
 * @license      LGPL {@link http://www.gnu.org/licenses/lgpl.html}
 **/

/**
 * Setup
 */
require_once( LIBERTY_PKG_PATH.'LibertySystem.php' );
define( 'NEXUS_DEFAULT_MENU', 'suckerfish' );

/**
 *   NexusSystem 
 * 
 * @package nexus
 * @uses LibertySystem
 */
class NexusSystem extends LibertySystem {
	// Contains plugin information
	var $mPlugins;

	/**
	 * Initiate class
	 * 
	 * @access public
	 * @return void
	 */
	function NexusSystem() {
		// Set the package using LibertySystem
		$this->mSystem = NEXUS_PKG_NAME;

		LibertySystem::LibertySystem( FALSE );
	}
}
?>
<?php
#/**
#* Nexus system class for handling the menu plugins
#*
#* @abstract
#* @author   xing <xing@synapse.plus.com>
#* copied   copied from LibertySystem.php
#* @version  $Revision: 1.8 $
#* @package  nexus
#*/
#
#// for menus that use regular HTML as output
#/**
#* definitions
#*/
#define( 'NEXUS_HTML_PLUGIN', 'nexushtml' );
#define( 'NEXUS_DEFAULT_GUID', 'suckerfish' );
#
#/**
#* required setup
#*/
#require_once( KERNEL_PKG_PATH.'BitBase.php' );
#
#/**
#* @package  nexus
#* @subpackage  NexusSystem
#*/
#class NexusSystem extends BitBase {
#
#	var $mPlugins;
#
#	function NexusSystem() {
#		BitBase::BitBase();
#		$this->loadPlugins();
#	}
#
#	function loadPlugins( $pCacheTime=BIT_QUERY_CACHE_TIME ) {
#		$rs = $this->mDb->query( "SELECT * FROM `".BIT_DB_PREFIX."nexus_plugins`", NULL, BIT_QUERY_DEFAULT, BIT_QUERY_DEFAULT );
#		while( $rs && !$rs->EOF ) {
#			$this->mPlugins[$rs->fields['plugin_guid']] = $rs->fields;
#			$rs->MoveNext();
#		}
#	}
#
#	function scanPlugins() {
#		$pluginsPath = NEXUS_PKG_PATH.'plugins/';
#		if( $pluginDir = opendir( $pluginsPath ) ) {
#			// Scan the plugins directory for plugins
#			while( FALSE !== ( $plugin = readdir( $pluginDir ) ) ) {
#				if( preg_match( '/\.php$/', $plugin ) ) {
#					include_once( $pluginsPath.$plugin );
#				}
#			}
#		}
#
#		// match up storage_type_id to plugin_guids. this _id varies from install to install, but guids are the same
#		foreach( array_keys( $this->mPlugins ) as $guid ) {
#			$handler = &$this->mPlugins[$guid]; //shorthand var alias
#			if( !isset( $handler['verified'] ) && $handler['is_active'] =='y' ) {
#				// We are missing a plugin!
#				$sql = "UPDATE `".BIT_DB_PREFIX."nexus_plugins` SET `is_active`='x' WHERE `plugin_guid`=?";
#				$this->mDb->query( $sql, array( $guid ) );
#				$handler['is_active'] = 'n';
#			} elseif( !empty( $handler['verified'] ) && $handler['is_active'] =='x' ) {
#				//We found a formally missing plugin - re-enable it
#				$sql = "UPDATE `".BIT_DB_PREFIX."nexus_plugins` SET `is_active`='y' WHERE `plugin_guid`=?";
#				$this->mDb->query( $sql, array( $guid ) );
#				$handler['is_active'] = 'y';
#			} elseif( empty( $handler['verified'] ) && !isset( $handler['is_active'] ) ) {
#				//We found a missing plugin - insert it
#				$sql = "INSERT INTO `".BIT_DB_PREFIX."nexus_plugins` ( `plugin_guid`, `plugin_type`, `plugin_description`, `is_active` ) VALUES ( ?, ?, ?, 'y' )";
#				$this->mDb->query( $sql, array( $guid, $handler['plugin_type'], $handler['description'] ) );
#				$handler['is_active'] = 'y';
#			}
#		}
#		if( !empty( $sql ) ) {
#			// we just ran some SQL - let's flush the loadPlugins query cache
#			$this->loadPlugins( 0 );
#		}
#		asort( $this->mPlugins );
#	}
#
#	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."nexus_plugins` 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."nexus_plugins` 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 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;
#	}
#
#	/**
#	 * fucntion to store pluging settings
#	 * $param $pParamHash contains settings for any guid that require updating
#	 * return TRUE
#	 */
#	function storePluginSettings( $pParamHash ) {
#		// first get all values from nexus_plugin_settings to see which ones need updating and which ones are added for the first time
#		$rs = $this->mDb->query( "SELECT * FROM `".BIT_DB_PREFIX."nexus_plugin_settings`", NULL );
#		while( $rs && !$rs->EOF ) {
#			$settings[] = $rs->fields;
#			$rs->MoveNext();
#		}
#	}
#}
#
#global $gNexusSystem;
#$gNexusSystem = new NexusSystem();
#$gNexusSystem->scanPlugins();
#$gBitSmarty->assign_by_ref( 'gNexusSystem', $gNexusSystem );
?>