(root)/page.class.php - Rev 496
Rev 478 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
<?PHP
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This file is part of Travelsized CMS
* A content management system with modules, based on wiki syntax
*
* Author: Dan Jensen <admin@leinir.dk>
* Copyright 2003/2004
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License is available at: http://www.gnu.org/copyleft/
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* Parts of this was originally based on code found on www.experten.dk
*/
/**
* Returns the url that corresponds to the globalID for a page
*
* @param splitID The global ID to check
*
* @return string A string containing the URL corresponding to the globalID, if existing
*/
function globalID_page
( $splitID )
{
global $language;
$pageID = null;
if( $splitID[0] == "content" )
{
// This means we have a language to deal with
if( $splitID[2] != null )
{
if( is_numeric( $splitID[2] ) )
$_REQUEST["page_id"] = $splitID[2];
else
{
$_REQUEST["page_id"] = getPageID
( stripslashes( urldecode( $splitID[2] ) ) );
$_REQUEST["page"] = stripslashes( urldecode( $splitID[2] ) );
}
$_REQUEST["language"] = $splitID[1];
$language = $_REQUEST["language"];
}
else if( is_numeric( $splitID[1] ) )
{
$_REQUEST["page_id"] = getPageID
($splitID[1]);
if( $_REQUEST["page_id"] < 0 )
header( "Location: " . globalIDtoURL
("") );
}
include("i18n.php");
$pageID = $_REQUEST["page_id"];
}
return $pageID;
}
$modules_globalID[] = "globalID_page";
/**
* This function types out the help for writing Travelsized CMS data
*
* @param language The language of the data you wish returned. Default is English (en)
* @param setupfolder The folder where the setup information lives. Default is "setup"
*
* @return string The simple HTML formatted data
*/
function showPageHelp
($language = "en", $setupfolder = "setup") {
$txtfile = "$setupfolder/i18n/$language/pagehelp.inc";
if (!(file_exists($txtfile))) $txtfile = "$setupfolder/i18n/en/pagehelp.inc";
if (file_exists($txtfile)) {
$fp = fopen($txtfile, "r");
$contents = fread($fp, filesize($txtfile));
fclose($fp);
return $contents;
} else {
return "Internationalisation error...";
}
}
class Page
{
var $ERRORS;
var $securitymeasures = "<?php die(\"access denied\"); ?>\n";
/**
* This function fetches page data
*
* @param page_id The ID of the page from which you wish to fetch data
* @param language The language of the page you wish to get. Default is English (en)
* @param page_folder The page folder as defined globally... Leftovers, stupidity
*
* @return array page data
*/
function fetchPageData
($page_id, $language = "en", $page_folder = "setup/pages") {
if ($language == "")
$language = "en";
$txtfile = "$page_folder/$page_id.$language.php";
if (!file_exists($txtfile)) {
$txtfile = "$page_folder/$page_id.en.php";
if (!file_exists($txtfile)) {
$txtfile = "$page_folder/$page_id.$language.txt";
//If the language is not english but the file doesn't exist, try english anyway
if (!file_exists($txtfile)) $txtfile = "$page_folder/$page_id.en.txt";
}
}
//Does the file exist?
if (file_exists($txtfile)) {
$fp = fopen($txtfile, "r");
$contents = fread($fp, filesize($txtfile));
if (substr($contents, 0, strlen($this->securitymeasures)) == $this->securitymeasures) $contents = substr($contents, strlen($this->securitymeasures));
$contents = unserialize($contents);
if (!empty($contents["date"])) {
$data = $contents;
}
$data = array_reverse($data);
fclose($fp);
} else {
$data["author"] = $owner_name;
$data["email"] = $owner_email;
$data["menu"] = 0;
$data["title"] = i18n
("Unknown page");
$data["content"] = i18n
("The page was not found on the system. Please return to the ((Front page)) and try again.");
$data["date"] = date("F j, Y, g:i a");
}
return $data;
}
/**
* This function gets a complete list of all pages, including language information
*
* @return array $returned["id"]["language"]["title"]
*/
function fetchPageList
($page_folder) {
//get list of all files (fill an array ($file_list) with the filenames
$fp = opendir($page_folder);
$array_index = 0;
while ($file = readdir($fp)) {
if( substr($file, 0, 1) != "." ) {
$dirarray[$array_index] = $file;
$array_index++;
}
}
closedir($fp);
if (count($dirarray) > 0) {
//go through files one by one, load the data from them
$array_index = 0;
foreach ($dirarray as $key => $value) {
$fpn = fopen("$page_folder/$value", "r");
$contents = fread($fpn, filesize("$page_folder/$value"));
if (substr($contents, 0, strlen($this->securitymeasures)) == $this->securitymeasures) $contents = substr($contents, strlen($this->securitymeasures));
$contents = unserialize($contents);
if (!empty($contents["date"]))
$loaded_data = $contents;
else
$loaded_data = array();
$loaded_data = array_reverse($loaded_data);
fclose($fpn);
$id = $loaded_data["id"];
$data["$id"]["id"] = $loaded_data["id"];
$data["$id"]["language"][] = $loaded_data["language"];
$data["$id"]["title"][] = $loaded_data["title"];
$array_index++;
}
return $data;
} else { //There are no pages yet, return data to this point
return array( "100" => array("id" => 100, "language" => array("en", "dk"), "title" => array("No pages so far", "Ingen sider endnu")),
"101" => array("id" => 101, "language" => array("en", "dk"), "title" => array("No pages so far 2", "Ingen sider endnu 2")));
}
}
/**
* This function finds a free page_id
*
* @param page_folder The system-wide page folder (normally this is simply $page_folder)
* @param page_control The pagectl used by in the calling function
*
* @return integer page_id
*/
function getFreePageID
($page_folder, $page_control) {
$page_list = $page_control->fetchPageList($page_folder);
$array_index = 100;
while (true) {
// Only need to check for the first of the "No pages so far" pages, if there's one, the rest will be there :)
if ($page_list["$array_index"]["id"] == "" || $page_list[101]["title"][0] == "No pages so far 2") {
$free_id = $array_index;
break;
}
$array_index++;
}
return $free_id;
}
/**
* This function saves a page
*
* @param page_folder The system-wide page folder (normally this is simply $page_folder)
* @param $page_id The page's ID
* @param $page_language The page's language
* @param $page_author Who wrote the page
* @param $page_author_email The author's e-mail address
* @param $page_menu Which sucject menu to use
* @param $page_title The title of the page (also used for reverse lookup)
* @param $page_content The page itself
*
* @return boolean true or false
*/
function savePageData
($page_folder, $page_id, $page_language = "en", $page_author, $page_author_email, $page_menu, $page_title, $page_content) {
if ($page_language == "") $page_language = "en";
$txtfile_old = "$page_folder/$page_id.$page_language.txt";
$txtfile = "$page_folder/$page_id.$page_language.php";
if (file_exists($txtfile_old)) { rename($txtfile_old, $txtfile); }
/*
//These regular expression replaces make sure the botched up data from web forms
$page_content = preg_replace("/\\\'/", "'", $page_content);
$page_content = preg_replace("/\\\\\"/", "\"", $page_content);
$page_content = preg_replace("/\\\\\\\\/", "\\", $page_content);
$page_title = preg_replace("/\\\'/", "'", $page_title);
$page_title = preg_replace("/\\\\\"/", "\"", $page_title);
$page_title = preg_replace("/\\\\\\\\/", "\\", $page_title);
*/
//$page_content = stripslashes($page_content);
//$page_title = stripslashes($page_title);
$data = array( "id" => $page_id,
"language" => $page_language,
"author" => $page_author,
"email" => $page_author_email,
"menu" => $page_menu,
"title" => $page_title,
"content" => $page_content,
"date" => date("F j, Y, g:i a"));
$data = serialize($data);
if (file_exists($txtfile)) unlink($txtfile);
$fp = fopen($txtfile, "a");
if ($fp) {
$fp = fwrite($fp, $this->securitymeasures . $data); // . chr(0)
chmod($txtfile, 0664);// make sure the file is actually accessible...
return true;
} else {
$this->ERRORS = "Could not save page.";
return false;
}
}
/**
* This function gets menu data
*
* @param menu_folder The menu folder as defined globally... Leftovers, stupidity
* @param menu_id The Menu menu ID
* @param language Language
*
* @return string menu menu
*/
function fetchMenuMenu
($menu_folder, $menu_id, $language = "en") {
if ($language == "") $language = "en";
if ($menu_id == 1) { //Setup
$data = "
<div class=\"menutext\"><a class=\"menutext\" href=\"" . globalIDtoURL
("setup") . "\">" . i18n
("Site setup") . "</a></div>
<div class=\"menutext\"><em>" . i18n
("Manage") . "...</em></div>
<div class=\"menutext\"><a class=\"menutext\" href=\"" . globalIDtoURL
("setup/pagesetup") . "\"> " . i18n
("Pages") . "</a></div>
<div class=\"menutext\"><a class=\"menutext\" href=\"" . globalIDtoURL
("setup/menusetup") . "\"> " . i18n
("Menus") . "</a></div>
<div class=\"menutext\"><a class=\"menutext\" href=\"" . globalIDtoURL
("setup/users") . "\"> " . i18n
("Users") . "</a></div>
<div class=\"menutext\"><a class=\"menutext\" href=\"" . globalIDtoURL
("setup/themes") . "\"> " . i18n
("Themes") . "</a></div>
<div class=\"menutext\"><a class=\"menutext\" href=\"" . globalIDtoURL
("setup/files") . "\"> " . i18n
("Files") . "</a></div>
<div class=\"menutext\"><a class=\"menutext\" href=\"" . globalIDtoURL
("setup/modulesetup") . "\"> " . i18n
("Modules") . "</a></div>
";
} else {
$txtfile = "$menu_folder/$menu_id.$language.php";
if (!file_exists($txtfile)) {
$txtfile = "$menu_folder/$menu_id.en.php";
if (!file_exists($txtfile)) {
$txtfile = "$menu_folder/$menu_id.$language.txt";
//If the language is not english but the file doesn't exist, try english anyway
if (!file_exists($txtfile)) $txtfile = "$menu_folder/$menu_id.en.txt";
}
}
$data = "";
if (file_exists($txtfile)) {
$fp = fopen($txtfile, "r");
$contents = fread($fp, filesize($txtfile));
if (substr($contents, 0, strlen($this->securitymeasures)) == $this->securitymeasures) $contents = substr($contents, strlen($this->securitymeasures));
$contents = unserialize($contents);
if (!$contents["menu"] == "" or
$menu_id == 0) { //if the menu menu exists (or if menu is 0 (default))
$data = $contents["menu"];
} else { //If the menu menu is empty, show the front page menu
$data = $this->fetchMenuMenu($menu_folder, 0);
}
fclose($fp);
} else { //If the menu menu doesn't exist, show a link to the front page
if (strlen($data) < 1) {
$data = "((" . i18n
("Front page") . "))";
}
}
}
/*
//These regular expression replaces make sure the botched up data from web forms
$data = preg_replace("/\\'/", "'", $data);
$data = preg_replace("/\\\\\"/", "\"", $data);
$data = preg_replace("/\\\\\\\\/", "\\", $data);
*/
//$data = stripslashes($data);
return $data;
}
/**
* This function gets menu title
*
* @param menu_id The Menu menu ID
* @param language Language
*
* @return string menu menu title
*/
function fetchMenuTitle
($menu_folder, $menu_id, $language = "en") {
if ($language == "") $language = "en";
if ($menu_id == 1) { //Setup
$data = i18n
("Setup");
} else {
$txtfile = "$menu_folder/$menu_id.$language.php";
if (!file_exists($txtfile)) {
$txtfile = "$menu_folder/$menu_id.en.php";
if (!file_exists($txtfile)) {
$txtfile = "$menu_folder/$menu_id.$language.txt";
//If the language is not english but the file doesn't exist, try english anyway
if (!file_exists($txtfile)) $txtfile = "$menu_folder/$menu_id.en.txt";
}
}
if (file_exists($txtfile)) {
$fp = fopen($txtfile, "r");
$contents = fread($fp, filesize($txtfile));
if (substr($contents, 0, strlen($this->securitymeasures)) == $this->securitymeasures) $contents = substr($contents, strlen($this->securitymeasures));
$contents = unserialize($contents);
if (!$contents["title"] == "" or
$menu_id == 0) { //if the menu menu exists (or if menu is 0 (default))
$data = $contents["title"];
} else { //If the menu menu is empty, show the front page menu
$data = $this->fetchMenuTitle($menu_folder, 0);
}
fclose($fp);
} else { //If the menu menu doesn't exist, show a link to the front page
if (strlen($data) < 1) {
$data = i18n
("Default");
}
}
}
return $data;
}
/**
* This function gets menu theme
*
* @param menu_folder The menu folder as defined globally... Leftovers, stupidity
* @param menu_id The Menu menu ID
* @param language Language
*
* @return string menu theme
*/
function fetchMenuTheme
($menu_folder, $menu_id, $language = "en") {
$data = "";
if ($language == "")
$language = "en";
if( $menu_id == 1 )
{ //Setup
$data = "/none/";
}
else
{
$txtfile = "$menu_folder/$menu_id.$language.php";
if (!file_exists($txtfile))
{
$txtfile = "$menu_folder/$menu_id.en.php";
if (!file_exists($txtfile))
{
$txtfile = "$menu_folder/$menu_id.$language.txt";
//If the language is not english but the file doesn't exist, try english anyway
if (!file_exists($txtfile)) $txtfile = "$menu_folder/$menu_id.en.txt";
}
}
if (file_exists($txtfile))
{
$fp = fopen($txtfile, "r");
$contents = fread($fp, filesize($txtfile));
if (substr($contents, 0, strlen($this->securitymeasures)) == $this->securitymeasures) $contents = substr($contents, strlen($this->securitymeasures));
$contents = unserialize($contents);
if ( array_key_exists( "theme", $contents ) or
$menu_id == 0)
{ //if the menu menu exists (or if menu is 0 (default))
$data = $contents["theme"];
}
else
{ //If the menu menu is empty, show the front page menu
$data = $this->fetchMenuTheme($menu_folder, 0);
}
fclose($fp);
}
else
{ //If the menu menu doesn't exist, show a link to the front page
if (strlen($data) < 1)
$data = "/none/";
}
}
return $data;
}
/**
* This function finds a free menu_id
*
* @param menu_folder The menu folder as defined globally... Leftovers, stupidity
* @param page_control The pagectl used by in the calling function
*
* @return integer page_id
*/
function getFreeMenuID
($menu_folder, $page_control) {
$menu_list = $page_control->fetchMenuMenuList($menu_folder);
// If the menu matches the default no content menu, then...
if ($menu_list == array("0" => array("id" => "100", "title" => array("Standard", "Default"), "menu" => array("", ""), "language" => array("dk", "en")))) return 100;
//This is nessecary because sort() re-names the array index
foreach($menu_list as $key => $value) {
$temp_menu_list[$value["id"]] = $menu_list[$key];
}
$menu_list = $temp_menu_list;
$array_index = 100;
while (true) {
if (!array_key_exists($array_index, $menu_list)) { //$menu_list["$array_index"]["id"] == "") {
$free_id = $array_index;
break;
}
$array_index++;
}
return $free_id;
}
/**
* Function saves Menu menu data
*
* @param menu_folder The menu folder as defined globally... Leftovers, stupidity
* @param $menu_* The part of the menu data the * says
*
* @return bool true or false
*/
function saveMenuMenu
($menu_folder, $menu_id, $menu_title, $menu_menu, $menu_language, $menu_theme) {
if ($menu_language == "") $menu_language = "en";
$txtfile_old = "$menu_folder/$menu_id.$menu_language.txt";
$txtfile = "$menu_folder/$menu_id.$menu_language.php";
if (file_exists($txtfile_old)) { rename($txtfile_old, $txtfile); }
$menu_menu = stripslashes($menu_menu);
$data = array( "id" => $menu_id,
"title" => $menu_title,
"menu" => $menu_menu,
"language" => $menu_language,
"theme" => $menu_theme);
$data = serialize($data);
if (file_exists($txtfile)) unlink($txtfile);
$fp = fopen($txtfile, "a");
if ($fp) {
$fp = fwrite($fp, $this->securitymeasures . $data); // . chr(0)
chmod($txtfile, 0664);// make sure the file is actually accessible...
return true;
} else {
$this->ERRORS = "Could not save menu menu.";
return false;
} }
function numberOfMenus
()
{
global $menu_folder;
$fp = opendir($menu_folder);
$dirarray = array();
while ($file = readdir($fp))
if( substr($file, 0, 1) != "." )
$dirarray[] = $file;
closedir($fp);
return count($dirarray);
}
/**
* Fetch list of all menu menus
*
* @return array
*/
function fetchMenuMenuList
($menu_folder, $language = "") {
//get list of all files (fill an array ($file_list) with the filenames
$fp = opendir($menu_folder);
$array_index = 0;
while ($file = readdir($fp)) {
if( substr($file, 0, 1) != "." ) {
$dirarray[$array_index] = $file;
$array_index++;
}
}
closedir($fp);
if (count($dirarray) > 0) {
//go through files one by one, load the data from them
$array_index = 0;
foreach ($dirarray as $key => $value) {
$fpn = fopen("$menu_folder/$value", "r");
$contents = fread($fpn, filesize("$menu_folder/$value"));
if (substr($contents, 0, strlen($this->securitymeasures)) == $this->securitymeasures) $contents = substr($contents, strlen($this->securitymeasures));
$contents = unserialize($contents);
if (!empty($contents["id"]))
$loaded_data = $contents;
else
$loaded_data = array();
$loaded_data = array_reverse($loaded_data);
fclose($fpn);
if ($language == "") {
$id = $loaded_data["id"];
$data["$id"]["id"] = $loaded_data["id"];
$data["$id"]["language"][] = $loaded_data["language"];
$data["$id"]["title"][] = $loaded_data["title"];
} else if ($language == $loaded_data["language"]) {
$id = $loaded_data["id"];
$data["$id"]["id"] = $loaded_data["id"];
$data["$id"]["language"] = $loaded_data["language"];
$data["$id"]["title"] = $loaded_data["title"];
}
$array_index++;
if ($array_index = 1) $array_index++; //Setup menu is 1
}
sort($data); //Sort the array after id
return $data;
} else { //There are no menu menus yet, return data to this point
return array("0" => array("id" => "100", "title" => array("Standard", "Default"), "menu" => array("", ""), "language" => array("dk", "en")));
}
}
}
//Updates the backwards page list
function update_getpage_id
($page_folder, $setup_folder, $pagectl) {
$page_list = $pagectl->fetchPageList($page_folder);
//To make sure you can navigate the standard pages as well (not standard pages)
//Front page
$page_list["0"]["id"] = 0;
$page_list["0"]["title"][] = "Forside";
$page_list["0"]["language"][] = "dk";
$page_list["0"]["title"][] = "Front page";
$page_list["0"]["language"][] = "en";
//About page
$page_list["1"]["id"] = 1;
$page_list["1"]["title"][] = "Om Travelsized CMS";
$page_list["1"]["language"][] = "dk";
$page_list["1"]["title"][] = "About Travelsized CMS";
$page_list["1"]["language"][] = "en";
//Tag wall
$page_list["2"]["id"] = 2;
$page_list["2"]["title"][] = "Tagwall";
$page_list["2"]["language"][] = "dk";
$page_list["2"]["title"][] = "Tag wall";
$page_list["2"]["language"][] = "en";
$txtfile = "$setup_folder/page_backwards.txt";
if (file_exists($txtfile)) unlink($txtfile);
$page_list = serialize($page_list);
$fp = fopen($txtfile, "a");
if ($fp) {
$fp = fwrite($fp, $page_list); // . chr(0)
chmod($txtfile, 0664);// make sure the file is actually accessible...
return true;
} else {
$this->ERRORS = "Could not update backwards page_id lookup index.";
return false;
}
}
function getPageID
( $search_page )
{
global $setup_folder;
return getpage_id
( $setup_folder, $search_page );
}
//gets $page_id by resolving $page backwards
//Returns -1 if index not found, or an array if more with the same title are found
function getpage_id
($setup_folder, $search_page) {
$txtfile = "$setup_folder/page_backwards.txt";
$fp = fopen($txtfile, "r");
if ($fp) {
$contents = fread($fp, filesize($txtfile));
$contents = unserialize($contents);
$value = $contents;
$data = array();
if (is_array($value)) {
foreach($value as $key2 => $value2) {
$value2 = $value[$key2]["title"];
if (is_array($value2)) {
foreach($value2 as $key3 => $value3) {
if (strtoupper($value2[$key3]) == strtoupper($search_page)) {
$data[] = $value[$key2];
}
}
} else {
if (strtoupper($value2) == strtoupper($search_page)) {
$data[] = $value;
}
}
}
}
if (count($data) == 0) {
$data = -1;
} else if (count($data) < 2) {
$data = "{$data[0]['id']}";
} else {
$data = array_reverse($data);
}
fclose($fp);
return $data;
} else {
$this->ERRORS = "Could not open file.";
return -1;
}
}
// The native page parsing functions
include ("page_parsefunctions.php");
// Import all the installed modules
// Modules have the page syntax \modulename(stuff)
$fp = opendir("$setup_folder/modules");
while ($file = readdir($fp)) {
if (substr($file, -4) == ".php") include("$setup_folder/modules/$file");
}
closedir($fp);
/*
* This function takes in raw page data ($page_data) and returns HTML
*
* Puts <p ></p > around all lines
* Makes links out of "(())" (remember $language)
* if (()) has the syntax "((page name||link title)), parse
* page name: link to a page with this name
* link title: show this as the link title
* Spots external links (In the following format: [[URL||Description]]). Open in a new window
* Make heading out of lines with "!", "!!" and "!!!" first on the line
* make **text**, //text// and __text__ into their HTML equivanents
* Make --- on a line of it's own into a horizontal rule
*
* Makes lists out of "* ","** " and "*** "
* Makes numbered lists out of "# ", "## " and "### "
*/
function parse_page_data
($page_data, $language = "en", $setup_folder = "setup", $is_menu_menu = false ) {
//If the page is HTML, return it without parsing
if (substr($page_data, 0, 1) == "<") return $page_data;
//This puts <p></p> around all lines and <br /> where else
//(copied straight from the PHP.net manual; thanks Matt (matt at mullenweg dot com))
$page_data = preg_replace("/(\r\n|\n|\r)/", "\n", $page_data); // cross-platform newlines
$page_data = preg_replace("/\n+/", "\n", $page_data); // take care of duplicates
$page_data = preg_replace("/\n?(.+?)(\n|\z)/s", "<p >$1</p >\n", $page_data); // make paragraphs, including one at the end
$page_data = preg_replace("/<p >([^<]*)(\s+)<\/p >/is", "<p >$1</p >", $page_data); // remove extra spaces at the end of the line
$page_data = preg_replace("/<p ><\/p >/is", "<br />", $page_data); // Just toss in <br /> tags where there is simply a line break
$count = 0; $page_data = preg_replace("/<p >!!!!!([^<]*)<\/p >/ise", "'<h6 name=\"6-' . ++\$count . '\">$1</h6>'", $page_data); //make !!!!! into heading, level 6
$count = 0; $page_data = preg_replace("/<p >!!!!([^<]*)<\/p >/ise", "'<h5 name=\"5-' . ++\$count . '\">$1</h5>'", $page_data); //make !!!! into heading, level 5
$count = 0; $page_data = preg_replace("/<p >!!!([^<]*)<\/p >/ise", "'<h4 name=\"4-' . ++\$count . '\">$1</h4>'", $page_data); //make !!! into heading, level 4
$count = 0; $page_data = preg_replace("/<p >!!([^<]*)<\/p >/ise", "'<h3 name=\"3-' . ++\$count . '\">$1</h3>'", $page_data); //make !! into heading, level 3
$count = 0; $page_data = preg_replace("/<p >!([^<]*)<\/p >/ise", "'<h2 name=\"2-' . ++\$count . '\">$1</h2>'", $page_data); //make ! into heading, level 2
$page_data = preg_replace("/{{([^<\}\{]*)\|\|([^<\}\{]*)}}/is", "<a href=\"" . siteURL
(true) . "$setup_folder/files/$1\" title=\"Download $1\">$2</a>", $page_data); //make {{filename||title}} into links to local files
$page_data = preg_replace("/\(\(\(([^<\}\{]*)\|\|([^<\}\{]*)\)\)\)/is", "<acronym class=\"description\" title=\"$1\">$2[?]</acronym>", $page_data); //make (((description||term))) into descriptions
// Images - remote files
$page_data = preg_replace("/{(http\:\/\/[^<\}\{]+)\|\|([^<\}\{]+)\|\|([^<\}\{]+)\|\|([^<\}\{]+)}/is", "<a href=\"$1\" title=\"$2\" target=\"_blank\"><img border=\"0\" src=\"$1\" alt=\"$2\" width=\"$3\" align=\"$4\" /></a>", $page_data); //make {filename||title||width||alignment} into image tags
$page_data = preg_replace("/{(http\:\/\/[^<\}\{]+)\|\|([^<\}\{]+)\|\|([^<\}\{]+)}/is", "<img border=\"0\" src=\"$1\" alt=\"$2\" style=\"float: $3;\" />", $page_data); //make {filename||title||alignment} into image tags
$page_data = preg_replace("/{(http\:\/\/[^<\}\{]+)\|\|([^<\}\{]+)}/is", "<img border=\"0\" src=\"$1\" alt=\"$2\" />", $page_data); //make {filename||title} into image tags
/* // Images - local files
$page_data = preg_replace("/{([^<\}\{]+)\|\|([^<\}\{]+)\|\|([^<\}\{]+)\|\|([^<\}\{]+)}/is", "<a href=\"$setup_folder/files/$1\" title=\"$2\" target=\"_blank\"><img border=\"0\" src=\"" . siteURL(true) . "$setup_folder/files/$1\" alt=\"$2\" width=\"$3\" align=\"$4\" /></a>", $page_data); //make {filename||title||width||alignment} into image tags
$page_data = preg_replace("/{([^<\}\{]+)\|\|([^<\}\{]+)\|\|([^<\}\{]+)}/is", "<img border=\"0\" src=\"" . siteURL(true) . "$setup_folder/files/$1\" alt=\"$2\" align=\"$3\" />", $page_data); //make {filename||title||alignment} into image tags
$page_data = preg_replace("/{([^<\}\{]+)\|\|([^<\}\{]+)}/is", "<img border=\"0\" src=\"" . siteURL(true) . "$setup_folder/files/$1\" alt=\"$2\" />", $page_data); //make {filename||title} into image tags*/
$page_data = parse_images
($page_data); // Do the images thing
$page_data = parse_tables
($page_data); // Spot tables
$page_data = parse_lists
($page_data); // Spot numerical and simple lists
$page_data = parse_wikilinks
($page_data); // Spot Wiki links
$page_data = parse_externallinks
($page_data); // Spot external links
$page_data = parse_userlist_control
($page_data); // Spot user profile controllers
$page_data = parse_profilelinks
($page_data); // Spot user profile links
$page_data = parse_preformatted
($page_data); // Spot pre-formatted text
$page_data = preg_replace("/\/\/([^\"]*?)\/\//is", "<em>$1</em>", $page_data); //make //text// into emphasized
$page_data = preg_replace("/\*\*(.*?)\*\*/is", "<b>$1</b>", $page_data); //make **text** into bold
$page_data = preg_replace("/__(.*?)__/is", "<u>$1</u>", $page_data); //make __text__ into underline
$page_data = preg_replace("/<p >---<\/p >/is", "<hr class=\"wikiline\" />", $page_data); //make --- into horizontal rules
$page_data = preg_replace("/<p >>>(.*?)<\/p >/is", "<p class=\"wikirightalign\">$1</p >", $page_data); //make >>text into right aligned text
$page_data = preg_replace("/<p >\|\|(.*?)<\/p >/is", "<p class=\"wikicenteralign\">$1</p >", $page_data); //make ||text into center aligned text
$page_data = parse_updates
($page_data); // Parse update lists
// Run through the modules and run them
global $modules;
foreach($modules as $module) {
$page_data = $module($page_data);
}
$page_data = parse_userlists
($page_data, $is_menu_menu); // Spot user list - This /must/ be done last, to avoid parsing the profile contents twice
if ($is_menu_menu) {
$page_data = str_replace("<p >", "<div class=\"menutext\">", $page_data);
$page_data = str_replace("<p class=\"wikirightalign\">", "<div class=\"menutextrightalign\">", $page_data);
$page_data = str_replace("<p class=\"wikicenteralign\">", "<div class=\"menutextcenteralign\">", $page_data);
$page_data = str_replace("</p >", "</div>", $page_data);
$page_data = str_replace("<h2", "<h2 class=\"menutext\"", $page_data);
$page_data = str_replace("<h3", "<h3 class=\"menutext\"", $page_data);
$page_data = str_replace("<h4", "<h4 class=\"menutext\"", $page_data);
$page_data = str_replace("<h5", "<h5 class=\"menutext\"", $page_data);
$page_data = str_replace("<h6", "<h6 class=\"menutext\"", $page_data);
$page_data = preg_replace("/<a ([^<]*)/is", "<a class=\"menutext\" $1", $page_data);
}
return $page_data;
}
?>