[Logicampus-cvs] logicampus/src/logicreate/lib/lesson lc_lesson.php, 1.1, 1.2 lc_lesson_xml.php, 1.
Brought to you by:
trilexcom
From: Mark K <har...@us...> - 2008-03-02 18:03:43
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/lib/lesson In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv23144/lib/lesson Modified Files: lc_lesson.php lc_lesson_xml.php Log Message: Fixing class naming convetion for Lc_Lesson Index: lc_lesson.php =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/lib/lesson/lc_lesson.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** lc_lesson.php 1 Mar 2008 23:43:19 -0000 1.1 --- lc_lesson.php 2 Mar 2008 18:03:24 -0000 1.2 *************** *** 7,15 **** * on the enrollment date for a student. */ ! class LC_Lesson { var $lessonDo = null; ! function LC_Lesson($id=-1) { if ($id > 0) { $this->lessonDo = ClassLessons::load($id); --- 7,16 ---- * on the enrollment date for a student. */ ! class Lc_Lesson { var $lessonDo = null; + var $guid = ''; ! function Lc_Lesson($id=-1) { if ($id > 0) { $this->lessonDo = ClassLessons::load($id); *************** *** 18,27 **** /** ! * Create a LC_Lesson object from a loaded dataobject * * @static */ function create($do) { ! $x = new LC_Lesson(); $x->lessonDo = $do; --- 19,28 ---- /** ! * Create a Lc_Lesson object from a loaded dataobject * * @static */ function create($do) { ! $x = new Lc_Lesson(); $x->lessonDo = $do; *************** *** 30,33 **** --- 31,41 ---- /** + * Set the GUID + */ + function setGuid($g) { + $this->guid = $g; + } + + /** * Load all lessons for this class * Index: lc_lesson_xml.php =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/lib/lesson/lc_lesson_xml.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** lc_lesson_xml.php 1 Mar 2008 23:43:19 -0000 1.1 --- lc_lesson_xml.php 2 Mar 2008 18:03:24 -0000 1.2 *************** *** 1,4 **** --- 1,6 ---- <?php + include_once(LIB_PATH.'PBDO/ClassLessons.php'); + include_once(LIB_PATH.'lesson/lc_lesson.php'); /** *************** *** 6,9 **** --- 8,129 ---- */ class Lc_Lesson_Xml { + + + /** + * return an Lc_Lesson object + * + * @static + */ + function parseNode($n) { + + /* + 'idClassLessons'=>'integer', + 'idClasses'=>'integer', + 'createdOn'=>'integer', + 'title'=>'varchar', + 'description'=>'longvarchar', + 'activeOn'=>'integer', + 'inactiveOn'=>'integer', + 'checkList'=>'longvarchar'); + */ + + $lessonDo = new ClassLessons(); + + $result = $n->getElementsByTagname('title'); + $title = $result->item(0); + + $lessonDo->title = $title->nodeValue; + + // TODO: double check the DB id belongs to this user. + $dbid = $n->getAttribute('dbid'); + $lessonDo->idClassLessons = $dbid; + + $lessonObj = Lc_Lesson::create($lessonDo); + + $guid = $n->getAttribute('guid'); + $lessonObj->setGuid($guid); + return $lessonObj; + /* + $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($this->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) ); + } + + return $lob; + // debug($children); + */ + } } |