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 ©(&$a_target_tree, $a_parent, $a_pos = IL_LAST_NODE)
00099 {
00100 $lm =& $this->getContentObject();
00101 $source_tree = new ilTree($lm->getId());
00102 $source_tree->setTableNames('lm_tree','lm_data');
00103 $source_tree->setTreeTablePK("lm_id");
00104
00105
00106 $target_lm_id = $a_target_tree->getTreeId();
00107 $target_lm = ilObjectFactory::getInstanceByObjId($target_lm_id);
00108 $chap =& new ilStructureObject($target_lm);
00109 $chap->setTitle($this->getTitle());
00110 $chap->setLMId($target_lm_id);
00111 $chap->setType($this->getType());
00112 $chap->setDescription($this->getDescription());
00113 $chap->create(true);
00114
00115
00116 include_once("Services/MetaData/classes/class.ilMD.php");
00117 $md = new ilMD($this->getLMId(), $this->getId(), $this->getType());
00118 $new_md =& $md->cloneMD($target_lm_id, $chap->getId(), $this->getType());
00119
00120
00121 $a_target_tree->insertNode($chap->getId(), $a_parent, $a_pos);
00122
00123 $childs =& $source_tree->getChilds($this->getId());
00124 foreach($childs as $child)
00125 {
00126 $lmobj = ilLMObjectFactory::getInstance($this->getContentObject(), $child["obj_id"], true);
00127 if ($child["type"] == "st")
00128 {
00129 $newobj =& $lmobj->copy($a_target_tree, $chap->getId());
00130 }
00131 else
00132 {
00133 $newobj =& $lmobj->copyToOtherContObject($target_lm);
00134 $a_target_tree->insertNode($newobj->getId(), $chap->getId());
00135 }
00136 }
00137
00138 return $chap;
00139 }
00140
00147 function exportXML(&$a_xml_writer, $a_inst, &$expLog)
00148 {
00149 global $ilBench;
00150
00151 $expLog->write(date("[y-m-d H:i:s] ")."Structure Object ".$this->getId());
00152 $attrs = array();
00153 $a_xml_writer->xmlStartTag("StructureObject", $attrs);
00154
00155
00156 $ilBench->start("ContentObjectExport", "exportStructureObject_exportMeta");
00157 $this->exportXMLMetaData($a_xml_writer);
00158 $ilBench->stop("ContentObjectExport", "exportStructureObject_exportMeta");
00159
00160
00161 $ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjects");
00162 $this->exportXMLPageObjects($a_xml_writer, $a_inst);
00163 $ilBench->stop("ContentObjectExport", "exportStructureObject_exportPageObjects");
00164
00165
00166 $this->exportXMLStructureObjects($a_xml_writer, $a_inst, $expLog);
00167
00168
00169
00170
00171 $a_xml_writer->xmlEndTag("StructureObject");
00172 }
00173
00174
00181 function exportXMLMetaData(&$a_xml_writer)
00182 {
00183 include_once("Services/MetaData/classes/class.ilMD2XML.php");
00184 $md2xml = new ilMD2XML($this->getLMId(), $this->getId(), $this->getType());
00185 $md2xml->setExportMode(true);
00186 $md2xml->startExport();
00187 $a_xml_writer->appendXML($md2xml->getXML());
00188 }
00189
00190 function modifyExportIdentifier($a_tag, $a_param, $a_value)
00191 {
00192 if ($a_tag == "Identifier" && $a_param == "Entry")
00193 {
00194 $a_value = "il_".IL_INST_ID."_st_".$this->getId();
00195
00196 }
00197
00198 return $a_value;
00199 }
00200
00205 function _getPresentationTitle($a_st_id, $a_include_numbers = false)
00206 {
00207 global $ilDB;
00208
00209
00210 $query = "SELECT * FROM lm_data WHERE obj_id = '".$a_st_id."'";
00211 $st_set = $ilDB->query($query);
00212 $st_rec = $st_set->fetchRow(DB_FETCHMODE_ASSOC);
00213
00214 $tree = new ilTree($st_rec["lm_id"]);
00215 $tree->setTableNames('lm_tree','lm_data');
00216 $tree->setTreeTablePK("lm_id");
00217
00218 if ($a_include_numbers)
00219 {
00220 if ($tree->isInTree($st_rec["obj_id"]))
00221 {
00222
00223 $query = "SELECT * FROM lm_tree WHERE child = ".
00224 $ilDB->quote($a_st_id)." AND lm_id = ".
00225 $ilDB->quote($st_rec["lm_id"]);
00226 $tree_set = $ilDB->query($query);
00227 $tree_node = $tree_set->fetchRow(DB_FETCHMODE_ASSOC);
00228 $depth = $tree_node["depth"];
00229
00230 $nr = $tree->getChildSequenceNumber($tree_node, "st")." ";
00231 for ($i = $depth - 1; $i > 1; $i --)
00232 {
00233
00234 $query = "SELECT * FROM lm_tree WHERE child = ".
00235 $ilDB->quote($tree_node["parent"])." AND lm_id = ".
00236 $ilDB->quote($st_rec["lm_id"]);
00237 $tree_set = $ilDB->query($query);
00238 $tree_node = $tree_set->fetchRow(DB_FETCHMODE_ASSOC);
00239 $seq = $tree->getChildSequenceNumber($tree_node, "st");
00240
00241 $nr = $seq.".".$nr;
00242 }
00243 }
00244 }
00245
00246 return $nr.$st_rec["title"];
00247 }
00248
00249
00250
00257 function exportXMLPageObjects(&$a_xml_writer, $a_inst = 0)
00258 {
00259 include_once './content/classes/class.ilLMPageObject.php';
00260
00261 global $ilBench;
00262
00263 $this->tree = new ilTree($this->getLmId());
00264 $this->tree->setTableNames('lm_tree', 'lm_data');
00265 $this->tree->setTreeTablePK("lm_id");
00266
00267 $childs = $this->tree->getChilds($this->getId());
00268 foreach ($childs as $child)
00269 {
00270 if($child["type"] != "pg")
00271 {
00272 continue;
00273 }
00274
00275
00276 $ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
00277
00278
00279
00280 ilLMPageObject::_exportXMLAlias($a_xml_writer, $child["obj_id"], $a_inst);
00281
00282
00283 $ilBench->stop("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
00284 }
00285 }
00286
00287
00294 function exportXMLStructureObjects(&$a_xml_writer, $a_inst, &$expLog)
00295 {
00296 $this->tree = new ilTree($this->getLmId());
00297 $this->tree->setTableNames('lm_tree', 'lm_data');
00298 $this->tree->setTreeTablePK("lm_id");
00299
00300 $childs = $this->tree->getChilds($this->getId());
00301 foreach ($childs as $child)
00302 {
00303 if($child["type"] != "st")
00304 {
00305 continue;
00306 }
00307
00308
00309 $structure_obj = new ilStructureObject($this->getContentObject(),
00310 $child["obj_id"]);
00311 $structure_obj->exportXML($a_xml_writer, $a_inst, $expLog);
00312 unset($structure_obj);
00313 }
00314 }
00315
00322 function exportFO(&$a_xml_writer)
00323 {
00324 global $ilBench;
00325
00326
00327
00328
00329 $attrs = array();
00330 $attrs["font-family"] = "Times";
00331 $attrs["font-size"] = "14pt";
00332 $a_xml_writer->xmlElement("fo:block", $attrs, $this->getTitle());
00333
00334
00335
00336 $this->exportFOPageObjects($a_xml_writer);
00337
00338
00339
00340
00341
00342 }
00343
00350 function exportFOPageObjects(&$a_xml_writer)
00351 {
00352 global $ilBench;
00353
00354 $this->tree = new ilTree($this->getLmId());
00355 $this->tree->setTableNames('lm_tree', 'lm_data');
00356 $this->tree->setTreeTablePK("lm_id");
00357
00358 $childs = $this->tree->getChilds($this->getId());
00359 foreach ($childs as $child)
00360 {
00361 if($child["type"] != "pg")
00362 {
00363 continue;
00364 }
00365
00366
00367
00368
00369 $page_obj = new ilLMPageObject($this->getContentObject(), $child["obj_id"]);
00370 $page_obj->exportFO($a_xml_writer);
00371
00372
00373 }
00374 }
00375
00376 }
00377 ?>