Esempio n. 1
0
			<description><?php 
        // URL link, if the post has one: (TODO: move below the text, because in summaries or podcasts it blows to have this on top)
        $Item->url_link(array('before' => '<p>', 'after' => '</p>', 'format' => 'entityencoded', 'podcast' => false));
        // Display images that are linked to this post:
        $content = $Item->get_images(array('before' => '<div>', 'before_image' => '<div>', 'before_image_legend' => '<div><i>', 'after_image_legend' => '</i></div>', 'after_image' => '</div>', 'after' => '</div>', 'image_size' => $image_size), 'htmlbody');
        $content .= $Item->get_content_teaser(1, false);
        if ($feed_content == 'normal') {
            // Teasers only
            $content .= $Item->get_more_link(array('before' => '', 'after' => '', 'disppage' => 1));
        } else {
            // Full contents
            $content .= $Item->get_content_extension(1, true);
        }
        // Get content as "htmlbody", otherwise make_rel_links_abs() can't catch <a> and <img> tags
        // TODO: clean solution : work in format_to_output!
        echo format_to_output(make_rel_links_abs($content), 'entityencoded');
        // Display Item footer text (text can be edited in Blog Settings):
        $Item->footer(array('mode' => 'xml', 'block_start' => '<div class="item_footer">', 'block_end' => '</div>', 'format' => 'entityencoded'));
        ?>
