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

Source for file md_document.php

Documentation is available at md_document.php

  1. <?php /*                      <!-- md_document.php for Dokeos metadata/*.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: class mdobject for Document-type items
  11. *
  12. *    @package dokeos.metadata
  13. ============================================================================== 
  14. */
  15.  
  16. class mdobject
  17. {
  18.  
  19. var $mdo_type;
  20. var $mdo_id;
  21. var $mdo_eid;
  22.  
  23. var $mdo_dcmap_e;
  24. var $mdo_dcmap_v;
  25.  
  26. var $mdo_path;
  27. var $mdo_title;
  28. var $mdo_group;
  29. var $mdo_url;
  30.  
  31.  
  32. function mdo_define_htt(return new xhtdoc(<<<EOD
  33.  
  34. <!-- {-INDEXABLETEXT-} -->
  35.  
  36.  {-V metadata/lom/general/title/string-} txt-sep
  37.  {-R metadata/lom/general/keyword C KWTEXT-} txt-sep
  38.  {-V metadata/lom/general/description[1]/string-} txt-end
  39.  document-type
  40.  {-V metadata/lom/lifeCycle/contribute[1]/entity-}
  41.  {-V metadata/lom/lifeCycle/contribute[1]/date/dateTime-}
  42.  {-V metadata/lom/technical/format-}
  43.  
  44.  
  45. <!-- {-KWTEXT-} -->
  46.  
  47.  {-V string-}-kw
  48.  
  49.  
  50. <!-- {--} -->
  51. EOD
  52. );
  53. }
  54.  
  55. function mdo_generate_default_xml_metadata()
  56. {
  57.     global $iso639_2_code$ieee_xml;
  58.     
  59.     $xhtDoc new xhtdoc($ieee_xml)$_user api_get_user_info();
  60.     
  61.     if ($xhtDoc->htt_error
  62.         give_up('IEEE XML (metadata/md_funcs): ' $xhtDoc->htt_error);
  63.     
  64.     $xhtDoc->xht_get_lang 'get_lang'$xhtDoc->xht_xmldoc new xmddoc('');
  65.     if ($xhtDoc->xht_xmldoc->errorgive_up($xhtDoc->xht_xmldoc->error);
  66.     
  67.     $xhtDoc->xht_param['siteUri'make_uri();
  68.     
  69.     $xhtDoc->xht_param['entry'$this->mdo_course['sysCode'
  70.         '.Document.' $this->mdo_id;  // 2005-05-30: path->sysCode
  71.     
  72.     $xhtDoc->xht_param['location'api_get_path(WEB_PATH
  73.         'main/metadata/openobject.php?cidReq=' 
  74.         urlencode($this->mdo_course['sysCode']'&eid=' 
  75.         urlencode($this->mdo_eid);
  76.     
  77.     $xhtDoc->xht_param['mdlang'strtolower($iso639_2_code);
  78.     $xhtDoc->xht_param['lang'=   strtolower($iso639_2_code);
  79.     
  80.     $xhtDoc->xht_param['title'
  81.         $this->mdo_title $this->mdo_title 
  82.             ($this->mdo_path ? $this->mdo_path : get_lang('MdTitle'));
  83.     $xhtDoc->xht_param['description'
  84.         $this->mdo_comment ? $this->mdo_comment : get_lang('MdDescription');
  85.     $xhtDoc->xht_param['coverage'get_lang('MdCoverage');
  86.  
  87.     if (isset($_user))
  88.     {
  89.         $xhtDoc->xht_param['author'"BEGIN:VCARD\\nFN:" 
  90.             $_user['firstName']." ".$_user['lastName'
  91.             "\\nEMAIL:".$_user['mail'"\\nEND:VCARD\\n";
  92.     }
  93.     
  94.     $xhtDoc->xht_param['dateTime'date('Y-m-d');
  95.     
  96.     if ($this->mdo_filetype == 'folder'$format "inode/directory";
  97.     else
  98.     {
  99.         require_once(api_get_path(LIBRARY_PATH'document.lib.php');
  100.         $format DocumentManager::file_get_mime_type($this->mdo_path);
  101.     }
  102.         
  103.     $xhtDoc->xht_param['format'$format;
  104.     
  105.     $xhtDoc->xht_param['size'(($s filesize(get_course_path(
  106.         $this->mdo_course['path''/document' $this->mdo_path))) $s '0';
  107.  
  108.     return $xhtDoc->xht_fill_template('XML');
  109. }
  110.  
  111.  
  112. function mdo_add_breadcrump_nav()
  113. {
  114.     global $interbreadcrumb$langFormats;
  115.     $regs array()// for use with ereg()
  116.     
  117.     $docurl api_get_self();  // should be .../main/xxx/yyy.php
  118.     if (ereg('^(.+[^/\.]+)/[^/\.]+/[^/\.]+.[^/\.]+$'$docurl$regs))
  119.         $docurl $regs[1'/document/document.php';
  120.     
  121.     $interbreadcrumb[]array ('url' => $docurl
  122.         "name"=> get_lang('MdCallingTool'));
  123.     
  124.     if (($docpath $this->mdo_path))
  125.     {
  126.         $docpath substr($docpath0strrpos($docpath'/'));
  127.     
  128.         if (strlen($docpath1$interbreadcrumb[]array ('url' => 
  129.             $docurl '?curdirpath=' urlencode($docpath
  130.             ($this->mdo_group '&gidReq=' $this->mdo_group '')"name" => 
  131.             htmlspecialchars(substr($docpathstrrpos($docpath'/'1)));
  132.     }
  133.     
  134.     // Complete assoclist $langFormats from mime types
  135.     
  136.     require_once(api_get_path(LIBRARY_PATH'xht.lib.php');
  137.     require_once(api_get_path(LIBRARY_PATH'document.lib.php');
  138.     
  139.     $sep $langFormats{0$langFormats{0":";
  140.     $arrFormats xht_explode_assoclist($langFormats);
  141.     
  142.     foreach (DocumentManager::file_get_mime_type(TRUEas $format)
  143.         if (!isset($arrFormats[$format]))
  144.             $langFormats .= ",, " $format $sep $format;
  145.     
  146.     if (!isset($arrFormats["inode/directory"]))
  147.         $langFormats .= ",, inode/directory" $sep "inode/directory";
  148.         
  149.     if (substr($langFormats03== ",, ")
  150.         $langFormats $sep substr($langFormats3);
  151. }
  152.  
  153.  
  154. function mdobject($_course$id)
  155. {
  156.     global $ieee_dcmap_e$ieee_dcmap_v;  // md_funcs
  157.     
  158.     $this->mdo_course = $_course$this->mdo_type = 'Document';
  159.     $this->mdo_id = $id$this->mdo_eid = $this->mdo_type . '.' $id;
  160.     
  161.     $this->mdo_dcmap_e $ieee_dcmap_e$this->mdo_dcmap_v $ieee_dcmap_v;
  162.     
  163.     $document_table Database::get_course_table(TABLE_DOCUMENT);
  164.     if (($docinfo @mysql_fetch_array(api_sql_query(
  165.             "SELECT path,title,comment,filetype FROM $document_table WHERE id='
  166.             addslashes($id"'"__FILE____LINE__))))
  167.     {
  168.         $this->mdo_path =     $docinfo['path'];
  169.         $this->mdo_title =    $docinfo['title'];
  170.         $this->mdo_comment =  $docinfo['comment'];
  171.         $this->mdo_filetype = $docinfo['filetype'];
  172.         $this->mdo_group =    '';  // 2005-05-30: find group_id, if any
  173.         
  174.         $group_info Database::get_course_table(TABLE_GROUP);
  175.         if (($result api_sql_query(
  176.                 "SELECT id,secret_directory FROM $group_info",  __FILE____LINE__)))
  177.             while (($row mysql_fetch_array($result)))
  178.                 if (($secdir $row['secret_directory''/'== 
  179.                         substr($this->mdo_path0strlen($secdir)))
  180.                 {
  181.                     $this->mdo_group $row['id']break;
  182.                 }
  183.     
  184.           // 2005-05-30: use direct URL
  185.           $this->mdo_url =  api_get_path(WEB_COURSE_PATH$_course['path'
  186.             '/document' str_replace('%2F''/'urlencode($this->mdo_path)) 
  187.             ($this->mdo_group '?gidReq=' $this->mdo_group '');
  188.     }
  189. }
  190.  
  191. }
  192. ?>

Documentation generated on Thu, 12 Jun 2008 14:05:20 -0500 by phpDocumentor 1.4.1