4. Templating Standards

4.1. Coding Example

4.1. Coding Example

The following code examples demonstrate how all coding on GForge is going to be done in the future. The first example shows the “switchbox” page (taken from www/tracker/index.php) - where the various objects are included, instantiated and checked for errors every step of the way.

Once the objects are instantiated, the template file can be included. In this example, the template file is detail.php (example2).

Template page
<?php
/**
 * GForge Tracker Facility
 *
 * Portions Copyright 1999-2000 (c) The SourceForge Crew
 * Copyright 2002-2004 (c) The GForge Teem
 * http://gforge.org/
 * 
 * @version $Id: templating.xml,v 1.2 2004/10/08 20:30:59 gsmet Exp $
 *
 * This file is part of GForge.
 *
 * GForge 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.
 *
 * GForge is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GForge; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  US
 */

echo $ath->header(array 
   ('title'=>'Detail: '.$ah->getID(). ' '.$ah->getSummary()));

?>
<H2>[#<?php echo $ah->getID(); ?>] <?php echo $ah->getSummary(); ?></H2>

<TABLE CELLPADDING="0" WIDTH="100%">
	<FORM ACTION="<?php echo $PHP_SELF; ?>
		?group_id=<?php echo $group_id; ?>
		&atid=<?php echo $ath->getID(); ?>" METHOD="POST">
	<INPUT TYPE="HIDDEN" NAME="func" VALUE="monitor">
	<INPUT TYPE="HIDDEN" NAME="artifact_id" 
		VALUE="<?php echo $ah->getID(); ?>">
	<TR>
		<TD COLSPAN=2">
		<?php
		if (!session_loggedin()) {
			?>
		<B>Email:</B> &nbsp;
		<INPUT TYPE="TEXT" NAME="user_email" 
			SIZE="20" MAXLENGTH="40">
		<?php
			}
			?>
		<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="Monitor">
		</FORM>
		</TD>
	</TR>
	<TR>
		<TD>
         <B>Date:</B><BR>
			<?php echo date( $sys_datefmt, 
				$ah->getOpenDate() ); ?></TD>
		<TD><B>Priority:</B><BR>
			<?php echo $ah->getPriority(); ?></TD>
	</TR>

	<TR>
		<TD><B>Submitted By:</B><BR>
			<?php echo $ah->getSubmittedRealName(); ?> 
			(<?php echo $ah->getSubmittedUnixName(); ?>)</TD>
		<TD><B>Assigned To:</B><BR>
			<?php echo $ah->getAssignedRealName(); ?>
			(<?php echo $ah->getAssignedUnixName(); ?>)</TD>
	</TR>

	<TR>
		<TD><B>Category:</B><BR>
			<?php echo $ah->getCategoryName(); ?></TD>
		<TD><B>Status:</B><BR>
			<?php echo $ah->getStatusName(); ?></TD>
	</TR>

	<TR><TD COLSPAN="2">
		<H3>DO NOT enter passwords or confidential information 
			in your message!</H3>
		<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="SUBMIT">
		</FORM>
	</TD></TR>

	</TABLE>
	</FORM>
<?php

$ath->footer(array());

?>