1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-15 03:56:20 +02:00

converted forum_post_shortcodes to class->method

This commit is contained in:
mcfly
2009-01-25 19:19:36 +00:00
parent 6633e23f94
commit 6d005ffaa8
2 changed files with 179 additions and 150 deletions

View File

@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_post.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_post.php,v $
| $Revision: 1.34 $ | $Revision: 1.35 $
| $Date: 2008-12-18 14:08:33 $ | $Date: 2009-01-25 19:19:36 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@ -78,17 +78,17 @@ if (!$forum->checkPerm($forumId, 'post'))
require_once(FOOTERF); require_once(FOOTERF);
exit; exit;
} }
define('MODERATOR', USER && $forum->isModerator(USERID));
define("MODERATOR", check_class($forum_info['forum_moderators']));
//require_once(e_HANDLER.'forum_include.php'); //require_once(e_HANDLER.'forum_include.php');
require_once(e_PLUGIN."forum/forum_post_shortcodes.php"); require_once(e_PLUGIN.'forum/forum_post_shortcodes.php');
require_once(e_PLUGIN."forum/forum_shortcodes.php"); require_once(e_PLUGIN.'forum/forum_shortcodes.php');
require_once(e_HANDLER."ren_help.php"); require_once(e_HANDLER.'ren_help.php');
setScVar('forum_post_shortcodes', 'forum', $forum);
setScVar('forum_post_shortcodes', 'threadInfo', $threadInfo);
$gen = new convert; $gen = new convert;
$fp = new floodprotect; $fp = new floodprotect;
$e107 = e107::getInstance(); $e107 = e107::getInstance();
//if thread is not active and not new thread, show warning //if thread is not active and not new thread, show warning
if ($action != 'nt' && !$threadInfo['thread_active'] && !MODERATOR) if ($action != 'nt' && !$threadInfo['thread_active'] && !MODERATOR)
{ {
@ -520,7 +520,9 @@ if($action == 'rp')
{ {
$FORUMPOST = $FORUMPOST_REPLY; $FORUMPOST = $FORUMPOST_REPLY;
} }
$text = $tp->parseTemplate($FORUMPOST, FALSE, $forum_post_shortcodes); $text = $tp->parseTemplate($FORUMPOST, true);
//$text = $tp->parseTemplate($FORUMPOST, FALSE, $forum_post_shortcodes);
// ------------------------------------------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -1,61 +1,81 @@
<?php <?php
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
include_once(e_HANDLER.'shortcode_handler.php'); register_shortcode('forum_post_shortcodes', true);
$forum_post_shortcodes = $tp -> e_sc -> parse_scbatch(__FILE__); initShortcodeClass('forum_post_shortcodes');
/* class forum_post_shortcodes
SC_BEGIN LATESTPOSTS
global $thread_info, $action, $gen, $tp, $forum_shortcodes, $post_info;
global $LATESTPOSTS_START, $LATESTPOSTS_END, $LATESTPOSTS_POST;
$txt = $tp->parseTemplate($LATESTPOSTS_START, TRUE, $forum_shortcodes);
for($i = count($thread_info)-2; $i>0; $i--)
{ {
$post_info = $thread_info[$i]; var $e107;
$txt .= $tp->parseTemplate($LATESTPOSTS_POST, TRUE, $forum_shortcodes); var $threadInfo;
var $forum;
function forum_post_shortcodes()
{
$this->e107 = e107::getInstance();
} }
$txt .= $tp->parseTemplate($LATESTPOSTS_END, TRUE, $forum_shortcodes);
function get_latestposts($parm)
{
$parm = ($parm ? $parm : 10);
global $LATESTPOSTS_START, $LATESTPOSTS_END, $LATESTPOSTS_POST;
$txt = $this->e107->tp->parseTemplate($LATESTPOSTS_START, true);
$start = max($this->threadInfo['thread_total_replies'] - $parm, 0);
$num = min($this->threadInfo['thread_total_replies'], $parm);
$tmp = $this->forum->postGet($this->threadInfo['thread_id'], $start, $num);
for($i = count($tmp)-1; $i > 0; $i--)
{
setScVar('forum_shortcodes', 'postInfo', $tmp[$i]);
$txt .= $this->e107->tp->parseTemplate($LATESTPOSTS_POST, true);
}
$txt .= $this->e107->tp->parseTemplate($LATESTPOSTS_END, true);
return $txt; return $txt;
SC_END }
function get_threadtopic()
{
global $THREADTOPIC_REPLY;
$tmp = $this->forum->postGet($this->threadInfo['thread_id'], 0, 1);
setScVar('forum_shortcodes', 'postInfo', $tmp[0]);
return $this->e107->tp->parseTemplate($THREADTOPIC_REPLY, true);
}
SC_BEGIN LATESTPOSTSCOUNT function get_forumstart()
return; // Null return as placeholder {
SC_END
SC_BEGIN THREADTOPIC
global $thread_info, $action, $gen, $tp, $post_info, $forum_shortcodes, $THREADTOPIC_REPLY;
$post_info = $thread_info['head'];
return $tp->parseTemplate($THREADTOPIC_REPLY, TRUE, $forum_shortcodes);
SC_END
SC_BEGIN FORMSTART
return "<form enctype='multipart/form-data' method='post' action='".e_SELF.'?'.e_QUERY."' id='dataform'>"; return "<form enctype='multipart/form-data' method='post' action='".e_SELF.'?'.e_QUERY."' id='dataform'>";
SC_END }
SC_BEGIN FORMEND function get_formend()
return "</form>"; {
SC_END return '</form>';
}
SC_BEGIN FORUMJUMP function get_forumjump()
{
return forumjump(); return forumjump();
SC_END }
SC_BEGIN USERBOX function get_userbox()
{
global $userbox; global $userbox;
return (USER == FALSE ? $userbox : ""); return (USER == false ? $userbox : '');
SC_END }
SC_BEGIN SUBJECTBOX function get_subjectbox()
{
global $subjectbox, $action; global $subjectbox, $action;
return ($action == 'nt' ? $subjectbox : ''); return ($action == 'nt' ? $subjectbox : '');
SC_END }
SC_BEGIN POSTTYPE function get_posttype()
{
global $action; global $action;
return ($action == "nt" ? LAN_63 : LAN_73); return ($action == 'nt' ? LAN_63 : LAN_73);
SC_END }
SC_BEGIN POSTBOX function get_postbox()
{
global $post, $pref; global $post, $pref;
$rows = (e_WYSIWYG) ? 15 : 10; $rows = (e_WYSIWYG) ? 15 : 10;
$ret = "<textarea class='tbox' id='post' name='post' cols='70' rows='{$rows}' style='width:95%' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'>$post</textarea>\n<br />\n"; $ret = "<textarea class='tbox' id='post' name='post' cols='70' rows='{$rows}' style='width:95%' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'>$post</textarea>\n<br />\n";
@ -64,12 +84,13 @@ if(!e_WYSIWYG)
$ret .= display_help('helpb', 'forum'); $ret .= display_help('helpb', 'forum');
} }
return $ret; return $ret;
SC_END }
SC_BEGIN BUTTONS function get_buttons()
{
global $action, $eaction; global $action, $eaction;
$ret = "<input class='button' type='submit' name='fpreview' value='".LAN_323."' /> "; $ret = "<input class='button' type='submit' name='fpreview' value='".LAN_323."' /> ";
if ($action != "nt") if ($action != 'nt')
{ {
$ret .= ($eaction ? "<input class='button' type='submit' name='update_reply' value='".LAN_78."' />" : "<input class='button' type='submit' name='reply' value='".LAN_74."' />"); $ret .= ($eaction ? "<input class='button' type='submit' name='update_reply' value='".LAN_78."' />" : "<input class='button' type='submit' name='reply' value='".LAN_74."' />");
} }
@ -78,9 +99,10 @@ else
$ret .= ($eaction ? "<input class='button' type='submit' name='update_thread' value='".LAN_77."' />" : "<input class='button' type='submit' name='newthread' value='".LAN_64."' />"); $ret .= ($eaction ? "<input class='button' type='submit' name='update_thread' value='".LAN_77."' />" : "<input class='button' type='submit' name='newthread' value='".LAN_64."' />");
} }
return $ret; return $ret;
SC_END }
SC_BEGIN FILEATTACH function get_fileattach()
{
global $pref, $fileattach, $fileattach_alert; global $pref, $fileattach, $fileattach_alert;
if ($pref['forum_attach'] && strpos(e_QUERY, 'edit') === FALSE && (check_class($pref['upload_class']) || getperms('0'))) if ($pref['forum_attach'] && strpos(e_QUERY, 'edit') === FALSE && (check_class($pref['upload_class']) || getperms('0')))
@ -91,7 +113,7 @@ if ($pref['forum_attach'] && strpos(e_QUERY, 'edit') === FALSE && (check_class($
} }
else else
{ {
$FILEATTACH = ""; $FILEATTACH = '';
if(ADMIN) if(ADMIN)
{ {
if(!$fileattach_alert) if(!$fileattach_alert)
@ -102,9 +124,10 @@ if ($pref['forum_attach'] && strpos(e_QUERY, 'edit') === FALSE && (check_class($
} }
} }
} }
SC_END }
SC_BEGIN POSTTHREADAS function get_postthreadas()
{
global $action, $thread_info; global $action, $thread_info;
if (MODERATOR && $action == "nt") if (MODERATOR && $action == "nt")
{ {
@ -112,20 +135,23 @@ if (MODERATOR && $action == "nt")
return "<br /><span class='defaulttext'>".LAN_400."<input name='threadtype' type='radio' value='0' ".(!$thread_sticky ? "checked='checked' " : "")." />".LAN_1."&nbsp;<input name='threadtype' type='radio' value='1' ".($thread_sticky == 1 ? "checked='checked' " : "")." />".LAN_2."&nbsp;<input name='threadtype' type='radio' value='2' ".($thread_sticky == 2 ? "checked='checked' " : "")." />".LAN_3."</span>"; return "<br /><span class='defaulttext'>".LAN_400."<input name='threadtype' type='radio' value='0' ".(!$thread_sticky ? "checked='checked' " : "")." />".LAN_1."&nbsp;<input name='threadtype' type='radio' value='1' ".($thread_sticky == 1 ? "checked='checked' " : "")." />".LAN_2."&nbsp;<input name='threadtype' type='radio' value='2' ".($thread_sticky == 2 ? "checked='checked' " : "")." />".LAN_3."</span>";
} }
return ''; return '';
SC_END }
SC_BEGIN BACKLINK function get_backlink()
{
global $forum, $thread_info,$eaction, $action,$BREADCRUMB; global $forum, $thread_info,$eaction, $action,$BREADCRUMB;
$forum->set_crumb(TRUE,($action == "nt" ? ($eaction ? LAN_77 : LAN_60) : ($eaction ? LAN_78 : LAN_406." ".$thread_info['head']['thread_name']))); $forum->set_crumb(TRUE,($action == "nt" ? ($eaction ? LAN_77 : LAN_60) : ($eaction ? LAN_78 : LAN_406." ".$thread_info['head']['thread_name'])));
return $BREADCRUMB; return $BREADCRUMB;
SC_END }
SC_BEGIN NOEMOTES function get_noemotes()
{
if($eaction == true) { return ; } if($eaction == true) { return ; }
return "<input type='checkbox' name='no_emote' value='1' />&nbsp;<span class='defaulttext'>".LAN_FORUMPOST_EMOTES.'</span>'; return "<input type='checkbox' name='no_emote' value='1' />&nbsp;<span class='defaulttext'>".LAN_FORUMPOST_EMOTES.'</span>';
SC_END }
SC_BEGIN EMAILNOTIFY function get_emailnotify()
{
global $pref, $thread_info, $action, $eaction; global $pref, $thread_info, $action, $eaction;
if($eaction == true) { return ; } if($eaction == true) { return ; }
if ($pref['email_notify'] && $action == 'nt' && USER) if ($pref['email_notify'] && $action == 'nt' && USER)
@ -148,16 +174,17 @@ if ($pref['email_notify'] && $action == 'nt' && USER)
return "<br /><input type='checkbox' name='email_notify' value='1' {$chk} />&nbsp;<span class='defaulttext'>".LAN_380."</span>"; return "<br /><input type='checkbox' name='email_notify' value='1' {$chk} />&nbsp;<span class='defaulttext'>".LAN_380."</span>";
} }
return ''; return '';
SC_END }
SC_BEGIN POLL function get_poll()
{
global $poll_form, $action, $pref; global $poll_form, $action, $pref;
if ($action == 'nt' && check_class($pref['forum_poll']) && strpos(e_QUERY, 'edit') === false) if ($action == 'nt' && check_class($pref['forum_poll']) && strpos(e_QUERY, 'edit') === false)
{ {
return $poll_form; return $poll_form;
} }
return ''; return '';
SC_END }
*/ }
?> ?>