diff --git a/core.php b/core.php index b786029..78bd0e0 100644 --- a/core.php +++ b/core.php @@ -147,51 +147,116 @@ $page = $_GET["page"]; //////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////// HTML fragments ////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// -function renderpage($title, $content, $minimal = false) +class page_renderer { - global $settings, $page, $user, $isloggedin, $isadmin, $start_time, $pageindex; + public static $html_template = " + +
+ +From {sitename}, which is managed by {admin-details-name}.
+Timed at {generation-date} +
Powered by Pepperminty Wiki.
"; + + public static function render($title, $content, $body_template) { - $html .= "\n\t\t\n"; + global $settings, $start_time; + + $result = self::$html_template; + $result = str_replace("{body}", $body_template, $result); + $result = str_replace([ + "{sitename}", + "{favicon-url}", + "{header-html}", + + "{navigation-bar}", + + "{admin-details-name}", + "{admin-details-email}", + + "{admins-name-list}", + + "{generation-date}", + + "{all-pages-datalist}" + ], [ + $settings->sitename, + $settings->favicon, + self::get_css_as_html(), + + self::render_navigation_bar(), + + $settings->admindetails["name"], + $settings->admindetails["email"], + + implode(", ", $settings->admins), + + date("l jS \of F Y \a\\t h:ia T"), + + self::generate_all_pages_datalist() + ], $result); + + $result = str_replace("{content}", $content, $result); + + $result = str_replace("{generation-time-taken}", microtime(true) - $start_time, $result); + return result; } - else + public static function render_main($title, $content) { - $html .= "\n\t\t\n"; + return render($title, $content, self::$main_content_template); } - $html .= "\n"; - - ////////// - - if($minimal) + public static function render_minimal($title, $content) { - $html .= "$content -From $settings->sitename, which is managed by " . $settings->admindetails["name"] . ".
-Timed at " . date("l jS \of F Y \a\\t h:ia T") . ".
-Powered by Pepperminty Wiki
"; + return render($title, $content, self::$minimal_content_template); } - else - { - $html .= ""; + return result; + } + public static function render_username($name) + { + $result = ""; + if(in_array($name, $settings->admins)) + $result .= $settings->admindisplaychar; + $result .= $name; - foreach($pageindex as $pagename => $pagedetails) - { - $html .= "\t\t\n"; - } - $html .= "\t"; + return $result; } - ////////// - $gentime = microtime(true) - $start_time; - $html .= "\n\t -"; - - return $html; + public static function generate_all_pages_datalist() + { + global $pageindex; + + $result = ""; + + return $result; + } } //////////////////////////////////////////////////////////////////////////////////////////// @@ -419,7 +486,7 @@ foreach($modules as $moduledata) // make sure that the credits page exists if(!isset($actions->credits)) { - exit(renderpage("Error - $settings->$sitename", "No credits page detected. The credits page is a required module!
")); + exit(pagerenderer::render_main("Error - $settings->$sitename", "No credits page detected. The credits page is a required module!
")); } // Perform the appropriate action @@ -431,6 +498,6 @@ if(isset($actions->$action_name)) } else { - exit(renderpage("Error - $settings->sitename", ",p>No action called " . strtolower($_GET["action"]) ." has been registered. Perhaps you are missing a module?")); + exit(pagerenderer::render_main("Error - $settings->sitename", "No action called " . strtolower($_GET["action"]) ." has been registered. Perhaps you are missing a module?
")); } ?>