diff options
| author | Brett Profitt <brett.profitt@gmail.com> | 2011-04-18 19:54:17 -0400 | 
|---|---|---|
| committer | Brett Profitt <brett.profitt@gmail.com> | 2011-04-18 19:54:17 -0400 | 
| commit | 0d9c5c1ccd66018a819b4ca327ab203f473e35dc (patch) | |
| tree | f55e5caa8bf8036b02fc553eecd2b615791d2ce5 /engine/classes | |
| parent | ca63a6b81eee1dfbee99a393a790402475a4612c (diff) | |
| parent | d928588805375e7190ab393e2def555b39701a27 (diff) | |
| download | elgg-0d9c5c1ccd66018a819b4ca327ab203f473e35dc.tar.gz elgg-0d9c5c1ccd66018a819b4ca327ab203f473e35dc.tar.bz2  | |
Merge branch 'master' of github.com:Elgg/Elgg
Diffstat (limited to 'engine/classes')
| -rw-r--r-- | engine/classes/ElggMenuItem.php | 8 | ||||
| -rw-r--r-- | engine/classes/ElggPlugin.php | 86 | ||||
| -rw-r--r-- | engine/classes/ElggPluginManifest.php | 30 | ||||
| -rw-r--r-- | engine/classes/ElggPluginManifestParser18.php | 6 | 
4 files changed, 43 insertions, 87 deletions
diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php index bf6cf2edc..61dbf539e 100644 --- a/engine/classes/ElggMenuItem.php +++ b/engine/classes/ElggMenuItem.php @@ -123,9 +123,9 @@ class ElggMenuItem {  			unset($options['context']);  		} -		if (isset($options['class'])) { -			$item->setLinkClass($options['class']); -			unset($options['class']); +		if (isset($options['link_class'])) { +			$item->setLinkClass($options['link_class']); +			unset($options['link_class']);  		}  		if (isset($options['item_class'])) { @@ -459,7 +459,7 @@ class ElggMenuItem {  		if ($this->href) {  			$vars['href'] = $this->href;  		} -		 +  		if ($this->linkClass) {  			$vars['class'] = $this->getLinkClass();  		} diff --git a/engine/classes/ElggPlugin.php b/engine/classes/ElggPlugin.php index 55be2b887..34e8e6732 100644 --- a/engine/classes/ElggPlugin.php +++ b/engine/classes/ElggPlugin.php @@ -639,24 +639,14 @@ class ElggPlugin extends ElggObject {  			// if there are any on_enable functions, start the plugin now and run them  			// Note: this will not run re-run the init hooks! -			$functions = $this->manifest->getOnActivate(); -			if ($return && $functions) { -				$flags = ELGG_PLUGIN_INCLUDE_START | ELGG_PLUGIN_REGISTER_CLASSES -						| ELGG_PLUGIN_REGISTER_LANGUAGES | ELGG_PLUGIN_REGISTER_VIEWS; - -				$this->start($flags); -				foreach ($functions as $function) { -					if (!is_callable($function)) { -						$return = false; -					} else { -						$result = call_user_func($function); -						// allow null to mean "I don't care" like other subsystems -						$return = ($result === false) ? false: true; -					} - -					if ($return === false) { -						break; -					} +			if ($return) { +				if ($this->canIncludeFile('activate.php')) { +					$flags = ELGG_PLUGIN_INCLUDE_START | ELGG_PLUGIN_REGISTER_CLASSES +							| ELGG_PLUGIN_REGISTER_LANGUAGES | ELGG_PLUGIN_REGISTER_VIEWS; + +					$this->start($flags); + +					$return = $this->includeFile('activate.php');  				}  			} @@ -690,27 +680,10 @@ class ElggPlugin extends ElggObject {  		$return = elgg_trigger_event('deactivate', 'plugin', $params); -		// run any deactivate functions -		// check for the manifest in case we haven't fully loaded the plugin. -		if ($this->manifest) { -			$functions = $this->manifest->getOnDeactivate(); -		} else { -			$functions = array(); -		} - -		if ($return && $functions) { -			foreach ($functions as $function) { -				if (!is_callable($function)) { -					$return = false; -				} else { -					$result = call_user_func($function); -					// allow null to mean "I don't care" like other subsystems -					$return = ($result === false) ? false : true; -				} - -				if ($return === false) { -					break; -				} +		// run any deactivate code +		if ($return) { +			if ($this->canIncludeFile('deactivate.php')) { +				$return = $this->includeFile('deactivate.php');  			}  		} @@ -736,7 +709,7 @@ class ElggPlugin extends ElggObject {  		// include start file  		if ($flags & ELGG_PLUGIN_INCLUDE_START) { -			$this->includeStart(); +			$this->includeFile('start.php');  		}  		// include views @@ -761,24 +734,39 @@ class ElggPlugin extends ElggObject {  	// start helpers  	/** -	 * Includes the plugin's start file +	 * Includes one of the plugins files +	 * +	 * @param string $filename The name of the file  	 *  	 * @throws PluginException -	 * @return true +	 * @return mixed The return value of the included file (or 1 if there is none)  	 */ -	protected function includeStart() { +	protected function includeFile($filename) {  		// This needs to be here to be backwards compatible for 1.0-1.7.  		// They expect the global config object to be available in start.php. -		global $CONFIG; +		if ($filename == 'start.php') { +			global $CONFIG; +		} + +		$filepath = "$this->path/$filename"; -		$start = "$this->path/start.php"; -		if (!include($start)) { -			$msg = elgg_echo('ElggPlugin:Exception:CannotIncludeStart', -							array($this->getID(), $this->guid, $this->path)); +		if (!$this->canIncludeFile($filename)) { +			$msg = elgg_echo('ElggPlugin:Exception:CannotIncludeFile', +							array($filename, $this->getID(), $this->guid, $this->path));  			throw new PluginException($msg);  		} -		return true; +		return include $filepath; +	} + +	/** +	 * Checks whether a plugin file with the given name exists +	 * +	 * @param string $filename The name of the file +	 * @return bool +	 */ +	protected function canIncludeFile($filename) { +		return file_exists($this->path.'/'.$filename);  	}  	/** diff --git a/engine/classes/ElggPluginManifest.php b/engine/classes/ElggPluginManifest.php index a0ec478a9..0f3b1d7a8 100644 --- a/engine/classes/ElggPluginManifest.php +++ b/engine/classes/ElggPluginManifest.php @@ -577,36 +577,6 @@ class ElggPluginManifest {  	}  	/** -	 * Returns the functions to run upon activation -	 * -	 *  @return array -	 */ -	public function getOnActivate() { -		$functions = $this->parser->getAttribute('on_activate'); - -		if (!$functions) { -			$functions = array(); -		} - -		return $functions; -	} - -	/** -	 * Returns the functions to run upon deactivation -	 * -	 *  @return array -	 */ -	public function getOnDeactivate() { -		$functions = $this->parser->getAttribute('on_deactivate'); - -		if (!$functions) { -			$functions = array(); -		} - -		return $functions; -	} - -	/**  	 * Returns the admin interface to use.  	 *  	 *  @return string simple or advanced diff --git a/engine/classes/ElggPluginManifestParser18.php b/engine/classes/ElggPluginManifestParser18.php index 38734f6b4..db8b3dc6a 100644 --- a/engine/classes/ElggPluginManifestParser18.php +++ b/engine/classes/ElggPluginManifestParser18.php @@ -15,8 +15,8 @@ class ElggPluginManifestParser18 extends ElggPluginManifestParser {  	protected $validAttributes = array(  		'name', 'author', 'version', 'blurb', 'description',  		'website', 'copyright', 'license', 'requires', 'suggests', -		'screenshot', 'category', 'conflicts', 'provides', 'on_activate', -		'on_deactivate', 'admin_interface', 'activate_on_install' +		'screenshot', 'category', 'conflicts', 'provides', +		'admin_interface', 'activate_on_install'  	);  	/** @@ -52,8 +52,6 @@ class ElggPluginManifestParser18 extends ElggPluginManifestParser {  					break;  				// arrays -				case 'on_activate': -				case 'on_deactivate':  				case 'category':  					$parsed[$element->name][] = $element->content;  					break;  | 
