ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCategoryXmlParser Class Reference

Group Import Parser. More...

+ Inheritance diagram for ilCategoryXmlParser:
+ Collaboration diagram for ilCategoryXmlParser:

Public Member Functions

 __construct ($a_xml, $a_parent_id)
 Constructor.
 getParentId ()
 Get parent id.
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private
 startParsing ()
 start the parser
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element
 handlerEndTag ($a_xml_parser, $a_name)
 Handler end tag.
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data
 setMode ($mode)
 Set import mode.
 setCategory ($cat)
 Set category object.
 getCategory ()
- Public Member Functions inherited from ilSaxParser
 ilSaxParser ($a_xml_file= '', $throwException=false)
 Constructor setup ILIAS global object public.
 setXMLContent ($a_xml_content)
 getXMLContent ()
 getInputType ()
 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_CREATE = 1
const MODE_UPDATE = 2
- 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()

Protected Member Functions

 getCurrentTranslation ()
 Get current translation.
 save ()
 Save category object.
- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle

Private Attributes

 $cat = null
 $parent_id = 0
 $current_translation = array()
 $current_container_setting

Detailed Description

Group Import Parser.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id:
class.ilCategoryXmlParser.php 53225 2014-09-10 11:43:24Z fwolf

Definition at line 38 of file class.ilCategoryXmlParser.php.

Constructor & Destructor Documentation

ilCategoryXmlParser::__construct (   $a_xml,
  $a_parent_id 
)

Constructor.

Parameters
string$a_xml_filexml file

public

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

References MODE_CREATE, and ilSaxParser\setXMLContent().

{
$this->parent_id = $a_parent_id;
$this->setXMLContent($a_xml);
}

+ Here is the call graph for this function:

Member Function Documentation

ilCategoryXmlParser::getCategory ( )

Definition at line 265 of file class.ilCategoryXmlParser.php.

References $cat.

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

{
return $this->cat;
}

+ Here is the caller graph for this function:

ilCategoryXmlParser::getCurrentTranslation ( )
protected

Get current translation.

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

References $current_translation.

ilCategoryXmlParser::getParentId ( )

Get parent id.

Returns
type

Definition at line 71 of file class.ilCategoryXmlParser.php.

References $parent_id.

Referenced by save().

{
}

+ Here is the caller graph for this function:

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

handler for begin of element

Definition at line 119 of file class.ilCategoryXmlParser.php.

References $ilErr, ilContainerSortingSettings\_importContainerSortingSettings(), and getCategory().

{
global $ilErr;
switch($a_name)
{
case "Category":
break;
case 'Translations':
$this->getCategory()->removeTranslations();
break;
case 'Translation':
$this->current_translation = array();
$this->current_translation['default'] = $a_attribs['default'] ? 1 : 0;
$this->current_translation['lang'] = $a_attribs['language'];
break;
case 'Sorting':
case 'Sort':
include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
break;
case 'ContainerSetting':
$this->current_container_setting = $a_attribs['id'];
break;
}
}

+ Here is the call graph for this function:

ilCategoryXmlParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Definition at line 211 of file class.ilCategoryXmlParser.php.

{
#$a_data = str_replace("<","&lt;",$a_data);
#$a_data = str_replace(">","&gt;",$a_data);
if(!empty($a_data))
{
$this->cdata .= $a_data;
}
}
ilCategoryXmlParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

Handler end tag.

Parameters
type$a_xml_parser
type$a_name

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

References ilContainer\_writeContainerSetting(), getCategory(), and save().

{
switch($a_name)
{
case "Category":
$this->save();
break;
case 'Title':
$this->current_translation['title'] = trim($this->cdata);
if($this->current_translation['default'])
{
$this->getCategory()->setTitle(trim($this->cdata));
}
break;
case 'Description':
$this->current_translation['description'] = trim($this->cdata);
if($this->current_translation['default'])
{
$this->getCategory()->setDescription(trim($this->cdata));
}
break;
case 'Translation':
// Add translation
$this->getCategory()->addTranslation(
(string) $this->current_translation['title'],
(string) $this->current_translation['description'],
(string) $this->current_translation['lang'],
(int) $this->current_translation['default']
);
break;
case 'ContainerSetting':
if($this->current_container_setting)
{
$this->getCategory()->getId(),
$this->current_container_setting,
$this->cdata);
}
break;
}
$this->cdata = '';
}

+ Here is the call graph for this function:

ilCategoryXmlParser::save ( )
protected

Save category object.

Returns
type

mode can be create or update

Definition at line 226 of file class.ilCategoryXmlParser.php.

References getCategory(), getParentId(), and MODE_CREATE.

Referenced by handlerEndTag().

{
{
$this->create();
$this->getCategory()->create();
$this->getCategory()->createReference();
$this->getCategory()->putInTree($this->getParentId());
$this->getCategory()->setPermissions($this->getParentId());
}
$this->getCategory()->update();
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCategoryXmlParser::setCategory (   $cat)

Set category object.

Parameters
type$cat

Definition at line 260 of file class.ilCategoryXmlParser.php.

References $cat.

{
$this->cat = $cat;
}
ilCategoryXmlParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

Reimplemented from ilSaxParser.

Definition at line 91 of file class.ilCategoryXmlParser.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');
}
ilCategoryXmlParser::setMode (   $mode)

Set import mode.

Parameters
type$mode

Definition at line 251 of file class.ilCategoryXmlParser.php.

{
$this->mode = $mode;
}
ilCategoryXmlParser::startParsing ( )

start the parser

Reimplemented from ilSaxParser.

Definition at line 101 of file class.ilCategoryXmlParser.php.

References MODE_CREATE.

{
{
return is_object($this->cat) ? $this->cat->getRefId() : false;
}
else
{
return is_object($this->cat) ? $this->cat->update() : false;
}
}

Field Documentation

ilCategoryXmlParser::$cat = null
private

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

Referenced by getCategory(), and setCategory().

ilCategoryXmlParser::$current_container_setting
private

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

ilCategoryXmlParser::$current_translation = array()
private

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

Referenced by getCurrentTranslation().

ilCategoryXmlParser::$parent_id = 0
private

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

Referenced by getParentId().

const ilCategoryXmlParser::MODE_CREATE = 1
const ilCategoryXmlParser::MODE_UPDATE = 2

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