update_indexabletext.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php /* <!-- Dokeos metadata/udate_indexableText.php -->
  2. <!-- 2005/03/16 -->
  3. <!-- Copyright (C) 2005 rene.haentjens@UGent.be - see metadata/md_funcs.php -->
  4. */
  5. /**
  6. ==============================================================================
  7. * Dokeos Metadata: update indexabletext for all eid_type records
  8. *
  9. * @package dokeos.metadata
  10. ==============================================================================
  11. */
  12. // PRELIMS -------------------------------------------------------------------->
  13. require('md_funcs.php');
  14. getpar('EID_TYPE', 'Entry Type'); // e.g. 'Document' or 'Scorm'
  15. define('TPLEN', strlen(EID_TYPE) + 1);
  16. require('md_' . strtolower(EID_TYPE) . '.php');
  17. // name of the language file that needs to be included
  18. $language_file = 'md_' . strtolower(EID_TYPE);
  19. include('../inc/global.inc.php');
  20. $this_section=SECTION_COURSES;
  21. $nameTools = get_lang('Tool');
  22. ($nameTools && get_lang('Sorry')) or give_up(
  23. 'Language file ' . $language_file . " doesn't define 'Tool' and 'Sorry'");
  24. $_course = api_get_course_info(); isset($_course) or give_up(get_lang('Sorry'));
  25. $is_allowed_to_edit = isset($_user['user_id']) && $is_courseMember && is_allowed_to_edit();
  26. if (!$is_allowed_to_edit) give_up(get_lang('Denied'));
  27. $mdStore = new mdstore($is_allowed_to_edit); // create table if needed
  28. $mdObj = new mdobject($_course, 0);
  29. require(api_get_path(LIBRARY_PATH) . 'xmd.lib.php');
  30. require(api_get_path(LIBRARY_PATH) . 'xht.lib.php');
  31. $xhtDoc = $mdObj->mdo_define_htt();
  32. $mdObj->mdo_add_breadcrump_nav(); // see 'md_' . EID_TYPE . '.php'
  33. Display::display_header($nameTools);
  34. // OPERATIONS ----------------------------------------------------------------->
  35. echo '<h3>', htmlspecialchars(EID_TYPE, ENT_QUOTES, $charset), '</h3>', "\n";
  36. $result = $mdStore->mds_get_many('eid,mdxmltext', "eid LIKE '" . EID_TYPE . ".%'");
  37. echo get_lang('TotalMDEs'), $total = Database::num_rows($result), "<br><br>\n";
  38. if ($total > 100) set_time_limit((int) ($total / 10));
  39. while ($row = Database::fetch_array($result))
  40. {
  41. $eid = $row['eid']; $xmltext = $row['mdxmltext'];
  42. $xhtDoc->xht_xmldoc = new xmddoc(explode("\n", $xmltext));
  43. $mdStore->mds_put($eid,
  44. $xhtDoc->xht_fill_template('INDEXABLETEXT'), 'indexabletext');
  45. echo htmlspecialchars($eid, ENT_QUOTES, $charset), ' ';
  46. }
  47. echo '<h5>', htmlspecialchars(EID_TYPE, ENT_QUOTES, $charset), '</h5>', "\n";
  48. Display::display_footer();
  49. ?>