ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilObjectXMLWriter Class Reference

XML writer class. More...

+ Inheritance diagram for ilObjectXMLWriter:
+ Collaboration diagram for ilObjectXMLWriter:

Public Member Functions

 ilObjectXMLWriter ()
 constructor
 setMode ($a_mode)
 setHighlighter ($a_highlighter)
 enablePermissionCheck ($a_status)
 isPermissionCheckEnabled ()
 setUserId ($a_id)
 getUserId ()
 enableOperations ($a_status)
 enabledOperations ()
 enableReferences ($a_stat)
 enabledReferences ()
 setObjects ($objects)
 __getObjects ()
 start ()
 getXML ()
 __appendObject ($object)
 __appendTimeTargets ($a_ref_id)
 Append time target settings for items inside of courses.
 __appendObjectProperties (ilObject $obj)
 Append object properties.
 __appendOperations ($a_ref_id, $a_type)
 __appendPath ($refid)
 __buildHeader ()
 __buildFooter ()
 __getAccessInfo (&$object, $ref_id)
- Public Member Functions inherited from ilXmlWriter
 ilXmlWriter ($version="1.0", $outEnc="utf-8", $inEnc="utf-8")
 constructor
 _ilXmlWriter ()
 destructor public
 xmlSetDtdDef ($dtdDef)
 Sets dtd definition.
 xmlSetStSheet ($stSheet)
 Sets stylesheet.
 xmlSetGenCmt ($genCmt)
 Sets generated comment.
 _xmlEscapeData ($data)
 Escapes reserved characters.
 xmlEncodeData ($data)
 Encodes text from input encoding into output encoding.
 xmlFormatData ($data)
 Indents text for better reading.
 xmlFormatElement ($array)
 Callback function for xmlFormatData; do not invoke directly.
 xmlHeader ()
 Writes xml header public.
 xmlStartTag ($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
 Writes a starttag.
 xmlEndTag ($tag)
 Writes an endtag.
 xmlComment ($comment)
 Writes a comment.
 xmlData ($data, $encode=TRUE, $escape=TRUE)
 Writes data.
 xmlElement ($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
 Writes a basic element (no children, just textual content)
 xmlDumpFile ($file, $format=TRUE)
 Dumps xml document from memory into a file.
 xmlDumpMem ($format=TRUE)
 Returns xml document from memory.
 appendXML ($a_str)
 append xml string to document
 xmlClear ()
 clears xmlStr public

Static Public Member Functions

static appendPathToObject ($writer, $refid)

Data Fields

const MODE_SEARCH_RESULT = 1
const TIMING_DEACTIVATED = 0
const TIMING_TEMPORARILY_AVAILABLE = 1
const TIMING_PRESETTING = 2
const TIMING_VISIBILITY_OFF = 0
const TIMING_VISIBILITY_ON = 1
 $ilias
 $xml
 $enable_operations = false
 $objects = array()
 $user_id = 0
- Data Fields inherited from ilXmlWriter
 $xmlStr
 $version
 $outEnc
 $inEnc
 $dtdDef = ""
 $stSheet = ""
 $genCmt = "Generated by ILIAS XmlWriter"

Protected Attributes

 $check_permission = false

Private Attributes

 $mode = 0
 $highlighter = null
 $enable_references = true

Detailed Description

XML writer class.

Class to simplify manual writing of xml documents. It only supports writing xml sequentially, because the xml document is saved in a string with no additional structure information. The author is responsible for well-formedness and validity of the xml document.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 19 of file class.ilObjectXMLWriter.php.

Member Function Documentation

ilObjectXMLWriter::__appendObject (   $object)

Definition at line 163 of file class.ilObjectXMLWriter.php.

References $ref_id, $title, __appendObjectProperties(), __appendOperations(), __appendPath(), __appendTimeTargets(), __getAccessInfo(), ilObject\_getAllReferences(), enabledReferences(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

{
global $tree, $rbacreview;
$id = $object->getId();
if ($object->getType() == "role" && $rbacreview->isRoleDeleted($id))
{
return;
}
$attrs = array('type' => $object->getType(),
'obj_id' => $id);
$this->xmlStartTag('Object',$attrs);
//$this->xmlElement('Title',null,$object->getTitle());
//$this->xmlElement('Description',null,$object->getDescription());
// begin-patch fm
if($this->mode == self::MODE_SEARCH_RESULT)
{
$title = $object->getTitle();
if($this->highlighter->getTitle($object->getId(),0))
{
$title = $this->highlighter->getTitle($object->getId(),0);
}
$description = $object->getDescription();
if($this->highlighter->getDescription($object->getId(),0))
{
$description = $this->highlighter->getDescription($object->getId(),0);
}
// Currently disabled
#$this->xmlElement('Title', null, $title);
#$this->xmlElement('Description',null,$description);
#$this->xmlElement('SearchResultContent', null, $this->highlighter->getContent($object->getId(),0));
$this->xmlElement('Title',null,$object->getTitle());
$this->xmlElement('Description',null,$object->getDescription());
}
else
{
$this->xmlElement('Title',null,$object->getTitle());
$this->xmlElement('Description',null,$object->getDescription());
}
// end-patch fm
$this->xmlElement('Owner',null,$object->getOwner());
$this->xmlElement('CreateDate',null,$object->getCreateDate());
$this->xmlElement('LastUpdate',null,$object->getLastUpdateDate());
$this->xmlElement('ImportId',null,$object->getImportId());
$this->__appendObjectProperties($object);
// begin-patch filemanager
if($this->enabledReferences())
{
$refs = ilObject::_getAllReferences($object->getId());
}
else
{
$refs = array($object->getRefId());
}
foreach($refs as $ref_id)
// end-patch filemanager
{
if (!$tree->isInTree($ref_id))
continue;
$attr = array('ref_id' => $ref_id, 'parent_id'=> $tree->getParentId(intval($ref_id)));
$attr['accessInfo'] = $this->__getAccessInfo($object,$ref_id);
$this->xmlStartTag('References',$attr);
$this->__appendTimeTargets($ref_id);
$this->__appendOperations($ref_id,$object->getType());
$this->__appendPath ($ref_id);
$this->xmlEndTag('References');
}
$this->xmlEndTag('Object');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectXMLWriter::__appendObjectProperties ( ilObject  $obj)

Append object properties.

Parameters
ilObject$obj

Definition at line 314 of file class.ilObjectXMLWriter.php.

References $size, ilObjFileAccess\_lookupFileSize(), ilObjFileAccess\_lookupSuffix(), ilObjFileAccess\_lookupVersion(), ilObject\getId(), ilObject\getType(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by __appendObject().

{
switch($obj->getType()) {
case 'file':
include_once './Modules/File/classes/class.ilObjFileAccess.php';
$extension = ilObjFileAccess::_lookupSuffix($obj->getId());
$this->xmlStartTag('Properties');
$this->xmlElement("Property",array('name' => 'fileSize'),(int) $size);
$this->xmlElement("Property",array('name' => 'fileExtension'),(string) $extension);
// begin-patch fm
$this->xmlElement('Property',array('name' => 'fileVersion'), (string) ilObjFileAccess::_lookupVersion($obj->getId()));
// end-patch fm
$this->xmlEndTag('Properties');
break;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectXMLWriter::__appendOperations (   $a_ref_id,
  $a_type 
)

Definition at line 335 of file class.ilObjectXMLWriter.php.

References $objects, enabledOperations(), ilRbacReview\lookupCreateOperationIds(), and ilXmlWriter\xmlElement().

Referenced by __appendObject().

{
global $ilAccess,$rbacreview,$objDefinition;
if($this->enabledOperations())
{
$ops = $rbacreview->getOperationsOnTypeString($a_type);
if (is_array($ops))
{
foreach($ops as $ops_id)
{
$operation = $rbacreview->getOperation($ops_id);
if(count ($operation) && $ilAccess->checkAccessOfUser($this->getUserId(),$operation['operation'],'view',$a_ref_id))
{
$this->xmlElement('Operation',null,$operation['operation']);
}
}
}
// Create operations
// Get creatable objects
$objects = $objDefinition->getCreatableSubObjects($a_type);
$creation_operations = array();
foreach($objects as $type => $info)
{
$ops_id = $ops_ids[$type];
if(!$ops_id)
{
continue;
}
$operation = $rbacreview->getOperation($ops_id);
if(count ($operation) && $ilAccess->checkAccessOfUser($this->getUserId(),$operation['operation'],'view',$a_ref_id))
{
$this->xmlElement('Operation',null,$operation['operation']);
}
}
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectXMLWriter::__appendPath (   $refid)

Definition at line 381 of file class.ilObjectXMLWriter.php.

References appendPathToObject().

Referenced by __appendObject().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectXMLWriter::__appendTimeTargets (   $a_ref_id)

Append time target settings for items inside of courses.

Parameters
int$ref_idReference id of object
Returns
void

Definition at line 249 of file class.ilObjectXMLWriter.php.

References ilObjectActivation\getItem(), TIMING_DEACTIVATED, TIMING_PRESETTING, TIMING_TEMPORARILY_AVAILABLE, TIMING_VISIBILITY_ON, ilObjectActivation\TIMINGS_ACTIVATION, ilObjectActivation\TIMINGS_DEACTIVATED, ilObjectActivation\TIMINGS_PRESETTING, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by __appendObject().

{
global $tree;
if(!$tree->checkForParentType($a_ref_id,'crs')) {
return;
}
include_once('./Services/Object/classes/class.ilObjectActivation.php');
$time_targets = ilObjectActivation::getItem($a_ref_id);
switch($time_targets['timing_type'])
{
break;
break;
break;
default:
break;
}
$this->xmlStartTag('TimeTarget',array('type' => $type));
# if($type == self::TIMING_TEMPORARILY_AVAILABLE)
{
$vis = $time_targets['visible'] == 0 ? self::TIMING_VISIBILITY_OFF : self::TIMING_VISIBILITY_ON;
$this->xmlElement('Timing',
array('starting_time' => $time_targets['timing_start'],
'ending_time' => $time_targets['timing_end'],
'visibility' => $vis));
}
# if($type == self::TIMING_PRESETTING)
{
if($time_targets['changeable'] or 1)
{
$this->xmlElement('Suggestion',
array('starting_time' => $time_targets['suggestion_start'],
'ending_time' => $time_targets['suggestion_end'],
'changeable' => $time_targets['changeable'],
'earliest_start' => $time_targets['earliest_start'],
'latest_end' => $time_targets['latest_end']));
}
else
{
$this->xmlElement('Suggestion',
array('starting_time' => $time_targets['suggestion_start'],
'ending_time' => $time_targets['suggestion_end'],
'changeable' => $time_targets['changeable']));
}
}
$this->xmlEndTag('TimeTarget');
return;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectXMLWriter::__buildFooter ( )

Definition at line 394 of file class.ilObjectXMLWriter.php.

References ilXmlWriter\xmlEndTag().

Referenced by start().

{
$this->xmlEndTag('Objects');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectXMLWriter::__buildHeader ( )

Definition at line 385 of file class.ilObjectXMLWriter.php.

References ilXmlWriter\xmlHeader(), ilXmlWriter\xmlSetDtdDef(), ilXmlWriter\xmlSetGenCmt(), and ilXmlWriter\xmlStartTag().

Referenced by start().

{
$this->xmlSetDtdDef("<!DOCTYPE Objects PUBLIC \"-//ILIAS//DTD ILIAS Repositoryobjects//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_object_4_0.dtd\">");
$this->xmlSetGenCmt("Export of ILIAS objects");
$this->xmlHeader();
$this->xmlStartTag("Objects");
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectXMLWriter::__getAccessInfo ( $object,
  $ref_id 
)

Definition at line 399 of file class.ilObjectXMLWriter.php.

References $ref_id, and getUserId().

Referenced by __appendObject().

{
global $ilAccess;
include_once 'Services/AccessControl/classes/class.ilAccessHandler.php';
$ilAccess->checkAccessOfUser($this->getUserId(),'read','view',$ref_id,$object->getType(),$object->getId());
if(!$info = $ilAccess->getInfo())
{
return 'granted';
}
else
{
return $info[0]['type'];
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectXMLWriter::__getObjects ( )

Definition at line 128 of file class.ilObjectXMLWriter.php.

Referenced by start().

{
return $this->objects ? $this->objects : array();
}

+ Here is the caller graph for this function:

static ilObjectXMLWriter::appendPathToObject (   $writer,
  $refid 
)
static

Definition at line 418 of file class.ilObjectXMLWriter.php.

References $lng.

Referenced by __appendPath(), and ilSoapRoleObjectXMLWriter\start().

{
global $tree, $lng;
$items = $tree->getPathFull($refid);
$writer->xmlStartTag("Path");
foreach ($items as $item) {
if ($item["ref_id"] == $refid)
continue;
if ($item["type"] == "root")
{
$item["title"] = $lng->txt("repository");
}
$writer->xmlElement("Element", array("ref_id" => $item["ref_id"], "type" => $item["type"]), $item["title"]);
}
$writer->xmlEndTag("Path");
}

+ Here is the caller graph for this function:

ilObjectXMLWriter::enabledOperations ( )

Definition at line 105 of file class.ilObjectXMLWriter.php.

References $enable_operations.

Referenced by __appendOperations().

+ Here is the caller graph for this function:

ilObjectXMLWriter::enabledReferences ( )

Definition at line 116 of file class.ilObjectXMLWriter.php.

References $enable_references.

Referenced by __appendObject().

+ Here is the caller graph for this function:

ilObjectXMLWriter::enableOperations (   $a_status)

Definition at line 98 of file class.ilObjectXMLWriter.php.

{
$this->enable_operations = $a_status;
return true;
}
ilObjectXMLWriter::enablePermissionCheck (   $a_status)

Definition at line 79 of file class.ilObjectXMLWriter.php.

{
$this->check_permission = $a_status;
}
ilObjectXMLWriter::enableReferences (   $a_stat)

Definition at line 111 of file class.ilObjectXMLWriter.php.

{
$this->enable_references = $a_stat;
}
ilObjectXMLWriter::getUserId ( )

Definition at line 93 of file class.ilObjectXMLWriter.php.

References $user_id.

Referenced by __getAccessInfo(), and start().

{
}

+ Here is the caller graph for this function:

ilObjectXMLWriter::getXML ( )

Definition at line 156 of file class.ilObjectXMLWriter.php.

References ilXmlWriter\xmlDumpMem().

{
return $this->xmlDumpMem(false);
}

+ Here is the call graph for this function:

ilObjectXMLWriter::ilObjectXMLWriter ( )

constructor

Parameters
stringxml version
stringoutput encoding
stringinput encoding public

Definition at line 56 of file class.ilObjectXMLWriter.php.

References $ilias, $ilUser, and ilXmlWriter\ilXmlWriter().

{
global $ilias,$ilUser;
$this->ilias =& $ilias;
$this->user_id = $ilUser->getId();
}

+ Here is the call graph for this function:

ilObjectXMLWriter::isPermissionCheckEnabled ( )

Definition at line 84 of file class.ilObjectXMLWriter.php.

References $check_permission.

Referenced by start().

+ Here is the caller graph for this function:

ilObjectXMLWriter::setHighlighter (   $a_highlighter)

Definition at line 72 of file class.ilObjectXMLWriter.php.

{
$this->highlighter = $a_highlighter;
}
ilObjectXMLWriter::setMode (   $a_mode)

Definition at line 67 of file class.ilObjectXMLWriter.php.

{
$this->mode = $a_mode;
}
ilObjectXMLWriter::setObjects (   $objects)

Definition at line 123 of file class.ilObjectXMLWriter.php.

References $objects.

{
$this->objects = $objects;
}
ilObjectXMLWriter::setUserId (   $a_id)

Definition at line 89 of file class.ilObjectXMLWriter.php.

{
$this->user_id = $a_id;
}
ilObjectXMLWriter::start ( )

Definition at line 133 of file class.ilObjectXMLWriter.php.

References __appendObject(), __buildFooter(), __buildHeader(), __getObjects(), getUserId(), and isPermissionCheckEnabled().

{
global $ilAccess,$objDefinition;
$this->__buildHeader();
foreach($this->__getObjects() as $object)
{
if(method_exists($object, 'getType') and $objDefinition->isRBACObject($object->getType()))
{
if($this->isPermissionCheckEnabled() and !$ilAccess->checkAccessOfUser($this->getUserId(),'read','',$object->getRefId()))
{
continue;
}
}
if (is_object($object))
$this->__appendObject($object);
}
$this->__buildFooter();
return true;
}

+ Here is the call graph for this function:

Field Documentation

ilObjectXMLWriter::$check_permission = false
protected

Definition at line 47 of file class.ilObjectXMLWriter.php.

Referenced by isPermissionCheckEnabled().

ilObjectXMLWriter::$enable_operations = false

Definition at line 40 of file class.ilObjectXMLWriter.php.

Referenced by enabledOperations().

ilObjectXMLWriter::$enable_references = true
private

Definition at line 42 of file class.ilObjectXMLWriter.php.

Referenced by enabledReferences().

ilObjectXMLWriter::$highlighter = null
private

Definition at line 25 of file class.ilObjectXMLWriter.php.

ilObjectXMLWriter::$ilias

Definition at line 37 of file class.ilObjectXMLWriter.php.

Referenced by ilObjectXMLWriter().

ilObjectXMLWriter::$mode = 0
private

Definition at line 24 of file class.ilObjectXMLWriter.php.

ilObjectXMLWriter::$objects = array()

Definition at line 44 of file class.ilObjectXMLWriter.php.

Referenced by __appendOperations(), and setObjects().

ilObjectXMLWriter::$user_id = 0

Definition at line 45 of file class.ilObjectXMLWriter.php.

Referenced by getUserId().

ilObjectXMLWriter::$xml

Definition at line 39 of file class.ilObjectXMLWriter.php.

const ilObjectXMLWriter::MODE_SEARCH_RESULT = 1

Definition at line 22 of file class.ilObjectXMLWriter.php.

const ilObjectXMLWriter::TIMING_DEACTIVATED = 0
const ilObjectXMLWriter::TIMING_PRESETTING = 2
const ilObjectXMLWriter::TIMING_TEMPORARILY_AVAILABLE = 1
const ilObjectXMLWriter::TIMING_VISIBILITY_OFF = 0

Definition at line 33 of file class.ilObjectXMLWriter.php.

const ilObjectXMLWriter::TIMING_VISIBILITY_ON = 1

Definition at line 34 of file class.ilObjectXMLWriter.php.

Referenced by __appendTimeTargets().


The documentation for this class was generated from the following file: