support for a documentation tag
This commit is contained in:
parent
2ba285a005
commit
ab64f4721f
2 changed files with 24 additions and 1 deletions
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ExtensionInfo { // {{{
|
class ExtensionInfo { // {{{
|
||||||
var $ext_name, $name, $link, $author, $email, $description;
|
var $ext_name, $name, $link, $author, $email, $description, $documentation;
|
||||||
|
|
||||||
function ExtensionInfo($main) {
|
function ExtensionInfo($main) {
|
||||||
$matches = array();
|
$matches = array();
|
||||||
|
@ -45,6 +45,15 @@ class ExtensionInfo { // {{{
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(preg_match("/(.*)Documentation: (.*)/", $line, $matches)) {
|
||||||
|
$this->documentation = $matches[2];
|
||||||
|
$start = $matches[1]." ";
|
||||||
|
$start_len = strlen($start);
|
||||||
|
while(substr($lines[$i+1], 0, $start_len) == $start) {
|
||||||
|
$this->documentation .= substr($lines[$i+1], $start_len);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(preg_match("/\*\//", $line, $matches)) {
|
if(preg_match("/\*\//", $line, $matches)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -84,6 +93,12 @@ class ExtManager implements Extension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(($event instanceof PageRequestEvent) && $event->page_matches("ext_doc")) {
|
||||||
|
$ext = $event->get_arg(0);
|
||||||
|
$info = new ExtensionInfo("contrib/$ext/main.php");
|
||||||
|
$this->theme->display_doc($event->page, $info);
|
||||||
|
}
|
||||||
|
|
||||||
if($event instanceof UserBlockBuildingEvent) {
|
if($event instanceof UserBlockBuildingEvent) {
|
||||||
if($event->user->is_admin()) {
|
if($event->user->is_admin()) {
|
||||||
$event->add_link("Extension Manager", make_link("ext_manager"));
|
$event->add_link("Extension Manager", make_link("ext_manager"));
|
||||||
|
|
|
@ -43,5 +43,13 @@ class ExtManagerTheme extends Themelet {
|
||||||
$page->add_block(new NavBlock());
|
$page->add_block(new NavBlock());
|
||||||
$page->add_block(new Block("Extension Manager", $html));
|
$page->add_block(new Block("Extension Manager", $html));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function display_doc(Page $page, ExtensionInfo $info) {
|
||||||
|
$html = "<div style='align: left'>".$info->documentation."</div>";
|
||||||
|
$page->set_title("Documentation for ".html_escape($info->name));
|
||||||
|
$page->set_heading(html_escape($info->name));
|
||||||
|
$page->add_block(new NavBlock());
|
||||||
|
$page->add_block(new Block("Documentation", $html));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Reference in a new issue