Source for file md_link.php
Documentation is available at md_link.php
<?php /* <!-- md_link.php for Dokeos metadata/*.php -->
<!-- Copyright (C) 2006 rene.haentjens@UGent.be - see metadata/md_funcs.php -->
==============================================================================
* Dokeos Metadata: class mdobject for Link-type objects
* @package dokeos.metadata
==============================================================================
function mdo_define_htt() { return new xhtdoc(<<<EOD
<!-- {-INDEXABLETEXT-} -->
Title: {-V metadata/lom/general/title/string-} txt-sep
Keyword(s): {-R metadata/lom/general/keyword C KWTEXT-} txt-sep
Category: {-V metadata/lom/general/coverage/string-} txt-sep
{-V metadata/lom/general/description[1]/string-} txt-end
function mdo_generate_default_xml_metadata()
global $iso639_2_code, $ieee_xml;
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;
$xhtDoc->xht_param['description'] = get_lang('MdDescription');
$xhtDoc->xht_param['coverage'] = $this->mdo_category_title ?
$this->mdo_category_title : get_lang('MdCoverage');
$xhtDoc->xht_param['author'] = "BEGIN:VCARD\\nFN:" .
$_user['firstName']. " ". $_user['lastName'] .
"\\nEMAIL:". $_user['mail'] . "\\nEND:VCARD\\n";
$xhtDoc->xht_param['dateTime'] = date('Y-m-d');
$xhtDoc->xht_param['format'] = ''; $xhtDoc->xht_param['size'] = '0';
$mdt = $xhtDoc->xht_fill_template('XML')));
if ($xd->error) return $mdt; // and worry later
$this->_add_keywords($xd, $keywords);
return $xhtDoc->xht_fill_template('XML');
function mdo_override(&$xmlDoc) // by ref!
$xmlDoc->xmd_update('metadata/lom/technical/location', $this->mdo_url);
$ge = $xmlDoc->xmd_select_single_element("metadata/lom/general");
$xmlDoc->xmd_update('title[1]/string', $this->mdo_title, $ge);
$xmlDoc->xmd_update('coverage[1]/string', $this->mdo_category_title, $ge);
if (($d = $this->mdo_description))
if ($keywords = $this->_find_keywords($d)) $d = array_pop($keywords);
$xmlDoc->xmd_update('description[1]/string', $d, $ge);
$xmlDoc->xmd_remove_nodes($xmlDoc->xmd_select_elements('keyword', $ge), $ge);
if (count($keywords)) $this->_add_keywords($xmlDoc, $keywords);
return $xmlDoc->xmd_xml();
function mdo_storeback(&$xmlDoc) // by ref!
if (!$this->mdo_url) return; // no record in link table, most probably
if (!($v = $xmlDoc->xmd_value('metadata/lom/technical/location'))) return;
$ge = $xmlDoc->xmd_select_single_element("metadata/lom/general");
$v = $xmlDoc->xmd_value('title[1]/string', $ge);
if ($v != $this->mdo_title)
{ $this->mdo_title = $v; $u .= ", title = '" . addslashes($v) . "'"; }
$vd = $xmlDoc->xmd_value('description[1]/string', $ge);
$vk = $xmlDoc->xmd_value('keyword/string', $ge, array('in' => ', '));
ereg_replace('\[((/?(b|big|i|small|sub|sup|u))|br/)\]', '<\\1>',
if ($v != $this->mdo_description)
$this->mdo_description = $v;
// do not store back a modified coverage as category...
function mdo_add_breadcrump_nav()
$regs = array(); // for use with ereg()
if (ereg('^(.+[^/\.]+)/[^/\.]+/[^/\.]+.[^/\.]+$', $docurl, $regs))
$docurl = $regs[1] . '/link/link.php';
$interbreadcrumb[]= array ('url' => $docurl,
global $ieee_dcmap_e, $ieee_dcmap_v; // md_funcs
$this->mdo_dcmap_e = $ieee_dcmap_e; $this->mdo_dcmap_v = $ieee_dcmap_v;
"SELECT url,title,description,category_id FROM $link_table WHERE id='" .
$this->mdo_title = $linkinfo['title'];
$this->mdo_description = $linkinfo['description'];
$this->mdo_category = ($lci = $linkinfo['category_id']);
"SELECT category_title FROM $linkcat_table WHERE id='" .
$this->mdo_category_title = $catinfo['category_title'];
function _find_keywords($d)
$dd = new xmddoc($d); if ($dd->error) return NULL;
$regs = array(); // for use with ereg()
foreach ($dd->attributes[0] as $name => $value)
if ($name == 'kw' && ereg('^<?([^>]+)>?$', $value, $regs))
if (ereg('^<' . ($tag = $dd->name[0]) . '[^>]*>(.*)</'. $tag. '>$',
$d, $regs)) // e.g. <i kw="...">A & <b>B</b>!</i>
'<((/?(b|big|i|small|sub|sup|u))|br/)>', '[\\1]',
($regs[1])), $htdc); // then & -> & etc.
else $d = $dd->xmd_text();
function _add_keywords(&$xmlDoc, $keywords) // by ref!
$ge = $xmlDoc->xmd_select_single_element("metadata/lom/general");
$dl = array("language" =>
$xmlDoc->xmd_value("description/string/@language", $ge));
foreach ($keywords as $kw)
$xmlDoc->xmd_add_text_element("string", $kw,
$xmlDoc->xmd_add_element("keyword", $ge), $dl);
|