tidy ups in the extension manager
git-svn-id: file:///home/shish/svn/shimmie2/trunk@808 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
4e19a29dd0
commit
9a54cf6d0d
@ -7,6 +7,40 @@
|
|||||||
* Description: A thing for point & click extension management
|
* Description: A thing for point & click extension management
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
class ExtensionInfo { // {{{
|
||||||
|
var $ext_name, $name, $link, $author, $email, $description;
|
||||||
|
|
||||||
|
function ExtensionInfo($main) {
|
||||||
|
$matches = array();
|
||||||
|
$data = file_get_contents($main);
|
||||||
|
preg_match("#contrib/(.*)/main.php#", $main, $matches);
|
||||||
|
$this->ext_name = $matches[1];
|
||||||
|
$this->name = $matches[1];
|
||||||
|
|
||||||
|
if(preg_match("/Name: (.*)/", $data, $matches)) {
|
||||||
|
$this->name = $matches[1];
|
||||||
|
}
|
||||||
|
if(preg_match("/Link: (.*)/", $data, $matches)) {
|
||||||
|
$this->link = $matches[1];
|
||||||
|
}
|
||||||
|
if(preg_match("/Author: (.*) [<\(](.*@.*)[>\)]/", $data, $matches)) {
|
||||||
|
$this->author = $matches[1];
|
||||||
|
$this->email = $matches[2];
|
||||||
|
}
|
||||||
|
else if(preg_match("/Author: (.*)/", $data, $matches)) {
|
||||||
|
$this->author = $matches[1];
|
||||||
|
}
|
||||||
|
if(preg_match("/Description: (.*)/", $data, $matches)) {
|
||||||
|
$this->description = $matches[1];
|
||||||
|
}
|
||||||
|
$this->enabled = $this->is_enabled($this->ext_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function is_enabled($fname) {
|
||||||
|
return file_exists("ext/$fname");
|
||||||
|
}
|
||||||
|
} // }}}
|
||||||
|
|
||||||
class ExtManager extends Extension {
|
class ExtManager extends Extension {
|
||||||
var $theme;
|
var $theme;
|
||||||
|
|
||||||
@ -42,37 +76,11 @@ class ExtManager extends Extension {
|
|||||||
private function get_extensions() {
|
private function get_extensions() {
|
||||||
$extensions = array();
|
$extensions = array();
|
||||||
foreach(glob("contrib/*/main.php") as $main) {
|
foreach(glob("contrib/*/main.php") as $main) {
|
||||||
$extension = array();
|
$extensions[] = new ExtensionInfo($main);
|
||||||
$matches = array();
|
|
||||||
$data = file_get_contents($main);
|
|
||||||
preg_match("#contrib/(.*)/main.php#", $main, $matches);
|
|
||||||
$extension["ext_name"] = $matches[1];
|
|
||||||
if(preg_match("/Name: (.*)/", $data, $matches)) {
|
|
||||||
$extension["name"] = $matches[1];
|
|
||||||
}
|
|
||||||
if(preg_match("/Link: (.*)/", $data, $matches)) {
|
|
||||||
$extension["link"] = $matches[1];
|
|
||||||
}
|
|
||||||
if(preg_match("/Author: (.*) [<\(](.*@.*)[>\)]/", $data, $matches)) {
|
|
||||||
$extension["author"] = $matches[1];
|
|
||||||
$extension["email"] = $matches[2];
|
|
||||||
}
|
|
||||||
else if(preg_match("/Author: (.*)/", $data, $matches)) {
|
|
||||||
$extension["author"] = $matches[1];
|
|
||||||
}
|
|
||||||
if(preg_match("/Description: (.*)/", $data, $matches)) {
|
|
||||||
$extension["description"] = $matches[1];
|
|
||||||
}
|
|
||||||
$extension["enabled"] = $this->is_enabled($extension["ext_name"]);
|
|
||||||
$extensions[] = $extension;
|
|
||||||
}
|
}
|
||||||
return $extensions;
|
return $extensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function is_enabled($fname) {
|
|
||||||
return file_exists("ext/$fname");
|
|
||||||
}
|
|
||||||
|
|
||||||
private function set_things($settings) {
|
private function set_things($settings) {
|
||||||
foreach(glob("contrib/*/main.php") as $main) {
|
foreach(glob("contrib/*/main.php") as $main) {
|
||||||
$matches = array();
|
$matches = array();
|
||||||
@ -88,7 +96,12 @@ class ExtManager extends Extension {
|
|||||||
if($enabled) {
|
if($enabled) {
|
||||||
// enable if currently disabled
|
// enable if currently disabled
|
||||||
if(!file_exists("ext/$fname")) {
|
if(!file_exists("ext/$fname")) {
|
||||||
$this->enable_extension($fname);
|
if(function_exists("symlink")) {
|
||||||
|
symlink("../contrib/$fname", "ext/$fname");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
full_copy("contrib/$fname", "ext/$fname");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -98,15 +111,6 @@ class ExtManager extends Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function enable_extension($fname) {
|
|
||||||
if(function_exists("symlink")) {
|
|
||||||
symlink("../contrib/$fname", "ext/$fname");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
full_copy("contrib/$fname", "ext/$fname");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
add_event_listener(new ExtManager());
|
add_event_listener(new ExtManager());
|
||||||
?>
|
?>
|
||||||
|
@ -8,13 +8,13 @@ class ExtManagerTheme extends Themelet {
|
|||||||
<tr><th>Name</th><th>Author</th><th>Description</th><th>Enabled</th></tr>
|
<tr><th>Name</th><th>Author</th><th>Description</th><th>Enabled</th></tr>
|
||||||
";
|
";
|
||||||
foreach($extensions as $extension) {
|
foreach($extensions as $extension) {
|
||||||
$ext_name = $extension["ext_name"];
|
$ext_name = $extension->ext_name;
|
||||||
$h_name = empty($extension["name"]) ? $ext_name : html_escape($extension["name"]);
|
$h_name = empty($extension->name) ? $ext_name : html_escape($extension->name);
|
||||||
$h_email = html_escape($extension["email"]);
|
$h_email = html_escape($extension->email);
|
||||||
$h_link = isset($extension["link"]) ? html_escape($extension["link"]) : "";
|
$h_link = isset($extension->link) ? html_escape($extension->link) : "";
|
||||||
$h_author = html_escape($extension["author"]);
|
$h_author = html_escape($extension->author);
|
||||||
$h_description = html_escape($extension["description"]);
|
$h_description = html_escape($extension->description);
|
||||||
$h_enabled = $extension["enabled"] ? " checked='checked'" : "";
|
$h_enabled = $extension->enabled ? " checked='checked'" : "";
|
||||||
$html .= "
|
$html .= "
|
||||||
<tr>
|
<tr>
|
||||||
" . (
|
" . (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user