Пример #1
0
 function mdo_generate_default_xml_metadata()
 {
     global $iso639_2_code, $ieee_xml;
     $xhtDoc = new xhtdoc($ieee_xml);
     $_user = api_get_user_info();
     if ($xhtDoc->htt_error) {
         give_up('IEEE XML (metadata/md_funcs): ' . $xhtDoc->htt_error);
     }
     $xhtDoc->xht_get_lang = 'get_lang';
     $xhtDoc->xht_xmldoc = new xmddoc('');
     if ($xhtDoc->xht_xmldoc->error) {
         give_up($xhtDoc->xht_xmldoc->error);
     }
     $xhtDoc->xht_param['siteUri'] = make_uri();
     $xhtDoc->xht_param['entry'] = $this->mdo_course['sysCode'] . '.Link.' . $this->mdo_id;
     // 2005-05-30: path->sysCode
     $xhtDoc->xht_param['location'] = $this->mdo_url . '';
     $xhtDoc->xht_param['mdlang'] = strtolower($iso639_2_code);
     $xhtDoc->xht_param['lang'] = strtolower($iso639_2_code);
     $xhtDoc->xht_param['title'] = $this->mdo_title ? $this->mdo_title : get_lang('MdTitle');
     if ($d = $this->mdo_description) {
         if ($keywords = $this->_find_keywords($d)) {
             $d = array_pop($keywords);
         }
         $xhtDoc->xht_param['description'] = $d;
     } else {
         $xhtDoc->xht_param['description'] = get_lang('MdDescription');
     }
     $xhtDoc->xht_param['coverage'] = $this->mdo_category_title ? $this->mdo_category_title : get_lang('MdCoverage');
     if (isset($_user)) {
         $xhtDoc->xht_param['author'] = "BEGIN:VCARD\\nFN:" . api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS) . "\\nEMAIL:" . $_user['mail'] . "\\nEND:VCARD\\n";
     }
     $xhtDoc->xht_param['dateTime'] = date('Y-m-d');
     $xhtDoc->xht_param['format'] = '';
     $xhtDoc->xht_param['size'] = '0';
     if (count($keywords)) {
         $xd = new xmddoc(explode("\n", $mdt = $xhtDoc->xht_fill_template('XML')));
         if ($xd->error) {
             return $mdt;
         }
         // and worry later
         $this->_add_keywords($xd, $keywords);
         return $xd->xmd_xml();
     }
     return $xhtDoc->xht_fill_template('XML');
 }
Пример #2
0
 function mdo_generate_default_xml_metadata()
 {
     global $iso639_2_code, $ieee_xml;
     $xhtDoc = new xhtdoc($ieee_xml);
     $_user = api_get_user_info();
     if ($xhtDoc->htt_error) {
         give_up('IEEE XML (metadata/md_funcs): ' . $xhtDoc->htt_error);
     }
     $xhtDoc->xht_get_lang = 'get_lang';
     $xhtDoc->xht_xmldoc = new xmddoc('');
     if ($xhtDoc->xht_xmldoc->error) {
         give_up($xhtDoc->xht_xmldoc->error);
     }
     $xhtDoc->xht_param['siteUri'] = make_uri();
     $xhtDoc->xht_param['entry'] = $this->mdo_course['sysCode'] . '.Document.' . $this->mdo_id;
     // 2005-05-30: path->sysCode
     $xhtDoc->xht_param['location'] = api_get_path(WEB_PATH) . 'main/metadata/openobject.php?cidReq=' . urlencode($this->mdo_course['sysCode']) . '&eid=' . urlencode($this->mdo_eid);
     $xhtDoc->xht_param['mdlang'] = strtolower($iso639_2_code);
     $xhtDoc->xht_param['lang'] = strtolower($iso639_2_code);
     $xhtDoc->xht_param['title'] = $this->mdo_title ? $this->mdo_title : ($this->mdo_path ? $this->mdo_path : get_lang('MdTitle', ''));
     $xhtDoc->xht_param['description'] = $this->mdo_comment ? $this->mdo_comment : get_lang('MdDescription', '');
     $xhtDoc->xht_param['coverage'] = get_lang('MdCoverage', '');
     if (isset($_user)) {
         $xhtDoc->xht_param['author'] = "BEGIN:VCARD\\nFN:" . api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS) . "\\nEMAIL:" . $_user['mail'] . "\\nEND:VCARD\\n";
     }
     $xhtDoc->xht_param['dateTime'] = date('Y-m-d');
     if ($this->mdo_filetype == 'folder') {
         $format = "inode/directory";
     } else {
         require_once api_get_path(LIBRARY_PATH) . 'document.lib.php';
         $format = DocumentManager::file_get_mime_type($this->mdo_path);
     }
     $xhtDoc->xht_param['format'] = $format;
     $xhtDoc->xht_param['size'] = ($s = filesize(get_course_path() . $this->mdo_course['path'] . '/document' . $this->mdo_path)) ? $s : '0';
     return $xhtDoc->xht_fill_template('XML');
 }
