foreach ($announcements as $index => $announcement) {
        $row = array();
        $row[] = $announcement->id;
        $row[] = Display::return_icon($announcement->visible ? 'accept.png' : 'exclamation.png', $announcement->visible ? get_lang('AnnouncementAvailable') : get_lang('AnnouncementNotAvailable'));
        $row[] = $announcement->title;
        $row[] = api_convert_and_format_date($announcement->date_start);
        $row[] = api_convert_and_format_date($announcement->date_end);
        $row[] = "<a href=\"?id=" . $announcement->id . "&person=" . SystemAnnouncementManager::VISIBLE_TEACHER . "&action=" . ($announcement->visible_teacher ? 'make_invisible' : 'make_visible') . "\">" . Display::return_icon($announcement->visible_teacher ? 'eyes.png' : 'eyes-close.png', get_lang('ShowOrHide')) . "</a>";
        $row[] = "<a href=\"?id=" . $announcement->id . "&person=" . SystemAnnouncementManager::VISIBLE_STUDENT . "&action=" . ($announcement->visible_student ? 'make_invisible' : 'make_visible') . "\">" . Display::return_icon($announcement->visible_student ? 'eyes.png' : 'eyes-close.png', get_lang('ShowOrHide')) . "</a>";
        $row[] = "<a href=\"?id=" . $announcement->id . "&person=" . SystemAnnouncementManager::VISIBLE_GUEST . "&action=" . ($announcement->visible_guest ? 'make_invisible' : 'make_visible') . "\">" . Display::return_icon($announcement->visible_guest ? 'eyes.png' : 'eyes-close.png', get_lang('ShowOrHide')) . "</a>";
        $row[] = $announcement->lang;
        $row[] = "<a href=\"?action=edit&id=" . $announcement->id . "\">" . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . "</a> <a href=\"?action=delete&id=" . $announcement->id . "\"  onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . "</a>";
        $announcement_data[] = $row;
    }
    $table = new SortableTableFromArray($announcement_data);
    $table->set_header(0, '', false);
    $table->set_header(1, get_lang('Active'));
    $table->set_header(2, get_lang('Title'));
    $table->set_header(3, get_lang('StartTimeWindow'));
    $table->set_header(4, get_lang('EndTimeWindow'));
    $table->set_header(5, get_lang('Teacher'));
    $table->set_header(6, get_lang('Student'));
    $table->set_header(7, get_lang('Guest'));
    $table->set_header(8, get_lang('Language'));
    $table->set_header(9, get_lang('Modify'), false, 'width="50px"');
    $form_actions = array();
    $form_actions['delete_selected'] = get_lang('Delete');
    $table->set_form_actions($form_actions);
    $table->display();
}
Display::display_footer();
Exemplo n.º 2
0
 /**
  * Displays a table
  * @param array $header Titles for the table header
  * 						each item in this array can contain 3 values
  * 						- 1st element: the column title
  * 						- 2nd element: true or false (column sortable?)
  * 						- 3th element: additional attributes for
  *  						th-tag (eg for column-width)
  * 						- 4the element: additional attributes for the td-tags
  * @param array $content 2D-array with the tables content
  * @param array $sorting_options Keys are:
  * 					'column' = The column to use as sort-key
  * 					'direction' = SORT_ASC or SORT_DESC
  * @param array $paging_options Keys are:
  * 					'per_page_default' = items per page when switching from
  * 										 full-	list to per-page-view
  * 					'per_page' = number of items to show per page
  * 					'page_nr' = The page to display
  * @param array $query_vars Additional variables to add in the query-string
  * @param string The style that the table will show. You can set 'table' or 'grid'
  * @author bart.mollet@hogent.be
  */
 public static function display_sortable_table($header, $content, $sorting_options = array(), $paging_options = array(), $query_vars = null, $form_actions = array(), $style = 'table')
 {
     global $origin;
     $column = isset($sorting_options['column']) ? $sorting_options['column'] : 0;
     $default_items_per_page = isset($paging_options['per_page']) ? $paging_options['per_page'] : 20;
     $table = new SortableTableFromArray($content, $column, $default_items_per_page);
     if (is_array($query_vars)) {
         $table->set_additional_parameters($query_vars);
     }
     if ($style == 'table') {
         if (is_array($header) && count($header) > 0) {
             foreach ($header as $index => $header_item) {
                 $table->set_header($index, $header_item[0], $header_item[1], isset($header_item[2]) ? $header_item[2] : null, isset($header_item[3]) ? $header_item[3] : null);
             }
         }
         $table->set_form_actions($form_actions);
         $table->display();
     } else {
         $table->display_grid();
     }
 }