ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilWebLinkXmlParser Class Reference

XML parser for weblink xml. More...

+ Inheritance diagram for ilWebLinkXmlParser:
+ Collaboration diagram for ilWebLinkXmlParser:

Public Member Functions

 __construct ($webr, $xml)
 Constructor.
 setWebLink (ilObject $webl)
 set weblink
 getWebLink ()
 Get weblink object.
 setMode ($a_mode)
 Set parsing mode.
 getMode ()
 Return parsing mode.
 start ()
 setHandlers ($a_xml_parser)
 set event handlers
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element
 handlerEndTag ($a_xml_parser, $a_name)
 handler for end of element
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data
- Public Member Functions inherited from ilMDSaxParser
 ilMDSaxParser ($a_xml_file= '')
 Constructor.
 enableMDParsing ($a_status)
 getMDParsingStatus ()
 setMDObject (&$md)
getMDObject ()
 inMetaData ()
 __getCharacterData ()
 __pushParent (&$md_obj)
__popParent ()
__getParent ()
 ilMDSaxParser ($a_xml_file= '')
 Constructor.
 setMDObject (&$md)
 inMetaData ()
 __getCharacterData ()
 __pushParent (&$md_obj)
__popParent ()
__getParent ()
- Public Member Functions inherited from ilSaxParser
 ilSaxParser ($a_xml_file= '', $throwException=false)
 Constructor setup ILIAS global object public.
 setXMLContent ($a_xml_content)
 getXMLContent ()
 getInputType ()
 startParsing ()
 stores xml data in array
 createParser ()
 create parser
 setOptions ($a_xml_parser)
 set parser options
 openXMLFile ()
 open xml file
 parse ($a_xml_parser, $a_fp=null)
 parse xml file
 freeParser ($a_xml_parser)
 free xml parser handle
 setThrowException ($throwException)
 set error handling
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor.
 _PEAR ()
 Destructor (the emulated type of...).
getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them.
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes.
 isError ($data, $code=null)
 Tell whether a value is a PEAR error.
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled.
 expectError ($code= '*')
 This method is used to tell which errors you expect to get.
 popExpect ()
 This method pops one element off the expected error codes stack.
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available.
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack.
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied.
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options.
 staticPushErrorHandling ($mode, $options=null)
 staticPopErrorHandling ()
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack.
 popErrorHandling ()
 Pop the last error handler used.
 loadExtension ($ext)
 OS independant PHP extension load.

Data Fields

const MODE_UNDEFINED = 0
const MODE_UPDATE = 1
const MODE_CREATE = 2
- Data Fields inherited from ilMDSaxParser
 $md_in_md = false
 $md_chr_data = ''
 $md_cur_el = null
 $md_parsing_enabled = null
 $md = null
 $md_gen
- Data Fields inherited from ilSaxParser
 $input_type = null
 $xml_content = ''
 $ilias
 $lng
 $xml_file
 $throwException = false
- Data Fields inherited from PEAR
 $_debug = false
 $_default_error_mode = null
 $_default_error_options = null
 $_default_error_handler = ''
 $_error_class = 'PEAR_Error'
 $_expected_errors = array()

Private Attributes

 $webl
 $mode = self::MODE_UNDEFINED
 $in_metadata = false

Additional Inherited Members

- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle

Detailed Description

XML parser for weblink xml.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 20 of file class.ilWebLinkXmlParser.php.

Constructor & Destructor Documentation

ilWebLinkXmlParser::__construct (   $webr,
  $xml 
)

Constructor.

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

References getWebLink(), ilMDSaxParser\setMDObject(), ilSaxParser\setThrowException(), setWebLink(), and ilSaxParser\setXMLContent().

{
$this->setXMLContent($xml);
$this->setWebLink($webr);
$this->setMDObject(new ilMD($this->getWebLink()->getId(),$this->getWebLink()->getId(),'webr'));
$this->setThrowException(true);
}

+ Here is the call graph for this function:

Member Function Documentation

ilWebLinkXmlParser::getMode ( )

Return parsing mode.

Returns

Definition at line 77 of file class.ilWebLinkXmlParser.php.

References $mode.

Referenced by handlerBeginTag().

{
return $this->mode;
}

+ Here is the caller graph for this function:

ilWebLinkXmlParser::getWebLink ( )

