3 <TITLE>Templating Standards</TITLE>
7 <H3>Coding Example:</H3>
9 The following code examples demonstrate how all coding on SourceForge
10 is going to be done in the future. The first example shows the "switchbox"
11 page (taken from www/tracker/index.php) - where the various objects
12 are included, instantiated and checked for errors every step of the way.
14 Once the objects are instantiated, the template file can be included. In this
15 example, the template file is detail.php (example2).
18 #highlight_string($string);
22 // SourceForge: Breaking Down the Barriers to Open Source Development
23 // Copyright 1999-2000 (c) The SourceForge Crew
24 // http://sourceforge.net
26 // $Id: templating.php,v 1.2 2001/03/06 16:04:31 tperdue Exp $
30 // Include core objects
33 require_once(\'common/tracker/Artifact.class\');
34 require_once(\'common/tracker/ArtifactFile.class\');
37 // Verify proper params passed in
39 if ($group_id && $atid) {
42 // get the Group object
44 $group =& group_get_object($group_id);
45 if (!$group || !is_object($group) || $group->isError()) {
50 // Create the ArtifactType object
52 $ath = new ArtifactTypeHtml($group,$atid);
53 if (!$ath || !is_object($ath)) {
54 exit_error(\'Error\',\'ArtifactType could not be created\');
56 if ($ath->isError()) {
57 exit_error(\'Error\',$ath->getErrorMessage());
61 // Fusebox-like architecture
67 // users can modify their own tickets if they submitted them
68 // even if they are not artifact admins
70 $ah=new ArtifactHtml($ath,$aid);
71 if (!$ah || !is_object($ah)) {
72 exit_error(\'ERROR\',\'Artifact Could Not Be Created\');
73 } else if ($ah->isError()) {
74 exit_error(\'ERROR\',$ah->getErrorMessage());
77 // Include the template file
79 include \'../tracker/detail.php\';
90 exit_missing_params();
97 // SourceForge: Breaking Down the Barriers to Open Source Development
98 // Copyright 1999-2000 (c) The SourceForge Crew
99 // http://sourceforge.net
101 // $Id: templating.php,v 1.2 2001/03/06 16:04:31 tperdue Exp $
103 echo $ath->header(array (\'title\'=>\'Detail: \'.$ah->getID(). \' \'.$ah->getSummary()));
106 <H2>[ #<?php echo $ah->getID(); ?> ] <?php echo $ah->getSummary(); ?></H2>
108 <TABLE CELLPADDING="0" WIDTH="100%">
109 <FORM ACTION="<?php echo $PHP_SELF; ?>?group_id=<?php echo $group_id; ?>&atid=<?php echo $ath->getID(); ?>" METHOD="POST">
110 <INPUT TYPE="HIDDEN" NAME="func" VALUE="monitor">
111 <INPUT TYPE="HIDDEN" NAME="artifact_id" VALUE="<?php echo $ah->getID(); ?>">
115 if (!user_isloggedin()) {
118 <INPUT TYPE="TEXT" NAME="user_email" SIZE="20" MAXLENGTH="40">
122 <INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="Monitor">
127 <TD><B>Date:</B><BR><?php echo date( $sys_datefmt, $ah->getOpenDate() ); ?></TD>
128 <TD><B>Priority:</B><BR><?php echo $ah->getPriority(); ?></TD>
132 <TD><B>Submitted By:</B><BR><?php echo $ah->getSubmittedRealName(); ?> (<?php echo $ah->getSubmittedUnixName(); ?>)</TD>
133 <TD><B>Assigned To:</B><BR><?php echo $ah->getAssignedRealName(); ?> (<?php echo $ah->getAssignedUnixName(); ?>)</TD>
137 <TD><B>Category:</B><BR><?php echo $ah->getCategoryName(); ?></TD>
138 <TD><B>Status:</B><BR><?php echo $ah->getStatusName(); ?></TD>
143 <H3>DO NOT enter passwords or confidential information in your message!</H3>
145 <INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="SUBMIT">
153 $ath->footer(array());
157 echo '<H4>Switchbox page:</H4><P>';
159 echo highlight_string($example);
162 echo '<H4>Template page (detail.php):</H4><P>';
164 echo highlight_string($example2);