specific_fields.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use Chamilo\CoreBundle\Framework\Container;
  4. /**
  5. * Manage specific fields
  6. *
  7. * @package chamilo.admin
  8. */
  9. // Resetting the course id.
  10. $cidReset = true;
  11. // User permissions
  12. api_protect_admin_script();
  13. // Breadcrumb
  14. $interbreadcrumb[] = array ('url' => Container::getRouter()->generate('administration'), 'name' => get_lang('PlatformAdmin'));
  15. $interbreadcrumb[] = array ('url' => 'settings.php?category=Search', 'name' => get_lang('PlatformConfigSettings'));
  16. $libpath = api_get_path(LIBRARY_PATH);
  17. include_once $libpath.'specific_fields_manager.lib.php';
  18. // Create an add-field box
  19. $form = new FormValidator('add_field','post','','',null,false);
  20. $renderer =& $form->defaultRenderer();
  21. $renderer->setCustomElementTemplate('<span>{element}</span> ');
  22. $form->addElement('static','search_advanced_link',null,'<a href="specific_fields_add.php">'.Display::return_icon('fieldadd.gif').get_lang('AddSpecificSearchField').'</a>');
  23. // Create a sortable table with specific fields data
  24. $column_show = array(1,1,1);
  25. $column_order = array(3,2,1);
  26. $extra_fields = get_specific_field_list();
  27. $number_of_extra_fields = count($extra_fields);
  28. $table = new SortableTableFromArrayConfig($extra_fields,2,50,'',$column_show,$column_order);
  29. $table->set_header(0, '&nbsp;', false,null,'width="2%"', 'style="display:none"');
  30. $table->set_header(1, get_lang('Code'), TRUE, 'width="10%"');
  31. $table->set_header(2, get_lang('Name'));
  32. $table->set_header(3, get_lang('Modify'),false,'width="10%"');
  33. $table->set_column_filter(3, 'edit_filter');
  34. function edit_filter($id,$url_params,$row) {
  35. global $charset;
  36. $return = '<a href="specific_fields_add.php?action=edit&field_id='.$row[0].'">'.Display::return_icon('edit.gif',get_lang('Edit')).'</a>';
  37. $return .= ' <a href="'.api_get_self().'?action=delete&field_id='.$row[0].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.Display::return_icon('delete.gif',get_lang('Delete')).'</a>';
  38. return $return;
  39. }
  40. if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
  41. delete_specific_field($_REQUEST['field_id']);
  42. header('Location: specific_fields.php?message='.get_lang('FieldRemoved'));
  43. exit;
  44. }
  45. // Start output
  46. // Displaying the header
  47. Display::display_header(get_lang('SpecificSearchFields'));
  48. echo Display::display_normal_message(get_lang('SpecificSearchFieldsIntro'));
  49. if(!empty($_GET['message'])) {
  50. Display::display_confirmation_message($_GET['message']);
  51. }
  52. echo '<div class="actions">';
  53. $form->display();
  54. echo '</div>';
  55. if (!empty($extra_fields)) {
  56. $table->display();
  57. }
  58. // Displaying the footer
  59. Display::display_footer();