123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <?php
- require_once '../inc/global.inc.php';
- require "md_funcs.php";
- getpar('EID', 'Entry IDentifier');
- if (!($dotpos = strpos(EID, '.'))) give_up('No . in ' . EID);
- define('EID_TYPE', substr(EID, 0, $dotpos));
- require('md_' . strtolower(EID_TYPE) . '.php');
- define('EID_ID', substr(EID, $dotpos + 1));
- getpar('LFN', 'LanguageFileName', 'md_' . strtolower(EID_TYPE));
- getpar('HTT', 'HTML Template Text filename', LFN);
- getpar('DBG', 'Debug number', '0');
- $urlp = '?eid=' . urlencode(EID);
- if (LFN != 'md_' . strtolower(EID_TYPE)) $urlp .= '&lfn=' . urlencode(LFN);
- if (HTT != LFN) $urlp .= '&htt=' . urlencode(HTT);
- if (DBG) $urlp .= '&dbg=' . urlencode(DBG);
- $language_file = LFN;
- require_once "../inc/global.inc.php";
- $this_section = SECTION_COURSES;
- $nameTools = get_lang('Tool');
- ($nameTools && get_lang('Sorry')) or give_up('Language file ' . LFN . " doesn't define 'Tool' and 'Sorry'");
- $_course = api_get_course_info(); isset($_course) or give_up(get_lang('Sorry'));
- require api_get_path(LIBRARY_PATH) . 'xmd.lib.php';
- require api_get_path(LIBRARY_PATH) . 'xht.lib.php';
- $mdObj = new mdobject($_course, EID_ID);
- $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;
- $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)
- $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)));
- $xhtDoc->xht_param['traceinfo'] = $xhtxmldoc->error;
- $xhtDoc->xht_param['dbrecord'] = $mdt_rec !== FALSE ? 'TRUE' : '';
- $xhtDoc->xht_xmldoc = $xhtxmldoc;
- if ($is_allowed_to_edit) $xhtDoc->xht_param['isallowedtoedit'] = 'TRUE';
- if ($is_allowed_to_edit && isset($_POST['mda'])) {
- $mdt = $mdStore->mds_update_xml_and_mdt($mdObj, $xhtDoc->xht_xmldoc,
- get_magic_quotes_gpc() ? stripslashes($_POST['mda']) : $_POST['mda'],
- EID, $xhtDoc->xht_param['traceinfo'], $mdt_rec !== FALSE);
- if ($mdt_rec !== FALSE) {
- if (strpos($xhtDoc->xht_param['traceinfo'], 'DELETE') !== FALSE)
- $xhtDoc->xht_param['dbrecord'] = '';
- } else if (strpos($xhtDoc->xht_param['traceinfo'], 'INSERT') !== FALSE)
- $xhtDoc->xht_param['dbrecord'] = 'TRUE';
- if (method_exists($mdObj, 'mdo_storeback'))
- $mdObj->mdo_storeback($xhtDoc->xht_xmldoc);
- $mdt_rec = FALSE;
- } elseif ($is_allowed_to_edit && $_POST['mdt']) {
-
- $mdStore->mds_put(EID,
- get_magic_quotes_gpc() ? stripslashes($_POST['mdt']) : $_POST['mdt'],
- 'mdxmltext', '?');
- $mdStore->mds_put(EID, HSH, 'md5');
- $xhtDoc->xht_param['dbrecord'] = 'TRUE';
- $mdt = ''; $xhtDoc->xht_param['traceinfo'] = get_lang('PressAgain');
- $mdt_rec = FALSE;
- }
- $xhtDoc->xht_param['mdt'] = $mdt;
- define('CACHE_IS_VALID', isset($mdt_rec) && $mdt_rec !== FALSE &&
- HSH && HSH == $mdStore->mds_get(EID, 'md5'));
- function md_part($part, $newtext) // callback from template (HTML cache in DB)
- {
- global $mdStore;
- if ($newtext === FALSE)
- {
- if (!CACHE_IS_VALID) return FALSE;
- return '<!-- ' . $part . ' -->' . $mdStore->mds_get(EID, $part);
- }
- else
- {
- $mdStore->mds_put(EID, HSH, 'md5');
- $mdStore->mds_put(EID, $newtext, $part);
- return $newtext;
- }
- }
- function md_part1($newtext) { return md_part('htmlcache1', $newtext); }
- function md_part2($newtext) { return md_part('htmlcache2', $newtext); }
- function md_indexabletext($newtext) { return md_part('indexabletext', $newtext); }
- 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;}
- $xhtDoc->xht_resource = 'resource_for';
- $htmlHeadXtra[] = $xhtDoc->xht_fill_template('HEAD');
- $mdObj->mdo_add_breadcrump_nav();
- $noPHP_SELF = TRUE;
- Display::display_header($nameTools); echo "\n";
- $xhtDoc->xht_dbgn = DBG;
- if (($ti = $xhtDoc->xht_param['traceinfo'])) $xhtDoc->xht_param['traceinfo'] =
- '<h5>Trace information</h5>' . htmlspecialchars($ti, ENT_QUOTES, $charset);
- echo $xhtDoc->xht_fill_template('METADATA'), "\n";
- if ($xhtDoc->xht_dbgn) echo $xhtDoc->xht_dbgo;
- Display::display_footer();
- ?>
|