• 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 = "2";
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                 $this->__buildWaitingList();
00076                 
00077                 $this->__buildSetting();
00078 
00079                 #$this->__buildObject($this->course_obj->getRefId());
00080                 
00081                 $this->__buildFooter();
00082         }
00083 
00084         function getXML()
00085         {
00086                 #var_dump("<pre>", htmlentities($this->xmlDumpMem()),"<pre>");
00087                 return $this->xmlDumpMem();
00088         }
00089 
00090         // Called from nested class
00091         function modifyExportIdentifier($a_tag, $a_param, $a_value)
00092         {
00093                 if ($a_tag == "Identifier" && $a_param == "Entry")
00094                 {
00095                         $a_value = "il_".$this->ilias->getSetting('inst_id')."_crs_".$this->course_obj->getId();
00096                 }
00097 
00098                 return $a_value;
00099         }
00100 
00101         // PRIVATE
00102         function __buildHeader()
00103         {
00104                 #$this->xmlSetDtdDef("<!DOCTYPE Course SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_course_0_1.dtd\">");
00105                 $this->xmlSetGenCmt("Export of ILIAS course ".
00106                                                         $this->course_obj->getId()." of installation ".$this->ilias->getSetting('inst_id').".");
00107                 $this->xmlHeader();
00108 
00109                 $attrs["exportVersion"] = $this->EXPORT_VERSION;
00110                 $attrs["id"] = "il_".$this->ilias->getSetting('inst_id').'_crs_'.$this->course_obj->getId();
00111                 $this->xmlStartTag("Course", $attrs);
00112 
00113                 return true;
00114         }
00115         function __buildMetaData()
00116         {
00117                 include_once 'Services/MetaData/classes/class.ilMD2XML.php';
00118 
00119                 $md2xml = new ilMD2XML($this->course_obj->getId(),$this->course_obj->getId(),'crs');
00120                 $md2xml->startExport();
00121                 $this->appendXML($md2xml->getXML());
00122 
00123                 return true;
00124         }
00125 
00126         function __buildAdmin()
00127         {
00128                 $this->course_obj->initCourseMemberObject();
00129 
00130                 foreach($this->course_obj->members_obj->getAdmins() as $id)
00131                 {
00132 
00133                         $data = $this->course_obj->members_obj->getUserData($id);
00134 
00135                         $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
00136                         $attr['notification'] = ($data['status'] == $this->course_obj->members_obj->STATUS_NOTIFY) ? 'Yes' : 'No';
00137                         $attr['passed'] = $data['passed'] ? 'Yes' : 'No';
00138 
00139                         $this->xmlStartTag('Admin',$attr);
00140                         $this->xmlEndTag('Admin');
00141                 }
00142                 return true;
00143         }
00144 
00145         function __buildTutor()
00146         {
00147                 $this->course_obj->initCourseMemberObject();
00148 
00149                 foreach($this->course_obj->members_obj->getTutors() as $id)
00150                 {
00151                         $data = $this->course_obj->members_obj->getUserData($id);
00152 
00153                         $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
00154                         $attr['notification'] = ($data['status'] == $this->course_obj->members_obj->STATUS_NOTIFY) ? 'Yes' : 'No';
00155                         $attr['passed'] = $data['passed'] ? 'Yes' : 'No';
00156 
00157                         $this->xmlStartTag('Tutor',$attr);
00158                         $this->xmlEndTag('Tutor');
00159                 }
00160                 return true;
00161         }
00162         function __buildMember()
00163         {
00164                 $this->course_obj->initCourseMemberObject();
00165 
00166                 foreach($this->course_obj->members_obj->getMembers() as $id)
00167                 {
00168                         $data = $this->course_obj->members_obj->getUserData($id);
00169 
00170                         $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
00171                         $attr['blocked'] = ($data['status'] == $this->course_obj->members_obj->STATUS_BLOCKED) ? 'Yes' : 'No';
00172                         $attr['passed'] = $data['passed'] ? 'Yes' : 'No';
00173 
00174                         $this->xmlStartTag('Member',$attr);
00175                         $this->xmlEndTag('Member');
00176                 }
00177                 return true;
00178         }
00179 
00180         function __buildSubscriber()
00181         {
00182                 $this->course_obj->initCourseMemberObject();
00183 
00184                 foreach($this->course_obj->members_obj->getSubscribers() as $id)
00185                 {
00186                         $data = $this->course_obj->members_obj->getSubscriberData($id);
00187 
00188                         $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
00189                         $attr['subscriptionTime'] = $data['time'];
00190 
00191                         $this->xmlStartTag('Subscriber',$attr);
00192                         $this->xmlEndTag('Subscriber');
00193                 }
00194                 return true;
00195         }
00196 
00197         function __buildWaitingList()
00198         {
00199                 include_once 'course/classes/class.ilCourseWaitingList.php';
00200 
00201                 $waiting_list = new ilCourseWaitingList($this->course_obj->getId());
00202                 
00203                 foreach($waiting_list->getAllUsers() as $data)
00204                 {
00205                         $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$data['usr_id'];
00206                         $attr['position'] = $data['position'];
00207                         $attr['subscriptionTime'] = $data['time'];
00208                         
00209                         $this->xmlStartTag('WaitingList',$attr);
00210                         $this->xmlEndTag('WaitingList');
00211                 }
00212                 return true;
00213         }
00214 
00215 
00216         function __buildSetting()
00217         {
00218                 $this->xmlStartTag('Settings');
00219 
00220                 // Availability
00221                 $this->xmlStartTag('Availability');
00222                 if($this->course_obj->getOfflineStatus())
00223                 {
00224                         $this->xmlElement('NotAvailable');
00225                 }
00226                 elseif($this->course_obj->getActivationUnlimitedStatus())
00227                 {
00228                         $this->xmlElement('Unlimited');
00229                 }
00230                 else
00231                 {
00232                         $this->xmlStartTag('TemporarilyAvailable');
00233                         $this->xmlElement('Start',null,$this->course_obj->getActivationStart());
00234                         $this->xmlElement('End',null,$this->course_obj->getActivationEnd());
00235                         $this->xmlEndTag('TemporarilyAvailable');
00236                 }
00237                 $this->xmlEndTag('Availability');
00238 
00239                 // Syllabus
00240                 $this->xmlElement('Syllabus',null,$this->course_obj->getSyllabus());
00241                 
00242                 // Contact
00243                 $this->xmlStartTag('Contact');
00244                 $this->xmlElement('Name',null,$this->course_obj->getContactName());
00245                 $this->xmlElement('Responsibility',null,$this->course_obj->getContactResponsibility());
00246                 $this->xmlElement('Phone',null,$this->course_obj->getContactPhone());
00247                 $this->xmlElement('Email',null,$this->course_obj->getContactEmail());
00248                 $this->xmlElement('Consultation',null,$this->course_obj->getContactConsultation());
00249                 $this->xmlEndTag('Contact');
00250 
00251                 // Registration
00252                 $attr = array();
00253 
00254                 if($this->course_obj->getSubscriptionType() == 2)
00255                 {
00256                         $attr['registrationType'] = 'Confirmation';
00257                 }
00258                 elseif($this->course_obj->getSubscriptionType() == 3)
00259                 {
00260                         $attr['registrationType'] = 'Direct';
00261                 }
00262                 else
00263                 {
00264                         $attr['registrationType'] = 'Password';
00265                 }
00266 
00267                 $attr['maxMembers'] = $this->course_obj->getSubscriptionMaxMembers();
00268                 $attr['notification'] = $this->course_obj->getSubscriptionNotify() ? 'Yes' : 'No';
00269                 $attr['waitinList'] = $this->course_obj->enabledWaitingList() ? 'Yes' : 'No';
00270 
00271                 $this->xmlStartTag('Registration',$attr);
00272                 
00273                 if($this->course_obj->getSubscriptionType() == 1)
00274                 {
00275                         $this->xmlElement('Disabled');
00276                 }
00277                 elseif($this->course_obj->getSubscriptionUnlimitedStatus() == 1)
00278                 {
00279                         $this->xmlElement('Unlimited');
00280                 }
00281                 else
00282                 {
00283                         $this->xmlStartTag('TemporarilyAvailable');
00284                         $this->xmlElement('Start',null,$this->course_obj->getSubscriptionStart());
00285                         $this->xmlElement('End',null,$this->course_obj->getSubscriptionEnd());
00286                         $this->xmlEndTag('TemporarilyAvailable');
00287                 }
00288                 if(strlen($pwd = $this->course_obj->getSubscriptionPassword()))
00289                 {
00290                         $this->xmlElement('Password',null,$pwd);
00291                 }
00292                 $this->xmlEndTag('Registration');
00293 
00294                 // Sort
00295                 $attr = array();
00296                 if($this->course_obj->getOrderType() == 1)
00297                 {
00298                         $attr['type'] = 'Manual';
00299                 }
00300                 elseif($this->course_obj->getOrderType() == 2)
00301                 {
00302                         $attr['type'] = 'Title';
00303                 }
00304                 else
00305                 {
00306                         $attr['type'] = 'Activation';
00307                 }
00308                 $this->xmlElement('Sort',$attr);
00309 
00310                 // Archives
00311                 $attr = array();
00312                 if($this->course_obj->getArchiveType() == 1)
00313                 {
00314                         $attr['Access'] = 'Disabled';
00315                 }
00316                 elseif($this->course_obj->getArchiveType() == 2)
00317                 {
00318                         $attr['Access'] = 'Read';
00319                 }
00320                 else
00321                 {
00322                         $attr['Access'] = 'Download';
00323                 }
00324                 $this->xmlStartTag('Archive',$attr);
00325 
00326                 $this->xmlElement('Start',null,$this->course_obj->getArchiveStart());
00327                 $this->xmlElement('End',null,$this->course_obj->getArchiveEnd());
00328 
00329                 $this->xmlEndTag('Archive');
00330 
00331                 $this->xmlEndTag('Settings');
00332 
00333                 return true;
00334         }
00335 
00336         
00337         // recursive
00338         function __buildObject($a_parent_id)
00339         {
00340                 $this->course_obj->initCourseItemObject();
00341                 $this->course_obj->items_obj->setParentId($a_parent_id);
00342 
00343                 foreach($this->course_obj->items_obj->getAllItems() as $item)
00344                 {
00345                         
00346                         if(!$tmp_obj =& ilObjectFactory::getInstanceByRefId($item['child'],false))
00347                         {
00348                                 continue;
00349                         }
00350                 
00351                         $attr = array();
00352                         $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_'.$tmp_obj->getType().'_'.$item['child'];
00353                         $attr['type'] = $tmp_obj->getType();
00354                         $attr['Unlimited'] = $item['activation_unlimited'] ? 1 : 0;
00355                         $attr['Position'] = $item['position'];
00356 
00357                         $this->xmlStartTag('Object',$attr);
00358                         $this->xmlElement('Title',null,$item['title']);
00359                         $this->xmlElement('Description',null,$item['description']);
00360                         $this->xmlElement('Start',null,$item['activation_start']);
00361                         $this->xmlElement('End',null,$item['activation_end']);
00362 
00363                         if($item['type'] == 'file')
00364                         {
00365                                 $this->xmlElement('FileType',null,$tmp_obj->getFileType());
00366                         }
00367 
00368                         $this->__buildObject($item['child']);
00369                         
00370                         $this->xmlEndTag('Object');
00371 
00372                         unset($tmp_obj);
00373                 }
00374         }
00375 
00376         function __buildFooter()
00377         {
00378                 $this->xmlEndTag('Course');
00379         }
00380 }
00381 
00382 
00383 ?>

Generated on Fri Dec 13 2013 11:57:58 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1