Пример #3
0
function define_kwds($mdo) {
    if (!($newtext = trim(@fgc(get_course_path() . $mdo->mdo_course['path'] .
            '/document' . $mdo->mdo_path ))))
    {
        unlink(KEYWORDS_CACHE); return;
    }
                                    // templates to define the tree as JScript object
    $xhtDocKw = new xhtdoc(<<<EOD

<!-- {-KWTREE_OBJECT-} -->

KWTREE_OBJECT = {n:"", ti:"{-X @title-}"
, c:[{-R * C DOWN_THE_KWTREE-}]};

document.write(traverseKwObj(KWTREE_OBJECT, '', 0)); KWDS_ARRAY.sort();

<!-- {-DOWN_THE_KWTREE-} -->
{-T number > 1 , -}{n:"{-V @.-}"{-D cm {-X @comment-}-}{-T cm != empty , cm:"{-P cm-}"-}{-D pt {-X @postit-}-}{-T pt != empty , pt:"{-P pt-}"-}{-R * P empty-}{-T number >= 1
, c:[-}{-T number >= 1 R * C DOWN_THE_KWTREE-}{-R * P empty-}{-T number >= 1 ]-}}

<!-- {--} -->
EOD
    );  // traverseKwObj (md_script) generates clickable tree and populates KWDS_ARRAY


    if ($xhtDocKw->htt_error)
        give_up('KwdTree template (metadata/md_funcs): ' . $xhtDocKw->htt_error);

    $xhtDocKw->xht_xmldoc = new xmddoc(explode("\n", $newtext));
    if ($xhtDocKw->xht_xmldoc->error)
        give_up('CourseKwds (metadata/md_funcs): XML error: ' .
        $xhtDocKw->xht_xmldoc->error);

    if (count($xhtDocKw->xht_xmldoc->children[0]) < 2)
    {
        unlink(KEYWORDS_CACHE); return;
    }

    $fileHandler = @fopen(KEYWORDS_CACHE, 'w');
    @fwrite($fileHandler, $xhtDocKw->xht_fill_template('KWTREE_OBJECT'));
    @fclose($fileHandler);
}
Пример #4
0
$xhtDoc = new xhtdoc(<<<EOD
<!-- {-HTTP-} -->

Expires: Mon, 26 Jul 1997 05:00:00 GMT


<!-- {-HEAD-} -->

<style type="text/css"> .bg3 {background-color:#E2E2E2} </style>


<!-- {-MAIN-} -->

<h1>testXht</h1>

<h3>{-X title-}</h3>

Hello {-P p1-}! {-X description-}<br>
{-X metadata/lom/general/description/langstring-}<br><br>

{-D label This is a funny <La"bel>-}{-C LABEL-}<br><br>
<table>
    {-R keywords/keyword C KEYWORD-}
</table>
There are {-R keywords/keyword P empty-}{-P number-} keywords...<br><br>

<select>
    {-D selkey nl-}{-R Langnames C OPTION-}
</select>
<br><br>

{-R Langnames C LEVEL1-}<br><br>

{-D author {-V author-}-}
{-T author != empty
<h5>There is an author</h5>
<!-- Note1: T tests parameters, not XML values directly -->
<!-- Note2: the space after 'empty' is necessary! - see below
 -}
{-T author != empty
parses wrong because missing space after 'empty'
 -}<br><br>

Special parentheses {-can still be used-} for other -}{-{-purposes...
<br>
Nesting is {-H {-L Am-}-}
<br><br>

{-E md_cache C RECALC-}


<!-- {-RECALC-} -->

This text is re-calculated when the cache is no longer valid.


<!-- {-LABEL-} -->

<span class="bg3">{-H {-P label-}-}&#xa0;:</span>&#xa0;


<!-- {-KEYWORD-} -->

<tr>
    <td>{-D label {-L Kw-}-}{-C LABEL-}{-X .-}</td>
    <td><input type="checkbox" title="keyword{-P number-}"/></td>
</tr>


<!-- {-OPTION-} -->

<option value="{-H {-P key-}-}" {-T key == selkey selected-}>{-H {-P value-}-}</option>


<!-- {-LEVEL1-} -->

<b>{-P rdepth-}.{-P key-}</b>: {-R keywords/keyword C LEVEL2-}<br>


<!-- {-LEVEL2-} -->

{-P rdepth-}.{-P number-}


<!-- {--} -->
EOD
);