• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

content/classes/class.ilStructureObject.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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 &copy(&$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                 // insert chapter in tree
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                         // insert page in tree
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                 // determine learning object
00138                 $lm_id = ilLMObject::_lookupContObjID($a_target);
00139 
00140                 // get all references
00141                 $ref_ids = ilObject::_getAllReferences($lm_id);
00142 
00143                 // check read permissions
00144                 foreach ($ref_ids as $ref_id)
00145                 {
00146                         include_once 'classes/class.ilSearch.php';
00147                         
00148                         // Added this additional check (ParentConditions) to avoid calls of objects inside e.g courses.
00149                         // Will be replaced in future releases by ilAccess::checkAccess()
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                 // MetaData
00176                 $ilBench->start("ContentObjectExport", "exportStructureObject_exportMeta");
00177                 $this->exportXMLMetaData($a_xml_writer);
00178                 $ilBench->stop("ContentObjectExport", "exportStructureObject_exportMeta");
00179 
00180                 // StructureObjects
00181                 $ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjects");
00182                 $this->exportXMLPageObjects($a_xml_writer, $a_inst);
00183                 $ilBench->stop("ContentObjectExport", "exportStructureObject_exportPageObjects");
00184 
00185                 // PageObjects
00186                 $this->exportXMLStructureObjects($a_xml_writer, $a_inst, $expLog);
00187 
00188                 // Layout
00189                 // not implemented
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                         //$a_value = ilUtil::insertInstIntoID($a_value);
00215                 }
00216 
00217                 return $a_value;
00218         }
00219 
00224         function _getPresentationTitle($a_st_id, $a_include_numbers = false)
00225         {
00226                 global $ilDB;
00227 
00228                 // get chapter data
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                                 // get chapter tree node
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                                         // get next parent tree node
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                         // export xml to writer object
00295                         $ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
00296                         //$ilBench->start("ContentObjectExport", "exportStructureObject_getLMPageObject");
00297                         //$page_obj = new ilLMPageObject($this->getContentObject(), $child["obj_id"]);
00298                         //$ilBench->stop("ContentObjectExport", "exportStructureObject_getLMPageObject");
00299                         ilLMPageObject::_exportXMLAlias($a_xml_writer, $child["obj_id"], $a_inst);
00300                         //$page_obj->exportXML($a_xml_writer, "alias", $a_inst);
00301                         //unset($page_obj);
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                         // export xml to writer object
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                 //$expLog->write(date("[y-m-d H:i:s] ")."Structure Object ".$this->getId());
00346 
00347                 // fo:block (complete)
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                 // page objects
00354                 //$ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjects");
00355                 $this->exportFOPageObjects($a_xml_writer);
00356                 //$ilBench->stop("ContentObjectExport", "exportStructureObject_exportPageObjects");
00357 
00358                 // structure objects
00359                 //$this->exportFOStructureObjects($a_xml_writer);
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                         // export xml to writer object
00386                         //$ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
00387 
00388                         $page_obj = new ilLMPageObject($this->getContentObject(), $child["obj_id"]);
00389                         $page_obj->exportFO($a_xml_writer);
00390 
00391                         //$ilBench->stop("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
00392                 }
00393         }
00394 
00395 }
00396 ?>

Generated on Fri Dec 13 2013 09:06:36 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1