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 require_once("content/classes/class.ilLMObject.php");
00025
00036 class ilStructureObject extends ilLMObject
00037 {
00038 var $is_alias;
00039 var $origin_id;
00040 var $tree;
00041
00046 function ilStructureObject(&$a_content_obj, $a_id = 0)
00047 {
00048 $this->setType("st");
00049 parent::ilLMObject($a_content_obj, $a_id);
00050 }
00051
00052 function create($a_upload = false)
00053 {
00054 parent::create($a_upload);
00055 }
00056
00060 function delete($a_delete_meta_data = true)
00061 {
00062 $this->tree = new ilTree($this->getLmId());
00063 $this->tree->setTableNames('lm_tree', 'lm_data');
00064 $this->tree->setTreeTablePK("lm_id");
00065 $node_data = $this->tree->getNodeData($this->getId());
00066 $this->delete_rec($this->tree, $a_delete_meta_data);
00067 $this->tree->deleteTree($node_data);
00068 }
00069
00073 function delete_rec(&$a_tree, $a_delete_meta_data = true)
00074 {
00075 $childs = $a_tree->getChilds($this->getId());
00076 foreach ($childs as $child)
00077 {
00078 $obj =& ilLMObjectFactory::getInstance($this->content_object, $child["obj_id"], false);
00079 if (is_object($obj))
00080 {
00081 if($obj->getType() == "st")
00082 {
00083 $obj->delete_rec($a_tree, $a_delete_meta_data);
00084 }
00085 if($obj->getType() == "pg")
00086 {
00087 $obj->delete($a_delete_meta_data);
00088 }
00089 }
00090 unset($obj);
00091 }
00092 parent::delete($a_delete_meta_data);
00093 }
00094
00098 function ©(&$lmtree, $a_parent, $a_pos = IL_LAST_NODE)
00099 {
00100 $meta =& new ilMetaData();
00101 $chap =& new ilLMPageObject($this->getContentObject());
00102 $chap->assignMetaData($meta);
00103 $chap->setTitle($this->getTitle());
00104 $chap->setLMId($this->getLMId());
00105 $chap->setType($this->getType());
00106 $chap->setDescription($this->getDescription());
00107 $chap->create();
00108
00109
00110 $lmtree->insertNode($chap->getId(), $a_parent, $a_pos);
00111
00112 $childs =& $lmtree->getChilds($this->getId());
00113 foreach($childs as $child)
00114 {
00115 $lmobj = ilLMObjectFactory::getInstance($this->getContentObject(), $child["obj_id"], true);
00116 $newobj =& $lmobj->copy($lmtree, $chap->getId());
00117
00118 if ($newobj->getType() == "pg")
00119 {
00120 $lmtree->insertNode($newobj->getId(), $chap->getId());
00121 }
00122 }
00123
00124 return $chap;
00125 }
00126
00127
00133 function _goto($a_target)
00134 {
00135 global $rbacsystem, $ilErr, $lng;
00136
00137
00138 $lm_id = ilLMObject::_lookupContObjID($a_target);
00139
00140
00141 $ref_ids = ilObject::_getAllReferences($lm_id);
00142
00143
00144 foreach ($ref_ids as $ref_id)
00145 {
00146 include_once 'classes/class.ilSearch.php';
00147
00148
00149
00150 if ($rbacsystem->checkAccess("read", $ref_id) and ilSearch::_checkParentConditions($ref_id))
00151 {
00152 ilUtil::redirect("content/lm_presentation.php?ref_id=$ref_id".
00153 "&obj_id=$a_target");
00154 }
00155 }
00156
00157 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
00158 }
00159
00160
00167 function exportXML(&$a_xml_writer, $a_inst, &$expLog)
00168 {
00169 global $ilBench;
00170
00171 $expLog->write(date("[y-m-d H:i:s] ")."Structure Object ".$this->getId());
00172 $attrs = array();
00173 $a_xml_writer->xmlStartTag("StructureObject", $attrs);
00174
00175
00176 $ilBench->start("ContentObjectExport", "exportStructureObject_exportMeta");
00177 $this->exportXMLMetaData($a_xml_writer);
00178 $ilBench->stop("ContentObjectExport", "exportStructureObject_exportMeta");
00179
00180
00181 $ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjects");
00182 $this->exportXMLPageObjects($a_xml_writer, $a_inst);
00183 $ilBench->stop("ContentObjectExport", "exportStructureObject_exportPageObjects");
00184
00185
00186 $this->exportXMLStructureObjects($a_xml_writer, $a_inst, $expLog);
00187
00188
00189
00190
00191 $a_xml_writer->xmlEndTag("StructureObject");
00192 }
00193
00194
00201 function exportXMLMetaData(&$a_xml_writer)
00202 {
00203 $nested = new ilNestedSetXML();
00204 $nested->setParameterModifier($this, "modifyExportIdentifier");
00205 $a_xml_writer->appendXML($nested->export($this->getId(),
00206 $this->getType()));
00207 }
00208
00209 function modifyExportIdentifier($a_tag, $a_param, $a_value)
00210 {
00211 if ($a_tag == "Identifier" && $a_param == "Entry")
00212 {
00213 $a_value = "il_".IL_INST_ID."_st_".$this->getId();
00214
00215 }
00216
00217 return $a_value;
00218 }
00219
00224 function _getPresentationTitle($a_st_id, $a_include_numbers = false)
00225 {
00226 global $ilDB;
00227
00228
00229 $query = "SELECT * FROM lm_data WHERE obj_id = '".$a_st_id."'";
00230 $st_set = $ilDB->query($query);
00231 $st_rec = $st_set->fetchRow(DB_FETCHMODE_ASSOC);
00232
00233 $tree = new ilTree($st_rec["lm_id"]);
00234 $tree->setTableNames('lm_tree','lm_data');
00235 $tree->setTreeTablePK("lm_id");
00236
00237 if ($a_include_numbers)
00238 {
00239 if ($tree->isInTree($st_rec["obj_id"]))
00240 {
00241
00242 $query = "SELECT * FROM lm_tree WHERE child = ".
00243 $ilDB->quote($a_st_id)." AND lm_id = ".
00244 $ilDB->quote($st_rec["lm_id"]);
00245 $tree_set = $ilDB->query($query);
00246 $tree_node = $tree_set->fetchRow(DB_FETCHMODE_ASSOC);
00247 $depth = $tree_node["depth"];
00248
00249 $nr = $tree->getChildSequenceNumber($tree_node, "st")." ";
00250 for ($i = $depth - 1; $i > 1; $i --)
00251 {
00252
00253 $query = "SELECT * FROM lm_tree WHERE child = ".
00254 $ilDB->quote($tree_node["parent"])." AND lm_id = ".
00255 $ilDB->quote($st_rec["lm_id"]);
00256 $tree_set = $ilDB->query($query);
00257 $tree_node = $tree_set->fetchRow(DB_FETCHMODE_ASSOC);
00258 $seq = $tree->getChildSequenceNumber($tree_node, "st");
00259
00260 $nr = $seq.".".$nr;
00261 }
00262 }
00263 }
00264
00265 return $nr.$st_rec["title"];
00266 }
00267
00268
00269
00276 function exportXMLPageObjects(&$a_xml_writer, $a_inst = 0)
00277 {
00278 include_once './content/classes/class.ilLMPageObject.php';
00279
00280 global $ilBench;
00281
00282 $this->tree = new ilTree($this->getLmId());
00283 $this->tree->setTableNames('lm_tree', 'lm_data');
00284 $this->tree->setTreeTablePK("lm_id");
00285
00286 $childs = $this->tree->getChilds($this->getId());
00287 foreach ($childs as $child)
00288 {
00289 if($child["type"] != "pg")
00290 {
00291 continue;
00292 }
00293
00294
00295 $ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
00296
00297
00298
00299 ilLMPageObject::_exportXMLAlias($a_xml_writer, $child["obj_id"], $a_inst);
00300
00301
00302 $ilBench->stop("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
00303 }
00304 }
00305
00306
00313 function exportXMLStructureObjects(&$a_xml_writer, $a_inst, &$expLog)
00314 {
00315 $this->tree = new ilTree($this->getLmId());
00316 $this->tree->setTableNames('lm_tree', 'lm_data');
00317 $this->tree->setTreeTablePK("lm_id");
00318
00319 $childs = $this->tree->getChilds($this->getId());
00320 foreach ($childs as $child)
00321 {
00322 if($child["type"] != "st")
00323 {
00324 continue;
00325 }
00326
00327
00328 $structure_obj = new ilStructureObject($this->getContentObject(),
00329 $child["obj_id"]);
00330 $structure_obj->exportXML($a_xml_writer, $a_inst, $expLog);
00331 unset($structure_obj);
00332 }
00333 }
00334
00341 function exportFO(&$a_xml_writer)
00342 {
00343 global $ilBench;
00344
00345
00346
00347
00348 $attrs = array();
00349 $attrs["font-family"] = "Times";
00350 $attrs["font-size"] = "14pt";
00351 $a_xml_writer->xmlElement("fo:block", $attrs, $this->getTitle());
00352
00353
00354
00355 $this->exportFOPageObjects($a_xml_writer);
00356
00357
00358
00359
00360
00361 }
00362
00369 function exportFOPageObjects(&$a_xml_writer)
00370 {
00371 global $ilBench;
00372
00373 $this->tree = new ilTree($this->getLmId());
00374 $this->tree->setTableNames('lm_tree', 'lm_data');
00375 $this->tree->setTreeTablePK("lm_id");
00376
00377 $childs = $this->tree->getChilds($this->getId());
00378 foreach ($childs as $child)
00379 {
00380 if($child["type"] != "pg")
00381 {
00382 continue;
00383 }
00384
00385
00386
00387
00388 $page_obj = new ilLMPageObject($this->getContentObject(), $child["obj_id"]);
00389 $page_obj->exportFO($a_xml_writer);
00390
00391
00392 }
00393 }
00394
00395 }
00396 ?>