[RC1] Full Syndication Suite 1.0.RC1 (RSS/ATOM)

MOD Authors: Discuss and post updates on new MODs in development for phpBB3, Receive feedback and Feature requests for MODs in development.

To submit your MOD or style, go to the STG MOD Manager
Forum rules
go to the STG MOD Manager to post your MOD in development.
Discuss and receive feedback for any MOD in development for phpBB3.
Suggest features for MODs in development.

No Support or MOD Requests
-- exceptions for MODs only posted here as Beta or Alpha.
Support requests for a MOD should be requested in the respective MOD topic.

Re: [DEV] Advanced Syndication MOD

Postby hurry » 03 Apr 2007, 20:48

I am using a framed site for one forum so the RSS feed icons don't appear in the browser address bar Sad. 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
Lieutenant
Lieutenant
 
Posts: 202
Joined: 09 Mar 2007, 12:26
Gender: Male


Re: [DEV] Advanced Syndication MOD

Postby hurry » 04 Apr 2007, 00:02

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.
hurry
Lieutenant
Lieutenant
 
Posts: 202
Joined: 09 Mar 2007, 12:26
Gender: Male

Re: [DEV] Advanced Syndication MOD

Postby Tuk » 04 Apr 2007, 04:24

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.


Can you please show me the source code of this site (right click -> show source code)? There probably is an error message instead of the feed, that's why the parsing fails.

(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?

Yes, it does.
(2) Can we exclude specific forum(s) from the full forum post and topic RSS feed?

That's currently not possible. But also in regard of your second post, I think I'll have to reconsider the implementation of the user interface. There are so many variations possible of how to create a feed, that it doesn't seem to make sense to only make a few fixed feeds available.

(3) How do we change the number of items in the RSS feed?

The administrator can set this in ACP's "Load Settings". The user can't change this right now, but I plan to change this while redoing the user interface.

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.

Yes, that's true. Thanks for noticing.

Yesterday I did a install of my MOD on a clean board and everything was working fine, so I'm optimistic that we will get it functional for you as well Wink.
"If sharks die, the sea dies" - Andy Cobb, ambassador SHARKPROJECT South Africa
User avatar
Tuk
Supporter
Supporter
 
Posts: 271
Joined: 17 Jul 2006, 11:46
Gender: Male

Re: [DEV] Advanced Syndication MOD

Postby hurry » 04 Apr 2007, 05:17

I sent to you. Please check and let me know. I am awaiting. Thanks.

Edit: It seems the STG server emails are not working. I have stopped receiving the emails of the topics which I am subscribed too many days back.

Edit: Sorry I figured out that they were all going to the spam folder. I hope there is a solution for this as being discussed in another topic on STG.
hurry
Lieutenant
Lieutenant
 
Posts: 202
Joined: 09 Mar 2007, 12:26
Gender: Male

Re: [DEV] Advanced Syndication MOD

Postby Tuk » 04 Apr 2007, 08:00

Can you please put this file as generate_feed_debug.php in your board directory?

Code: Select all
<?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&amp;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&amp;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&amp;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&amp;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&amp;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;
   }
}

?>

It is basically the same file as generate_feed.php but I added a lot of debug outputs which should help me to find the problem. It seems as if everything works fine up to the point where the template is displayed. I'm not yet sure what the problem is, I even installed the same php version as on your server but couldn't reproduce it. It must be an issue with some server/php settings I guess.
"If sharks die, the sea dies" - Andy Cobb, ambassador SHARKPROJECT South Africa
User avatar
Tuk
Supporter
Supporter
 
Posts: 271
Joined: 17 Jul 2006, 11:46
Gender: Male

Re: [DEV] Advanced Syndication MOD

Postby hurry » 04 Apr 2007, 10:51

Ok, done and uploaded. You can check now. I tried loading it in the browser and it says: This script has been called incorrectly. I really hope there is a solution. Thanks so so much.
hurry
Lieutenant
Lieutenant
 
Posts: 202
Joined: 09 Mar 2007, 12:26
Gender: Male

Re: [DEV] Advanced Syndication MOD

Postby hurry » 04 Apr 2007, 10:53

I have eaccelerator and memcached installed. I hope that is not a problem.
hurry
Lieutenant
Lieutenant
 
Posts: 202
Joined: 09 Mar 2007, 12:26
Gender: Male

Re: [DEV] Advanced Syndication MOD

Postby Tuk » 04 Apr 2007, 14:16

There is indeed something wrong with the template engine. The script works absolutely fine, up to the line with
Code: Select all
$template->display('body');

I'll try to provide an version of the MOD which uses the echo function instead of the template engine, hopefully this will do the trick.

By the way, I'm working on a new user interface. I'll give you a preview:
ui.jpg

With this new interface every user will be able to create his very own, unique and custom feed Smile. I'm also rewriting large parts of the MOD to make the code cleaner and more increase performance.

This is what a feed looks like once it is working Wink:
example.jpg
"If sharks die, the sea dies" - Andy Cobb, ambassador SHARKPROJECT South Africa
User avatar
Tuk
Supporter
Supporter
 
Posts: 271
Joined: 17 Jul 2006, 11:46
Gender: Male

Re: [DEV] Advanced Syndication MOD

Postby Handyman » 04 Apr 2007, 14:48

It's probably not a good idea to do an echo version since everything that can be done with an echo can be done with the templates? did you try it in the latest CVS or a Beta 5?
Beta 5 will give you a blank page if there's a problem? the CVS will tell you what the problem is so you can fix it.
Please contact me if you have any news to submit to SCOFF News.
SCOFFing at the candidates while you sleep.
My Mods || My Mod Queue
Image
User avatar
Handyman    
Rear Fleet Admiral
Rear Fleet Admiral
 
Posts: 7454
Joined: 08 May 2006, 04:45
Location: Where no man has gone before!
Favorite Team: Seattle Seahawks
Gender: Male

Re: [DEV] Advanced Syndication MOD

Postby Tuk » 04 Apr 2007, 16:32

I'm always developing with CVS (and properly will aways do so until at least RC1). hurry must be using CVS too as he has prosilver installed on his board. Maybe it is an old CVS version except of the styles.

I would like to release version 0.0.2a.

Changelog:
  • Applied various fixes to installation file and download package.
  • Rewrote large parts for better structure and code quality, including many bugfixes.
  • Added feature for user being able to create own feeds easily (see screenshot in my last post). This is in addition to the "standard feeds" which are displayed on index,php, viewtopic.php and viewforum.php.

Files that have changed:
  • all included files (there are new files included)
  • includes/functions.php
  • styles/prosilver/template/overall_header.html
  • adm/style/acp_forums.html

Todo list:
  • private feeds
  • ATOM support
hurry, you may try if this version changes anything for you, but I don't think so.
Maybe someone else can give it a go so that we can see if this is a general or specific problem in only some cases.
"If sharks die, the sea dies" - Andy Cobb, ambassador SHARKPROJECT South Africa
User avatar
Tuk
Supporter
Supporter
 
Posts: 271
Joined: 17 Jul 2006, 11:46
Gender: Male

PreviousNext

Return to MODs in Development

Who is online

Users browsing this forum: No registered users and 16 guests