Source for file index.php
Documentation is available at index.php
<?php /* <!-- Dokeos metadata/index.php -->
<!-- Copyright (C) 2005 rene.haentjens@UGent.be - see metadata/md_funcs.php -->
==============================================================================
* Dokeos Metadata: view/edit metadata of a Dokeos course object
* - eid= entry-id = object-id = type.identifier, e.g. 'Document.12';
* - lfn= filename of a language file, default= 'md_' + type, e.g. 'md_doc';
* - htt= HTML template file (same dir as script), default= same as lfn;
* - dbg= debuginfo start number, e.g. 10000
* @package dokeos.metadata
==============================================================================
// PRELIMS -------------------------------------------------------------------->
getpar('EID', 'Entry IDentifier'); // e.g. 'Document.12' or 'Scorm.xx'
define('EID_TYPE', substr(EID, 0, $dotpos)); // e.g. 'Document' or 'Scorm'
require ('md_' . strtolower(EID_TYPE) . '.php');
define('EID_ID', substr(EID, $dotpos + 1)); // e.g. '12'
getpar('HTT', 'HTML Template Text filename', LFN);
getpar('DBG', 'Debug number', '0');
if (HTT != LFN) $urlp .= '&htt=' . urlencode(HTT);
// name of the language file that needs to be included
require ("../inc/global.inc.php");
or give_up('Language file ' . LFN . " doesn't define 'Tool' and '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); // see 'md_' . EID_TYPE . '.php'
// Construct assoclist $langLangs from language table ------------------------->
" WHERE available='1' ORDER BY isocode ASC", __FILE__ , __LINE__ );
$sep = ":"; $langLangs = $sep . "xx" . $sep . "xx";
if (($isocode = $row['isocode']))
$langLangs .= ",, " . $isocode . $sep . $isocode;
// XML and DB STUFF ----------------------------------------------------------->
$is_allowed_to_edit = isset ($_user['user_id']) && $is_courseMember && 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();
$httfile = ($xhtxmldoc->error) ? 'md_editxml.htt' : HTT . '.htt';
if (!$xhtxmldoc->error && $mdt_rec !== FALSE &&
$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' : '';
$xhtDoc->xht_xmldoc = $xhtxmldoc;
if ($is_allowed_to_edit) $xhtDoc->xht_param['isallowedtoedit'] = 'TRUE';
if ($is_allowed_to_edit && isset ($_POST['mda'])) // MD updates to Doc and DB
$mdt = $mdStore->mds_update_xml_and_mdt($mdObj, $xhtDoc->xht_xmldoc,
EID, $xhtDoc->xht_param['traceinfo'], $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';
$mdObj->mdo_storeback($xhtDoc->xht_xmldoc);
$mdt_rec = FALSE; // cached HTML obsolete, must re-apply templates
elseif ($is_allowed_to_edit && $_POST['mdt']) // md_editxml.htt
$mdStore->mds_put(EID, HSH, 'md5');
$xhtDoc->xht_param['dbrecord'] = 'TRUE';
$mdt = ''; $xhtDoc->xht_param['traceinfo'] = get_lang('PressAgain');
$mdt_rec = FALSE; // cached HTML obsolete, must re-apply templates
$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)
return '<!-- ' . $part . ' -->' . $mdStore->mds_get(EID, $part);
$mdStore->mds_put(EID, HSH, 'md5');
$mdStore->mds_put(EID, $newtext, $part);
// 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'
$noPHP_SELF = TRUE; // in breadcrumps
$xhtDoc->xht_dbgn = DBG; // for template debug info, set to e.g. 10000
if (($ti = $xhtDoc->xht_param['traceinfo'])) $xhtDoc->xht_param['traceinfo'] =
echo $xhtDoc->xht_fill_template('METADATA'), "\n";
if ($xhtDoc->xht_dbgn) echo $xhtDoc->xht_dbgo;
|