コード例 #1
0
 function store_md_and_traverse_subitems($mfdocId, $level, $counter, $contextElem, $treeElem, $parentElem)
 {
     global $_user, $xht_doc, $mdStore, $mdObj, $sdisub, $charset;
     //  $contextElem -> @identifier, metadata/lom
     //  $treeElem ->    title, items
     $itemId = $xht_doc->xmd_value(ITEMID, $contextElem);
     if ($sdisub && $level == 1 && $sdisub != $itemId) {
         return;
     }
     //  <item level=... number=... identifier=...>:
     //      <title>...</title>
     //      <parent identifier=... /> <previous ... /> <next ... />
     //      <child identifier=... /> <child identifier=... /> ...
     //      <resource href=...>
     //          <file href=... /> <file href=... /> ...
     //      </resource>
     //      <metadata>...</metadata>
     //  </item>
     set_time_limit(30);
     // again 30 seconds from here on...
     $mddoc = new xmddoc('<item/>');
     // version, name ?
     $mddoc->xmd_set_attribute(0, 'level', $level, false);
     $mddoc->xmd_set_attribute(0, 'number', $counter, false);
     $mddoc->xmd_set_attribute(0, IDENTIF, $itemId, false);
     if ($level == 0) {
         $mddoc->xmd_set_attribute(0, 'created', date('Y/m/d H:i:s'), false);
         $mddoc->xmd_set_attribute(0, 'by', $_user['user_id'], false);
     }
     $mddoc->xmd_add_text_element(TITLE, $xht_doc->xmd_value(TITLE, $treeElem));
     if ($ppnId = $xht_doc->xmd_value(ITEMID, $parentElem)) {
         $mddoc->xmd_add_element('parent', 0, array(IDENTIF => $ppnId));
     }
     if ($ppnId = $xht_doc->xmd_value('-' . SUBIT, $treeElem)) {
         $mddoc->xmd_add_element('previous', 0, array(IDENTIF => $ppnId));
     }
     if ($ppnId = $xht_doc->xmd_value('+' . SUBIT, $treeElem)) {
         $mddoc->xmd_add_element('next', 0, array(IDENTIF => $ppnId));
     }
     if (($srcElem = resource_for($treeElem)) > 0) {
         // change stuff below to xmd_copy_foreign_child ?
         $resElem = $mddoc->xmd_add_element('resource', 0, array(HREF => $xht_doc->xmd_value(WEBF, $srcElem)));
         foreach ($xht_doc->xmd_select_elements(FILE, $srcElem) as $fileElem) {
             $mddoc->xmd_add_element(FILE, $resElem, array(HREF => $xht_doc->xmd_value(WEBF, $fileElem)));
         }
     }
     $mddoc->xmd_copy_foreign_child($xht_doc, $xht_doc->xmd_select_single_element('metadata', $contextElem));
     foreach ($xht_doc->xmd_select_elements(SUBITEM, $treeElem) as $subElem) {
         $mddoc->xmd_add_element('child', 0, array(IDENTIF => $xht_doc->xmd_value(ITEMID, $subElem)));
     }
     $mdt = $mddoc->xmd_xml();
     $xhtDoc = $mdObj->mdo_define_htt();
     $xhtDoc->xht_xmldoc = $mddoc;
     // $xhtDoc->xht_param['xxx'] = 'yyy';
     $mdStore->mds_put($eid = EID_TYPE . '.' . $mfdocId . '.' . $itemId, $mdt, 'mdxmltext', '?');
     $mdStore->mds_put($eid, $ixt = $xhtDoc->xht_fill_template('INDEXABLETEXT'), 'indexabletext');
     if ($level == 0) {
         $mdStore->mds_put(EID_TYPE . '.' . $mfdocId, $mdt, 'mdxmltext', '?');
         $mdStore->mds_put(EID_TYPE . '.' . $mfdocId, $ixt, 'indexabletext');
     }
     echo $level <= 1 ? '<br />' . $level . '/ ' : ' ', htmlspecialchars($itemId, ENT_QUOTES, $charset);
     flush();
     $loopctr = 0;
     foreach ($xht_doc->xmd_select_elements(SUBITEM, $treeElem) as $subElem) {
         store_md_and_traverse_subitems($mfdocId, $level + 1, ++$loopctr, $subElem, $subElem, $contextElem);
         // note: replacing this recursion by queue+loop makes it slower!
     }
 }
