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 = " + + + + {title} + + - $title - - "; - if(preg_match("/^[^\/]*\/\/|^\//", $settings->css)) + public static $main_content_template = "{navigation-bar} +

{sitename}

+ {content} + + {all-pages-datalist}"; + public static $minimal_content_template = "{content} +
+

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