Get weblink object.

Returns
ilObject

Definition at line 58 of file class.ilWebLinkXmlParser.php.

References $webl.

Referenced by __construct(), handlerBeginTag(), and handlerEndTag().

{
return $this->webl;
}

+ Here is the caller graph for this function:

ilWebLinkXmlParser::handlerBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

handler for begin of element

Parameters
resource$a_xml_parserxml parser
string$a_nameelement name
array$a_attribselement attributes array

Reimplemented from ilMDSaxParser.

Definition at line 114 of file class.ilWebLinkXmlParser.php.

References $ilErr, ilMDSaxParser\$md, $valid, getMode(), ilParameterAppender\getParameterIds(), getWebLink(), LINKS_LOGIN, LINKS_MATRICULATION, LINKS_USER_ID, ilContainer\SORT_MANUAL, and ilContainer\SORT_TITLE.

{
global $ilErr;
if($this->in_metadata)
{
parent::handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
return;
}
switch($a_name)
{
case "MetaData":
$this->in_metadata = true;
// Delete old meta data
$md = new ilMD($this->getWebLink()->getId(),0,'webr');
$md->deleteAll();
parent::handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
break;
case 'WebLink':
$this->current_link_update = false;
$this->current_link_delete = false;
$this->current_parameters = array();
if($this->getMode() == self::MODE_CREATE or (isset($a_attribs['action']) and $a_attribs['action'] == 'Create'))
{
// New weblink
$this->current_link = new ilLinkResourceItems($this->getWebLink()->getId());
}
elseif($this->getMode() == self::MODE_UPDATE and $a_attribs['action'] == 'Delete')
{
$this->current_link_delete = true;
$this->current_link = new ilLinkResourceItems($this->getWebLink()->getId());
$this->current_link->delete($a_attribs['id']);
break;
}
elseif($this->getMode() == self::MODE_UPDATE and ($a_attribs['action'] == 'Update' or !isset($a_attribs['action'])))
{
$this->current_link = new ilLinkResourceItems($this->getWebLink()->getId());
$this->current_link->readItem($a_attribs['id']);
$this->current_link_update = true;
// Delete all dynamic parameter
include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
foreach(ilParameterAppender::getParameterIds($this->getWebLink()->getId(), $a_attribs['id']) as $param_id)
{
$param = new ilParameterAppender($this->getWebLink()->getId());
$param->delete($param_id);
}
}
else
{
throw new ilWebLinkXmlParserException('Invalid action given for element "Weblink"');
}
// Active
$this->current_link->setActiveStatus($a_attribs['active'] ? 1 : 0);
// Valid
if(!isset($a_attribs['valid']))
{
$valid = 1;
}
else
{
$valid = $a_attribs['valid'] ? 1 : 0;
}
$this->current_link->setValidStatus($valid);
// Disable check
$this->current_link->setDisableCheckStatus($a_attribs['disableValidation'] ? 1 : 0);
break;
case 'Sorting':
include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
$sort = new ilContainerSortingSettings($this->getWebLink()->getId());
$sort->delete();
switch($a_attribs['type'])
{
case 'Manual':
$sort->setSortMode(ilContainer::SORT_MANUAL);
break;
case 'Title':
default:
$sort->setSortMode(ilContainer::SORT_TITLE);
}
$sort->save();
break;
case 'WebLinks':
case 'Title':
case 'Description':
case 'Target':
// Nothing to do
break;
case 'DynamicParameter':
$param = new ilParameterAppender($this->getWebLink()->getId());
$param->setName($a_attribs['name']);
switch($a_attribs['type'])
{
case 'userName':
# $GLOBALS['ilLog']->write("VALUE: ".LINKS_LOGIN);
$param->setValue(LINKS_LOGIN);
break;
case 'userId':
# $GLOBALS['ilLog']->write("VALUE: ".LINKS_USER_ID);
$param->setValue(LINKS_USER_ID);
break;
case 'matriculation':
# $GLOBALS['ilLog']->write("VALUE: ".LINKS_MATRICULATION);
$param->setValue(LINKS_MATRICULATION);
break;
default:
throw new ilWebLinkXmlParserException('Invalid attribute "type" given for element "Dynamic parameter". Aborting');
break;
}
$this->current_parameters[] = $param;
break;
}
}

