[Cs-content-commits] SF.net SVN: cs-content:[386] trunk/1.0
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-06-01 14:50:02
|
Revision: 386 http://cs-content.svn.sourceforge.net/cs-content/?rev=386&view=rev Author: crazedsanity Date: 2009-06-01 14:49:57 +0000 (Mon, 01 Jun 2009) Log Message: ----------- Remove old code & consolidate how errors are displayed + use of APPURL. /contentSystem.class.php: * MAIN::: -- removed code that set SITE_ROOT globally * initialize_locals(): -- add APPURL as a template var, if it is defined. * die_gracefully(): -- push the message_box template into the 404 template and set all of the required template vars to make it appear properly. * add_template(): -- removed some debug_print() statements. /sample_files/: * updated 404 template to have a template var to stuff message_box into * update system templates to prefix image refs with {APPURL} * removed old templates (construction & db_error) * added images required to display message box. Modified Paths: -------------- trunk/1.0/contentSystem.class.php trunk/1.0/sample_files/templates/system/404.shared.tmpl trunk/1.0/sample_files/templates/system/message_box.tmpl Added Paths: ----------- trunk/1.0/sample_files/public_html/images/ trunk/1.0/sample_files/public_html/images/clear.gif trunk/1.0/sample_files/public_html/images/frame/ trunk/1.0/sample_files/public_html/images/frame/crn-white-bl.gif trunk/1.0/sample_files/public_html/images/frame/crn-white-br.gif trunk/1.0/sample_files/public_html/images/frame/crn-white-tl.gif trunk/1.0/sample_files/public_html/images/frame/crn-white-tr.gif Removed Paths: ------------- trunk/1.0/sample_files/templates/system/construction.content.tmpl trunk/1.0/sample_files/templates/system/db_error.tmpl Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-05-31 21:22:05 UTC (rev 385) +++ trunk/1.0/contentSystem.class.php 2009-06-01 14:49:57 UTC (rev 386) @@ -63,13 +63,6 @@ * |--> /includes/content/members/test.inc */ -//TODO: remove this terrible little hack. -if(!isset($GLOBALS['SITE_ROOT'])) { - //define where our scripts are located. - $GLOBALS['SITE_ROOT'] = $_SERVER['DOCUMENT_ROOT']; - $GLOBALS['SITE_ROOT'] = str_replace("/public_html", "", $GLOBALS['SITE_ROOT']); -} - require_once(dirname(__FILE__) ."/abstract/cs_content.abstract.class.php"); require_once(dirname(__FILE__) ."/cs_fileSystem.class.php"); require_once(dirname(__FILE__) ."/cs_session.class.php"); @@ -157,6 +150,11 @@ } $this->templateObj->add_template_var('CURRENT_URL', $myUrl); + if(defined('APPURL')) { + //set the APPURL as a template var. + $this->templateObj->add_template_var('APPURL', constant('APPURL')); + } + //create a fileSystem object for templates. $tmplBaseDir = constant('SITE_ROOT') .'/templates'; if(defined('TMPLDIR')) { @@ -730,7 +728,14 @@ if($this->templateObj->template_file_exists('system/404.shared.tmpl')) { //Simple "Page Not Found" error... show 'em. $this->templateObj->add_template_var('main', $this->templateObj->file_to_string('system/404.shared.tmpl')); - $this->templateObj->add_template_var('details', $details); + + //add the message box & required template vars to display the error. + $this->templateObj->add_template_var('content', $this->templateObj->file_to_string('system/message_box.tmpl')); + $this->templateObj->add_template_var('messageType', 'fatal'); + $this->templateObj->add_template_var('title', "Fatal Error"); + $this->templateObj->add_template_var('message', $details); + + $this->templateObj->add_template_var('datetime', date('m-d-Y H:i:s')); $this->templateObj->print_page(); exit; @@ -917,12 +922,9 @@ //------------------------------------------------------------------------ private final function add_template($var, $file, $allowIndex=false) { if($var == 'index' && $allowIndex !== true) { - $this->gfObj->debug_print(__METHOD__ .": set index invalidly (". $file ."), IGNORED"); + //$this->gfObj->debug_print(__METHOD__ .": set index invalidly (". $file ."), IGNORED"); } else { - if(isset($this->templateList[$var])) { - $this->gfObj->debug_print(__METHOD__ .": REPLACING [". $var ."], was (". $this->templateList[$var] .") with (". $file .")"); - } $this->templateList[$var] = $file; } }//end add_template() Added: trunk/1.0/sample_files/public_html/images/clear.gif =================================================================== (Binary files differ) Property changes on: trunk/1.0/sample_files/public_html/images/clear.gif ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/1.0/sample_files/public_html/images/frame/crn-white-bl.gif =================================================================== (Binary files differ) Property changes on: trunk/1.0/sample_files/public_html/images/frame/crn-white-bl.gif ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/1.0/sample_files/public_html/images/frame/crn-white-br.gif =================================================================== (Binary files differ) Property changes on: trunk/1.0/sample_files/public_html/images/frame/crn-white-br.gif ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/1.0/sample_files/public_html/images/frame/crn-white-tl.gif =================================================================== (Binary files differ) Property changes on: trunk/1.0/sample_files/public_html/images/frame/crn-white-tl.gif ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/1.0/sample_files/public_html/images/frame/crn-white-tr.gif =================================================================== (Binary files differ) Property changes on: trunk/1.0/sample_files/public_html/images/frame/crn-white-tr.gif ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Modified: trunk/1.0/sample_files/templates/system/404.shared.tmpl =================================================================== --- trunk/1.0/sample_files/templates/system/404.shared.tmpl 2009-05-31 21:22:05 UTC (rev 385) +++ trunk/1.0/sample_files/templates/system/404.shared.tmpl 2009-06-01 14:49:57 UTC (rev 386) @@ -8,37 +8,11 @@ --> <head> <title>Page Not Found</title> + <link rel="stylesheet" href="{APPURL}/css/site.css" type="text/css"> </head> <body> <table border=0 cellpadding=0 cellspacing=0 width="90%" align="center"> -<tr> - <!-- This row should span across the page. --> - - <td align="center" colspan=2> - <table border="0" cellpadding="0" cellspacing="0" width="100%"> -<tbody><tr> - <td align="center"> - <font face="Georgia, Times New Roman, Times, serif"> - - <table border="0" cellpadding="3" cellspacing="0"> - <tbody><tr valign="middle"> - <td align="right">Crazed</td> - <td align="center" width="118"><img border="0" src="http://crazedsanity.com/images/dev-logo.gif?from=404" width="118" width="67"></td> - - <td align="left">Sanity</td> - </tr> - <tr> - <td colspan="3" align="center"> - Dot Com<BR> - </td> - </tr> - </tbody></table> - - </font> - - </td> -</tr> <TR> <td align="center"><!-- This row should span across the page. --><hr>{datetime}<hr></td> </TR> @@ -46,23 +20,14 @@ <tr> <td> - Could not find the page requested...<BR> - <pre>{details}</pre> + + + {content} + + + </td> </tr> - <tr> - <td> - <hr> - <div align="center"><font size="1"> - All content is ©opyright CrazedSanity - Computer Industries, 1998-2007. <br> - CrazedSanity Computer Industries is a division of <a href="http://unlimited.buzzkill.org">BuzzKill - Productions Unlimited ®</a>. All rights reserved. <br> - For questions, to report a problem, or to offer your first born child as a sacrifice, - contact <a href="mailto:webmaster@127.0.0.1">webmaster -at- crazedsanity.com</a>.</font><br><br> -</div> - </td> - </tr> - </table> +</table> </body> </html> Deleted: trunk/1.0/sample_files/templates/system/construction.content.tmpl =================================================================== --- trunk/1.0/sample_files/templates/system/construction.content.tmpl 2009-05-31 21:22:05 UTC (rev 385) +++ trunk/1.0/sample_files/templates/system/construction.content.tmpl 2009-06-01 14:49:57 UTC (rev 386) @@ -1,5 +0,0 @@ -<!-- BEGIN content/construction_content.tmpl --> - <h2 align="center"><br> - <br> - It's broken. I don't know what to say, dude. -<!-- END content/construction_content.tmpl --> Deleted: trunk/1.0/sample_files/templates/system/db_error.tmpl =================================================================== --- trunk/1.0/sample_files/templates/system/db_error.tmpl 2009-05-31 21:22:05 UTC (rev 385) +++ trunk/1.0/sample_files/templates/system/db_error.tmpl 2009-06-01 14:49:57 UTC (rev 386) @@ -1,47 +0,0 @@ -<HTML> -<HEAD> - <title>CS - Database Error</title> -</HEAD> - -<body bgcolor="white" text="#666666" link="#006666" vlink="#006666" alink="#006666"> -<table border="0" cellpadding="0" cellspacing="0" width="100%"> -<tr><!-- This row should span across the page. --> - <td align="center"> - <font face="Georgia, Times New Roman, Times, serif"> - <table border=0 cellpadding=3 cellspacing=0> - <TR> - <td>Crazed</td> - <td><img border=0 src="/images/dev-logo.gif"></td> - <td>Sanity</td> - </TR> - <TR> - <td colspan="3" align="center">Dot Com</td> - </TR> - </table> - </font> - </td> -</tr> -</table> - -<hr> - -<!-- BEGIN excuse --> -<p align="center">If you're seeing this, that means something pretty bad is happening.<BR> -Either the database went down, or bigger issues have arisen.<BR> -Check back in awhile.</p> -<!-- END excuse --> - - - <hr> -<center> -<font size="1"> - <a href="http://www.buzzkill.org/"><img src="/images/Bk3dtext.jpg" width="474" height="40" border="0"></a><BR> -All content is copyright CrazedSanity.com, 1998-2004. <br> - CrazedSanity.com is a division of -<a href="http://www.buzzkill.org/">BuzzKill Productions Unlimited ®</a>. All rights reserved. <br> - For questions or to report a problem, contact -<a href="?emailLink=spam" onClick="invalidEmailLink('webmaster')">webmaster at crazedsanity dot com</a>.</font> -</center> -</body> - -</HTML> Modified: trunk/1.0/sample_files/templates/system/message_box.tmpl =================================================================== --- trunk/1.0/sample_files/templates/system/message_box.tmpl 2009-05-31 21:22:05 UTC (rev 385) +++ trunk/1.0/sample_files/templates/system/message_box.tmpl 2009-06-01 14:49:57 UTC (rev 386) @@ -1,12 +1,12 @@ -<!-- *** MESSAGE_BOX START (/help/messages/message_box.tmpl) *** --> +<!-- *** MESSAGE_BOX START (/system/message_box.tmpl) *** --> <table border="0" cellspacing="0" cellpadding="0" align="center"> <tr> - <td class="{messageType}" width="5" align="left" valign="top"><img src="/images/frame/crn-white-tl.gif" width="5" height="5" alt=""></td> - <td class="{messageType}"><img src="/images/clear.gif" width="20" height="2" alt=""></td> - <td class="{messageType}" width="5" align="right" valign="top"><img src="/images/frame/crn-white-tr.gif" width="5" height="5" alt=""></td> + <td class="{messageType}" width="5" align="left" valign="top"><img src="{APPURL}/images/frame/crn-white-tl.gif" width="5" height="5" alt=""></td> + <td class="{messageType}"><img src="{APPURL}/images/clear.gif" width="20" height="2" alt=""></td> + <td class="{messageType}" width="5" align="right" valign="top"><img src="{APPURL}/images/frame/crn-white-tr.gif" width="5" height="5" alt=""></td> </tr> <tr> - <td class="{messageType}" width="5"><img src="/images/clear.gif" width="5" height="20" alt=""></td> + <td class="{messageType}" width="5"><img src="{APPURL}/images/clear.gif" width="5" height="20" alt=""></td> <td> <table class="{messageType}" width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> @@ -16,14 +16,14 @@ {redirect} </td> </tr> </table></td> - <td class="{messageType}" width="5"><img src="/images/clear.gif" width="5" height="20" alt=""></td> + <td class="{messageType}" width="5"><img src="{APPURL}/images/clear.gif" width="5" height="20" alt=""></td> </tr> <tr> - <td class="{messageType}" width="5" align="left" valign="bottom"><img src="/images/frame/crn-white-bl.gif" width="5" height="5" alt=""></td> - <td class="{messageType}"><img src="/images/clear.gif" width="20" height="2" alt=""></td> - <td class="{messageType}" width="5" align="right" valign="bottom"><img src="/images/frame/crn-white-br.gif" width="5" height="5" alt=""></td> + <td class="{messageType}" width="5" align="left" valign="bottom"><img src="{APPURL}/images/frame/crn-white-bl.gif" width="5" height="5" alt=""></td> + <td class="{messageType}"><img src="{APPURL}/images/clear.gif" width="20" height="2" alt=""></td> + <td class="{messageType}" width="5" align="right" valign="bottom"><img src="{APPURL}/images/frame/crn-white-br.gif" width="5" height="5" alt=""></td> </tr> </table> <br> -<!-- *** MESSAGE_BOX END (/help/messages/message_box.tmpl) *** --> +<!-- *** MESSAGE_BOX END (/system/message_box.tmpl) *** --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |