functionality
git-svn-id: file:///home/shish/svn/shimmie2/trunk@619 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
cf68910da1
commit
18b97444d4
@ -15,9 +15,16 @@ class ExtManager extends Extension {
|
|||||||
|
|
||||||
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "ext_manager")) {
|
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "ext_manager")) {
|
||||||
if($event->user->is_admin()) {
|
if($event->user->is_admin()) {
|
||||||
|
if($event->get_arg(0) == "set") {
|
||||||
|
$this->set_things($_POST);
|
||||||
|
$event->page->set_mode("redirect");
|
||||||
|
$event->page->set_redirect("ext_manager");
|
||||||
|
}
|
||||||
|
else {
|
||||||
$this->theme->display_table($event->page, $this->get_extensions());
|
$this->theme->display_table($event->page, $this->get_extensions());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(is_a($event, 'UserBlockBuildingEvent')) {
|
if(is_a($event, 'UserBlockBuildingEvent')) {
|
||||||
if($event->user->is_admin()) {
|
if($event->user->is_admin()) {
|
||||||
@ -34,15 +41,22 @@ class ExtManager extends Extension {
|
|||||||
$data = file_get_contents($main);
|
$data = file_get_contents($main);
|
||||||
preg_match("#contrib/(.*)/main.php#", $main, $matches);
|
preg_match("#contrib/(.*)/main.php#", $main, $matches);
|
||||||
$extension["ext_name"] = $matches[1];
|
$extension["ext_name"] = $matches[1];
|
||||||
preg_match("/Name: (.*)/", $data, $matches);
|
if(preg_match("/Name: (.*)/", $data, $matches)) {
|
||||||
$extension["name"] = $matches[1];
|
$extension["name"] = $matches[1];
|
||||||
preg_match("/Link: (.*)/", $data, $matches);
|
}
|
||||||
|
if(preg_match("/Link: (.*)/", $data, $matches)) {
|
||||||
$extension["link"] = $matches[1];
|
$extension["link"] = $matches[1];
|
||||||
preg_match("/Author: (.*) <(.*)>/", $data, $matches);
|
}
|
||||||
|
if(preg_match("/Author: (.*) [<\(](.*@.*)[>\)]/", $data, $matches)) {
|
||||||
$extension["author"] = $matches[1];
|
$extension["author"] = $matches[1];
|
||||||
$extension["email"] = $matches[2];
|
$extension["email"] = $matches[2];
|
||||||
preg_match("/Description: (.*)/", $data, $matches);
|
}
|
||||||
|
else if(preg_match("/Author: (.*)/", $data, $matches)) {
|
||||||
|
$extension["author"] = $matches[1];
|
||||||
|
}
|
||||||
|
if(preg_match("/Description: (.*)/", $data, $matches)) {
|
||||||
$extension["description"] = $matches[1];
|
$extension["description"] = $matches[1];
|
||||||
|
}
|
||||||
$extension["enabled"] = $this->is_enabled($extension["ext_name"]);
|
$extension["enabled"] = $this->is_enabled($extension["ext_name"]);
|
||||||
$extensions[] = $extension;
|
$extensions[] = $extension;
|
||||||
}
|
}
|
||||||
@ -52,6 +66,30 @@ class ExtManager extends Extension {
|
|||||||
private function is_enabled($fname) {
|
private function is_enabled($fname) {
|
||||||
return file_exists("ext/$fname");
|
return file_exists("ext/$fname");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function set_things($settings) {
|
||||||
|
foreach(glob("contrib/*/main.php") as $main) {
|
||||||
|
$matches = array();
|
||||||
|
preg_match("#contrib/(.*)/main.php#", $main, $matches);
|
||||||
|
$fname = $matches[1];
|
||||||
|
|
||||||
|
$this->set_enabled($fname, $settings["ext_$fname"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private function set_enabled($fname, $enabled) {
|
||||||
|
if($enabled) {
|
||||||
|
// enable if currently disabled
|
||||||
|
if(!file_exists("ext/$fname")) {
|
||||||
|
shell_exec("ln -s ../contrib/$fname ext/$fname");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// disable if currently enabled
|
||||||
|
if(file_exists("ext/$fname")) {
|
||||||
|
shell_exec("rm ext/$fname");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
add_event_listener(new ExtManager());
|
add_event_listener(new ExtManager());
|
||||||
?>
|
?>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
class ExtManagerTheme extends Themelet {
|
class ExtManagerTheme extends Themelet {
|
||||||
public function display_table($page, $extensions) {
|
public function display_table($page, $extensions) {
|
||||||
$html = "
|
$html = "
|
||||||
<form action='' method='POST'>
|
<form action='".make_link("ext_manager/set")."' method='POST'>
|
||||||
<table border='1'>
|
<table border='1'>
|
||||||
<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>
|
||||||
";
|
";
|
||||||
@ -21,8 +21,11 @@ class ExtManagerTheme extends Themelet {
|
|||||||
empty($h_link) ?
|
empty($h_link) ?
|
||||||
"<td>$h_name</td>" :
|
"<td>$h_name</td>" :
|
||||||
"<td><a href='$h_link'>$h_name</a></td>"
|
"<td><a href='$h_link'>$h_name</a></td>"
|
||||||
|
) . (
|
||||||
|
empty($h_email) ?
|
||||||
|
"<td>$h_author</td>" :
|
||||||
|
"<td><a href='mailto:$h_email'>$h_author</a></td>"
|
||||||
) . "
|
) . "
|
||||||
<td><a href='mailto:$h_email'>$h_author</a></td>
|
|
||||||
<td>$h_description</td>
|
<td>$h_description</td>
|
||||||
<td>
|
<td>
|
||||||
<input type='checkbox' name='ext_$ext_name'$h_enabled>
|
<input type='checkbox' name='ext_$ext_name'$h_enabled>
|
||||||
@ -30,6 +33,7 @@ class ExtManagerTheme extends Themelet {
|
|||||||
</tr>";
|
</tr>";
|
||||||
}
|
}
|
||||||
$html .= "
|
$html .= "
|
||||||
|
<tr><td colspan='4'><input type='submit' value='Set Extensions'></td></tr>
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
";
|
";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user