4 * FusionForge Documentation Manager
6 * Copyright 1999-2001, VA Linux Systems
7 * Copyright 2000, Quentin Cregan/SourceForge
8 * Copyright 2002-2004, GForge Team
9 * Copyright 2010, Franck Villaume
11 * This file is part of FusionForge.
13 * FusionForge 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 * FusionForge 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 FusionForge; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 function getNameDocGroup($id,$group) {
31 $res = db_query_params ('SELECT groupname FROM doc_groups WHERE doc_group=$1 AND group_id=$2',
33 if (!$res || db_numrows($res) < 1) {
34 $this->setError(_('DocumentGroup: Invalid DocumentGroup ID'));
37 return (db_result($res,0,'groupname'));
41 function getStateDocGroup($id,$group) {
42 $res = db_query_params ('SELECT stateid FROM doc_groups WHERE doc_group=$1 AND group_id=$2',
44 if (!$res || db_numrows($res) < 1) {
45 $this->setError(_('DocumentGroup: Invalid DocumentGroup ID'));
48 return (db_result($res,0,'stateid'));
52 function doc_get_state_box($checkedval='xzxz') {
53 $res_states=db_query_params ('select * from doc_states', array());
54 echo html_build_select_box ($res_states,'stateid',$checkedval,false);
58 function docman_recursive_display($docgroup) {
59 global $nested_groups,$group_id;
60 global $idExposeTreeIndex,$dirid,$idhtml;
62 if (is_array(@$nested_groups[$docgroup])) {
63 foreach ($nested_groups[$docgroup] as $dg) {
66 if ($dirid == $dg->getID())
67 $idExposeTreeIndex = $idhtml;
70 ['".'<span class="JSCookTreeFolderClosed"><i><img alt="" src="\' + ctThemeXPBase + \'folder1.gif" /></i></span><span class="JSCookTreeFolderOpen"><i><img alt="" src="\' + ctThemeXPBase + \'folderopen1.gif"></i></span>'."', '".addslashes($dg->getName())."', '?group_id=".$group_id."&view=listfile&dirid=".$dg->getID()."', '', '',";
71 docman_recursive_display($dg->getID());
78 function docman_recursive_stateid($docgroup,$nested_groups,$nested_docs,$stateid=2) {
79 if (is_array(@$nested_groups[$docgroup])) {
80 foreach ($nested_groups[$docgroup] as $dg) {
81 $dg->setStateID($stateid);
84 if (isset($nested_docs[$docgroup]) && is_array($nested_docs[$docgroup])) {
85 foreach ($nested_docs[$docgroup] as $d) {
86 $d->setStateID($stateid);
92 * docman_display_documents - Recursive function to show the documents inside the groups tree
94 function docman_display_trash(&$document_factory,$parent_group=0) {
95 $nested_groups =& $document_factory->getNested(2);
96 $child_count = count($nested_groups["$parent_group"]);
97 echo "<ul style='list-style-type: none'>\n";
98 for ($i=0; $i < $child_count; $i++) {
99 $doc_group =& $nested_groups["$parent_group"][$i];
100 echo "<li>".$doc_group->getName()."</li>";
105 function docman_display_documents(&$nested_groups, &$document_factory, $is_editor, $stateid=0, $parent_group=0) {
106 if (!array_key_exists("$parent_group",$nested_groups) || !is_array($nested_groups["$parent_group"])) {
110 echo '<script language="javascript">';
111 echo 'function EditData(iddiv) {';
112 echo ' if ( "none" == document.getElementById(iddiv).style.display ) {';
113 echo ' document.getElementById(iddiv).style.display = "inline";';
115 echo ' document.getElementById(iddiv).style.display = "none";';
119 echo "<ul style='list-style-type: none'>\n";
120 $child_count = count($nested_groups["$parent_group"]);
122 for ($i=0; $i < $child_count; $i++) {
123 $doc_group =& $nested_groups["$parent_group"][$i];
125 if ($doc_group->hasDocuments($nested_groups, $document_factory, $stateid)) {
126 $icon = 'ofolder15.png';
127 echo "<li>".html_image('docman/directory.png',"22","22",array("border"=>"0"))." ".$doc_group->getName()."</li>";
128 docman_display_documents($nested_groups, $document_factory, $is_editor, $stateid, $doc_group->getID());
131 // Display this group's documents
132 // Retrieve all the docs from this category
134 $document_factory->setStateID($stateid);
136 $document_factory->setDocGroupID($doc_group->getID());
137 $docs = $document_factory->getDocuments();
138 if (is_array($docs)) {
139 $docs_count = count($docs);
141 echo "<ul style='list-style-type: none'>";
142 for ($j=0; $j < $docs_count; $j++) {
143 $tooltip = $docs[$j]->getFileName() . " (" .
144 ($docs[$j]->getUpdated() ?
145 date(_('Y-m-d H:i'), $docs[$j]->getUpdated()) :
146 date(_('Y-m-d H:i'),$docs[$j]->getCreated())) .
148 if ($docs[$j]->getFileSize() > 1024) {
149 $tooltip .= floor($docs[$j]->getFileSize()/1024) . "KB";
151 $tooltip .= $docs[$j]->getFileSize() . "B";
153 $tooltip = htmlspecialchars($tooltip);
154 echo '<li>'. html_image('docman/file_type_unknown.png',"22","22",array("border"=>"0")).
155 $docs[$j]->getName(). ' - ' . $tooltip . ' <a href="#" onclick="javascript:EditData(\'editdata'.$docs[$j]->getID().'\')" >'. html_image('docman/edit-file.png',22,22,array('alt'=>'editfile')) .'</a></li>';
156 echo "<i>".$docs[$j]->getDescription()."</i><br/>";
157 echo '<div id="editdata'.$docs[$j]->getID().'" style="display:none">';
158 document_editdata($docs[$j]);
167 function document_editdata(&$document) {
168 global $g,$dirid,$group_id;
169 $dgh = new DocumentGroupHTML($g);
171 exit_error('Error',$dgh->getErrorMessage());
173 $dgf = new DocumentGroupFactory($g);
175 exit_error('Error',$dgf->getErrorMessage());
180 <?php echo _("<strong>Document Title</strong>: Refers to the relatively brief title of the document (e.g. How to use the download server)<br /><strong>Description:</strong> A brief description to be placed just under the title.") ?>
183 if ($g->useDocmanSearch())
184 echo '<p>'. _('Both fields are used by document search engine.'). '</p>';
187 <form id="editdata<?php echo $document->getID(); ?>" name="editdata<?php echo $document->getID(); ?>" action="?group_id=<?php echo $group_id; ?>&action=editfile&dirid=<?php echo $dirid; ?>" method="post" enctype="multipart/form-data">
192 <strong><?php echo _('Document Title') ?>: </strong><?php echo utils_requiredField(); ?> <?php printf(_('(at least %1$s characters)'), 5) ?><br />
193 <input type="text" name="title" size="40" maxlength="255" value="<?php echo $document->getName(); ?>" />
200 <strong><?php echo _('Description') ?></strong><?php echo utils_requiredField(); ?> <?php printf(_('(at least %1$s characters)'), 10) ?><br />
201 <input type="text" name="description" size="50" maxlength="255" value="<?php echo $document->getDescription(); ?>" />
207 <strong><?php echo _('File')?></strong><?php echo utils_requiredField(); ?><br />
208 <?php if ($document->isURL()) {
209 echo '<a href="'.inputSpecialchars($d->getFileName()).'">[View File URL]</a>';
211 <a target="_blank" href="../view.php/<?php echo $group_id.'/'.$document->getID().'/'.urlencode($document->getFileName()) ?>"><?php echo $document->getName(); ?></a>
218 if ((!$document->isURL()) && ($document->isText())) {
223 echo _('Edit the contents to your desire or leave them as they are to remain unmodified.');
224 echo '<textarea name="data" rows="15" cols="100" wrap="soft">'. $document->getFileData() .'</textarea><br />';
225 echo '<input type="hidden" name="filetype" value="text/plain">';
234 <strong><?php echo _('Group that document belongs in') ?></strong><br />
236 $dgh->showSelectNestedGroups($dgf->getNested(), 'doc_group', false, $document->getDocGroupID());
243 <br /><strong><?php echo _('State') ?>:</strong><br />
245 doc_get_state_box($document->getStateID());
250 <?php if ($document->isURL()) { ?>
251 <strong><?php echo _('Specify an outside URL where the file will be referenced') ?> :</strong><?php echo utils_requiredField(); ?><br />
252 <input type="text" name="file_url" size="50" value="<?php echo $document->getFileName() ?>" />
254 <strong><?php echo _('OPTIONAL: Upload new file') ?></strong><br />
255 <input type="file" name="uploaded_data" size="30" /><br/><br />
257 if (forge_get_config('use_ftp_uploads')) {
259 printf(_('OR choose one form FTP %1$s.'), forge_get_config('ftp_upload_host'));
260 echo '</strong><br />' ;
261 $ftp_files_arr=array_merge($arr,ls($upload_dir,true));
262 echo html_build_select_box_from_arrays($ftp_files_arr,$ftp_files_arr,'ftp_filename','');
271 <input type="hidden" name="docid" value="<?php echo $document->getID(); ?>" />
272 <input type="submit" id="submiteditdata<?php echo $document->getID(); ?>" value="<?php echo _('Submit Edit') ?>" /><br /><br />