Skip to content

Commit

Permalink
Merge branch 'w14_MDL-34222_m25_simplepie131' of git://github.com/sko…
Browse files Browse the repository at this point in the history
…dak/moodle
  • Loading branch information
stronk7 committed Apr 8, 2013
2 parents b19e8a1 + d958e6b commit de0fc86
Show file tree
Hide file tree
Showing 41 changed files with 19,343 additions and 14,566 deletions.
13 changes: 9 additions & 4 deletions blocks/rss_client/block_rss_client.php
Expand Up @@ -231,10 +231,15 @@ function get_item_html($item){
if(empty($link)){
$link = $item->get_id();
} else {
//URLs in our RSS cache will be escaped (correctly as theyre store in XML)
//html_writer::link() will re-escape them. To prevent double escaping unescape here.
//This can by done using htmlspecialchars_decode() but moodle_url also has that effect
$link = new moodle_url($link);
try {
// URLs in our RSS cache will be escaped (correctly as theyre store in XML)
// html_writer::link() will re-escape them. To prevent double escaping unescape here.
// This can by done using htmlspecialchars_decode() but moodle_url also has that effect.
$link = new moodle_url($link);
} catch (moodle_exception $e) {
// Catching the exception to prevent the whole site to crash in case of malformed RSS feed
$link = '';
}
}

$r = html_writer::start_tag('li');
Expand Down
7 changes: 4 additions & 3 deletions blog/external_blog_edit_form.php
Expand Up @@ -75,13 +75,14 @@ public function validation($data, $files) {

require_once($CFG->libdir . '/simplepie/moodle_simplepie.php');

$rssfile = new moodle_simplepie_file($data['url']);
$filetest = new SimplePie_Locator($rssfile);
$rss = new moodle_simplepie();
$rssfile = $rss->registry->create('File', array($data['url']));
$filetest = $rss->registry->create('Locator', array($rssfile));

if (!$filetest->is_feed($rssfile)) {
$errors['url'] = get_string('feedisinvalid', 'blog');
} else {
$rss = new moodle_simplepie($data['url']);
$rss->set_feed_url($data['url']);
if (!$rss->init()) {
$errors['url'] = get_string('emptyrssfeed', 'blog');
}
Expand Down
8 changes: 5 additions & 3 deletions blog/lib.php
Expand Up @@ -147,8 +147,9 @@ function blog_sync_external_entries($externalblog) {
global $CFG, $DB;
require_once($CFG->libdir . '/simplepie/moodle_simplepie.php');

$rssfile = new moodle_simplepie_file($externalblog->url);
$filetest = new SimplePie_Locator($rssfile);
$rss = new moodle_simplepie();
$rssfile = $rss->registry->create('File', array($externalblog->url));
$filetest = $rss->registry->create('Locator', array($rssfile));

if (!$filetest->is_feed($rssfile)) {
$externalblog->failedlastsync = 1;
Expand All @@ -159,7 +160,8 @@ function blog_sync_external_entries($externalblog) {
$DB->update_record('blog_external', $externalblog);
}

$rss = new moodle_simplepie($externalblog->url);
$rss->set_feed_url($externalblog->url);
$rss->init();

if (empty($rss->data)) {
return null;
Expand Down
86 changes: 86 additions & 0 deletions lib/simplepie/autoloader.php
@@ -0,0 +1,86 @@
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2009, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/


// autoloader
spl_autoload_register(array(new SimplePie_Autoloader(), 'autoload'));

if (!class_exists('SimplePie'))
{
trigger_error('Autoloader not registered properly', E_USER_ERROR);
}

/**
* Autoloader class
*
* @package SimplePie
* @subpackage API
*/
class SimplePie_Autoloader
{
/**
* Constructor
*/
public function __construct()
{
$this->path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'library';
}

/**
* Autoloader
*
* @param string $class The name of the class to attempt to load.
*/
public function autoload($class)
{
// Only load the class if it starts with "SimplePie"
if (strpos($class, 'SimplePie') !== 0)
{
return;
}

$filename = $this->path . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
include $filename;
}
}

0 comments on commit de0fc86

Please sign in to comment.