1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-25 05:22:59 +00:00

Preliminary testing done! I think it works!!!

This commit is contained in:
Starbeamrainbowlabs 2015-05-08 20:30:32 +01:00
parent 0840170750
commit 80afa3d415
5 changed files with 29 additions and 18 deletions

View file

@ -1,2 +1,3 @@
del index.php del index.php
php rebuild_module_index.php
php build.php php build.php

View file

@ -391,6 +391,9 @@ $modules = []; // list that contains all the loaded modules
// function to register a module // function to register a module
function register_module($moduledata) function register_module($moduledata)
{ {
global $modules;
//echo("registering module\n");
//var_dump($moduledata);
$modules[] = $moduledata; $modules[] = $moduledata;
} }
@ -398,6 +401,8 @@ function register_module($moduledata)
$actions = new stdClass(); $actions = new stdClass();
function add_action($action_name, $func) function add_action($action_name, $func)
{ {
global $actions;
//echo("adding $action_name\n");
$actions->$action_name = $func; $actions->$action_name = $func;
} }
@ -413,17 +418,17 @@ foreach($modules as $moduledata)
$moduledata["code"](); $moduledata["code"]();
} }
// make sure that the credits page exists // make sure that the credits page exists
if(!isset($actions["credits"])) if(!isset($actions->credits))
{ {
exit(renderpage("Error - $settings->$sitename", "<p>No credits page detected. The credits page is a required module!</p>")) exit(renderpage("Error - $settings->$sitename", "<p>No credits page detected. The credits page is a required module!</p>"));
} }
// Perform the appropriate action // Perform the appropriate action
if(isset($actions[strtolower($_GET["action"])])) $action_name = strtolower($_GET["action"]);
if(isset($actions->$action_name))
{ {
$req_action = strtolower($_GET["action"]); $req_action_data = $actions->$action_name;
$req_action_data = $action_name->$req_action; $req_action_data();
$req_action_data["code"]();
} }
else else
{ {

View file

@ -519,6 +519,9 @@ $modules = []; // list that contains all the loaded modules
// function to register a module // function to register a module
function register_module($moduledata) function register_module($moduledata)
{ {
global $modules;
//echo("registering module\n");
//var_dump($moduledata);
$modules[] = $moduledata; $modules[] = $moduledata;
} }
@ -526,6 +529,8 @@ function register_module($moduledata)
$actions = new stdClass(); $actions = new stdClass();
function add_action($action_name, $func) function add_action($action_name, $func)
{ {
global $actions;
//echo("adding $action_name\n");
$actions->$action_name = $func; $actions->$action_name = $func;
} }
@ -624,7 +629,7 @@ register_module([
register_module([ register_module([
"name" => "Page editor", "name" => "Page editor",
"version" => "0.4", "version" => "0.5",
"author" => "Starbeamrainbowlabs", "author" => "Starbeamrainbowlabs",
"description" => "Allows you to edit pages by adding the edit and save actions. You should probably include this one.", "description" => "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
"id" => "page-edit", "id" => "page-edit",
@ -664,7 +669,7 @@ register_module([
if(!$creatingpage) if(!$creatingpage)
{ {
//the page already exists - let the user view the page source //the page already exists - let the user view the page source
exit(renderpage("Viewing source for $page", "<textarea readonly>$pagetext</textarea>")); exit(renderpage("Viewing source for $page", "<p>$settings->sitename does not allow anonymous users to make edits. You can view the source of $page below, but you can't edit it.</p><textarea name='content' readonly>$pagetext</textarea>"));
} }
else else
{ {
@ -1132,17 +1137,17 @@ foreach($modules as $moduledata)
$moduledata["code"](); $moduledata["code"]();
} }
// make sure that the credits page exists // make sure that the credits page exists
if(!isset($actions["credits"])) if(!isset($actions->credits))
{ {
exit(renderpage("Error - $settings->$sitename", "<p>No credits page detected. The credits page is a required module!</p>")) exit(renderpage("Error - $settings->$sitename", "<p>No credits page detected. The credits page is a required module!</p>"));
} }
// Perform the appropriate action // Perform the appropriate action
if(isset($actions[strtolower($_GET["action"])])) $action_name = strtolower($_GET["action"]);
if(isset($actions->$action_name))
{ {
$req_action = strtolower($_GET["action"]); $req_action_data = $actions->$action_name;
$req_action_data = $action_name->$req_action; $req_action_data();
$req_action_data["code"]();
} }
else else
{ {

View file

@ -25,11 +25,11 @@
}, },
{ {
"name": "Page editor", "name": "Page editor",
"version": "0.4", "version": "0.5",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.", "description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
"id": "page-edit", "id": "page-edit",
"lastupdate": 1428758936 "lastupdate": 1431113232
}, },
{ {
"name": "Help page", "name": "Help page",

View file

@ -1,7 +1,7 @@
<?php <?php
register_module([ register_module([
"name" => "Page editor", "name" => "Page editor",
"version" => "0.4", "version" => "0.5",
"author" => "Starbeamrainbowlabs", "author" => "Starbeamrainbowlabs",
"description" => "Allows you to edit pages by adding the edit and save actions. You should probably include this one.", "description" => "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
"id" => "page-edit", "id" => "page-edit",
@ -41,7 +41,7 @@ register_module([
if(!$creatingpage) if(!$creatingpage)
{ {
//the page already exists - let the user view the page source //the page already exists - let the user view the page source
exit(renderpage("Viewing source for $page", "<textarea readonly>$pagetext</textarea>")); exit(renderpage("Viewing source for $page", "<p>$settings->sitename does not allow anonymous users to make edits. You can view the source of $page below, but you can't edit it.</p><textarea name='content' readonly>$pagetext</textarea>"));
} }
else else
{ {