Ejemplo n.º 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');
 }
Ejemplo n.º 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');
 }
Ejemplo n.º 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);
}
Ejemplo n.º 4
0
        } else {
            // do some preparations
            return FALSE;
        }
        // signals XHT to generate new text from template
    } else {
        // store the new text in the cache...
        // possibly modify the text to be output...
        return $newtext;
        // often the output is identical to the new text
    }
}
// GENERATE OUTPUT ------------------------------------------------------------>
foreach (explode("\n", $xhtDoc->htt_array['HTTP']) as $httpXtra) {
    if ($httpXtra) {
        header($httpXtra);
    }
}
echo "<html>\n<head>", $xhtDoc->xht_fill_template('HEAD'), "\n</head>\n\n<body>\n";
$xhtDoc->xht_dbgn = 0;
// for template debug info, set to e.g. 10000
echo $xhtDoc->xht_fill_template('MAIN'), '<br><br>Child nodes of "description":';
foreach ($testdoc->children[$testdoc->xmd_select_single_element('description')] as $child) {
    echo '<br>', strlen($child), ': ', htmlspecialchars($child);
}
echo "\n\n</body>\n</html>\n";
if ($xhtDoc->xht_dbgn) {
    echo $xhtDoc->xht_dbgo;
}
// Note: XML document and templates would normally be fetched from (different)
// external sources, such as a file or a DB record...