Database::select_db($_configuration['main_database'], $db);
        }
    } elseif ($smo == get_lang('Index')) {
        echo 'Problem! PhpDig connect.php has gone or else URL "' . htmlspecialchars($mdObj->mdo_url, ENT_QUOTES, $charset) . '" is not like "http://xxxx/yyy.../zzz/index.php"';
    }
}
// STATISTICS ----------------------------------------------------------------->
echo '<h3>', get_lang('Statistics'), '</h3>', "\n";
$result = $mdStore->mds_get_many('eid', "eid LIKE '" . EID_TYPE . ".%'");
echo get_lang('TotalMDEs'), Database::num_rows($result), "\n";
while ($row = Database::fetch_array($result)) {
    $eid_id = substr($eid = $row['eid'], TPLEN);
    if ($dotpos = strpos($eid_id, '.')) {
        $eid_id = substr($eid_id, 0, $dotpos);
    } else {
        $mdtmain[$eid_id] = $mdStore->mds_get($eid);
    }
    $perId[$eid_id] = ($pi = $perId[$eid_id]) ? $pi + 1 : 1;
}
if (isset($sdi)) {
    $mdo = new mdobject($_course, $sdi);
    echo '<br />', htmlspecialchars($mdo->mdo_path, ENT_QUOTES, $charset), ', SD-id ', $sdi, ': ', $perId[$sdi] ? $perId[$sdi] : '0', ' ', $mdtmain[$sdi] ? '- <span class="lbs" onClick="' . "makeWindow('index.php?eid=" . EID_TYPE . '.' . $sdi . "', '', '')\">" . get_lang('MainMD') . '</span>' : '', "\n";
}
if (count($perId)) {
    foreach ($perId as $id => $number) {
        $mdo = new mdobject($_course, $id);
        if (!($pth = $mdo->mdo_path)) {
            $pth = $mdtmain[$id];
            // fetch something simple without parsing
            if ($ttopen = strpos($pth, '<title>')) {
                if ($ttclose = strpos($pth, '</title>', $ttopen)) {
/**
 * This function writes the imsmanifest.xml and exports the chapter names
 * @param    array        Array containing filenames
 * @param    integer    Learnpath_id
 * @return    void
 */
function createimsmanifest($circle1_files, $learnpath_id)
{
    global $LPname, $expdir, $LPnamesafe;
    $_course = api_get_course_info();
    //$tbl_learnpath_main, $tbl_learnpath_chapter, $tbl_learnpath_item,
    $tbl_learnpath_main = Database::get_course_table(TABLE_LEARNPATH_MAIN);
    $tbl_learnpath_item = Database::get_course_table(TABLE_LEARNPATH_ITEM);
    $tbl_learnpath_chapter = Database::get_course_table(TABLE_LEARNPATH_CHAPTER);
    include_once '../metadata/md_funcs.php';
    // RH: export metadata
    // Header
    // Charset should be dependent on content.
    $header = '<?xml version="1.0" encoding="' . api_get_system_encoding() . '"?>' . "\n<manifest identifier='" . $LPnamesafe . "' version='1.1'\n xmlns='http://www.imsproject.org/xsd/imscp_rootv1p1p2'\n xmlns:adlcp='http://www.adlnet.org/xsd/adlcp_rootv1p2'\n xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\n xsi:schemaLocation='http://www.imsproject.org/xsd/imscp_rootv1p1p2 imscp_rootv1p1p2.xsd\n http://www.imsglobal.org/xsd/imsmd_rootv1p2p1 imsmd_rootv1p2p1.xsd\n http://www.adlnet.org/xsd/adlcp_rootv1p2 adlcp_rootv1p2.xsd'>\n";
    $org = xmltagwrite('metadata', 'open');
    $org .= '  ' . xmltagwrite('schema', 'full', 'ADL SCORM');
    $org .= '  ' . xmltagwrite('schemaversion', 'full', '1.2');
    $org .= xmltagwrite('metadata', 'close');
    $defaultorgname = 'default_org';
    $attributes[0][0] = 'default';
    $attributes[1][0] = $defaultorgname;
    $org .= xmltagwrite('organizations', 'open', $attributes);
    $attributes[0][0] = 'identifier';
    $attributes[1][0] = $defaultorgname;
    $org .= '  ' . xmltagwrite('organization', 'open', $attributes);
    $org .= '    ' . xmltagwrite('title', 'full', $LPname);
    // Items list.
    $i = 0;
    $course_id = api_get_course_int_id();
    $previous_item_id = '00';
    while ($circle1_files[0][$i]) {
        // Check whether we are in the border of two chapters.
        //if (!$desc=strpos($circle1_files[2][$i],'scription')) {  // This is needed if the descriptions are exported to file.
        $sql = "SELECT * FROM {$tbl_learnpath_item} WHERE c_id = {$course_id} AND (id=" . $circle1_files[2][$i] . ")";
        $result = Database::query($sql);
        $row = Database::fetch_array($result);
        $parent_item_id = $row['parent_item_id'];
        if ($parent_item_id != $previous_item_id) {
            // We create the item tag for the chapter (without indifierref).
            $sql2 = "SELECT * FROM {$tbl_learnpath_chapter} WHERE c_id = {$course_id} AND (id=" . $parent_item_id . ")";
            $result2 = Database::query($sql2);
            $row2 = Database::fetch_array($result2);
            $chapter_name = $row2['chapter_name'];
            $attributes = '';
            $attributes[0][] = 'identifier';
            $attributes[1][] = 'chapter_' . $row2['id'];
            $attributes[0][] = 'isvisible';
            $attributes[1][] = '1';
            if ($previous_item_id != '00') {
                $org .= '    ' . xmltagwrite('item', 'close');
            }
            $org .= '    ' . xmltagwrite('item', 'open', $attributes);
            $org .= '      ' . xmltagwrite('title', 'full', $chapter_name);
            if ($row2['chapter_description'] != '') {
                // Chapter description.
                $attributes = '';
                $attributes[0][] = 'identifier';
                $attributes[1][] = 'chapter_' . $row2['id'] . '_desc';
                $attributes[0][] = 'isvisible';
                $attributes[1][] = '1';
                $org .= '    ' . xmltagwrite('item', 'open', $attributes);
                $org .= '      ' . xmltagwrite('title', 'full', ' ' . $row2['chapter_description']);
                $org .= '    ' . xmltagwrite('item', 'close');
            }
        }
        $previous_item_id = $parent_item_id;
        //}
        $attributes = '';
        // Item output.
        $attributes[0][] = 'identifier';
        $attributes[1][] = 'item_' . $circle1_files[2][$i];
        $attributes[0][] = 'identifierref';
        $attributes[1][] = 'item_ref_' . $circle1_files[2][$i];
        $attributes[0][] = 'isvisible';
        $attributes[1][] = '1';
        $org .= '    ' . xmltagwrite('item', 'open', $attributes);
        $org .= '      ' . xmltagwrite('title', 'full', $circle1_files[1][$i]);
        if ($row['prereq_id'] != '') {
            // Item prerequisites.
            $attributes = '';
            $attributes[0][] = 'type';
            $attributes[1][] = 'aicc_script';
            $org .= '      ' . xmltagwrite('adlcp:prerequisites', 'open', $attributes, 'no_linebreak');
            if ($row['prereq_type'] == 'i') {
                $org .= 'item_' . $row['prereq_id'];
            }
            if ($row['prereq_type'] == 'c') {
                $org .= 'chapter_' . $row['prereq_id'];
            }
            $org .= xmltagwrite('adlcp:prerequisites', 'close', $attributes);
        }
        if ($row['description'] != '') {
            // Item description.
            $attributes = '';
            $attributes[0][] = 'identifier';
            $attributes[1][] = 'item_' . $circle1_files[2][$i] . '_desc';
            $attributes[0][] = 'isvisible';
            $attributes[1][] = '1';
            $org .= '    ' . xmltagwrite('item', 'open', $attributes);
            $org .= '      ' . xmltagwrite('title', 'full', ' ' . $row['description']);
            $org .= '    ' . xmltagwrite('item', 'close');
        }
        $mds = new mdstore(true);
        // RH: export metadata; if no table, create it
        if ($mdt = $mds->mds_get($row['item_type'] . '.' . $row['item_id'])) {
            if (($mdo = api_strpos($mdt, '<metadata>')) && ($mdc = api_strpos($mdt, '</metadata>'))) {
                $org .= '    ' . api_substr($mdt, $mdo, $mdc - $mdo + 11) . "\n";
            }
        }
        $org .= '    ' . xmltagwrite('item', 'close');
        $i++;
    }
    if ($circle1_files) {
        $org .= '    ' . xmltagwrite('item', 'close');
    }
    // Not needed in case of a blank path.
    $org .= '  ' . xmltagwrite('organization', 'close');
    $org .= xmltagwrite('organizations', 'close');
    $org .= xmltagwrite('resources', 'open');
    // Resources list.
    $i = 0;
    while ($circle1_files[0][$i]) {
        $attributes = '';
        $attributes[0][] = 'identifier';
        $attributes[1][] = 'item_ref_' . $circle1_files[2][$i];
        $attributes[0][] = 'type';
        $attributes[1][] = 'webcontent';
        $attributes[0][] = 'adlcp:scormtype';
        $attributes[1][] = 'sco';
        $attributes[0][] = 'href';
        $attributes[1][] = $circle1_files[0][$i];
        $org .= '  ' . xmltagwrite('resource', 'open', $attributes);
        $org .= '    ' . xmltagwrite('metadata', 'open');
        $org .= '      ' . xmltagwrite('schema', 'full', 'ADL SCORM');
        $org .= '      ' . xmltagwrite('schemaversion', 'full', '1.2');
        $org .= '    ' . xmltagwrite('metadata', 'close');
        $attributes = '';
        $attributes[0][] = 'href';
        $attributes[1][] = $circle1_files[0][$i];
        $org .= '    ' . xmltagwrite('file', 'open', $attributes);
        $org .= '  ' . xmltagwrite('resource', 'close');
        $i++;
    }
    $org .= xmltagwrite('resources', 'close');
    $org .= xmltagwrite('manifest', 'close');
    $manifest = $header . $org;
    exporttofile('imsmanifest.xml', 'Manifest file', '0', $manifest);
}
// mdo_generate_default_xml_metadata
$noPHP_SELF = TRUE;
Display::display_header($nameTools);
echo "\n";
// if the language file in use is not 'md_' . EID_TYPE ...
$langMdTitle = 'Default Title (if doc not in DB)';
$langMdDescription = 'Default description (if doc has no comment)';
$langMdCoverage = 'bachelor of engineering';
$langMdCopyright = 'Ghent University';
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>';
    }
    give_up('Invalid directory: ' . DIRECTORY);
}
chdir(DIRECTORY);
for ($i = 0; $i < 10; $i++) {
    if (!file_exists(HTT . '.htt')) {
        if (strtolower(realpath(getcwd())) == $topdir) {
            break;
        } else {
            chdir('..');
        }
    }
}
// XML and DB STUFF ----------------------------------------------------------->
$is_allowed_to_edit = isset($_user['user_id']) && $is_courseMember && api_is_allowed_to_edit();
$mdStore = new mdstore($is_allowed_to_edit);
if (($mdt_rec = $mdStore->mds_get(EID)) === FALSE) {
    // no record, default XML
    $mdt = $mdObj->mdo_generate_default_xml_metadata();
} else {
    $mdt = $mdt_rec;
}
$xhtxmldoc = new xmddoc(explode("\n", $mdt));
!$xhtxmldoc->error or give_up($xhtxmldoc->error);
if (SID == $id_range_first && ($prv = $xhtxmldoc->xmd_select_single_element('previous')) != -1) {
    $xhtxmldoc->xmd_remove_element($prv);
}
if (SID == $id_range_last && ($nxt = $xhtxmldoc->xmd_select_single_element('next')) != -1) {
    $xhtxmldoc->xmd_remove_element($nxt);
}
$before_first = $id_range_first ? TRUE : FALSE;
$after_last = FALSE;
Beispiel #5
0
require api_get_path(LIBRARY_PATH) . 'xht.lib.php';
$mdObj = new mdobject($_course, EID_ID);
// see 'md_' . EID_TYPE . '.php'
// Construct assoclist $langLangs from language table ------------------------->
$result = Database::query("SELECT isocode FROM " . Database::get_main_table(TABLE_MAIN_LANGUAGE) . " WHERE available='1' ORDER BY isocode ASC");
$sep = ":";
$langLangs = $sep . "xx" . $sep . "xx";
while ($row = Database::fetch_array($result)) {
    if ($isocode = $row['isocode']) {
        $langLangs .= ",, " . $isocode . $sep . $isocode;
    }
}
// XML and DB STUFF ----------------------------------------------------------->
$is_allowed_to_edit = isset($_user['user_id']) && $is_courseMember && api_is_allowed_to_edit();
$mdStore = new mdstore($is_allowed_to_edit);
if (($mdt_rec = $mdStore->mds_get(EID)) === FALSE) {
    // no record, default XML
    $mdt = $mdObj->mdo_generate_default_xml_metadata();
} else {
    $mdt = $mdt_rec;
}
$xhtxmldoc = new xmddoc(explode("\n", $mdt));
$httfile = $xhtxmldoc->error ? 'md_editxml.htt' : HTT . '.htt';
if (!$xhtxmldoc->error && $mdt_rec !== FALSE && method_exists($mdObj, 'mdo_override')) {
    $mdt = $mdObj->mdo_override($xhtxmldoc);
}
$xhtDoc = define_htt($httfile, $urlp, $_course['path']);
define('HSH', md5($mdt . LFN . $nameTools . get_lang('Sorry') . $httfile . implode('{}', $xhtDoc->htt_array)));
// cached HTML depends on LFN+HTT
$xhtDoc->xht_param['traceinfo'] = $xhtxmldoc->error;
$xhtDoc->xht_param['dbrecord'] = $mdt_rec !== FALSE ? 'TRUE' : '';