예제 #1
0
파일: feeds.php 프로젝트: rmccue/Lilina
/**
 * feed_list_table() - {@internal Missing Short Description}}
 *
 * {@internal Missing Long Description}}
 */
function feed_list_table()
{
    //Defined in admin panel
    $feeds = Feeds::get_instance()->getAll();
    $j = 0;
    $table = '';
    if (is_array($feeds) && !empty($feeds)) {
        foreach ($feeds as $this_feed) {
            $table .= '
		<tr id="feed-' . $j . '" class="' . ($j % 2 ? 'alt' : '') . '">
			<td class="name-col"><span>' . stripslashes($this_feed['name']) . '</span></td>
			<td class="url-col"><span>' . $this_feed['feed'] . '</span></td>
			<!--<td class="cat-col"><span>' . $this_feed['cat'] . '</span></td>-->
			' . apply_filters('admin-feeds-infocol', '', $this_feed, $j) . '
			<!--<td class="change-col"><a href="feeds.php?change=' . $j . '&amp;action=change" class="change_link">' . _r('Change') . '</a></td>-->
			<td class="remove-col"><a href="feeds.php?remove=' . $j . '&amp;action=remove">' . _r('Remove') . '</a></td>
			' . apply_filters('admin-feeds-actioncol', '', $this_feed, $j) . '
		</tr>';
            ++$j;
        }
    } else {
        $table = '<tr id="nofeeds"><td>' . _r('You don\'t currently have any feeds. Try <a href="#add_form">adding some</a>.') . '</td></tr>';
    }
    return $table;
}
예제 #2
0
 public static function run()
 {
     if (isset($_GET['test'])) {
         return self::success_page('xyz');
     }
     if (isset($_GET['test2'])) {
         return self::sub_page('FAIL');
     }
     if (empty($_POST['url'])) {
         return self::sub_page();
     }
     try {
         $_GET['url'] = $_POST['url'];
         $result = Feeds::get_instance()->add($_POST['url'], $_POST['name']);
     } catch (Exception $e) {
         return self::sub_page($e->getMessage());
     }
     return self::success_page($result);
 }
예제 #3
0
 /**
  * Callback for feeds.get
  */
 public static function feeds_get()
 {
     return Feeds::get_instance()->getAll();
 }
예제 #4
0
/**
 * Check for the existence of a feed based on a ID
 *
 * @deprecated Use Feeds::get_instance()->get($id) instead
 * Checks whether the supplied feed is in the feed list
 * @param string $id ID to lookup
 * @return array|bool Returns the feed array if found, false otherwise
 */
function feed_exists($id)
{
    return !!Feeds::get_instance()->get($id);
}
예제 #5
0
?>
</h1>
<?php 
if (count(Feeds::get_instance()->getAll()) === 0) {
    ?>
<p><?php 
    _e("Firstly, thanks for using Lilina! To help you settle in, we've included a few nifty tools in Lilina, just to help you get started.");
    ?>
</p>
<?php 
} else {
    $updated = get_option('last_updated');
    if (!$updated) {
        $message = sprintf(_r('You currently have %d items in %d feeds. Never updated.', count(Items::get_instance()->get_items()), count(Feeds::get_instance()->getAll())));
    } else {
        $message = sprintf(_r('You currently have %d items in %d feeds. Last updated %s.'), count(Items::get_instance()->get_items()), count(Feeds::get_instance()->getAll()), relative_time($updated));
    }
    ?>
<p><?php 
    echo $message;
    ?>
</p>
<?php 
}
?>
<h2><?php 
_e('Import');
?>
</h2>
<p><?php 
_e("We can import from any service which supports an open standard called OPML. Here's some services you can import from:");
예제 #6
0
_e('Edit your feeds');
?>
</a></li>
	<li><a href="settings.php"><?php 
_e('Change your settings');
?>
</a></li>
</ul>
<div class="dashbox" id="contain_feeds">
	<h3><?php 
_e('Current Feeds');
?>
</h3>
	<ul>
<?php 
$feed_list = Feeds::get_instance()->getAll();
if (is_array($feed_list)) {
    foreach ($feed_list as $this_feed) {
        if (isset($this_feed['name']) && !empty($this_feed['name'])) {
            echo '
	<li><a href="' . $this_feed['feed'] . '">' . stripslashes($this_feed['name']) . '</a></li>';
        } else {
            echo '
	<li><a href="' . $this_feed['feed'] . '">' . _r('(No title specified)') . '</a></li>';
        }
    }
} else {
    echo '<li>' . _r('No feeds installed yet.') . '</li>';
}
?>
	</ul>
