update_indexabletext.php 2.2 KB

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