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>';
 }
Example #2
0
 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>';
 }
    $announcement_data = array();
    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();
}
    $table->set_header(3, get_lang('Email'), true);
    $table->set_header(4, get_lang('Status'), true);
    $table->set_header(5, '', false);
    $table->display();
} else {
    echo get_lang('NoUsersInCourse');
}
$session_list = SessionManager::get_session_by_course($course->code);
$url = api_get_path(WEB_CODE_PATH);
if (!empty($session_list)) {
    foreach ($session_list as &$session) {
        $session[0] = Display::url($session[0], $url . 'admin/resume_session.php?id_session=' . $session['id']);
        unset($session[1]);
    }
    echo Display::page_header(get_lang('Sessions'));
    $table = new SortableTableFromArray($session_list, 0, 20, 'user_table');
    $table->display();
}
/*$group = new UserGroup();
$usegroups = $group->get_usergroup_by_course($course->id);*/
/*@todo This should be dissapear classes are a deprecated feature*/
/*
//Show all classes subscribed in this course

$table_course_class = Database :: get_main_table(TABLE_MAIN_COURSE_CLASS);
$table_class 		= Database :: get_main_table(TABLE_MAIN_CLASS);
$sql = "SELECT * FROM $table_course_class cc, $table_class c WHERE cc.class_id = c.id AND cc.course_code = '".$code."'";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
	$data = array ();
	while ($class = Database::fetch_object($res)) {
        if ($mode == 'gallery') {
            $title = $a_prefix.str_replace('_',' ',$result['title']). $a_sufix;
            $blocks[] = array(
                $a_prefix .'<img src="'.$result['thumbnail'].'" />'. $a_sufix .'<br />'.$title.'<br />'.$result['author'],
            );
        } else {
            $title = '<div style="text-align:left;">'. $a_prefix . $result['title']. $a_sufix .(!empty($result['author']) ? ' '.$result['author'] : '').'<div>';
            $blocks[] = array($title);
        }
    }
}

// Show results.
if (count($blocks) > 0) {
    $s = new SortableTableFromArray($blocks);
    $s->display_mode = $mode; // default
    $s->display_mode_params = 3;
    $s->per_page = 9;
    $additional_parameters = array (
        'mode' => $mode,
        'action' => 'search',
        'query' => Security::remove_XSS($_REQUEST['query']),
    );
    $get_params = '';
    foreach ($specific_fields as $specific_field) {
        if (isset($_REQUEST[ 'sf_'. $specific_field['code'] ])) {
            $values = $_REQUEST[ 'sf_'. $specific_field['code'] ];
            //Sortable additional_parameters doesn't accept multi dimensional arrays
            //$additional_parameters[ 'sf_'. $specific_field['code'] ] = $values;
            foreach ( $values as $value ) {
Example #6
0
 /**
  * Gets a nice grid in html string
  * @param string grid name (important to create css)
  * @param array header content
  * @param array array with the information to show
  * @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
  * 					'hide_navigation' =  true to hide the navigation
  * @param array $query_vars Additional variables to add in the query-string
  * @param array $form actions Additional variables to add in the query-string
  * @param mixed An array with bool values to know which columns show. i.e:
  *  $visibility_options= array(true, false) we will only show the first column
  * 	Can be also only a bool value. TRUE: show all columns, FALSE: show nothing
  * @param bool  true for sorting data or false otherwise
  * @param array grid classes
  * @return 	string   html grid
  */
 public static function return_sortable_grid($name, $header, $content, $paging_options = array(), $query_vars = null, $form_actions = array(), $visibility_options = true, $sort_data = true, $grid_class = array(), $elementCount = 0)
 {
     $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, $name);
     $table->total_number_of_items = intval($elementCount);
     if (is_array($query_vars)) {
         $table->set_additional_parameters($query_vars);
     }
     return $table->display_simple_grid($visibility_options, $paging_options['hide_navigation'], $default_items_per_page, $sort_data, $grid_class);
 }
Example #7
0
/**
 * 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'));
        }
    }
}
        //document title with hyperlink
        $row[] = '<a href="#" onclick="javascript: OpenFile(\'' . $http_www . '/' . $id['title'] . '\', \'' . $sType . '\');return false;">' . $id['title'] . '</a>';
        //comments => display comment under the document name
        //$row[] = $invisibility_span_open.nl2br(htmlspecialchars($id['comment'])).$invisibility_span_close;
        $display_size = format_file_size($size);
        $row[] = '<span style="display:none;">' . $size . '</span>' . $invisibility_span_open . $display_size . $invisibility_span_close;
        //last edit date
        $display_date = format_date(strtotime($id['lastedit_date']));
        $row[] = '<span style="display:none;">' . $id['lastedit_date'] . '</span>' . $invisibility_span_open . $display_date . $invisibility_span_close;
        $sortable_data[] = $row;
    }
} else {
    $sortable_data = array();
    //$table_footer='<div style="text-align:center;"><strong>'.get_lang('NoDocsInFolder').'</strong></div>';
}
$table = new SortableTableFromArray($sortable_data, 4, 10);
$query_vars['curdirpath'] = $curdirpath;
if (isset($_SESSION['_gid'])) {
    $query_vars['gidReq'] = $_SESSION['_gid'];
}
$table->set_additional_parameters($query_vars);
$column = 0;
/*
if ($is_allowed_to_edit AND count($docs_and_folders) > 1) {
	$table->set_header($column++, '', false);
}
*/
$table->set_header($column++, api_htmlentities(get_lang('Type'), ENT_QUOTES));
$table->set_header($column++, api_htmlentities(get_lang('Title'), ENT_QUOTES));
//$column_header[] = array(get_lang('Comment'),true);  => display comment under the document name
$table->set_header($column++, api_htmlentities(get_lang('Size'), ENT_QUOTES));