예제 #7
0
 * @author Feed on Feeds Team
 * @package Lilina
 * @version 1.0
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 */
/** */
define('LILINA_PATH', dirname(__FILE__));
define('LILINA_INCPATH', LILINA_PATH . '/inc');
define('LILINA_PAGE', 'favicon');
// Hide errors
ini_set('display_errors', false);
require_once LILINA_INCPATH . '/contrib/simplepie.class.php';
require_once LILINA_INCPATH . '/core/conf.php';
require_once LILINA_INCPATH . '/core/plugin-functions.php';
if (isset($_GET['feed'])) {
    $feed = Feeds::get_instance()->get($_GET['feed']);
    if ($feed !== false && $feed['icon'] === true) {
        $data = new DataHandler(get_option('cachedir'));
        $data = $data->load($feed['id'] . '.ico');
        if ($data !== null) {
            $icon = unserialize($data);
            header('Content-Type: ' . $icon['type']);
            header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT');
            // 7 days
            echo $icon['body'];
            die;
        }
    }
    $_GET['i'] = 'default';
}
if (!isset($_GET['i'])) {
예제 #8
0
/**
* Gets all feeds and returns as an array
*
* @return array List of feeds and associated data
*/
function get_feeds()
{
    return apply_filters('get_feeds', Feeds::get_instance()->getAll());
}
예제 #9
0
/**
 * Check for the existence of a feed based on a URL
 *
 * Checks whether the supplied feed is in the feed list
 * @param string $url URL to lookup
 * @return array|bool Returns the feed array if found, false otherwise
 */
function feed_exists($url)
{
    global $data;
    foreach (Feeds::get_instance()->getAll() as $feed) {
        if ($feed['url'] === $url || strpos($feed['url'], $url)) {
            return $feed;
        }
    }
    return false;
}
예제 #10
0
    /**
     * Page header
     */
    protected function page()
    {
        header('Content-Type: text/html; charset=utf-8');
        $feeds = Feeds::get_instance()->getAll();
        foreach ($feeds as &$feed) {
            $feed = $feed['id'];
        }
        $feeds = array_values($feeds);
        ?>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
		<title><?php 
        _e('Item Updater');
        ?>
 &mdash; <?php 
        echo get_option('sitename');
        ?>
</title>
		<link rel="stylesheet" type="text/css" href="<?php 
        echo get_option('baseurl');
        ?>
admin/resources/reset.css" />
		<link rel="stylesheet" type="text/css" href="<?php 
        echo get_option('baseurl');
        ?>
install.css" />
		<link rel="stylesheet" type="text/css" href="<?php 
        echo get_option('baseurl');
        ?>
admin/resources/iu.css" />
		<script type="text/javascript" src="<?php 
        echo get_option('baseurl');
        ?>
inc/js/jquery.js"></script>
		<script type="text/javascript" src="<?php 
        echo get_option('baseurl');
        ?>
inc/js/json2.js"></script>
		<script type="text/javascript" src="<?php 
        echo get_option('baseurl');
        ?>
admin/resources/iu.js"></script>
		<script type="text/javascript">
			ItemUpdater.location = "<?php 
        echo get_option('baseurl');
        ?>
";
			ItemUpdater.feeds = <?php 
        echo json_encode($feeds);
        ?>
;
		</script>
	</head>
	<body class="updater">
		<div id="content">
			<h1 id="title"><?php 
        _e('Lilina Item Updater');
        ?>
</h1>
			<p><?php 
        _e('Now beginning update of feeds. This might take a while. You must have Javascript enabled.');
        ?>
</p>
			<p class="js-hide"><?php 
        _e('You need to have Javascript enabled to run the updater.');
        ?>
</p>
			<ul id="updatelist">
			</ul>
			<p id="loading"><?php 
        _e('Updating...');
        ?>
</p>
			<div id="finished">
				<p><?php 
        _e('Finished updating.');
        ?>
</p>
				<p><?php 
        echo sprintf(_r('<a href="%1$s">Return to %2$s</a>.'), get_option('baseurl'), get_option('sitename'));
        ?>
</p>
			</div>
		</div>
		<div id="footer">
			<p>Powered by <a href="http://getlilina.org/">Lilina</a> <span class="version">1.0-bleeding</span>. Read the <a href="http://codex.getlilina.org/">documentation</a> or get help on the <a href="http://getlilina.org/forums/">forums</a></p>
		</div>
	</body>
</html>
<?php 
    }
예제 #11
0
/**
 * 
 * @global array
 */
function get_feeds()
{
    return Feeds::get_instance()->getAll();
}
예제 #12
0
    public function admin_page()
    {
        if (isset($_POST['clear'])) {
            $this->log = array();
            $this->save_log();
            header('HTTP/1.1 302 Found', true, 302);
            header('Location: ' . get_option('baseurl') . 'admin/admin.php?page=usl-admin&cleared=1');
            die;
        }
        $this->log = get_option('updaterspeedlog-log', array());
        // Adding it here to avoid putting on other pages
        add_action('admin_header', array(&$this, 'admin_header'));
        admin_header('Updater Speed Log');
        if (!empty($_GET['cleared'])) {
            echo '<div class="message"><p>Cleared log.</p></div>';
        }
        $feeds = array();
        foreach ($this->log as $item) {
            if ($item['name'] == 'Starting feed processing') {
                $feeds[$item['feed']] = array('start' => $item['time'], 'processed' => 0, 'added' => 0);
            } elseif ($item['name'] == 'Loaded feed') {
                $feeds[$item['feed']]['loaded'] = $item['time'];
            } elseif ($item['name'] == 'Finish feed processing') {
                echo '<tr></tr>';
                $feeds[$item['feed']]['finish'] = $item['time'];
            } elseif ($item['name'] == 'Item about to be checked') {
                $feeds[$item['feed']]['processed']++;
            } elseif ($item['name'] == 'Added item to database') {
                $feeds[$item['feed']]['added']++;
            }
        }
        ?>
		<h1>Updater Speed Log</h1>
<?php 
        if (empty($this->log)) {
            ?>
		<p>No logging data yet! Try updating your feeds.</p>
<?php 
        } else {
            ?>
		<form action="" method="POST" id="clear-form">
			<input type="hidden" name="clear" value="clear" />
			<button type="submit">Clear log</button>
		</form>
		<h2>Summary</h2>
		<table class="item-table">
			<thead>
				<tr>
					<th>Feed</th>
					<th>Load Time</th>
					<th>Time Processing</th>
					<th>Total Time</th>
					<th>Items Processed</th>
					<th><abbr title="Average">Avg</abbr> Processing Time Per Item</th>
				</tr>
			</thead>
			<tbody>
<?php 
            foreach ($feeds as $id => $feed) {
                $the_feed = Feeds::get_instance()->get($id);
                $avg_time = $feed['finish'] - $feed['loaded'];
                $avg_time = $avg_time / $feed['processed'];
                ?>
				<tr id="feed-<?php 
                echo $id;
                ?>
">
					<td><?php 
                echo $the_feed['name'];
                ?>
</td>
					<td><?php 
                echo round($feed['loaded'] - $feed['start'], 3);
                ?>
</td>
					<td><?php 
                echo round($feed['finish'] - $feed['loaded'], 3);
                ?>
</td>
					<td><?php 
                echo round($feed['finish'] - $feed['start'], 3);
                ?>
</td>
					<td><?php 
                echo $feed['added'] . ' / ' . $feed['processed'];
                ?>
</td>
					<td><?php 
                echo round($avg_time, 3);
                ?>
</td>
				</tr>
<?php 
            }
            ?>
			</tbody>
		</table>
		<h3>Full Log</h3>
		<table class="item-table" id="full-log">
			<thead>
				<tr>
					<th>Type</th>
					<th>Time Since Init</th>
					<th>Feed</th>
				</tr>
			</thead>
			<tbody>
<?php 
            $start = 0;
            foreach ($this->log as $item) {
                $class = '';
                if ($item['name'] == 'Initialized Lilina') {
                    $start = $item['time'];
                    $class = ' init';
                }
                if ($item['name'] == 'Skipped item') {
                    $class = ' skipped';
                }
                if ($item['name'] == 'Added item to database') {
                    $class = ' added';
                }
                $feed = Feeds::get_instance()->get($item['feed']);
                $since = round($item['time'] - $start, 3);
                if (!$feed) {
                    $feed = array('name' => 'n/a');
                }
                ?>
				<tr class="<?php 
                echo $class;
                ?>
">
					<td><?php 
                echo $item['name'];
                ?>
</td>
					<td><?php 
                echo $since;
                ?>
</td>
					<td><a href="#feed-<?php 
                echo $item['feed'];
                ?>
"><?php 
                echo $feed['name'];
                ?>
</a></td>
				</tr>
<?php 
                if ($item['name'] == 'Finish feed processing') {
                    echo '
				<tr class="header">
					<th>Type</th>
					<th>Time Since Init</th>
					<th>Feed</th>
				</tr>';
                }
            }
            ?>
			</tbody>
		</table>
		<script type="text/javascript">
		jQuery(document).ready(function ($) {
			$("#full-log").hide();
			$("<p class='hideshow'><span>Show full log</span></p>").insertBefore("#full-log").click(function () {
				$("#full-log").show();
				$(this).hide();
			});
		});
		</script>
<?php 
        }
        admin_footer();
    }