home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / cms / select.php < prev    next >
Encoding:
PHP Script  |  2004-03-08  |  9.5 KB  |  257 lines

  1. <?php
  2. /*
  3. Copyright Intermesh 2003
  4. Author: Merijn Schering <mschering@intermesh.nl>
  5. Version: 1.0 Release date: 08 July 2003
  6.  
  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.
  11. */
  12.  
  13. $site_id = isset($_REQUEST['site_id']) ? $_REQUEST['site_id'] : 0;
  14.  
  15. $filter[] = 'html';
  16. $filter[] = 'htm';
  17. $filter[] = 'jpg';
  18. $filter[] = 'gif';
  19. $filter[] = 'png';
  20.  
  21. function get_path($folder_id)
  22. {
  23.     global $cms;
  24.     $path = '';
  25.  
  26.     while($folder = $cms->get_folder($folder_id))
  27.     {
  28.         $path = '/<a href="'.$_SERVER['PHP_SELF'].'?folder_id='.$folder['id'].'">'.$folder['name'].'</a>'.$path;
  29.         $folder_id = $folder['parent_id'];
  30.     }
  31.     return $path;
  32. }
  33.  
  34. require("../../Group-Office.php");
  35. require($GO_CONFIG->class_path.'cms.class.inc');
  36. $cms = new cms();
  37.  
  38. //authenticate the user
  39. $GO_SECURITY->authenticate();
  40.  
  41. //see if the user has access to this module
  42. //for this to work there must be a module named 'example'
  43. $GO_MODULES->authenticate('cms');
  44.  
  45. //get the language file
  46. require($GO_LANGUAGE->get_language_file('cms'));
  47.  
  48. //remember sorting in cookie
  49. if (isset($_REQUEST['newsort']))
  50. {
  51.     SetCookie("cms_sort",$_REQUEST['newsort'],time()+3600*24*365,"/","",0);
  52.     $_COOKIE['cms_sort'] = $_REQUEST['newsort'];
  53. }
  54. if (isset($_REQUEST['newdirection']))
  55. {
  56.     SetCookie("cms_direction",$_REQUEST['newdirection'],time()+3600*24*365,"/","",0);
  57.     $_COOKIE['cms_direction'] = $_REQUEST['newdirection'];
  58. }
  59.  
  60.  
  61. $site = $cms->get_site($site_id);
  62.  
  63. if (!$GO_SECURITY->has_permission($GO_SECURITY->user_id, $site['acl_write']))
  64. {
  65.     require($GO_THEME->theme_path."header.inc");
  66.     require($GO_CONFIG->root_path.'error_docs/403.inc');
  67.     require($GO_THEME->theme_path."footer.inc");
  68.     exit();
  69.  
  70. }
  71.  
  72. //set the folder id we are in
  73. $folder_id = isset($_REQUEST['folder_id']) ? $_REQUEST['folder_id'] : $site['root_folder_id'];
  74.  
  75. require($GO_THEME->theme_path."header.inc");
  76.  
  77. //determine sorting
  78. if (!isset($_COOKIE['cms_sort']))
  79.         $_COOKIE['cms_sort'] = "cms_files.name";
  80.  
  81. if (!isset($_COOKIE['cms_direction']))
  82.         $_COOKIE['cms_direction'] = "ASC";
  83.  
  84. if ($_COOKIE['cms_direction'] == "DESC")
  85. {
  86.     $image_string = ' <img src="'.$GO_THEME->image_url.'buttons/arrow_down.gif" border="0" />';
  87.     $newdirection = "ASC";
  88. }else
  89. {
  90.     $image_string = ' <img src="'.$GO_THEME->image_url.'buttons/arrow_up.gif" border="0" />';
  91.     $newdirection = "DESC";
  92. }
  93.  
  94. $folder = $cms->get_folder($folder_id);
  95.  
  96. echo '<table border="0" cellpadding="10"><tr><td>';
  97. echo '<h2>'.get_path($folder['parent_id']).'/<a href="'.$_SERVER['PHP_SELF'].'?site_id='.$site_id.'&folder_id='.$folder['id'].'">'.$folder['name'].'</a></h2>';
  98. echo '<table border="0">';
  99. if($folder['parent_id']!=0)
  100. {
  101.     echo '<td align="center" width="60" nowrap>';
  102.     echo '<a class="small" href="'.$_SERVER['PHP_SELF'].'?site_id='.$site_id.'&folder_id='.$folder['parent_id'].'"><img src="'.$GO_THEME->images['uplvl_big'].'" border="0" height="32" width="32" /><br />omhoog</a></td>';
  103. }
  104. echo '<td align="center" width="60" nowrap>';
  105. echo '<a class="small" href="javascript:window.close();"><img src="'.$GO_THEME->images['close'].'" border="0" height="32" width="32" /><br />close</a></td>';
  106.  
  107. echo '</table>';
  108.  
  109. echo '<table border="0" cellpadding="0" cellspacing="0"><tr>';
  110. echo '<td class="TableHead2" width="16"><input type="checkbox" onclick="javascript:invert_selection()" name="dummy" /></td>';
  111. echo '<td class="TableHead2" width="16"> </td>';
  112. echo '<td class="TableHead2" width="100" nowrap><a class="TableHead2" href="'.$_SERVER['PHP_SELF'].'?site_id='.$site_id.'&newsort=cms_files.name&newdirection='.$newdirection.'">'.$strName;
  113. if ($_COOKIE['cms_sort'] == "cms_files.name")
  114.         echo $image_string;
  115. echo '</a></td>';
  116.  
  117. echo '<td class="TableHead2" width="100" nowrap><a class="TableHead2" href="'.$_SERVER['PHP_SELF'].'?site_id='.$site_id.'&newsort=filetypes.friendly&newdirection='.$newdirection.'">'.$strType;
  118. if ($_COOKIE['cms_sort'] == "filetypes.friendly")
  119.         echo $image_string;
  120. /*
  121. echo '</a></td>';
  122.  
  123. echo '<td class="TableHead2" width="100" nowrap><a class="TableHead2" href="'.$_SERVER['PHP_SELF'].'?site_id='.$site_id.'&newsort=cms_files.size&newdirection='.$newdirection.'">'.$strSize;
  124. if ($_COOKIE['cms_sort'] == "cms_files.size")
  125.         echo $image_string;
  126. echo '</a></td>';
  127.  
  128. echo '<td class="TableHead2" width="100" nowrap><a class="TableHead2" href="'.$_SERVER['PHP_SELF'].'?site_id='.$site_id.'&newsort=cms_files.mtime&newdirection='.$newdirection.'">'.$strModified;
  129. if ($_COOKIE['cms_sort'] == "cms_files.mtime")
  130.         echo $image_string;
  131. */
  132. echo '<td class="TableHead2" width="100" nowrap><a class="TableHead2" href="'.$_SERVER['PHP_SELF'].'?site_id='.$site_id.'&newsort=cms_files.priority&newdirection='.$newdirection.'&folder_id='.$folder_id.'">'.$cms_priority;
  133. if ($_COOKIE['cms_sort'] == "cms_files.priority")
  134.         echo $image_string;
  135. echo '</a></td></tr>';
  136.  
  137. //list the folders
  138.  
  139. //adjust sorting because folders because they lack some columns
  140. if ($_COOKIE['cms_sort'] == "cms_files.time")
  141. {
  142.     $folders_sort = "time";
  143. }else
  144. {
  145.     $folders_sort = "name";
  146. }
  147.  
  148. //list the folders first
  149. $total_size = 0;
  150. $count_folders = $cms->get_folders($folder_id, $folders_sort, $_COOKIE['cms_direction']);
  151. while ($cms->next_record())
  152. {
  153.     $short_name = cut_string($cms->f('name'), 30);
  154.     echo '<tr id="folder_'.$cms->f('id').'" class="Table1">';
  155.     echo '<td><input onclick="javascript:folder_click(this)" type="checkbox" name="folders[]" value="'.$cms->f('id').'" id="'.$cms->f('name').'" /></td>';
  156.     if ($cms->f('disabled') == '1')
  157.     {
  158.         echo '<td><img width="16" height="16" border="0" src="'.$GO_THEME->images['invisible_folder'].'" /></td>';
  159.     }else
  160.     {
  161.         echo '<td><img width="16" height="16" border="0" src="'.$GO_THEME->images['folder'].'" /></td>';
  162.     }
  163.  
  164.     if (isset($cut_folders) && in_array($cms->f('id'), $cut_folders))
  165.     {
  166.         echo '<td nowrap> <a href="'.$_SERVER['PHP_SELF'].'?site_id='.$site_id.'&folder_id='.$cms->f('id').'"><font color="#7d7d7d">'.$cms->f('name').'</font></a>  </td>';
  167.     }else
  168.     {
  169.         echo '<td nowrap> <a href="'.$_SERVER['PHP_SELF'].'?site_id='.$site_id.'&folder_id='.$cms->f('id').'" title="'.$cms->f('name').'">'.$short_name.'</a>  </td>';
  170.     }
  171.     echo '<td nowrap>'.$fbFolder.'  </td>';
  172.     /*
  173.     echo '<td align="right">-  </td>';
  174.     echo '<td nowrap>'.date($_SESSION['GO_SESSION']['date_format'], $cms->f('mtime')).'  </td>';
  175.     */
  176.     echo '<td nowrap align="center">'.$cms->f('priority').'</td>';
  177.     echo '</tr>';
  178.     echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
  179.  
  180. }
  181.  
  182. //list the files
  183. $count_files = $cms->get_files($folder_id, $_COOKIE['cms_sort'], $_COOKIE['cms_direction']);
  184. while ($cms->next_record())
  185. {
  186.     if (in_array($cms->f('extension'), $filter))
  187.     {
  188.         $total_size += $cms->f('size');
  189.         $short_name = strip_extension(cut_string($cms->f('name'), 30));
  190.  
  191.         echo '<tr id="file_'.$cms->f('id').'" class="Table1">';
  192.         echo '<td><input onclick="javascript:file_click(this)" type="checkbox" name="files[]" value="'.$cms->f('id').'" id="'.$cms->f('name').'" /></td>';
  193.         echo '<td><img width="16" height="16" border="0" src="'.$GO_CONFIG->control_url.'icon.php?extension='.$cms->f('extension').'" /></td>';
  194.  
  195.         if (eregi('htm',$cms->f('extension')))
  196.         {
  197.             if ($cms->f('title') != '')
  198.             {
  199.                 $link_name = $cms->f('title');
  200.             }else
  201.             {
  202.                 $link_name = strip_extension($cms->f('name'));
  203.             }
  204.             echo '<td nowrap> <a href=\'javascript:_insertHyperlink("view.php?site_id='.$site_id.'&file_id='.$cms->f('id').'", "'.$link_name.'");\' title="'.$cms->f('name').'">';
  205.         }else
  206.         {
  207.             echo '<td nowrap> <a href=\'javascript:_insertImage("download.php?site_id='.$site_id.'&file_id='.$cms->f('id').'");\' title="'.$cms->f('name').'">';
  208.         }
  209.  
  210.         if (isset($cut_files) && in_array($cms->f('id'), $cut_files))
  211.         {
  212.             echo '<font color="#7d7d7d">'.$short_name.'</font></a>  </td>';
  213.         }else
  214.         {
  215.             echo $short_name.'</a>  </td>';
  216.         }
  217.         echo '<td nowrap>'.$cms->f('friendly').'  </td>';
  218.         /*
  219.         echo '<td nowrap align="right">'.format_size($cms->f('size')).'  </td>';
  220.         echo '<td nowrap>'.date($_SESSION['GO_SESSION']['date_format'], $cms->f('mtime')).'  </td>';
  221.         */
  222.         echo '<td nowrap align="center">'.$cms->f('priority').'</td>';
  223.         echo '</tr>';
  224.         echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
  225.     }
  226. }
  227.  
  228. $count_items = $count_folders+$count_files;
  229. echo '<tr><td colspan="99" class="small" height="18"> '.$count_items.' item(s)     '.$fbFolderSize.': '.format_size($total_size).'</td></tr>';
  230. echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
  231. echo "</table>";
  232.  
  233. echo '</td></tr></table>';
  234. ?>
  235. <script type="text/javascript" language="javascript">
  236.  
  237. function _insertImage(url)
  238. {
  239.     opener.editor_insertHTML('<img src="'+url+'" border="0" align="absmiddle" />');
  240.     //opener.editor_insertImage(url);
  241.     window.close();
  242. }
  243.  
  244. function _insertHyperlink(url, name)
  245. {
  246.     opener.editor_insertHTML('<a href="'+url+'" target="_self">'+name+'</a>');
  247.     window.close();
  248. }
  249.  
  250. window.onblur = function() {
  251.     setTimeout('self.focus()',100);
  252. }
  253.  
  254. </script>
  255. <?php
  256. require($GO_THEME->theme_path."footer.inc");
  257. ?>