3 * GForge Documentaion Manager
5 * Portions Copyright 1999-2001 (c) VA Linux Systems
6 * The rest Copyright 2002-2004 (c) GForge Team
11 * This file is part of GForge.
13 * GForge is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * GForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with GForge; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 by Quentin Cregan, SourceForge 06/2000
34 function display_groups_option($group_id=false,$checkedval='xzxz') {
39 $query = "select doc_group, groupname "
41 ."where group_id = '$group_id' "
42 ."order by groupname";
43 $result = db_query($query);
45 echo html_build_select_box ($result,'doc_group',$checkedval,false);
49 } //end display_groups_option
52 function docman_header($title,$pagehead,$style='xyz') {
54 global $group_id, $HTML, $sys_use_docman;
56 if (!$sys_use_docman) {
60 $project =& group_get_object($group_id);
61 if (!$project || !is_object($project)) {
65 if (!$project->usesDocman()) {
66 exit_error(_('Error'),_('This project has turned off the Doc Manager.'));
69 site_project_header(array('title'=>$title,'group'=>$group_id,'toptab'=>'docman'));
74 $menu_text[]=_('Submit new documentation');
75 $menu_links[]='/docman/new.php?group_id='.$group_id;
76 $menu_text[]=_('View Documentation');
77 $menu_links[]='/docman/index.php?group_id='.$group_id;
78 $menu_text[]=_('Search in documents');
79 $menu_links[]='/docman/search.php?group_id='.$group_id;
82 if (session_loggedin()) {
83 $perm =& $project->getPermission(session_get_user());
84 if ($perm && is_object($perm) && !$perm->isError() && $perm->isDocEditor()) {
85 $menu_text[]=_('Admin');
86 $menu_links[]='/docman/admin/index.php?group_id='.$group_id;
95 function doc_droplist_count($l_group_id, $language_id, $g) {
96 if (session_loggedin()) {
97 $perm =& $g->getPermission( session_get_user() );
98 if (!$perm || !is_object($perm) || !$perm->isMember()) {
99 $public_flag='AND dd.stateid=1';
101 $public_flag='AND dd.stateid IN (1,4,5)';
104 $public_flag='AND dd.stateid=1';
107 $query = "select dd.language_id, sl.name, count(*) as count
108 from doc_groups as dg, doc_data as dd, supported_languages as sl
109 where dg.doc_group = dd.doc_group
110 and dg.group_id = '$l_group_id'
112 and sl.language_id = dd.language_id
113 group by dd.language_id,sl.name";
115 $gresult = db_query($query);
118 if (db_numrows($gresult) >= 1) {
120 print "<form name=\"langchoice\" action=\"index.php?group_id=".$l_group_id."\" method=\"post\"><table border=\"0\">"
121 ." <tr><td valign=\"middle\"><strong>"._('Language')." </strong></td>"
122 ." <td valign=\"middle\"><select name=\"language_id\">\n\n";
123 print "<option value=\"*\">"._('All Languages')." </option>";
124 while($grow = db_fetch_array($gresult)) {
126 if ($language_id == $grow['language_id']) {
128 print "<option value=\"".$grow['language_id']."\" selected=\"selected\">".$grow['name']." (".$grow['count'].") </option>";
130 print "<option value=\"".$grow['language_id']."\">".$grow['name']." (".$grow['count'].") </option>";
133 print "</select></td><td valign=\"middle\"><input type=\"submit\" value=\""._('Go')."\" /></td></tr></table></form>";
141 function doc_get_state_box($checkedval='xzxz') {
142 $res_states=db_query("select * from doc_states;");
143 echo html_build_select_box ($res_states,'stateid',$checkedval,false);
147 function docman_footer($params) {
148 site_project_footer($params);
152 * docman_display_documents - Recursive function to show the documents inside the groups tree
154 function docman_display_documents(&$nested_groups, &$document_factory, $is_editor, $stateid=0, $from_admin=false, $parent_group=0) {
155 global $selected_doc_group_id;
157 $selected_doc_group_id=getIntFromRequest('selected_doc_group_id');
162 if (!is_array($nested_groups["$parent_group"])) {
166 echo "<ul style='list-style-type: none'>";
167 $child_count = count($nested_groups["$parent_group"]);
169 for ($i=0; $i < $child_count; $i++) {
170 $doc_group =& $nested_groups["$parent_group"][$i];
172 // Display group and subgroups only if it has associated documents
173 if ($doc_group->hasDocuments($nested_groups, $document_factory, $stateid)) {
175 if (($doc_group->getID() == $selected_doc_group_id || $doc_group->hasSubgroup($nested_groups, $selected_doc_group_id)) && (!$stateid || $stateid == $selected_stateid)) {
176 $icon = 'ofolder15.png';
178 $icon = 'cfolder15.png';
180 echo "<li>".html_image('ic/'.$icon,"15","13",array("border"=>"0"))." <a href='index.php?group_id=".$doc_group->Group->getID()."&selected_doc_group_id=".$doc_group->getID()."&language_id=".$GLOBALS['selected_language'];
181 if ($from_admin && $stateid) { // if we're sorting by the state, pass the state as a variable
182 echo "&selected_stateid=".$stateid;
184 echo "'>".$doc_group->getName()."</a>";
186 // display link to add a document to the current group
187 echo " <a href='".($from_admin ? "../" : "")."new.php?group_id=".$doc_group->Group->getID()."&selected_doc_group=".$doc_group->getID()."'>";
188 echo html_image('ic/adddoc12.png',"12","14",array("border"=>"0"))." ";
189 echo _('[Add document here]');
191 if (($doc_group->getID() == $selected_doc_group_id || $doc_group->hasSubgroup($nested_groups, $selected_doc_group_id)) && (!$stateid || $stateid == $selected_stateid)) {
192 docman_display_documents($nested_groups, $document_factory, $is_editor, $stateid, $from_admin, $doc_group->getID());
196 // Display this group's documents
197 if (($doc_group->hasSubgroup($nested_groups, $selected_doc_group_id) || $selected_doc_group_id == $doc_group->getID()) && (!$stateid || $stateid == $GLOBALS['selected_stateid'])) {
198 // Retrieve all the docs from this category
200 $document_factory->setStateID($stateid);
202 $document_factory->setDocGroupID($doc_group->getID());
203 $docs = $document_factory->getDocuments();
204 if (is_array($docs)) {
205 $docs_count = count($docs);
207 echo "<ul style='list-style-type: none'>";
208 for ($j=0; $j < $docs_count; $j++) {
210 $link = "index.php?editdoc=1&docid=".$docs[$j]->getID()."&group_id=".$docs[$j]->Group->getID();
212 $link = (( $docs[$j]->isURL() ) ? $docs[$j]->getFileName() : "view.php/".$docs[$j]->Group->getID()."/".$docs[$j]->getID()."/".$docs[$j]->getFileName() );
214 $tooltip = $docs[$j]->getFileName() . " (" .
215 ($docs[$j]->getUpdated() ?
216 date(_('Y-m-d H:i'), $docs[$j]->getUpdated()) :
217 date(_('Y-m-d H:i'),$docs[$j]->getCreated())) .
219 if ($docs[$j]->getFilesize() > 1024) {
220 $tooltip .= floor($docs[$j]->getFilesize()/1024) . "KB";
222 $tooltip .= $docs[$j]->getFilesize() . "B";
224 $tooltip = htmlspecialchars($tooltip);
226 html_image('ic/docman16b.png',"20","20",array("border"=>"0")).
228 "<a href=\"".$link."\" title=\"$tooltip\">".
229 $docs[$j]->getName().
230 "</a> - " . $tooltip . "</li>".
231 "(".$docs[$j]->getFileSize()." "._('bytes').")";
233 echo "<br /> ";
234 echo "<i>".$docs[$j]->getDescription()."</i>";
245 // c-file-style: "bsd"