ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilForumExplorer Class Reference

Class ilForumExplorer class for explorer view of forum posts. More...

+ Collaboration diagram for ilForumExplorer:

Public Member Functions

 __construct (ilObjForumGUI $gui, ilForumTopic $topic, ilForumProperties $properties)
 Constructor public.
 render ()
 fillTreeTemplate ()
 getHtml ()
 This method returns the tree html for the forum template public.

Static Public Member Functions

static getTreeNodeHtml ($object, ilObjForumGUI $gui, $pageHits)
 Returns the html used for a single forum tree node public.

Protected Attributes

 $tpl
 $gui
 $topic
 $properties
 $root_id

Detailed Description

Class ilForumExplorer class for explorer view of forum posts.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Nadia Ahmad nahma.nosp@m.d@da.nosp@m.tabay.nosp@m..de
Andreas Kordosz akord.nosp@m.osz@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

Definition at line 17 of file class.ilForumExplorer.php.

Constructor & Destructor Documentation

ilForumExplorer::__construct ( ilObjForumGUI  $gui,
ilForumTopic  $topic,
ilForumProperties  $properties 
)

Constructor public.

Definition at line 64 of file class.ilForumExplorer.php.

References $_SESSION, $gui, $ilCtrl, $properties, $topic, $tpl, ilYuiUtil\getLocalPath(), and ilYuiUtil\initConnection().

{
global $tpl, $ilCtrl;
$this->gui = $gui;
$this->topic = $topic;
$this->properties = $properties;
$this->tpl = new ilTemplate('tpl.frm_tree.html', true, true, 'Modules/Forum');
$tpl->addJavaScript(ilYuiUtil::getLocalPath() . '/yahoo/yahoo-min.js');
$tpl->addJavaScript(ilYuiUtil::getLocalPath() . '/event/event-min.js');
$tpl->addJavaScript('./Modules/Forum/js/treeview.js');
$tpl->addJavaScript('./Modules/Forum/js/treeview_extensions.js');
$tpl->addCss('./Modules/Forum/css/forum_tree.css');
// Set ref_id for urls
$ilCtrl->setParameter($this->gui, 'thr_pk', $this->topic->getId());
$ilCtrl->setParameter($this->gui, 'backurl', null);
// Set urls for async commands
$this->tpl->setVariable('THR_TREE_STATE_URL', $ilCtrl->getLinkTarget($this->gui, 'setTreeStateAsynch', '', true, false));
$this->tpl->setVariable('THR_TREE_FETCH_CHILDREN_URL', $ilCtrl->getLinkTarget($this->gui, 'fetchTreeChildrenAsync', '', true, false));
// Fetch root id of the thread node
$this->root_id = $this->topic->getFirstPostNode()->getId();
if(!is_array($_SESSION['frm'][$this->topic->getId()]['openTreeNodes']))
{
$_SESSION['frm'][(int)$this->topic->getId()]['openTreeNodes'] = array(0);
}
// Prevent key gaps
shuffle($_SESSION['frm'][(int)$this->topic->getId()]['openTreeNodes']);
}

+ Here is the call graph for this function:

Member Function Documentation

ilForumExplorer::fillTreeTemplate ( )

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

References $_SESSION, ilJsonUtil\encode(), and getTreeNodeHtml().

Referenced by render().

