function show_html()
 {
     $sections = array('chamilo', 'php', 'mysql', 'webserver');
     if (!in_array(trim($_GET['section']), $sections)) {
         $current_section = 'chamilo';
     } else {
         $current_section = $_GET['section'];
     }
     $html = '<div class="tabbable"><ul class="nav nav-tabs">';
     foreach ($sections as $section) {
         if ($current_section == $section) {
             $html .= '<li class="active">';
         } else {
             $html .= '<li>';
         }
         $params['section'] = $section;
         $html .= '<a href="system_status.php?section=' . $section . '">' . get_lang($section) . '</a></li>';
     }
     $html .= '</ul><div class="tab-pane">';
     $data = call_user_func(array($this, 'get_' . $current_section . '_data'));
     echo $html;
     $table = new SortableTableFromArray($data, 1, 100);
     $table->set_header(0, '', false);
     $table->set_header(1, get_lang('Section'), false);
     $table->set_header(2, get_lang('Setting'), false);
     $table->set_header(3, get_lang('Current'), false);
     $table->set_header(4, get_lang('Expected'), false);
     $table->set_header(5, get_lang('Comment'), false);
     $table->display();
     echo '</div></div>';
 }
 public function show_html()
 {
     $sections = array('chamilo', 'php', 'database', 'webserver', 'paths');
     $currentSection = isset($_GET['section']) ? $_GET['section'] : 'chamilo';
     if (!in_array(trim($currentSection), $sections)) {
         $currentSection = 'chamilo';
     }
     $html = '<div class="tabbable"><ul class="nav nav-tabs">';
     foreach ($sections as $section) {
         if ($currentSection === $section) {
             $html .= '<li class="active">';
         } else {
             $html .= '<li>';
         }
         $params['section'] = $section;
         $html .= '<a href="system_status.php?section=' . $section . '">' . get_lang($section) . '</a></li>';
     }
     $html .= '</ul><div class="tab-pane">';
     $data = call_user_func(array($this, 'get_' . $currentSection . '_data'));
     echo $html;
     if ($currentSection != 'paths') {
         $table = new SortableTableFromArray($data, 1, 100);
         $table->set_header(0, '', false);
         $table->set_header(1, get_lang('Section'), false);
         $table->set_header(2, get_lang('Setting'), false);
         $table->set_header(3, get_lang('Current'), false);
         $table->set_header(4, get_lang('Expected'), false);
         $table->set_header(5, get_lang('Comment'), false);
         $table->display();
     } else {
         $headers = $data['headers'];
         $results = $data['data'];
         $table = new HTML_Table(array('class' => 'data_table'));
         $column = 0;
         foreach ($headers as $header) {
             $table->setHeaderContents(0, $column, $header);
             $column++;
         }
         $row = 1;
         foreach ($results as $index => $rowData) {
             $table->setCellContents($row, 0, $rowData);
             $table->setCellContents($row, 1, $index);
             $row++;
         }
         echo $table->display();
     }
     echo '</div></div>';
 }
    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();
            foreach ( $values as $value ) {
                $get_params .= '&sf_' . $specific_field['code'] .'[]='. $value;
            }
            $get_params .= '&';
        }
    }
    $additional_parameters['operator'] = $op;

    $s->additional_parameters = $additional_parameters;

    if ($mode == 'default') {
        $s->set_header(0, get_lang(ucfirst(TOOL_SEARCH)), false);
    }

    $search_link = '<a href="%ssearch/index.php?mode=%s&action=search&query=%s%s">';

    $mode_selector = '<div id="mode-selector">';
    $mode_selector .= sprintf($search_link, api_get_path(WEB_CODE_PATH), 'gallery', $_REQUEST['query'], $get_params);
    $mode_selector .= '<img src="../img/'. (($mode=='gallery')?'ButtonGallOn':'ButtonGallOff') .'.png" /></a>';
    $mode_selector .= sprintf($search_link, api_get_path(WEB_CODE_PATH), 'default', $_REQUEST['query'], $get_params);
    $mode_selector .= '<img src="../img/'.(($mode=='default')?'ButtonListOn':'ButtonListOff').'.png" /></a>';
    $mode_selector .= '</div>';

    echo '<div id="search-results-container">';
    echo $mode_selector;
    $s->display();
    echo '</div>';
}

Display::display_footer();
 /**
  * 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();
     }
 }
/**
 * Search options
 * TODO: support for multiple site. aka $_configuration['access_url'] == 1
 * @author Marco Villegas <*****@*****.**>
 */
function handle_search()
{
    global $SettingsStored, $_configuration;
    require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
    $search_enabled = api_get_setting('search.search_enabled');
    $form = new FormValidator('search-options', 'post', api_get_self() . '?category=Search');
    $values = api_get_settings_options('search_enabled');
    $form->addElement('header', null, get_lang('SearchEnabledTitle'));
    $group = array();
    if (is_array($values)) {
        foreach ($values as $key => $value) {
            $element =& $form->createElement('radio', 'search_enabled', '', get_lang($value['display_text']), $value['value']);
            $group[] = $element;
        }
    }
    //SearchEnabledComment
    $form->addGroup($group, 'search_enabled', array(get_lang('SearchEnabledTitle'), get_lang('SearchEnabledComment')), '<br />', false);
    $search_enabled = api_get_setting('search.search_enabled');
    if ($form->validate()) {
        $formvalues = $form->exportValues();
        $r = api_set_settings_category('Search', 'false', $_configuration['access_url']);
        // Save the settings.
        foreach ($formvalues as $key => $value) {
            $result = api_set_setting($key, $value, null, null);
        }
        $search_enabled = $formvalues['search_enabled'];
        Display::display_confirmation_message($SettingsStored);
    }
    $specific_fields = get_specific_field_list();
    if ($search_enabled == 'true') {
        $values = api_get_settings_options('search_show_unlinked_results');
        $group = array();
        foreach ($values as $key => $value) {
            $element =& $form->createElement('radio', 'search_show_unlinked_results', '', get_lang($value['display_text']), $value['value']);
            $group[] = $element;
        }
        $form->addGroup($group, 'search_show_unlinked_results', array(get_lang('SearchShowUnlinkedResultsTitle'), get_lang('SearchShowUnlinkedResultsComment')), '', false);
        $default_values['search_show_unlinked_results'] = api_get_setting('search_show_unlinked_results');
        $sf_values = array();
        foreach ($specific_fields as $sf) {
            $sf_values[$sf['code']] = $sf['name'];
        }
        $group = array();
        $url = Display::div(Display::url(get_lang('AddSpecificSearchField'), 'specific_fields.php'), array('class' => 'sectioncomment'));
        if (empty($sf_values)) {
            $form->addElement('html', get_lang('SearchPrefilterPrefix') . $url);
        } else {
            $form->addElement('select', 'search_prefilter_prefix', array(get_lang('SearchPrefilterPrefix'), $url), $sf_values, '');
            $default_values['search_prefilter_prefix'] = api_get_setting('search_prefilter_prefix');
        }
    }
    $default_values['search_enabled'] = $search_enabled;
    $form->addButtonSave(get_lang('Save'));
    $form->setDefaults($default_values);
    echo '<div id="search-options-form">';
    $form->display();
    echo '</div>';
    if ($search_enabled == 'true') {
        $xapian_path = api_get_path(SYS_UPLOAD_PATH) . 'plugins/xapian/searchdb';
        /*
        @todo Test the Xapian connection
        if (extension_loaded('xapian')) {
            require_once 'xapian.php';
            try {
                $db = new XapianDatabase($xapian_path.'/');
            } catch (Exception $e) {
                var_dump($e->getMessage());
            }
        
            require_once api_get_path(LIBRARY_PATH) . 'search/DokeosIndexer.class.php';
            require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php';
            require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
        
            $indexable = new IndexableChunk();
            $indexable->addValue("content", 'Test');
        
            $di = new DokeosIndexer();
            $di->connectDb(NULL, NULL, 'english');
            $di->addChunk($indexable);
            $did = $di->index();
        }
        */
        $xapian_loaded = Display::return_icon('bullet_green.gif', get_lang('Ok'));
        $dir_exists = Display::return_icon('bullet_green.gif', get_lang('Ok'));
        $dir_is_writable = Display::return_icon('bullet_green.gif', get_lang('Ok'));
        $specific_fields_exists = Display::return_icon('bullet_green.gif', get_lang('Ok'));
        //Testing specific fields
        if (empty($specific_fields)) {
            $specific_fields_exists = Display::return_icon('bullet_red.gif', get_lang('AddSpecificSearchField'));
        }
        //Testing xapian extension
        if (!extension_loaded('xapian')) {
            $xapian_loaded = Display::return_icon('bullet_red.gif', get_lang('Error'));
        }
        //Testing xapian searchdb path
        if (!is_dir($xapian_path)) {
            $dir_exists = Display::return_icon('bullet_red.gif', get_lang('Error'));
        }
        //Testing xapian searchdb path is writable
        if (!is_writable($xapian_path)) {
            $dir_is_writable = Display::return_icon('bullet_red.gif', get_lang('Error'));
        }
        $data[] = array(get_lang('XapianModuleInstalled'), $xapian_loaded);
        $data[] = array(get_lang('DirectoryExists') . ' - ' . $xapian_path, $dir_exists);
        $data[] = array(get_lang('IsWritable') . ' - ' . $xapian_path, $dir_is_writable);
        $data[] = array(get_lang('SpecificSearchFieldsAvailable'), $specific_fields_exists);
        echo Display::tag('h3', get_lang('Settings'));
        $table = new SortableTableFromArray($data);
        $table->set_header(0, get_lang('Setting'), false);
        $table->set_header(1, get_lang('Status'), false);
        echo $table->display();
        //@todo windows support
        if (api_is_windows_os() == false) {
            $list_of_programs = array('pdftotext', 'ps2pdf', 'catdoc', 'html2text', 'unrtf', 'catppt', 'xls2csv');
            foreach ($list_of_programs as $program) {
                $output = $ret_val = null;
                exec("which {$program}", $output, $ret_val);
                $icon = Display::return_icon('bullet_red.gif', get_lang('NotInstalled'));
                if (!empty($output[0])) {
                    $icon = Display::return_icon('bullet_green.gif', get_lang('Installed'));
                }
                $data2[] = array($program, $output[0], $icon);
            }
            echo Display::tag('h3', get_lang('ProgramsNeededToConvertFiles'));
            $table = new SortableTableFromArray($data2);
            $table->set_header(0, get_lang('Program'), false);
            $table->set_header(1, get_lang('Path'), false);
            $table->set_header(2, get_lang('Status'), false);
            echo $table->display();
        } else {
            Display::display_warning_message(get_lang('YouAreUsingChamiloInAWindowsPlatformSadlyYouCantConvertDocumentsInOrderToSearchTheContentUsingThisTool'));
        }
    }
}