</description>
			<content:encoded><![CDATA[<?php 
        // URL link, if the post has one:
        $Item->url_link(array('before' => '<p>', 'after' => '</p>', 'podcast' => false, 'format' => 'htmlfeed'));
        // Display images that are linked to this post:
        $Item->images(array('before' => '<div>', 'before_image' => '<div>', 'before_image_legend' => '<div><i>', 'after_image_legend' => '</i></div>', 'after_image' => '</div>', 'after' => '</div>', 'image_size' => 'fit-320x320'), 'htmlfeed');
        $Item->content_teaser(array('disppage' => 1, 'stripteaser' => false, 'format' => 'htmlfeed', 'before_image' => '<div>', 'before_image_legend' => '<div><i>', 'after_image_legend' => '</i></div>', 'after_image' => '</div>', 'image_size' => 'fit-320x320'));
        if ($feed_content == 'normal') {
            // Teasers only
            $Item->more_link(array('before' => '', 'after' => '', 'disppage' => 1, 'format' => 'htmlfeed'));
        } else {
            // Full contents
Esempio n. 2
0
        $Item->url_link(array('before' => '<p>', 'after' => '</p>', 'format' => 'entityencoded', 'podcast' => false));
        // Display images that are linked to this post:
        $content = $Item->get_images(array('before' => '<div>', 'before_image' => '<div>', 'before_image_legend' => '<div><i>', 'after_image_legend' => '</i></div>', 'after_image' => '</div>', 'after' => '</div>', 'image_size' => $image_size), 'entityencoded');
        $content .= $Item->get_content_teaser(1, false, 'entityencoded');
        if ($feed_content == 'normal') {
            // Teasers only
            $content .= $Item->get_more_link(array('before' => '', 'after' => '', 'disppage' => 1, 'format' => 'entityencoded'));
        } else {
            // Full contents
            $content .= $Item->get_content_extension(1, true, 'entityencoded');
        }
        // fp> this is another one of these "oooooh it's just a tiny little change"
        // and "we only need to make the links absolute in RSS"
        // and then you get half baked code! The URL LINK stays RELATIVE!! :((
        // TODO: clean solution : work in format_to_output!
        echo make_rel_links_abs($content);
        // Display Item footer text (text can be edited in Blog Settings):
        $Item->footer(array('mode' => 'xml', 'block_start' => '<div class="item_footer">', 'block_end' => '</div>', 'format' => 'entityencoded'));
        ?>
</description>
	<content:encoded><![CDATA[<?php 
        // URL link, if the post has one:
        $Item->url_link(array('before' => '<p>', 'after' => '</p>', 'podcast' => false, 'format' => 'htmlfeed'));
        // Display images that are linked to this post:
        $Item->images(array('before' => '<div>', 'before_image' => '<div>', 'before_image_legend' => '<div><i>', 'after_image_legend' => '</i></div>', 'after_image' => '</div>', 'after' => '</div>', 'image_size' => 'fit-320x320'), 'htmlfeed');
        $Item->content_teaser(array('disppage' => 1, 'stripteaser' => true, 'format' => 'htmlfeed', 'before_image' => '<div>', 'before_image_legend' => '<div><i>', 'after_image_legend' => '</i></div>', 'after_image' => '</div>', 'image_size' => 'fit-320x320'));
        if ($feed_content == 'normal') {
            // Teasers only
            $Item->more_link(array('before' => '', 'after' => '', 'disppage' => 1, 'format' => 'htmlfeed'));
        } else {
            // Full contents
Esempio n. 3
0
/**
 * Format a string/content for being output
 *
 * @author fplanque
 * @todo htmlspecialchars() takes a charset argument, which we could provide ($evo_charset?)
 * @param string raw text
 * @param string format, can be one of the following
 * - raw: do nothing
 * - htmlbody: display in HTML page body: allow full HTML
 * - entityencoded: Special mode for RSS 0.92: allow full HTML but escape it
 * - htmlhead: strips out HTML (mainly for use in Title)
 * - htmlattr: use as an attribute: escapes quotes, strip tags
 * - formvalue: use as a form value: escapes quotes and < > but leaves code alone
 * - text: use as plain-text, e.g. for ascii-mails
 * - xml: use in an XML file: strip HTML tags
 * - xmlattr: use as an attribute: strips tags and escapes quotes
 * @return string formatted text
 */
function format_to_output($content, $format = 'htmlbody')
{
    global $Plugins;
    switch ($format) {
        case 'raw':
            // do nothing!
            break;
        case 'htmlbody':
            // display in HTML page body: allow full HTML
            $content = convert_chars($content, 'html');
            break;
        case 'urlencoded':
            // Encode string to be passed as part of an URL
            $content = rawurlencode($content);
            break;
        case 'entityencoded':
            // Special mode for RSS 0.92: apply renders and allow full HTML but escape it
            $content = convert_chars($content, 'html');
            $content = htmlspecialchars($content, ENT_QUOTES);
            break;
        case 'htmlfeed':
            // For use in RSS <content:encoded>, allow full HTML + absolute URLs
            $content = make_rel_links_abs($content);
            $content = convert_chars($content, 'html');
            $content = str_replace(']]>', ']]&gt;', $content);
            // encode CDATA closing tag
            break;
        case 'htmlhead':
            // Strips out HTML (mainly for use in Title)
            $content = strip_tags($content);
            $content = convert_chars($content, 'html');
            break;
        case 'htmlattr':
            // use as an attribute: strips tags and escapes quotes
            // TODO: dh> why not just htmlspecialchars?fp> because an attribute can never contain a tag? dh> well, "onclick='return 1<2;'" would get stripped, too. I'm just saying: why mess with it, when we can just use htmlspecialchars.. fp>ok
            $content = strip_tags($content);
            $content = convert_chars($content, 'html');
            $content = str_replace(array('"', "'"), array('&quot;', '&#039;'), $content);
            break;
        case 'htmlspecialchars':
        case 'formvalue':
            // use as a form value: escapes &, quotes and < > but leaves code alone
            $content = htmlspecialchars($content, ENT_QUOTES);
            // Handles &, ", ', < and >
            break;
        case 'xml':
            // use in an XML file: strip HTML tags
            $content = strip_tags($content);
            $content = convert_chars($content, 'xml');
            break;
        case 'xmlattr':
            // use as an attribute: strips tags and escapes quotes
            $content = strip_tags($content);
            $content = convert_chars($content, 'xml');
            $content = str_replace(array('"', "'"), array('&quot;', '&#039;'), $content);
            break;
        case 'text':
            // use as plain-text, e.g. for ascii-mails
            $content = strip_tags($content);
            $trans_tbl = get_html_translation_table(HTML_ENTITIES);
            $trans_tbl = array_flip($trans_tbl);
            $content = strtr($content, $trans_tbl);
            $content = preg_replace('/[ \\t]+/', ' ', $content);
            $content = trim($content);
            break;
        default:
            debug_die('Output format [' . $format . '] not supported.');
    }
    return $content;
}
Esempio n. 4
0
    $Comment->author('', '#', '', '#', 'xml');
    ?>
</dc:creator>
			<guid isPermaLink="false">c<?php 
    $Comment->ID();
    ?>
@<?php 
    echo $baseurl;
    ?>
</guid>
			<description><?php 
    echo make_rel_links_abs($Comment->get_content('entityencoded'));
    ?>
</description>
			<content:encoded><![CDATA[<?php 
    echo make_rel_links_abs($Comment->get_content());
    ?>
]]></content:encoded>
			<link><?php 
    $Comment->permanent_url();
    ?>
</link>
		</item>
		<?php 
}
/* End of comment loop. */
?>
	</channel>
</rss>
<?php 
$Hit->log();
 /**
  * Tests {@link make_rel_links_abs()}.
  */
 function test_make_rel_links_abs()
 {
     $this->assertEqual(make_rel_links_abs('foo <a href="/bar">bar</a>', 'http://example.com'), 'foo <a href="http://example.com/bar">bar</a>');
     $this->assertEqual(make_rel_links_abs('foo <a href="http://test/bar">bar</a> <img src="/bar" />', 'http://example.com'), 'foo <a href="http://test/bar">bar</a> <img src="http://example.com/bar" />');
 }
Esempio n. 6
0
		<?php 
while ($Comment =& $CommentList->get_next()) {
    // Loop through comments:
    // Load comment's Item:
    $Comment->get_Item();
    ?>
		<item>
			<title><?php 
    echo format_to_output(T_('In response to:'), 'xml');
    ?>
 <?php 
    $Comment->Item->title(array('format' => 'xml', 'link_type' => 'none'));
    ?>
</title>
			<description><?php 
    echo make_rel_links_abs($Comment->get_content('entityencoded'));
    ?>
</description>
			<link><?php 
    $Comment->permanent_url();
    ?>
</link>
		</item>
		<?php 
}
// End of comment loop.
?>
  </channel>
</rss>
<?php 
$Hit->log();