{
$emptyOnLoad = false;
$nodes_to_request = $_SESSION['frm'][(int)$this->topic->getId()]['openTreeNodes'];
if(!$_SESSION['frm'][(int)$this->topic->getId()]['openTreeNodes'] ||
(count($_SESSION['frm'][(int)$this->topic->getId()]['openTreeNodes']) == 1 && $_SESSION['frm'][(int)$this->topic->getId()]['openTreeNodes'][0] == 0))
{
$emptyOnLoad = true;
$nodes_to_request = array();
}
$objects = $this->topic->getNestedSetPostChildren(null, $nodes_to_request);
$counter = 0;
$onloadNodes = array();
$nodesFetchedWithChildren = array();
$frm = new ilForum();
$pageHits = $frm->getPageHits();
include_once 'Services/JSON/classes/class.ilJsonUtil.php';
foreach($objects as $object)
{
if($object['pos_pk'] != $this->root_id &&
!in_array($object['parent_pos'], $onloadNodes)
)
{
continue;
}
if(in_array((int)$object['parent_pos'], $onloadNodes) &&
!in_array((int)$object['parent_pos'], $nodesFetchedWithChildren)
)
{
$nodesFetchedWithChildren[] = (int)$object['parent_pos'];
}
$object, $this->gui, $pageHits
);
$hasChildren = ($object['children'] >= 1);
$node = new stdClass();
$node->html = $html;
if($object['pos_pk'] == $this->root_id)
{
$this->tpl->setVariable('FRM_TREE_ROOT_NODE_VARIABLE', 'frmNode' . $object['pos_pk']);
$this->tpl->setVariable('FRM_TREE_ROOT_NODE_LINK', ilJsonUtil::encode($node));
$this->tpl->setVariable('FRM_TREE_ROOT_NODE_HAS_CHILDREN', $hasChildren ? 'true' : 'false');
}
else
{
$this->tpl->setCurrentBlock('frm_nodes');
$this->tpl->setVariable('FRM_NODES_VARNAME', 'frmNode' . $object['pos_pk']);
$this->tpl->setVariable('FRM_NODES_PARENT_VARNAME', 'frmNode' . $object['parent_pos']);
$this->tpl->setVariable('FRM_NODES_LINK', ilJsonUtil::encode($node));
$this->tpl->setVariable('FRM_NODES_HAS_CHILDREN', $hasChildren ? 'true' : 'false');
$this->tpl->parseCurrentBlock();
}
$onloadNodes[] = (int)$object['pos_pk'];
++$counter;
}
$this->tpl->setVariable('THR_ONLOAD_NODES', ilJsonUtil::encode($onloadNodes));
$this->tpl->setVariable('THR_ONLOAD_NODES_FETCHED_WITH_CHILDREN', ilJsonUtil::encode($nodesFetchedWithChildren));
if($emptyOnLoad)
{
$this->tpl->setVariable('THR_OPEN_NODES', ilJsonUtil::encode($onloadNodes));
$_SESSION['frm'][(int)$this->topic->getId()]['openTreeNodes'] = array_unique(array_merge(array(0), $onloadNodes));
}
else
{
$this->tpl->setVariable('THR_OPEN_NODES', ilJsonUtil::encode($_SESSION['frm'][(int)$this->topic->getId()]['openTreeNodes']));
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForumExplorer::getHtml ( )

This method returns the tree html for the forum template public.

Returns
string

Definition at line 245 of file class.ilForumExplorer.php.

{
return $this->tpl->get();
}
static ilForumExplorer::getTreeNodeHtml (   $object,
ilObjForumGUI  $gui,
  $pageHits 
)
static

Returns the html used for a single forum tree node public.

Definition at line 197 of file class.ilForumExplorer.php.

References $ilCtrl, ilDatePresentation\formatDate(), and IL_CAL_DATETIME.

Referenced by ilObjForumGUI\fetchTreeChildrenAsyncObject(), and fillTreeTemplate().

{
global $ilCtrl;
$html = '';
// Set pos_pk for urls
$ilCtrl->setParameter($gui, 'pos_pk', $object['pos_pk']);
// Set offset
$ilCtrl->setParameter($gui, 'offset', floor($object['counter'] / $pageHits) * $pageHits);
// @todo: HTML in PHP used because of performance issues of ilTemplate an big forum trees
if($object['post_read'])
{
$url = $ilCtrl->getLinkTarget($gui, 'viewThread', $object['pos_pk']);
$link = "<a class='small' href='" . $url . "'>" . stripslashes($object['pos_subject']) . "</a>";
$html .= "<div class='frmTreeInfo'><span class='frmTitle' id='frm_node_" . $object['pos_pk'] . "'>" . $link . "</span><br />" .
"<span id='frm_node_desc_" . $object['pos_pk'] . "' class='small'>";
}
else
{
$url = $ilCtrl->getLinkTarget($gui, 'markPostRead', $object['pos_pk']);
$link = "<a class='small' href='" . $url . "'>" . stripslashes($object['pos_subject']) . "</a>";
$html .= "<div class='frmTreeInfo'><span class='frmTitleBold' id='frm_node_" . $object['pos_pk'] . "'>" . $link . "</span><br />" .
"<span id='frm_node_desc_" . $object['pos_pk'] . "' class='small'>";
}
require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
$authorinfo = new ilForumAuthorInformation(
$object['pos_usr_id'],
$object['pos_usr_alias'],
$object['import_name']
);
$html .= $authorinfo->getAuthorShortName();
$html .= ", " . ilDatePresentation::formatDate(new ilDateTime($object['pos_date'], IL_CAL_DATETIME)) . "</span></div>";
return $html;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilForumExplorer::render ( )

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

References fillTreeTemplate().

{
$this->fillTreeTemplate();
return $this;
}

+ Here is the call graph for this function:

Field Documentation

ilForumExplorer::$gui
protected

Definition at line 33 of file class.ilForumExplorer.php.

Referenced by __construct().

ilForumExplorer::$properties
protected

Definition at line 49 of file class.ilForumExplorer.php.

Referenced by __construct().

ilForumExplorer::$root_id
protected

Definition at line 57 of file class.ilForumExplorer.php.

ilForumExplorer::$topic
protected

Definition at line 41 of file class.ilForumExplorer.php.

Referenced by __construct().

ilForumExplorer::$tpl
protected

Definition at line 25 of file class.ilForumExplorer.php.

Referenced by __construct().


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