ILIAS  release_4-4 Revision
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. More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private More...
 
 startParsing ()
 start the parser More...
 
 buildTag ($type, $name, $attr="")
 generate a tag with given name and attributes More...
 
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element More...
 
 handlerEndTag ($a_xml_parser, $a_name)
 handler for end of element More...
 
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data More...
 
- Public Member Functions inherited from ilSaxParser
 ilSaxParser ($a_xml_file='', $throwException=false)
 Constructor setup ILIAS global object public. More...
 
 setXMLContent ($a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 create parser More...
 
 setOptions ($a_xml_parser)
 set parser options More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private More...
 
 openXMLFile ()
 open xml file More...
 
 parse ($a_xml_parser, $a_fp=null)
 parse xml file More...
 
 freeParser ($a_xml_parser)
 free xml parser handle More...
 
 setThrowException ($throwException)
 set error handling More...
 
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
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. More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
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. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 

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 More...
 

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$

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

Member Function Documentation

◆ buildTag()

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.

86  {
87  $tag = "<";
88 
89  if ($type == "end")
90  $tag.= "/";
91 
92  $tag.= $name;
93 
94  if (is_array($attr))
95  {
96  while (list($k,$v) = each($attr))
97  $tag.= " ".$k."=\"$v\"";
98  }
99 
100  $tag.= ">";
101 
102  return $tag;
103  }

◆ handlerBeginTag()

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, and ilObject\setImportId().

110  {
111 
112  global $rbacadmin, $rbacreview, $rbacsystem;
113 
114  switch($a_name)
115  {
116  case "Category":
117  $cur_parent = $this->parent[$this->parent_cnt - 1];
118  require_once("Modules/Category/classes/class.ilObjCategory.php");
119  $this->category = new ilObjCategory;
120  $this->category->setImportId($a_attribs["Id"]." (#".$cur_parent.")");
121  $this->default_language = $a_attribs["DefaultLanguage"];
122  $this->category->setTitle($a_attribs["Id"]);
123  $this->category->create();
124  $this->category->createReference();
125  $this->category->putInTree($cur_parent);
126  $this->parent[$this->parent_cnt++] = $this->category->getRefId();
127 
128  // added for create local roles to categories imported
129  if ($this->withrol) {
130 
131  //CHECK ACCESS 'create' rolefolder
132  if (!$rbacsystem->checkAccess('create',$this->category->getRefId(),'rolf')) {
133  $this->ilias->raiseError($this->lng->txt("msg_no_perm_create_rolf"),$this->ilias->error_obj->WARNING);
134  }
135 
136  include_once ("./Services/Object/classes/class.ilObject.php");
137  include_once ("./Services/AccessControl/classes/class.ilObjRole.php");
138 
139  // create a rolefolder
140  $rolfObj = $this->category->createRoleFolder("Local roles","Role Folder of category obj_no. ".$this->category->getRefId());
141  $parentRoles = $rbacreview->getParentRoleIds($rolfObj->getRefId(),true);
142 
143  // iterate through the chosen templates to create a rol for each checkbox checked
144  foreach($_POST["adopt"] as $postadopt) {
145 
146  $desc = $a_attribs["Id"]. " ".$parentRoles[$postadopt]["title"];
147  $roleObj = $rolfObj->createRole($desc,"Local rol for category ".$desc);
148  // adopt permissions from rol template selected
149  $rbacadmin->copyRoleTemplatePermissions($postadopt,$parentRoles[$postadopt]["parent"],$rolfObj->getRefId(),$roleObj->getId());
150  unset($roleObj);
151  }
152 
153  unset($rolfObj);
154  unset($parentRoles);
155 
156  // -----------------------------
157  }
158  break;
159 
160  case "CategorySpec":
161  $this->cur_spec_lang = $a_attribs["Language"];
162  break;
163 
164  }
165 
166  }
$_POST['username']
Definition: cron.php:12
redirection script todo: (a better solution should control the processing via a xml file) ...
Class ilObjCategory.
setImportId($a_import_id)
set import id
+ Here is the call graph for this function:

◆ handlerCharacterData()

ilCategoryImportParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

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

213  {
214  // i don't know why this is necessary, but
215  // the parser seems to convert "&gt;" to ">" and "&lt;" to "<"
216  // in character data, but we don't want that, because it's the
217  // way we mask user html in our content, so we convert back...
218  $a_data = str_replace("<","&lt;",$a_data);
219  $a_data = str_replace(">","&gt;",$a_data);
220 
221  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
222  $a_data = preg_replace("/\n/","",$a_data);
223  $a_data = preg_replace("/\t+/","",$a_data);
224  if(!empty($a_data))
225  {
226  $this->cdata .= $a_data;
227  }
228  }

◆ handlerEndTag()

ilCategoryImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

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

References ilSaxParser\$ilias.

173  {
174  global $ilias, $rbacadmin;
175 
176  switch($a_name)
177  {
178  case "Category":
179  unset($this->category);
180  unset($this->parent[$this->parent_cnt - 1]);
181  $this->parent_cnt--;
182  break;
183 
184  case "CategorySpec":
185  $is_def = 0;
186  if ($this->cur_spec_lang == $this->default_language)
187  {
188  $this->category->setTitle($this->cur_title);
189  $this->category->setDescription($this->cur_description);
190  $this->category->update();
191  $is_def = 1;
192  }
193  $this->category->addTranslation($this->cur_title,
194  $this->cur_description, $this->cur_spec_lang, $is_def);
195  break;
196 
197  case "Title":
198  $this->cur_title = $this->cdata;
199  break;
200 
201  case "Description":
202  $this->cur_description = $this->cdata;
203  break;
204  }
205 
206  $this->cdata = "";
207  }

◆ ilCategoryImportParser()

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.

49  {
50  $this->parent_cnt = 0;
51  $this->parent[$this->parent_cnt] = $a_parent;
52  $this->parent_cnt++;
53  $this->withrol = $withrol;
54  parent::ilSaxParser($a_xml_file);
55  }

◆ setHandlers()

ilCategoryImportParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

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

64  {
65  xml_set_object($a_xml_parser,$this);
66  xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
67  xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
68  }

◆ startParsing()

ilCategoryImportParser::startParsing ( )

start the parser

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

74  {
75  parent::startParsing();
76  }

Field Documentation

◆ $parent

ilCategoryImportParser::$parent

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

◆ $withrol

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: