[Logicampus-cvs] logicampus/src/logicreate/lib/lob lc_lob.php, 1.1, 1.2 lc_lob_xml.php, 1.1, 1.2
Brought to you by:
trilexcom
From: Mark K <har...@us...> - 2008-03-02 19:01:04
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/lib/lob In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv13918/lib/lob Modified Files: lc_lob.php lc_lob_xml.php Log Message: Move xml processing of LOBs into specialized utility class. Index: lc_lob.php =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/lib/lob/lc_lob.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** lc_lob.php 1 Mar 2008 23:43:19 -0000 1.1 --- lc_lob.php 2 Mar 2008 19:00:38 -0000 1.2 *************** *** 35,45 **** /** - * Document style content, word processing files, audio, etc - */ - function isFile() { - return $this->repoObj->lobSubType == 'document'; - } - - /** * Acitivty/assignment style content. homework, upload a file, etc. */ --- 35,38 ---- *************** *** 55,58 **** --- 48,74 ---- } + /** + * Content or classroom material style content. + */ + function isMaterial() { + return $this->repoObj->lobType == 'content'; + } + + /** + * Document style content, word processing files, audio, etc + * + * This sub type is a binary document file that can't be displayed + * in Web pages w/o a plugin or a download. + */ + function isFile() { + return $this->repoObj->lobSubType == 'document'; + } + + /** + * Textual content, plain text, html + * + * This sub type is a binary document file that can be displayed + * in Web pages. + */ function isText() { return $this->repoObj->lobSubType == 'text'; Index: lc_lob_xml.php =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/lib/lob/lc_lob_xml.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** lc_lob_xml.php 1 Mar 2008 23:43:19 -0000 1.1 --- lc_lob_xml.php 2 Mar 2008 19:00:39 -0000 1.2 *************** *** 6,10 **** --- 6,176 ---- */ class Lc_Lob_Xml { + + /** + * return an Lc_Lob object + * + * @param $tempDir string The location of the unzipped backup file (/tmp/campus9999/). + * @static + */ + function parseNode($n,$tempDir='/tmp/') { + $result = $n->getElementsByTagname('type'); + $type = $result->item(0); + $children = $type->childNodes; + $content = ''; + if ($children->length) { + $content = trim($children->item(0)->nodeValue); + $guid = $n->getAttribute('guid'); + $dbid = $n->getAttribute('dbid'); + } + else { + die ('unknown class: '. get_class($type)); + return null; + } + $lob = null; + $lob = new LobRepoEntry(); + $lob->set('lobGuid',$guid); + switch ($content) { + case 'content': + $lob->set('lobType','content'); + break; + case 'activity': + $lob->set('lobType','activity'); + break; + case 'test': + $lob->set('lobType','test'); + break; + } + if ($lob->lobType == '') { return null; die ('unknown type '. $content); } + + + $result = $n->getElementsByTagname('title'); + $node = $result->item(0); + $children = $node->childNodes; + $lob->set('lobTitle', trim($children->item(0)->nodeValue) ); + + $result = $n->getElementsByTagname('content'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobContent', trim($children->item(0)->nodeValue) ); + } + + $result = $n->getElementsByTagname('filename'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobFilename', trim($children->item(0)->nodeValue) ); + + $urlTitle = Lc_Lob_Util::createLinkText(trim($children->item(0)->nodeValue)); + $lob->set('lobUrltitle', $urlTitle ); + $lob->set('lobBinary', file_get_contents($tempDir.'/content/'.trim($children->item(0)->nodeValue)) ); + } else { + $urlTitle = Lc_Lob_Util::createLinkText(trim( $lob->get('lobTitle')) ); + $lob->set('lobUrltitle', $urlTitle ); + } + + $result = $n->getElementsByTagname('description'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobDescription', trim($children->item(0)->nodeValue) ); + } + + + $result = $n->getElementsByTagname('subtype'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobSubType', trim($children->item(0)->nodeValue) ); + } + + $result = $n->getElementsByTagname('mime'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobMime', trim($children->item(0)->nodeValue) ); + } + + $lobSub = null; + + if ($lobObj->lobType == 'content') { + $lobSub = $this->makeContentNode($n); + } + if ($lobObj->lobType == 'activity') { + $lobSub = $this->makeActivityNode($n); + } + + if ( is_object($lobSub) ) { + $lob->lobSub = $lobSub; + } + + $lobMetaObj = Lc_Lob_Xml::processLobMeta($n); + $lobUserObj = new LobUserLink(); + + /* + $lobUserObj->set('lobRepoEntryId',$lobObj->getPrimaryKey()); + $lobUserObj->set('userId',$u->userId); + $lobUserObj->set('isOwner','1'); + $lobUserObj->save(); + */ + + return $lob; + // debug($children); + } + + /** + * return a lob metadata object + */ + function processLobMeta($n) { + $result = $n->getElementsByTagname('metadata'); + $meta = $result->item(0); + $children = $meta->childNodes; + + + $lob = null; + $lob = new LobMetadata(); + + foreach($children as $childNode) { + if ($childNode->nodeType == XML_TEXT_NODE) { + continue; + } + + $tag = $childNode->tagName; + $subchild = $childNode->childNodes; + $lob->set($tag, trim($subchild->item(0)->nodeValue) ); + } + } + /* + + $result = $n->getElementsByTagname('lobtitle'); + $node = $result->item(0); + $children = $node->childNodes; + $lob->set('lobTitle', trim($children->item(0)->nodeValue) ); + + $result = $n->getElementsByTagname('lobcontent'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobContent', trim($children->item(0)->nodeValue) ); + } + + $result = $n->getElementsByTagname('lobfilename'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobFilename', trim($children->item(0)->nodeValue) ); + $lob->set('lobUrltitle', urlencode(trim($children->item(0)->nodeValue)) ); + } else { + $urltitle = $lob->get('lobTitle'); + $urltitle = str_replace(' ', '_', $urltitle); + $urltitle = urlencode($urltitle); + $lob->set('lobUrltitle', $urltitle ); + } + + $result = $n->getElementsByTagname('lobdescription'); + $node = $result->item(0); + */ } + ?> |