specific_fields.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2008 Dokeos SPRL
  6. For a full list of contributors, see "credits.txt".
  7. The full license can be read in "license.txt".
  8. This program is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU General Public License
  10. as published by the Free Software Foundation; either version 2
  11. of the License, or (at your option) any later version.
  12. See the GNU General Public License for more details.
  13. Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com
  14. ==============================================================================
  15. */
  16. /**
  17. * Manage specific fields
  18. *
  19. * @package dokeos.admin
  20. */
  21. $language_file[] = 'admin';
  22. // including some necessary dokeos files
  23. require('../inc/global.inc.php');
  24. // user permissions
  25. api_protect_admin_script();
  26. // breadcrumb
  27. $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
  28. $interbreadcrumb[] = array ("url" => 'specific_fields.php', "name" => get_lang('SpecificSearchFields'));
  29. $libpath = api_get_path(LIBRARY_PATH);
  30. include_once ($libpath.'specific_fields_manager.lib.php');
  31. require_once ($libpath.'formvalidator/FormValidator.class.php');
  32. // Create an add-field box
  33. $form = new FormValidator('add_field','post','','',null,false);
  34. $renderer =& $form->defaultRenderer();
  35. $renderer->setElementTemplate('<span>{element}</span> ');
  36. $form->addElement('static','search_advanced_link',null,'<a href="specific_fields_add.php">'.Display::return_icon('fieldadd.gif').get_lang('AddSpecificSearchField').'</a>');
  37. // Create a sortable table with specific fields data
  38. $column_show = array(1,1,1,1);
  39. $column_order = array(3,2,1,4);
  40. $extra_fields = get_specific_field_list();
  41. $number_of_extra_fields = count($extra_fields);
  42. $table = new SortableTableFromArrayConfig($extra_fields,2,50,'',$column_show,$column_order);
  43. $table->set_header(0, '', false,null,'width="2%"', 'style="display:none"');
  44. $table->set_header(1, get_lang('Code'), TRUE, 'width="10%"');
  45. $table->set_header(2, get_lang('Name'));
  46. $table->set_header(3, get_lang('Modify'),true,'width="10%"');
  47. $table->set_column_filter(3, 'edit_filter');
  48. function edit_filter($id,$url_params,$row)
  49. {
  50. global $charset;
  51. $return = '<a href="specific_fields_add.php?action=edit&field_id='.$row[0].'">'.Display::return_icon('edit.gif',get_lang('Edit')).'</a>';
  52. $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>';
  53. return $return;
  54. }
  55. if ($_REQUEST['action'] == 'delete') {
  56. delete_specific_field($_REQUEST['field_id']);
  57. header('Location: specific_fields.php?message='.get_lang('FieldRemoved'));
  58. }
  59. // Start output
  60. // Displaying the header
  61. Display::display_header($nameTools);
  62. echo '<div class="admin-tool-intro">'.get_lang('SpecificSearchFieldsIntro').'</div>';
  63. if(!empty($_GET['message']))
  64. {
  65. Display::display_confirmation_message($_GET['message']);
  66. }
  67. echo '<div class="actions">';
  68. $form->display();
  69. echo '</div>';
  70. $table->display();
  71. // Displaying the footer
  72. Display::display_footer();