ILIAS  Release_3_10_x_branch Revision 61812
 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

Data Fields

 $parent
 $counter
- Data Fields inherited from ilSaxParser
 $input_type = null
 $xml_content = ''
 $ilias
 $lng
 $xml_file
 $throwException = false

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 13854 2007-05-11 08:21:59Z smeyer

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 364 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 311 of file class.ilForumImportParser.php.

References __getParentId(), and __pushParentId().

Referenced by handlerEndTag().

{
global $ilDB;
$this->forum_obj->setImportName($this->post["login"]);
$this->forum_obj->setWhereCondition("top_frm_fk = ".$ilDB->quote($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 __initForumObject(), and __pushParentId().

Referenced by handlerEndTag().

{
global $ilDB;
$this->forum_obj->setImportName($this->thread["login"]);
$this->forum_obj->setWhereCondition("top_frm_fk = ".$ilDB->quote($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->setWhereCondition("top_pk = ".$ilDB->quote($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 341 of file class.ilForumImportParser.php.

References $_SESSION, and __addModerator().

Referenced by handlerEndTag().

{
global $ilDB;
$query = "INSERT INTO frm_data VALUES('0',".
$ilDB->quote($this->forum->getId()).",".
$ilDB->quote($this->forum->getTitle()).",".
$ilDB->quote($this->forum->getDescription()).",'".
"0','0','".
"',".$ilDB->quote($this->roles[0]).",'".
date("Y:m:d H:i:s")."','".
"0','".
date("Y:m:d H:i:s")."','".
"0',".
$ilDB->quote($_SESSION["AccountId"]).")";
$ilDB->query($query);
// 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 331 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: