experimental new plugin system
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
class Button {
|
||||
|
||||
protected $link;
|
||||
|
||||
function __construct($link) {
|
||||
$this->link = $link;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
class Button_Tweet extends Button {
|
||||
function render($article_id) {
|
||||
$rv = "<img src=\"".theme_image($this->link, 'images/art-tweet.png')."\"
|
||||
class='tagsPic' style=\"cursor : pointer\"
|
||||
onclick=\"tweetArticle($article_id)\"
|
||||
title='".__('Share on Twitter')."'>";
|
||||
|
||||
return $rv;
|
||||
}
|
||||
|
||||
function getTweetInfo() {
|
||||
$id = db_escape_string($_REQUEST['id']);
|
||||
|
||||
$result = db_query($this->link, "SELECT title, link
|
||||
FROM ttrss_entries, ttrss_user_entries
|
||||
WHERE id = '$id' AND ref_id = id AND owner_uid = " .$_SESSION['uid']);
|
||||
|
||||
if (db_num_rows($result) != 0) {
|
||||
$title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')),
|
||||
100, '...');
|
||||
$article_link = db_fetch_result($result, 0, 'link');
|
||||
}
|
||||
|
||||
print json_encode(array("title" => $title, "link" => $article_link,
|
||||
"id" => $id));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
class Filter {
|
||||
protected $link;
|
||||
|
||||
function __construct($link) {
|
||||
$this->link = $link;
|
||||
}
|
||||
|
||||
function filter_article($article) {
|
||||
return $article;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
class PluginHandler extends Handler_Protected {
|
||||
function csrf_ignore($method) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function catchall($method) {
|
||||
global $pluginhost;
|
||||
|
||||
$plugin = $pluginhost->get_plugin($_REQUEST["plugin"]);
|
||||
|
||||
if (method_exists($plugin, $method)) {
|
||||
$plugin->$method();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
class PluginHost {
|
||||
private $link;
|
||||
private $hooks = array();
|
||||
private $plugins = array();
|
||||
|
||||
const HOOK_ARTICLE_BUTTON = 1;
|
||||
const HOOK_ARTICLE_FILTER = 2;
|
||||
|
||||
function __construct($link) {
|
||||
$this->link = $link;
|
||||
}
|
||||
|
||||
private function register_plugin($name, $plugin) {
|
||||
//array_push($this->plugins, $plugin);
|
||||
$this->plugins[$name] = $plugin;
|
||||
}
|
||||
|
||||
function get_link() {
|
||||
return $this->link;
|
||||
}
|
||||
|
||||
function get_plugins() {
|
||||
return $this->plugins;
|
||||
}
|
||||
|
||||
function get_plugin($name) {
|
||||
return $this->plugins[$name];
|
||||
}
|
||||
|
||||
function add_hook($type, $sender) {
|
||||
if (!is_array($this->hooks[$type])) {
|
||||
$this->hooks[$type] = array();
|
||||
}
|
||||
|
||||
array_push($this->hooks[$type], $sender);
|
||||
}
|
||||
|
||||
function del_hook($type, $sender) {
|
||||
if (is_array($this->hooks[$type])) {
|
||||
$key = array_Search($this->hooks[$type], $sender);
|
||||
if ($key !== FALSE) {
|
||||
unset($this->hooks[$type][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function get_hooks($type) {
|
||||
return $this->hooks[$type];
|
||||
}
|
||||
|
||||
function load($classlist) {
|
||||
$plugins = explode(",", $classlist);
|
||||
|
||||
foreach ($plugins as $class) {
|
||||
$class = trim($class);
|
||||
$class_file = str_replace("_", "/", strtolower(basename($class)));
|
||||
$file = dirname(__FILE__)."/../plugins/$class_file/$class_file.php";
|
||||
|
||||
if (file_exists($file)) require_once $file;
|
||||
|
||||
if (class_exists($class)) {
|
||||
$plugin = new $class($this);
|
||||
|
||||
$this->register_plugin($class, $plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
Before Width: | Height: | Size: 159 B |
@ -1,3 +1,3 @@
|
||||
<?php # This file has been generated at: Fri Sep 7 10:20:51 MSK 2012
|
||||
<?php # This file has been generated at: Sun Dec 23 13:56:09 MSK 2012
|
||||
define('GENERATED_CONFIG_CHECK', 26);
|
||||
$requred_defines = array( 'DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'MYSQL_CHARSET', 'SELF_URL_PATH', 'SINGLE_USER_MODE', 'PHP_EXECUTABLE', 'LOCK_DIRECTORY', 'CACHE_DIR', 'ICONS_DIR', 'ICONS_URL', 'AUTH_MODULES', 'AUTH_AUTO_CREATE', 'AUTH_AUTO_LOGIN', 'DEFAULT_UPDATE_METHOD', 'FORCE_ARTICLE_PURGE', 'PUBSUBHUBBUB_HUB', 'PUBSUBHUBBUB_ENABLED', 'SPHINX_ENABLED', 'SPHINX_INDEX', 'ENABLE_REGISTRATION', 'REG_NOTIFY_ADDRESS', 'REG_MAX_USERS', 'SESSION_COOKIE_LIFETIME', 'SESSION_EXPIRE_TIME', 'SESSION_CHECK_ADDRESS', 'SMTP_FROM_NAME', 'SMTP_FROM_ADDRESS', 'DIGEST_SUBJECT', 'SMTP_HOST', 'SMTP_LOGIN', 'SMTP_PASSWORD', 'CHECK_FOR_NEW_VERSION', 'ENABLE_GZIP_OUTPUT', 'FEEDBACK_URL', 'ARTICLE_BUTTON_PLUGINS', 'CONFIG_VERSION'); ?>
|
||||
$requred_defines = array( 'DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'MYSQL_CHARSET', 'SELF_URL_PATH', 'SINGLE_USER_MODE', 'PHP_EXECUTABLE', 'LOCK_DIRECTORY', 'CACHE_DIR', 'ICONS_DIR', 'ICONS_URL', 'AUTH_MODULES', 'AUTH_AUTO_CREATE', 'AUTH_AUTO_LOGIN', 'DEFAULT_UPDATE_METHOD', 'FORCE_ARTICLE_PURGE', 'PUBSUBHUBBUB_HUB', 'PUBSUBHUBBUB_ENABLED', 'SPHINX_ENABLED', 'SPHINX_INDEX', 'ENABLE_REGISTRATION', 'REG_NOTIFY_ADDRESS', 'REG_MAX_USERS', 'SESSION_COOKIE_LIFETIME', 'SESSION_EXPIRE_TIME', 'SESSION_CHECK_ADDRESS', 'SMTP_FROM_NAME', 'SMTP_FROM_ADDRESS', 'DIGEST_SUBJECT', 'SMTP_HOST', 'SMTP_LOGIN', 'SMTP_PASSWORD', 'CHECK_FOR_NEW_VERSION', 'ENABLE_GZIP_OUTPUT', 'FEEDBACK_URL', 'CONFIG_VERSION'); ?>
|
||||
|
@ -1,31 +0,0 @@
|
||||
function tweetArticle(id) {
|
||||
try {
|
||||
var query = "?op=rpc&method=buttonPlugin&plugin=tweet&plugin_method=getTweetInfo&id=" + param_escape(id);
|
||||
|
||||
console.log(query);
|
||||
|
||||
var d = new Date();
|
||||
var ts = d.getTime();
|
||||
|
||||
var w = window.open('backend.php?op=backend&method=loading', 'ttrss_tweet',
|
||||
"status=0,toolbar=0,location=0,width=500,height=400,scrollbars=1,menubar=0");
|
||||
|
||||
new Ajax.Request("backend.php", {
|
||||
parameters: query,
|
||||
onComplete: function(transport) {
|
||||
var ti = JSON.parse(transport.responseText);
|
||||
|
||||
var share_url = "http://twitter.com/share?_=" + ts +
|
||||
"&text=" + param_escape(ti.title) +
|
||||
"&url=" + param_escape(ti.link);
|
||||
|
||||
w.location.href = share_url;
|
||||
|
||||
} });
|
||||
|
||||
|
||||
} catch (e) {
|
||||
exception_error("tweetArticle", e);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
Shares article by email
|
Before Width: | Height: | Size: 192 B After Width: | Height: | Size: 192 B |
@ -0,0 +1 @@
|
||||
Support for article notes
|
@ -1,7 +1,7 @@
|
||||
function editArticleNote(id) {
|
||||
try {
|
||||
|
||||
var query = "backend.php?op=rpc&method=buttonPlugin&plugin=note&plugin_method=edit¶m=" + param_escape(id);
|
||||
var query = "backend.php?op=pluginhandler&plugin=note&method=edit¶m=" + param_escape(id);
|
||||
|
||||
if (dijit.byId("editNoteDlg"))
|
||||
dijit.byId("editNoteDlg").destroyRecursive();
|
Before Width: | Height: | Size: 159 B After Width: | Height: | Size: 159 B |
@ -0,0 +1 @@
|
||||
Inline image links in Reddit RSS
|
@ -1,7 +1,17 @@
|
||||
<?php
|
||||
class Filter_RedditImgur {
|
||||
class RedditImgur {
|
||||
|
||||
function filter_article($article) {
|
||||
private $link;
|
||||
private $host;
|
||||
|
||||
function __construct($host) {
|
||||
$this->link = $host->get_link();
|
||||
$this->host = $host;
|
||||
|
||||
$host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
|
||||
}
|
||||
|
||||
function hook_article_filter($article) {
|
||||
|
||||
if (strpos($article["link"], "reddit.com/r/") !== FALSE) {
|
||||
if (strpos($article["content"], "i.imgur.com") !== FALSE) {
|
@ -0,0 +1 @@
|
||||
Support for sharing articles by URL
|
@ -1,6 +1,20 @@
|
||||
<?php
|
||||
class Button_Share extends Button {
|
||||
function render($article_id, $line) {
|
||||
class Share {
|
||||
private $link;
|
||||
private $host;
|
||||
|
||||
function __construct($host) {
|
||||
$this->link = $host->get_link();
|
||||
$this->host = $host;
|
||||
|
||||
$host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
|
||||
}
|
||||
|
||||
function get_js() {
|
||||
return file_get_contents(dirname(__FILE__) . "/share.js");
|
||||
}
|
||||
|
||||
function hook_article_button($line) {
|
||||
return "<img src=\"".theme_image($this->link, 'images/art-share.png')."\"
|
||||
class='tagsPic' style=\"cursor : pointer\"
|
||||
onclick=\"shareArticle(".$line['int_id'].")\"
|
Before Width: | Height: | Size: 183 B After Width: | Height: | Size: 183 B |