Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00034 class ilObjectDefinition extends ilSaxParser
00035 {
00042 var $obj_id;
00043
00049 var $parent;
00050
00056 var $obj_data;
00057
00064 function ilObjectDefinition()
00065 {
00066 parent::ilSaxParser(ILIAS_ABSOLUTE_PATH."/objects.xml");
00067 }
00068
00069
00070
00077 function getDefinition($a_obj_name)
00078 {
00079 return $this->obj_data[$a_obj_name];
00080 }
00081
00088 function getClassName($a_obj_name)
00089 {
00090 return $this->obj_data[$a_obj_name]["class_name"];
00091 }
00092
00093
00100 function getLocation($a_obj_name)
00101 {
00102 return $this->obj_data[$a_obj_name]["location"];
00103 }
00104
00105
00112 function getModule($a_obj_name)
00113 {
00114 return $this->obj_data[$a_obj_name]["module"];
00115 }
00116
00117
00124 function hasCheckbox($a_obj_name)
00125 {
00126 return (bool) $this->obj_data[$a_obj_name]["checkbox"];
00127 }
00128
00135 function getTranslationType($a_obj_name)
00136 {
00137 global $ilDB;
00138
00139 if ($a_obj_name == "root")
00140 {
00141 if (!isset($this->root_trans_type))
00142 {
00143 $q = "SELECT count(*) as cnt FROM object_translation WHERE obj_id = ".
00144 $ilDB->quote(ROOT_FOLDER_ID);
00145 $set = $ilDB->query($q);
00146 $rec = $set->fetchRow(DB_FETCHMODE_ASSOC);
00147 if($rec["cnt"] > 0)
00148 {
00149 $this->root_trans_type = "db";
00150 }
00151 else
00152 {
00153 $this->root_trans_type = $this->obj_data[$a_obj_name]["translate"];
00154 }
00155 }
00156 return $this->root_trans_type;
00157 }
00158
00159 return $this->obj_data[$a_obj_name]["translate"];
00160 }
00161
00162
00169 function stopInheritance($a_obj_name)
00170 {
00171 return (bool) $this->obj_data[$a_obj_name]["inherit"];
00172 }
00173
00180 function getProperties($a_obj_name)
00181 {
00182
00183
00184 if (defined("ILIAS_MODULE") || $_GET["baseClass"] != "")
00185 {
00186 $props = array();
00187 if (is_array($this->obj_data[$a_obj_name]["properties"]))
00188 {
00189 foreach ($this->obj_data[$a_obj_name]["properties"] as $data => $prop)
00190 {
00191 if ($prop["module"] != "n")
00192 {
00193 $props[$data] = $prop;
00194 }
00195 }
00196 }
00197 return $props;
00198 }
00199 else
00200 {
00201 $props = array();
00202 if (is_array($this->obj_data[$a_obj_name]["properties"]))
00203 {
00204 foreach ($this->obj_data[$a_obj_name]["properties"] as $data => $prop)
00205 {
00206 if ($prop["module"] != 1)
00207 {
00208 $props[$data] = $prop;
00209 }
00210 }
00211 }
00212 return $props;
00213 }
00214 }
00215
00222 function getDevMode($a_obj_name)
00223 {
00224 return (bool) $this->obj_data[$a_obj_name]["devmode"];
00225 }
00226
00233 function getDevModeAll()
00234 {
00235 $types = array_keys($this->obj_data);
00236
00237 foreach ($types as $type)
00238 {
00239 if ($this->getDevMode($type))
00240 {
00241 $devtypes[] = $type;
00242 }
00243 }
00244
00245 return $devtypes ? $devtypes : array();
00246 }
00247
00255 function isRBACObject($a_obj_name)
00256 {
00257 return (bool) $this->obj_data[$a_obj_name]["rbac"];
00258 }
00259
00266 function getAllRBACObjects()
00267 {
00268 $types = array_keys($this->obj_data);
00269
00270 foreach ($types as $type)
00271 {
00272 if ($this->isRBACObject($type))
00273 {
00274 $rbactypes[] = $type;
00275 }
00276 }
00277
00278 return $rbactypes ? $rbactypes : array();
00279 }
00280
00287 function getAllObjects()
00288 {
00289 return array_keys($this->obj_data);
00290 }
00291
00298 function allowLink($a_obj_name)
00299 {
00300 return (bool) $this->obj_data[$a_obj_name]["allow_link"];
00301 }
00302
00309 function allowCopy($a_obj_name)
00310 {
00311 return (bool) $this->obj_data[$a_obj_name]["allow_copy"];
00312 }
00313
00321 public function getContentItemSortingModes($a_obj_name)
00322 {
00323 if(isset($this->obj_data[$a_obj_name]['sorting']))
00324 {
00325 return $this->obj_data[$a_obj_name]['sorting']['modes'] ? $this->obj_data[$a_obj_name]['sorting']['modes'] : array();
00326 }
00327 return array();
00328 }
00329
00338 function getSubObjects($a_obj_type,$a_filter = true)
00339 {
00340 $subs = array();
00341
00342 if ($subobjects = $this->obj_data[$a_obj_type]["subobjects"])
00343 {
00344
00345 if ($a_filter)
00346 {
00347 $this->__filterObjects($subobjects);
00348 }
00349
00350 foreach ($subobjects as $data => $sub)
00351 {
00352 if ($sub["module"] != "n")
00353 {
00354 $subs[$data] = $sub;
00355 }
00356 }
00357
00358 return $subs;
00359 }
00360
00361 return $subs;
00362 }
00363
00377 function getSubObjectsRecursively($a_obj_type)
00378 {
00379
00380
00381 $recursivesubs = array();
00382
00383
00384
00385 $to_do = array($a_obj_type);
00386
00387
00388
00389
00390
00391 $done = array();
00392
00393 while (count($to_do) > 0)
00394 {
00395 $type = array_pop($to_do);
00396 $done[] = $type;
00397 $subs = $this->getSubObjects($type);
00398 foreach ($subs as $subtype => $data)
00399 {
00400 $recursivesubs[$subtype] = $data;
00401 if (! in_array($subtype, $done)
00402 && ! in_array($subtype, $to_do))
00403 {
00404 $to_do[] = $subtype;
00405 }
00406 }
00407 }
00408
00409 return $recursivesubs;
00410 }
00411
00421 function getSubobjectsToFilter($a_obj_type = "adm")
00422 {
00423 foreach($this->obj_data[$a_obj_type]["subobjects"] as $key => $value)
00424 {
00425 switch($key)
00426 {
00427 case "rolf":
00428
00429 break;
00430
00431 default:
00432 $tmp_subs[] = $key;
00433 }
00434 }
00435
00436 $tmp_subs[] = "adm";
00437 #$tmp_subs[] = "root";
00438
00439 return $tmp_subs ? $tmp_subs : array();
00440 }
00441
00449 function getCreatableSubObjects($a_obj_type)
00450 {
00451 $subobjects = $this->getSubObjects($a_obj_type);
00452
00453
00454 unset($subobjects["rolf"]);
00455
00456 $sub_types = array_keys($subobjects);
00457
00458
00459 foreach ($sub_types as $type)
00460 {
00461 if ($this->getDevMode($type))
00462 {
00463 unset($subobjects[$type]);
00464 }
00465 }
00466
00467 return $subobjects;
00468 }
00469
00476 function getActions($a_obj_name)
00477 {
00478 $ret = (is_array($this->obj_data[$a_obj_name]["actions"])) ?
00479 $this->obj_data[$a_obj_name]["actions"] :
00480 array();
00481 return $ret;
00482 }
00483
00490 function getFirstProperty($a_obj_name)
00491 {
00492 if (defined("ILIAS_MODULE"))
00493 {
00494 foreach ($this->obj_data[$a_obj_name]["properties"] as $data => $prop)
00495 {
00496 if($prop["module"] != "n")
00497 {
00498 return $data;
00499 }
00500 }
00501 }
00502 else
00503 {
00504 foreach ($this->obj_data[$a_obj_name]["properties"] as $data => $prop)
00505 {
00506 if ($prop["module"] != 1)
00507 {
00508 return $data;
00509 }
00510 }
00511 }
00512 }
00513
00520 function getPropertyName($a_cmd, $a_obj_name)
00521 {
00522 return $this->obj_data[$a_obj_name]["properties"][$a_cmd]["lng"];
00523 }
00524
00531 function getSubObjectsAsString($a_obj_type)
00532 {
00533 $string = "";
00534
00535 if (is_array($this->obj_data[$a_obj_type]["subobjects"]))
00536 {
00537 $data = array_keys($this->obj_data[$a_obj_type]["subobjects"]);
00538
00539 $string = "'".implode("','", $data)."'";
00540 }
00541
00542 return $string;
00543 }
00544
00551 function getImportObjects($a_obj_type)
00552 {
00553 $imp = array();
00554
00555 if (is_array($this->obj_data[$a_obj_type]["subobjects"]))
00556 {
00557 foreach ($this->obj_data[$a_obj_type]["subobjects"] as $sub)
00558 {
00559 if ($sub["import"] == 1)
00560 {
00561 $imp[] = $sub["name"];
00562 }
00563 }
00564 }
00565
00566 return $imp;
00567 }
00568
00577 public function isContainer($a_obj_name)
00578 {
00579 if(!is_array($this->obj_data[$a_obj_name]['subobjects']))
00580 {
00581 return false;
00582 }
00583 return count($this->obj_data[$a_obj_name]['subobjects']) > 1 ? true : false;
00584 }
00585
00586
00587
00594 function setHandlers($a_xml_parser)
00595 {
00596 xml_set_object($a_xml_parser,$this);
00597 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
00598 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
00599 }
00600
00609 function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
00610 {
00611 switch ($a_name)
00612 {
00613 case 'objects':
00614 $this->current_tag = '';
00615 break;
00616 case 'object':
00617 $this->parent_tag_name = $a_attribs["name"];
00618 $this->current_tag = '';
00619 $this->obj_data["$a_attribs[name]"]["name"] = $a_attribs["name"];
00620 $this->obj_data["$a_attribs[name]"]["class_name"] = $a_attribs["class_name"];
00621 $this->obj_data["$a_attribs[name]"]["location"] = $a_attribs["location"];
00622 $this->obj_data["$a_attribs[name]"]["checkbox"] = $a_attribs["checkbox"];
00623 $this->obj_data["$a_attribs[name]"]["inherit"] = $a_attribs["inherit"];
00624 $this->obj_data["$a_attribs[name]"]["module"] = $a_attribs["module"];
00625 $this->obj_data["$a_attribs[name]"]["translate"] = $a_attribs["translate"];
00626 $this->obj_data["$a_attribs[name]"]["devmode"] = $a_attribs["devmode"];
00627 $this->obj_data["$a_attribs[name]"]["allow_link"] = $a_attribs["allow_link"];
00628 $this->obj_data["$a_attribs[name]"]["allow_copy"] = $a_attribs["allow_copy"];
00629 $this->obj_data["$a_attribs[name]"]["rbac"] = $a_attribs["rbac"];
00630 $this->obj_data["$a_attribs[name]"]["system"] = $a_attribs["system"];
00631 $this->obj_data["$a_attribs[name]"]["sideblock"] = $a_attribs["sideblock"];
00632 break;
00633 case 'subobj':
00634 $this->current_tag = "subobj";
00635 $this->current_tag_name = $a_attribs["name"];
00636 $this->obj_data[$this->parent_tag_name]["subobjects"][$this->current_tag_name]["name"] = $a_attribs["name"];
00637
00638 $this->obj_data[$this->parent_tag_name]["subobjects"][$this->current_tag_name]["max"] = $a_attribs["max"];
00639
00640 $this->obj_data[$this->parent_tag_name]["subobjects"][$this->current_tag_name]["import"] = $a_attribs["import"];
00641 $this->obj_data[$this->parent_tag_name]["subobjects"][$this->current_tag_name]["module"] = $a_attribs["module"];
00642 break;
00643 case 'property':
00644 $this->current_tag = "property";
00645 $this->current_tag_name = $a_attribs["name"];
00646 $this->obj_data[$this->parent_tag_name]["properties"][$this->current_tag_name]["name"] = $a_attribs["name"];
00647 $this->obj_data[$this->parent_tag_name]["properties"][$this->current_tag_name]["module"] = $a_attribs["module"];
00648 break;
00649 case 'action':
00650 $this->current_tag = "action";
00651 $this->current_tag_name = $a_attribs["name"];
00652 $this->obj_data[$this->parent_tag_name]["actions"][$this->current_tag_name]["name"] = $a_attribs["name"];
00653 break;
00654
00655 case 'sorting':
00656 $this->current_tag = 'sorting';
00657 $this->obj_data[$this->parent_tag_name]['sorting']['modes'][] = $a_attribs['mode'];
00658 break;
00659 }
00660 }
00661
00669 function handlerCharacterData($a_xml_parser,$a_data)
00670 {
00671
00672 $a_data = preg_replace("/\n/","",$a_data);
00673 $a_data = preg_replace("/\t+/","",$a_data);
00674
00675 if (!empty($a_data))
00676 {
00677 switch ($this->current_tag)
00678 {
00679 case "subobj":
00680 $this->obj_data[$this->parent_tag_name]["subobjects"][$this->current_tag_name]["lng"] .= $a_data;
00681 break;
00682 case "action" :
00683 $this->obj_data[$this->parent_tag_name]["actions"][$this->current_tag_name]["lng"] .= $a_data;
00684 break;
00685 case "property" :
00686 $this->obj_data[$this->parent_tag_name]["properties"][$this->current_tag_name]["lng"] .= $a_data;
00687 break;
00688 default:
00689 break;
00690 }
00691 }
00692 }
00693
00701 function handlerEndTag($a_xml_parser,$a_name)
00702 {
00703 $this->current_tag = '';
00704 $this->current_tag_name = '';
00705 }
00706
00707 function __filterObjects(&$subobjects)
00708 {
00709 foreach($subobjects as $type => $data)
00710 {
00711 switch($type)
00712 {
00713 case "chat":
00714 if(!$this->ilias->getSetting("chat_active"))
00715 {
00716 unset($subobjects[$type]);
00717 }
00718 break;
00719
00720 case "icrs":
00721 if(!$this->ilias->getSetting("ilinc_active"))
00722 {
00723 unset($subobjects[$type]);
00724 }
00725 break;
00726
00727 default:
00728
00729 }
00730 }
00731 }
00732
00746 function isSystemObject($a_obj_name)
00747 {
00748 return (bool) $this->obj_data[$a_obj_name]["system"];
00749 }
00750
00757 function isSideBlock($a_obj_name)
00758 {
00759 return (bool) $this->obj_data[$a_obj_name]["sideblock"];
00760 }
00761
00762 }
00763 ?>