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 $group_object = & group_get_object($group);;
32 $res = db_query_params ('SELECT groupname FROM doc_groups WHERE doc_group=$1 AND group_id=$2',
34 if (!$res || db_numrows($res) < 1) {
35 $group_object->setError(_('DocumentGroup: Invalid DocumentGroup ID'));
38 return (db_result($res,0,'groupname'));
42 function getStateDocGroup($id,$group) {
43 $group_object = & group_get_object($group);;
44 $res = db_query_params ('SELECT stateid FROM doc_groups WHERE doc_group=$1 AND group_id=$2',
46 if (!$res || db_numrows($res) < 1) {
47 $group_object->setError(_('DocumentGroup: Invalid DocumentGroup ID'));
50 return (db_result($res,0,'stateid'));
54 function doc_get_state_box($checkedval='xzxz') {
55 $res_states=db_query_params ('select * from doc_states', array());
56 echo html_build_select_box ($res_states,'stateid',$checkedval,false);
60 function docman_recursive_display($docgroup) {
61 global $nested_groups,$group_id;
62 global $idExposeTreeIndex,$dirid,$idhtml;
64 if (is_array(@$nested_groups[$docgroup])) {
65 foreach ($nested_groups[$docgroup] as $dg) {
68 if ($dirid == $dg->getID())
69 $idExposeTreeIndex = $idhtml;
72 ['".'<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()."', '', '',";
73 docman_recursive_display($dg->getID());
80 function docman_recursive_stateid($docgroup,$nested_groups,$nested_docs,$stateid=2) {
81 if (is_array(@$nested_groups[$docgroup])) {
82 foreach ($nested_groups[$docgroup] as $dg) {
83 $dg->setStateID($stateid);
86 if (isset($nested_docs[$docgroup]) && is_array($nested_docs[$docgroup])) {
87 foreach ($nested_docs[$docgroup] as $d) {
88 $d->setStateID($stateid);
94 * docman_display_documents - Recursive function to show the documents inside the groups tree
96 function docman_display_trash(&$document_factory,$parent_group=0) {
97 $nested_groups =& $document_factory->getNested(2);
98 $child_count = count($nested_groups["$parent_group"]);
99 echo "<ul style='list-style-type: none'>\n";
100 for ($i=0; $i < $child_count; $i++) {
101 $doc_group =& $nested_groups["$parent_group"][$i];
102 echo "<li>".$doc_group->getName()."</li>";
107 function docman_display_documents(&$nested_groups, &$document_factory, $is_editor, $stateid=0, $parent_group=0) {
108 if (!array_key_exists("$parent_group",$nested_groups) || !is_array($nested_groups["$parent_group"])) {
112 echo '<script language="javascript">';
113 echo 'function EditData(iddiv) {';
114 echo ' if ( "none" == document.getElementById(iddiv).style.display ) {';
115 echo ' document.getElementById(iddiv).style.display = "block";';
117 echo ' document.getElementById(iddiv).style.display = "none";';
121 echo "<ul style='list-style-type: none'>\n";
122 $child_count = count($nested_groups["$parent_group"]);
124 for ($i=0; $i < $child_count; $i++) {
125 $doc_group =& $nested_groups["$parent_group"][$i];
127 if ($doc_group->hasDocuments($nested_groups, $document_factory, $stateid)) {
128 $icon = 'ofolder15.png';
129 echo "<li>".html_image('docman/directory.png',"22","22",array("border"=>"0"))." ".$doc_group->getName()."</li>";
130 docman_display_documents($nested_groups, $document_factory, $is_editor, $stateid, $doc_group->getID());
133 // Display this group's documents
134 // Retrieve all the docs from this category
136 $document_factory->setStateID($stateid);
138 $document_factory->setDocGroupID($doc_group->getID());
139 $docs = $document_factory->getDocuments();
140 if (is_array($docs)) {
141 $docs_count = count($docs);
143 echo "<ul style='list-style-type: none'>";
144 for ($j=0; $j < $docs_count; $j++) {
145 $tooltip = $docs[$j]->getFileName() . " (" .
146 ($docs[$j]->getUpdated() ?
147 date(_('Y-m-d H:i'), $docs[$j]->getUpdated()) :
148 date(_('Y-m-d H:i'),$docs[$j]->getCreated())) .
150 if ($docs[$j]->getFileSize() > 1024) {
151 $tooltip .= floor($docs[$j]->getFileSize()/1024) . "KB";
153 $tooltip .= $docs[$j]->getFileSize() . "B";
155 $tooltip = htmlspecialchars($tooltip);
156 echo '<li>'. html_image('docman/file_type_unknown.png',"22","22",array("border"=>"0")).
157 $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>';
158 echo "<i>".$docs[$j]->getDescription()."</i><br/>";
159 echo '<div class="docman_div_include" id="editdata'.$docs[$j]->getID().'" style="display:none">';
160 document_editdata($docs[$j]);
169 function document_editdata(&$document) {
170 global $g,$dirid,$group_id;
171 $dgh = new DocumentGroupHTML($g);
173 exit_error('Error',$dgh->getErrorMessage());
175 $dgf = new DocumentGroupFactory($g);
177 exit_error('Error',$dgf->getErrorMessage());
180 <div class="docmanDivIncluded">
182 <?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.") ?>
185 if ($g->useDocmanSearch())
186 echo '<p>'. _('Both fields are used by document search engine.'). '</p>';
189 <form id="editdata<?php echo $document->getID(); ?>" name="editdata<?php echo $document->getID(); ?>" action="?group_id=<?php echo $group_id; ?>&action=editfile&fromview=admin&dirid=<?php echo $dirid; ?>" method="post" enctype="multipart/form-data">
193 <td style="text-align:right;"> <strong><?php echo _('Document Title') ?></strong><?php echo utils_requiredField(); ?>
196 <input type="text" name="title" size="40" maxlength="255" value="<?php echo $document->getName(); ?>" />
197 <?php printf(_('(at least %1$s characters)'), 5) ?>
201 <td style="text-align:right;">
202 <strong><?php echo _('Description') ?></strong><?php echo utils_requiredField(); ?>
205 <input type="text" name="description" size="50" maxlength="255" value="<?php echo $document->getDescription(); ?>" />
206 <?php printf(_('(at least %1$s characters)'), 10) ?>
211 <td style="text-align:right;">
212 <strong><?php echo _('File')?></strong><?php echo utils_requiredField(); ?>
215 <?php if ($document->isURL()) {
216 echo '<a href="'.inputSpecialchars($d->getFileName()).'">[View File URL]</a>';
218 <a target="_blank" href="../view.php/<?php echo $group_id.'/'.$document->getID().'/'.urlencode($document->getFileName()) ?>"><?php echo $document->getName(); ?></a>
225 if ((!$document->isURL()) && ($document->isText())) {
230 echo _('Edit the contents to your desire or leave them as they are to remain unmodified.');
231 echo '<textarea name="data" rows="15" cols="100" wrap="soft">'. $document->getFileData() .'</textarea><br />';
232 echo '<input type="hidden" name="filetype" value="text/plain">';
240 <td style="text-align:right;">
241 <strong><?php echo _('Group that document belongs in') ?></strong>
244 <?php $dgh->showSelectNestedGroups($dgf->getNested(), 'doc_group', false, $document->getDocGroupID()); ?>
249 <td style="text-align:right;">
250 <strong><?php echo _('State') ?></strong>
253 <?php doc_get_state_box($document->getStateID()); ?>
257 <td style="text-align:right;">
258 <?php if ($document->isURL()) { ?>
259 <strong><?php echo _('Specify an outside URL where the file will be referenced') ?> :</strong><?php echo utils_requiredField(); ?>
262 <input type="text" name="file_url" size="50" value="<?php echo $document->getFileName() ?>" />
264 <strong><?php echo _('OPTIONAL: Upload new file') ?></strong>
267 <input type="file" name="uploaded_data" size="30" />
269 if (forge_get_config('use_ftp_uploads')) {
271 printf(_('OR choose one form FTP %1$s.'), forge_get_config('ftp_upload_host'));
272 echo '</strong><br />' ;
273 $ftp_files_arr=array_merge($arr,ls($upload_dir,true));
274 echo html_build_select_box_from_arrays($ftp_files_arr,$ftp_files_arr,'ftp_filename','');
282 <input type="hidden" name="docid" value="<?php echo $document->getID(); ?>" />
283 <input type="submit" id="submiteditdata<?php echo $document->getID(); ?>" value="<?php echo _('Submit Edit') ?>" /><br /><br />