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"]);
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 if ($rbacsystem->checkAccess("read", $ref_id))
00147 {
00148 ilUtil::redirect("content/lm_presentation.php?ref_id=$ref_id".
00149 "&obj_id=$a_target");
00150 }
00151 }
00152
00153 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
00154 }
00155
00156
00163 function exportXML(&$a_xml_writer, $a_inst, &$expLog)
00164 {
00165 global $ilBench;
00166
00167 $expLog->write(date("[y-m-d H:i:s] ")."Structure Object ".$this->getId());
00168 $attrs = array();
00169 $a_xml_writer->xmlStartTag("StructureObject", $attrs);
00170
00171
00172 $ilBench->start("ContentObjectExport", "exportStructureObject_exportMeta");
00173 $this->exportXMLMetaData($a_xml_writer);
00174 $ilBench->stop("ContentObjectExport", "exportStructureObject_exportMeta");
00175
00176
00177 $ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjects");
00178 $this->exportXMLPageObjects($a_xml_writer, $a_inst);
00179 $ilBench->stop("ContentObjectExport", "exportStructureObject_exportPageObjects");
00180
00181
00182 $this->exportXMLStructureObjects($a_xml_writer, $a_inst, $expLog);
00183
00184
00185
00186
00187 $a_xml_writer->xmlEndTag("StructureObject");
00188 }
00189
00190
00197 function exportXMLMetaData(&$a_xml_writer)
00198 {
00199 $nested = new ilNestedSetXML();
00200 $nested->setParameterModifier($this, "modifyExportIdentifier");
00201 $a_xml_writer->appendXML($nested->export($this->getId(),
00202 $this->getType()));
00203 }
00204
00205 function modifyExportIdentifier($a_tag, $a_param, $a_value)
00206 {
00207 if ($a_tag == "Identifier" && $a_param == "Entry")
00208 {
00209 $a_value = "il_".IL_INST_ID."_st_".$this->getId();
00210
00211 }
00212
00213 return $a_value;
00214 }
00215
00220 function _getPresentationTitle($a_st_id, $a_include_numbers = false)
00221 {
00222 global $ilDB;
00223
00224
00225 $query = "SELECT * FROM lm_data WHERE obj_id = '".$a_st_id."'";
00226 $st_set = $ilDB->query($query);
00227 $st_rec = $st_set->fetchRow(DB_FETCHMODE_ASSOC);
00228
00229 $tree = new ilTree($st_rec["lm_id"]);
00230 $tree->setTableNames('lm_tree','lm_data');
00231 $tree->setTreeTablePK("lm_id");
00232
00233 if ($a_include_numbers)
00234 {
00235 if ($tree->isInTree($st_rec["obj_id"]))
00236 {
00237
00238 $query = "SELECT * FROM lm_tree WHERE child = ".
00239 $ilDB->quote($a_st_id)." AND lm_id = ".
00240 $ilDB->quote($st_rec["lm_id"]);
00241 $tree_set = $ilDB->query($query);
00242 $tree_node = $tree_set->fetchRow(DB_FETCHMODE_ASSOC);
00243 $depth = $tree_node["depth"];
00244
00245 $nr = $tree->getChildSequenceNumber($tree_node, "st")." ";
00246 for ($i = $depth - 1; $i > 1; $i --)
00247 {
00248
00249 $query = "SELECT * FROM lm_tree WHERE child = ".
00250 $ilDB->quote($tree_node["parent"])." AND lm_id = ".
00251 $ilDB->quote($st_rec["lm_id"]);
00252 $tree_set = $ilDB->query($query);
00253 $tree_node = $tree_set->fetchRow(DB_FETCHMODE_ASSOC);
00254 $seq = $tree->getChildSequenceNumber($tree_node, "st");
00255
00256 $nr = $seq.".".$nr;
00257 }
00258 }
00259 }
00260
00261 return $nr.$st_rec["title"];
00262 }
00263
00264
00265
00272 function exportXMLPageObjects(&$a_xml_writer, $a_inst = 0)
00273 {
00274 include_once './content/classes/class.ilLMPageObject.php';
00275
00276 global $ilBench;
00277
00278 $this->tree = new ilTree($this->getLmId());
00279 $this->tree->setTableNames('lm_tree', 'lm_data');
00280 $this->tree->setTreeTablePK("lm_id");
00281
00282 $childs = $this->tree->getChilds($this->getId());
00283 foreach ($childs as $child)
00284 {
00285 if($child["type"] != "pg")
00286 {
00287 continue;
00288 }
00289
00290
00291 $ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
00292
00293
00294
00295 ilLMPageObject::_exportXMLAlias($a_xml_writer, $child["obj_id"], $a_inst);
00296
00297
00298 $ilBench->stop("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
00299 }
00300 }
00301
00302
00309 function exportXMLStructureObjects(&$a_xml_writer, $a_inst, &$expLog)
00310 {
00311 $this->tree = new ilTree($this->getLmId());
00312 $this->tree->setTableNames('lm_tree', 'lm_data');
00313 $this->tree->setTreeTablePK("lm_id");
00314
00315 $childs = $this->tree->getChilds($this->getId());
00316 foreach ($childs as $child)
00317 {
00318 if($child["type"] != "st")
00319 {
00320 continue;
00321 }
00322
00323
00324 $structure_obj = new ilStructureObject($this->getContentObject(),
00325 $child["obj_id"]);
00326 $structure_obj->exportXML($a_xml_writer, $a_inst, $expLog);
00327 unset($structure_obj);
00328 }
00329 }
00330
00337 function exportFO(&$a_xml_writer)
00338 {
00339 global $ilBench;
00340
00341
00342
00343
00344 $attrs = array();
00345 $attrs["font-family"] = "Times";
00346 $attrs["font-size"] = "14pt";
00347 $a_xml_writer->xmlElement("fo:block", $attrs, $this->getTitle());
00348
00349
00350
00351 $this->exportFOPageObjects($a_xml_writer);
00352
00353
00354
00355
00356
00357 }
00358
00365 function exportFOPageObjects(&$a_xml_writer)
00366 {
00367 global $ilBench;
00368
00369 $this->tree = new ilTree($this->getLmId());
00370 $this->tree->setTableNames('lm_tree', 'lm_data');
00371 $this->tree->setTreeTablePK("lm_id");
00372
00373 $childs = $this->tree->getChilds($this->getId());
00374 foreach ($childs as $child)
00375 {
00376 if($child["type"] != "pg")
00377 {
00378 continue;
00379 }
00380
00381
00382
00383
00384 $page_obj = new ilLMPageObject($this->getContentObject(), $child["obj_id"]);
00385 $page_obj->exportFO($a_xml_writer);
00386
00387
00388 }
00389 }
00390
00391 }
00392 ?>