コード例 #2
0
foreach (array(1001, 1002, 1003) as $eid_id) {
    $mdObj = new mdobject($_course, $eid_id);
    // see 'md_' . EID_TYPE . '.php'
    $eid = $mdObj->mdo_eid;
    $titlePath = $mdObj->mdo_dcmap_v['Title'];
    // no IEEE dependencies here...
    if (($mdt_rec = $mdStore->mds_get($eid)) === FALSE) {
        $mdt = $mdObj->mdo_generate_default_xml_metadata();
        $xmlDoc = new xmddoc(explode("\n", $mdt));
        if (!$xmlDoc->error) {
            echo htmlspecialchars($titlePath), ': ';
            $mdTitle = $xmlDoc->xmd_value($titlePath);
            if ($mdTitle == $langMdTitle) {
                $mdTitle = EID_TYPE . ' ' . $eid_id;
                $xmlDoc->xmd_update($titlePath, $mdTitle);
                $mdt = $xmlDoc->xmd_xml();
            }
            echo htmlspecialchars($mdTitle), ':';
        }
        $mdStore->mds_put($eid, $mdt, 'mdxmltext', FALSE);
        echo '<a href="../index.php?eid=', urlencode($eid), '">', htmlspecialchars($eid), '</a><br>';
    }
}
echo '<br>';
$xmlDoc = new xmddoc(explode("\n", $mdStore->mds_get($eid = EID_TYPE . '.1002')));
if ($xmlDoc->error) {
    give_up($xmlDoc->error);
}
$mdObj = new mdobject($_course, '1002');
$mda = "~~";
// delete metadata of 'Document.1002'
コード例 #3
0
    }
    if (($mdt_rec = $mdStore->mds_get(BID . '.' . $chId)) === FALSE) {
        $mdt = $mdObj->mdo_generate_default_xml_metadata();
    } else {
        $mdt = $mdt_rec;
    }
    $xhtxmldocchild = new xmddoc(explode("\n", $mdt));
    !$xhtxmldocchild->error or give_up($chId . ': ' . $xhtxmldocchild->error);
    // make stuff below a parameter? copy some already in importmanifest?
    $xhtxmldoc->xmd_copy_foreign_child($xhtxmldocchild, $xhtxmldocchild->xmd_select_single_element('title'), $chEl);
    $xhtxmldoc->xmd_copy_foreign_child($xhtxmldocchild, $xhtxmldocchild->xmd_select_single_element('resource'), $chEl);
    $after_last = $after_last || $chId == $id_range_last;
}
$xhtDoc = define_htt(HTT . '.htt', $urlp, $_course['path']);
$xhtDoc->xht_xmldoc = $xhtxmldoc;
$xhtDoc->xht_param['mdt'] = $xhtxmldoc->xmd_xml();
// GENERATE OUTPUT ------------------------------------------------------------>
foreach (explode("\n", $xhtDoc->htt_array['HTTP']) as $httpXtra) {
    if ($httpXtra) {
        $httpHeadXtra[] = $httpXtra;
    }
}
$xhtDoc->xht_get_lang = 'get_lang';
function resource_for($e)
{
    return $e;
}
// dummy, '=/' not used here
$xhtDoc->xht_resource = 'resource_for';
$htmlHeadXtra[] = $xhtDoc->xht_fill_template('HEAD');
// $mdObj->mdo_add_breadcrump_nav();  // see 'md_' . EID_TYPE . '.php'
コード例 #4
0
ファイル: md_funcs.php プロジェクト: annickvdp/Chamilo1.9.10
 function mds_put_dc_elements($mdo, $dcelem) {
     if (($mdt = $this->mds_get($mdo->mdo_eid)) === FALSE) {
         $mdt = $mdo->mdo_generate_default_xml_metadata(); $exists = FALSE;
     } else
         $exists = TRUE;
 
     $xmlDoc = new xmddoc(explode("\n", $mdt)); if ($xmlDoc->error) return FALSE;    
     foreach ($dcelem as $dce => $value) {
         $xmlDoc->xmd_update($mdo->mdo_dcmap_v[$dce], (string) $value);
     }    
     $this->mds_put($mdo->mdo_eid, '', 'md5', $exists);    
     return $this->mds_put($mdo->mdo_eid, $xmlDoc->xmd_xml());
 }