/** * This is the main function that displays the list or the table with all * the glossary terms * @param string View ('table' or 'list'). Optional parameter. * Defaults to 'table' and prefers glossary_view from the session by default. * @return void * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium * @version januari 2009, dokeos 1.8.6 */ public static function display_glossary($view = 'table') { // This function should always be called with the corresponding // parameter for view type. Meanwhile, use this cheap trick. $glossaryView = Session::read('glossary_view'); if (empty($glossaryView)) { Session::write('glossary_view', $view); } // action links echo '<div class="actions">'; if (api_is_allowed_to_edit(null, true)) { echo '<a href="index.php?' . api_get_cidreq() . '&action=addglossary&msg=add?' . api_get_cidreq() . '">' . Display::return_icon('new_glossary_term.png', get_lang('TermAddNew'), '', ICON_SIZE_MEDIUM) . '</a>'; } echo '<a href="index.php?' . api_get_cidreq() . '&action=export">' . Display::return_icon('export_csv.png', get_lang('ExportGlossaryAsCSV'), '', ICON_SIZE_MEDIUM) . '</a>'; if (api_is_allowed_to_edit(null, true)) { echo '<a href="index.php?' . api_get_cidreq() . '&action=import">' . Display::return_icon('import_csv.png', get_lang('ImportGlossary'), '', ICON_SIZE_MEDIUM) . '</a>'; } echo '<a href="index.php?' . api_get_cidreq() . '&action=export_to_pdf">' . Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM) . '</a>'; if (isset($glossaryView) && $glossaryView == 'table' or !isset($glossaryView)) { echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=list">' . Display::return_icon('view_detailed.png', get_lang('ListView'), '', ICON_SIZE_MEDIUM) . '</a>'; } else { echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=table">' . Display::return_icon('view_text.png', get_lang('TableView'), '', ICON_SIZE_MEDIUM) . '</a>'; } echo '</div>'; if (!$glossaryView || $glossaryView == 'table') { $table = new SortableTable('glossary', array('GlossaryManager', 'get_number_glossary_terms'), array('GlossaryManager', 'get_glossary_data'), 0); //$table->set_header(0, '', false); $table->set_header(0, get_lang('TermName'), true); $table->set_header(1, get_lang('TermDefinition'), true); if (api_is_allowed_to_edit(null, true)) { $table->set_header(2, get_lang('Actions'), false, 'width=90px', array('class' => 'td_actions')); $table->set_column_filter(2, array('GlossaryManager', 'actions_filter')); } $table->display(); } if ($glossaryView == 'list') { GlossaryManager::display_glossary_list(); } }
/** * This is the main function that displays the list or the table with all * the glossary terms * @param string View ('table' or 'list'). Optional parameter. * Defaults to 'table' and prefers glossary_view from the session by default. * @return void * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium * @version januari 2009, dokeos 1.8.6 */ public static function display_glossary($view = 'table') { // This function should always be called with the corresponding // parameter for view type. Meanwhile, use this cheap trick. $glossaryView = Session::read('glossary_view'); if (empty($glossaryView)) { Session::write('glossary_view', $view); } // action links //echo '<div class="actions">'; $actionsLeft = ''; if (api_is_allowed_to_edit(null, true)) { $actionsLeft .= '<a href="index.php?' . api_get_cidreq() . '&action=addglossary&msg=add?' . api_get_cidreq() . '">' . Display::return_icon('new_glossary_term.png', get_lang('TermAddNew'), '', ICON_SIZE_MEDIUM) . '</a>'; } $actionsLeft .= '<a href="index.php?' . api_get_cidreq() . '&action=export">' . Display::return_icon('export_csv.png', get_lang('ExportGlossaryAsCSV'), '', ICON_SIZE_MEDIUM) . '</a>'; if (api_is_allowed_to_edit(null, true)) { $actionsLeft .= '<a href="index.php?' . api_get_cidreq() . '&action=import">' . Display::return_icon('import_csv.png', get_lang('ImportGlossary'), '', ICON_SIZE_MEDIUM) . '</a>'; } $actionsLeft .= '<a href="index.php?' . api_get_cidreq() . '&action=export_to_pdf">' . Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM) . '</a>'; if (isset($_SESSION['glossary_view']) && $_SESSION['glossary_view'] == 'table' or !isset($_SESSION['glossary_view'])) { $actionsLeft .= '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=list">' . Display::return_icon('view_detailed.png', get_lang('ListView'), '', ICON_SIZE_MEDIUM) . '</a>'; } else { $actionsLeft .= '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=table">' . Display::return_icon('view_text.png', get_lang('TableView'), '', ICON_SIZE_MEDIUM) . '</a>'; } /* BUILD SEARCH FORM */ $form = new FormValidator('search', 'get', api_get_self() . '?' . api_get_cidreq(), '', array(), FormValidator::LAYOUT_INLINE); $form->addText('keyword', '', false, array('class' => 'col-md-2')); $form->addElement('hidden', 'cidReq', api_get_course_id()); $form->addElement('hidden', 'id_session', api_get_session_id()); $form->addButtonSearch(get_lang('Search')); $actionsRight = $form->returnForm(); $toolbar = Display::toolbarAction('toolbar-document', array(0 => $actionsLeft, 1 => $actionsRight)); echo $toolbar; if ($glossaryView == 'table') { $table = new SortableTable('glossary', array('GlossaryManager', 'get_number_glossary_terms'), array('GlossaryManager', 'get_glossary_data'), 0); //$table->set_header(0, '', false); $table->set_header(0, get_lang('TermName'), true); $table->set_header(1, get_lang('TermDefinition'), true); if (api_is_allowed_to_edit(null, true)) { $table->set_header(2, get_lang('Actions'), false, 'width=90px', array('class' => 'td_actions')); $table->set_column_filter(2, array('GlossaryManager', 'actions_filter')); } $table->display(); } if ($glossaryView == 'list') { GlossaryManager::display_glossary_list(); } }