4 * SourceForge Code Snippets Repository
6 * SourceForge: Breaking Down the Barriers to Open Source Development
7 * Copyright 1999-2001 (c) VA Linux Systems
8 * http://sourceforge.net
15 require_once('../env.inc.php');
16 require_once('pre.php');
17 require_once('www/snippet/snippet_utils.php');
20 Show a detail page for either a snippet or a package
21 or a specific version of a package
24 $type = getStringFromRequest('type');
25 $id = getIntFromRequest('id');
27 if ($type=='snippet') {
29 View a snippet and show its versions
30 Expand and show the code for the latest version
33 snippet_header(array('title'=>$Language->getText('snippet_detail','title')));
35 snippet_show_snippet_details($id);
38 Get all the versions of this snippet
40 $sql="SELECT users.realname,users.user_name,snippet_version.snippet_version_id,snippet_version.version,snippet_version.post_date,snippet_version.changes ".
41 "FROM snippet_version,users ".
42 "WHERE users.user_id=snippet_version.submitted_by AND snippet_id='$id' ".
43 "ORDER BY snippet_version.snippet_version_id DESC";
45 $result=db_query($sql);
46 $rows=db_numrows($result);
47 if (!$result || $rows < 1) {
48 echo '<h3>' .$Language->getText('snippet_detail','error_no_version_found').'</h3>';
51 <h3>' .$Language->getText('snippet_detail','version_of_this_snippet').':</h3>
54 $title_arr[]= $Language->getText('snippet_detail','snippet_id');
55 $title_arr[]= $Language->getText('snippet_detail','download_version');
56 $title_arr[]= $Language->getText('snippet_detail','date_posted');
57 $title_arr[]= $Language->getText('snippet_detail','author');
58 $title_arr[]= $Language->getText('snippet_detail','delete');
60 echo $GLOBALS['HTML']->listTableTop ($title_arr);
63 get the newest version of this snippet, so we can display its code
65 $newest_version=db_result($result,0,'snippet_version_id');
67 echo $GLOBALS['HTML']->createLinkToUserHome(db_result($result, $i, 'user_name'), db_result($result, $i, 'realname'));
69 for ($i=0; $i<$rows; $i++) {
71 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td>'.db_result($result,$i,'snippet_version_id').
72 '</td><td><a href="'.$GLOBALS['sys_urlprefix'].'/snippet/download.php?type=snippet&id='.
73 db_result($result,$i,'snippet_version_id').'"><strong>'.
74 db_result($result,$i,'version').'</strong></a></td><td>'.
75 date($sys_datefmt,db_result($result,$i,'post_date')).'</td><td>'.
76 $GLOBALS['HTML']->createLinkToUserHome(db_result($result, $i, 'user_name'), db_result($result, $i, 'realname')).'</td>'.
77 '<td style="text-align:center"><a href="'.$GLOBALS['sys_urlprefix'].'/snippet/delete.php?type=snippet&snippet_version_id='.
78 db_result($result,$i,'snippet_version_id').
79 '">' . html_image("ic/trash.png","16","16",array("border"=>"0")) . '</a></td></tr>';
81 if ($i != ($rows - 1)) {
83 <tr'.$row_color.'><td colspan="5">' .$Language->getText('snippet_detail','changes_since_last_version').':<br />'.
84 nl2br(db_result($result,$i,'changes')).'</td></tr>';
88 echo $GLOBALS['HTML']->listTableBottom();
91 </p><p>'.$Language->getText('snippet_detail','download_a_raw_text').'
95 show the latest version of this snippet's code
97 $result=db_query("SELECT code,version FROM snippet_version WHERE snippet_version_id='$newest_version'");
102 <h2>'.$Language->getText('snippet_detail','latest_snippet_version').' :'.db_result($result,0,'version').'</h2>
104 <span class="snippet-detail">'. db_result($result,0,'code') .'
108 Show a link so you can add a new version of this snippet
111 <h3><a href="'.$GLOBALS['sys_urlprefix'].'/snippet/addversion.php?type=snippet&id='.htmlspecialchars($id).'"><span class="important">'.$Language->getText('snippet_detail','submit_a_new_snippet').'</span></a></h3>
112 <p>' .$Language->getText('snippet_detail','you_can_submit_a_new').'.</p>';
114 snippet_footer(array());
116 } else if ($type=='package') {
120 View a package and show its versions
121 Expand and show the snippets for the latest version
126 snippet_header(array('title'=>$Language->getText('snippet_detail','title')));
128 snippet_show_package_details($id);
131 Get all the versions of this package
133 $sql="SELECT users.realname,users.user_name,snippet_package_version.snippet_package_version_id,".
134 "snippet_package_version.version,snippet_package_version.post_date ".
135 "FROM snippet_package_version,users ".
136 "WHERE users.user_id=snippet_package_version.submitted_by AND snippet_package_id='$id' ".
137 "ORDER BY snippet_package_version.snippet_package_version_id DESC";
139 $result=db_query($sql);
140 $rows=db_numrows($result);
141 if (!$result || $rows < 1) {
142 echo '<h3>' .$Language->getText('snippet_detail','error_no_version_found').'</h3>';
145 <h3>' .$Language->getText('snippet_detail','version_of_this_package').':</h3>
148 $title_arr[]= $Language->getText('snippet_detail','package_version');
149 $title_arr[]= $Language->getText('snippet_detail','date_posted');
150 $title_arr[]= $Language->getText('snippet_detail','author');
151 $title_arr[]= $Language->getText('snippet_detail','edit_del');
153 echo $GLOBALS['HTML']->listTableTop ($title_arr);
156 determine the newest version of this package,
157 so we can display the snippets that it contains
159 $newest_version=db_result($result,0,'snippet_package_version_id');
161 for ($i=0; $i<$rows; $i++) {
163 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td><a href="'.$GLOBALS['sys_urlprefix'].'/snippet/detail.php?type=packagever&id='.
164 db_result($result,$i,'snippet_package_version_id').'"><strong>'.
165 db_result($result,$i,'version').'</strong></a></td><td>'.
166 date($sys_datefmt,db_result($result,$i,'post_date')).'</td><td>'.
167 $GLOBALS['HTML']->createLinkToUserHome(db_result($result, $i, 'user_name'), db_result($result, $i, 'realname')).'</td>'.
168 '<td style="text-align:center"><a href="'.$GLOBALS['sys_urlprefix'].'/snippet/add_snippet_to_package.php?snippet_package_version_id='.
169 db_result($result,$i,'snippet_package_version_id').
170 '">' . html_image("ic/pencil.png","20","25",array("border"=>"0")) .
171 '</a> <a href="'.$GLOBALS['sys_urlprefix'].'/snippet/delete.php?type=package&snippet_package_version_id='.
172 db_result($result,$i,'snippet_package_version_id').
173 '">' . html_image("ic/trash.png","16","16",array("border"=>"0")) . '</a></td></tr>';
176 echo $GLOBALS['HTML']->listTableBottom();
179 </p><p>' .$Language->getText('snippet_detail','download_a_raw_text').'
184 show the latest version of the package
191 <h2>' .$Language->getText('snippet_detail','latest_package_version').' : '.db_result($result,0,'version').'</h2>
194 snippet_show_package_snippets($newest_version);
197 Show a form so you can add a new version of this package
200 <h3><a href="'.$GLOBALS['sys_urlprefix'].'/snippet/addversion.php?type=package&id='.$id.'"><span class="important">' .$Language->getText('snippet_detail','submit_a_new_version').'</span></a></h3>
201 <p>' .$Language->getText('snippet_detail','you_can_submit_a_new_version_of_package').'.</p>';
203 snippet_footer(array());
205 } else if ($type=='packagever') {
207 Show a specific version of a package and its specific snippet versions
210 snippet_header(array('title'=>$Language->getText('snippet_detail','title')));
212 snippet_show_package_details($id);
214 snippet_show_package_snippets($id);
216 snippet_footer(array());
220 exit_error($Language->getText('general','error'),$Language->getText('snippet_detail','error_was_the_url_mangled'));