1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-21 13:11:52 +02:00

- Forums working again (general functionallity) - the new URL assembling/configuration implemented. SEF URL config will be added when forums are 100% functional.

- Minor URL assembling issues fixed
This commit is contained in:
secretr 2011-11-28 14:19:19 +00:00
parent ed9f06c50f
commit 497efdb710
15 changed files with 460 additions and 89 deletions

View File

@ -1723,7 +1723,7 @@ class eRouter
$format = isset($config['format']) && $config['format'] ? $config['format'] : self::FORMAT_GET;
// Fix base url for legacy links
if($config['noSingleEntry']) $base = $options['full'] ? SITEURLBASE : SITEURL;
if($config['noSingleEntry']) $base = $options['full'] ? SITEURL : e_HTTP;
// TODO - main module - don't include it in the return URL
@ -1850,8 +1850,8 @@ class eRouter
{
$pairs = array();
$equal = $options['equal'];
$ampersand = $options['amp'];
$encode = $options['encode'];
$ampersand = !$encode && $options['amp'] == '&' ? '&' : $options['amp'];
foreach ($params as $k => $v)
{
if (null !== $key) $k = $key.'['.$k.']';

View File

@ -27,8 +27,8 @@ class plugin_forum_view_shortcodes extends e_shortcode
function sc_threaddatestamp()
{
$gen = e107::getDateConvert();
return "<a id='post_{$this->postInfo['post_id']}' href='".$this->e107->url->getUrl('forum', 'thread', array('func' => 'post', 'id' => $this->postInfo['post_id']))."'>".IMAGE_post."</a> ".$gen->convert_date($this->postInfo['post_datestamp'], 'forum');
$gen = e107::getDateConvert(); // XXX _URL_ check if all required info is there
return "<a id='post_{$this->postInfo['post_id']}' href='".$this->e107->url->create('forum/thread/post', array('name' => $this->postInfo['thread_name'], 'thread' => $this->postInfo['post_thread'], 'id' => $this->postInfo['post_id']))."'>".IMAGE_post."</a> ".$gen->convert_date($this->postInfo['post_datestamp'], 'forum');
}
function sc_post()
@ -135,7 +135,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
{
if($this->postInfo['user_name'])
{
return "<a href='".$this->e107->url->getUrl('core:user', 'main', array('func' => 'profile', 'id' => $this->postInfo['post_user']))."'>{$this->postInfo['user_name']}</a>";
return "<a href='".$this->e107->url->create('user/profile/view', array('name' => $this->postInfo['user_name'], 'id' => $this->postInfo['post_user']))."'>{$this->postInfo['user_name']}</a>";
}
else
{
@ -235,7 +235,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
{
if (USER && $this->postInfo['post_user'] == USERID && $this->thread->threadInfo['thread_active'])
{
return "<a href='".$this->e107->url->getUrl('forum', 'thread', array('func' => 'edit', 'id' => $this->postInfo['post_id']))."'>".IMAGE_edit.'</a> ';
return "<a href='".$this->e107->url->create('forum/thread/edit', array('id' => $this->postInfo['post_id']))."'>".IMAGE_edit.'</a> ';
}
}
@ -243,7 +243,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
{
if($this->forum->checkperm($this->postInfo['post_forum'], 'post'))
{
return "<a href='".$this->e107->url->getUrl('forum', 'thread', array('func' => 'quote', 'id' => $this->postInfo['post_id']))."'>".IMAGE_quote.'</a> ';
return "<a href='".$this->e107->url->create('forum/thread/quote', array('id' => $this->postInfo['post_id']))."'>".IMAGE_quote.'</a> ';
}
}
@ -251,7 +251,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
{
global $page;
if (USER) {
return "<a href='".$this->e107->url->getUrl('forum', 'thread', "func=report&id={$this->postInfo['post_thread']}&post={$this->postInfo['post_id']}")."'>".IMAGE_report.'</a> ';
return "<a href='".$this->e107->url->create('forum/thread/report', "id={$this->postInfo['post_thread']}&post={$this->postInfo['post_id']}")."'>".IMAGE_report.'</a> ';
}
}
@ -321,7 +321,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
if($parm == 'link')
{
$e107 = e107::getInstance();
$url = $e107->url->getUrl('core:user', 'main', 'func=profile&id='.$this->postInfo['post_edit_user']);
$url = $e107->url->create('user/profile/view', array('name' => $this->postInfo['edit_name'], 'id' => $this->postInfo['post_edit_user']));
return "<a href='{$url}'>{$this->postInfo['edit_name']}</a>";
}
return $this->postInfo['edit_name'];

View File

@ -0,0 +1,169 @@
<?php
/*
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Forum Default URL configuration
* TODO - SEF URL configuration
*/
class plugin_forum_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'noSingleEntry' => true, // [optional] default false; disallow this module to be shown via single entry point when this config is used
'legacy' => '{e_PLUGIN}forum/forum.php', // this config won't work in single entry point mod (legacy not used at all), so just set this to default plugin file to notify router it's legacy module
'format' => 'get', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'selfParse' => false, // [optional] default false; use only this->parse() method, no core routine URL parsing
'selfCreate' => true, // [optional] default false; use only this->create() method, no core routine URL creating
'defaultRoute' => 'forum/main', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
'legacyQuery' => '' // default legacy query string template, null to disable, empty - use current QUERY_STRING
),
// rule set array
'rules' => array()
);
}
/**
* NOTE we have double 'forum' but this is the best way to map new-old forum URLs to the new routing engine
* Additionally, 'forum' controller is descriptive, and leading 'forum' module name could be easiely changed (URL aliases administration page)
*/
public function create($route, $params = array(), $options = array())
{
$amp = varset($options['encode']) ? '&amp;' : '&';
if(is_string($route)) $route = explode('/', $route, 2);
if(!varset($route[0])) $route[0] = 'forum';
if(!varset($route[1])) $route[1] = 'main';
$base = e107::getInstance()->getFolder('plugins').'forum/';
//var_dump($options, $route, $params);
if($route[0] == 'forum')
{
if(!isset($params['id']) && isset($params['forum_id'])) $params['id'] = $params['forum_id'];
// if(isset($params['forum_name'])) $params['name'] = $params['forum_name']; - not used in this config
switch($route[1])
{
case 'view':
$page = (varset($params['page']) ? $amp.'p='.$params['page'] : '');
return $base."forum_viewforum.php?id={$params['id']}{$page}";
break;
case 'track':
return $base.'forum.php?track';
break;
case 'main':
return $base.'forum.php';
break;
case 'post':
return $base."forum_post.php?f={$params['type']}}id={$params['id']}";
break;
case 'rules':
return $base.'forum.php?f=rules';
break;
case 'mfar':
return $base.'forum.php?f=mfar'.$amp.'id='.$params['id'];
break;
}
}
elseif($route[0] == 'thread')
{
if(!isset($params['id']) && isset($params['thread_id'])) $params['id'] = $params['thread_id'];
// if(isset($params['thread_name'])) $params['name'] = $params['thread_name']; - not used in this config
switch($route[1])
{
case 'new':
return $base."forum_post.php?f=nt{$amp}id={$params['id']}";
break;
case 'reply':
return $base."forum_post.php?f=rp{$amp}id={$params['id']}";
break;
case 'view':
$page = (varset($params['page']) ? $amp.'p='.$params['page'] : '');
return $base."forum_viewtopic.php?id={$params['id']}{$page}";
break;
case 'last':
return $base."forum_viewtopic.php?id={$params['id']}{$amp}last=1";
break;
case 'post':
return $base."forum_viewtopic.php?f=post{$amp}id={$params['id']}";
break;
case 'report':
$page = (isset($params['page']) ? (int)$params['page'] : 0 );
return $base."forum_viewtopic.php?f=report{$amp}id={$params['id']}{$amp}post={$params['post']}{$amp}p={$page}";
break;
case 'edit':
return $base."forum_post.php?f=edit{$amp}id={$params['id']}";
break;
case 'move':
return $base."forum_conf.php?f=move{$amp}id={$params['id']}";
break;
case 'split':
return $base."forum_conf.php?f=split{$amp}id={$params['id']}";
break;
case 'quote':
return $base."forum_post.php?f=quote{$amp}id={$params['id']}";
break;
case 'next':
return $base."forum_viewtopic.php?f=next{$amp}id={$params['id']}";
break;
case 'prev':
return $base."forum_viewtopic.php?f=prev{$amp}id={$params['id']}";
break;
case 'track':
return $base."forum_viewtopic.php?f=track{$amp}id={$params['id']}";
break;
case 'untrack':
return $base."forum_viewtopic.php?f=untrack{$amp}id={$params['id']}";
break;
case 'track_toggle':
return $base."forum_viewtopic.php?f=track_toggle{$amp}id={$params['id']}";
break;
}
}
return false;
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
e107::plugLan('forum', 'lan_forum_url');
static $admin = array(
'labels' => array(
'name' => FORUM_LAN_URL_NAME, // Module name
'label' => FORUM_LAN_URL_DEFAULT_LABEL, // Current profile name
'description' => FORUM_LAN_URL_DEFAULT_DESCR, //
),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
}

View File

@ -1,5 +1,6 @@
<?php
// $Id$
// DEPRECATED - subject of removal
function url_forum_forum($parms)
{
$amp = isset($parms['raw']) ? '&' : '&amp;';

View File

@ -1,5 +1,6 @@
<?php
// $Id$
// DEPRECATED - subject of removal
function url_forum_thread($parms)
{
$amp = isset($parms['raw']) ? '&' : '&amp;';

View File

@ -19,7 +19,8 @@ if(!defined('e107_INIT'))
$e107 = e107::getInstance();
if (!$e107->isInstalled('forum'))
{
header('Location: '.e_BASE.'index.php');
// FIXME GLOBAL - get rid of all e_BASE|e_HTTP|Whatever/index.php - just point to SITEURL
header('Location: '.SITEURL);
exit;
}
@ -31,7 +32,7 @@ $forum = new e107forum;
if ($untrackId = varset($_REQUEST['untrack']))
{
$forum->track('del', USERID, $untrackId);
header('location:'.$e107->url->getUrl('forum', 'thread', array('func' => 'track')));
header('location:'.$e107->url->create('forum/thread/track', array(), 'full=1&encode=0'));
exit;
}
@ -84,7 +85,7 @@ if(USER)
}
if($rules_text != '')
{
$fVars->USERINFO .= " | <a href='".$e107->url->getUrl('forum', 'forum', "func=rules")."'>".LAN_433.'</a>';
$fVars->USERINFO .= " | <a href='".$e107->url->create('forum/forum/rules')."'>".LAN_433.'</a>';
}
$total_topics = $sql->db_Count("forum_thread", "(*)");
$total_replies = $sql->db_Count("forum_post", "(*)");
@ -286,7 +287,7 @@ function parse_forum($f, $restricted_string = '')
if(USER && is_array($newflag_list) && in_array($f['forum_id'], $newflag_list))
{
$fVars->NEWFLAG = "<a href='".$e107->url->getUrl('forum','forum', 'func=mfar&id='.$f['forum_id'])."'>".IMAGE_new.'</a>';
$fVars->NEWFLAG = "<a href='".$e107->url->create('forum/forum/mfar', $f)."'>".IMAGE_new.'</a>';
}
else
{
@ -299,8 +300,8 @@ function parse_forum($f, $restricted_string = '')
}
$f['forum_name'] = $e107->tp->toHTML($f['forum_name'], true, 'no_hook');
$f['forum_description'] = $e107->tp->toHTML($f['forum_description'], true, 'no_hook');
$fVars->FORUMNAME = "<a href='".$e107->url->getUrl('forum', 'forum', "func=view&id={$f['forum_id']}")."'>{$f['forum_name']}</a>";
$fVars->FORUMNAME = "<a href='".$e107->url->create('forum/forum/view', $f)."'>{$f['forum_name']}</a>";
$fVars->FORUMDESCRIPTION = $f['forum_description'].($restricted_string ? "<br /><span class='smalltext'><i>$restricted_string</i></span>" : "");
$fVars->THREADS = $f['forum_threads'];
$fVars->REPLIES = $f['forum_replies'];
@ -328,14 +329,14 @@ function parse_forum($f, $restricted_string = '')
if ($f['user_name'])
{
$lastpost_name = "<a href='".$e107->url->getUrl('core:user','main','func=profile&id='.$f['forum_lastpost_user'])."'>{$f['user_name']}</a>";
$lastpost_name = "<a href='".$e107->url->create('user/profile/view', array('name' => $f['user_name'], 'id' => $f['forum_lastpost_user']))."'>{$f['user_name']}</a>";
}
else
{
$lastpost_name = $e107->tp->toHTML($f['forum_lastpost_user_anon']);
}
$lastpost_datestamp = $gen->convert_date($lastpost_datestamp, 'forum');
$fVars->LASTPOST = $lastpost_datestamp.'<br />'.$lastpost_name." <a href='".$e107->url->getUrl('forum', 'thread', array('func' => 'last', 'id' => $lastpost_thread))."'>".IMAGE_post2.'</a>';
$fVars->LASTPOST = $lastpost_datestamp.'<br />'.$lastpost_name." <a href='".$e107->url->create('forum/thread/last', array('name' => $lastpost_name, 'id' => $lastpost_thread))."'>".IMAGE_post2.'</a>';
}
else
{
@ -352,7 +353,7 @@ function parse_subs($subList, $lastpost_datestamp)
foreach($subList as $sub)
{
$ret['text'] .= ($ret['text'] ? ', ' : '');
$suburl = $e107->url->getUrl('forum', 'forum', array('func' => 'view', 'id' => $sub['forum_id']));
$suburl = $e107->url->create('forum/forum/view', $sub);
$ret['text'] .= "<a href='{$suburl}'>".$e107->tp->toHTML($sub['forum_name']).'</a>';
$ret['threads'] += $sub['forum_threads'];
$ret['replies'] += $sub['forum_replies'];
@ -391,7 +392,7 @@ if (e_QUERY == 'track')
$trackVars->NEWIMAGE = IMAGE_new_small;
}
$url = $e107->url->getUrl('forum', 'thread', "func=view&id={$row['thread_id']}");
$url = $e107->url->create('forum/thread/view', $row); // configs will be able to map thread_* vars to the url
$trackVars->TRACKPOSTNAME = "<a href='{$url}'>".$e107->tp->toHTML($row['thread_name']).'</a>';
$trackVars->UNTRACK = "<a href='".e_SELF."?untrack.".$row['thread_id']."'>".LAN_392."</a>";
$forum_trackstring .= $e107->tp->simpleParse($FORUM_TRACK_MAIN, $trackVars);
@ -425,9 +426,9 @@ if (e_QUERY == 'new')
}
else
{
$nVars->STARTERTITLE = "<a href='".$e107->url->getUrl('core:user', 'main', 'func=profile&id='.$thread['thread_lastuser'])."'>{$author_name}</a><br />".$datestamp;
$nVars->STARTERTITLE = "<a href='".$e107->url->create('user/profile/view', array('id' => $thread['thread_lastuser'], 'name' => $author_name))."'>{$author_name}</a><br />".$datestamp;
}
$nVars->NEWSPOSTNAME = "<a href='".$e107->url->getUrl('forum', 'thread', 'func=last&id='.$thread['thread_id'])."'>".$e107->tp->toHTML($thread['thread_name'], TRUE, 'no_make_clickable, no_hook').'</a>';
$nVars->NEWSPOSTNAME = "<a href='".$e107->url->create('forum/thread/last', $thread)."'>".$e107->tp->toHTML($thread['thread_name'], TRUE, 'no_make_clickable, no_hook').'</a>';
$forum_newstring .= $e107->tp->simpleParse($FORUM_NEWPOSTS_MAIN, $nVars);
}

View File

@ -347,7 +347,7 @@ class forumAdmin
{
$text .= "
<tr>
<td style='width:5%; text-align:center' class='forumheader3'>".IMAGE_new."</td>\n<td style='width:55%' class='forumheader3'><a href='".$e107->url->getUrl('forum', 'forum', array('func' => 'view', 'id'=>$forum['forum_id']))."'>".$e107->tp->toHTML($forum['forum_name'])."</a>";
<td style='width:5%; text-align:center' class='forumheader3'>".IMAGE_new."</td>\n<td style='width:55%' class='forumheader3'><a href='".$e107->url->create('forum/forum/view', $forum)."'>".$e107->tp->toHTML($forum['forum_name'])."</a>";
// <td style='width:5%; text-align:center' class='forumheader3'>".IMAGE_new."</td>\n<td style='width:55%' class='forumheader3'><a href='".e_PLUGIN."forum/forum_viewforum.php?{$forum['forum_id']}'>".$e107->tp->toHTML($forum['forum_name'])."</a>";
$text .= "

View File

@ -2,7 +2,7 @@
/*
* e107 website system
*
* Copyright (c) 2008-2010 e107 Inc (e107.org)
* Copyright (c) 2008-2011 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
@ -392,7 +392,7 @@ class e107forum
if('post' === $start)
{
$qry = '
SELECT u.user_name, t.thread_active, t.thread_datestamp, t.thread_name, p.* FROM `#forum_post` AS p
SELECT u.user_name, t.thread_active, t.thread_datestamp, t.thread_name, t.thread_id, p.* FROM `#forum_post` AS p
LEFT JOIN `#forum_thread` AS t ON t.thread_id = p.post_thread
LEFT JOIN `#user` AS u ON u.user_id = p.post_user
WHERE p.post_id = '.$id;
@ -403,11 +403,13 @@ class e107forum
SELECT p.*,
u.user_name, u.user_customtitle, u.user_hideemail, u.user_email, u.user_signature,
u.user_admin, u.user_image, u.user_join, ue.user_plugin_forum_posts,
eu.user_name AS edit_name
eu.user_name AS edit_name,
t.thread_name
FROM `#forum_post` AS p
LEFT JOIN `#user` AS u ON p.post_user = u.user_id
LEFT JOIN `#user` AS eu ON p.post_edit_user IS NOT NULL AND p.post_edit_user = eu.user_id
LEFT JOIN `#user_extended` AS ue ON ue.user_extended_id = p.post_user
LEFT JOIN `#forum_thread` AS t ON t.thread_id = p.post_thread
WHERE p.post_thread = {$id}
ORDER BY p.post_datestamp ASC
LIMIT {$start}, {$num}
@ -1167,11 +1169,11 @@ class e107forum
if(is_array($FORUM_CRUMB))
{
$search = array('{SITENAME}', '{SITENAME_HREF}');
$replace = array(SITENAME, $e107->url->getUrl('core:core', 'main', 'action=index'));
$replace = array(SITENAME, $e107->url->create('/'));
$FORUM_CRUMB['sitename']['value'] = str_replace($search, $replace, $FORUM_CRUMB['sitename']['value']);
$search = array('{FORUMS_TITLE}', '{FORUMS_HREF}');
$replace = array(LAN_01, $e107->url->getUrl('forum', 'forum', 'func=main'));
$replace = array(LAN_01, $e107->url->create('forum/forum/main'));
$FORUM_CRUMB['forums']['value'] = str_replace($search, $replace, $FORUM_CRUMB['forums']['value']);
$search = '{PARENT_TITLE}';
@ -1181,7 +1183,7 @@ class e107forum
if($forumInfo['forum_sub'])
{
$search = array('{SUBPARENT_TITLE}', '{SUBPARENT_HREF}');
$replace = array(ltrim($forumInfo['sub_parent'], '*'), $e107->url->getUrl('forum', 'forum', "func=view&id={$forumInfo['forum_sub']}"));
$replace = array(ltrim($forumInfo['sub_parent'], '*'), $e107->url->create('forum/forum/view', "id={$forumInfo['forum_sub']}")); // XXX forum sub name
$FORUM_CRUMB['subparent']['value'] = str_replace($search, $replace, $FORUM_CRUMB['subparent']['value']);
}
else
@ -1191,12 +1193,12 @@ class e107forum
$search = array('{FORUM_TITLE}', '{FORUM_HREF}');
// TODO - remove 'href=' from the return value
$replace = array(ltrim($forumInfo['forum_name'], '*'), $e107->url->getUrl('forum', 'forum', "func=view&id={$forumInfo['forum_id']}"));
$replace = array(ltrim($forumInfo['forum_name'], '*'), $e107->url->create('forum/forum/view', $forumInfo));
$FORUM_CRUMB['forum']['value'] = str_replace($search, $replace, $FORUM_CRUMB['forum']['value']);
$threadInfo['thread_id'] = intval($threadInfo['thread_id']);
$search = array('{THREAD_TITLE}', '{THREAD_HREF}');
$replace = array($threadInfo['thread_name'], $e107->url->getUrl('forum', 'thread', "func=view&id={$threadInfo['thread_id']}")); // $thread->threadInfo - no reference found
$replace = array($threadInfo['thread_name'], $e107->url->create('forum/thread/view', $threadInfo)); // $thread->threadInfo - no reference found
$FORUM_CRUMB['thread']['value'] = str_replace($search, $replace, $FORUM_CRUMB['thread']['value']);
$FORUM_CRUMB['fieldlist'] = 'sitename,forums,parent,subparent,forum,thread';

View File

@ -28,7 +28,7 @@ $e_sub_cat = 'forum';
if(!USER || !isset($_GET['f']) || !isset($_GET['id']))
{
header('location:'.$e107->url->getUrl('core:core', 'main', 'action=index'));
header('location:'.$e107->url->create('/'), array(), array('encode' => false, 'full' => 1));
exit;
}
@ -51,7 +51,7 @@ $modList = $forum->forumGetMods($threadInfo->forum_moderators);
//If user is not a moderator of indicated forum, redirect to index page
if(!in_array(USERID, array_keys($modList)))
{
header('location:'.$e107->url->getUrl('core:core', 'main', 'action=index'));
header('location:'.$e107->url->create('/'), array(), array('encode' => false, 'full' => 1));
exit;
}
@ -91,8 +91,8 @@ if (isset($_POST['move']))
$forum->threadMove($threadId, $toForum, $newThreadTitle, $newThreadTitleType);
$message = FORCONF_9;
$url = $e107->url->getUrl('forum', 'thread', 'func=view&id='.$threadId);
$message = FORCONF_9;// XXX _URL_ thread name
$url = $e107->url->create('forum/thread/view', 'id='.$threadId);
}
if (isset($_POST['movecancel']))
@ -103,7 +103,7 @@ if (isset($_POST['movecancel']))
$message = FORCONF_10;
// $url = e_PLUGIN."forum/forum_viewforum.php?".$info['forum_id'];
$url = $e107->url->getUrl('forum', 'forum', 'func=view&id='.$postInfo[0]['post_forum']);
$url = $e107->url->create('forum/forum/view', 'id='.$postInfo[0]['post_forum']);// XXX _URL_ thread name
}
if ($message)

View File

@ -2,7 +2,7 @@
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Copyright (C) 2008-2011 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
@ -28,7 +28,7 @@ include_lan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_post.php');
if (isset($_POST['fjsubmit']))
{
header('Location:'.$e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id'=>$_POST['forumjump'], 'raw' => true)));
header('Location:'.$e107->url->create('forum/forum/view', array('id'=>(int) $_POST['forumjump']), '', 'full=1&encode=0'));
exit;
}
@ -37,7 +37,7 @@ $forum = new e107forum();
if (!e_QUERY || !isset($_GET['id']))
{
header('Location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'main', 'raw' => true)));
header('Location:'.$e107->url->create('forum/forum/main', array(), 'full=1&encode=0'));
exit;
}
@ -66,7 +66,7 @@ switch($action)
break;
default:
header("Location:".$e107->url->getUrl('forum', 'forum', array('func' => 'main', 'raw' => true)));
header("Location:".$e107->url->create('forum/forum/main', array(), 'full=1&encode=0'));
exit;
}
@ -328,11 +328,14 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
}
$e107cache->clear('newforumposts');
$threadLink = $e107->url->getUrl('forum', 'thread', array('func' => 'last', 'id' => $threadId));
$forumLink = $e107->url->getUrl('forum', 'forum', array('func' => 'view', 'id' => $forumId));
$postInfo = $forum->postGet($newPostId, 'post');
$forumInfo = $forum->forumGet($postInfo['post_forum']);
$threadLink = $e107->url->create('forum/thread/last', $postInfo);
$forumLink = $e107->url->create('forum/forum/view', $forumInfo);
if ($forum->prefs->get('redirect'))
{
header('location:'.$e107->url->getUrl('forum', 'thread', array('func' => 'last', 'id' => $threadId, 'raw' => true)));
header('location:'.$e107->url->create('forum/thread/last', $postInfo, array('encode' => false, 'full' => true)));
exit;
}
else
@ -399,7 +402,7 @@ if (isset($_POST['update_thread']))
$forum->threadUpdate($postInfo['post_thread'], $threadVals);
$forum->postUpdate($postInfo['post_id'], $postVals);
$e107cache->clear('newforumposts');
$url = $e107->url->getUrl('forum', 'thread', "func=post&id={$postInfo['post_id']}&raw=1");
$url = $e107->url->create('forum/thread/post', array('name'=>$threadVals['thread_name'], 'id' => $postInfo['post_id'], 'thread' => $postInfo['post_thread']));
header('location:'.$url);
exit;
}
@ -426,7 +429,7 @@ if (isset($_POST['update_reply']))
$forum->postUpdate($postInfo['post_id'], $postVals);
$e107cache->clear('newforumposts');
$url = $e107->url->getUrl('forum', 'thread', "func=post&id={$postInfo['post_id']}&raw=1");
$url = $e107->url->create('forum/thread/post', "id={$postInfo['post_id']}", 'encode=0&full=1'); // XXX what data is available, find thread name
header('location:'.$url);
exit;
}

View File

@ -17,20 +17,21 @@ require_once('../../class2.php');
$e107 = e107::getInstance();
if (!$e107->isInstalled('forum'))
{
header('Location: '.e_BASE.'index.php');
header('Location: '.SITEURL);
exit;
}
include_lan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_viewforum.php');
if (isset($_POST['fjsubmit']))
{
header('location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'view', 'id'=>$_POST['forumjump'])));
// TODO - load from DB and find forum_name
header('location:'.$e107->url->create('forum/forum/view', array('id'=>(int) $_POST['forumjump']), '', 'full=1&encode=0'));
exit;
}
if (!e_QUERY)
{
header('Location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'main')));
header('Location:'.$e107->url->create('forum/forum/main', array(), 'full=1&encode=0'));
exit;
}
@ -56,7 +57,7 @@ $forumId = (int)$_REQUEST['id'];
if (!$forum->checkPerm($forumId, 'view'))
{
header('Location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'main')));
header('Location:'.$e107->url->create('forum/forum/main'));
exit;
}
@ -143,17 +144,18 @@ if ($pages)
if(strpos($FORUM_VIEW_START, 'THREADPAGES') !== false || strpos($FORUM_VIEW_END, 'THREADPAGES') !== false)
{
//if(!$page) $page = 1;
// __FIX URL__ - forum urls - fixed only parse error
$url = rawurlencode(e107::getUrl()->create('forum', 'forum', array('func' => 'view', 'id' => $forumId, 'page' => '[FROM]')));
$urlparms = $forumInfo;
$urlparms['page'] = '[FROM]';
$url = rawurlencode(e107::getUrl()->create('forum/forum/view', $urlparms));
$parms = "total={$pages}&type=page&current={$page}&url=".$url."&caption=off";
$fVars->THREADPAGES = $e107->tp->parseTemplate("{NEXTPREV={$parms}}");
unset($urlparms);
}
}
if($forum->checkPerm($forumId, 'post'))
{
$fVars->NEWTHREADBUTTON = "<a href='".$e107->url->getUrl('forum', 'thread', array('func' => 'nt', 'id' => $forumId))."'>".IMAGE_newthread.'</a>';
$fVars->NEWTHREADBUTTON = "<a href='".$e107->url->create('forum/thread/new', array('id' => $forumId))."'>".IMAGE_newthread.'</a>';
}
if(substr($forumInfo['forum_name'], 0, 1) == '*')
@ -350,7 +352,8 @@ function parse_thread($thread_info)
$lastpost_datestamp = $gen->convert_date($thread_info['thread_lastpost'], 'forum');
if($thread_info['lastpost_username'])
{
$url = $e107->url->getUrl('core:user', 'main', "func=profile&id={$thread_info['thread_lastuser']}");
// XXX hopefully & is not allowed in user name - it would break parsing of url parameters, change to array if something wrong happens
$url = $e107->url->create('user/profile/view', "name={$thread_info['lastpost_username']}&id={$thread_info['thread_lastuser']}");
$tVars->LASTPOST = "<a href='{$url}'>".$thread_info['lastpost_username']."</a>";
}
else
@ -417,9 +420,10 @@ function parse_thread($thread_info)
{
$title = '';
}
$tVars->THREADNAME = "<a {$title} href='".$e107->url->getUrl('forum', 'thread', "func=view&id={$threadId}")."'>{$thread_name}</a>";
$tVars->THREADNAME = "<a {$title} href='".$e107->url->create('forum/thread/view', array('id' => $threadId, 'name' => $thread_name))."'>{$thread_name}</a>";
// FIXME - pages -> convert to nextprev shortcode
$pages = ceil(($tVars->REPLIES)/$forum->prefs->get('postspage'));
$urlparms = $thread_info;
if ($pages > 1)
{
if($pages > 6)
@ -428,7 +432,8 @@ function parse_thread($thread_info)
{
$aa = $a + 1;
$tVars->PAGES .= $tVars->PAGES ? ' ' : '';
$url = $e107->url->getUrl('forum', 'thread', "func=view&id={$thread_info['thread_id']}&page={$aa}");
$urlparms['page'] = $aa;
$url = $e107->url->create('forum/thread/view', $urlparms);
$tVars->PAGES .= "<a href='{$url}'>{$aa}</a>";
}
$tVars->PAGES .= ' ... ';
@ -436,7 +441,8 @@ function parse_thread($thread_info)
{
$aa = $a + 1;
$tVars->PAGES .= $tVars->PAGES ? ' ' : '';
$url = $e107->url->getUrl('forum', 'thread', "func=view&id={$thread_info['thread_id']}&page={$aa}");
$urlparms['page'] = $aa;
$url = $e107->url->create('forum/thread/view', $urlparms);
$tVars->PAGES .= "<a href='{$url}'>{$aa}</a>";
}
}
@ -446,7 +452,8 @@ function parse_thread($thread_info)
{
$aa = $a + 1;
$tVars->PAGES .= $tVars->PAGES ? ' ' : '';
$url = $e107->url->getUrl('forum', 'thread', "func=view&id={$thread_info['thread_id']}&page={$aa}");
$urlparms['page'] = $aa;
$url = $e107->url->create('forum/thread/view', $urlparms);
$tVars->PAGES .= "<a href='{$url}'>{$aa}</a>";
}
}
@ -459,12 +466,15 @@ function parse_thread($thread_info)
if (MODERATOR)
{
// FIXME _URL_ thread name
// $e107->url->create('forum/forum/view', "id={$thread_info['thread_forum_id']}")
// USED self instead
$tVars->ADMIN_ICONS = "
<form method='post' action='".$e107->url->getUrl('forum', 'forum', "func=view&id={$thread_info['thread_forum_id']}")."' id='frmMod_{$forumId}_{$threadId}' style='margin:0;'><div>
<form method='post' action='".e_REQUEST_URI."' id='frmMod_{$forumId}_{$threadId}' style='margin:0;'><div>
<input type='image' ".IMAGE_admin_delete." name='deleteThread_{$threadId}' value='thread_action' onclick=\"return confirm_({$threadId})\" />
".($thread_info['thread_sticky'] == 1 ? "<input type='image' ".IMAGE_admin_unstick." name='unstick_{$threadId}' value='thread_action' /> " : "<input type='image' ".IMAGE_admin_stick." name='stick_{$threadId}' value='thread_action' /> ")."
".($thread_info['thread_active'] ? "<input type='image' ".IMAGE_admin_lock." name='lock_{$threadId}' value='thread_action' /> " : "<input type='image' ".IMAGE_admin_unlock." name='unlock_{$threadId}' value='thread_action' /> "). "
<a href='".$e107->url->getUrl('forum', 'thread', "func=move&id={$threadId}")."'>".IMAGE_admin_move.'</a>
<a href='".$e107->url->create('forum/thread/move', "id={$threadId}")."'>".IMAGE_admin_move.'</a>
</div></form>
';
}
@ -475,7 +485,7 @@ function parse_thread($thread_info)
if($thread_info['user_name'])
{
$tVars->POSTER = "<a href='".$e107->url->getUrl('core:user', 'main', "func=profile&id={$thread_info['thread_user']}")."'>".$thread_info['user_name']."</a>";
$tVars->POSTER = "<a href='".$e107->url->create('user/profile/view', array('id' => $thread_info['thread_user'], 'name' => $thread_info['user_name']))."'>".$thread_info['user_name']."</a>";
}
else
{
@ -519,14 +529,14 @@ function parse_sub($subInfo)
$tVars = new e_vars;
$e107 = e107::getInstance();
$forumName = $e107->tp->toHTML($subInfo['forum_name'], true);
$tVars->SUB_FORUMTITLE = "<a href='".$e107->url->getUrl('forum', 'forum', "func=view&id={$subInfo['forum_id']}")."'>{$forumName}</a>";
$tVars->SUB_FORUMTITLE = "<a href='".$e107->url->create('forum/forum/view', $subInfo)."'>{$forumName}</a>";
$tVars->SUB_DESCRIPTION = $e107->tp->toHTML($subInfo['forum_description'], false, 'no_hook');
$tVars->SUB_THREADS = $subInfo['forum_threads'];
$tVars->SUB_REPLIES = $subInfo['forum_replies'];
if(USER && is_array($newflag_list) && in_array($subInfo['forum_id'], $newflag_list))
{
$tVars->NEWFLAG = "<a href='".$e107->url->getUrl('forum','forum', 'func=mfar&id='.$subInfo['forum_id'])."'>".IMAGE_new.'</a>';
$tVars->NEWFLAG = "<a href='".$e107->url->create('forum/forum/mfar', 'id='.$subInfo['forum_id'])."'>".IMAGE_new.'</a>';
}
else
{
@ -536,12 +546,12 @@ function parse_sub($subInfo)
if($subInfo['forum_lastpost_info'])
{
$tmp = explode('.', $subInfo['forum_lastpost_info']);
$lp_thread = "<a href='".$e107->url->getUrl('forum', 'thread', array('func' => 'last', 'id' => $tmp[1]))."'>".IMAGE_post2.'</a>';
$lp_thread = "<a href='".$e107->url->create('forum/thread/last', array('id' => $tmp[1]))."'>".IMAGE_post2.'</a>';
$lp_date = $gen->convert_date($tmp[0], 'forum');
if($subInfo['user_name'])
{
$lp_name = "<a href='".$e107->url->getUrl('core:user', 'main', "func=profile&id={$subInfo['forum_lastpost_user']}")."'>{$subInfo['user_name']}</a>";
$lp_name = "<a href='".$e107->url->create('user/profile/view', array('id' => $subInfo['forum_lastpost_user'], 'name' => $subInfo['user_name']))."'>{$subInfo['user_name']}</a>";
}
else
{

View File

@ -27,7 +27,7 @@ if (!$e107->isInstalled('forum'))
if (isset($_POST['fjsubmit']))
{
header('location:' . $e107->url->getUrl('forum', 'forum', array('func' => 'view', 'id' => $_POST['forumjump'])));
header('location:' . $e107->url->create('forum/forum/view', array('id'=>(int) $_POST['forumjump']), 'full=1&encode=0'));
exit;
}
$highlight_search = isset($_POST['highlight_search']);
@ -35,7 +35,7 @@ $highlight_search = isset($_POST['highlight_search']);
if (!e_QUERY)
{
//No parameters given, redirect to forum home
header('Location:' . $e107->url->getUrl('forum', 'forum', array('func' => 'main')));
header('Location:' . $e107->url->create('forum/forum/main', array(), 'full=1&encode=0'));
exit;
}
@ -163,14 +163,14 @@ $forum->set_crumb(true, '', $tVars); // Set $BREADCRUMB (and BACKLINK)
//$tVars->BACKLINK = $tVars->BREADCRUMB;
//$tVars->FORUM_CRUMB = $crumbs['forum_crumb'];
$tVars->THREADNAME = $e107->tp->toHTML($thread->threadInfo['thread_name'], true, 'no_hook, emotes_off');
$tVars->NEXTPREV = "&lt;&lt; <a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'prev', 'id' => $thread->threadId)) . "'>" . LAN_389 . "</a>";
$tVars->NEXTPREV = "&lt;&lt; <a href='" . $e107->url->create('forum/thread/prev', array('id' => $thread->threadId)) . "'>" . LAN_389 . "</a>";
$tVars->NEXTPREV .= ' | ';
$tVars->NEXTPREV .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'next', 'id' => $thread->threadId)) . "'>" . LAN_390 . "</a> &gt;&gt;";
$tVars->NEXTPREV .= "<a href='" . $e107->url->create('forum/thread/prev', array('id' => $thread->threadId)) . "'>" . LAN_390 . "</a> &gt;&gt;";
if ($forum->prefs->get('track') && USER)
{
$img = ($thread->threadInfo['track_userid'] ? IMAGE_track : IMAGE_untrack);
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $thread->threadId));
$url = $e107->url->create('forum/thread/view', array('id' => $thread->threadId), 'encode=0'); // encoding could break AJAX call
$tVars->TRACK .= "
<span id='forum-track-trigger-container'>
<a href='{$url}' id='forum-track-trigger'>{$img}</a>
@ -199,7 +199,7 @@ $tVars->THREADSTATUS = (!$thread->threadInfo['thread_active'] ? LAN_66 : '');
if ($thread->pages > 1)
{
if(!$thread->page) $thread->page = 1;
$url = rawurlencode(e107::getUrl()->getUrl('forum', 'thread', array('func' => 'view', 'id' => $thread->threadId, 'page' => '[FROM]')));
$url = rawurlencode(e107::getUrl()->create('forum/thread/view', array('name' => $thread->threadInfo['thread_name'], 'id' => $thread->threadId, 'page' => '[FROM]')));
$parms = "total={$thread->pages}&type=page&current={$thread->page}&url=".$url."&caption=off";
$tVars->GOTOPAGES = $tp->parseTemplate("{NEXTPREV={$parms}}");
/*
@ -210,11 +210,11 @@ if ($thread->pages > 1)
$tVars->BUTTONS = '';
if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'post') && $thread->threadInfo['thread_active'])
{
$tVars->BUTTONS .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'rp', 'id' => $thread->threadId)) . "'>" . IMAGE_reply . "</a>";
$tVars->BUTTONS .= "<a href='" . $e107->url->create('forum/thread/reply', array('id' => $thread->threadId)) . "'>" . IMAGE_reply . "</a>";
}
if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'thread'))
{
$tVars->BUTTONS .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'nt', 'id' => $thread->threadInfo['thread_forum_id'])) . "'>" . IMAGE_newthread . "</a>";
$tVars->BUTTONS .= "<a href='" . $e107->url->create('forum/thread/new', array('id' => $thread->threadInfo['thread_forum_id'])) . "'>" . IMAGE_newthread . "</a>";
}
$tVars->POLL = $pollstr;
@ -277,7 +277,7 @@ if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'post') && $thread
if (!$forum_quickreply)
{
$tVars->QUICKREPLY = "
<form action='" . $e107->url->getUrl('forum', 'thread', array('func' => 'rp', 'id' => $thread->threadId)) . "' method='post'>
<form action='" . $e107->url->create('forum/thread/reply', array('id' => $thread->threadId)) . "' method='post'>
<p>" . LAN_393 . ":<br />
<textarea cols='60' rows='4' class='tbox' name='post' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'></textarea>
<br />
@ -337,7 +337,8 @@ function showmodoptions()
if ($postInfo['thread_start'])
{
$type = 'Thread';
$ret = "<form method='post' action='" . $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $postInfo['post_thread']))."' id='frmMod_{$postInfo['post_forum']}_{$postInfo['post_thread']}'>";
// XXX _URL_ thread name?
$ret = "<form method='post' action='" . $e107->url->create('forum/thread/view', array('id' => $postInfo['post_thread']))."' id='frmMod_{$postInfo['post_forum']}_{$postInfo['post_thread']}'>";
$delId = $postInfo['post_thread'];
}
else
@ -349,17 +350,17 @@ function showmodoptions()
$ret .= "
<div>
<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'edit', 'id' => $postInfo['post_id']))."'>" . IMAGE_admin_edit . "</a>
<a href='" . $e107->url->create('forum/thread/edit', array('id' => $postInfo['post_id']))."'>" . IMAGE_admin_edit . "</a>
<input type='image' " . IMAGE_admin_delete . " name='delete{$type}_{$delId}' value='thread_action' onclick=\"return confirm_('{$type}', {$postInfo['post_forum']}, {$postInfo['post_thread']}, '{$postInfo['user_name']}')\" />
<input type='hidden' name='mod' value='1'/>
";
if ($type == 'Thread')
{
$ret .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'move', 'id' => $postInfo['post_id']))."'>" . IMAGE_admin_move2 . "</a>";
$ret .= "<a href='" . $e107->url->create('forum/thread/move', array('id' => $postInfo['post_id']))."'>" . IMAGE_admin_move2 . "</a>";
}
else
{
$ret .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'split', 'id' => $postInfo['post_id']))."'>" . IMAGE_admin_split . '</a>';
$ret .= "<a href='" . $e107->url->create('forum/thread/split', array('id' => $postInfo['post_id']))."'>" . IMAGE_admin_split . '</a>';
}
$ret .= "
@ -507,14 +508,14 @@ class e107ForumThread
//If threadId doesn't exist, or not given, redirect to main forum page
if (!$this->threadId || !$this->threadInfo = $forum->threadGet($this->threadId))
{
header('Location:' . $e107->url->getUrl('forum', 'forum', array('func' => 'main')));
header('Location:' . $e107->url->create('forum/forum/main', array(), 'encode=0&full=1'));
exit;
}
//If not permitted to view forum, redirect to main forum page
if (!$forum->checkPerm($this->threadInfo['thread_forum_id'], 'view'))
{
header('Location:' . $e107->url->getUrl('forum', 'forum', array('func' => 'main')));
header('Location:' . $e107->url->create('forum/forum/main', array(), 'encode=0&full=1'));
exit;
}
$this->pages = ceil(($this->threadInfo['thread_total_replies']) / $this->perPage);
@ -538,7 +539,7 @@ class e107ForumThread
}
if(e_AJAX_REQUEST)
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $thread->threadId));
$url = $e107->url->create('forum/thread/view', array('name' => $this->threadInfo['thread_name'], 'id' => $thread->threadId));
echo "<a href='{$url}' id='forum-track-trigger'>{$img}</a>";
exit();
}
@ -562,7 +563,7 @@ class e107ForumThread
$postInfo = $forum->postGet($postId,'post');
$postNum = $forum->postGetPostNum($postInfo['post_thread'], $postId);
$postPage = ceil($postNum / $forum->prefs->get('postspage'));
$url = $e107->url->getUrl('forum', 'thread', "func=view&id={$postInfo['post_thread']}&page=$postPage&raw");
$url = $e107->url->create('forum/thread/view', array('id' => $postInfo['post_thread'], 'name' => $postInfo['thread_name'], 'page' => $postPage), 'full=1&encode=0');
header('location: '.$url);
exit;
break;
@ -576,7 +577,7 @@ class e107ForumThread
$next = $forum->threadGetNextPrev('next', $this->threadId, $this->threadInfo['forum_id'], $this->threadInfo['thread_lastpost']);
if ($next)
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $next, 'raw' => true));
$url = $e107->url->create('forum/thread/view', array('id' => $next), array('encode' => false, 'full' => 1)); // no thread name info at this time
header("location: {$url}");
exit;
}
@ -587,7 +588,7 @@ class e107ForumThread
$prev = $forum->threadGetNextPrev('prev', $this->threadId, $this->threadInfo['forum_id'], $this->threadInfo['thread_lastpost']);
if ($prev)
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $prev, 'raw' => true));
$url = $e107->url->create('forum/thread/view', array('id' => $prev), array('encode' => false, 'full' => 1));// no thread name info at this time
header("location: {$url}");
exit;
}
@ -612,7 +613,7 @@ class e107ForumThread
// 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}'");
define('e_PAGETITLE', LAN_01 . " / " . LAN_428);
$url = $e107->url->getUrl('forum', 'thread', 'func=post&id='.$postId);
$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);
}
@ -620,8 +621,8 @@ class e107ForumThread
{
$thread_name = $e107->tp->toHTML($postInfo['thread_name'], true, 'no_hook, emotes_off');
define('e_PAGETITLE', LAN_01 . ' / ' . LAN_426 . ' ' . $thread_name);
$url = $e107->url->getUrl('forum', 'thread', 'func=post&id='.$postId);
$actionUrl = $e107->url->getUrl('forum', 'thread', "func=report&id={$threadId}&post={$postId}");
$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}");
$text = "<form action='".$actionUrl."' method='post'>
<table style='width:100%'>
<tr>

View File

@ -0,0 +1,14 @@
<?php
/*
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* URL configuration language file (adminsitration)
*/
define("FORUM_LAN_URL_NAME", "Forum");
define("FORUM_LAN_URL_DEFAULT_LABEL", "Default Forum URLs");
define("FORUM_LAN_URL_DEFAULT_DESCR", "URLs of 'GET type' with no single entry point. Examples:<br />http://yoursite.com/e107_plugins/forum/forum.php (forum index)<br />http://yoursite.com/e107_plugins/forum/forum_viewtopic.php?id=2 (thread view)");
// TODO - awaiting forum SEF config
define("FORUM_LAN_URL_REWRITE_LABEL", "SEF Forum URLs (UNDER DEVELOPMENT)");
define("FORUM_LAN_URL_REWRITE_DESCR", "Examples:<br />UNDER DEVELOPMENT");

View File

@ -52,7 +52,7 @@ if($results = $e107->sql->db_Select_gen($qry))
{
if($row['user_name'])
{
$poster = "<a href='".$e107->url->getUrl('core:user', 'main', array('func' => 'profile', 'id' => $row['post_user']))."'>{$row['user_name']}</a>";
$poster = "<a href='".$e107->url->create('user/profile/view', array('name' => $row['user_name'], 'id' => $row['post_user']))."'>{$row['user_name']}</a>";
}
else
{
@ -63,7 +63,7 @@ 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']);
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'last', 'id' => $id));
$url = $e107->url->create('forum/thread/last', $row);
//TODO legacy bullet is not use here anymore
//$bullet = "<img src='".THEME_ABS.'images/'.(defined('BULLET') ? BULLET : 'bullet2.gif')."' alt='' />";

View File

@ -0,0 +1,169 @@
<?php
/*
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* Forum SEF URL configuration
* TODO - UNDER DEVELOPMENT
*/
class plugin_forum_rewrite_url extends eUrlConfig
{
public function config()
{
return array(
'config' => array(
'noSingleEntry' => true, // [optional] default false; disallow this module to be shown via single entry point when this config is used
'legacy' => '{e_PLUGIN}forum/forum.php', // this config won't work in single entry point mod (legacy not used at all), so just set this to default plugin file to notify router it's legacy module
'format' => 'get', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
'selfParse' => false, // [optional] default false; use only this->parse() method, no core routine URL parsing
'selfCreate' => true, // [optional] default false; use only this->create() method, no core routine URL creating
'defaultRoute' => 'forum/main', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
'legacyQuery' => '' // default legacy query string template, null to disable, empty - use current QUERY_STRING
),
// rule set array
'rules' => array()
);
}
/**
* NOTE we have double 'forum' but this is the best way to map new-old forum URLs to the new routing engine
* Additionally, 'forum' controller is descriptive, and leading 'forum' module name could be easiely changed (URL aliases administration page)
*/
public function create($route, $params = array(), $options = array())
{
$amp = varset($options['encode']) ? '&amp;' : '&';
if(is_string($route)) $route = explode('/', $route, 2);
if(!varset($route[0])) $route[0] = 'forum';
if(!varset($route[1])) $route[1] = 'main';
$base = e107::getInstance()->getFolder('plugins').'forum/';
//var_dump($options, $route, $params);
if($route[0] == 'forum')
{
if(!isset($params['id']) && isset($params['forum_id'])) $params['id'] = $params['forum_id'];
// if(isset($params['forum_name'])) $params['name'] = $params['forum_name']; - not used in this config
switch($route[1])
{
case 'view':
$page = (varset($params['page']) ? $amp.'p='.$params['page'] : '');
return $base."forum_viewforum.php?id={$params['id']}{$page}";
break;
case 'track':
return $base.'forum.php?track';
break;
case 'main':
return $base.'forum.php';
break;
case 'post':
return $base."forum_post.php?f={$params['type']}}id={$params['id']}";
break;
case 'rules':
return $base.'forum.php?f=rules';
break;
case 'mfar':
return $base.'forum.php?f=mfar'.$amp.'id='.$params['id'];
break;
}
}
elseif($route[0] == 'thread')
{
if(!isset($params['id']) && isset($params['thread_id'])) $params['id'] = $params['thread_id'];
// if(isset($params['thread_name'])) $params['name'] = $params['thread_name']; - not used in this config
switch($route[1])
{
case 'new':
return $base."forum_post.php?f=nt{$amp}id={$params['id']}";
break;
case 'reply':
return $base."forum_post.php?f=rp{$amp}id={$params['id']}";
break;
case 'view':
$page = (varset($params['page']) ? $amp.'p='.$params['page'] : '');
return $base."forum_viewtopic.php?id={$params['id']}{$page}";
break;
case 'last':
return $base."forum_viewtopic.php?id={$params['id']}{$amp}last=1";
break;
case 'post':
return $base."forum_viewtopic.php?f=post{$amp}id={$params['id']}";
break;
case 'report':
$page = (isset($params['page']) ? (int)$params['page'] : 0 );
return $base."forum_viewtopic.php?f=report{$amp}id={$params['id']}{$amp}post={$params['post']}{$amp}p={$page}";
break;
case 'edit':
return $base."forum_post.php?f=edit{$amp}id={$params['id']}";
break;
case 'move':
return $base."forum_conf.php?f=move{$amp}id={$params['id']}";
break;
case 'split':
return $base."forum_conf.php?f=split{$amp}id={$params['id']}";
break;
case 'quote':
return $base."forum_post.php?f=quote{$amp}id={$params['id']}";
break;
case 'next':
return $base."forum_viewtopic.php?f=next{$amp}id={$params['id']}";
break;
case 'prev':
return $base."forum_viewtopic.php?f=prev{$amp}id={$params['id']}";
break;
case 'track':
return $base."forum_viewtopic.php?f=track{$amp}id={$params['id']}";
break;
case 'untrack':
return $base."forum_viewtopic.php?f=untrack{$amp}id={$params['id']}";
break;
case 'track_toggle':
return $base."forum_viewtopic.php?f=track_toggle{$amp}id={$params['id']}";
break;
}
}
return false;
}
/**
* Admin callback
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
*/
public function admin()
{
// static may be used for performance
e107::plugLan('forum', 'lan_forum_url');
static $admin = array(
'labels' => array(
'name' => FORUM_LAN_URL_NAME, // Module name
'label' => FORUM_LAN_URL_REWRITE_LABEL, // Current profile name
'description' => FORUM_LAN_URL_REWRITE_DESCR, //
),
'form' => array(), // Under construction - additional configuration options
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
);
return $admin;
}
}