dokeos-metadata
[ class tree: dokeos-metadata ] [ index: dokeos-metadata ] [ all elements ]

Source for file importdocs.php

Documentation is available at importdocs.php

  1. <?php /*                                 <!-- Dokeos metadata/importdocs.php -->
  2.                                                              <!-- 2005/09/20 -->
  3.  
  4. <!-- Copyright (C) 2005 rene.haentjens@UGent.be -  see metadata/md_funcs.php -->
  5.  
  6. */
  7.  
  8. /**
  9. ============================================================================== 
  10. *    Dokeos Metadata: index all course documents with PhpDig
  11. *
  12. *    @package dokeos.metadata
  13. ============================================================================== 
  14. */
  15.  
  16.  
  17. // PRELIMS -------------------------------------------------------------------->
  18.  
  19. $getpostvars array('dmo')require('md_funcs.php');
  20.  
  21. define('EID_TYPE''Document')define('AFTER_DOT'strlen(EID_TYPE1);
  22. define('OF_EID_TYPE'"eid LIKE '" EID_TYPE ".%'");
  23.  
  24. require('md_' strtolower(EID_TYPE'.php');
  25.  
  26. // name of the language file that needs to be included 
  27. $language_file 'md_' strtolower(EID_TYPE);
  28. include('../inc/global.inc.php');
  29. $nameTools get_lang('Tool');
  30.  
  31. ($nameTools && get_lang('Sorry')) or give_up
  32.     'Language file ' $language_file " doesn't define 'Tool' and 'Sorry'");
  33.  
  34. $_course api_get_course_info()isset($_courseor give_up(get_lang('Sorry'));
  35.  
  36. $is_allowed_to_edit = isset($_user['user_id']&& $is_courseMember && is_allowed_to_edit();
  37. if (!$is_allowed_to_editgive_up(get_lang('Denied'));
  38.  
  39. $mdObj new mdobject($_course0);
  40. $mdStore new mdstore($is_allowed_to_edit);  // create table if needed
  41.  
  42. require(api_get_path(LIBRARY_PATH'xmd.lib.php');
  43. require(api_get_path(LIBRARY_PATH'xht.lib.php');
  44.  
  45. require('md_phpdig.php');
  46.  
  47. $mdObj->mdo_add_breadcrump_nav();  // see 'md_' . EID_TYPE . '.php'
  48.  
  49. $htmlHeadXtra['
  50. <link rel="stylesheet" type="text/css" href="md_styles.css">
  51. <script type="text/javascript" src="md_script.js"></script>
  52. ';
  53. Display::display_header($nameTools);
  54.  
  55.  
  56. if (isset($dmo))  // for future use
  57. {
  58.     echo '<h3>'$dmo'</h3>'"\n";  // document metadata op
  59.  
  60.     // if ($dmo == get_lang('Index')) $dmo = $dmo;
  61. }
  62.  
  63. $result $mdStore->mds_get_many('eid,indexabletext'OF_EID_TYPE);
  64. echo get_lang('Tool')': 'mysql_num_rows($result)"<br><br>\n";
  65.  
  66. $idt array()$cidpar '?cidReq=' $_course['sysCode'];
  67.  
  68. while ($row mysql_fetch_array($result))  // load indexabletexts in memory
  69. {
  70.     $mdObj new mdobject($_coursesubstr($row['eid']AFTER_DOT));
  71.     $idt[$mdObj->mdo_url $cidpar$row['indexabletext'];
  72. }
  73.  
  74. if (count($idt&& file_exists($phpDigIncCn))
  75. {
  76.     require($phpDigIncCn);  // switch to PhpDig DB
  77.     
  78.     foreach ($idt as $url => $text)
  79.     if (ereg('^http://([^/]+)/(.+)/([^/]+)\?cidReq=(.+)$'$url$regs))
  80.     {
  81.         $path $regs[2.'/'$file $regs[3'?cidReq=' $regs[4];
  82.         if ($site_id remove_engine_entries('http://' $regs[1.'/'
  83.                 $path$file))
  84.         {
  85.             echo '<table>'"\n";
  86.             index_words($site_id$path$file
  87.                 get_first_words($text$path$file)
  88.                 get_keywords($text));
  89.             echo '</table>'"\n";
  90.         }
  91.     }
  92.     
  93.     if(isset($db))
  94.     {
  95.         mysql_select_db($_configuration['main_database']$db);  // back to Dokeos
  96.     }
  97. }
  98. else
  99. {
  100.     echo 'No documents with metadata or no PhpDig in this course...<br>';
  101. }
  102.  
  103. if (false && file_exists($phpDigIncCn))  // future: buttons for operations
  104. {
  105.     echo '<form action="' .api_get_self()'" method="post">'"\n"
  106.         '<input type="submit" name="dmo" value="'get_lang('Import''noDLTT')'">'"\n"
  107.         '<input type="submit" name="dmo" value="'get_lang('Remove''noDLTT')'">'"\n"
  108.         '</form>'"\n";
  109. }
  110.  
  111. ?>

Documentation generated on Thu, 12 Jun 2008 13:47:16 -0500 by phpDocumentor 1.4.1