• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

course/classes/class.ilCourseXMLWriter.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004     +-----------------------------------------------------------------------------+
00005     | ILIAS open source                                                           |
00006         +-----------------------------------------------------------------------------+
00007     | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00008     |                                                                             |
00009     | This program is free software; you can redistribute it and/or               |
00010     | modify it under the terms of the GNU General Public License                 |
00011     | as published by the Free Software Foundation; either version 2              |
00012     | of the License, or (at your option) any later version.                      |
00013     |                                                                             |
00014     | This program is distributed in the hope that it will be useful,             |
00015     | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00016     | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00017     | GNU General Public License for more details.                                |
00018     |                                                                             |
00019     | You should have received a copy of the GNU General Public License           |
00020     | along with this program; if not, write to the Free Software                 |
00021     | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00022     +-----------------------------------------------------------------------------+
00023 */
00024 
00038 include_once "./classes/class.ilXmlWriter.php";
00039 
00040 class ilCourseXMLWriter extends ilXmlWriter
00041 {
00042         var $ilias;
00043 
00044         var $xml;
00045         var $course_obj;
00046 
00054         function ilCourseXMLWriter(&$course_obj)
00055         {
00056                 global $ilias;
00057 
00058                 parent::ilXmlWriter();
00059 
00060                 $this->EXPORT_VERSION = 1;
00061 
00062                 $this->ilias =& $ilias;
00063                 $this->course_obj =& $course_obj;
00064         }
00065 
00066         function start()
00067         {
00068                 $this->__buildHeader();
00069                 $this->__buildMetaData();
00070                 
00071                 $this->__buildAdmin();
00072                 $this->__buildTutor();
00073                 $this->__buildMember();
00074                 $this->__buildSubscriber();
00075 
00076                 $this->__buildSetting();
00077 
00078                 $this->__buildObject($this->course_obj->getRefId());
00079                 
00080                 $this->__buildFooter();
00081         }
00082 
00083         function getXML()
00084         {
00085                 return $this->xmlDumpMem();
00086         }
00087 
00088         // Called from nested class
00089         function modifyExportIdentifier($a_tag, $a_param, $a_value)
00090         {
00091                 if ($a_tag == "Identifier" && $a_param == "Entry")
00092                 {
00093                         $a_value = "il_".$this->ilias->getSetting('inst_id')."_crs_".$this->course_obj->getId();
00094                 }
00095 
00096                 return $a_value;
00097         }
00098 
00099         // PRIVATE
00100         function __buildHeader()
00101         {
00102                 $this->xmlSetDtdDef("<!DOCTYPE Course SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_course.dtd\">");
00103                 $this->xmlSetGenCmt("Export of ILIAS course ".
00104                                                         $this->course_obj->getId()." of installation ".$this->ilias->getSetting('inst_id').".");
00105                 $this->xmlHeader();
00106 
00107                 $attrs["exportVersion"] = $this->EXPORT_VERSION;
00108                 $attrs["id"] = "il_".$this->ilias->getSetting('inst_id').'_course_'.$this->course_obj->getId();
00109                 $this->xmlStartTag("Course", $attrs);
00110 
00111                 return true;
00112         }
00113         function __buildMetaData()
00114         {
00115                 include_once "./classes/class.ilNestedSetXML.php";
00116 
00117                 $nested = new ilNestedSetXML();
00118                 $nested->setParameterModifier($this, "modifyExportIdentifier");
00119                 $this->appendXML($nested->export($this->course_obj->getId(),$this->course_obj->getType()));
00120                 
00121                 return true;
00122         }
00123 
00124         function __buildAdmin()
00125         {
00126                 $this->course_obj->initCourseMemberObject();
00127 
00128                 foreach($this->course_obj->members_obj->getAdmins() as $id)
00129                 {
00130                         $data = $this->course_obj->members_obj->getUserData($id);
00131 
00132                         $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
00133                         $attr['status'] = $data['status'];
00134 
00135                         $this->xmlStartTag('Admin',$attr);
00136                         $this->xmlEndTag('Admin');
00137                 }
00138                 return true;
00139         }
00140 
00141         function __buildTutor()
00142         {
00143                 $this->course_obj->initCourseMemberObject();
00144 
00145                 foreach($this->course_obj->members_obj->getTutors() as $id)
00146                 {
00147                         $data = $this->course_obj->members_obj->getUserData($id);
00148 
00149                         $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
00150                         $attr['status'] = $data['status'];
00151 
00152                         $this->xmlStartTag('Tutor',$attr);
00153                         $this->xmlEndTag('Tutor');
00154                 }
00155                 return true;
00156         }
00157         function __buildMember()
00158         {
00159                 $this->course_obj->initCourseMemberObject();
00160 
00161                 foreach($this->course_obj->members_obj->getMembers() as $id)
00162                 {
00163                         $data = $this->course_obj->members_obj->getUserData($id);
00164 
00165                         $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
00166                         $attr['status'] = $data['status'];
00167 
00168                         $this->xmlStartTag('Member',$attr);
00169                         $this->xmlEndTag('Member');
00170                 }
00171                 return true;
00172         }
00173 
00174         function __buildSubscriber()
00175         {
00176                 $this->course_obj->initCourseMemberObject();
00177 
00178                 foreach($this->course_obj->members_obj->getSubscribers() as $id)
00179                 {
00180                         $data = $this->course_obj->members_obj->getSubscriberData($id);
00181 
00182                         $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
00183                         $attr['SubscriptionTime'] = $data['time'];
00184 
00185                         $this->xmlStartTag('Subscriber',$attr);
00186                         $this->xmlEndTag('Subscriber');
00187                 }
00188                 return true;
00189         }
00190 
00191         function __buildSetting()
00192         {
00193                 $this->xmlStartTag('Settings');
00194 
00195                 $this->xmlElement('Syllabus',null,$this->course_obj->getSyllabus());
00196 
00197                 $this->xmlStartTag('Contact');
00198                 $this->xmlElement('Name',null,$this->course_obj->getContactName());
00199                 $this->xmlElement('Responsibility',null,$this->course_obj->getContactResponsibility());
00200                 $this->xmlElement('Phone',null,$this->course_obj->getContactPhone());
00201                 $this->xmlElement('Email',null,$this->course_obj->getContactEmail());
00202                 $this->xmlElement('Consultation',null,$this->course_obj->getContactConsultation());
00203                 $this->xmlEndTag('Contact');
00204 
00205                 $attr = array();
00206                 $attr["Unlimited"] = $this->course_obj->getActivationUnlimitedStatus() ? 1 : 0;
00207                 $attr["Offline"] = $this->course_obj->getOfflineStatus() ? 1 : 0;
00208                 $this->xmlStartTag('Activation',$attr);
00209                 $this->xmlElement('Start',null,$this->course_obj->getActivationStart());
00210                 $this->xmlElement('End',null,$this->course_obj->getActivationEnd());
00211                 $this->xmlEndTag('Activation');
00212 
00213                 $attr = array();
00214                 $attr['Unlimited'] = $this->course_obj->getSubscriptionUnlimitedStatus() ? 1 : 0;
00215                 $attr['MaxMembers'] = $this->course_obj->getSubscriptionMaxMembers();
00216                 $attr['Notify'] = $this->course_obj->getSubscriptionNotify() ? 1 : 0;
00217                 $attr['Type'] = $this->course_obj->getSubscriptionType();
00218                 $this->xmlStartTag('Subscription',$attr);
00219                 $this->xmlElement('Start',null,$this->course_obj->getSubscriptionStart());
00220                 $this->xmlElement('End',null,$this->course_obj->getSubscriptionEnd());
00221                 $this->xmlElement('Password',null,$this->course_obj->getSubscriptionPassword());
00222                 $this->xmlEndTag('Subscription');
00223 
00224                 $attr = array();
00225                 $attr['SortType'] = $this->course_obj->getOrderType();
00226                 $this->xmlElement('Sort',$attr);
00227 
00228                 $attr = array();
00229                 $attr['Type'] = $this->course_obj->getArchiveType();
00230                 $this->xmlStartTag('Archive',$attr);
00231                 $this->xmlElement('Start',null,$this->course_obj->getArchiveStart());
00232                 $this->xmlElement('End',null,$this->course_obj->getArchiveEnd());
00233                 $this->xmlEndTag('Archive');
00234 
00235                 $this->xmlEndTag('Settings');
00236         }
00237 
00238         
00239         // recursive
00240         function __buildObject($a_parent_id)
00241         {
00242                 $this->course_obj->initCourseItemObject();
00243                 $this->course_obj->items_obj->setParentId($a_parent_id);
00244 
00245                 foreach($this->course_obj->items_obj->getAllItems() as $item)
00246                 {
00247                         
00248                         if(!$tmp_obj =& ilObjectFactory::getInstanceByRefId($item['child'],false))
00249                         {
00250                                 continue;
00251                         }
00252                 
00253                         $attr = array();
00254                         $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_'.$tmp_obj->getType().'_'.$item['child'];
00255                         $attr['type'] = $tmp_obj->getType();
00256                         $attr['Unlimited'] = $item['activation_unlimited'] ? 1 : 0;
00257                         $attr['Position'] = $item['position'];
00258 
00259                         $this->xmlStartTag('Object',$attr);
00260                         $this->xmlElement('Title',null,$item['title']);
00261                         $this->xmlElement('Description',null,$item['description']);
00262                         $this->xmlElement('Start',null,$item['activation_start']);
00263                         $this->xmlElement('End',null,$item['activation_end']);
00264 
00265                         if($item['type'] == 'file')
00266                         {
00267                                 $this->xmlElement('FileType',null,$tmp_obj->getFileType());
00268                         }
00269 
00270                         $this->__buildObject($item['child']);
00271                         
00272                         $this->xmlEndTag('Object');
00273 
00274                         unset($tmp_obj);
00275                 }
00276         }
00277 
00278         function __buildFooter()
00279         {
00280                 $this->xmlEndTag('Course');
00281         }
00282 }
00283 
00284 
00285 ?>

Generated on Fri Dec 13 2013 09:06:36 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1