1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-26 04:52:36 +01:00
php-phpbb/phpBB/phpbb/feed/post_base.php
Dhruv fd9366daf5 Merge branch 'ticket/11271' into ticket/11271-develop
* ticket/11271:
  [ticket/11271] Add docblock of feed_generate_content( )
  [ticket/11271] Fix tabs and use !empty( ) instead of count( )
  [ticket/11271] Remove unnecessary inclusion of functions_display
  [ticket/11271] Typecast forum and topic id to integer
  [ticket/11271] Use absolute path for displaying inline attachments in feeds
  [ticket/11271] Changed executable bit.
  [ticket/11271] Formatting code and removing null assignment.
  [ticket/11271] Removing unnecessary database object
  [ticket/11271] Separated attachment fetching query
  [ticket/11271] Fetched feed attachments before loop.
  [ticket/11271] Removed in-line attachment comments properly.
  [ticket/11271] Displaying in-line attached images in ATOM feed.

Conflicts:
	phpBB/feed.php
2013-12-27 01:33:32 +05:30

90 lines
2.4 KiB
PHP

<?php
/**
*
* @package phpBB3
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\feed;
/**
* Abstract class for post based feeds
*
* @package phpBB3
*/
abstract class post_base extends \phpbb\feed\base
{
var $num_items = 'feed_limit_post';
var $attachments = array();
function set_keys()
{
$this->set('title', 'post_subject');
$this->set('title2', 'topic_title');
$this->set('author_id', 'user_id');
$this->set('creator', 'username');
$this->set('published', 'post_time');
$this->set('updated', 'post_edit_time');
$this->set('text', 'post_text');
$this->set('bitfield', 'bbcode_bitfield');
$this->set('bbcode_uid','bbcode_uid');
$this->set('enable_bbcode', 'enable_bbcode');
$this->set('enable_smilies', 'enable_smilies');
$this->set('enable_magic_url', 'enable_magic_url');
}
function adjust_item(&$item_row, &$row)
{
$item_row['link'] = $this->helper->append_sid('viewtopic.' . $this->phpEx, "t={$row['topic_id']}&amp;p={$row['post_id']}#p{$row['post_id']}");
if ($this->config['feed_item_statistics'])
{
$item_row['statistics'] = $this->user->lang['POSTED'] . ' ' . $this->user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row)
. ' ' . $this->separator_stats . ' ' . $this->user->format_date($row[$this->get('published')])
. (($this->is_moderator_approve_forum($row['forum_id']) && $row['post_visibility'] !== ITEM_APPROVED) ? ' ' . $this->separator_stats . ' ' . $this->user->lang['POST_UNAPPROVED'] : '');
}
}
function fetch_attachments()
{
$sql_array = array(
'SELECT' => 'a.*',
'FROM' => array(
ATTACHMENTS_TABLE => 'a'
),
'WHERE' => 'a.in_message = 0 ',
'ORDER_BY' => 'a.filetime DESC, a.post_msg_id ASC',
);
if (isset($this->topic_id))
{
$sql_array['WHERE'] .= 'AND a.topic_id = ' . (int) $this->topic_id;
}
else if (isset($this->forum_id))
{
$sql_array['LEFT_JOIN'] = array(
array(
'FROM' => array(TOPICS_TABLE => 't'),
'ON' => 'a.topic_id = t.topic_id',
)
);
$sql_array['WHERE'] .= 'AND t.forum_id = ' . (int) $this->forum_id;
}
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query($sql);
// Set attachments in feed items
while ($row = $this->db->sql_fetchrow($result))
{
$this->attachments[$row['post_msg_id']][] = $row;
}
$this->db->sql_freeresult($result);
}
}