24 require_once(
"./Modules/LearningModule/classes/class.ilObjContentObject.php");
59 include_once(
"./Modules/LearningModule/classes/class.ilBibItem.php");
62 $this->bib_obj->read();
84 WHERE lm_tree.lm_id = ".$ilDB->quote($obj_id).
"
85 AND lm_tree.child = lm_data.obj_id
86 AND ( lm_data.type = 'st' OR lm_data.type = 'pg' )
87 AND lm_tree.depth = ".$ilDB->quote($depth).
"
88 AND lm_tree.lft > ".$ilDB->quote($left).
" and lm_tree.rgt < ".$ilDB->quote($right).
"
89 ORDER BY lm_tree.lft";
90 $result = $this->ilias->db->query($query);
93 if ($row[
"type"] ==
"st")
95 $xml .=
"<StructureObject>";
98 $xml .= $nested->export($row[
"obj_id"],
"st");
101 $xml .= $this->
exportRekursiv($obj_id, $depth+1, $row[
"lft"], $row[
"rgt"]);
103 $xml .=
"</StructureObject>";
106 if ($row[
"type"] ==
"pg")
109 $query =
"SELECT * FROM page_object WHERE page_id= ".$ilDB->quote($row[
"obj_id"]);
110 $result2 = $this->ilias->db->query($query);
114 $PO = $row2[
"content"].
"\n";
116 if (stristr($PO,
"MediaObject"))
121 $path =
"//MediaObject/MediaAlias";
123 for($i = 0; $i < count(
$res->nodeset); $i++)
125 $id_arr = explode(
"_",
$res->nodeset[$i]->get_attribute(
"OriginId"));
126 $mob_id = $id_arr[count($id_arr) - 1];
127 $this->mob_ids[$mob_id] =
true;
132 $mdxml = $nested->export($row[
"obj_id"],
"pg");
134 $PO = str_replace(
"<PageObject>",
"<PageObject>\n$mdxml\n",$PO);
152 include_once(
"./classes/class.ilNestedSetXML.php");
156 $query =
"SELECT * FROM object_reference,object_data WHERE object_reference.ref_id= ".
157 $ilDB->quote($this->
getRefId()).
" AND object_reference.obj_id=object_data.obj_id ";
158 $result = $this->ilias->db->query($query);
162 $obj_id = $objRow[
"obj_id"];
164 $this->mob_ids = array();
169 $xml =
"<?xml version=\"1.0\"?>\n<!DOCTYPE ContentObject SYSTEM \"ilias_co.dtd\">\n<ContentObject Type=\"LibObject\">\n";
175 $xml .= $nested->export($obj_id,
"dbk").
"\n";
182 FROM lm_tree, lm_data
183 WHERE lm_tree.lm_id = ".$ilDB->quote($obj_id).
"
184 AND lm_tree.child = lm_data.obj_id
185 AND ( lm_data.type = 'du' )
186 AND lm_tree.depth = 1
187 ORDER BY lm_tree.lft";
188 $result = $this->ilias->db->query($query);
191 $xml .= $this->
exportRekursiv($obj_id,2, $treeData[
"lft"], $treeData[
"rgt"]);
202 $mob_ids = $this->mob_ids;
203 if (is_array($mob_ids) && count($mob_ids)>0)
206 while (list ($key, $val) = each ($mob_ids))
209 $xml .=
"<MediaObject>";
211 $query =
"SELECT * FROM media_item WHERE mob_id= ".$ilDB->quote($key).
" ";
214 $result = $this->ilias->db->query($query);
221 $metaxml = $nested->export($key,
"mob");
222 $metaxml = preg_replace(
"/Entry=\"(.*?)\"/",
"Entry=\"il__mob_".$key.
"\"",$metaxml);
224 $metaxml2 =
"<Technical>";
225 $metaxml2 .=
"<Format>".$row[
"format"].
"</Format>";
226 $metaxml2 .=
"<Size>14559</Size>";
227 $metaxml2 .=
"<Location Type=\"".$row[
"location_type"].
"\">".$row[
"location"].
"</Location>";
228 $metaxml2 .=
"</Technical>";
230 $metaxml = str_replace(
"</MetaData>",$metaxml2.
"</MetaData>",$metaxml);
237 $xml .=
"<MediaItem Purpose=\"".$row[
"purpose"].
"\">";
238 $xml .=
"<Location Type=\"".$row[
"location_type"].
"\">".$row[
"location"].
"</Location>";
239 $xml .=
"<Format>".$row[
"format"].
"</Format>";
240 $xml .=
"<Layout Width=\"".$row[
"width"].
"\" Height=\"".$row[
"height"].
"\"/>";
241 $xml .=
"</MediaItem>";
244 $xml .=
"</MediaObject>";
253 $bib = $nested->export($obj_id,
"bib");
260 $xml .=
"</ContentObject>";
265 $fileName = $objRow[
"title"];
266 $fileName = str_replace(
" ",
"_",$fileName);
268 if (!file_exists($export_dir.
"/".$fileName))
270 @mkdir($export_dir.
"/".$fileName);
271 @chmod($export_dir.
"/".$fileName,0755);
274 if (!file_exists($export_dir.
"/".$fileName.
"/objects"))
276 @mkdir($export_dir.
"/".$fileName.
"/objects");
277 @chmod($export_dir.
"/".$fileName.
"/objects",0755);
283 $mob_ids = $this->mob_ids;
284 if (is_array($mob_ids) && count($mob_ids)>0)
287 while (list ($key, $val) = each ($mob_ids))
290 if (!file_exists($export_dir.
"/".$fileName.
"/objects/mm".$key))
292 @mkdir($export_dir.
"/".$fileName.
"/objects/mm".$key);
293 @chmod($export_dir.
"/".$fileName.
"/objects/mm".$key,0755);
296 $mobdir =
"./data/mobs/mm_".$key;
297 ilUtil::rCopy($mobdir, $export_dir.
"/".$fileName.
"/objects/mm".$key);
304 $fp = fopen($export_dir.
"/".$fileName.
"/".$fileName.
".xml",
"wb");
311 ilUtil::zip($export_dir.
"/".$fileName, $export_dir.
"/".$fileName.
".zip");
323 return $export_dir.
"/".$fileName.
".zip";
352 $query =
"REPLACE INTO dbk_translations ".
353 "SET id = ".$ilDB->quote($this->ref_id).
", ".
354 "tr_id = ".$ilDB->quote($a_ref_id).
" ";
355 $res = $this->ilias->db->query($query);
357 $query =
"REPLACE INTO dbk_translations ".
358 "SET id = ".$ilDB->quote($a_ref_id).
", ".
359 "tr_id = ".$ilDB->quote($this->ref_id).
" ";
360 $res = $this->ilias->db->query($query);
370 if(!is_array($a_arr_ref_id))
374 foreach($a_arr_ref_id as
$ref_id)
389 $query =
"DELETE FROM dbk_translations ".
390 "WHERE id = ".$ilDB->quote($this->ref_id).
" ".
391 "AND tr_id = ".$ilDB->quote($a_ref_id).
" ";
393 $res = $this->ilias->db->query($query);
395 $query =
"DELETE FROM dbk_translations ".
396 "WHERE id = ".$ilDB->quote($a_ref_id).
" ".
397 "AND tr_id = ".$ilDB->quote($this->ref_id).
" ";
399 $res = $this->ilias->db->query($query);
409 if(!is_array($a_arr_ref_id))
413 foreach($a_arr_ref_id as
$ref_id)
421 return $this->tr_ids;
438 $in = $search_obj->getInStatement(
"r.ref_id");
439 $where = $search_obj->getWhereCondition(
"fulltext",array(
"xv.tag_value"));
451 $query1 =
"SELECT DISTINCT(r.ref_id) FROM object_reference AS r,object_data AS o, ".
452 "xmlnestedset AS xm,xmlvalue AS xv ".
455 "AND r.obj_id=o.obj_id AND ( ".
456 "(o.obj_id=xm.ns_book_fk AND xm.ns_type IN ('dbk','bib'))) ".
457 "AND xm.ns_tag_fk=xv.tag_fk ".
461 $query1 =
"SELECT DISTINCT(r.ref_id) as ref_id FROM xmlvalue AS xv ".
462 "LEFT JOIN xmlnestedset AS xm ON xm.ns_tag_fk=xv.tag_fk ".
463 "LEFT JOIN object_data AS o ON o.obj_id = xm.ns_book_fk ".
464 "LEFT JOIN object_reference AS r ON o.obj_id = r.obj_id ".
467 " AND o.type = 'dbk' AND xm.ns_type IN ('dbk','bib')";
469 $query2 =
"SELECT DISTINCT(r.ref_id) FROM object_reference AS r,object_data AS o, ".
470 "lm_data AS l,xmlnestedset AS xm,xmlvalue AS xv ".
473 "AND r.obj_id=o.obj_id AND ((o.obj_id=l.lm_id AND xm.ns_book_fk=l.obj_id) ".
475 "AND xm.ns_tag_fk=xv.tag_fk ".
478 $query2 =
"SELECT DISTINCT(r.ref_id) as ref_id FROM xmlvalue AS xv ".
479 " LEFT JOIN xmlnestedset AS xm ON xm.ns_tag_fk = xv.tag_fk ".
480 " LEFT JOIN lm_data AS l ON l.obj_id = xm.ns_book_fk ".
481 " LEFT JOIN object_data AS o ON o.obj_id = l.lm_id ".
482 " LEFT JOIN object_reference AS r ON r.obj_id = o.obj_id ".
485 "AND o.type = 'dbk'";
499 $ilBench->start(
"Search",
"ilObjDlBook_search_meta");
500 $res1 = $search_obj->ilias->db->query($query1);
501 $res2 = $search_obj->ilias->db->query($query2);
502 $ilBench->stop(
"Search",
"ilObjDlBook_search_meta");
508 $ids[] = $row->ref_id;
509 $result[$counter][
"id"] = $row->ref_id;
515 if(in_array($row->ref_id,$ids))
519 $result[$counter][
"id"] = $row->ref_id;
526 $in = $search_obj->getInStatement(
"ref_id");
527 $where = $search_obj->getWhereCondition(
"fulltext",array(
"pg.content"));
529 $query =
"SELECT DISTINCT(r.ref_id) AS ref_id ,pg.page_id AS page_id FROM page_object AS pg ".
530 "INNER JOIN object_reference AS r ON pg.parent_id = r.obj_id ".
533 "AND pg.parent_type = 'dbk' ";
535 $ilBench->start(
"Search",
"ilObjDlBook_search_content");
536 $res = $search_obj->ilias->db->query($query);
537 $ilBench->stop(
"Search",
"ilObjDlBook_search_content");
542 $result[$counter][
"id"] = $row->ref_id;
543 $result[$counter][
"page_id"] = $row->page_id;
554 return $this->
export(
false);
563 $query =
"SELECT tr_id FROM dbk_translations ".
564 "WHERE id = ".$ilDB->quote($this->ref_id).
" ";
566 $res = $this->ilias->db->query($query);
569 $tmp_tr_ids[] = $row->tr_id;
571 return $this->tr_ids = $tmp_tr_ids ? $tmp_tr_ids : array();