ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilForumImportParser Class Reference

Forum Import Parser. More...

+ Inheritance diagram for ilForumImportParser:
+ Collaboration diagram for ilForumImportParser:

Public Member Functions

 ilForumImportParser ($a_xml_file, $a_parent_id)
 Constructor.
 getParent ()
 __pushParentId ($a_id)
 __popParentId ()
 __getParentId ()
 getRefId ()
 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 for end of element
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data
 __createNew ($a_id)
 __addThread ()
 __addPost ()
 __initForumObject ()
 __addTopic ()
 __addModerator ($id)
- 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
 $counter
- 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

Forum Import Parser.

Author
Stefan Meyer smeye.nosp@m.r@da.nosp@m.tabay.nosp@m..de
Version
Id:
class.ilForumImportParser.php 19838 2009-04-30 09:44:25Z nkrzywon

Id: class.ilForumImportParser.php,v 1.6 2006/05/19 15:39:16 akill Exp $

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

Member Function Documentation

ilForumImportParser::__addModerator (   $id)

Definition at line 401 of file class.ilForumImportParser.php.

Referenced by __addTopic(), and handlerBeginTag().

{
global $rbacadmin;
$rbacadmin->assignUser($this->roles[0],$id, "n");
return true;
}

+ Here is the caller graph for this function:

ilForumImportParser::__addPost ( )

Definition at line 313 of file class.ilForumImportParser.php.

References $ilDB, __getParentId(), and __pushParentId().

Referenced by handlerEndTag().

{
global $ilDB;
$this->forum_obj->setImportName($this->post["login"]);
$this->forum_obj->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($this->forum->getId()));
$topic = $this->forum_obj->getOneTopic();
$post = $this->forum_obj->getPostById($this->__getParentId());
#$post = $this->forum_obj->getPostById($this->parent[count($this->parent)-1]);
/* $this->parent[] = (int) $this->forum_obj->generatePost($topic["top_pk"],$post["pos_thr_fk"],$this->post["author"],
$this->post["message"],$this->parent[count($this->parent)-1],
$this->post["title"],'',date("Y-m-d H:i:s",$this->post["c_time"]));*/
$this->__pushParentId((int) $this->forum_obj->generatePost($topic["top_pk"],$post["pos_thr_fk"],$this->post["author"],
$this->post["message"],$this->parent[count($this->parent)-1],
0,$this->post["title"],'',date("Y-m-d H:i:s",$this->post["c_time"])));
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForumImportParser::__addThread ( )

Definition at line 287 of file class.ilForumImportParser.php.

References $ilDB, __initForumObject(), and __pushParentId().

Referenced by handlerEndTag().

{
global $ilDB;
$this->forum_obj->setImportName($this->thread["login"]);
$this->forum_obj->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($this->forum->getId()));
$topic = $this->forum_obj->getOneTopic();
// GENERATE IT AND 'INCREMENT' parent variable
/* $this->parent[] = (int) $this->forum_obj->generateThread($topic["top_pk"],$this->thread["author"],
$this->thread["title"],
$this->post["message"],0,0,'',date("Y-m-d H:i:s",$this->thread["c_time"]));*/
$this->__pushParentId((int) $this->forum_obj->generateThread($topic["top_pk"],$this->thread["author"],
$this->thread["title"],
$this->post["message"],0,0,'',date("Y-m-d H:i:s",$this->thread["c_time"])));
$this->forum_obj->setDbTable("frm_data");
$this->forum_obj->setMDB2WhereCondition('top_pk = %s ', array('integer'), array($topic['top_pk']));
$this->forum_obj->updateVisits($topic["top_pk"]);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForumImportParser::__addTopic ( )

Definition at line 345 of file class.ilForumImportParser.php.

References $_SESSION, $ilDB, and __addModerator().

Referenced by handlerEndTag().

