Public Member Functions | Data Fields

ilCategoryImportParser Class Reference

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

Data Fields

 $parent
 $withrol

Detailed Description

Definition at line 35 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
string element/tag name
array array of attributes

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

References $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 109 of file class.ilCategoryImportParser.php.

References $_POST, $rbacadmin, $rbacreview, and $rbacsystem.

        {
          
          global $rbacadmin, $rbacreview, $rbacsystem;
          
          switch($a_name)
                {
                        case "Category":
                                $cur_parent = $this->parent[$this->parent_cnt - 1];
                                require_once("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 ("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->copyRolePermission($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;

                }

        }

ilCategoryImportParser::handlerCharacterData ( a_xml_parser,
a_data 
)

handler for character data

Definition at line 213 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 173 of file class.ilCategoryImportParser.php.

References ilSaxParser::$ilias, and $rbacadmin.

        {
                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_file xml file

public

Definition at line 48 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 64 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 74 of file class.ilCategoryImportParser.php.


Field Documentation

ilCategoryImportParser::$parent

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

ilCategoryImportParser::$withrol

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

Referenced by ilCategoryImportParser().


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