ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilECSEContentReader Class Reference
+ Collaboration diagram for ilECSEContentReader:

Public Member Functions

 __construct ($a_server_id, $a_econtent_id=0)
 Constructor.
 getEContent ()
 get resources
 getEContentDetails ()
 Get econtent details.
 readResourceList ($a_filter=null)
 Read resource list ilLog $ilLog.
 read ($details_only=false)
 Read.

Data Fields

const ECS_QUERY_STRINGS = 'X-EcsQueryStrings'
const ECS_HEADER_SENDER = 'X-EcsSender'
const RECEIVER_ONLY = 'receiver=true'
const SENDER_ONLY = 'sender=true'
const ALL_ECONTENT = 'all=true'

Protected Attributes

 $log
 $settings = null
 $connector = null
 $econtent = array()
 $econtent_details = array()
 $econtent_id = 0

Private Member Functions

 parseSenderHeader (ilECSResult $res)
 Parse the sender header.

Detailed Description

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

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

Constructor & Destructor Documentation

ilECSEContentReader::__construct (   $a_server_id,
  $a_econtent_id = 0 
)

Constructor.

public

Exceptions
ilECSConnectorException

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

References $ilLog, and ilECSSetting\getInstanceByServerId().

{
global $ilLog;
include_once('Services/WebServices/ECS/classes/class.ilECSSetting.php');
include_once('Services/WebServices/ECS/classes/class.ilECSConnector.php');
include_once('Services/WebServices/ECS/classes/class.ilECSConnectorException.php');
include_once('Services/WebServices/ECS/classes/class.ilECSEContent.php');
include_once('Services/WebServices/ECS/classes/class.ilECSReaderException.php');
$this->settings = ilECSSetting::getInstanceByServerId($a_server_id);
$this->connector = new ilECSConnector($this->settings);
$this->log = $ilLog;
$this->econtent_id = $a_econtent_id;
}

+ Here is the call graph for this function:

Member Function Documentation

ilECSEContentReader::getEContent ( )

get resources

public

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

{
return $this->econtent ? $this->econtent : array();
}
ilECSEContentReader::getEContentDetails ( )

Get econtent details.

Returns
array

Definition at line 88 of file class.ilECSEContentReader.php.

Referenced by read().

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

+ Here is the caller graph for this function:

ilECSEContentReader::parseSenderHeader ( ilECSResult  $res)
private

Parse the sender header.

Parameters
ilECSResult$res
Returns
int

Definition at line 198 of file class.ilECSEContentReader.php.

References ilECSResult\getHeaders().

Referenced by read().

{
#$GLOBALS['ilLog']->write(__METHOD__.' Reading sender from header');
foreach($res->getHeaders() as $key => $value)
{
#$GLOBALS['ilLog']->write(__METHOD__.' Key is: '.$key);
if($key == self::ECS_HEADER_SENDER)
{
#$GLOBALS['ilLog']->write(__METHOD__.' Value is: '.$value);
$sender = trim($value);
$value_arr = explode(',', $value);
foreach((array) $value_arr as $s)
{
return (int) trim($s);
}
}
}
return 0;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSEContentReader::read (   $details_only = false)

Read.

public

Returns
bool false in case og HTTP 404
Exceptions
ilECSConnectorException,ilECSReaderException

Definition at line 127 of file class.ilECSEContentReader.php.

References $GLOBALS, $ilLog, $res, getEContentDetails(), ilECSConnector\HTTP_CODE_NOT_FOUND, and parseSenderHeader().

{
global $ilLog;
if($details_only and $this->getEContentDetails() instanceof ilECSEContentDetails)
{
return true;
}
try
{
$res = $this->connector->getResource($this->econtent_id,$details_only);
{
return false;
}
if(!is_object($res->getResult()))
{
$ilLog->write(__METHOD__ . ': Error parsing result. Expected result of type array.');
$ilLog->logStack();
throw new ilECSReaderException('Error parsing query');
}
if($details_only)
{
include_once './Services/WebServices/ECS/classes/class.ilECSEContentDetails.php';
$tmp_content = new ilECSEContentDetails();
$tmp_content->loadFromJSON($res->getResult());
$this->econtent_details = $tmp_content;
}
else
{
$tmp_content = new ilECSEContent($this->econtent_id);
$tmp_content->loadFromJSON($res->getResult());
$sender = $this->parseSenderHeader($res);
if($sender)
{
$tmp_content->setOwner($sender);
$GLOBALS['ilLog']->write(__METHOD__.': Reading sender from header: '.$sender);
}
else
{
$details = $this->read(true);
$details = $this->getEContentDetails();
$GLOBALS['ilLog']->write(__METHOD__.': Reading sender from details: '.$details->getFirstSender());
$tmp_content->setOwner($details->getFirstSender());
}
$this->econtent = $tmp_content;
}
return true;
}
{
$ilLog->write(__METHOD__ . ': Error connecting to ECS server. ' . $e->getMessage());
throw $e;
}
{
$ilLog->write(__METHOD__ . ': Error reading EContent. ' . $e->getMessage());
throw $e;
}
return false;
}

+ Here is the call graph for this function:

ilECSEContentReader::readResourceList (   $a_filter = null)

Read resource list ilLog $ilLog.

Returns
ilECSUriList
Exceptions
ilECSConnectorException,ilECSReaderException

Definition at line 99 of file class.ilECSEContentReader.php.

References $ilLog, and $res.

{
global $ilLog;
try {
$this->connector->addHeader(self::ECS_QUERY_STRINGS, $a_filter ? $a_filter : self::ALL_ECONTENT);
$res = $this->connector->getResourceList();
return $res->getResult();
}
{
$ilLog->write(__METHOD__ . ': Error connecting to ECS server. ' . $e->getMessage());
throw $e;
}
{
$ilLog->write(__METHOD__ . ': Error reading course links. ' . $e->getMessage());
throw $e;
}
}

Field Documentation

ilECSEContentReader::$connector = null
protected

Definition at line 43 of file class.ilECSEContentReader.php.

ilECSEContentReader::$econtent = array()
protected

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

ilECSEContentReader::$econtent_details = array()
protected

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

ilECSEContentReader::$econtent_id = 0
protected

Definition at line 46 of file class.ilECSEContentReader.php.

ilECSEContentReader::$log
protected

Definition at line 41 of file class.ilECSEContentReader.php.

ilECSEContentReader::$settings = null
protected

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

const ilECSEContentReader::ALL_ECONTENT = 'all=true'

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

const ilECSEContentReader::ECS_HEADER_SENDER = 'X-EcsSender'

Definition at line 36 of file class.ilECSEContentReader.php.

const ilECSEContentReader::ECS_QUERY_STRINGS = 'X-EcsQueryStrings'

Definition at line 35 of file class.ilECSEContentReader.php.

const ilECSEContentReader::RECEIVER_ONLY = 'receiver=true'

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

const ilECSEContentReader::SENDER_ONLY = 'sender=true'

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