. So I think it would be great to have noticeable icons on the pages as well which will be a help for those browsers which do not auto-detect feeds also.
. So I think it would be great to have noticeable icons on the pages as well which will be a help for those browsers which do not auto-detect feeds also.

hurry wrote:
- Code: Select all
XML Parsing Error: no element found
Location: http://mysite.com/generate_feed.php?mode=global_posts&sub=1
Line Number 1, Column 1:
^
Message
XML Parsing error: syntax error
Explanation
Your feed is not well formed according to the XML specification. All feeds should be well-formed XML.
(1) Does it show the full text of the posts? I want it to show the full post text with the bbcode?
(4) Does it parse custom bbcodes?
(2) Can we exclude specific forum(s) from the full forum post and topic RSS feed?
(3) How do we change the number of items in the RSS feed?
hurry wrote:The first and third changes in the acp_forums file in the MOD seems to be duplicate so I did three only instead of four in that file. But I cannot see the Enable Syndication option in the edit forum page in the ACP.
.

<?php
/**
*
* @package phpBB3
* @version $Id$
* @copyright (c) 2007 Niklas Schmidtmer
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
* @todo
* - RSS1?, Atom; currently only RSS2 supported
* - split global_*, code gets to unclean
* - think about caching certain queries
*
* Currently supported modes:
* - forum_topics: topic titles of a forum/category with post_text of first post
* - forum_posts: post_text of a forum/category
* - topic_posts: post_text of a topic's posts
* - global_posts: boardwide posts
* - global_topics: boardwide topics
*/
/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/syndication');
if (!$config['enable_syndication'])
{
trigger_error('SERVICE_UNAVAILABLE');
}
$forum_id = request_var('f', 0);
$topic_id = request_var('t', 0);
$mode = request_var('mode', '');
$include_subforums = request_var('sub', false);
$global_mode = ($mode == 'global_posts' || $mode == 'global_topics') ? true : false;
if ((!$forum_id && !$global_mode && !$topic_id) || !$mode)
{
trigger_error('INVALID_INPUT');
}
var_dump($forum_id, $topic_id, $mode, $include_subforums, $global_mode);
// get subforums if requested
if ($include_subforums)
{
// if no forum_id is provided, obtain the lowest id to start search for subforums from
if (!$forum_id)
{
$sql = 'SELECT MIN(forum_id) AS forum_id
FROM ' . FORUMS_TABLE;
$result = $db->sql_query($sql, 900);
$row = $db->sql_fetchrow($result);
$forum_id = $row['forum_id'];
}
// obtain all children of given forum
$forums = array();
get_subforums($forum_id, $forums);
echo "subforums:\n";
var_dump($forums);
}
else if (!$auth->acl_get('f_read', $forum_id))
{
trigger_error('SORRY_AUTH_READ');
}
if (!$global_mode)
{
// obtain forum name, check if syndication has been disabled for this forum
// @todo category setting superseeds forum?
$sql = 'SELECT forum_name, enable_syndication
FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $forum_id;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$row['enable_syndication'])
{
trigger_error('SYNDICATION_DISABLED');
}
$forum_name = $row['forum_name'];
echo '$forum_name: ';
var_dump($forum_name);
}
$board_url = generate_board_url();
echo '$board_url: ';
var_dump($board_url);
echo "calling mode\n---------------------\n";
switch ($mode)
{
/**
* syndicate topics of a forum
*/
case 'forum_topics':
case 'global_topics':
if ($mode == 'forum_topics')
{
$title = sprintf($user->lang['SYNDICATION_TITLE'], $forum_name);
$description = sprintf($user->lang['SYNDICATION_FORUM_TOPICS'], $forum_name, $config['sitename']);
$source_link = "{$board_url}/viewforum.$phpEx?f=$forum_id";
}
else
{
$title = sprintf($user->lang['SYNDICATION_TITLE'], $config['sitename']);
$description = sprintf($user->lang['SYNDICATION_GLOBAL_TOPICS'], $config['sitename']);
$source_link = "{$board_url}/index.$phpEx";
}
echo "details:\n";
var_dump($title, $description, $source_link);
$where_sql = generate_where_sql('t.forum_id');
$sql = 'SELECT t.forum_id, t.topic_id, topic_title, topic_first_poster_name, topic_time, post_text, bbcode_uid, bbcode_bitfield
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p
WHERE p.post_id = t.topic_first_post_id
AND p.post_approved = 1
AND $where_sql
ORDER BY post_time DESC";
$result = $db->sql_query_limit($sql, $config['syndication_items']);
echo "starting loop\n";
while ($row = $db->sql_fetchrow($result))
{
($mode == 'global_topics') ? $forum_id = $row['forum_id'] : '';
var_dump($row);
$template->assign_block_vars('item', array(
'AUTHOR' => $row['topic_first_poster_name'],
'TIME' => date('r', $row['topic_time']),
'LINK' => "{$board_url}/viewtopic.$phpEx?f=$forum_id&t={$row['topic_id']}",
'TITLE' => $row['topic_title'],
'TEXT' => parse_message($row['post_text'], $row['bbcode_bitfield'], $row['bbcode_uid']))
);
}
$db->sql_freeresult($result);
break;
/**
* syndicate posts of a forum
*/
case 'forum_posts':
case 'global_posts':
if ($mode == 'forum_posts')
{
$title = sprintf($user->lang['SYNDICATION_TITLE'], $forum_name);
$description = sprintf($user->lang['SYNDICATION_FORUM_POSTS'], $forum_name, $config['sitename']);
$source_link = "{$board_url}/viewtopic.$phpEx?f=$forum_id&t=$topic_id";
}
else
{
$title = sprintf($user->lang['SYNDICATION_TITLE'], $config['sitename']);
$description = sprintf($user->lang['SYNDICATION_GLOBAL_POSTS'], $config['sitename']);
$source_link = "{$board_url}/index.$phpEx";
}
echo "details:\n";
var_dump($title, $description, $source_link);
$where_sql = generate_where_sql('forum_id');
$sql = 'SELECT forum_id, topic_id, post_id, post_text, post_username, post_time, post_subject, bbcode_bitfield, bbcode_uid
FROM ' . POSTS_TABLE . "
WHERE post_approved = 1
AND $where_sql
ORDER BY post_time DESC";
$result = $db->sql_query_limit($sql, $config['syndication_items']);
echo "starting loop\n";
while ($row = $db->sql_fetchrow($result))
{
if ($mode == 'global_posts')
{
$forum_id = $row['forum_id'];
$topic_id = $row['topic_id'];
}
var_dump($row);
$template->assign_block_vars('item', array(
'AUTHOR' => $row['post_username'],
'TIME' => date('r', $row['post_time']),
'LINK' => "{$board_url}/viewtopic.$phpEx?f=$forum_id&t=$topic_id#p{$row['post_id']}",
'TITLE' => $row['post_subject'],
'TEXT' => parse_message($row['post_text'], $row['bbcode_bitfield'], $row['bbcode_uid']))
);
}
$db->sql_freeresult($result);
break;
/**
* syndicate posts of a topic
*/
case 'topic_posts':
//obtain topic title
$sql = 'SELECT topic_title
FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $topic_id;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$title = sprintf($user->lang['SYNDICATION_TITLE'], $row['topic_title']);
$description = sprintf($user->lang['SYNDICATION_TOPIC'], $row['topic_title'], $config['sitename']);
$source_link = "{$board_url}/viewtopic.$phpEx?f=$forum_id&t=$topic_id";
echo "details:\n";
var_dump($title, $description, $source_link);
$sql = 'SELECT post_id, post_text, post_username, post_time, post_subject, bbcode_bitfield, bbcode_uid
FROM ' . POSTS_TABLE . '
WHERE topic_id = ' . $topic_id . '
AND post_approved = 1
ORDER BY post_time DESC';
$result = $db->sql_query_limit($sql, $config['syndication_items']);
echo "starting loop\n";
while ($row = $db->sql_fetchrow($result))
{
var_dump($row);
$template->assign_block_vars('item', array(
'AUTHOR' => $row['post_username'],
'TIME' => date('r', $row['post_time']),
'LINK' => "{$board_url}/viewtopic.$phpEx?f=$forum_id&t=$topic_id#p={$row['post_id']}",
'TITLE' => $row['post_subject'],
'TEXT' => parse_message($row['post_text'], $row['bbcode_bitfield'], $row['bbcode_uid']))
);
}
$db->sql_freeresult($result);
break;
default:
trigger_error('INVALID_INPUT');
}
echo "finished switch\n";
echo "-------------------\n";
echo "template after switch: ";
var_dump($template);
// start preparing the template
$template->set_filenames(array(
'body' => 'syndication_rss2.xml')
);
$template->assign_vars(array(
'HEADER' => '<?xml version="1.0" encoding="UTF-8" ?>', // workaround for remove_php_tags() removing this line
'TITLE' => $title,
'DESCRIPTION' => $description,
'LINK' => $source_link)
);
echo "\n--------------\ntemplate before parsing: ";
var_dump($template);
// start output
//header ('Content-Type: text/xml');
$template->display('body');
exit;
/**
* parse a message
*/
function parse_message($message, $bbcode_bitfield, $bbcode_uid)
{
global $board_url;
$message = censor_text($message);
// Second parse bbcode here
if ($bbcode_bitfield)
{
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
$bbcode->bbcode_second_pass($message, $bbcode_uid, $bbcode_bitfield);
}
$message = smiley_text($message);
// smilies contain relative URL, we need it to be absolute
$message = str_replace('<img src="./', '<img src="' . $board_url . '/', $message);
return htmlspecialchars($message);
}
/**
* get all subforums of a specified forum, including the given forum itself
*/
function get_subforums($forum_id, &$forums)
{
global $auth, $db;
$sql = 'SELECT left_id, right_id, enable_syndication
FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $forum_id;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row['enable_syndication'] && $auth->acl_get('f_read', $forum_id))
{
$forums[] = (int) $forum_id;
}
if ($row['right_id'] - $row['left_id'] > 1)
{
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . '
WHERE parent_id = ' . (int) $forum_id;
$child_result = $db->sql_query($sql);
while ($child_row = $db->sql_fetchrow($child_result))
{
get_subforums($child_row['forum_id'], $forums);
}
$db->sql_freeresult($child_result);
}
}
/**
* generates where_sql condition for including subforums
*/
function generate_where_sql($forum_id_column)
{
global $include_subforums;
if ($include_subforums)
{
global $forums;
if (sizeof($forums))
{
global $db;
return $db->sql_in_set('forum_id', $forums);
}
else
{
// no forums to query means that syndication has been disabled for all forums
return "$forum_id_column = 0";
}
}
else
{
global $forum_id;
return 'forum_id = ' . $forum_id;
}
}
?>


$template->display('body');
. I'm also rewriting large parts of the MOD to make the code cleaner and more increase performance.
:



Users browsing this forum: No registered users and 16 guests