source: contrib/Dms/inc/inc.OutUtils.php @ 3526

Revision 3526, 14.3 KB checked in by afernandes, 13 years ago (diff)

Ticket #1416 - Disponibilizado modulos Timesheet e DMS para a comunidade.

  • Property svn:executable set to *
Line 
1<?php
2
3function getThemes()
4{
5        GLOBAL $settings;
6       
7        $themes = array();
8       
9        $path = $settings->_rootDir . "themes/";
10        $handle = opendir($path);
11       
12        while ($entry = readdir($handle) )
13        {
14                if ($entry == ".." || $entry == ".")
15                        continue;
16                else if (is_dir($path . $entry))
17                        array_push($themes, $entry);
18        }
19        closedir($handle);
20       
21        return $themes;
22}
23
24$theme = $settings->_theme;
25
26function printHTMLHead($title)
27{
28        global $theme;
29
30        $GLOBALS['phpgw_info']['flags'] = array(
31        'currentapp' => 'mydms',
32        'noheader'   => True,
33        'nonavbar'   => True
34);
35        include_once('../../header.inc.php');
36       
37        if(!@is_object($GLOBALS['phpgw']->js))
38        {
39                $GLOBALS['phpgw']->js =& CreateObject('phpgwapi.javascript');
40        }
41        $GLOBALS['phpgw']->js->validate_file('dhtmlxtree','js/dhtmlXCommon');
42        $GLOBALS['phpgw']->js->validate_file('dhtmlxtree','js/dhtmlXTree');
43
44        $GLOBALS['phpgw']->js->validate_file('jscode','mydms','mydms');
45                       
46        $GLOBALS['phpgw']->common->phpgw_header();
47        echo parse_navbar();
48
49        if ( is_file("../themes/$theme/styles.css") )
50                $stylesheet="../themes/$theme/styles.css";
51        else
52                $stylesheet="../themes/default/styles.css";
53       
54        if ( is_file("../themes/$theme/HTMLHead.html" ) )
55                include("../themes/$theme/HTMLHead.html");
56        else
57                include("../themes/default/HTMLHead.html");
58}
59
60function printHTMLFoot()
61{
62        global $theme;
63
64        $GLOBALS['phpgw']->common->phpgw_footer();     
65        if ( is_file("../themes/$theme/HTMLFoot.html" ) )
66        {
67                include("../themes/$theme/HTMLFoot.html");
68        } else {
69                include("../themes/default/HTMLFoot.html");
70        }
71}
72
73function printStartBox($header)
74{
75        global $theme;
76       
77        if ( is_file("../themes/$theme/StartBox.html" ) )
78        {
79                include("../themes/$theme/StartBox.html");
80        } else {
81                include("../themes/default/StartBox.html");
82        }
83}
84
85function printNextBox($header)
86{
87        global $theme;
88       
89        if ( is_file("../themes/$theme/NextBox.html" ) )
90        {
91                include("../themes/$theme/NextBox.html");
92        } else {
93                include("../themes/default/NextBox.html");
94        }
95}
96
97function printEndBox()
98{
99        global $theme;
100       
101        if ( is_file("../themes/$theme/EndBox.html" ) )
102        {
103                include("../themes/$theme/EndBox.html");
104        } else {
105                include("../themes/default/EndBox.html");
106        }
107}
108
109function printCenterStart()
110{
111        print "<table width=\"100%\" height=\"60%\"><tr><td align=\"center\" valign=\"middle\">";
112}
113
114function printCenterEnd()
115{
116        print "</td></tr></table>";
117}
118
119function printGoBack()
120{
121        print "<p><a href=\"javascript:history.back()\">".getMLText("back")."</a>";
122}
123
124function printGoto($targets)
125{
126        print "<p>".getMLText("goto").": ";
127        for ($i = 0; $i < count($targets); $i++)
128        {
129                print "<a href=\"".$targets[$i][1]."\">".$targets[$i][0]."</a>";
130                if ($i+1 < count($targets))
131                        print " | ";
132        }
133}
134
135
136function printTitleBar($folder)
137{
138        return;
139       
140        global $user, $settings, $theme;
141       
142        $options=array();
143        $options[getMLText("content")]=$settings->_httpRoot . "out/out.ViewFolder.php?folderid=" . $folder->getID();
144        $options[getMLText("search")]=$settings->_httpRoot . "out/out.SearchForm.php?folderid=" . $folder->getID();
145       
146        if ($user->getID() != $settings->_guestID)
147                //$options[getMLText("my_account")]=$settings->_httpRoot . "out/out.EditUserData.php";
148       
149        if ($user->isAdmin())
150        {
151                $options[getMLText("admin_tools")] = $settings->_httpRoot . "out/out.AdminTools.php";
152        //      $options[getMLText("user_management")]=$settings->_httpRoot . "out/out.UsrMgr.php";
153        //      $options[getMLText("group_management")]=$settings->_httpRoot . "out/out.GroupMgr.php";
154        } else
155                $options[getMLText("user_list")]=$settings->_httpRoot . "out/out.UserList.php";
156       
157        //$options[getMLText("logout")]=$settings->_httpRoot . "op/op.Logout.php";
158       
159        $title=getMLText("logged_in_as")." ".$user->getFullName();
160        $menu = buildMenu( $options, "titlebar" );
161       
162        if ( is_file("../themes/$theme/TitleBar.html" ) )
163        {
164                include("../themes/$theme/TitleBar.html");
165        } else {
166                include("../themes/default/TitleBar.html");
167        }
168}
169
170
171function printFolderTree($path, $level = 0, $activeObj, $isFolder)
172{
173        GLOBAL $user;
174
175        #$folder = $path[$level];
176        #$subFolders = $folder->getSubFolders();
177        #$subFolders = filterAccess($subFolders, $user, M_READ);
178
179        $allSubFolders = array();
180        foreach($path as $folderObject)
181        {
182                $allSubFolders['_id'.$folderObject->getID()] = $folderObject;
183                $subFoldersL1 = $folderObject->getSubFolders();
184                foreach((array)$subFoldersL1 as $subFolderL1Object)
185                {
186                        $allSubFolders['_id'.$subFolderL1Object->getID()] = $subFolderL1Object;
187                        $subFoldersL2 = $subFolderL1Object->getSubFolders();
188                        foreach((array)$subFoldersL2 as $subFolderL2Object)
189                        {
190                                $allSubFolders['_id'.$subFolderL2Object->getID()] = $subFolderL2Object;
191                        }
192                }
193        }
194
195        $uimydms =& CreateObject('mydms.uimydms');
196        print $uimydms->folderChooser($allSubFolders, $activeObj);
197       
198        return;
199}
200
201
202function printFolderPageStart($folder)
203{
204        global $theme;
205       
206        $uimydms =& CreateObject('mydms.uimydms');
207       
208        $title1 = getMLText("foldertree");
209        $title2 = "<img src='".getImgPath("folder_opened.gif")."' ".
210                       "width='18' height='18' alt='' border='0' align='absmiddle'> ".
211                  getMLText("selected_folder") . ": " . $folder->getName();
212        $path = $folder->getPathNew();
213
214        $txtpath = '';
215if($path!=''){
216        foreach($path as $folderObject)
217        {
218                if(!empty($txtpath)) $txtpath .= " / ";
219                $txtpath .= "<a class=\"path\" href=\"out.ViewFolder.php?folderid=".$folderObject->getID()."\">".
220                            $folderObject->getName()."</a>";
221        }
222}
223       
224        $txtpath = getMLText("folder_path") . ": " . $txtpath;
225       
226        if ( is_file("../themes/$theme/FolderPageStart.html" ) )
227        {
228                include("../themes/$theme/FolderPageStart.html");
229        } else {
230                include("../themes/default/FolderPageStart.html");
231        }
232       
233}
234
235function printFolderPageEnd($folder)
236{
237        GLOBAL $user, $theme;
238
239        $title = getMLText("edit_folder");
240        $options=array();
241        $accessMode = $folder->getAccessMode($user);
242        if ($accessMode >= M_READWRITE)
243        {
244                $options[getMLText("add_subfolder")] = "out.AddSubFolder.php?folderid=" . $folder->getID();
245                $options[getMLText("add_document")] = "out.AddDocument.php?folderid=" . $folder->getID();
246                $options[getMLText("edit_folder_props")] = "out.EditFolder.php?folderid=" . $folder->getID();
247                $options[getMLText("edit_folder_notify")] = "out.FolderNotify.php?folderid=" . $folder->getID();
248                $options[getMLText("move_folder")] = "out.MoveFolder.php?folderid=" . $folder->getID();
249        }
250       
251        if ($accessMode == M_ALL)
252        {
253                $options[getMLText("rm_folder")] = "out.RemoveFolder.php?folderid=" . $folder->getID();
254                $options[getMLText("edit_folder_access")] = "out.FolderAccess.php?folderid=" . $folder->getID();
255        }
256       
257        $menu=buildMenu( $options, "editfolder" );
258       
259        if ( is_file("../themes/$theme/FolderPageEnd.html" ) )
260        {
261                include("../themes/$theme/FolderPageEnd.html");
262        } else {
263                include("../themes/default/FolderPageEnd.html");
264        }
265}
266
267function printPageHeader($header)
268{
269        print "<p><div class=\"pageHeader\">".$header."</div></p>\n";
270}
271
272function printDocumentPageStart($document)
273{
274        global $theme;
275
276        $uimydms =& CreateObject('mydms.uimydms');
277       
278        $folder = $document->getFolder();
279        $title1 = getMLText("foldertree");
280        $title2 = "<img src='".getImgPath("file.gif")."' ".
281                       "width='18' height='18' alt='' border='0' align='absmiddle'> ".
282                  getMLText("selected_document") . ": " . $document->getName();
283
284        $path = $folder->getPathNew();
285
286        $txtpath = '';
287        foreach($path as $folderObject)
288        {
289                if(!empty($txtpath)) $txtpath .= " / ";
290                $txtpath .= "<a class=\"path\" href=\"out.ViewFolder.php?folderid=".$folderObject->getID()."\">".
291                            $folderObject->getName()."</a>";
292        }
293       
294        $txtpath = getMLText("folder_path") . ": " . $txtpath;
295
296        if ( is_file("../themes/$theme/DocumentPageStart.html" ) )
297        {
298                include("../themes/$theme/DocumentPageStart.html");
299        } else {
300                include("../themes/default/DocumentPageStart.html");
301        }
302}
303
304function printDocumentPageEnd($document)
305{
306        GLOBAL $user, $theme;
307       
308        $docid=".php?documentid=" . $document->getID();
309        $title = getMLText("edit_document");
310        $options=array();
311        $accessMode = $document->getAccessMode($user);
312        if ($accessMode >= M_READWRITE)
313        {
314          if (!$document->isLocked())
315          {
316            $options[getMLText("update_document")]      = "out.UpdateDocument" . $docid;
317            $options[getMLText("lock_document")]        = "../op/op.LockDocument" . $docid;
318            $options[getMLText("edit_document_props")]  = "out.EditDocument" . $docid;
319            $options[getMLText("expires")]              = "out.SetExpires" . $docid;
320            $options[getMLText("edit_document_notify")] = "out.DocumentNotify" . $docid;
321            $options[getMLText("move_document")]        = "out.MoveDocument" . $docid;
322          } else {
323            $lockingUser = $document->getLockingUser();
324            if (($lockingUser->getID() == $user->getID()) || ($document->getAccessMode($user) == M_ALL))
325            {
326              $options[getMLText("update_document")]    = "out.UpdateDocument" . $docid;
327              $options[getMLText("unlock_document")]    = "../op/op.UnlockDocument" . $docid;
328              $options[getMLText("edit_document_props")]= "out.EditDocument" . $docid;
329              $options[getMLText("expires")]            = "out.SetExpires" . $docid;
330              $options[getMLText("edit_document_notify")]= "out.DocumentNotify" . $docid;
331              $options[getMLText("move_document")]      = "out.MoveDocument" . $docid;
332            }
333          }
334        }
335       
336        if ($accessMode == M_ALL)
337        {
338          $options[getMLText("rm_document")]            = "out.RemoveDocument" . $docid;
339          $options[getMLText("edit_document_access")]   = "out.DocumentAccess" . $docid;
340        }
341       
342        $menu=buildMenu( $options, "editfolder" );
343       
344        if ( is_file("../themes/$theme/DocumentPageEnd.html" ) )
345        {
346                include("../themes/$theme/DocumentPageEnd.html");
347        } else {
348                include("../themes/default/DocumentPageEnd.html");
349        }
350}
351
352function printDateChooser($defDate = -1, $varName)
353{
354        if ($defDate == -1)
355                $defDate = mktime();
356        $day   = date("d", $defDate);
357        $month = date("m", $defDate);
358        $year  = date("Y", $defDate);
359       
360        print "<select name=\"" . $varName . "day\">\n";
361        for ($i = 1; $i <= 31; $i++)
362        {
363                print "<option value=\"" . $i . "\"";
364                if (intval($day) == $i)
365                        print " selected";
366                print ">" . $i . "</option>\n";
367        }
368        print "</select>.\n";
369        print "<select name=\"" . $varName . "month\">\n";
370        for ($i = 1; $i <= 12; $i++)
371        {
372                print "<option value=\"" . $i . "\"";
373                if (intval($month) == $i)
374                        print " selected";
375                print ">" . $i . "</option>\n";
376        }
377        print "</select>.\n";
378        print "<select name=\"" . $varName . "year\">\n";
379        for ($i = 2004; $i <= 2010; $i++)
380        {
381                print "<option value=\"" . $i . "\"";
382                if (intval($year) == $i)
383                        print " selected";
384                print ">" . $i . "</option>\n";
385        }
386        print "</select>";
387}
388
389
390function printSequenceChooser($objArr, $keepID = -1)
391{
392        if (count($objArr) > 0)
393        {
394                $max = $objArr[count($objArr)-1]->getSequence() + 1;
395                $min = $objArr[0]->getSequence() - 1;
396        }
397        else
398                $max = 1.0;
399       
400        print "<select name=\"sequence\">\n";
401        if ($keepID != -1)
402                print "  <option value=\"keep\">" . getMLText("seq_keep");
403        print "  <option value=\"".$max."\">" . getMLText("seq_end");
404        if (count($objArr) > 0)
405                print "  <option value=\"".$min."\">" . getMLText("seq_start");
406       
407        for ($i = 0; $i < count($objArr) - 1; $i++)
408        {
409                if (($objArr[$i]->getID() == $keepID) || (($i + 1 < count($objArr)) && ($objArr[$i+1]->getID() == $keepID)))
410                        continue;
411                $index = ($objArr[$i]->getSequence() + $objArr[$i+1]->getSequence()) / 2;
412                print "  <option value=\"".$index."\">" . getMLText("seq_after", array("prevname" => $objArr[$i]->getName() ) );
413        }
414       
415        print "</select>";
416}
417
418function printDocumentChooser($formName) {
419        GLOBAL $settings;
420        ?>
421        <script language="JavaScript">
422        var openDlg;
423        function chooseDoc() {
424                openDlg = open("out.DocumentChooser.php?folderid=<?php echo $settings->_rootFolderID?>&form=<?php echo urlencode($formName)?>", "openDlg", "width=300,height=450,scrollbars=yes,resizable=yes,status=yes");
425        }
426        </script>
427        <?php
428        print "<input type=\"Hidden\" name=\"docid\">";
429        print "<input disabled name=\"docname\">";
430        print "&nbsp;&nbsp;<input type=\"Button\" value=\"Open...\" onclick=\"chooseDoc();\">";
431}
432
433
434function printFolderChooser($formName, $accessMode, $exclude = -1, $default = false) {
435        GLOBAL $settings;
436       
437        $linkData = array
438        (
439                'menuaction'    => 'mydms.uimydms.folderChooser',
440                'form'          => $formName,
441                'mode'          => $accessMode,
442                'exlcude'       => $exclude,
443                'folderid'      => $settings->_rootFolderID
444        );
445        $link = $GLOBALS['phpgw']->link('/index.php',$linkData);
446       
447        ?>
448        <script language="JavaScript">
449        var openDlg;
450        function chooseDoc() {
451                //openDlg = open("out.FolderChooser.php?form=<?php echo $formName?>&mode=<?php echo $accessMode?>&exclude=<?php echo $exclude?>&folderid=<?php echo $settings->_rootFolderID?>", "openDlg", "width=300,height=450,scrollbars=yes,resizable=yes,status=yes");
452                openDlg = open("<?php echo $link?>", "openDlg", "width=300,height=450,scrollbars=yes,resizable=yes,status=yes");
453        }
454        </script>
455        <?php
456        print "<input type=\"Hidden\" name=\"targetid\" value=\"". (($default) ? $default->getID() : "") ."\">";
457        print "<input disabled name=\"targetname\" value=\"". (($default) ? $default->getName() : "") ."\">";
458        print "&nbsp;&nbsp;<input type=\"Button\" value=\"Open...\" onclick=\"chooseDoc();\">";
459}
460
461/* ---------------------------------------- ICONS --------------------------------------------- */
462
463$icons = array();
464$icons["txt"]  = "txt.png";
465$icons["doc"]  = "word.png";
466$icons["rtf"]  = "document.png";
467$icons["xls"]  = "excel.png";
468$icons["ppt"]  = "powerpoint.png";
469$icons["exe"]  = "binary.png";
470$icons["html"] = "html.png";
471$icons["htm"]  = "html.png";
472$icons["gif"]  = "image.png";
473$icons["jpg"]  = "image.png";
474$icons["bmp"]  = "image.png";
475$icons["png"]  = "image.png";
476$icons["log"]  = "log.png";
477$icons["midi"] = "midi.png";
478$icons["pdf"]  = "pdf.png";
479$icons["wav"]  = "sound.png";
480$icons["mp3"]  = "sound.png";
481$icons["c"]    = "source_c.png";
482$icons["cpp"]  = "source_cpp.png";
483$icons["h"]    = "source_h.png";
484$icons["java"] = "source_java.png";
485$icons["py"]   = "source_py.png";
486$icons["tar"]  = "tar.png";
487$icons["gz"]   = "gz.png";
488$icons["zip"]  = "gz.png";
489$icons["mpg"]  = "video.png";
490$icons["avi"]  = "video.png";
491$icons["tex"]  = "tex.png";
492$icons["default"] = "default.png";
493
494function getImgPath($img) {
495  global $theme;
496 
497  if ( is_file("../themes/$theme/images/$img") )
498  {
499    return "../themes/$theme/images/$img";
500  }
501  return "../out/images/$img";
502}
503
504function printImgPath($img)
505{
506  print getImgPath($img);
507}
508
509function buildMenu( $options , $class="titlebar" )
510{
511    $sep = "";
512        $menu = "";
513        reset($options);
514        while ( list($desc,$url) = each($options) )
515        {
516                $menu.=$sep;
517                $menu.="<nobr><a href='$url' class='$class'>$desc</a></nobr>\n";
518                $sep=" | \n";
519        }
520        return $menu;
521}
522
523function getMimeIcon($fileType)
524{
525        GLOBAL $icons;
526       
527        $ext = substr($fileType, 1);
528        if (isset($icons[$ext]))
529                return $icons[$ext];
530        else
531                return $icons["default"];
532}
533?>
Note: See TracBrowser for help on using the repository browser.