+ Here is the call graph for this function:

ilWebLinkXmlParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Parameters
resource$a_xml_parserxml parser
string$a_datacharacter data

Reimplemented from ilMDSaxParser.

Definition at line 346 of file class.ilWebLinkXmlParser.php.

{
if($this->in_metadata)
{
parent::handlerCharacterData($a_xml_parser,$a_data);
}
if($a_data != "\n")
{
// Replace multiple tabs with one space
$a_data = preg_replace("/\t+/"," ",$a_data);
$this->cdata .= $a_data;
}
}
ilWebLinkXmlParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

Parameters
resource$a_xml_parserxml parser
string$a_nameelement name
Exceptions
ilSaxParserExceptionif invalid xml structure is given
ilWebLinkXMLParserExceptionmissing elements

Reimplemented from ilMDSaxParser.

Definition at line 258 of file class.ilWebLinkXmlParser.php.

References $GLOBALS, and getWebLink().

{
if($this->in_metadata)
{
parent::handlerEndTag($a_xml_parser,$a_name);
}
$GLOBALS['ilLog']->write(__METHOD__.': Called '.$a_name);
switch($a_name)
{
case 'MetaData':
$this->in_metadata = false;
parent::handlerEndTag($a_xml_parser,$a_name);
break;
case 'WebLinks':
$this->getWebLink()->MDUpdateListener('General');
$this->getWebLink()->update();
break;
case 'WebLink':
if($this->current_link_delete)
{
break;
}
if(!$this->current_link)
{
throw new ilSaxParserException('Invalid xml structure given. Missing start tag "WebLink"');
}
if(!$this->current_link->validate())
{
throw new ilWebLinkXmlParserException('Missing required elements "Title, Target"');
}
if($this->current_link_update)
{
$this->current_link->update();
}
else
{
$this->current_link->add();
}
// Save dynamic parameters
foreach($this->current_parameters as $param)
{
$param->add($this->current_link->getLinkId());
}
unset($this->current_link);
break;
case 'Title':
if($this->current_link)
{
$this->current_link->setTitle(trim($this->cdata));
}
break;
case 'Description':
if($this->current_link)
{
$this->current_link->setDescription(trim($this->cdata));
}
break;
case 'Target':
if($this->current_link)
{
$this->current_link->setTarget(trim($this->cdata));
}
break;
}
// Reset cdata
$this->cdata = '';
}

+ Here is the call graph for this function:

ilWebLinkXmlParser::setHandlers (   $a_xml_parser)

set event handlers

Parameters
resourcereference to the xml parser private

Reimplemented from ilMDSaxParser.

Definition at line 100 of file class.ilWebLinkXmlParser.php.

{
xml_set_object($a_xml_parser,$this);
xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
}
ilWebLinkXmlParser::setMode (   $a_mode)

Set parsing mode.

Parameters
int$a_mode
Returns

Definition at line 68 of file class.ilWebLinkXmlParser.php.

{
$this->mode = $a_mode;
}
ilWebLinkXmlParser::setWebLink ( ilObject  $webl)

set weblink

Parameters
ilObject$webl
Returns

Definition at line 49 of file class.ilWebLinkXmlParser.php.

References $webl.

Referenced by __construct().

{
$this->webl = $webl;
}

+ Here is the caller graph for this function:

ilWebLinkXmlParser::start ( )
Returns
Exceptions
ilSaxParserExceptionif invalid xml structure is given
ilWebLinkXMLParserExceptionmissing elements

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

References ilSaxParser\startParsing().

{
return $this->startParsing();
}

+ Here is the call graph for this function:

Field Documentation

ilWebLinkXmlParser::$in_metadata = false
private

Definition at line 29 of file class.ilWebLinkXmlParser.php.

ilWebLinkXmlParser::$mode = self::MODE_UNDEFINED
private

Definition at line 27 of file class.ilWebLinkXmlParser.php.

Referenced by getMode().

ilWebLinkXmlParser::$webl
private

Definition at line 26 of file class.ilWebLinkXmlParser.php.

Referenced by getWebLink(), and setWebLink().

const ilWebLinkXmlParser::MODE_CREATE = 2
const ilWebLinkXmlParser::MODE_UNDEFINED = 0

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

const ilWebLinkXmlParser::MODE_UPDATE = 1

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