1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 13:17:24 +02:00

Coverted forum shortcodes to new class->method use

This commit is contained in:
mcfly
2009-01-10 04:39:54 +00:00
parent fddee6174c
commit b70b956148
3 changed files with 376 additions and 330 deletions

View File

@@ -9,8 +9,8 @@
* mySQL Handler * mySQL Handler
* *
* $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $ * $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $
* $Revision: 1.35 $ * $Revision: 1.36 $
* $Date: 2009-01-09 16:22:08 $ * $Date: 2009-01-10 04:39:54 $
* $Author: mcfly_e107 $ * $Author: mcfly_e107 $
*/ */
@@ -44,7 +44,7 @@ $db_ConnectionID = NULL; // Stores ID for the first DB connection used - which s
* MySQL Abstraction class * MySQL Abstraction class
* *
* @package e107 * @package e107
* @version $Revision: 1.35 $ * @version $Revision: 1.36 $
* @author $Author: mcfly_e107 $ * @author $Author: mcfly_e107 $
*/ */
class db { class db {
@@ -415,7 +415,6 @@ class db {
unset($_tmp); unset($_tmp);
} }
if(!isset($arg['data'])) { return false; } if(!isset($arg['data'])) { return false; }
var_dump($arg);
$fieldTypes = $this->_getTypes($arg); $fieldTypes = $this->_getTypes($arg);
foreach ($arg['data'] as $fn => $fv) foreach ($arg['data'] as $fn => $fv)

View File

@@ -9,8 +9,8 @@
* Message Handler * Message Handler
* *
* $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_class.php,v $ * $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_class.php,v $
* $Revision: 1.36 $ * $Revision: 1.37 $
* $Date: 2009-01-09 16:22:08 $ * $Date: 2009-01-10 04:39:54 $
* $Author: mcfly_e107 $ * $Author: mcfly_e107 $
* *
*/ */
@@ -155,6 +155,8 @@ class e107forum
$result = false; $result = false;
$e107 = e107::getInstance(); $e107 = e107::getInstance();
$info = array();
$info['_FIELD_TYPES'] = $this->fieldTypes['forum_post'];
$info['data'] = $postInfo; $info['data'] = $postInfo;
$postId = $e107->sql->db_Insert('forum_post', $info); $postId = $e107->sql->db_Insert('forum_post', $info);
$forumInfo = array(); $forumInfo = array();
@@ -241,10 +243,7 @@ class e107forum
$info['data'] = $threadInfo; $info['data'] = $threadInfo;
if($newThreadId = $e107->sql->db_Insert('forum_thread', $info)) if($newThreadId = $e107->sql->db_Insert('forum_thread', $info))
{ {
$info = array(); $postInfo['post_thread'] = $newThreadId;
$info['_FIELD_TYPES'] = $this->fieldTypes['forum_post'];
$info['data'] = $postInfo;
$info['data']['post_thread'] = $newThreadId;
$newPostId = $this->postAdd($postInfo, false); $newPostId = $this->postAdd($postInfo, false);
$this->threadMarkAsRead($newThreadId); $this->threadMarkAsRead($newThreadId);
return array('postid' => $newPostId, 'threadid' => $newThreadId); return array('postid' => $newPostId, 'threadid' => $newThreadId);

View File

@@ -1,51 +1,82 @@
<?php <?php
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
include_once(e_HANDLER.'shortcode_handler.php');
$forum_shortcodes = $tp -> e_sc -> parse_scbatch(__FILE__);
/* /*
SC_BEGIN TOP $codes = array(
return "<a href='".e_SELF."?".e_QUERY."#top' onclick=\"window.scrollTo(0,0);\">".LAN_10."</a>"; 'top','joined','threaddatestamp','post','postdeleted','attachments','privmessage',
SC_END 'avatar','anon_ip','ip','poster','emailimg','emailitem','signature','profileimg',
'posts','visits','customtitle','website','websiteimg','editimg','quoteimg','reportimg',
'rpg','memberid','level','modoptions','lastedit','lasteditby','poll','newflag'
);
*/
SC_BEGIN JOINED $codes = array();
global $postInfo, $gen; $tmp = get_class_methods('forum_shortcodes');
if ($postInfo['post_user']) foreach($tmp as $c)
{ {
return LAN_06.': '.$gen->convert_date($postInfo['user_join'], 'forum').'<br />'; if(strpos($c, 'get_') === 0)
{
$codes[] = substr($c, 4);
}
} }
SC_END register_shortcode('forum_shortcodes', $codes);
SC_BEGIN THREADDATESTAMP class forum_shortcodes
global $postInfo, $gen;
$e107 = e107::getInstance();
return "<a id='post_{$post_info['post_id']}' href='".$e107->url->getUrl('forum', 'thread', array('func' => 'post', 'id' => $postInfo['post_id']))."'>".IMAGE_post."</a> ".$gen->convert_date($postInfo['post_datestamp'], 'forum');
SC_END
SC_BEGIN POST
global $postInfo;
$e107 = e107::getInstance();
$emote = (isset($postInfo['post_options']['no_emote']) ? ',emotes_off' : '');
return $e107->tp->toHTML($postInfo['post_entry'], true, 'USER_BODY'.$emote, 'class:'.$post_info['user_class']);
SC_END
SC_BEGIN POSTDELETED
global $postInfo;
if($postInfo['post_status'])
{ {
var $e107;
function forum_shortcodes()
{
$this->e107 = e107::getInstance();
}
function get_top()
{
return "<a href='".e_SELF.'?'.e_QUERY."#top' onclick=\"window.scrollTo(0,0);\">".LAN_10.'</a>';
}
function get_joined()
{
global $postInfo, $gen;
if ($postInfo['post_user'])
{
return LAN_06.': '.$gen->convert_date($postInfo['user_join'], 'forum').'<br />';
}
}
function get_threaddatestamp()
{
global $postInfo, $gen;
return "<a id='post_{$post_info['post_id']}' href='".$this->e107->url->getUrl('forum', 'thread', array('func' => 'post', 'id' => $postInfo['post_id']))."'>".IMAGE_post."</a> ".$gen->convert_date($postInfo['post_datestamp'], 'forum');
}
function get_post()
{
global $postInfo;
$emote = (isset($postInfo['post_options']['no_emote']) ? ',emotes_off' : '');
return $this->e107->tp->toHTML($postInfo['post_entry'], true, 'USER_BODY'.$emote, 'class:'.$post_info['user_class']);
}
function get_postdeleted()
{
global $postInfo;
if($postInfo['post_status'])
{
$info = unserialize($postInfo['post_options']); $info = unserialize($postInfo['post_options']);
return " return "
Post delete on: {$info['deldate']}<br /> Post delete on: {$info['deldate']}<br />
reason: {$info['delreason']} reason: {$info['delreason']}
"; ";
$ret = '<pre>'.print_r($info, true).'</pre>'; $ret = '<pre>'.print_r($info, true).'</pre>';
} }
SC_END }
SC_BEGIN ATTACHMENTS function get_attachments()
global $postInfo; {
$e107 = e107::getInstance(); global $postInfo;
if($postInfo['post_attachments']) if($postInfo['post_attachments'])
{ {
$attachments = explode(',', $postInfo['post_attachments']); $attachments = explode(',', $postInfo['post_attachments']);
$txt = ''; $txt = '';
foreach($attachments as $a) foreach($attachments as $a)
@@ -70,21 +101,24 @@ if($postInfo['post_attachments'])
} }
} }
return $txt; return $txt;
} }
SC_END
SC_BEGIN PRIVMESSAGE }
global $postInfo, $tp;
if(plugInstalled('pm') && ($postInfo['post_user'] > 0))
{
return $tp->parseTemplate("{SENDPM={$postInfo['post_user']}}");
}
SC_END
SC_BEGIN AVATAR function get_privmessage()
global $postInfo; {
if ($postInfo['post_user']) global $postInfo;
{ if(plugInstalled('pm') && ($postInfo['post_user'] > 0))
{
return $this->e107->tp->parseTemplate("{SENDPM={$postInfo['post_user']}}");
}
}
function get_avatar()
{
global $postInfo;
if ($postInfo['post_user'])
{
if(!$avatar = getcachedvars('forum_avatar_'.$postInfo['post_user'])) if(!$avatar = getcachedvars('forum_avatar_'.$postInfo['post_user']))
{ {
if ($postInfo['user_image']) if ($postInfo['user_image'])
@@ -99,230 +133,243 @@ if ($postInfo['post_user'])
cachevars('forum_avatar_'.$postInfo['post_user'], $avatar); cachevars('forum_avatar_'.$postInfo['post_user'], $avatar);
} }
return $avatar; return $avatar;
} }
return ''; return '';
SC_END
SC_BEGIN ANON_IP }
global $postInfo;
$e107 = e107::getInstance();
if($postInfo['post_user_anon'] && (ADMIN || MODERATOR))
{
return $e107->ipDecode($postInfo['post_ip']);
}
SC_END
SC_BEGIN IP function get_anon_ip()
global $postInfo; {
$e107 = e107::getInstance(); global $postInfo;
if((ADMIN || MODERATOR) && !$postInfo['user_admin']) if($postInfo['post_user_anon'] && (ADMIN || MODERATOR))
{ {
return $e107->ipDecode($postInfo['post_ip']); return $this->e107->ipDecode($postInfo['post_ip']);
} }
SC_END }
SC_BEGIN POSTER function get_ip()
global $postInfo; {
$e107 = e107::getInstance(); global $postInfo;
if($postInfo['user_name']) if((ADMIN || MODERATOR) && !$postInfo['user_admin'])
{ {
return "<a href='".$e107->url->getUrl('core:user', 'main', array('func' => 'profile', 'id' => $postInfo['post_user']))."'>{$postInfo['user_name']}</a>"; return $this->e107->ipDecode($postInfo['post_ip']);
} }
else
{
return '<b>'.$e107->tp->toHTML($postInfo['post_user_anon']).'</b>';
}
SC_END
SC_BEGIN EMAILIMG }
global $postInfo;
$e107 = e107::getInstance();
if($postInfo['user_name'])
{
return (!$post_info['user_hideemail'] ? $e107->tp->parseTemplate("{EMAILTO={$postInfo['user_email']}}") : '');
}
return '';
SC_END
SC_BEGIN EMAILITEM function get_poster()
global $postInfo, $tp; {
if($postInfo['thread_start']) global $postInfo;
{ if($postInfo['user_name'])
return $tp->parseTemplate("{EMAIL_ITEM=".FORLAN_101."^plugin:forum.{$postInfo['post_thread']}}"); {
} return "<a href='".$this->e107->url->getUrl('core:user', 'main', array('func' => 'profile', 'id' => $postInfo['post_user']))."'>{$postInfo['user_name']}</a>";
SC_END }
else
{
return '<b>'.$this->e107->tp->toHTML($postInfo['post_user_anon']).'</b>';
}
SC_BEGIN PRINTITEM }
global $postInfo, $tp;
if($postInfo['thread_start'])
{
return $tp->parseTemplate("{PRINT_ITEM=".FORLAN_102."^plugin:forum.{$postInfo['post_thread']}}");
}
SC_END
SC_BEGIN SIGNATURE function get_emailimg()
if(!USER) { return ''; } {
global $postInfo, $pref; global $postInfo;
static $forum_sig_shown; if($postInfo['user_name'])
$e107 = e107::getInstance(); {
//$pref['forum_sig_once'] = true; return (!$post_info['user_hideemail'] ? $this->e107->tp->parseTemplate("{EMAILTO={$postInfo['user_email']}}") : '');
if(varsettrue($pref['forum_sig_once'])) }
{ return '';
}
function get_emailitem()
{
if($postInfo['thread_start'])
{
return $this->e107->tp->parseTemplate("{EMAIL_ITEM=".FORLAN_101."^plugin:forum.{$postInfo['post_thread']}}");
}
}
function get_printitem()
{
global $postInfo;
if($postInfo['thread_start'])
{
return $this->e107->tp->parseTemplate("{PRINT_ITEM=".FORLAN_102."^plugin:forum.{$postInfo['post_thread']}}");
}
}
function get_signature()
{
if(!USER) { return ''; }
global $postInfo, $pref;
static $forum_sig_shown;
if(varsettrue($pref['forum_sig_once']))
{
$_tmp = 'forum_sig_shown_'.$postInfo['post_user']; $_tmp = 'forum_sig_shown_'.$postInfo['post_user'];
if(getcachedvars($_tmp)) { return ''; } if(getcachedvars($_tmp)) { return ''; }
cachevars($_tmp, 1); cachevars($_tmp, 1);
} }
return ($postInfo['user_signature'] ? "<br /><hr style='width:15%; text-align:left' /><span class='smalltext'>".$e107->tp->toHTML($postInfo['user_signature'], true).'</span>' : ''); return ($postInfo['user_signature'] ? "<br /><hr style='width:15%; text-align:left' /><span class='smalltext'>".$this->e107->tp->toHTML($postInfo['user_signature'], true).'</span>' : '');
SC_END
SC_BEGIN PROFILEIMG }
global $postInfo, $tp;
if (USER && $postInfo['user_name'])
{
return $tp->parseTemplate("{PROFILE={$postInfo['post_user']}}");
}
SC_END
SC_BEGIN POSTS function get_profileimg()
global $postInfo; {
if ($postInfo['post_user']) global $postInfo;
{ if (USER && $postInfo['user_name'])
{
return $this->e107->tp->parseTemplate("{PROFILE={$postInfo['post_user']}}");
}
}
function get_posts()
{
global $postInfo;
if ($postInfo['post_user'])
{
return LAN_67.': '.(int)$postInfo['user_plugin_forum_posts'].'<br />'; return LAN_67.': '.(int)$postInfo['user_plugin_forum_posts'].'<br />';
} }
SC_END }
SC_BEGIN VISITS function get_visits()
global $postInfo; {
if ($postInfo['user_name']) global $postInfo;
{ if ($postInfo['user_name'])
return LAN_09.': '.$postInfo['user_visits'].'<br />'; {
} return LAN_09.': '.$postInfo['user_visits'].'<br />';
SC_END }
}
SC_BEGIN CUSTOMTITLE function get_customtitle()
global $postInfo; {
$e107 = e107::getInstance(); global $postInfo;
if ($postInfo['user_customtitle']) if ($postInfo['user_customtitle'])
{ {
return $e107->tp->toHTML($postInfo['user_customtitle']).'<br />'; return $this->e107->tp->toHTML($postInfo['user_customtitle']).'<br />';
} }
SC_END }
SC_BEGIN WEBSITE function get_website()
global $postInfo, $tp; {
if ($postInfo['user_homepage']) { global $postInfo;
return LAN_08.': '.$postInfo['user_homepage'].'<br />'; if ($postInfo['user_homepage']) {
} return LAN_08.': '.$postInfo['user_homepage'].'<br />';
SC_END }
}
SC_BEGIN WEBSITEIMG function get_websiteimg()
global $postInfo; {
if ($postInfo['user_homepage'] && $postInfo['user_homepage'] != 'http://') global $postInfo;
{ if ($postInfo['user_homepage'] && $postInfo['user_homepage'] != 'http://')
{
return "<a href='{$postInfo['user_homepage']}'>".IMAGE_website.'</a>'; return "<a href='{$postInfo['user_homepage']}'>".IMAGE_website.'</a>';
} }
SC_END }
SC_BEGIN EDITIMG function get_editimg()
global $postInfo, $threadInfo; {
$e107 = e107::getInstance(); global $postInfo, $threadInfo;
if (USER && $postInfo['post_user'] == USERID && $threadInfo['thread_active']) if (USER && $postInfo['post_user'] == USERID && $threadInfo['thread_active'])
{ {
return "<a href='".$e107->url->getUrl('forum', 'thread', array('func' => 'edit', 'id' => $postInfo['post_id']))."'>".IMAGE_edit.'</a> '; return "<a href='".$this->e107->url->getUrl('forum', 'thread', array('func' => 'edit', 'id' => $postInfo['post_id']))."'>".IMAGE_edit.'</a> ';
} }
SC_END }
SC_BEGIN QUOTEIMG function get_quoteimg()
global $postInfo, $forum; {
$e107 = e107::getInstance(); global $postInfo, $forum;
if($forum->checkperm($postInfo['post_forum'], 'post')) if($forum->checkperm($postInfo['post_forum'], 'post'))
{ {
return "<a href='".$e107->url->getUrl('forum', 'thread', array('func' => 'quote', 'id' => $postInfo['post_id']))."'>".IMAGE_quote.'</a> '; return "<a href='".$this->e107->url->getUrl('forum', 'thread', array('func' => 'quote', 'id' => $postInfo['post_id']))."'>".IMAGE_quote.'</a> ';
} }
SC_END }
SC_BEGIN REPORTIMG function get_reportimg()
global $postInfo, $page; {
if (USER) { global $postInfo, $page;
$e107 = e107::getInstance(); if (USER) {
return "<a href='".$e107->url->getUrl('forum', 'thread', 'func=report&id='.$postInfo['post_thread'])."'>".IMAGE_report.'</a> '; return "<a href='".$this->e107->url->getUrl('forum', 'thread', 'func=report&id='.$postInfo['post_thread'])."'>".IMAGE_report.'</a> ';
} }
SC_END }
SC_BEGIN RPG function get_rpg()
global $postInfo; {
return rpg($postInfo['user_join'],$postInfo['user_plugin_forum_posts']); global $postInfo;
SC_END return rpg($postInfo['user_join'],$postInfo['user_plugin_forum_posts']);
}
SC_BEGIN MEMBERID function get_memberid()
global $post_info, $ldata, $pref, $forum_info; {
if ($post_info['anon']) { global $post_info, $ldata, $pref, $forum_info;
return ""; if ($post_info['anon']) { return ''; }
}
$fmod = ($post_info['user_class'] != "" && check_class($forum_info['forum_moderators'], $post_info['user_class'], TRUE)); $fmod = ($post_info['user_class'] != '' && check_class($forum_info['forum_moderators'], $post_info['user_class'], TRUE));
if(!$fmod && $forum_info['forum_moderators'] == e_UC_ADMIN) if(!$fmod && $forum_info['forum_moderators'] == e_UC_ADMIN)
{ {
$fmod = $post_info['user_admin']; $fmod = $post_info['user_admin'];
} }
if (!array_key_exists($post_info['user_id'],$ldata)) { if (!array_key_exists($post_info['user_id'],$ldata)) {
$ldata[$post_info['user_id']] = get_level($post_info['user_id'], $post_info['user_forums'], $post_info['user_comments'], $post_info['user_chats'], $post_info['user_visits'], $post_info['user_join'], $post_info['user_admin'], $post_info['user_perms'], $pref, $fmod); $ldata[$post_info['user_id']] = get_level($post_info['user_id'], $post_info['user_forums'], $post_info['user_comments'], $post_info['user_chats'], $post_info['user_visits'], $post_info['user_join'], $post_info['user_admin'], $post_info['user_perms'], $pref, $fmod);
} }
return $ldata[$post_info['user_id']][0]; return $ldata[$post_info['user_id']][0];
SC_END
SC_BEGIN LEVEL }
global $post_info, $ldata, $pref, $forum_info;
if ($post_info['anon']) { function get_level()
return ""; {
} global $post_info, $ldata, $pref, $forum_info;
$fmod = ($post_info['user_class'] != "" && check_class($forum_info['forum_moderators'], $post_info['user_class'], TRUE)); if ($post_info['anon']) { return ''; }
if(!$fmod && $forum_info['forum_moderators'] == e_UC_ADMIN) $fmod = ($post_info['user_class'] != "" && check_class($forum_info['forum_moderators'], $post_info['user_class'], TRUE));
{ if(!$fmod && $forum_info['forum_moderators'] == e_UC_ADMIN)
{
$fmod = $post_info['user_admin']; $fmod = $post_info['user_admin'];
} }
if (!array_key_exists($post_info['user_id'],$ldata)) { if (!array_key_exists($post_info['user_id'],$ldata)) {
$ldata[$post_info['user_id']] = get_level($post_info['user_id'], $post_info['user_forums'], $post_info['user_comments'], $post_info['user_chats'], $post_info['user_visits'], $post_info['user_join'], $post_info['user_admin'], $post_info['user_perms'], $pref, $fmod); $ldata[$post_info['user_id']] = get_level($post_info['user_id'], $post_info['user_forums'], $post_info['user_comments'], $post_info['user_chats'], $post_info['user_visits'], $post_info['user_join'], $post_info['user_admin'], $post_info['user_perms'], $pref, $fmod);
} }
if($parm == 'pic') if($parm == 'pic')
{ {
return $ldata[$post_info['user_id']]['pic']; return $ldata[$post_info['user_id']]['pic'];
} }
if($parm == 'name') if($parm == 'name')
{ {
return $ldata[$post_info['user_id']]['name']; return $ldata[$post_info['user_id']]['name'];
} }
if($parm == 'special') if($parm == 'special')
{ {
return $ldata[$post_info['user_id']]['special']; return $ldata[$post_info['user_id']]['special'];
} }
if($parm == 'userid') if($parm == 'userid')
{ {
return $ldata[$post_info['user_id']]['userid']; return $ldata[$post_info['user_id']]['userid'];
} }
return $ldata[$post_info['user_id']][1]; return $ldata[$post_info['user_id']][1];
SC_END
SC_BEGIN MODOPTIONS }
if (MODERATOR)
{ function get_modoptions()
{
if (MODERATOR)
{
return showmodoptions(); return showmodoptions();
} }
SC_END }
SC_BEGIN LASTEDIT function get_lastedit()
global $postInfo, $gen; {
//var_dump($postInfo); global $postInfo, $gen;
if ($postInfo['post_edit_datestamp']) if ($postInfo['post_edit_datestamp'])
{ {
return $gen->convert_date($postInfo['post_edit_datestamp'],'forum'); return $gen->convert_date($postInfo['post_edit_datestamp'],'forum');
} }
SC_END }
SC_BEGIN LASTEDITBY function get_lasteditby()
global $postInfo; {
if(isset($postInfo['edit_name'])) global $postInfo;
{ if(isset($postInfo['edit_name']))
{
if($parm == 'link') if($parm == 'link')
{ {
$e107 = e107::getInstance(); $e107 = e107::getInstance();
@@ -330,18 +377,19 @@ if(isset($postInfo['edit_name']))
return "<a href='{$url}'>{$postInfo['edit_name']}</a>"; return "<a href='{$url}'>{$postInfo['edit_name']}</a>";
} }
return $postInfo['edit_name']; return $postInfo['edit_name'];
}
}
function get_poll()
{
global $pollstr;
return $pollstr;
}
function get_newflag()
{
// Defined in case an indicator is required
return '';
}
} }
SC_END
SC_BEGIN POLL
global $pollstr;
return $pollstr;
SC_END
SC_BEGIN NEWFLAG
// Defined in case an indicator is required
return '';
SC_END
*/
?> ?>