1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-15 12:06:19 +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,97 +1,119 @@
<?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;
$txt .= $tp->parseTemplate($LATESTPOSTS_END, TRUE, $forum_shortcodes);
return $txt;
SC_END
function forum_post_shortcodes()
{
$this->e107 = e107::getInstance();
}
SC_BEGIN LATESTPOSTSCOUNT function get_latestposts($parm)
return; // Null return as placeholder {
SC_END $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);
SC_BEGIN THREADTOPIC $tmp = $this->forum->postGet($this->threadInfo['thread_id'], $start, $num);
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 for($i = count($tmp)-1; $i > 0; $i--)
return "<form enctype='multipart/form-data' method='post' action='".e_SELF.'?'.e_QUERY."' id='dataform'>"; {
SC_END 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_BEGIN FORMEND function get_threadtopic()
return "</form>"; {
SC_END 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 FORUMJUMP function get_forumstart()
return forumjump(); {
SC_END return "<form enctype='multipart/form-data' method='post' action='".e_SELF.'?'.e_QUERY."' id='dataform'>";
}
SC_BEGIN USERBOX function get_formend()
global $userbox; {
return (USER == FALSE ? $userbox : ""); return '</form>';
SC_END }
SC_BEGIN SUBJECTBOX function get_forumjump()
global $subjectbox, $action; {
return ($action == 'nt' ? $subjectbox : ''); return forumjump();
SC_END }
SC_BEGIN POSTTYPE function get_userbox()
global $action; {
return ($action == "nt" ? LAN_63 : LAN_73); global $userbox;
SC_END return (USER == false ? $userbox : '');
}
SC_BEGIN POSTBOX function get_subjectbox()
global $post, $pref; {
$rows = (e_WYSIWYG) ? 15 : 10; global $subjectbox, $action;
$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"; return ($action == 'nt' ? $subjectbox : '');
if(!e_WYSIWYG) }
{
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)
{
$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; {
$ret = "<input class='button' type='submit' name='fpreview' value='".LAN_323."' /> "; global $action, $eaction;
if ($action != "nt") $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."' />"); $ret .= ($eaction ? "<input class='button' type='submit' name='update_reply' value='".LAN_78."' />" : "<input class='button' type='submit' name='reply' value='".LAN_74."' />");
} }
else 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')))
{ {
if (is_writable(e_FILE.'public')) if (is_writable(e_FILE.'public'))
{ {
return $fileattach; return $fileattach;
} }
else else
{ {
$FILEATTACH = ""; $FILEATTACH = '';
if(ADMIN) if(ADMIN)
{ {
if(!$fileattach_alert) if(!$fileattach_alert)
@ -101,35 +123,39 @@ if ($pref['forum_attach'] && strpos(e_QUERY, 'edit') === FALSE && (check_class($
return $fileattach_alert; return $fileattach_alert;
} }
} }
} }
SC_END }
SC_BEGIN POSTTHREADAS function get_postthreadas()
global $action, $thread_info; {
if (MODERATOR && $action == "nt") global $action, $thread_info;
{ if (MODERATOR && $action == "nt")
{
$thread_sticky = (isset($_POST['threadtype']) ? $_POST['threadtype'] : $thread_info['head']['thread_sticky']); $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 "<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; {
$forum->set_crumb(TRUE,($action == "nt" ? ($eaction ? LAN_77 : LAN_60) : ($eaction ? LAN_78 : LAN_406." ".$thread_info['head']['thread_name']))); global $forum, $thread_info,$eaction, $action,$BREADCRUMB;
return $BREADCRUMB; $forum->set_crumb(TRUE,($action == "nt" ? ($eaction ? LAN_77 : LAN_60) : ($eaction ? LAN_78 : LAN_406." ".$thread_info['head']['thread_name'])));
SC_END return $BREADCRUMB;
}
SC_BEGIN NOEMOTES function get_noemotes()
if($eaction == true) { return ; } {
return "<input type='checkbox' name='no_emote' value='1' />&nbsp;<span class='defaulttext'>".LAN_FORUMPOST_EMOTES.'</span>'; if($eaction == true) { return ; }
SC_END return "<input type='checkbox' name='no_emote' value='1' />&nbsp;<span class='defaulttext'>".LAN_FORUMPOST_EMOTES.'</span>';
}
SC_BEGIN EMAILNOTIFY function get_emailnotify()
global $pref, $thread_info, $action, $eaction; {
if($eaction == true) { return ; } global $pref, $thread_info, $action, $eaction;
if ($pref['email_notify'] && $action == 'nt' && USER) if($eaction == true) { return ; }
{ if ($pref['email_notify'] && $action == 'nt' && USER)
{
if(isset($_POST['fpreview'])) if(isset($_POST['fpreview']))
{ {
$chk = ($_POST['email_notify'] ? "checked = 'checked'" : ''); $chk = ($_POST['email_notify'] ? "checked = 'checked'" : '');
@ -146,18 +172,19 @@ 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; {
if ($action == 'nt' && check_class($pref['forum_poll']) && strpos(e_QUERY, 'edit') === false) global $poll_form, $action, $pref;
{ if ($action == 'nt' && check_class($pref['forum_poll']) && strpos(e_QUERY, 'edit') === false)
{
return $poll_form; return $poll_form;
} }
return ''; return '';
SC_END }
*/ }
?> ?>