home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / cms / site_search_words.inc < prev    next >
Text File  |  2004-03-08  |  6KB  |  178 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. echo '<input type="hidden" name="task" />';
  14. $search_word_id = isset($_REQUEST['search_word_id']) ? $_REQUEST['search_word_id'] : 0;
  15. echo '<input type="hidden" name="search_word_id" value="'.$search_word_id.'" />';
  16.  
  17. if($task == 'add_search_word')
  18. {
  19.     if ($search_word_id > 0)
  20.     {
  21.         $search_word = $cms->get_search_word($search_word_id);
  22.         $search_word_name = $search_word['search_word'];
  23.     }else
  24.     {
  25.         $search_word_name = isset($_POST['search_word_name']) ? $_POST['search_word_name'] : '';
  26.     }
  27.     if (isset($feedback)) echo '<br />'.$feedback;
  28.     ?>
  29.     <table border="0" cellpadding="4">
  30.     <tr>
  31.         <td><?php echo $strName; ?></td>
  32.         <td><input type="text" class="textbox" size="30" name="search_word_name" value="<?php echo $search_word_name; ?>" />
  33.     </tr>
  34.     <tr>
  35.         <td colspan="2">
  36.         <table border="0">
  37.         <?php
  38.         function print_files($folder_id)
  39.         {
  40.             global $cms, $GO_CONFIG, $search_word_id, $searched_files;
  41.             $cms2 = new cms();
  42.  
  43.             $cms->get_files($folder_id);
  44.             while($cms->next_record())
  45.             {
  46.                 if(!isset($searched_files))
  47.                 {
  48.                     $check = $cms2->file_is_attached($cms->f('id'), $search_word_id) ? 'checked' : '';
  49.                 }else
  50.                 {
  51.                     $check = in_array($cms->f('id'), $searched_files) ? 'checked' : '';
  52.                 }
  53.                 echo '<tr><td><input type="hidden" name="files[]" value="'.$cms->f('id').'" /><input type="checkbox" name="selected_files[]" value="'.$cms->f('id').'" '.$check.' /></td>';
  54.                 echo '<td><img align="absmiddle" border="0" src="'.$GO_CONFIG->control_url.'icon.php?extension='.$cms->f('extension').'" /></td>';
  55.                 echo '<td>'.$cms2->get_path($folder_id).'/'.$cms->f('name');
  56.  
  57.             }
  58.  
  59.             $cms2->get_folders($folder_id);
  60.             while ($cms2->next_record())
  61.             {
  62.                 print_files($cms2->f('id'));
  63.             }
  64.         }
  65.  
  66.         $site = $cms->get_site($site_id);
  67.         //print_files($site['root_folder_id']);
  68.         if ($search_word_id > 0)
  69.         {
  70.             $cms2 = new cms();
  71.             $cms->get_attached_files($search_word_id);
  72.  
  73.             while($cms->next_record())
  74.             {
  75.                 echo '<tr><td><input type="hidden" name="files[]" value="'.$cms->f('id').'" /><input type="checkbox" name="selected_files[]" value="'.$cms->f('id').'" checked /></td>';
  76.                 echo '<td><img align="absmiddle" border="0" src="'.$GO_CONFIG->control_url.'icon.php?extension='.$cms->f('extension').'" /></td>';
  77.                 echo '<td><a href="browse.php?site_id='.$site_id.'&folder_id='.$cms->f('folder_id').'&file_id='.$cms->f('id').'">'.$cms2->get_path($cms->f('folder_id')).'/'.$cms->f('name').'</a></td></tr>';
  78.             }
  79.         }
  80.         ?>
  81.         </table>
  82.         </td>
  83.     </tr>
  84.     <tr>
  85.         <td colspan="2">
  86.         <?php
  87.         $button = new button($cmdOk, "javascript:save_search_word()");
  88.         echo '  ';
  89.         $button = new button($cms_search_files, "javascript:search_files()");
  90.         echo '  ';
  91.         $button = new button($cmdClose, "javascript:document.forms[0].submit()");
  92.         ?>
  93.         </td>
  94.     </tr>
  95.     </table>
  96.     <script type="text/javascript">
  97.  
  98.     function save_search_word()
  99.     {
  100.         document.forms[0].task.value='save_search_word';
  101.         document.forms[0].submit();
  102.     }
  103.  
  104.     function search_files()
  105.     {
  106.         document.forms[0].task.value='search_files';
  107.         document.forms[0].submit();
  108.     }
  109.     document.forms[0].search_word_name.focus();
  110.     </script>
  111.     <?php
  112. }else
  113. {
  114.     ?>
  115.     <br /><a class="normal" href="javascript:edit_search_word(0)"><?php echo $cmdAdd; ?></a><br /><br />
  116.     <?php
  117.     echo '<table border="0" cellspacing="8"><tr>';
  118.     $columns=3;
  119.     $column_count = 0;
  120.     $last_char = '';
  121.     $cms->get_search_words($site_id);
  122.     while ($cms->next_record())
  123.     {
  124.         $name = $cms->f('search_word');
  125.         $char = strtoupper($name[0]);
  126.         if ($char != $last_char)
  127.         {
  128.             if ($last_char != '')
  129.             {
  130.                 echo '</td>';
  131.                 $column_count++;
  132.             }
  133.  
  134.             if ($column_count == $columns)
  135.             {
  136.                 echo '</tr><tr>';
  137.                 $column_count=0;
  138.             }
  139.  
  140.             echo '<td valign="top" width="150"><h2>'.$char.'</h2>';
  141.         }
  142.  
  143.         echo '<table border="0" cellpadding="0" cellspacing="2"><tr><td nowrap>'.$name.'</td>';
  144.         echo '<td><a align="absmiddle" href="javascript:edit_search_word('.$cms->f('id').')" title="'.$strEdit.' \''.$cms->f('search_word').'\'"><img src="'.$GO_THEME->images['edit'].'" border="0" /></a></td>';
  145.         echo "<td><a align=\"absmiddle\" href='javascript:confirm_action(\"javascript:delete_search_word(".$cms->f('id').")\",\"".rawurlencode($strDeletePrefix."'".$cms->f('search_word')."'".$strDeleteSuffix)."\")' title=\"".$strDeleteItem." '".$cms->f('search_word')."'\"><img src=\"".$GO_THEME->images['delete']."\" border=\"0\"></a></td>";
  146.         echo '</tr></table>';
  147.         $last_char = $char;
  148.     }
  149.  
  150.     for ($i=$column_count+1;$i<$columns;$i++)
  151.     {
  152.         echo '</td><td width="150"> ';
  153.     }
  154.  
  155.     echo '</td></tr></table><br />';
  156.     $button = new button($cmdClose, "javascript:document.location='".$return_to."';");
  157.     ?>
  158.  
  159.     <script type="text/javascript">
  160.  
  161.     function edit_search_word(search_word_id)
  162.     {
  163.         document.forms[0].search_word_id.value = search_word_id;
  164.         document.forms[0].task.value='add_search_word';
  165.         document.forms[0].submit();
  166.     }
  167.  
  168.     function delete_search_word(search_word_id)
  169.     {
  170.         document.forms[0].search_word_id.value = search_word_id;
  171.         document.forms[0].task.value='delete_search_word';
  172.         document.forms[0].submit();
  173.     }
  174.     </script>
  175.     <?php
  176. }
  177. ?>
  178.