<?php
if (MING != "merciless") require ('index.php'); // this keeps people from executing "help.php" directly
else {
/*
Here you will find help documents on Planet Mongo.

You may either read the HTML directly here (not recommended), or point your browser at index.php?rqst=__help
to read them there (recommended).

*/


$file = new FileWrapper();
$file->title = 'Help!';
$file->directory = $content_directory;
$file->type = POWER_HTML;
$file->dont_list = TRUE;
$file->is_capable = FALSE;
$file->file_name = 'help';
main_add_magic_file ($file );
function magicfile_help ()
{
	$contents = <<<XYQ
<h2>Need help?</h2>
<em>Try some of these documents...</em>
<p>Planet Mongo guide:</p>
<ul>
	<li><a href="index.php?rqst=__help_getting_started">Getting Started with Planet Mongo</a></li>
</ul>
<p>The "10 Second Guides" take literally only ten seconds to read a piece, so check 'em out. They should give 
you enough information to get you started, and are written in the style of tutorials.</p>
<ul><i>The 10 Second Guide on...</i>
	<li><a href="index.php?rqst=__tsg_installation">...downloading and installation.</a></li>
	<li><a href="index.php?rqst=__tsg_modules">...coding your own modules.</a></li>
	<li><a href="index.php?rqst=__tsg_themes">...making your own themes.</a></li>
	<li><a href="index.php?rqst=__tsg_filenaming">...file naming in Planet Mongo.</a></li>
	<li><a href="index.php?rqst=__tsg_shorturls">...making short urls.</a></li>
</ul>
<hr />
If all else fails, head on over to <a href="http://planetmongo.sf.net">Planet Mongo's Highly Official Website</a> and 
post a whiny message in an appropriate message board.
XYQ;
	return $contents;	
}



$file = new FileWrapper();
$file->title = 'Help!';
$file->directory = $content_directory;
$file->type = POWER_HTML;
$file->dont_list = TRUE;
$file->is_capable = FALSE;
$file->file_name = 'tsg_installation';
main_add_magic_file ($file );

function magicfile_tsg_installation ()
{
	$contents = <<<XYQ

<h3>The Ten Second Guide on Downloading and Installing Planet Mongo</h3>
<ol><small><i>Prerequisite: functioning knowledge of computers</i></small>
    <li>Click <a href="http://planetmongo.sf.net/downloads.php">here</a> to see available downloads.</li>
    <li>Download the newest version of Planet Mongo. </li>
    <li>Unpack it to a location of your choice, using a utility like
    <a href="http://sevenzip.sf.net">7-zip</a>.</li>
    <li>Put all of your pages in the directory entitled "content".</li>
    <li>Open up the file called "config.php" in the directory
    called "config".</li>
    <li>Follow the instructions contained in this file on how to configure
    Planet Mongo.</li>
    <li>Customize all of the settings to your heart's content.</li>
    <li>Upload the entire Planet Mongo folder and all of it's sub-folders to
    your server.</li>
    <li>Upload the entire Planet Mongo folder and all of it's sub-folders to
    your server.</li>
    <li>Point your browser to where you uploaded Planet Mongo and enjoy!</li>
</ol>
<p>Welcome to the Planet! Click around a bit. This Ten Second guide, and all
other important documentation is included with your Planet Mongo distribution
for your convenience. It should be accessable via a link in the "Welcome" page.
The "Welcome" page is the first page you see when you look first load Planet
Mongo, unless you removed the file entitled "welcome.index.html" found in the
"content" directory, or added a file containing the text "index" to your
content directory.</p>

XYQ;
	return $contents;
}


$file = new FileWrapper();
$file->title = 'Help!';
$file->directory = $content_directory;
$file->type = POWER_HTML;
$file->dont_list = TRUE;
$file->is_capable = FALSE;
$file->file_name = 'tsg_themes';
main_add_magic_file ($file );
function magicfile_tsg_themes ()
{
	$contents = <<<XYQ
<h3>The Ten Second Guide on Making Your Own Themes</h3>
<ol><small><i>Prerequisite: basic knowledge of HTML</i></small>
    <li>Write the HTML for your theme.</li>
    <li>Save it as "theme.php" in a folder bearing your theme's name.</li>
    <li>Put that folder in the "theme" directory.</li>
    <li>All image URL's should be relative to Planet Mongo's base directory.
    </li>
    <li>Thus, an image tag might look like:
    <code>&lt;img src="themes/my_theme/img.gif" /&gt;</code>.
    <li>Insert <code>&lt;!--[[ content: main ]]--&gt;</code> where you want the
    content to be displayed.</li>
    <li>Insert <code>&lt;!--[[ theme: link_box ]]--&gt;</code> where the
    navigational links go.</li>
    <li>Insert <code>&lt;!--[[ theme: footer ]]--&gt;</code> where the
    copyright footer goes.</li>
    <li>Insert <code>&lt;!--[[ theme: head ]]--&gt;</code> anywhere in your
    theme's head.</li>
    <li>Open "config.php" in the "config" directory to change to
    your new theme.</li>
</ol>
<p>And there you have it! You've just made your first theme! Everything should
be working flawlessly. If you want to change what links are displayed in the
linkbox, that is done in the "config.php" file. Or, if you want,
you can skip step 7 altogether and just manually insert your links.</p>
<p>
Remember, nearly any file, and almost every bit of text
in Planet Mongo can be interpretted as PHP, theme files included. In other
words, this "easy-theme" system is not sacrificing any power of a more
complicated theme system, as do some systems such as the AutoTheme 
module for postnuke or PHP-Nuke.</p>

XYQ;
	return $contents;
}

$file = new FileWrapper();
$file->title = 'Help!';
$file->directory = $content_directory;
$file->type = POWER_HTML;
$file->dont_list = TRUE;
$file->is_capable = FALSE;
$file->file_name = 'tsg_shorturls';
main_add_magic_file ($file );
function magicfile_tsg_shorturls ()
{
	$contents = <<<XYQ

<h3>The Ten Second Guide on Using Short URLs</h3>
<ol><small><i>Prerequisite: basic understanding of computers and filesystems</i>
	<li>Short URLs are those URLs without complicated GET variables.</li>
	<li>'http://mysite.com/news.php' is a Short URL, while 'http://mysite.com/index.php?rqst=news' is not.</li>
	<li>Currently, in Planet Mongo, Short URLs must be enable individually for each file by hand.</li>
	<li>Short URLs are easier to remember, and look nicer.</li>
	<li>To make your own Short URL, create a file with the desired name and a '.php' file exension (e.g. 'news.php')</li>
	<li>Then, copy into your new file the following PHP code:
<blockquote><code>
\$content_request = '[file_name]';<br />
require ('index.php');
</code></blockquote></li>
	<li>Change the [file_name] text to equal the name or a part of the name of your content file (e.g. 'news')</li>
	<li>Save the file.</li>
	<li>On a Unix server, you might need to chmod your new file to permit execution.</li>
	<li>Point your browser to your new Short URL to test it out.</li>
</ol>
<p>
It's really that easy. That code will create a "short url" php file. For
example, if you replace 'file_name' with 'news.php', running the file will be
the same as if you visited the URL 'index.php?rqst=news.php'. This file should
be placed in the same directory as 'index.php', and named as a PHP file. <br />
</p>
<p>This is what occurs: when the content module loads and the request GET variable
is empty, then it checks to see if there is anything stored in the global
variable <code>\$content_request</code>. If something is stored in that
variable, then it uses that as the request instead. So, all that the short url
does is just require 'index.php' and throw a different request at the content
module. Enjoy!</p>

XYQ;
	return $contents;
}

$file = new FileWrapper();
$file->title = 'Help!';
$file->directory = $content_directory;
$file->type = POWER_HTML;
$file->dont_list = TRUE;
$file->is_capable = FALSE;
$file->file_name = 'tsg_filenaming';
main_add_magic_file ($file );
function magicfile_tsg_filenaming ()
{
	$contents = <<<XYQ

<h3>The Ten Second Guide on File Naming and Planet Mongo Keywords</h3>
<ol><small><i>Prerequisite: basic understanding of computers and filesystems</i>
</small>
    <li>The filename of every file in Planet Mongo tells Plant Mongo how to
    treat it.</li>
    <li>These options are set via a series of "keywords" seperated by dots.</li>
    <li>The first keyword is always the title of the file.</li>
    <li>Planet Mongo will display the title in proper case and will replace
    underscores with spaces.</li>
    <li>The other keywords can come in any order, each separated with a period.
    <li><code>php</code> will allow that file to be evaluated as PHP code.</li>
    <li><code>html</code> will only permit HTML.</li>
    <li><code>bb</code> signifies that the file uses BBCode, an easier form of
    HTML.</li>
    <li>PMCMS will not show files with <code>nolist</code> when it automatically
    lists files.</li>
    <li>Use <code>index</code> to make a content file the default file to be
    served.</li>
</ol>
<p>Now you can specify options in your content files with ease! For example, a
file named <code>site_introduction.index.nolist.php</code> will have the
title of "Site Introduction", it will be served first when no other page is
requested (much like index.html is traditionally served first), it will not be
listed whenever files are automatically listed, and it will be evaluated as a
PHP file. It's that easy! It should be noted that all of these keywords can be
changed and configured in the "config.php" configuration file in the
"config" directory. Also, it is usually good practice to put the file
extension at the end of the file name. Otherwise, if a ambitious individual
were to try to access the file directly, your server may serve the contents of
your file in an inappropriate manner, possibly revealing a security hole.
Another important note is that the "index" keyword may appear as the title or
part of the title. Thus, files named "index.html" or "site_index.html" will be
also be served by default.
</p>

XYQ;
	return $contents;
}

$file = new FileWrapper();
$file->title = 'Help!';
$file->directory = $content_directory;
$file->type = POWER_HTML;
$file->dont_list = TRUE;
$file->is_capable = FALSE;
$file->file_name = 'tsg_modules';
main_add_magic_file ($file );

function magicfile_tsg_modules ()
{
	$contents = <<<XYQ
<h3>The Ten Second Guide on Writing Your Own Modules</h3>
<ol><small><i>Prerequisite: basic knowledge of PHP</i></small>
    <li>Modules in Planet Mongo are activated by this text: <code>
    &lt;!--[[ module_name : module_function : argument ]]--&gt; </code></li>
    <li>With that in mind, decide on a unique name and list a few functions
    for your module.</li>
    <li>Code those functions.</li>
    <li>For best conformity, use the function "outblurt" instead of "eval" or
    "echo".</li>
    <li>"outblurt" takes a string (the text) and an optional integer argument
    which specifies the "power" of the text.
    </li>
    <li>You might use <code>POWER_PHP</code>, <code>POWER_BB</code>, or
	<code>POWER_HTML</code> (default) for the second argument.</li>
    <li>Name your new functions like this:
    <code>[modname]_[function_name]_doaction( \$argument )</code></li>
    <li>Example: a function for a picture gallery (picgal) might look like this:
    <code>picgal_display_gallery_doaction ( \$directory )</code></li>
    <li>Place a .php file containing those functions in the "modules" directory.
    </li>
    <li>Place a .php file containing the configuration variables in the "config"
    directory, and add it to the \$header_first_includes array in header.php.</li>
</ol>
<p>
It's that easy! Now all you have to do is use <code>
&lt;!--[[ your_mod_name : your_mod_function : [optional argument] ]]--&gt;
</code>
almost anywhere text is to be displayed in Planet Mongo, and that function of
your module will be activated! Also, if you used outblurt, the text processed
by your function will also be able to activate modules! Not only that, once
the web administration module is completed, Planet Mongo will automatically
offer a web interface to configure your module by finding all of the variables
defined in your config file and displaying them as an appropriate HTML
input!</p>

XYQ;
	return $contents;
}


$file = new FileWrapper();
$file->title = 'Help! BBCode Reference';
$file->directory = $content_directory;
$file->type = POWER_HTML;
$file->dont_list = TRUE;
$file->is_capable = FALSE;
$file->file_name = 'help_bbcode';
main_add_magic_file ($file );

function magicfile_help_bbcode ()
{
	$contents = <<<XYQ
BBCode:
<table>
	<tr><th>code</th></th><th>effect</th></tr>
	<tr><td>[b]text[/b]</td><td><strong>text</strong></td></tr>
	<tr><td>[i]text[/i]</td><td><em>text</em></td></tr>
	<tr><td>[u]text[/u]</td><td><span style="border-bottom: 1px dotted">text</span></td></tr>
	<tr><td>[strike]text[/strike]</td><td><strike>text</strike></td></tr>
	<tr><td>[img]http://www.w3.org/Icons/valid-xhtml10[/img]</td><td><img src="http://www.w3.org/Icons/valid-xhtml10" alt="" style="border:0px;" /></td></tr>
	<tr><td>http://gogole.com/</td><td><a href="http://google.com/">http://gogole.com/</a></td></tr>
	<tr><td>[url]http://gogole.com/[/url]</td><td><a href="http://google.com/">http://gogole.com/</a></td></tr>
	<tr><td>[url=http://gogole.com/]Google[/url]</td><td><a href="http://google.com/">Google</a></td></tr>
</table>	
XYQ;
	return $contents;
}



$file = new FileWrapper();
$file->title = 'Help! Quick PHP Tutorial';
$file->directory = $content_directory;
$file->type = POWER_HTML;
$file->dont_list = TRUE;
$file->is_capable = FALSE;
$file->file_name = 'help_php';
main_add_magic_file ($file);

function magicfile_help_php ()
{
	$contents = <<<XYQ
	<h1>Quick PHP Tutorial</h1>
<p>Taken from Rich Payne's <a href="http://wiki.gnhlug.org/twiki2/pub/Www/PresentPHP1/index1.phppage_numb1">website</a></p>
<center><h3>Basic Syntax</h3>

<table width=70%>
<tr>
	<td><font size="+1">From HTML to PHP</font></td>

</tr>
<tr>
	<td>
	<ul>
		<li>PHP ignores everything <strong>not</strong> inside the &#60;?php &nbsp &nbsp ?&#62; tags.</li>
		<li>You can rename all of your .html file to .php files and nothing will change.</li>

	</ul>
	</td>
</tr>
<tr>
	<td><font size="+1">Syntax</font></td>
</tr>
<tr>
	<td>
	
	 Statements terminated by either a semicolon or the closing tag.
		<table width=100%>
			<tr>

			<td bgcolor="#E0E0E0"><pre>
&#13;&#60;?php
	echo "This is a test";
?&#62; 

&#60;?php echo "This is a test" ?&#62; 
			</pre>
			</td>
			</tr>
		</table>
	</td>
</tr>
<tr>

	<td><font size="+1">Comments</font></td>
</tr>
<tr>
	<td>
	<table width=100%>
		<tr>
		<td bgcolor="#e0e0e0"><pre>
&#60;?php 
	// This is a one-line c++ style comment

	/* This is
		a multi line comment */
?&#62;
		</pre>

		</td>
		</tr>
	</table>
	</td>

</tr>

</table>
</center>

<center><h3>Types and Variables</h3>

<table width=80% border=0>
<tr>
	<td><font size="+1">Types</font>

	<ul>
	<li>boolean
    	<li>integer
	<li>floating-point number (double)
    	<li>string
	<li>array
	<li>object
	<li>resource
	<li>NULL
	</ul></td>
</tr>
<tr><td align=center>
	<table width=90% border=0>
	<tr>

	<td bgcolor="#e0e0e0"> The type of a variable is usually not set by the programmer; rather, it is decided at runti	me by PHP depending on the context in which that variable is used.
	<p>
	If you would like to force a variable to be converted to a certain type, you may either cast the 	variable or use the settype() function on it.
	<p>
	 PHP does not require (or support) explicit type definition in variable declaration; a variable's type is determined by the context in which that variable is used. That is to say, if you assign a string value to variable <i>var, var</i> becomes a string. If you then assign an integer value to var, it becomes an integer.<p>

	</td>
	</tr>

	</table>
</td></tr>

<tr>

	<td><font size="+1">Variables</font>
	<ul>
	<li> Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive.
	<li>Starting with PHP4 variables can be passed to function by value or by reference:
	</ul>
	</td>

</tr>
<tr>
	<td align=center>
	<table width =90%>
		<tr><td bgcolor="#e0e0e0">
<pre>
&#13;&#60;?php

	// Pass by value
	call_function (\$var1, \$var2);

	// Pass by reference
	call_function (&\$var1, &\$var2);

?&#62;
</pre>
	</td></tr>
	</table>

	</td>

</tr>	
</table>\
<h3><center>Functions</h3>
<table>
<tr>
	<td><font size="+1">User Functions</font></td>

	</tr>
	<tr>
	<td><pre>
function foo (\$arg_1, \$arg_2) {
    echo "Example function.\n";
}
	</pre>
	</td>
</tr>
<tr>
	<td><font size="+1">Returning Variables</fonr></td>
</tr>
<tr>

	<td><pre>
function foo (\$arg_1, \$arg_2) {
    echo "Example function.\n";
    return \$arg_1;
}

\$answer=foo(\$a,\$b);
echo \$answer;
	</pre>
	</td>
</tr>
<tr>
	<td><font size="+1">Variable Functions</td>
</tr>
<tr>
	<td><pre>

function foo() {
    echo "In foo()<br>\n";
}

function bar( \$arg = '' ) {
    echo "In bar(); argument was '\$arg'.<br>\n";
}

\$func = 'foo';
\$func();
\$func = 'bar';
\$func( 'test' );

	</pre>

	</td>
</tr>

</table>

XYQ;
	return $contents;
}


$file = new FileWrapper();
$file->title = 'Help! Getting Started';
$file->directory = $content_directory;
$file->type = POWER_HTML;
$file->dont_list = TRUE;
$file->is_capable = FALSE;
$file->file_name = 'help_getting_started';
main_add_magic_file ($file);

function magicfile_help_getting_started ()
{
	$contents = <<<XYQ
	<pre>
 ____  _                  _     __  __                         
|  _ \| | __ _ _ __   ___| |_  |  \/  | ___  _ __   __ _  ___  
| |_) | |/ _` | '_ \ / _ \ __| | |\/| |/ _ \| '_ \ / _` |/ _ \ 
|  __/| | (_| | | | |  __/ |_  | |  | | (_) | | | | (_| | (_) |
|_|   |_|\__,_|_| |_|\___|\__| |_|  |_|\___/|_| |_|\__, |\___/ 
         The Transparent Content Manager           |___/v0.04a

This is a quick outline that will explain everything you need to 
know in order to use Planet Mongo effectively.

Installation
	0. Extract all files to directory on server (it would seem that 
		you already did this).
				You're done! If everything was 
				completed successfully, pointing 
				your browser at index.php should 
				result in a friendly welcome page!
		
		If you are planning on using the web-based content and news 
		editor, then also do the following:
	1. Open up "config/config.php" and change the \$main_salt 
		variable to something else. Since, unlike a password, a 
		salt is just used internally, you'll never be asked to 
		remember this. That means you can just mash random keys, 
		and make it as difficult as possible.
	2. You probably also want to set the \$editor_enabled variable 
		to equal TRUE.
	3. Open up "config/users.php" and change the password for the 
		administrator account. Just use the two example users 
		listed there as templates for adding your own.
	4. Point your browser at index.php?rqst=__page_editor to 
		start using the web-based content editor.
		
* Planet Mongo might be a little different than what you'd expect
	0. Planet Mongo focuses on the simplest possible use of a 
		content manager: putting a "theme" together with a page 
		of "content".
	1. Although Planet Mongo contains modules for things like 
		a blog, users, and other such features, they are only 
		invoked within "a page" of content using a Planet Mongo 
		command.

* Understanding Planet Mongo commands
	0. Planet Mongo is based on these things called "Planet Mongo" 
		commands.
	1. A Planet Mongo command looks like this:
		&lt;!--[[ comment : main : feedback ]]--&gt;
	2. The first item is the module name. The second item specifies 
		which module function you want to use.
	3. The third item is a (usually) optional argument. In the 
		case of the "comment:main" command, the third item is 
		the name of the database to read comments from and write 
		new comments to.
	4. A file that, when displayed by Planet Mongo, will interpret 
		Planet Mongo commands, is called a "capable" file. By 
		default files in the "content" and in the "theme" 
		directories are capable.
	5. Use the 'capable' and 'uncapable' filename keywords to 
		make a file that is ordinarily (see the filename 
		keywords section).

* Making your own theme
	0. Probably the first thing you wanna do after an installation is 
		make your own theme.
	1. It's uber easy.
	2. You can open up "themes/template.html" as an example.
	3. As you can see, you don't even need to know any PHP to write a 
		theme! The entire theme is contained right there in the HTML 
		file!
	4. Also, as you can see, the theme is simply a series of Planet 
		Mongo commands separated by HTML (see the previous section).
	5. The important Planet Mongo commands for a theme are the 
		following:		
			&lt;!--[[ theme : head ]]--&gt;
				(put this somewhere between &lt;head&gt; and &lt;/head&gt;)
			&lt;!--[[ theme : site_title ]]--&gt; 
				(displays the title of your site, as specified by 
				\$main_site_title in config.php) ***
			&lt;!--[[ content : page_title ]]--&gt;
				(displays the title of the current page that the 
				user is looking at)
			&lt;!--[[ theme : link_box ]]--&gt; 
				(displays the navigation, as specified by the
				\$theme_link_box variable in config.php) ***
			&lt;!--[[ content : main ]]--&gt;
				(displays the page content)
			&lt;!--[[ theme : footer ]]--&gt;			
				(displays the copyright line) ***
	6. You may have noticed the curious *** in the previous list.
		The commands marked with *** are commands that you may 
		prefer not to use and instead just hard-code such things 
		into your theme, since it is likely you want to use your 
		theme only for one website. With Planet Mongo hackability 
		is expected, and respected, and effected, and elected.

* Adding content
	0. Now that you have your theme installed and customized, its 
		time to add content.
	1. All you need to do is put it in the "content" directory.
	2. News articles go in the "news" directory.
	3. When adding pages such as these, you should keep in mind the 
		file-name keywords (explained in next section).

* File-naming
	0. The file name of every file in Planet Mongo tells how to treat 
		it.
	1. These options are set via a series of "keywords" separated by 
		dots, such as "welcome.index.html".
	2. The first keyword is always the title. Unless the title is in 
		mixed case, the title will be automatically formatted into 
		proper case. Thus, "my_page_of_links.html" will become
		"My Page of Links".
	3. A keyword that is entirely a number will be assumed to be a 
		date, in the Unix time-stamp format. This is useful for 
		dating news articles, although it can be used for other files 
		also.
	4. Several file extensions are also recognized by Planet Mongo:
		php: file will be executed as a PHP file
		html: file will be outputted without modification
		bb: file will be interpreted as BBCode and translated into 
			HTML before being outputted
		txt: file will be outputted in a fixed-width font
	5. A few other handy keywords:
		index: serves this file first when your page is visited
		capable: allows a file that is not ordinarily capable of 
			interpreting Planet Mongo commands to interpret 
			Planet Mongo commands
		uncapable: (inverse of above)
		nolist: doesn't list the file when automatically listing 
			files
		error404: use this file as a custom 404 error page, when 
			a non-existent file is requested


There! You're ready to use Planet Mongo! Have fun!
</pre>
XYQ;
	return $contents;
}

}
?>
