diff options
author | Brett Profitt <brett.profitt@gmail.com> | 2011-04-26 15:03:02 -0400 |
---|---|---|
committer | Brett Profitt <brett.profitt@gmail.com> | 2011-04-26 15:03:02 -0400 |
commit | c80ba5aa03264dd64c20ed8ae222e87f9371a44d (patch) | |
tree | 9355d87a9ab4570b9e54685ad9869cd4fedd392f /engine/classes | |
parent | 581c2d35ae053aed07a607b8bb844603c48b7c2f (diff) | |
parent | 632cf13234d04a3f6b7acf67866a82e0bebde55c (diff) | |
download | elgg-c80ba5aa03264dd64c20ed8ae222e87f9371a44d.tar.gz elgg-c80ba5aa03264dd64c20ed8ae222e87f9371a44d.tar.bz2 |
Merge remote branch 'upstream/master'
Diffstat (limited to 'engine/classes')
-rw-r--r-- | engine/classes/ElggPlugin.php | 39 | ||||
-rw-r--r-- | engine/classes/ElggPluginPackage.php | 19 |
2 files changed, 41 insertions, 17 deletions
diff --git a/engine/classes/ElggPlugin.php b/engine/classes/ElggPlugin.php index 34e8e6732..20a8673de 100644 --- a/engine/classes/ElggPlugin.php +++ b/engine/classes/ElggPlugin.php @@ -30,7 +30,6 @@ class ElggPlugin extends ElggObject { $this->access_id = ACCESS_PUBLIC; } - /** * Loads the plugin by GUID or path. * @@ -91,7 +90,6 @@ class ElggPlugin extends ElggObject { } } - /** * Save the plugin object. Make sure required values exist. * @@ -138,7 +136,6 @@ class ElggPlugin extends ElggObject { return sanitise_filepath($this->path); } - /** * Sets the location of this plugin. * @@ -149,6 +146,23 @@ class ElggPlugin extends ElggObject { return $this->attributes['title'] = $id; } + /** + * Returns an array of available markdown files for this plugin + * + * @return array + */ + public function getAvailableTextFiles() { + $filenames = $this->package->getTextFilenames(); + + $files = array(); + foreach ($filenames as $filename) { + if ($this->canReadFile($filename)) { + $files[$filename] = "$this->path/$filename"; + } + } + + return $files; + } // Load Priority @@ -162,7 +176,6 @@ class ElggPlugin extends ElggObject { return $this->$name; } - /** * Sets the priority of the plugin * @@ -324,7 +337,6 @@ class ElggPlugin extends ElggObject { return $this->set($name, $value); } - /** * Removes a plugin setting name and value. * @@ -336,7 +348,6 @@ class ElggPlugin extends ElggObject { return remove_private_setting($this->guid, $name); } - /** * Removes all settings for this plugin. * @@ -496,7 +507,6 @@ class ElggPlugin extends ElggObject { return remove_private_setting($user->guid, $name); } - /** * Removes all User Settings for this plugin * @@ -517,7 +527,6 @@ class ElggPlugin extends ElggObject { return delete_data($q); } - /** * Removes this plugin's user settings for all users. * @@ -566,7 +575,6 @@ class ElggPlugin extends ElggObject { return true; } - /** * Is this plugin active? * @@ -591,7 +599,6 @@ class ElggPlugin extends ElggObject { return check_entity_relationship($this->guid, 'active_plugin', $site->guid); } - /** * Checks if this plugin can be activated on the current * Elgg installation. @@ -640,7 +647,7 @@ 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! if ($return) { - if ($this->canIncludeFile('activate.php')) { + if ($this->canReadFile('activate.php')) { $flags = ELGG_PLUGIN_INCLUDE_START | ELGG_PLUGIN_REGISTER_CLASSES | ELGG_PLUGIN_REGISTER_LANGUAGES | ELGG_PLUGIN_REGISTER_VIEWS; @@ -660,7 +667,6 @@ class ElggPlugin extends ElggObject { return false; } - /** * Deactivates the plugin. * @@ -682,7 +688,7 @@ class ElggPlugin extends ElggObject { // run any deactivate code if ($return) { - if ($this->canIncludeFile('deactivate.php')) { + if ($this->canReadFile('deactivate.php')) { $return = $this->includeFile('deactivate.php'); } } @@ -694,7 +700,6 @@ class ElggPlugin extends ElggObject { } } - /** * Start the plugin. * @@ -750,7 +755,7 @@ class ElggPlugin extends ElggObject { $filepath = "$this->path/$filename"; - if (!$this->canIncludeFile($filename)) { + if (!$this->canReadFile($filename)) { $msg = elgg_echo('ElggPlugin:Exception:CannotIncludeFile', array($filename, $this->getID(), $this->guid, $this->path)); throw new PluginException($msg); @@ -765,8 +770,8 @@ class ElggPlugin extends ElggObject { * @param string $filename The name of the file * @return bool */ - protected function canIncludeFile($filename) { - return file_exists($this->path.'/'.$filename); + protected function canReadFile($filename) { + return is_readable($this->path . '/' . $filename); } /** diff --git a/engine/classes/ElggPluginPackage.php b/engine/classes/ElggPluginPackage.php index b2ec20549..4daab381e 100644 --- a/engine/classes/ElggPluginPackage.php +++ b/engine/classes/ElggPluginPackage.php @@ -28,6 +28,15 @@ class ElggPluginPackage { ); /** + * The optional files that can be read and served through the markdown page handler + * @var array + */ + private $textFiles = array( + 'README.txt', 'CHANGES.txt', + 'INSTALL.txt', 'COPYRIGHT.txt', 'LICENSE.txt' + ); + + /** * Valid types for provides. * * @var array @@ -286,6 +295,16 @@ class ElggPluginPackage { return false; } + /**************** + * Readme Files * + ***************/ + + /** + * Returns an array of present and readable text files + */ + public function getTextFilenames() { + return $this->textFiles; + } /*********************** * Dependencies system * |