1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-20 04:32:01 +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).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_post.php,v $
| $Revision: 1.34 $
| $Date: 2008-12-18 14:08:33 $
| $Revision: 1.35 $
| $Date: 2009-01-25 19:19:36 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@ -78,17 +78,17 @@ if (!$forum->checkPerm($forumId, 'post'))
require_once(FOOTERF);
exit;
}
define("MODERATOR", check_class($forum_info['forum_moderators']));
define('MODERATOR', USER && $forum->isModerator(USERID));
//require_once(e_HANDLER.'forum_include.php');
require_once(e_PLUGIN."forum/forum_post_shortcodes.php");
require_once(e_PLUGIN."forum/forum_shortcodes.php");
require_once(e_HANDLER."ren_help.php");
require_once(e_PLUGIN.'forum/forum_post_shortcodes.php');
require_once(e_PLUGIN.'forum/forum_shortcodes.php');
require_once(e_HANDLER.'ren_help.php');
setScVar('forum_post_shortcodes', 'forum', $forum);
setScVar('forum_post_shortcodes', 'threadInfo', $threadInfo);
$gen = new convert;
$fp = new floodprotect;
$e107 = e107::getInstance();
//if thread is not active and not new thread, show warning
if ($action != 'nt' && !$threadInfo['thread_active'] && !MODERATOR)
{
@ -520,7 +520,9 @@ if($action == 'rp')
{
$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,163 +1,190 @@
<?php
if (!defined('e107_INIT')) { exit; }
include_once(e_HANDLER.'shortcode_handler.php');
$forum_post_shortcodes = $tp -> e_sc -> parse_scbatch(__FILE__);
register_shortcode('forum_post_shortcodes', true);
initShortcodeClass('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--)
class forum_post_shortcodes
{
$post_info = $thread_info[$i];
$txt .= $tp->parseTemplate($LATESTPOSTS_POST, TRUE, $forum_shortcodes);
}
$txt .= $tp->parseTemplate($LATESTPOSTS_END, TRUE, $forum_shortcodes);
return $txt;
SC_END
SC_BEGIN LATESTPOSTSCOUNT
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'>";
SC_END
SC_BEGIN FORMEND
return "</form>";
SC_END
SC_BEGIN FORUMJUMP
return forumjump();
SC_END
SC_BEGIN USERBOX
global $userbox;
return (USER == FALSE ? $userbox : "");
SC_END
SC_BEGIN SUBJECTBOX
global $subjectbox, $action;
return ($action == 'nt' ? $subjectbox : '');
SC_END
SC_BEGIN POSTTYPE
global $action;
return ($action == "nt" ? LAN_63 : LAN_73);
SC_END
SC_BEGIN POSTBOX
global $post, $pref;
$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";
if(!e_WYSIWYG)
{
$ret .= display_help('helpb', 'forum');
}
return $ret;
SC_END
SC_BEGIN BUTTONS
global $action, $eaction;
$ret = "<input class='button' type='submit' name='fpreview' value='".LAN_323."' /> ";
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."' />");
}
else
{
$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;
SC_END
SC_BEGIN FILEATTACH
global $pref, $fileattach, $fileattach_alert;
if ($pref['forum_attach'] && strpos(e_QUERY, 'edit') === FALSE && (check_class($pref['upload_class']) || getperms('0')))
{
if (is_writable(e_FILE.'public'))
var $e107;
var $threadInfo;
var $forum;
function forum_post_shortcodes()
{
return $fileattach;
$this->e107 = e107::getInstance();
}
else
function get_latestposts($parm)
{
$FILEATTACH = "";
if(ADMIN)
$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--)
{
if(!$fileattach_alert)
{
$fileattach_alert = "<tr><td colspan='2' class='nforumcaption2'>".($pref['image_post'] ? LAN_390 : LAN_416)."</td></tr><tr><td colspan='2' class='forumheader3'>".LAN_FORUM_1."</td></tr>\n";
}
return $fileattach_alert;
setScVar('forum_shortcodes', 'postInfo', $tmp[$i]);
$txt .= $this->e107->tp->parseTemplate($LATESTPOSTS_POST, true);
}
$txt .= $this->e107->tp->parseTemplate($LATESTPOSTS_END, true);
return $txt;
}
}
SC_END
SC_BEGIN POSTTHREADAS
global $action, $thread_info;
if (MODERATOR && $action == "nt")
{
$thread_sticky = (isset($_POST['threadtype']) ? $_POST['threadtype'] : $thread_info['head']['thread_sticky']);
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 '';
SC_END
SC_BEGIN BACKLINK
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'])));
return $BREADCRUMB;
SC_END
SC_BEGIN NOEMOTES
if($eaction == true) { return ; }
return "<input type='checkbox' name='no_emote' value='1' />&nbsp;<span class='defaulttext'>".LAN_FORUMPOST_EMOTES.'</span>';
SC_END
SC_BEGIN EMAILNOTIFY
global $pref, $thread_info, $action, $eaction;
if($eaction == true) { return ; }
if ($pref['email_notify'] && $action == 'nt' && USER)
{
if(isset($_POST['fpreview']))
function get_threadtopic()
{
$chk = ($_POST['email_notify'] ? "checked = 'checked'" : '');
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);
}
else
function get_forumstart()
{
if(isset($thread_info))
return "<form enctype='multipart/form-data' method='post' action='".e_SELF.'?'.e_QUERY."' id='dataform'>";
}
function get_formend()
{
return '</form>';
}
function get_forumjump()
{
return forumjump();
}
function get_userbox()
{
global $userbox;
return (USER == false ? $userbox : '');
}
function get_subjectbox()
{
global $subjectbox, $action;
return ($action == 'nt' ? $subjectbox : '');
}
function get_posttype()
{
global $action;
return ($action == 'nt' ? LAN_63 : LAN_73);
}
function get_postbox()
{
global $post, $pref;
$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";
if(!e_WYSIWYG)
{
$chk = ($thread_info['head']['thread_active'] == 99 ? "checked='checked'" : '');
$ret .= display_help('helpb', 'forum');
}
return $ret;
}
function get_buttons()
{
global $action, $eaction;
$ret = "<input class='button' type='submit' name='fpreview' value='".LAN_323."' /> ";
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."' />");
}
else
{
$chk = ($pref['email_notify_on'] ? "checked='checked'" : '');
$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;
}
function get_fileattach()
{
global $pref, $fileattach, $fileattach_alert;
if ($pref['forum_attach'] && strpos(e_QUERY, 'edit') === FALSE && (check_class($pref['upload_class']) || getperms('0')))
{
if (is_writable(e_FILE.'public'))
{
return $fileattach;
}
else
{
$FILEATTACH = '';
if(ADMIN)
{
if(!$fileattach_alert)
{
$fileattach_alert = "<tr><td colspan='2' class='nforumcaption2'>".($pref['image_post'] ? LAN_390 : LAN_416)."</td></tr><tr><td colspan='2' class='forumheader3'>".LAN_FORUM_1."</td></tr>\n";
}
return $fileattach_alert;
}
}
}
}
return "<br /><input type='checkbox' name='email_notify' value='1' {$chk} />&nbsp;<span class='defaulttext'>".LAN_380."</span>";
}
return '';
SC_END
function get_postthreadas()
{
global $action, $thread_info;
if (MODERATOR && $action == "nt")
{
$thread_sticky = (isset($_POST['threadtype']) ? $_POST['threadtype'] : $thread_info['head']['thread_sticky']);
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 '';
}
function get_backlink()
{
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'])));
return $BREADCRUMB;
}
function get_noemotes()
{
if($eaction == true) { return ; }
return "<input type='checkbox' name='no_emote' value='1' />&nbsp;<span class='defaulttext'>".LAN_FORUMPOST_EMOTES.'</span>';
}
function get_emailnotify()
{
global $pref, $thread_info, $action, $eaction;
if($eaction == true) { return ; }
if ($pref['email_notify'] && $action == 'nt' && USER)
{
if(isset($_POST['fpreview']))
{
$chk = ($_POST['email_notify'] ? "checked = 'checked'" : '');
}
else
{
if(isset($thread_info))
{
$chk = ($thread_info['head']['thread_active'] == 99 ? "checked='checked'" : '');
}
else
{
$chk = ($pref['email_notify_on'] ? "checked='checked'" : '');
}
}
return "<br /><input type='checkbox' name='email_notify' value='1' {$chk} />&nbsp;<span class='defaulttext'>".LAN_380."</span>";
}
return '';
}
function get_poll()
{
global $poll_form, $action, $pref;
if ($action == 'nt' && check_class($pref['forum_poll']) && strpos(e_QUERY, 'edit') === false)
{
return $poll_form;
}
return '';
}
SC_BEGIN POLL
global $poll_form, $action, $pref;
if ($action == 'nt' && check_class($pref['forum_poll']) && strpos(e_QUERY, 'edit') === false)
{
return $poll_form;
}
return '';
SC_END
*/
}
?>