ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCategoryImportParser Class Reference

Category Import Parser. More...

+ Inheritance diagram for ilCategoryImportParser:
+ Collaboration diagram for ilCategoryImportParser:

Public Member Functions

 ilCategoryImportParser ($a_xml_file, $a_parent, $withrol)
 Constructor.
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private
 startParsing ()
 start the parser
 buildTag ($type, $name, $attr="")
 generate a tag with given name and attributes
 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 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

 $parent
 $withrol
- 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()

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

Category Import Parser.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
Id:
class.ilCategoryImportParser.php 15681 2008-01-07 17:05:41Z akill

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

Member Function Documentation

ilCategoryImportParser::buildTag (   $type,
  $name,
  $attr = "" 
)

generate a tag with given name and attributes

Parameters
string"start" | "end" for starting or ending tag
stringelement/tag name
arrayarray of attributes

Definition at line 85 of file class.ilCategoryImportParser.php.

References $name, and $type.

{
$tag = "<";
if ($type == "end")
$tag.= "/";
$tag.= $name;
if (is_array($attr))
{
while (list($k,$v) = each($attr))
$tag.= " ".$k."=\"$v\"";
}
$tag.= ">";
return $tag;
}
ilCategoryImportParser::handlerBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

handler for begin of element

Definition at line 108 of file class.ilCategoryImportParser.php.

References $_POST, $desc, and ilObject\setImportId().

{
global $rbacadmin, $rbacreview, $rbacsystem;
switch($a_name)
{
case "Category":
$cur_parent = $this->parent[$this->parent_cnt - 1];
require_once("Modules/Category/classes/class.ilObjCategory.php");
$this->category = new ilObjCategory;
$this->category->setImportId($a_attribs["Id"]." (#".$cur_parent.")");
$this->default_language = $a_attribs["DefaultLanguage"];
$this->category->setTitle($a_attribs["Id"]);
$this->category->create();
$this->category->createReference();
$this->category->putInTree($cur_parent);
$this->parent[$this->parent_cnt++] = $this->category->getRefId();
// added for create local roles to categories imported
if ($this->withrol) {
//CHECK ACCESS 'create' rolefolder
if (!$rbacsystem->checkAccess('create',$this->category->getRefId(),'rolf')) {
$this->ilias->raiseError($this->lng->txt("msg_no_perm_create_rolf"),$this->ilias->error_obj->WARNING);
}
include_once ("classes/class.ilObject.php");
include_once ("./Services/AccessControl/classes/class.ilObjRole.php");
// create a rolefolder
$rolfObj = $this->category->createRoleFolder("Local roles","Role Folder of category obj_no. ".$this->category->getRefId());
$parentRoles = $rbacreview->getParentRoleIds($rolfObj->getRefId(),true);
// iterate through the chosen templates to create a rol for each checkbox checked
foreach($_POST["adopt"] as $postadopt) {
$desc = $a_attribs["Id"]. " ".$parentRoles[$postadopt]["title"];
$roleObj = $rolfObj->createRole($desc,"Local rol for category ".$desc);
// adopt permissions from rol template selected
$rbacadmin->copyRoleTemplatePermissions($postadopt,$parentRoles[$postadopt]["parent"],$rolfObj->getRefId(),$roleObj->getId());
unset($roleObj);
}
unset($rolfObj);
unset($parentRoles);
// -----------------------------
}
break;
case "CategorySpec":
$this->cur_spec_lang = $a_attribs["Language"];
break;
}
}

+ Here is the call graph for this function:

ilCategoryImportParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Definition at line 212 of file class.ilCategoryImportParser.php.

{
// i don't know why this is necessary, but
// the parser seems to convert "&gt;" to ">" and "&lt;" to "<"
// in character data, but we don't want that, because it's the
// way we mask user html in our content, so we convert back...
$a_data = str_replace("<","&lt;",$a_data);
$a_data = str_replace(">","&gt;",$a_data);
// DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
$a_data = preg_replace("/\n/","",$a_data);
$a_data = preg_replace("/\t+/","",$a_data);
if(!empty($a_data))
{
$this->cdata .= $a_data;
}
}
ilCategoryImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

Definition at line 172 of file class.ilCategoryImportParser.php.

References ilSaxParser\$ilias.

{
global $ilias, $rbacadmin;
switch($a_name)
{
case "Category":
unset($this->category);
unset($this->parent[$this->parent_cnt - 1]);
$this->parent_cnt--;
break;
case "CategorySpec":
$is_def = 0;
if ($this->cur_spec_lang == $this->default_language)
{
$this->category->setTitle($this->cur_title);
$this->category->setDescription($this->cur_description);
$this->category->update();
$is_def = 1;
}
$this->category->addTranslation($this->cur_title,
$this->cur_description, $this->cur_spec_lang, $is_def);
break;
case "Title":
$this->cur_title = $this->cdata;
break;
case "Description":
$this->cur_description = $this->cdata;
break;
}
$this->cdata = "";
}
ilCategoryImportParser::ilCategoryImportParser (   $a_xml_file,
  $a_parent,
  $withrol 
)

Constructor.

Parameters
string$a_xml_filexml file

public

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

References $withrol, and ilSaxParser\ilSaxParser().

{
$this->parent_cnt = 0;
$this->parent[$this->parent_cnt] = $a_parent;
$this->parent_cnt++;
$this->withrol = $withrol;
parent::ilSaxParser($a_xml_file);
}

+ Here is the call graph for this function:

ilCategoryImportParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

Reimplemented from ilSaxParser.

Definition at line 63 of file class.ilCategoryImportParser.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');
}
ilCategoryImportParser::startParsing ( )

start the parser

Reimplemented from ilSaxParser.

Definition at line 73 of file class.ilCategoryImportParser.php.

Field Documentation

ilCategoryImportParser::$parent

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

ilCategoryImportParser::$withrol

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

Referenced by ilCategoryImportParser().


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