Inheritance diagram for ilObjDlBook:
Collaboration diagram for ilObjDlBook:Public Member Functions | |
| ilObjDlBook ($a_id=0, $a_call_by_reference=true) | |
| Constructor public. | |
| initBibItemObject () | |
| init bib object (contains all bib item data) | |
| exportRekursiv ($obj_id, $depth, $left, $right) | |
| export lm_data-table to xml-structure | |
| export ($a_deliver=true) | |
| exports the digi-lib-object into a xml structure | |
| addTranslation ($a_ref_id) | |
| addTranslations ($a_arr_ref_id) | |
| deleteTranslation ($a_ref_id) | |
| deleteTranslations ($a_arr_ref_id) | |
| getTranslations () | |
| getXMLZip () | |
| readAssignedTranslations () | |
Static Public Member Functions | |
| _search (&$search_obj, $a_search_in) | |
| STATIC METHOD search for dbk data. | |
Data Fields | |
| $bib_obj | |
Definition at line 34 of file class.ilObjDlBook.php.
| ilObjDlBook::_search | ( | &$ | search_obj, | |
| $ | a_search_in | |||
| ) | [static] |
STATIC METHOD search for dbk data.
This method is called from class.ilSearch
| object | reference on object of search class public |
Reimplemented from ilObjContentObject.
Definition at line 422 of file class.ilObjDlBook.php.
References $counter, $ilBench, $query, $query1, $query2, $res, $result, and $row.
Referenced by ilSearch::performSearch().
{
global $ilBench;
switch($a_search_in)
{
case 'meta':
// FILTER ALL DBK OBJECTS
$in = $search_obj->getInStatement("r.ref_id");
$where = $search_obj->getWhereCondition("fulltext",array("xv.tag_value"));
/* very slow on mysql < 4.0.18
$query = "SELECT DISTINCT(r.ref_id) FROM object_reference AS r,object_data AS o, ".
"lm_data AS l,xmlnestedset AS xm,xmlvalue AS xv ".
$where.
$in.
"AND r.obj_id=o.obj_id AND ((o.obj_id=l.lm_id AND xm.ns_book_fk=l.obj_id) OR ".
"(o.obj_id=xm.ns_book_fk AND xm.ns_type IN ('dbk','bib'))) ".
"AND xm.ns_tag_fk=xv.tag_fk ".
"AND o.type= 'dbk'"; */
$query1 = "SELECT DISTINCT(r.ref_id) FROM object_reference AS r,object_data AS o, ".
"xmlnestedset AS xm,xmlvalue AS xv ".
$where.
$in.
"AND r.obj_id=o.obj_id AND ( ".
"(o.obj_id=xm.ns_book_fk AND xm.ns_type IN ('dbk','bib'))) ".
"AND xm.ns_tag_fk=xv.tag_fk ".
"AND o.type= 'dbk'";
// BEGINNING SELECT WITH SEARCH RESULTS IS MUCH FASTER
$query1 = "SELECT DISTINCT(r.ref_id) as ref_id FROM xmlvalue AS xv ".
"LEFT JOIN xmlnestedset AS xm ON xm.ns_tag_fk=xv.tag_fk ".
"LEFT JOIN object_data AS o ON o.obj_id = xm.ns_book_fk ".
"LEFT JOIN object_reference AS r ON o.obj_id = r.obj_id ".
$where.
$in.
" AND o.type = 'dbk' AND xm.ns_type IN ('dbk','bib')";
$query2 = "SELECT DISTINCT(r.ref_id) FROM object_reference AS r,object_data AS o, ".
"lm_data AS l,xmlnestedset AS xm,xmlvalue AS xv ".
$where.
$in.
"AND r.obj_id=o.obj_id AND ((o.obj_id=l.lm_id AND xm.ns_book_fk=l.obj_id) ".
") ".
"AND xm.ns_tag_fk=xv.tag_fk ".
"AND o.type= 'dbk'";
$query2 = "SELECT DISTINCT(r.ref_id) as ref_id FROM xmlvalue AS xv ".
" LEFT JOIN xmlnestedset AS xm ON xm.ns_tag_fk = xv.tag_fk ".
" LEFT JOIN lm_data AS l ON l.obj_id = xm.ns_book_fk ".
" LEFT JOIN object_data AS o ON o.obj_id = l.lm_id ".
" LEFT JOIN object_reference AS r ON r.obj_id = o.obj_id ".
$where.
$in.
"AND o.type = 'dbk'";
/*
$query = "SELECT DISTINCT(r.ref_id) AS ref_id FROM object_reference AS r ".
"INNER JOIN object_data AS o ON r.obj_id=o.obj_id ".
"INNER JOIN lm_data AS l ON l.lm_id = o.obj_id ".
"INNER JOIN xmlnestedset AS xm ON (xm.ns_book_fk = l.obj_id OR xm.ns_type IN ('dbk','bib')) ".
"INNER JOIN xmlvalue AS xv ON xm.ns_tag_fk = xv.tag_fk ".
$where.
$in.
"AND o.type = 'dbk'";
*/
$ilBench->start("Search", "ilObjDlBook_search_meta");
$res1 = $search_obj->ilias->db->query($query1);
$res2 = $search_obj->ilias->db->query($query2);
$ilBench->stop("Search", "ilObjDlBook_search_meta");
$counter = 0;
$ids = array();
while($row = $res1->fetchRow(DB_FETCHMODE_OBJECT))
{
$ids[] = $row->ref_id;
$result[$counter]["id"] = $row->ref_id;
++$counter;
}
while($row = $res2->fetchRow(DB_FETCHMODE_OBJECT))
{
if(in_array($row->ref_id,$ids))
{
continue;
}
$result[$counter]["id"] = $row->ref_id;
++$counter;
}
break;
case 'content':
$in = $search_obj->getInStatement("ref_id");
$where = $search_obj->getWhereCondition("fulltext",array("pg.content"));
$query = "SELECT DISTINCT(r.ref_id) AS ref_id ,pg.page_id AS page_id FROM page_object AS pg ".
"INNER JOIN object_reference AS r ON pg.parent_id = r.obj_id ".
$where.
$in.
"AND pg.parent_type = 'dbk' ";
$ilBench->start("Search", "ilObjDlBook_search_content");
$res = $search_obj->ilias->db->query($query);
$ilBench->stop("Search", "ilObjDlBook_search_content");
$counter = 0;
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$result[$counter]["id"] = $row->ref_id;
$result[$counter]["page_id"] = $row->page_id;
#$result[$counter]["link"] = "content/lm_presentation.php?ref_id=".$row->ref_id;
#$result[$counter]["target"] = "_top";
++$counter;
}
break;
}
return $result ? $result : array();
}
Here is the caller graph for this function:| ilObjDlBook::addTranslation | ( | $ | a_ref_id | ) |
Definition at line 344 of file class.ilObjDlBook.php.
References $query, $res, and readAssignedTranslations().
Referenced by addTranslations().
{
$query = "REPLACE INTO dbk_translations ".
"SET id = '".$this->ref_id."', ".
"tr_id = '".$a_ref_id."'";
$res = $this->ilias->db->query($query);
$query = "REPLACE INTO dbk_translations ".
"SET id = '".$a_ref_id."', ".
"tr_id = '".$this->ref_id."'";
$res = $this->ilias->db->query($query);
// UPDATE MEMBER VARIABLE
$this->readAssignedTranslations();
return true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjDlBook::addTranslations | ( | $ | a_arr_ref_id | ) |
Definition at line 362 of file class.ilObjDlBook.php.
References ilObject::$ref_id, and addTranslation().
{
if(!is_array($a_arr_ref_id))
{
return false;
}
foreach($a_arr_ref_id as $ref_id)
{
$this->addTranslation($ref_id);
}
return true;
}
Here is the call graph for this function:| ilObjDlBook::deleteTranslation | ( | $ | a_ref_id | ) |
Definition at line 374 of file class.ilObjDlBook.php.
References $query, $res, and readAssignedTranslations().
Referenced by deleteTranslations().
{
if(!$a_ref_id)
{
return false;
}
$query = "DELETE FROM dbk_translations ".
"WHERE id = '".$this->ref_id."' ".
"AND tr_id = '".$a_ref_id."'";
$res = $this->ilias->db->query($query);
$query = "DELETE FROM dbk_translations ".
"WHERE id = '".$a_ref_id."' ".
"AND tr_id = '".$this->ref_id."'";
$res = $this->ilias->db->query($query);
// UPDATE MEMBER VARIABLE
$this->readAssignedTranslations();
return true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjDlBook::deleteTranslations | ( | $ | a_arr_ref_id | ) |
Definition at line 399 of file class.ilObjDlBook.php.
References ilObject::$ref_id, and deleteTranslation().
{
if(!is_array($a_arr_ref_id))
{
return false;
}
foreach($a_arr_ref_id as $ref_id)
{
$this->deleteTranslation($ref_id);
}
return true;
}
Here is the call graph for this function:| ilObjDlBook::export | ( | $ | a_deliver = true |
) |
exports the digi-lib-object into a xml structure
Definition at line 146 of file class.ilObjDlBook.php.
References $nested, $obj_id, $query, $result, $row, $xml, ilObjContentObject::createExportDirectory(), ilUtil::deliverFile(), exportRekursiv(), ilObjContentObject::getExportDirectory(), ilUtil::rCopy(), and ilUtil::zip().
Referenced by getXMLZip().
{
include_once("./classes/class.ilNestedSetXML.php");
// ------------------------------------------------------
// anhand der ref_id die obj_id ermitteln.
// ------------------------------------------------------
$query = "SELECT * FROM object_reference,object_data WHERE object_reference.ref_id='".$this->getRefId()."' AND object_reference.obj_id=object_data.obj_id ";
$result = $this->ilias->db->query($query);
$objRow = $result->fetchRow(DB_FETCHMODE_ASSOC);
$obj_id = $objRow["obj_id"];
$this->mob_ids = array();
// ------------------------------------------------------
// start xml-String
// ------------------------------------------------------
$xml = "<?xml version=\"1.0\"?>\n<!DOCTYPE ContentObject SYSTEM \"ilias_co.dtd\">\n<ContentObject Type=\"LibObject\">\n";
// ------------------------------------------------------
// get global meta-data
// ------------------------------------------------------
$nested = new ilNestedSetXML();
$xml .= $nested->export($obj_id,"dbk")."\n";
// ------------------------------------------------------
// get all book-xml-data recursiv
// ------------------------------------------------------
$query = "SELECT *
FROM lm_tree, lm_data
WHERE lm_tree.lm_id = $obj_id
AND lm_tree.child = lm_data.obj_id
AND ( lm_data.type = 'du' )
AND lm_tree.depth = 1
ORDER BY lm_tree.lft";
$result = $this->ilias->db->query($query);
$treeData = $result->fetchRow(DB_FETCHMODE_ASSOC);
$xml .= $this->exportRekursiv($obj_id,2, $treeData["lft"], $treeData["rgt"]);
// ------------------------------------------------------
// get or create export-directory
// ------------------------------------------------------
$this->createExportDirectory();
$export_dir = $this->getExportDirectory();
// ------------------------------------------------------
// get mediaobject-xml-data
// ------------------------------------------------------
$mob_ids = $this->mob_ids;
if (is_array($mob_ids) && count($mob_ids)>0)
{
reset ($mob_ids);
while (list ($key, $val) = each ($mob_ids))
{
$xml .= "<MediaObject>";
$query = "SELECT * FROM media_item WHERE mob_id='".$key."' ";
//vd($query);
$first = true;
$result = $this->ilias->db->query($query);
while (is_array($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) )
{
if($first)
{
//vd($row[purpose]);
$nested = new ilNestedSetXML();
$metaxml = $nested->export($key,"mob");
$metaxml = preg_replace("/Entry=\"(.*?)\"/","Entry=\"il__mob_".$key."\"",$metaxml);
$metaxml2 = "<Technical>";
$metaxml2 .= "<Format>".$row["format"]."</Format>";
$metaxml2 .= "<Size>14559</Size>";
$metaxml2 .= "<Location Type=\"".$row["location_type"]."\">".$row["location"]."</Location>";
$metaxml2 .= "</Technical>";
$metaxml = str_replace("</MetaData>",$metaxml2."</MetaData>",$metaxml);
$xml .= $metaxml;
$first = false;
}
$xml .= "<MediaItem Purpose=\"".$row["purpose"]."\">";
$xml .= "<Location Type=\"".$row["location_type"]."\">".$row["location"]."</Location>";
$xml .= "<Format>".$row["format"]."</Format>";
$xml .= "<Layout Width=\"".$row["width"]."\" Height=\"".$row["height"]."\"/>";
$xml .= "</MediaItem>";
}
$xml .= "</MediaObject>";
}
}
// ------------------------------------------------------
// get bib-xml-data
// ------------------------------------------------------
$nested = new ilNestedSetXML();
$bib = $nested->export($obj_id,"bib");
$xml .= $bib."\n";
// ------------------------------------------------------
// xml-ending
// ------------------------------------------------------
$xml .= "</ContentObject>";
// ------------------------------------------------------
// filename and directory-creation
// ------------------------------------------------------
$fileName = $objRow["title"];
$fileName = str_replace(" ","_",$fileName);
if (!file_exists($export_dir."/".$fileName))
{
@mkdir($export_dir."/".$fileName);
@chmod($export_dir."/".$fileName,0755);
}
if (!file_exists($export_dir."/".$fileName."/objects"))
{
@mkdir($export_dir."/".$fileName."/objects");
@chmod($export_dir."/".$fileName."/objects",0755);
}
// ------------------------------------------------------
// copy mob-files
// ------------------------------------------------------
$mob_ids = $this->mob_ids;
if (is_array($mob_ids) && count($mob_ids)>0)
{
reset ($mob_ids);
while (list ($key, $val) = each ($mob_ids))
{
if (!file_exists($export_dir."/".$fileName."/objects/mm".$key))
{
@mkdir($export_dir."/".$fileName."/objects/mm".$key);
@chmod($export_dir."/".$fileName."/objects/mm".$key,0755);
}
$mobdir = "./data/mobs/mm_".$key;
ilUtil::rCopy($mobdir, $export_dir."/".$fileName."/objects/mm".$key);
}
}
// ------------------------------------------------------
// save xml-file
// ------------------------------------------------------
$fp = fopen($export_dir."/".$fileName."/".$fileName.".xml","wb");
fwrite($fp,$xml);
fclose($fp);
// ------------------------------------------------------
// zip all files
// ------------------------------------------------------
ilUtil::zip($export_dir."/".$fileName, $export_dir."/".$fileName.".zip");
// ------------------------------------------------------
// deliver files
// ------------------------------------------------------
if($a_deliver)
{
ilUtil::deliverFile($export_dir."/".$fileName.".zip",$fileName);
}
else
{
return $export_dir."/".$fileName.".zip";
}
/*
header("Expires: Mon, 1 Jan 1990 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-type: application/octet-stream");
if (stristr(" ".$GLOBALS["HTTP_SERVER_VARS"]["HTTP_USER_AGENT"],"MSIE") )
{
header ("Content-Disposition: attachment; filename=" . $fileName.".zip");
}
else
{
header ("Content-Disposition: inline; filename=".$fileName.".zip" );
}
header ("Content-length:".(string)( filesize($export_dir."/".$fileName.".zip")) );
readfile( $export_dir."/".$fileName.".zip" );
*/
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjDlBook::exportRekursiv | ( | $ | obj_id, | |
| $ | depth, | |||
| $ | left, | |||
| $ | right | |||
| ) |
export lm_data-table to xml-structure
| integer | obj_id | |
| integer | depth | |
| integer | left left border of nested-set-structure | |
| integer | right right border of nested-set-structure public |
Definition at line 77 of file class.ilObjDlBook.php.
References $dom, $nested, $obj_id, $path, $query, $res, $result, $row, $xml, $xpc, domxml_open_mem(), xpath_eval(), and xpath_new_context().
Referenced by export().
{
// Jetzt alle lm_data anhand der obj_id auslesen.
$query = "SELECT *
FROM lm_tree, lm_data
WHERE lm_tree.lm_id = $obj_id
AND lm_tree.child = lm_data.obj_id
AND ( lm_data.type = 'st' OR lm_data.type = 'pg' )
AND lm_tree.depth = $depth
AND lm_tree.lft>$left and lm_tree.rgt<$right
ORDER BY lm_tree.lft";
$result = $this->ilias->db->query($query);
while (is_array($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) )
{
if ($row["type"] == "st")
{
$xml .= "<StructureObject>";
$nested = new ilNestedSetXML();
$xml .= $nested->export($row["obj_id"],"st");
$xml .= "\n";
$xml .= $this->exportRekursiv($obj_id, $depth+1, $row["lft"], $row["rgt"]);
$xml .= "</StructureObject>";
}
if ($row["type"] == "pg")
{
$query = "SELECT * FROM page_object WHERE page_id='".$row["obj_id"]."' ";
$result2 = $this->ilias->db->query($query);
$row2 = $result2->fetchRow(DB_FETCHMODE_ASSOC);
$PO = $row2["content"]."\n";
if (stristr($PO,"MediaObject"))
{
$dom = domxml_open_mem($PO);
$xpc = xpath_new_context($dom);
$path = "//MediaObject/MediaAlias";
$res =& xpath_eval($xpc, $path);
for($i = 0; $i < count($res->nodeset); $i++)
{
$id_arr = explode("_", $res->nodeset[$i]->get_attribute("OriginId"));
$mob_id = $id_arr[count($id_arr) - 1];
$this->mob_ids[$mob_id] = true;
}
}
$nested = new ilNestedSetXML();
$mdxml = $nested->export($row["obj_id"],"pg");
$PO = str_replace("<PageObject>","<PageObject>\n$mdxml\n",$PO);
$xml .= $PO;
}
}
return($xml);
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjDlBook::getTranslations | ( | ) |
Definition at line 411 of file class.ilObjDlBook.php.
{
return $this->tr_ids;
}
| ilObjDlBook::getXMLZip | ( | ) |
Reimplemented from ilObjContentObject.
Definition at line 546 of file class.ilObjDlBook.php.
References export().
{
return $this->export(false);
}
Here is the call graph for this function:| ilObjDlBook::ilObjDlBook | ( | $ | a_id = 0, |
|
| $ | a_call_by_reference = true | |||
| ) |
Constructor public.
Definition at line 42 of file class.ilObjDlBook.php.
References ilObjContentObject::ilObjContentObject(), and readAssignedTranslations().
{
$this->type = "dbk";
parent::ilObjContentObject($a_id, $a_call_by_reference);
if($a_id)
{
$this->readAssignedTranslations();
}
}
Here is the call graph for this function:| ilObjDlBook::initBibItemObject | ( | ) |
init bib object (contains all bib item data)
Definition at line 57 of file class.ilObjDlBook.php.
{
include_once("content/classes/class.ilBibItem.php");
$this->bib_obj =& new ilBibItem($this);
$this->bib_obj->read();
return true;
}
| ilObjDlBook::readAssignedTranslations | ( | ) |
Definition at line 553 of file class.ilObjDlBook.php.
References $query, $res, and $row.
Referenced by addTranslation(), deleteTranslation(), and ilObjDlBook().
{
$query = "SELECT tr_id FROM dbk_translations ".
"WHERE id = '".$this->ref_id."'";
$res = $this->ilias->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$tmp_tr_ids[] = $row->tr_id;
}
return $this->tr_ids = $tmp_tr_ids ? $tmp_tr_ids : array();
}
Here is the caller graph for this function:| ilObjDlBook::$bib_obj |
Definition at line 36 of file class.ilObjDlBook.php.
1.7.1