ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilECSEContent.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
34 {
35  private $obj_id;
36  private $owner = 0;
37 
38  // ECS JSON variables
39  // All exportable fields have to be public
40 
41  public $url = '';
42  public $title = '';
43  //public $eligibleMembers = array();
44  public $etype = 'application/ecs-course';
45  public $status = 'offline';
46  public $lang = 'en_EN';
47  public $abstract = '';
48  public $study_courses = array();
49  public $credits = '';
50  public $semesterHours = '';
51  public $lecturer = array();
52  public $courseType = '';
53  public $courseID = '';
54  public $eid = 0;
55  public $term = '';
56  public $timePlace = null;
57 
58 
66  public function __construct($a_eid = 0)
67  {
68  include_once('./Services/WebServices/ECS/classes/class.ilECSTimePlace.php');
69 
70  if($a_eid)
71  {
72  $this->eid = $a_eid;
73  }
74  $this->timePlace = new ilECSTimePlace();
75  }
76 
83  public function getEContentId()
84  {
85  return $this->eid;
86  }
87 
95  public function setObjId($a_id)
96  {
97  $this->obj_id = $a_id;
98  }
99 
107  public function getObjId()
108  {
109  return $this->obj_id;
110  }
111 
118  public function getOrganization()
119  {
120  return $this->organisation;
121  }
122 
130  public function getTimePlace()
131  {
132  return $this->timePlace;
133  }
134 
142  public function setTitle($a_title)
143  {
144  $this->title = $a_title;
145  }
146 
153  public function getTitle()
154  {
155  return $this->title;
156  }
157 
165  public function setInfo($a_info)
166  {
167  $this->abstract = $a_info;
168  }
169 
176  public function getInfo()
177  {
178  return $this->abstract;
179  }
180 
188  public function setURL($a_url)
189  {
190  $this->url = $a_url;
191  }
192 
199  public function getURL()
200  {
201  return $this->url;
202  }
203 
211  public function setLanguage($a_key)
212  {
213  if(strlen($a_key))
214  {
215  $this->lang = ($a_key.'_'.strtoupper($a_key));
216  }
217  }
218 
225  public function getLanguage()
226  {
227  if(strlen($this->lang))
228  {
229  return substr($this->lang,0,2);
230  }
231  }
232 
233 
239  public function getOwner()
240  {
241  return $this->owner ? $this->owner : 0;
242  }
243 
251  public function setOwner($a_owner)
252  {
253  $this->owner = (int) $a_owner;
254  }
255 
256 
264  public function setStatus($a_status)
265  {
266  switch($a_status)
267  {
268  case 'online':
269  $this->status = 'online';
270  break;
271 
272  default:
273  $this->status = 'offline';
274  break;
275  }
276  }
277 
285  public function getStatus()
286  {
287  return $this->status == 'online' ? $this->status : 'offline';
288  }
289 
296  public function isOnline()
297  {
298  return $this->status == 'online' ? true : false;
299  }
300 
308  public function setCredits($a_credits)
309  {
310  $this->credits = $a_credits;
311  }
312 
319  public function getCredits()
320  {
321  return $this->credits;
322  }
323 
331  public function setSemesterHours($a_semester_hours)
332  {
333  $this->semesterHours = $a_semester_hours;
334  }
335 
342  public function getSemesterHours()
343  {
344  return $this->semesterHours;
345  }
346 
356  public function setLecturers($a_lecturer)
357  {
358  $lecturer_arr = explode(',',$a_lecturer);
359  $this->lecturer = array();
360  foreach($lecturer_arr as $lecturer)
361  {
362  $this->lecturer[] = trim($lecturer);
363  }
364  return true;
365  }
366 
373  public function getLecturers()
374  {
375  return implode(', ',$this->lecturer);
376  }
377 
387  public function setStudyCourses($a_courses)
388  {
389  $courses_arr = explode(',',$a_courses);
390  $this->study_courses = array();
391  foreach($courses_arr as $course)
392  {
393  $this->study_courses[] = trim($course);
394  }
395  return true;
396  }
397 
404  public function getStudyCourses()
405  {
406  return implode(', ',$this->study_courses);
407  }
408 
416  public function setCourseType($a_type)
417  {
418  $this->courseType = $a_type;
419  }
420 
427  public function getCourseType()
428  {
429  return $this->courseType;
430  }
431 
439  public function setCourseID($a_id)
440  {
441  $this->courseID = $a_id;
442  }
443 
450  public function getCourseID()
451  {
452  return $this->courseID;
453  }
454 
462  public function setTerm($a_term)
463  {
464  $this->term = $a_term;
465  }
466 
473  public function getTerm()
474  {
475  return $this->term;
476  }
477 
482  public function getAbstract()
483  {
484  return $this->abstract;
485  }
486 
494  public function loadFromJSON($a_json)
495  {
496  global $ilLog;
497 
498  if(!is_object($a_json))
499  {
500  include_once('./Services/WebServices/ECS/classes/class.ilECSReaderException.php');
501  $ilLog->write(__METHOD__.': Cannot load from JSON. No object given.');
502  throw new ilECSReaderException('Cannot parse ECSContent.');
503  }
504  $this->organisation = $a_json->organisation;
505  $this->study_courses = $a_json->study_courses ? $a_json->study_courses : array();
506  $this->title = $a_json->title;
507  $this->abstract = $a_json->abstract;
508  $this->credits = $a_json->credits;
509  $this->semesterHours = $a_json->semesterHours;
510  $this->lecturer = $a_json->lecturer ? $a_json->lecturer : array();
511  $this->etype = $a_json->etype;
512  $this->status = $a_json->status;
513 
514  $this->courseID = $a_json->courseID;
515  $this->courseType = $a_json->courseType;
516  #$this->eid = $a_json->eid;
517  $this->term = $a_json->term;
518  $this->url = $a_json->url;
519  $this->lang = $a_json->lang;
520 
521  if(is_object($a_json->timePlace))
522  {
523  $this->timePlace = new ilECSTimePlace();
524  $this->timePlace->loadFromJSON($a_json->timePlace);
525  }
526  else
527  {
528  $this->timePlace = new ilECSTimePlace();
529  }
530  }
531 }
532 
533 ?>