1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-20 05:11:42 +02:00

Code clean-up (globals, $e107->, headers, $sql)

This commit is contained in:
Moc
2013-03-25 18:48:48 +01:00
parent 231dd00f27
commit 2074ef8f37
17 changed files with 106 additions and 121 deletions

View File

@@ -61,13 +61,13 @@ class list_forum
}
if(!$results = $this->parent->e107->sql->db_Select_gen($qry))
if(!$results = $this->parent->$sql->gen($qry))
{
$list_data = LIST_FORUM_2;
}
else
{
$forumArray = $this->parent->e107->sql->db_getList();
$forumArray = $this->parent->e107->$sql->getList();
$path = e_PLUGIN."forum/";
foreach($forumArray as $forumInfo)

View File

@@ -15,6 +15,7 @@ if(!defined('e107_INIT'))
}
$e107 = e107::getInstance();
$tp = e107::getParser();
$sql = e107::getDb();
if (!$e107->isInstalled('forum'))
{
@@ -419,9 +420,9 @@ if (e_QUERY == 'track')
WHERE thread_id IN({$trackedThreadList})
ORDER BY thread_lastpost DESC
";
if($e107->sql->db_Select_gen($qry))
if($sql->gen($qry))
{
while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
while($row = $sql->fetch(MYSQL_ASSOC))
{
$trackVars->NEWIMAGE = IMAGE_nonew_small;
if ($row['thread_datestamp'] > USERLV && !in_array($row['thread_id'], $viewed))

View File

@@ -2,14 +2,10 @@
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
*
* $URL$
* $Id$
*/
if (!defined('e107_INIT')) { exit(); }
@@ -18,6 +14,7 @@ include_lan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_admin.php');
function forum_thread_moderate($p)
{
$e107 = e107::getInstance();
$sql = e107::getDb();
foreach ($p as $key => $val)
{
if (preg_match("#(.*?)_(\d+)_x#", $key, $matches))
@@ -28,22 +25,22 @@ function forum_thread_moderate($p)
switch ($act)
{
case 'lock':
$e107->sql->db_Update('forum_thread', 'thread_active=0 WHERE thread_id='.$id);
$sql->update('forum_thread', 'thread_active=0 WHERE thread_id='.$id);
return FORLAN_CLOSE;
break;
case 'unlock':
$e107->sql->db_Update('forum_thread', 'thread_active=1 WHERE thread_id='.$id);
$sql->update('forum_thread', 'thread_active=1 WHERE thread_id='.$id);
return FORLAN_OPEN;
break;
case 'stick':
$e107->sql->db_Update('forum_thread', 'thread_sticky=1 WHERE thread_id='.$id);
$sql->update('forum_thread', 'thread_sticky=1 WHERE thread_id='.$id);
return FORLAN_STICK;
break;
case 'unstick':
$e107->sql->db_Update('forum_thread', 'thread_sticky=0 WHERE thread_id='.$id);
$sql->update('forum_thread', 'thread_sticky=0 WHERE thread_id='.$id);
return FORLAN_UNSTICK;
break;

View File

@@ -2,15 +2,12 @@
/*
* e107 website system
*
* Copyright (C) 2008-2011 e107 Inc (e107.org)
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Forum View Topic
*
* $URL$
* $Id$
*
*/
require_once ('../../class2.php');
@@ -641,6 +638,8 @@ class e107ForumThread
{
global $forum, $thread;
$e107 = e107::getInstance();
$ns = e107::getRender();
$sql = e107::getDb();
if (!isset($_GET['f']))
{
@@ -703,15 +702,15 @@ class e107ForumThread
sendemail(SITEADMINEMAIL, $subject, $report);
}
// no reference of 'head' $threadInfo['head']['thread_name']
$e107->sql->db_Insert('generic', "0, 'reported_post', " . time() . ", '" . USERID . "', '{$this->threadInfo['thread_name']}', " . intval($this->threadId) . ", '{$report_add}'");
$sql->insert('generic', "0, 'reported_post', " . time() . ", '" . USERID . "', '{$this->threadInfo['thread_name']}', " . intval($this->threadId) . ", '{$report_add}'");
define('e_PAGETITLE', LAN_01 . " / " . LAN_428);
$url = $e107->url->create('forum/thread/post', array('id' => $postId, 'name' => $postInfo['thread_name'], 'thread' => $threadId)); // both post info and thread info contain thread name
$text = LAN_424 . "<br /><br /><a href='{$url}'>" . LAN_429 . '</a>';
return $e107->ns->tablerender(LAN_414, $text, array('forum_viewtopic', 'report'), true);
return $ns->tablerender(LAN_414, $text, array('forum_viewtopic', 'report'), true);
}
else
{
$thread_name = $e107->tp->toHTML($postInfo['thread_name'], true, 'no_hook, emotes_off');
$thread_name = e107::getParser()->toHTML($postInfo['thread_name'], true, 'no_hook, emotes_off');
define('e_PAGETITLE', LAN_01 . ' / ' . LAN_426 . ' ' . $thread_name);
$url = $e107->url->create('forum/thread/post', array('id' => $postId, 'name' => $postInfo['thread_name'], 'thread' => $threadId));
$actionUrl = $e107->url->create('forum/thread/report', "id={$threadId}&post={$postId}");
@@ -740,7 +739,7 @@ class e107ForumThread
</td>
</tr>
</table>";
return $e107->ns->tablerender(LAN_414, $text, array('forum_viewtopic', 'report2'), true);
return e107::getRender()->tablerender(LAN_414, $text, array('forum_viewtopic', 'report2'), true);
}
// require_once (FOOTERF);
exit;

View File

@@ -2,14 +2,10 @@
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
*
* $URL$
* $Id$
*/
if (!defined('e107_INIT')) exit;
@@ -17,6 +13,7 @@ if (!defined('e107_INIT')) exit;
global $menu_pref;
$e107 = e107::getInstance();
$sql = e107::getDb();
$gen = new convert;
include_lan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_newforumposts_menu.php');
@@ -38,9 +35,9 @@ LEFT JOIN `#user` AS u ON u.user_id = p.post_user
WHERE {$maxage} p.post_forum IN ({$forumList})
ORDER BY p.post_datestamp DESC LIMIT 0, ".$menu_pref['newforumposts_display'];
if($results = $e107->sql->db_Select_gen($qry))
if($results = $sql->gen($qry))
{
while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
while($row = $sql->fetch(MYSQL_ASSOC))
{
$datestamp = $gen->convert_date($row['post_datestamp'], 'short');
$id = $row['thread_id'];
@@ -62,8 +59,8 @@ if($results = $e107->sql->db_Select_gen($qry))
}
}
$post = strip_tags($e107->tp->toHTML($row['post_entry'], true, 'emotes_off, no_make_clickable', '', $pref['menu_wordwrap']));
$post = $e107->tp->text_truncate($post, $menu_pref['newforumposts_characters'], $menu_pref['newforumposts_postfix']);
$post = strip_tags(e107::getParser()->toHTML($row['post_entry'], true, 'emotes_off, no_make_clickable', '', $pref['menu_wordwrap']));
$post = e107::getParser()->text_truncate($post, $menu_pref['newforumposts_characters'], $menu_pref['newforumposts_postfix']);
$url = $e107->url->create('forum/thread/last', $row);
//TODO legacy bullet is not use here anymore
@@ -84,4 +81,4 @@ else
{
$text = NFP_2;
}
$e107->ns->tablerender($menu_pref['newforumposts_caption'], $text, 'nfp_menu');
e107::getRender()->tablerender($menu_pref['newforumposts_caption'], $text, 'nfp_menu');

View File

@@ -15,8 +15,9 @@ class plugin_forum_post_shortcodes extends e_shortcode
{
$parm = ($parm ? $parm : 10);
global $LATESTPOSTS_START, $LATESTPOSTS_END, $LATESTPOSTS_POST;
$tp = e107::getParser();
$txt = $this->e107->tp->parseTemplate($LATESTPOSTS_START, true);
$txt = $tp->parseTemplate($LATESTPOSTS_START, true);
$start = max($this->threadInfo['thread_total_replies'] - $parm, 0);
$num = min($this->threadInfo['thread_total_replies'], $parm);
@@ -26,9 +27,9 @@ class plugin_forum_post_shortcodes extends e_shortcode
for($i = count($tmp); $i > 0; $i--)
{
$bach->setScVar('postInfo', $tmp[$i-1]);
$txt .= $this->e107->tp->parseTemplate($LATESTPOSTS_POST, true);
$txt .= $tp->parseTemplate($LATESTPOSTS_POST, true);
}
$txt .= $this->e107->tp->parseTemplate($LATESTPOSTS_END, true);
$txt .= $tp->parseTemplate($LATESTPOSTS_END, true);
return $txt;
}
@@ -37,7 +38,7 @@ class plugin_forum_post_shortcodes extends e_shortcode
global $THREADTOPIC_REPLY;
$tmp = $this->forum->postGet($this->threadInfo['thread_id'], 0, 1);
e107::getScBatch('view', 'forum')->setScVar('postInfo', $tmp[0]);
return $this->e107->tp->parseTemplate($THREADTOPIC_REPLY, true);
return e107::getParser()->parseTemplate($THREADTOPIC_REPLY, true);
}
function sc_formstart()

View File

@@ -55,7 +55,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
function sc_post()
{
$emote = (isset($this->postInfo['post_options']['no_emote']) ? ',emotes_off' : '');
return $this->e107->tp->toHTML($this->postInfo['post_entry'], true, 'USER_BODY'.$emote, 'class:'.$this->postInfo['user_class']);
return e107::getParser()->toHTML($this->postInfo['post_entry'], true, 'USER_BODY'.$emote, 'class:'.$this->postInfo['user_class']);
}
function sc_postdeleted()
@@ -108,7 +108,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
{
if(plugInstalled('pm') && ($this->postInfo['post_user'] > 0))
{
return $this->e107->tp->parseTemplate("{SENDPM={$this->postInfo['post_user']}}");
return e107::getParser()->parseTemplate("{SENDPM={$this->postInfo['post_user']}}");
}
}
@@ -164,7 +164,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
}
else
{
return '<b>'.$this->e107->tp->toHTML($this->postInfo['post_user_anon']).'</b>';
return '<b>'.e107::getParser()->toHTML($this->postInfo['post_user_anon']).'</b>';
}
}
@@ -173,7 +173,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
{
if($this->postInfo['user_name'])
{
return (!$this->postInfo['user_hideemail'] ? $this->e107->tp->parseTemplate("{EMAILTO={$this->postInfo['user_email']}}") : '');
return (!$this->postInfo['user_hideemail'] ? e107::getParser()->parseTemplate("{EMAILTO={$this->postInfo['user_email']}}") : '');
}
return '';
@@ -183,7 +183,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
{
if($this->postInfo['thread_start'])
{
return $this->e107->tp->parseTemplate("{EMAIL_ITEM=".FORLAN_101."^plugin:forum.{$this->postInfo['post_thread']}}");
return e107::getParser()->parseTemplate("{EMAIL_ITEM=".FORLAN_101."^plugin:forum.{$this->postInfo['post_thread']}}");
}
}
@@ -191,7 +191,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
{
if($this->postInfo['thread_start'])
{
return $this->e107->tp->parseTemplate("{PRINT_ITEM=".FORLAN_102."^plugin:forum.{$this->postInfo['post_thread']}}");
return e107::getParser()->parseTemplate("{PRINT_ITEM=".FORLAN_102."^plugin:forum.{$this->postInfo['post_thread']}}");
}
}
@@ -221,7 +221,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
{
if (USER && $this->postInfo['user_name'])
{
return $this->e107->tp->parseTemplate("{PROFILE={$this->postInfo['post_user']}}");
return e107::getParser()->parseTemplate("{PROFILE={$this->postInfo['post_user']}}");
}
}
@@ -245,7 +245,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
{
if ($this->postInfo['user_customtitle'])
{
return $this->e107->tp->toHTML($this->postInfo['user_customtitle']).'<br />';
return e107::getParser()->toHTML($this->postInfo['user_customtitle']).'<br />';
}
}