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'=>_('Snippet Library')));
35 snippet_show_snippet_details($id);
38 Get all the versions of this snippet
40 $sql="SELECT users.realname,users.user_name,users.user_id,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>' ._('Error - no versions found').'</h3>';
51 <h3>' ._('Versions Of This Snippet:').'</h3>
54 $title_arr[]= _('Snippet ID');
55 $title_arr[]= _('Download Version');
56 $title_arr[]= _('Date Posted');
57 $title_arr[]= _('Author');
58 $title_arr[]= _('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 for ($i=0; $i<$rows; $i++) {
69 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td>'.db_result($result,$i,'snippet_version_id').
71 util_make_link ('/snippet/download.php?type=snippet&id='.db_result($result,$i,'snippet_version_id'),'<strong>'. db_result($result,$i,'version').'</strong>').'</td><td>'.
72 date(_('Y-m-d H:i'),db_result($result,$i,'post_date')).'</td><td>'.
73 util_make_link_u (db_result($result, $i, 'user_name'), db_result($result, $i, 'user_id'),db_result($result, $i, 'realname')).'</td>'.
74 '<td style="text-align:center"><a href="'.util_make_url ('/snippet/delete.php?type=snippet&snippet_version_id='.db_result($result,$i,'snippet_version_id')).'">' . html_image("ic/trash.png","16","16",array("border"=>"0")) . '</a></td></tr>';
76 if ($i != ($rows - 1)) {
78 <tr'.$row_color.'><td colspan="5">' ._('Changes since last version:').'<br />'.
79 nl2br(db_result($result,$i,'changes')).'</td></tr>';
83 echo $GLOBALS['HTML']->listTableBottom();
86 </p><p>'._('Download a raw-text version of this code by clicking on "<strong>Download Version</strong>"').'
90 show the latest version of this snippet's code
92 $result=db_query("SELECT code,version FROM snippet_version WHERE snippet_version_id='$newest_version'");
97 <h2>'._('Latest Snippet Version: ').db_result($result,0,'version').'</h2>
99 <span class="snippet-detail">'. db_result($result,0,'code') .'
103 Show a link so you can add a new version of this snippet
106 <h3><a href="'.util_make_url ('/snippet/addversion.php?type=snippet&id='.htmlspecialchars($id)).'"><span class="important">'._('Submit a new version').'</span></a></h3>
107 <p>' ._('You can submit a new version of this snippet if you have modified it and you feel it is appropriate to share with others.').'.</p>';
109 snippet_footer(array());
111 } else if ($type=='package') {
115 View a package and show its versions
116 Expand and show the snippets for the latest version
121 snippet_header(array('title'=>_('Snippet Library')));
123 snippet_show_package_details($id);
126 Get all the versions of this package
128 $sql="SELECT users.realname,users.user_name,users.user_id,snippet_package_version.snippet_package_version_id,".
129 "snippet_package_version.version,snippet_package_version.post_date ".
130 "FROM snippet_package_version,users ".
131 "WHERE users.user_id=snippet_package_version.submitted_by AND snippet_package_id='$id' ".
132 "ORDER BY snippet_package_version.snippet_package_version_id DESC";
134 $result=db_query($sql);
135 $rows=db_numrows($result);
136 if (!$result || $rows < 1) {
137 echo '<h3>' ._('Error - no versions found').'</h3>';
140 <h3>' ._('Versions Of This Package:').'</h3>
143 $title_arr[]= _('Package Version');
144 $title_arr[]= _('Date Posted');
145 $title_arr[]= _('Author');
146 $title_arr[]= _('Edit/Del');
148 echo $GLOBALS['HTML']->listTableTop ($title_arr);
151 determine the newest version of this package,
152 so we can display the snippets that it contains
154 $newest_version=db_result($result,0,'snippet_package_version_id');
156 for ($i=0; $i<$rows; $i++) {
158 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td>'.
159 util_make_link ('/snippet/detail.php?type=packagever&id='.db_result($result,$i,'snippet_package_version_id'),'<strong>'.db_result($result,$i,'version').'</strong>').'</td><td>'.
160 date(_('Y-m-d H:i'),db_result($result,$i,'post_date')).'</td><td>'.
161 util_make_link_u (db_result($result, $i, 'user_name'), db_result($result, $i, 'user_id'),db_result($result, $i, 'realname')).'</td>'.
162 '<td style="text-align:center"><a href="'.util_make_url ('/snippet/add_snippet_to_package.php?snippet_package_version_id='.db_result($result,$i,'snippet_package_version_id')).
163 '">' . html_image("ic/pencil.png","20","25",array("border"=>"0")) .
164 '</a> <a href="'.
165 util_make_url ('/snippet/delete.php?type=package&snippet_package_version_id='.db_result($result,$i,'snippet_package_version_id')).
166 '">' . html_image("ic/trash.png","16","16",array("border"=>"0")) . '</a></td></tr>';
169 echo $GLOBALS['HTML']->listTableBottom();
172 </p><p>' ._('Download a raw-text version of this code by clicking on "<strong>Download Version</strong>"').'
177 show the latest version of the package
184 <h2>' ._('Latest Package Version: ').db_result($result,0,'version').'</h2>
187 snippet_show_package_snippets($newest_version);
190 Show a form so you can add a new version of this package
193 <h3><a href="'.util_make_url ('/snippet/addversion.php?type=package&id='.$id).'"><span class="important">' ._('Submit a new version').'</span></a></h3>
194 <p>' ._('You can submit a new version of this package if you have modified it and you feel it is appropriate to share with others.').'.</p>';
196 snippet_footer(array());
198 } else if ($type=='packagever') {
200 Show a specific version of a package and its specific snippet versions
203 snippet_header(array('title'=>_('Snippet Library')));
205 snippet_show_package_details($id);
207 snippet_show_package_snippets($id);
209 snippet_footer(array());
213 exit_error(_('Error'),_('Error - was the URL mangled?'));