Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

newforumpostsmenu update #5340

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 33 additions & 32 deletions e107_plugins/forum/newforumposts_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

include_once(e_PLUGIN.'forum/forum_class.php');



if(!class_exists('forum_newforumposts_menu'))
{
class forum_newforumposts_menu // plugin folder + menu name (without the .php)
Expand All @@ -31,8 +29,14 @@ class forum_newforumposts_menu // plugin folder + menu name (without the .php)
function __construct()
{
$this->plugPref = e107::pref('forum'); // general forum preferences.
$this->menuPref = e107::getMenu()->pref();// ie. popup config details from within menu-manager.
$this->forumObj = new e107forum;
// $this->menuPref = e107::getMenu()->pref();// ie. popup config details from within menu-manager.
$menuPrefs = e107::getMenu()->pref();// ie. popup config details from within menu-manager.
$this->forumObj = new e107forum;

parse_str($menuPrefs, $this->menuPref);

// echo "<hr><hr><hr>";
// var_dump($this->menuPref);

// Set some defaults ...
if (!isset($this->menuPref['title'])) $this->menuPref['title'] = "";
Expand All @@ -43,8 +47,10 @@ function __construct()
if (!isset($this->menuPref['scroll'])) $this->menuPref['scroll'] = "";
if (empty($this->menuPref['layout'])) $this->menuPref['layout'] = 'default';

$this->cacheTag .= "_".$this->menuPref['layout'];
// echo "<hr><hr><hr>";
// var_dump($this->menuPref);

$this->cacheTag .= "_".$this->menuPref['layout'];

if($text = e107::getCache()->retrieve($this->cacheTag, $this->cacheTime, true))
{
Expand All @@ -54,6 +60,7 @@ function __construct()
return null;
}

/*
$sql = e107::getDb();

$this->total['topics'] = $sql->count("forum_thread");
Expand All @@ -64,14 +71,11 @@ function __construct()
$tmp = $sql->fetch();
$this->total['views'] = intval($tmp["sum"]);
}

*/
$this->render();

}




private function getQuery()
{
$max_age = vartrue($this->menuPref['maxage'], 0);
Expand All @@ -86,7 +90,6 @@ private function getQuery()
return false;
}


$this->menuPref['layout'] = vartrue($this->menuPref['layout'], 'default');
switch($this->menuPref['layout'])
{
Expand Down Expand Up @@ -132,11 +135,9 @@ private function getQuery()
ORDER BY t.thread_lastpost DESC LIMIT 0, ".vartrue($this->menuPref['display'],10);
}


return $qry;
}


private function render()
{
$tp = e107::getParser();
Expand Down Expand Up @@ -164,17 +165,13 @@ private function render()

$template = e107::getTemplate('forum','newforumposts_menu',$layout);




$param = array();

foreach($this->menuPref as $k=>$v)
{
$param['nfp_'.$k] = $v;
}


if($qry)
{
if($results = $sql->gen($qry))
Expand All @@ -186,22 +183,34 @@ private function render()

$sc = e107::getScBatch('view', 'forum')->setScVar('param',$param);

$list = $tp->parseTemplate($template['start'], true);
// $list = $tp->parseTemplate($template['start'], true);
$text = $tp->parseTemplate($template['start'], true);

while($row = $sql->fetch())
{
// var_dump ($row);
// echo "<hr>";

$row['thread_sef'] = $this->forumObj->getThreadSef($row);

$sc->setScVar('postInfo', $row);
$sc->setVars($row);
$list .= $tp->parseTemplate($template['item'], true, $sc);
}
// $list .= $tp->parseTemplate($template['item'], true, $sc);
$text .= $tp->parseTemplate($template['item'], true, $sc);

$TOTALS = array('TOTAL_TOPICS'=>$this->total['topics'], 'TOTAL_VIEWS'=>$this->total['views'], 'TOTAL_REPLIES'=>$this->total['replies']);
++$total_topics;
$total_views += $row['thread_views'];
$total_replies += $row['thread_total_replies'];

$list .= $tp->parseTemplate($template['end'], true, $TOTALS);
}

// $TOTALS = array('TOTAL_TOPICS'=>$this->total['topics'], 'TOTAL_VIEWS'=>$this->total['views'], 'TOTAL_REPLIES'=>$this->total['replies']);
$TOTALS = array('TOTAL_TOPICS'=>$total_topics, 'TOTAL_VIEWS'=>$total_views, 'TOTAL_REPLIES'=>$total_replies);

$text = $list;
// $list .= $tp->parseTemplate($template['end'], true, $TOTALS);
$text .= $tp->parseTemplate($template['end'], true, $TOTALS);
//
// $text = $list;
}
else
{
Expand All @@ -212,7 +221,7 @@ private function render()
{
$text = LAN_FORUM_MENU_016;
}

//var_dump ($text);
$caption = $this->getCaption();

if(!empty($this->menuPref['scroll']))
Expand All @@ -221,7 +230,6 @@ private function render()
}
// e107::debug('menuPref', $this->menuPref);


e107::getCache()->set($this->cacheTag, $text, true);

$ns->tablerender($caption, $text, 'nfp_menu');
Expand Down Expand Up @@ -252,7 +260,6 @@ private function getCaption()
//$caption = !empty($this->menuPref['caption'][e_LANGUAGE]) ? $this->menuPref['caption'][e_LANGUAGE] : $this->menuPref['caption'];
}


if (empty($caption))
{
$caption = LAN_PLUGIN_FORUM_LATESTPOSTS;
Expand All @@ -261,14 +268,8 @@ private function getCaption()
return $caption;
}


}


}


new forum_newforumposts_menu;



new forum_newforumposts_menu;
14 changes: 11 additions & 3 deletions e107_plugins/forum/shortcodes/batch/view_shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,26 @@ function sc_topic_url($parm = null)

function sc_topic_views($parm = null)
{

$val = ($this->var['thread_views']) ? $this->var['thread_views'] : '0';


if(!empty($parm['raw']))
{
return $val;
}

return e107::getParser()->toBadge($val);
}


function sc_topic_replies($parm = null)
{

$val = ($this->var['thread_total_replies']) ? $this->var['thread_total_replies'] : '0';

if(!empty($parm['raw']))
{
return $val;
}

return e107::getParser()->toBadge($val);
}

Expand Down
Loading