{
global $ilDB;
$nextId= $ilDB->nextId('frm_data');
$statement = $ilDB->manipulateF('
INSERT INTO frm_data
( top_pk,
top_frm_fk,
top_name,
top_description,
top_num_posts,
top_num_threads,
top_las_post,
top_mods,
top_date,
visits,
top_update,
update_user,
top_usr_id
)
VALUES(%s, %s, %s,%s,%s,%s,%s,%s,%s,%s,%s,%s, %s)',
array( 'integer',
'integer',
'text',
'text',
'integer',
'integer',
'text',
'integer',
'timestamp',
'integer',
'timestamp',
'integer',
'integer'),
array( $nextId,
$this->forum->getId(),
$this->forum->getTitle(),
$this->forum->getDescription(),
'0',
'0',
NULL,
$this->roles[0],
date("Y:m:d H:i:s"),
'0',
date("Y:m:d H:i:s"),
'0',
$_SESSION["AccountId"]
));
// TO ENSURE THERE IS MINIMUM ONE MODERATOR
$this->__addModerator($_SESSION["AccountId"]);
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForumImportParser::__createNew (   $a_id)

Definition at line 262 of file class.ilForumImportParser.php.

References $_GET.

Referenced by handlerBeginTag().

{
include_once "./Modules/Forum/classes/class.ilObjForum.php";
$this->forum =& new ilObjForum();
$this->forum->setImportId($a_id);
$this->forum->setTitle("empty");
$this->forum->create();
$this->forum->createReference();
//$this->forum->putInTree($this->getParent());
$this->forum->putInTree($_GET["ref_id"]);
// INIT DEFAULT PERMISSIONS
$this->forum->setPermissions($this->forum->getRefId());
// INIT DEFAULT MODERATOR ROLE
$this->roles = $this->forum->initDefaultRoles();
$this->ref_id = $this->forum->getRefId();
return true;
}

+ Here is the caller graph for this function:

ilForumImportParser::__getParentId ( )

Definition at line 75 of file class.ilForumImportParser.php.

Referenced by __addPost().

{
return $this->parent[count($this->parent) - 1];
}

+ Here is the caller graph for this function:

ilForumImportParser::__initForumObject ( )

Definition at line 335 of file class.ilForumImportParser.php.

Referenced by __addThread().

{
include_once "./Modules/Forum/classes/class.ilForum.php";
$this->forum_obj =& new ilForum();
$this->forum_obj->setForumRefId($this->ref_id);
return true;
}

+ Here is the caller graph for this function:

ilForumImportParser::__popParentId ( )

Definition at line 69 of file class.ilForumImportParser.php.

Referenced by handlerEndTag().

{
array_pop($this->parent);
return true;
}

+ Here is the caller graph for this function:

ilForumImportParser::__pushParentId (   $a_id)

Definition at line 65 of file class.ilForumImportParser.php.

Referenced by __addPost(), __addThread(), and handlerBeginTag().

{
$this->parent[] = $a_id;
}

+ Here is the caller graph for this function:

ilForumImportParser::getParent ( )

Definition at line 60 of file class.ilForumImportParser.php.

References $parent.

{
return $this->parent;
}
ilForumImportParser::getRefId ( )

Definition at line 80 of file class.ilForumImportParser.php.

References $ref_id.

{
return $this->ref_id;
}
ilForumImportParser::handlerBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

handler for begin of element

Definition at line 113 of file class.ilForumImportParser.php.

References $ilErr, __addModerator(), __createNew(), __pushParentId(), and ilObjUser\_getImportedUserId().

{
global $ilErr;
switch($a_name)
{
// FORUM DATA
case "forum":
if($a_attribs["exportVersion"] < EXPORT_VERSION)
{
$ilErr->raiseError("!!! This export Version isn't supported, update your ILIAS 2 installation"
,$ilErr->WARNING);
}
$this->__createNew($a_attribs["id"]);
// FINALLY SET FIRST PARENT
$this->parent = array(0);
break;
case "title":
case "description":
$this->cdata = '';
break;
case "moderator":
if($mod = ilObjUser::_getImportedUserId($a_attribs["id"]))
{
$this->__addModerator($mod);
}
// THREAD DATA
case "thread":
// EMPTY DATA ARRAY
$this->thread = array();
$this->thread_start = true;
$this->__pushParentId(0);
#this->parent = array(0);
break;
case "threadAuthor":
$this->thread["author"] = ilObjUser::_getImportedUserId($a_attribs["id"]);
$this->thread["login"] = $a_attribs["login"];
break;
// POST DATA
case "posting":
// EMPTY DATA ARRAY
$this->post = array();
break;
case "postingAuthor":
$this->post["author"] = ilObjUser::_getImportedUserId($a_attribs["id"]);
$this->post["login"] = $a_attribs["login"];
break;
}
}

+ Here is the call graph for this function:

ilForumImportParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Definition at line 246 of file class.ilForumImportParser.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);
if(!empty($a_data))
{
$this->cdata .= $a_data;
}
}
ilForumImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

Definition at line 174 of file class.ilForumImportParser.php.

References __addPost(), __addThread(), __addTopic(), and __popParentId().

{
switch($a_name)
{
// FORUM DATA
case "title":
$this->forum->setTitle($this->cdata);
$this->forum->update();
break;
case "description":
$this->forum->setDescription($this->cdata);
$this->forum->update();
// DATA COMPLETE UPDATE 'Topic_data'
$this->__addTopic();
break;
// THREAD DATA
case "thread":
$this->__popParentId();
#unset($this->parent[count($this->parent)-1]);
break;
case "threadTitle":
$this->thread["title"] = $this->cdata;
break;
case "threadCreationDate":
$this->thread["c_time"] = $this->cdata;
break;
// POST DATA
case "posting":
$this->__popParentId();
#unset($this->parent[count($this->parent)-1]);
break;
case "postingTitle":
$this->post["title"] = $this->cdata;
break;
case "postingCreationDate":
$this->post["c_time"] = $this->cdata;
break;
case "message":
$this->post["message"] = $this->cdata;
// ALL DATA COMPLETE, INSERT NODE HERE
if($this->thread_start)
{
$this->__addThread();
$this->thread_start = false;
}
else
{
$this->__addPost();
}
break;
case "forum":
break;
}
$this->cdata = '';
}

+ Here is the call graph for this function:

ilForumImportParser::ilForumImportParser (   $a_xml_file,
  $a_parent_id 
)

Constructor.

Parameters
string$a_xml_filexml file

public

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

References ilSaxParser\ilSaxParser().

{
define('EXPORT_VERSION',4);
parent::ilSaxParser($a_xml_file);
// SET MEMBER VARIABLES
$this->parent = $a_parent_id;
$this->counter = 0;
}

+ Here is the call graph for this function:

ilForumImportParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

Reimplemented from ilSaxParser.

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

start the parser

Reimplemented from ilSaxParser.

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

{
// SET FIRST PARENT
return true;
}

Field Documentation

ilForumImportParser::$counter

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

ilForumImportParser::$parent

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

Referenced by getParent().


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