first clean up of code and update license

This commit is contained in:
Jean-Christian Denis 2021-09-11 11:56:57 +02:00
parent 64e75c9f1c
commit d8a9b15346
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
19 changed files with 3649 additions and 3843 deletions

View file

@ -1,19 +1,19 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief zoneclearFeedServer, a plugin for Dotclear 2
# This file is part of zoneclearFeedServer, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis, BG, Pierre Van Glabeke
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
# Namespace for settings # Namespace for settings
@ -23,7 +23,7 @@ $core->blog->settings->addNamespace('zoneclearFeedServer');
if ($core->getVersion('zoneclearFeedServer') != if ($core->getVersion('zoneclearFeedServer') !=
$core->plugins->moduleInfo('zoneclearFeedServer', 'version')) { $core->plugins->moduleInfo('zoneclearFeedServer', 'version')) {
return null; return null;
} }
# Widgets # Widgets
@ -31,48 +31,48 @@ require_once dirname(__FILE__).'/_widgets.php';
# Admin menu # Admin menu
$_menu['Blog']->addItem( $_menu['Blog']->addItem(
__('Feeds server'), __('Feeds server'),
'plugin.php?p=zoneclearFeedServer', 'plugin.php?p=zoneclearFeedServer',
'index.php?pf=zoneclearFeedServer/icon.png', 'index.php?pf=zoneclearFeedServer/icon.png',
preg_match( preg_match(
'/plugin.php\?p=zoneclearFeedServer(&.*)?$/', '/plugin.php\?p=zoneclearFeedServer(&.*)?$/',
$_SERVER['REQUEST_URI'] $_SERVER['REQUEST_URI']
), ),
$core->auth->check('admin', $core->blog->id) $core->auth->check('admin', $core->blog->id)
); );
# Delete related info about feed post in meta table # Delete related info about feed post in meta table
$core->addBehavior( $core->addBehavior(
'adminBeforePostDelete', 'adminBeforePostDelete',
array('zcfsAdminBehaviors', 'adminBeforePostDelete') array('zcfsAdminBehaviors', 'adminBeforePostDelete')
); );
if ($core->auth->check('admin', $core->blog->id)) { if ($core->auth->check('admin', $core->blog->id)) {
# Dashboard icon # Dashboard icon
$core->addBehavior( $core->addBehavior(
'adminDashboardFavorites', 'adminDashboardFavorites',
array('zcfsAdminBehaviors', 'adminDashboardFavorites') array('zcfsAdminBehaviors', 'adminDashboardFavorites')
); );
# Add info about feed on post page sidebar # Add info about feed on post page sidebar
$core->addBehavior( $core->addBehavior(
'adminPostHeaders', 'adminPostHeaders',
array('zcfsAdminBehaviors', 'adminPostHeaders') array('zcfsAdminBehaviors', 'adminPostHeaders')
); );
$core->addBehavior( $core->addBehavior(
'adminPostFormItems', 'adminPostFormItems',
array('zcfsAdminBehaviors', 'adminPostFormItems') array('zcfsAdminBehaviors', 'adminPostFormItems')
); );
} }
# Take care about tweakurls (thanks Mathieu M.) # Take care about tweakurls (thanks Mathieu M.)
if (version_compare($core->plugins->moduleInfo('tweakurls', 'version'), '0.8', '>=')) { if (version_compare($core->plugins->moduleInfo('tweakurls', 'version'), '0.8', '>=')) {
$core->addbehavior( $core->addbehavior(
'zcfsAfterPostCreate', 'zcfsAfterPostCreate',
array('zoneclearFeedServer', 'tweakurlsAfterPostCreate') array('zoneclearFeedServer', 'tweakurlsAfterPostCreate')
); );
} }
/** /**
@ -82,178 +82,178 @@ if (version_compare($core->plugins->moduleInfo('tweakurls', 'version'), '0.8', '
*/ */
class zcfsAdminBehaviors class zcfsAdminBehaviors
{ {
/** /**
* Favorites. * Favorites.
* *
* @param dcCore $core dcCore instance * @param dcCore $core dcCore instance
* @param arrayObject $favs Array of favorites * @param arrayObject $favs Array of favorites
*/ */
public static function adminDashboardFavorites(dcCore $core, $favs) public static function adminDashboardFavorites(dcCore $core, $favs)
{ {
$favs->register('zcfs', array( $favs->register('zcfs', array(
'title' => __('Feeds server'), 'title' => __('Feeds server'),
'url' => 'plugin.php?p=zoneclearFeedServer', 'url' => 'plugin.php?p=zoneclearFeedServer',
'small-icon' => 'index.php?pf=zoneclearFeedServer/icon.png', 'small-icon' => 'index.php?pf=zoneclearFeedServer/icon.png',
'large-icon' => 'index.php?pf=zoneclearFeedServer/icon-big.png', 'large-icon' => 'index.php?pf=zoneclearFeedServer/icon-big.png',
'permissions' => 'usage,contentadmin', 'permissions' => 'usage,contentadmin',
'active_cb' => array( 'active_cb' => array(
'zcfsAdminBehaviors', 'zcfsAdminBehaviors',
'adminDashboardFavoritesActive' 'adminDashboardFavoritesActive'
), ),
'dashboard_cb' => array( 'dashboard_cb' => array(
'zcfsAdminBehaviors', 'zcfsAdminBehaviors',
'adminDashboardFavoritesCallback' 'adminDashboardFavoritesCallback'
) )
)); ));
} }
/** /**
* Favorites selection. * Favorites selection.
* *
* @param string $request Requested page * @param string $request Requested page
* @param array $params Requested parameters * @param array $params Requested parameters
*/ */
public static function adminDashboardFavoritesActive($request, $params) public static function adminDashboardFavoritesActive($request, $params)
{ {
return $request == 'plugin.php' return $request == 'plugin.php'
&& isset($params['p']) && isset($params['p'])
&& $params['p'] == 'zoneclearFeedServer'; && $params['p'] == 'zoneclearFeedServer';
} }
/** /**
* Favorites hack. * Favorites hack.
* *
* @param dcCore $core dcCore instance * @param dcCore $core dcCore instance
* @param arrayObject $fav Fav attributes * @param arrayObject $fav Fav attributes
*/ */
public static function adminDashboardFavoritesCallback(dcCore $core, $fav) public static function adminDashboardFavoritesCallback(dcCore $core, $fav)
{ {
$zcfs = new zoneclearFeedServer($core); $zcfs = new zoneclearFeedServer($core);
$count = $zcfs->getFeeds(array( $count = $zcfs->getFeeds(array(
'feed_status' => '0' 'feed_status' => '0'
), true)->f(0); ), true)->f(0);
if (!$count) { if (!$count) {
return null; return null;
} }
$fav['title'] .= '<br />'.sprintf( $fav['title'] .= '<br />'.sprintf(
__('%s feed disabled', '%s feeds disabled', $count), __('%s feed disabled', '%s feeds disabled', $count),
$count $count
); );
$fav['url'] = 'plugin.php?p=zoneclearFeedServer&part=feeds'. $fav['url'] = 'plugin.php?p=zoneclearFeedServer&part=feeds'.
'&sortby=feed_status&order=asc'; '&sortby=feed_status&order=asc';
$fav['large-icon'] = 'index.php?pf=zoneclearFeedServer'. $fav['large-icon'] = 'index.php?pf=zoneclearFeedServer'.
'/icon-big-update.png'; '/icon-big-update.png';
} }
/** /**
* Add javascript for toggle to post edition page header. * Add javascript for toggle to post edition page header.
* *
* @return string Page header * @return string Page header
*/ */
public static function adminPostHeaders() public static function adminPostHeaders()
{ {
return dcPage::jsLoad( return dcPage::jsLoad(
'index.php?pf=zoneclearFeedServer/js/post.js' 'index.php?pf=zoneclearFeedServer/js/post.js'
); );
} }
/** /**
* Add form to post sidebar. * Add form to post sidebar.
* *
* @param ArrayObject $main_items Main items * @param ArrayObject $main_items Main items
* @param ArrayObject $sidebar_items Sidebar items * @param ArrayObject $sidebar_items Sidebar items
* @param record $post Post record or null * @param record $post Post record or null
*/ */
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, $post) public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, $post)
{ {
if ($post === null || $post->post_type != 'post') { if ($post === null || $post->post_type != 'post') {
return null; return null;
} }
global $core; global $core;
$url = $core->meta->getMetadata(array( $url = $core->meta->getMetadata(array(
'post_id' => $post->post_id, 'post_id' => $post->post_id,
'meta_type' => 'zoneclearfeed_url', 'meta_type' => 'zoneclearfeed_url',
'limit' => 1 'limit' => 1
)); ));
$url = $url->isEmpty() ? '' : $url->meta_id; $url = $url->isEmpty() ? '' : $url->meta_id;
if (!$url) { if (!$url) {
return null; return null;
} }
$author = $core->meta->getMetadata(array( $author = $core->meta->getMetadata(array(
'post_id' => $post->post_id, 'post_id' => $post->post_id,
'meta_type' => 'zoneclearfeed_author', 'meta_type' => 'zoneclearfeed_author',
'limit' => 1 'limit' => 1
)); ));
$author = $author->isEmpty() ? '' : $author->meta_id; $author = $author->isEmpty() ? '' : $author->meta_id;
$site = $core->meta->getMetadata(array( $site = $core->meta->getMetadata(array(
'post_id' => $post->post_id, 'post_id' => $post->post_id,
'meta_type' => 'zoneclearfeed_site', 'meta_type' => 'zoneclearfeed_site',
'limit' => 1 'limit' => 1
)); ));
$site = $site->isEmpty() ? '' : $site->meta_id; $site = $site->isEmpty() ? '' : $site->meta_id;
$sitename = $core->meta->getMetadata(array( $sitename = $core->meta->getMetadata(array(
'post_id' => $post->post_id, 'post_id' => $post->post_id,
'meta_type' => 'zoneclearfeed_sitename', 'meta_type' => 'zoneclearfeed_sitename',
'limit' => 1 'limit' => 1
)); ));
$sitename = $sitename->isEmpty() ? '' : $sitename->meta_id; $sitename = $sitename->isEmpty() ? '' : $sitename->meta_id;
$edit = ''; $edit = '';
if ($core->auth->check('admin', $core->blog->id)) { if ($core->auth->check('admin', $core->blog->id)) {
$fid = $core->meta->getMetadata(array( $fid = $core->meta->getMetadata(array(
'post_id' => $post->post_id, 'post_id' => $post->post_id,
'meta_type' => 'zoneclearfeed_id', 'meta_type' => 'zoneclearfeed_id',
'limit' => 1 'limit' => 1
)); ));
if (!$fid->isEmpty()) { if (!$fid->isEmpty()) {
$edit = $edit =
'<p><a href="plugin.php?p=zoneclearFeedServer'. '<p><a href="plugin.php?p=zoneclearFeedServer'.
'&amp;part=feed&amp;feed_id='.$fid->meta_id. '&amp;part=feed&amp;feed_id='.$fid->meta_id.
'">'.__('Edit this feed').'</a></p>'; '">'.__('Edit this feed').'</a></p>';
} }
} }
$sidebar_items['options-box']['items']['zcfs'] = $sidebar_items['options-box']['items']['zcfs'] =
'<div id="zcfs">'. '<div id="zcfs">'.
'<h5>'.__('Feed source').'</h5>'. '<h5>'.__('Feed source').'</h5>'.
'<p>'. '<p>'.
'<a href="'.$url.'" title="'.$author.' - '.$url.'">'.__('feed URL').'</a> - '. '<a href="'.$url.'" title="'.$author.' - '.$url.'">'.__('feed URL').'</a> - '.
'<a href="'.$site.'" title="'.$sitename.' - '.$site.'">'.__('site URL').'</a>'. '<a href="'.$site.'" title="'.$sitename.' - '.$site.'">'.__('site URL').'</a>'.
'</p>'. '</p>'.
$edit. $edit.
'</div>'; '</div>';
} }
/** /**
* Delete related info about feed post in meta table. * Delete related info about feed post in meta table.
* *
* @param integer $post_id Post id * @param integer $post_id Post id
*/ */
public static function adminBeforePostDelete($post_id) public static function adminBeforePostDelete($post_id)
{ {
global $core; global $core;
$core->con->execute( $core->con->execute(
'DELETE FROM '.$core->prefix.'meta '. 'DELETE FROM '.$core->prefix.'meta '.
'WHERE post_id = '.((integer) $post_id).' '. 'WHERE post_id = '.((integer) $post_id).' '.
'AND meta_type '.$core->con->in(array( 'AND meta_type '.$core->con->in(array(
'zoneclearfeed_url', 'zoneclearfeed_url',
'zoneclearfeed_author', 'zoneclearfeed_author',
'zoneclearfeed_site', 'zoneclearfeed_site',
'zoneclearfeed_sitename', 'zoneclearfeed_sitename',
'zoneclearfeed_id' 'zoneclearfeed_id'
)).' ' )).' '
); );
} }
} }

View file

@ -1,23 +1,23 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief zoneclearFeedServer, a plugin for Dotclear 2
# This file is part of zoneclearFeedServer, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis, BG, Pierre Van Glabeke
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_CONTEXT_MODULE')) { if (!defined('DC_CONTEXT_MODULE')) {
return null; return null;
} }
$redir = empty($_REQUEST['redir']) ? $redir = empty($_REQUEST['redir']) ?
$list->getURL().'#plugins' : $_REQUEST['redir']; $list->getURL().'#plugins' : $_REQUEST['redir'];
# -- Get settings -- # -- Get settings --
$core->blog->settings->addNamespace('zoneclearFeedServer'); $core->blog->settings->addNamespace('zoneclearFeedServer');
@ -35,13 +35,13 @@ $post_title_redir = @unserialize($s->zoneclearFeedServer_post_title_redir);
$feeduser = (string) $s->zoneclearFeedServer_user; $feeduser = (string) $s->zoneclearFeedServer_user;
if ($update_limit < 1) { if ($update_limit < 1) {
$update_limit = 10; $update_limit = 10;
} }
if (!is_array($post_full_tpl)) { if (!is_array($post_full_tpl)) {
$post_full_tpl = array(); $post_full_tpl = array();
} }
if (!is_array($post_title_redir)) { if (!is_array($post_title_redir)) {
$post_title_redir = array(); $post_title_redir = array();
} }
$zc = new zoneclearFeedServer($core); $zc = new zoneclearFeedServer($core);
@ -49,65 +49,65 @@ $zc = new zoneclearFeedServer($core);
# -- Set settings -- # -- Set settings --
if (!empty($_POST['save'])) { if (!empty($_POST['save'])) {
try { try {
$active = !empty($_POST['active']); $active = !empty($_POST['active']);
$pub_active = !empty($_POST['pub_active']); $pub_active = !empty($_POST['pub_active']);
$post_status_new = !empty($_POST['post_status_new']); $post_status_new = !empty($_POST['post_status_new']);
$bhv_pub_upd = (integer) $_POST['bhv_pub_upd']; $bhv_pub_upd = (integer) $_POST['bhv_pub_upd'];
$limit = abs((integer) $_POST['update_limit']); $limit = abs((integer) $_POST['update_limit']);
$keep_empty_feed = !empty($_POST['keep_empty_feed']); $keep_empty_feed = !empty($_POST['keep_empty_feed']);
$tag_case = (integer) $_POST['tag_case']; $tag_case = (integer) $_POST['tag_case'];
$post_full_tpl = $_POST['post_full_tpl']; $post_full_tpl = $_POST['post_full_tpl'];
$post_title_redir = $_POST['post_title_redir']; $post_title_redir = $_POST['post_title_redir'];
$feeduser = (string) $_POST['feeduser']; $feeduser = (string) $_POST['feeduser'];
if ($limit < 1) { if ($limit < 1) {
$limit = 10; $limit = 10;
} }
$s->put('zoneclearFeedServer_active', $active); $s->put('zoneclearFeedServer_active', $active);
$s->put('zoneclearFeedServer_pub_active', $pub_active); $s->put('zoneclearFeedServer_pub_active', $pub_active);
$s->put('zoneclearFeedServer_post_status_new', $post_status_new); $s->put('zoneclearFeedServer_post_status_new', $post_status_new);
$s->put('zoneclearFeedServer_bhv_pub_upd', $bhv_pub_upd); $s->put('zoneclearFeedServer_bhv_pub_upd', $bhv_pub_upd);
$s->put('zoneclearFeedServer_update_limit', $limit); $s->put('zoneclearFeedServer_update_limit', $limit);
$s->put('zoneclearFeedServer_keep_empty_feed', $keep_empty_feed); $s->put('zoneclearFeedServer_keep_empty_feed', $keep_empty_feed);
$s->put('zoneclearFeedServer_tag_case', $tag_case); $s->put('zoneclearFeedServer_tag_case', $tag_case);
$s->put('zoneclearFeedServer_post_full_tpl', serialize($post_full_tpl)); $s->put('zoneclearFeedServer_post_full_tpl', serialize($post_full_tpl));
$s->put('zoneclearFeedServer_post_title_redir', serialize($post_title_redir)); $s->put('zoneclearFeedServer_post_title_redir', serialize($post_title_redir));
$s->put('zoneclearFeedServer_user', $feeduser); $s->put('zoneclearFeedServer_user', $feeduser);
$core->blog->triggerBlog(); $core->blog->triggerBlog();
dcPage::addSuccessNotice( dcPage::addSuccessNotice(
__('Configuration successfully updated.') __('Configuration successfully updated.')
); );
http::redirect( http::redirect(
$list->getURL('module=zoneclearFeedServer&conf=1&redir='. $list->getURL('module=zoneclearFeedServer&conf=1&redir='.
$list->getRedir()) $list->getRedir())
); );
} }
catch (Exception $e) { catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
} }
} }
# -- Form combos -- # -- Form combos --
$combo_admins = $zc->getAllBlogAdmins(); $combo_admins = $zc->getAllBlogAdmins();
$combo_pubupd = array( $combo_pubupd = array(
__('Disable') => 0, __('Disable') => 0,
__('Before display') => 1, __('Before display') => 1,
__('After display') => 2, __('After display') => 2,
__('Through Ajax') => 3 __('Through Ajax') => 3
); );
$combo_status = array( $combo_status = array(
__('Unpublished') => 0, __('Unpublished') => 0,
__('Published') => 1 __('Published') => 1
); );
$combo_tagcase = array( $combo_tagcase = array(
__('Keep source case') => 0, __('Keep source case') => 0,
__('First upper case') => 1, __('First upper case') => 1,
__('All lower case') => 2, __('All lower case') => 2,
__('All upper case') => 3 __('All upper case') => 3
); );
$pub_page_url = $core->blog->url.$core->url->getBase('zoneclearFeedsPage'); $pub_page_url = $core->blog->url.$core->url->getBase('zoneclearFeedsPage');
@ -115,12 +115,12 @@ $pub_page_url = $core->blog->url.$core->url->getBase('zoneclearFeedsPage');
# -- Display form -- # -- Display form --
if (!is_writable(DC_TPL_CACHE)) { if (!is_writable(DC_TPL_CACHE)) {
echo echo
'<p class="error">'. '<p class="error">'.
__('Dotclear cache is not writable or not well configured!'). __('Dotclear cache is not writable or not well configured!').
'</p>'; '</p>';
} }
echo ' echo '
<div class="fieldset"> <div class="fieldset">
@ -135,7 +135,7 @@ echo '
<div class="fieldset">'; <div class="fieldset">';
if ($core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_pub_active) { if ($core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_pub_active) {
echo '<p><a class="onblog_link" href="'.$pub_page_url.'" title="'.$pub_page_url.''.'">'.__('View the public list of feeds').'</a></p>'; echo '<p><a class="onblog_link" href="'.$pub_page_url.'" title="'.$pub_page_url.''.'">'.__('View the public list of feeds').'</a></p>';
} }
echo ' echo '
@ -178,14 +178,14 @@ __('Enable public page').'</label></p>
<p>'.__('Redirect to original post on:').'</p><ul>'; <p>'.__('Redirect to original post on:').'</p><ul>';
foreach($zc->getPublicUrlTypes($core) as $k => $v) { foreach($zc->getPublicUrlTypes($core) as $k => $v) {
echo echo
'<li><label for="post_title_redir_'.$v.'">'. '<li><label for="post_title_redir_'.$v.'">'.
form::checkbox( form::checkbox(
array('post_title_redir[]', 'post_title_redir_'.$v), array('post_title_redir[]', 'post_title_redir_'.$v),
$v, $v,
in_array($v, $post_title_redir) in_array($v, $post_title_redir)
). ).
__($k).'</label></li>'; __($k).'</label></li>';
} }
echo ' echo '
</ul> </ul>
@ -195,14 +195,14 @@ echo '
<p>'.__('Show full content on:').'</p><ul>'; <p>'.__('Show full content on:').'</p><ul>';
foreach($zc->getPublicUrlTypes($core) as $k => $v) { foreach($zc->getPublicUrlTypes($core) as $k => $v) {
echo echo
'<li><label for="post_full_tpl_'.$v.'">'. '<li><label for="post_full_tpl_'.$v.'">'.
form::checkbox( form::checkbox(
array('post_full_tpl[]', 'post_full_tpl_'.$v), array('post_full_tpl[]', 'post_full_tpl_'.$v),
$v, $v,
in_array($v, $post_full_tpl) in_array($v, $post_full_tpl)
). ).
__($k).'</label></li>'; __($k).'</label></li>';
} }
echo ' echo '
</ul> </ul>

View file

@ -1,36 +1,31 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief zoneclearFeedServer, a plugin for Dotclear 2
# This file is part of zoneclearFeedServer, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis, BG, Pierre Van Glabeke
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null;
return null;
} }
$this->registerModule( $this->registerModule(
/* Name */ 'zoneclearFeedServer',
"zoneclearFeedServer", 'Mix your blog with a feeds planet',
/* Description*/ 'Jean-Christian Denis, BG, Pierre Van Glabeke',
"Mix your blog with a feeds planet", '2015.07.19',
/* Author */ [
"Jean-Christian Denis, BG, Pierre Van Glabeke", 'requires' => [['core', '2.19']],
/* Version */ 'permissions' => 'admin',
'2015.07.19', 'type' => 'plugin',
/* Properies */ 'support' => 'https://github.com/JcDenis/zoneclearFeedServer',
array( 'details' => 'https://plugins.dotaddict.org/dc2/details/pacKman',
'permissions' => 'admin', 'repository' => 'https://raw.githubusercontent.com/JcDenis/zoneclearFeedServer/master/dcstore.xml'
'type' => 'plugin', ]
'dc_min' => '2.8',
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=331158',
'details' => 'http://plugins.dotaddict.org/dc2/details/zoneclearFeedServer'
)
); );

View file

@ -1,98 +1,98 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief zoneclearFeedServer, a plugin for Dotclear 2
# This file is part of zoneclearFeedServer, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis, BG, Pierre Van Glabeke
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
$dc_min = '2.7'; $dc_min = '2.7';
$mod_id = 'zoneclearFeedServer'; $mod_id = 'zoneclearFeedServer';
try { try {
# Check module version # Check module version
if (version_compare( if (version_compare(
$core->getVersion($mod_id), $core->getVersion($mod_id),
$core->plugins->moduleInfo($mod_id, 'version'), $core->plugins->moduleInfo($mod_id, 'version'),
'>=' '>='
)) { )) {
return null; return null;
} }
# Check Dotclear version # Check Dotclear version
if (!method_exists('dcUtils', 'versionsCompare') if (!method_exists('dcUtils', 'versionsCompare')
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) { || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
throw new Exception(sprintf( throw new Exception(sprintf(
'%s requires Dotclear %s', $mod_id, $dc_min '%s requires Dotclear %s', $mod_id, $dc_min
)); ));
} }
# Tables
$t = new dbStruct($core->con, $core->prefix);
$t->zc_feed
->feed_id ('bigint', 0, false)
->feed_creadt ('timestamp', 0, false, 'now()')
->feed_upddt ('timestamp', 0, false, 'now()')
->feed_type ('varchar', 32, false, "'feed'")
->blog_id ('varchar', 32, false)
->cat_id ('bigint', 0, true)
->feed_upd_int ('integer', 0, false, 3600)
->feed_upd_last ('integer', 0, false, 0)
->feed_status ('smallint', 0, false, 0)
->feed_name ('varchar', 255, false)
->feed_desc ('text', 0, true) //!pgsql reserved 'desc'
->feed_url ('varchar', 255, false)
->feed_feed ('varchar', 255, false)
->feed_tags ('varchar', 255, true)
->feed_get_tags ('smallint', 0, false, 1)
->feed_owner ('varchar', 255, false)
->feed_tweeter ('varchar', 64, false) // tweeter ident
->feed_lang ('varchar', 5, true)
->feed_nb_out ('integer', 0, false, 0)
->feed_nb_in ('integer', 0, false, 0)
->primary('pk_zcfs', 'feed_id')
->index('idx_zcfs_type', 'btree', 'feed_type')
->index('idx_zcfs_blog', 'btree', 'blog_id');
$ti = new dbStruct($core->con, $core->prefix);
$changes = $ti->synchronize($t);
# Settings
$core->blog->settings->addNamespace('zoneclearFeedServer');
$s = $core->blog->settings->zoneclearFeedServer;
$s->put('zoneclearFeedServer_active', false, 'boolean', 'Enable zoneclearBlogServer', false, true);
$s->put('zoneclearFeedServer_pub_active', false, 'boolean', 'Enable public page of list of feeds', false, true);
$s->put('zoneclearFeedServer_post_status_new', true, 'boolean', 'Enable auto publish new posts', false, true);
$s->put('zoneclearFeedServer_bhv_pub_upd', 2, 'string', 'Auto update on public side (disable/before/after)', false, true);
$s->put('zoneclearFeedServer_update_limit', 1, 'integer', 'Number of feeds to update at one time', false, true);
$s->put('zoneclearFeedServer_keep_empty_feed', false, 'boolean', 'Keep active empty feeds', false, true);
$s->put('zoneclearFeedServer_tag_case', 0, 'integer', 'How to transform imported tags', false, true);
$s->put('zoneclearFeedServer_user', '', 'string','User id that has right on post', false, true);
$s->put('zoneclearFeedServer_post_full_tpl', serialize(array('post', 'category', 'tag', 'archive')), 'string', 'List of templates types for full feed', false, true);
$s->put('zoneclearFeedServer_post_title_redir', serialize(array('feed')), 'string', 'List of templates types for redirection to original post', false, true);
# Set module version # Tables
$core->setVersion( $t = new dbStruct($core->con, $core->prefix);
$mod_id, $t->zc_feed
$core->plugins->moduleInfo($mod_id, 'version') ->feed_id ('bigint', 0, false)
); ->feed_creadt ('timestamp', 0, false, 'now()')
->feed_upddt ('timestamp', 0, false, 'now()')
->feed_type ('varchar', 32, false, "'feed'")
->blog_id ('varchar', 32, false)
->cat_id ('bigint', 0, true)
->feed_upd_int ('integer', 0, false, 3600)
->feed_upd_last ('integer', 0, false, 0)
->feed_status ('smallint', 0, false, 0)
->feed_name ('varchar', 255, false)
->feed_desc ('text', 0, true) //!pgsql reserved 'desc'
->feed_url ('varchar', 255, false)
->feed_feed ('varchar', 255, false)
->feed_tags ('varchar', 255, true)
->feed_get_tags ('smallint', 0, false, 1)
->feed_owner ('varchar', 255, false)
->feed_tweeter ('varchar', 64, false) // tweeter ident
->feed_lang ('varchar', 5, true)
->feed_nb_out ('integer', 0, false, 0)
->feed_nb_in ('integer', 0, false, 0)
return true; ->primary('pk_zcfs', 'feed_id')
->index('idx_zcfs_type', 'btree', 'feed_type')
->index('idx_zcfs_blog', 'btree', 'blog_id');
$ti = new dbStruct($core->con, $core->prefix);
$changes = $ti->synchronize($t);
# Settings
$core->blog->settings->addNamespace('zoneclearFeedServer');
$s = $core->blog->settings->zoneclearFeedServer;
$s->put('zoneclearFeedServer_active', false, 'boolean', 'Enable zoneclearBlogServer', false, true);
$s->put('zoneclearFeedServer_pub_active', false, 'boolean', 'Enable public page of list of feeds', false, true);
$s->put('zoneclearFeedServer_post_status_new', true, 'boolean', 'Enable auto publish new posts', false, true);
$s->put('zoneclearFeedServer_bhv_pub_upd', 2, 'string', 'Auto update on public side (disable/before/after)', false, true);
$s->put('zoneclearFeedServer_update_limit', 1, 'integer', 'Number of feeds to update at one time', false, true);
$s->put('zoneclearFeedServer_keep_empty_feed', false, 'boolean', 'Keep active empty feeds', false, true);
$s->put('zoneclearFeedServer_tag_case', 0, 'integer', 'How to transform imported tags', false, true);
$s->put('zoneclearFeedServer_user', '', 'string','User id that has right on post', false, true);
$s->put('zoneclearFeedServer_post_full_tpl', serialize(array('post', 'category', 'tag', 'archive')), 'string', 'List of templates types for full feed', false, true);
$s->put('zoneclearFeedServer_post_title_redir', serialize(array('feed')), 'string', 'List of templates types for redirection to original post', false, true);
# Set module version
$core->setVersion(
$mod_id,
$core->plugins->moduleInfo($mod_id, 'version')
);
return true;
} }
catch (Exception $e) { catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
return false; return false;
} }

View file

@ -1,25 +1,25 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief zoneclearFeedServer, a plugin for Dotclear 2
# This file is part of zoneclearFeedServer, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis, BG, Pierre Van Glabeke
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
if ($core->getVersion('zoneclearFeedServer') != if ($core->getVersion('zoneclearFeedServer') !=
$core->plugins->moduleInfo('zoneclearFeedServer', 'version')) { $core->plugins->moduleInfo('zoneclearFeedServer', 'version')) {
return null; return null;
} }
$d = dirname(__FILE__).'/inc/'; $d = dirname(__FILE__).'/inc/';
@ -32,24 +32,24 @@ $__autoload['zcfsDefaultFeedsActions'] = $d.'class.zcfs.feedsactions.php';
# public url for page of description of the flux # public url for page of description of the flux
$core->url->register( $core->url->register(
'zoneclearFeedsPage', 'zoneclearFeedsPage',
'zcfeeds', 'zcfeeds',
'^zcfeeds(.*?)$', '^zcfeeds(.*?)$',
array('zcfsUrlHandler', 'zcFeedsPage') array('zcfsUrlHandler', 'zcFeedsPage')
); );
/*
# Add to plugn soCialMe (writer part) # Add to plugn soCialMe (writer part)
$__autoload['zcfsSoCialMeWriter'] = $d.'lib.zcfs.socialmewriter.php'; $__autoload['zcfsSoCialMeWriter'] = $d.'lib.zcfs.socialmewriter.php';
$core->addBehavior( $core->addBehavior(
'soCialMeWriterMarker', 'soCialMeWriterMarker',
array('zcfsSoCialMeWriter', 'soCialMeWriterMarker') array('zcfsSoCialMeWriter', 'soCialMeWriterMarker')
); );
$core->addBehavior( $core->addBehavior(
'zoneclearFeedServerAfterFeedUpdate', 'zoneclearFeedServerAfterFeedUpdate',
array('zcfsSoCialMeWriter', 'zoneclearFeedServerAfterFeedUpdate') array('zcfsSoCialMeWriter', 'zoneclearFeedServerAfterFeedUpdate')
); );
//*/
# Add to report on plugin activityReport # Add to report on plugin activityReport
if (defined('ACTIVITY_REPORT')) { if (defined('ACTIVITY_REPORT')) {
require_once $d.'lib.zcfs.activityreport.php'; require_once $d.'lib.zcfs.activityreport.php';
} }

File diff suppressed because it is too large Load diff

View file

@ -1,83 +1,82 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief zoneclearFeedServer, a plugin for Dotclear 2
# This file is part of zoneclearFeedServer, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis, BG, Pierre Van Glabeke
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
$mod_id = 'zoneclearFeedServer'; $mod_id = 'zoneclearFeedServer';
$this->addUserAction( $this->addUserAction(
/* type */ 'settings', /* type */ 'settings',
/* action */ 'delete_all', /* action */ 'delete_all',
/* ns */ $mod_id, /* ns */ $mod_id,
/* desc */ __('delete all settings') /* desc */ __('delete all settings')
); );
$this->addUserAction( $this->addUserAction(
/* type */ 'tables', /* type */ 'tables',
/* action */ 'delete', /* action */ 'delete',
/* ns */ 'zc_feed', /* ns */ 'zc_feed',
/* desc */ __('delete table') /* desc */ __('delete table')
); );
$this->addUserAction( $this->addUserAction(
/* type */ 'plugins', /* type */ 'plugins',
/* action */ 'delete', /* action */ 'delete',
/* ns */ $mod_id, /* ns */ $mod_id,
/* desc */ __('delete plugin files') /* desc */ __('delete plugin files')
); );
$this->addUserAction( $this->addUserAction(
/* type */ 'versions', /* type */ 'versions',
/* action */ 'delete', /* action */ 'delete',
/* ns */ $mod_id, /* ns */ $mod_id,
/* desc */ __('delete the version number') /* desc */ __('delete the version number')
); );
$this->addDirectAction( $this->addDirectAction(
/* type */ 'settings', /* type */ 'settings',
/* action */ 'delete_all', /* action */ 'delete_all',
/* ns */ $mod_id, /* ns */ $mod_id,
/* desc */ sprintf(__('delete all %s settings'), $mod_id) /* desc */ sprintf(__('delete all %s settings'), $mod_id)
); );
$this->addDirectAction( $this->addDirectAction(
/* type */ 'tables', /* type */ 'tables',
/* action */ 'delete', /* action */ 'delete',
/* ns */ 'zc_feed', /* ns */ 'zc_feed',
/* desc */ sprintf(__('delete %s table'), $mod_id) /* desc */ sprintf(__('delete %s table'), $mod_id)
); );
$this->addDirectAction( $this->addDirectAction(
/* type */ 'plugins', /* type */ 'plugins',
/* action */ 'delete', /* action */ 'delete',
/* ns */ $mod_id, /* ns */ $mod_id,
/* desc */ sprintf(__('delete %s plugin files'), $mod_id) /* desc */ sprintf(__('delete %s plugin files'), $mod_id)
); );
$this->addDirectAction( $this->addDirectAction(
/* type */ 'versions', /* type */ 'versions',
/* action */ 'delete', /* action */ 'delete',
/* ns */ $mod_id, /* ns */ $mod_id,
/* desc */ sprintf(__('delete %s version number'), $mod_id) /* desc */ sprintf(__('delete %s version number'), $mod_id)
); );
$this->addDirectCallback( $this->addDirectCallback(
/* function */ 'zoneclearfeedServerUninstall', /* function */ 'zoneclearfeedServerUninstall',
/* desc */ 'delete feeds relations' /* desc */ 'delete feeds relations'
); );
function zoneclearfeedServerUninstall($core, $id) function zoneclearfeedServerUninstall($core, $id)
{ {
if ($id != 'zoneclearFeedServer') { if ($id != 'zoneclearFeedServer') {
return null; return null;
} }
//... //...
} }

View file

@ -1,28 +1,28 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief zoneclearFeedServer, a plugin for Dotclear 2
# This file is part of zoneclearFeedServer, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis, BG, Pierre Van Glabeke
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
$core->addBehavior( $core->addBehavior(
'initWidgets', 'initWidgets',
array('zoneclearFeedServerWidget', 'adminSource') array('zoneclearFeedServerWidget', 'adminSource')
); );
$core->addBehavior( $core->addBehavior(
'initWidgets', 'initWidgets',
array('zoneclearFeedServerWidget', 'adminNumber') array('zoneclearFeedServerWidget', 'adminNumber')
); );
/** /**
@ -32,282 +32,282 @@ $core->addBehavior(
*/ */
class zoneclearFeedServerWidget class zoneclearFeedServerWidget
{ {
/** /**
* Widget configuration for sources list. * Widget configuration for sources list.
* *
* @param dcWidget $w dcWidget instance * @param dcWidget $w dcWidget instance
*/ */
public static function adminSource($w) public static function adminSource($w)
{ {
$w->create( $w->create(
'zcfssource', 'zcfssource',
__('Feeds server: sources'), __('Feeds server: sources'),
array('zoneclearFeedServerWidget', 'publicSource'), array('zoneclearFeedServerWidget', 'publicSource'),
null, null,
__('List sources of feeds') __('List sources of feeds')
); );
$w->zcfssource->setting( $w->zcfssource->setting(
'title', 'title',
__('Title:'), __('Title:'),
__('Feeds sources'), __('Feeds sources'),
'text' 'text'
); );
$w->zcfssource->setting( $w->zcfssource->setting(
'sortby', 'sortby',
__('Order by:'), __('Order by:'),
'feed_upd_last', 'feed_upd_last',
'combo', 'combo',
array( array(
__('Last update') => 'feed_upd_last', __('Last update') => 'feed_upd_last',
__('Name') => 'lowername', __('Name') => 'lowername',
__('Create date') => 'feed_creadt' __('Create date') => 'feed_creadt'
) )
); );
$w->zcfssource->setting( $w->zcfssource->setting(
'sort', 'sort',
__('Sort:'), __('Sort:'),
'desc', 'desc',
'combo', 'combo',
array( array(
__('Ascending') => 'asc', __('Ascending') => 'asc',
__('Descending') => 'desc' __('Descending') => 'desc'
) )
); );
$w->zcfssource->setting( $w->zcfssource->setting(
'limit', 'limit',
__('Limit:'), __('Limit:'),
10, 10,
'text' 'text'
); );
$w->zcfssource->setting('pagelink',__('Link to the list of sources:'),__('All sources')); $w->zcfssource->setting('pagelink',__('Link to the list of sources:'),__('All sources'));
$w->zcfssource->setting( $w->zcfssource->setting(
'homeonly', 'homeonly',
__('Display on:'), __('Display on:'),
0, 0,
'combo', 'combo',
array( array(
__('All pages') => 0, __('All pages') => 0,
__('Home page only') => 1, __('Home page only') => 1,
__('Except on home page') => 2 __('Except on home page') => 2
) )
); );
$w->zcfssource->setting('content_only',__('Content only'),0,'check'); $w->zcfssource->setting('content_only',__('Content only'),0,'check');
$w->zcfssource->setting('class',__('CSS class:'),''); $w->zcfssource->setting('class',__('CSS class:'),'');
$w->zcfssource->setting('offline',__('Offline'),0,'check'); $w->zcfssource->setting('offline',__('Offline'),0,'check');
} }
/** /**
* Widget configuration for feeds info. * Widget configuration for feeds info.
* *
* @param dcWidget $w dcWidget instance * @param dcWidget $w dcWidget instance
*/ */
public static function adminNumber($w) public static function adminNumber($w)
{ {
$w->create( $w->create(
'zcfsnumber', 'zcfsnumber',
__('Feeds server: numbers'), __('Feeds server: numbers'),
array('zoneclearFeedServerWidget', 'publicNumber'), array('zoneclearFeedServerWidget', 'publicNumber'),
null, null,
__('Show some numbers about feeds') __('Show some numbers about feeds')
); );
$w->zcfsnumber->setting( $w->zcfsnumber->setting(
'title', 'title',
__('Title:') __('Title:')
,__('Feeds numbers'), ,__('Feeds numbers'),
'text' 'text'
); );
# Feed # Feed
$w->zcfsnumber->setting( $w->zcfsnumber->setting(
'feed_show', 'feed_show',
__('Show feeds count'), __('Show feeds count'),
1, 1,
'check' 'check'
); );
$w->zcfsnumber->setting( $w->zcfsnumber->setting(
'feed_title', 'feed_title',
__('Title for feeds count:'), __('Title for feeds count:'),
__('Feeds:'), __('Feeds:'),
'text' 'text'
); );
# Entry # Entry
$w->zcfsnumber->setting( $w->zcfsnumber->setting(
'entry_show', 'entry_show',
__('Show entries count'), __('Show entries count'),
1, 1,
'check' 'check'
); );
$w->zcfsnumber->setting( $w->zcfsnumber->setting(
'entry_title', 'entry_title',
__('Title for entries count:'), __('Title for entries count:'),
__('Entries:'), __('Entries:'),
'text' 'text'
); );
$w->zcfsnumber->setting(
'homeonly',
__('Display on:'),
0,
'combo',
array(
__('All pages') => 0,
__('Home page only') => 1,
__('Except on home page') => 2
)
);
$w->zcfsnumber->setting(
'content_only',
__('Content only'),
0,
'check'
);
$w->zcfsnumber->setting(
'class',
__('CSS class:'),
''
);
$w->zcfsnumber->setting('offline',__('Offline'),0,'check');
}
/** $w->zcfsnumber->setting(
* Widget for sources list. 'homeonly',
* __('Display on:'),
* @param dcWidget $w dcWidget instance 0,
*/ 'combo',
public static function publicSource($w) array(
{ __('All pages') => 0,
global $core; __('Home page only') => 1,
__('Except on home page') => 2
)
);
$w->zcfsnumber->setting(
'content_only',
__('Content only'),
0,
'check'
);
$w->zcfsnumber->setting(
'class',
__('CSS class:'),
''
);
$w->zcfsnumber->setting('offline',__('Offline'),0,'check');
}
if ($w->offline) /**
return; * Widget for sources list.
*
if (!$core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active * @param dcWidget $w dcWidget instance
|| $w->homeonly == 1 && $core->url->type != 'default' */
|| $w->homeonly == 2 && $core->url->type == 'default' public static function publicSource($w)
) { {
return null; global $core;
}
$p = array(); if ($w->offline)
$p['order'] = ($w->sortby && in_array($w->sortby, array('feed_upd_last', 'lowername', 'feed_creadt'))) ? return;
$w->sortby.' ' : 'feed_upd_last ';
$p['order'] .= $w->sort == 'desc' ? 'DESC' : 'ASC';
$p['limit'] = abs((integer) $w->limit);
$p['feed_status'] = 1;
$zc = new zoneclearFeedServer($core); if (!$core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active
$rs = $zc->getFeeds($p); || $w->homeonly == 1 && $core->url->type != 'default'
|| $w->homeonly == 2 && $core->url->type == 'default'
) {
return null;
}
if ($rs->isEmpty()) { $p = array();
$p['order'] = ($w->sortby && in_array($w->sortby, array('feed_upd_last', 'lowername', 'feed_creadt'))) ?
$w->sortby.' ' : 'feed_upd_last ';
$p['order'] .= $w->sort == 'desc' ? 'DESC' : 'ASC';
$p['limit'] = abs((integer) $w->limit);
$p['feed_status'] = 1;
return null; $zc = new zoneclearFeedServer($core);
} $rs = $zc->getFeeds($p);
$res = ''; if ($rs->isEmpty()) {
$i = 1;
while($rs->fetch()) {
$res .=
'<li>'.
'<a href="'.$rs->feed_url.'" title="'.$rs->feed_owner.'">'.$rs->feed_name.'</a>'.
'</li>';
$i++;
}
$res = return null;
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : ''). }
$res = '';
$i = 1;
while($rs->fetch()) {
$res .=
'<li>'.
'<a href="'.$rs->feed_url.'" title="'.$rs->feed_owner.'">'.$rs->feed_name.'</a>'.
'</li>';
$i++;
}
$res =
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
'<ul>'.$res.'</ul>'; '<ul>'.$res.'</ul>';
if ($w->pagelink) { if ($w->pagelink) {
$res .= '<p><strong><a href="'.$core->blog->url.$core->url->getBase('zoneclearFeedsPage').'">'. $res .= '<p><strong><a href="'.$core->blog->url.$core->url->getBase('zoneclearFeedsPage').'">'.
html::escapeHTML($w->pagelink).'</a></strong></p>'; html::escapeHTML($w->pagelink).'</a></strong></p>';
} }
return $w->renderDiv($w->content_only,'zoneclear-sources '.$w->class,'',$res); return $w->renderDiv($w->content_only,'zoneclear-sources '.$w->class,'',$res);
} }
/** /**
* Widget for feeds info. * Widget for feeds info.
* *
* @param dcWidget $w dcWidget instance * @param dcWidget $w dcWidget instance
*/ */
public static function publicNumber($w) public static function publicNumber($w)
{ {
global $core; global $core;
if ($w->offline) if ($w->offline)
return; return;
if (!$core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active if (!$core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active
|| $w->homeonly == 1 && $core->url->type != 'default' || $w->homeonly == 1 && $core->url->type != 'default'
|| $w->homeonly == 2 && $core->url->type == 'default' || $w->homeonly == 2 && $core->url->type == 'default'
) { ) {
return null; return null;
} }
$zc = new zoneclearFeedServer($core); $zc = new zoneclearFeedServer($core);
$content = ''; $content = '';
# Feed # Feed
if ($w->feed_show) { if ($w->feed_show) {
$title = ($w->feed_title ? $title = ($w->feed_title ?
'<strong>'.html::escapeHTML($w->feed_title).'</strong> ' : ''); '<strong>'.html::escapeHTML($w->feed_title).'</strong> ' : '');
$count = $zc->getFeeds(array(),true)->f(0); $count = $zc->getFeeds(array(),true)->f(0);
if ($count == 0) { if ($count == 0) {
$text = sprintf(__('no sources'),$count); $text = sprintf(__('no sources'),$count);
} }
elseif ($count == 1) { elseif ($count == 1) {
$text = sprintf(__('one source'),$count); $text = sprintf(__('one source'),$count);
} }
else { else {
$text = sprintf(__('%d sources'),$count); $text = sprintf(__('%d sources'),$count);
} }
if ($core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_pub_active) { if ($core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_pub_active) {
$text = '<a href="'.$core->blog->url.$core->url->getBase('zoneclearFeedsPage').'">'.$text.'</a>'; $text = '<a href="'.$core->blog->url.$core->url->getBase('zoneclearFeedsPage').'">'.$text.'</a>';
} }
$content .= sprintf('<li>%s%s</li>',$title,$text); $content .= sprintf('<li>%s%s</li>',$title,$text);
} }
# Entry # Entry
if ($w->entry_show) { if ($w->entry_show) {
$count = 0; $count = 0;
$feeds = $zc->getFeeds(); $feeds = $zc->getFeeds();
if (!$feeds->isEmpty()) { if (!$feeds->isEmpty()) {
while ($feeds->fetch()) { while ($feeds->fetch()) {
$count += (integer) $zc->getPostsByFeed(array('feed_id' => $feeds->feed_id), true)->f(0); $count += (integer) $zc->getPostsByFeed(array('feed_id' => $feeds->feed_id), true)->f(0);
} }
} }
$title = ($w->entry_title ? $title = ($w->entry_title ?
'<strong>'.html::escapeHTML($w->entry_title).'</strong> ' : ''); '<strong>'.html::escapeHTML($w->entry_title).'</strong> ' : '');
if ($count == 0) { if ($count == 0) {
$text = sprintf(__('no entries'),$count); $text = sprintf(__('no entries'),$count);
} }
elseif ($count == 1) { elseif ($count == 1) {
$text = sprintf(__('one entry'),$count); $text = sprintf(__('one entry'),$count);
} }
else { else {
$text = sprintf(__('%d entries'),$count); $text = sprintf(__('%d entries'),$count);
} }
$content .= sprintf('<li>%s%s</li>',$title,$text); $content .= sprintf('<li>%s%s</li>',$title,$text);
} }
# Nothing to display # Nothing to display
if (!$content) { if (!$content) {
return null; return null;
} }
# Display # Display
$res = $res =
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : ''). ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
'<ul>'.$content.'</ul>'; '<ul>'.$content.'</ul>';
return $w->renderDiv($w->content_only,'zoneclear-number '.$w->class,'',$res); return $w->renderDiv($w->content_only,'zoneclear-number '.$w->class,'',$res);
} }
} }

View file

@ -1,17 +1,5 @@
#!/usr/bin/env php #!/usr/bin/env php
<?php <?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of zoneclearFeedServer, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
# This file is highly based cron-script.php # This file is highly based cron-script.php
# From Dotclear extension called planet # From Dotclear extension called planet
# By Olivier Meunier and contributors # By Olivier Meunier and contributors
@ -21,18 +9,18 @@ $opts = getopt('d:c:b:u:h');
function help($status=0) function help($status=0)
{ {
echo echo
"Options: \n". "Options: \n".
" -h shows this help\n". " -h shows this help\n".
" -d DotClear root path\n". " -d DotClear root path\n".
" -c DotClear conf path\n". " -c DotClear conf path\n".
" -b Blog ID\n". " -b Blog ID\n".
" -u User ID\n\n"; " -u User ID\n\n";
exit($status); exit($status);
} }
if (isset($opts['h'])) { if (isset($opts['h'])) {
help(); help();
} }
$dc_root = null; $dc_root = null;
@ -40,36 +28,36 @@ $dc_conf = null;
$blog_id = null; $blog_id = null;
if (isset($opts['d'])) { if (isset($opts['d'])) {
$dc_root = $opts['d']; $dc_root = $opts['d'];
} elseif (isset($_SERVER['DC_ROOT'])) { } elseif (isset($_SERVER['DC_ROOT'])) {
$dc_root = $_SERVER['DC_ROOT']; $dc_root = $_SERVER['DC_ROOT'];
} }
if (isset($opts['c'])) { if (isset($opts['c'])) {
$dc_conf = realpath($opts['c']); $dc_conf = realpath($opts['c']);
} elseif (isset($_SERVER['DC_RC_PATH'])) { } elseif (isset($_SERVER['DC_RC_PATH'])) {
$dc_conf = realpath($_SERVER['DC_RC_PATH']); $dc_conf = realpath($_SERVER['DC_RC_PATH']);
} }
if (isset($opts['b'])) { if (isset($opts['b'])) {
$blog_id = $opts['b']; $blog_id = $opts['b'];
} elseif (isset($_SERVER['DC_BLOG_ID'])) { } elseif (isset($_SERVER['DC_BLOG_ID'])) {
$blog_id = $opts['DC_BLOG_ID']; $blog_id = $opts['DC_BLOG_ID'];
} }
if (!$dc_root || !is_dir($dc_root)) { if (!$dc_root || !is_dir($dc_root)) {
fwrite(STDERR,"DotClear root path is not defined\n\n"); fwrite(STDERR,"DotClear root path is not defined\n\n");
help(1); help(1);
} }
if (!$dc_conf || !is_readable($dc_conf)) { if (!$dc_conf || !is_readable($dc_conf)) {
fwrite(STDERR,"DotClear configuration not found\n\n"); fwrite(STDERR,"DotClear configuration not found\n\n");
help(1); help(1);
} }
if (!$blog_id) { if (!$blog_id) {
fwrite(STDERR,"Blog ID is not defined\n\n"); fwrite(STDERR,"Blog ID is not defined\n\n");
help(1); help(1);
} }
$_SERVER['DC_RC_PATH'] = $dc_conf; $_SERVER['DC_RC_PATH'] = $dc_conf;
@ -83,13 +71,13 @@ unset($dc_root);
$core->setBlog(DC_BLOG_ID); $core->setBlog(DC_BLOG_ID);
if ($core->blog->id == null) { if ($core->blog->id == null) {
fwrite(STDERR,"Blog is not defined\n"); fwrite(STDERR,"Blog is not defined\n");
exit(1); exit(1);
} }
if (!isset($opts['u']) || !$core->auth->checkUser($opts['u'])) { if (!isset($opts['u']) || !$core->auth->checkUser($opts['u'])) {
fwrite(STDERR,"Unable to set user\n"); fwrite(STDERR,"Unable to set user\n");
exit(1); exit(1);
} }
$core->plugins->loadModules(DC_PLUGINS_ROOT); $core->plugins->loadModules(DC_PLUGINS_ROOT);
@ -97,9 +85,9 @@ $core->plugins->loadModules(DC_PLUGINS_ROOT);
$core->blog->settings->addNamespace('zoneclearFeedServer'); $core->blog->settings->addNamespace('zoneclearFeedServer');
try { try {
$zc = new zoneclearFeedServer($core); $zc = new zoneclearFeedServer($core);
$zc->checkFeedsUpdate(); $zc->checkFeedsUpdate();
} catch (Exception $e) { } catch (Exception $e) {
fwrite(STDERR,$e->getMessage()."\n"); fwrite(STDERR,$e->getMessage()."\n");
exit(1); exit(1);
} }

View file

@ -1,93 +1,87 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of zoneclearFeedServer, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
/** /**
* @ingroup DC_PLUGIN_ZONECLEARFEEDSERVER * @brief zoneclearFeedServer, a plugin for Dotclear 2
* @brief Feeds server - actions methods *
* @since 2.6 * @package Dotclear
* @see dcPostsActionsPage for more info * @subpackage Plugin
*
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
class zcfsFeedsActionsPage extends dcActionsPage class zcfsFeedsActionsPage extends dcActionsPage
{ {
public $zcfs; public $zcfs;
public function __construct(dcCore $core, $uri, $redirect_args=array()) public function __construct(dcCore $core, $uri, $redirect_args=array())
{ {
$this->zcfs = new zoneclearFeedServer($core); $this->zcfs = new zoneclearFeedServer($core);
parent::__construct($core, $uri, $redirect_args); parent::__construct($core, $uri, $redirect_args);
$this->redirect_fields = array( $this->redirect_fields = array(
'sortby', 'order', 'page', 'nb' 'sortby', 'order', 'page', 'nb'
); );
$this->field_entries = 'feeds'; $this->field_entries = 'feeds';
$this->caller_title = __('Feeds'); $this->caller_title = __('Feeds');
$this->loadDefaults(); $this->loadDefaults();
} }
protected function loadDefaults() protected function loadDefaults()
{ {
zcfsDefaultFeedsActions::zcfsFeedsActionsPage($this->core, $this); zcfsDefaultFeedsActions::zcfsFeedsActionsPage($this->core, $this);
$this->core->callBehavior('zcfsFeedsActionsPage', $this->core, $this); $this->core->callBehavior('zcfsFeedsActionsPage', $this->core, $this);
} }
public function beginPage($breadcrumb='', $head='') public function beginPage($breadcrumb='', $head='')
{ {
echo echo
'<html><head><title>'.__('Feeds server').'</title>'. '<html><head><title>'.__('Feeds server').'</title>'.
dcPage::jsLoad('js/_posts_actions.js'). dcPage::jsLoad('js/_posts_actions.js').
$head. $head.
'</script></head><body>'. '</script></head><body>'.
$breadcrumb. $breadcrumb.
'<p><a class="back" href="'.$this->getRedirection(true).'">'. '<p><a class="back" href="'.$this->getRedirection(true).'">'.
__('Back to feeds list').'</a></p>'; __('Back to feeds list').'</a></p>';
} }
public function endPage() public function endPage()
{ {
echo echo
'</body></html>'; '</body></html>';
} }
public function error(Exception $e) public function error(Exception $e)
{ {
$this->core->error->add($e->getMessage()); $this->core->error->add($e->getMessage());
$this->beginPage(dcPage::breadcrumb(array( $this->beginPage(dcPage::breadcrumb(array(
html::escapeHTML($this->core->blog->name) => '', html::escapeHTML($this->core->blog->name) => '',
$this->getCallerTitle() => $this->getRedirection(true), $this->getCallerTitle() => $this->getRedirection(true),
__('Feeds actions') => '' __('Feeds actions') => ''
))); )));
$this->endPage(); $this->endPage();
} }
protected function fetchEntries($from) protected function fetchEntries($from)
{ {
if (!empty($from['feeds'])) { if (!empty($from['feeds'])) {
$params['feed_id'] = $from['feeds']; $params['feed_id'] = $from['feeds'];
$feeds = $this->zcfs->getFeeds($params); $feeds = $this->zcfs->getFeeds($params);
while ($feeds->fetch()) { while ($feeds->fetch()) {
$this->entries[$feeds->feed_id] = $feeds->feed_name; $this->entries[$feeds->feed_id] = $feeds->feed_name;
} }
$this->rs = $feeds; $this->rs = $feeds;
} }
else { else {
$this->rs = $this->core->con->select( $this->rs = $this->core->con->select(
"SELECT blog_id FROM ". "SELECT blog_id FROM ".
$this->core->prefix."blog WHERE false" $this->core->prefix."blog WHERE false"
); );
} }
} }
} }
/** /**
@ -98,292 +92,292 @@ class zcfsFeedsActionsPage extends dcActionsPage
*/ */
class zcfsDefaultFeedsActions class zcfsDefaultFeedsActions
{ {
public static function zcfsFeedsActionsPage(dcCore $core, zcfsFeedsActionsPage $ap) public static function zcfsFeedsActionsPage(dcCore $core, zcfsFeedsActionsPage $ap)
{ {
$ap->addAction( $ap->addAction(
array(__('Change category') => 'changecat'), array(__('Change category') => 'changecat'),
array('zcfsDefaultFeedsActions', 'doChangeCategory') array('zcfsDefaultFeedsActions', 'doChangeCategory')
); );
$ap->addAction( $ap->addAction(
array(__('Change update interval') => 'changeint'), array(__('Change update interval') => 'changeint'),
array('zcfsDefaultFeedsActions', 'doChangeInterval') array('zcfsDefaultFeedsActions', 'doChangeInterval')
); );
$ap->addAction( $ap->addAction(
array(__('Disable feed update') => 'disablefeed'), array(__('Disable feed update') => 'disablefeed'),
array('zcfsDefaultFeedsActions', 'doEnableFeed') array('zcfsDefaultFeedsActions', 'doEnableFeed')
); );
$ap->addAction( $ap->addAction(
array(__('Enable feed update') => 'enablefeed'), array(__('Enable feed update') => 'enablefeed'),
array('zcfsDefaultFeedsActions', 'doEnableFeed') array('zcfsDefaultFeedsActions', 'doEnableFeed')
); );
$ap->addAction( $ap->addAction(
array(__('Reset last update') => 'resetupdlast'), array(__('Reset last update') => 'resetupdlast'),
array('zcfsDefaultFeedsActions', 'doResetUpdate') array('zcfsDefaultFeedsActions', 'doResetUpdate')
); );
$ap->addAction( $ap->addAction(
array(__('Update (check) feed') => 'updatefeed'), array(__('Update (check) feed') => 'updatefeed'),
array('zcfsDefaultFeedsActions', 'doUpdateFeed') array('zcfsDefaultFeedsActions', 'doUpdateFeed')
); );
$ap->addAction( $ap->addAction(
array(__('Delete related posts') => 'deletepost'), array(__('Delete related posts') => 'deletepost'),
array('zcfsDefaultFeedsActions', 'doDeletePost') array('zcfsDefaultFeedsActions', 'doDeletePost')
); );
$ap->addAction( $ap->addAction(
array(__('Delete feed (without related posts)') => 'deletefeed'), array(__('Delete feed (without related posts)') => 'deletefeed'),
array('zcfsDefaultFeedsActions', 'doDeleteFeed') array('zcfsDefaultFeedsActions', 'doDeleteFeed')
); );
} }
public static function doEnableFeed(dcCore $core, zcfsFeedsActionsPage $ap, $post) public static function doEnableFeed(dcCore $core, zcfsFeedsActionsPage $ap, $post)
{ {
$enable = $ap->getAction() == 'enablefeed'; $enable = $ap->getAction() == 'enablefeed';
$ids = $ap->getIDs(); $ids = $ap->getIDs();
if (empty($ids)) { if (empty($ids)) {
throw new Exception(__('No feeds selected')); throw new Exception(__('No feeds selected'));
} }
foreach($ids as $id) { foreach($ids as $id) {
$ap->zcfs->enableFeed($id, $enable); $ap->zcfs->enableFeed($id, $enable);
} }
dcPage::addSuccessNotice(sprintf( dcPage::addSuccessNotice(sprintf(
$enable ? $enable ?
__( __(
'%d feed has been successfully enabled.', '%d feed has been successfully enabled.',
'%d feeds have been successfully enabled.', '%d feeds have been successfully enabled.',
count($ids) count($ids)
) )
: :
__( __(
'%d feed has been successfully disabled.', '%d feed has been successfully disabled.',
'%d feeds have been successfully disabled.', '%d feeds have been successfully disabled.',
count($ids) count($ids)
) )
, ,
count($ids) count($ids)
)); ));
$ap->redirect(true); $ap->redirect(true);
} }
public static function doDeletePost(dcCore $core, zcfsFeedsActionsPage $ap, $post) public static function doDeletePost(dcCore $core, zcfsFeedsActionsPage $ap, $post)
{ {
$types = array( $types = array(
'zoneclearfeed_url', 'zoneclearfeed_url',
'zoneclearfeed_author', 'zoneclearfeed_author',
'zoneclearfeed_site', 'zoneclearfeed_site',
'zoneclearfeed_sitename', 'zoneclearfeed_sitename',
'zoneclearfeed_id' 'zoneclearfeed_id'
); );
$ids = $ap->getIDs(); $ids = $ap->getIDs();
if (empty($ids)) { if (empty($ids)) {
throw new Exception(__('No feeds selected')); throw new Exception(__('No feeds selected'));
} }
foreach($ids as $id) { foreach($ids as $id) {
$posts = $ap->zcfs->getPostsByFeed(array( $posts = $ap->zcfs->getPostsByFeed(array(
'feed_id' => $id 'feed_id' => $id
)); ));
while($posts->fetch()) { while($posts->fetch()) {
$core->blog->delPost($posts->post_id); $core->blog->delPost($posts->post_id);
$core->con->execute( $core->con->execute(
'DELETE FROM '.$core->prefix.'meta '. 'DELETE FROM '.$core->prefix.'meta '.
'WHERE post_id = '.$posts->post_id.' '. 'WHERE post_id = '.$posts->post_id.' '.
'AND meta_type '.$core->con->in($types).' ' 'AND meta_type '.$core->con->in($types).' '
); );
} }
} }
dcPage::addSuccessNotice( dcPage::addSuccessNotice(
__('Entries have been successfully deleted.') __('Entries have been successfully deleted.')
); );
$ap->redirect(true); $ap->redirect(true);
} }
public static function doDeleteFeed(dcCore $core, zcfsFeedsActionsPage $ap, $post) public static function doDeleteFeed(dcCore $core, zcfsFeedsActionsPage $ap, $post)
{ {
$ids = $ap->getIDs(); $ids = $ap->getIDs();
if (empty($ids)) { if (empty($ids)) {
throw new Exception(__('No feeds selected')); throw new Exception(__('No feeds selected'));
} }
foreach($ids as $id) { foreach($ids as $id) {
$ap->zcfs->delFeed($id); $ap->zcfs->delFeed($id);
} }
dcPage::addSuccessNotice(sprintf( dcPage::addSuccessNotice(sprintf(
__( __(
'%d feed has been successfully deleted.', '%d feed has been successfully deleted.',
'%d feeds have been successfully deleted.', '%d feeds have been successfully deleted.',
count($ids) count($ids)
), ),
count($ids) count($ids)
)); ));
$ap->redirect(true); $ap->redirect(true);
} }
public static function doUpdateFeed(dcCore $core, zcfsFeedsActionsPage $ap, $post) public static function doUpdateFeed(dcCore $core, zcfsFeedsActionsPage $ap, $post)
{ {
$ids = $ap->getIDs(); $ids = $ap->getIDs();
if (empty($ids)) { if (empty($ids)) {
throw new Exception(__('No feeds selected')); throw new Exception(__('No feeds selected'));
} }
foreach($ids as $id) { foreach($ids as $id) {
$ap->zcfs->checkFeedsUpdate($id, true); $ap->zcfs->checkFeedsUpdate($id, true);
} }
dcPage::addSuccessNotice(sprintf( dcPage::addSuccessNotice(sprintf(
__( __(
'%d feed has been successfully updated.', '%d feed has been successfully updated.',
'%d feeds have been successfully updated.', '%d feeds have been successfully updated.',
count($ids) count($ids)
), ),
count($ids) count($ids)
)); ));
$ap->redirect(true); $ap->redirect(true);
} }
public static function doResetUpdate(dcCore $core, zcfsFeedsActionsPage $ap, $post) public static function doResetUpdate(dcCore $core, zcfsFeedsActionsPage $ap, $post)
{ {
$ids = $ap->getIDs(); $ids = $ap->getIDs();
if (empty($ids)) { if (empty($ids)) {
throw new Exception(__('No feeds selected')); throw new Exception(__('No feeds selected'));
} }
foreach($ids as $id) { foreach($ids as $id) {
$cur = $ap->zcfs->openCursor(); $cur = $ap->zcfs->openCursor();
$cur->feed_upd_last = 0; $cur->feed_upd_last = 0;
$ap->zcfs->updFeed($id, $cur); $ap->zcfs->updFeed($id, $cur);
$ap->zcfs->checkFeedsUpdate($id, true); $ap->zcfs->checkFeedsUpdate($id, true);
} }
dcPage::addSuccessNotice(sprintf( dcPage::addSuccessNotice(sprintf(
__( __(
'Last update of %s feed successfully reseted.', 'Last update of %s feed successfully reseted.',
'Last update of %s feeds successfully reseted.', 'Last update of %s feeds successfully reseted.',
count($ids) count($ids)
), ),
count($ids) count($ids)
)); ));
$ap->redirect(true); $ap->redirect(true);
} }
public static function doChangeCategory(dcCore $core, zcfsFeedsActionsPage $ap, $post) public static function doChangeCategory(dcCore $core, zcfsFeedsActionsPage $ap, $post)
{ {
if (isset($post['upd_cat_id'])) { if (isset($post['upd_cat_id'])) {
$ids = $ap->getIDs(); $ids = $ap->getIDs();
if (empty($ids)) { if (empty($ids)) {
throw new Exception(__('No feeds selected')); throw new Exception(__('No feeds selected'));
} }
$cat_id = abs((integer) $post['upd_cat_id']); $cat_id = abs((integer) $post['upd_cat_id']);
foreach($ids as $id) { foreach($ids as $id) {
$cur = $ap->zcfs->openCursor(); $cur = $ap->zcfs->openCursor();
$cur->cat_id = $cat_id == 0 ? null : $cat_id; $cur->cat_id = $cat_id == 0 ? null : $cat_id;
$ap->zcfs->updFeed($id, $cur); $ap->zcfs->updFeed($id, $cur);
} }
dcPage::addSuccessNotice(sprintf( dcPage::addSuccessNotice(sprintf(
__( __(
'Category of %s feed successfully changed.', 'Category of %s feed successfully changed.',
'Category of %s feeds successfully changed.', 'Category of %s feeds successfully changed.',
count($ids) count($ids)
), ),
count($ids) count($ids)
)); ));
$ap->redirect(true); $ap->redirect(true);
} }
else { else {
$categories_combo = dcAdminCombos::getCategoriesCombo( $categories_combo = dcAdminCombos::getCategoriesCombo(
$core->blog->getCategories() $core->blog->getCategories()
); );
$ap->beginPage( $ap->beginPage(
dcPage::breadcrumb( dcPage::breadcrumb(
array( array(
html::escapeHTML($core->blog->name) => '', html::escapeHTML($core->blog->name) => '',
__('Feeds server') => '', __('Feeds server') => '',
$ap->getCallerTitle() => $ap->getRedirection(true), $ap->getCallerTitle() => $ap->getRedirection(true),
__('Change category for this selection') => '' __('Change category for this selection') => ''
))); )));
echo echo
'<form action="'.$ap->getURI().'" method="post">'. '<form action="'.$ap->getURI().'" method="post">'.
$ap->getCheckboxes(). $ap->getCheckboxes().
'<p><label for="upd_cat_id" class="classic">'.__('Category:').'</label> '. '<p><label for="upd_cat_id" class="classic">'.__('Category:').'</label> '.
form::combo(array('upd_cat_id'), $categories_combo, ''). form::combo(array('upd_cat_id'), $categories_combo, '').
$core->formNonce(). $core->formNonce().
$ap->getHiddenFields(). $ap->getHiddenFields().
form::hidden(array('action'), 'changecat'). form::hidden(array('action'), 'changecat').
'<input type="submit" value="'.__('Save').'" /></p>'. '<input type="submit" value="'.__('Save').'" /></p>'.
'</form>'; '</form>';
$ap->endPage(); $ap->endPage();
} }
} }
public static function doChangeInterval(dcCore $core, zcfsFeedsActionsPage $ap, $post) public static function doChangeInterval(dcCore $core, zcfsFeedsActionsPage $ap, $post)
{ {
if (isset($post['upd_upd_int'])) { if (isset($post['upd_upd_int'])) {
$ids = $ap->getIDs(); $ids = $ap->getIDs();
if (empty($ids)) { if (empty($ids)) {
throw new Exception(__('No feeds selected')); throw new Exception(__('No feeds selected'));
} }
$upd_int = abs((integer) $post['upd_upd_int']); $upd_int = abs((integer) $post['upd_upd_int']);
foreach($ids as $id) { foreach($ids as $id) {
$cur = $ap->zcfs->openCursor(); $cur = $ap->zcfs->openCursor();
$cur->feed_upd_int = $upd_int; $cur->feed_upd_int = $upd_int;
$ap->zcfs->updFeed($id, $cur); $ap->zcfs->updFeed($id, $cur);
} }
dcPage::addSuccessNotice(sprintf( dcPage::addSuccessNotice(sprintf(
__( __(
'Update frequency of %s feed successfully changed.', 'Update frequency of %s feed successfully changed.',
'Update frequency of %s feeds successfully changed.', 'Update frequency of %s feeds successfully changed.',
count($ids) count($ids)
), ),
count($ids) count($ids)
)); ));
$ap->redirect(true); $ap->redirect(true);
} }
else { else {
$ap->beginPage( $ap->beginPage(
dcPage::breadcrumb( dcPage::breadcrumb(
array( array(
html::escapeHTML($core->blog->name) => '', html::escapeHTML($core->blog->name) => '',
__('Feeds server') => '', __('Feeds server') => '',
$ap->getCallerTitle() => $ap->getRedirection(true), $ap->getCallerTitle() => $ap->getRedirection(true),
__('Change update frequency for this selection') => '' __('Change update frequency for this selection') => ''
))); )));
echo echo
'<form action="'.$ap->getURI().'" method="post">'. '<form action="'.$ap->getURI().'" method="post">'.
$ap->getCheckboxes(). $ap->getCheckboxes().
'<p><label for="upd_upd_int" class="classic">'.__('Frequency:').'</label> '. '<p><label for="upd_upd_int" class="classic">'.__('Frequency:').'</label> '.
form::combo(array('upd_upd_int'), $ap->zcfs->getAllUpdateInterval(), ''). form::combo(array('upd_upd_int'), $ap->zcfs->getAllUpdateInterval(), '').
$core->formNonce(). $core->formNonce().
$ap->getHiddenFields(). $ap->getHiddenFields().
form::hidden(array('action'), 'changeint'). form::hidden(array('action'), 'changeint').
'<input type="submit" value="'.__('Save').'" /></p>'. '<input type="submit" value="'.__('Save').'" /></p>'.
'</form>'; '</form>';
$ap->endPage(); $ap->endPage();
} }
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -1,19 +1,19 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief zoneclearFeedServer, a plugin for Dotclear 2
# This file is part of zoneclearFeedServer, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis, BG, Pierre Van Glabeke
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
/** /**
@ -24,95 +24,95 @@ if (!defined('DC_CONTEXT_ADMIN')) {
*/ */
class zcfsFeedsList extends adminGenericList class zcfsFeedsList extends adminGenericList
{ {
public function feedsDisplay($page, $nb_per_page, $url, $enclose='') public function feedsDisplay($page, $nb_per_page, $url, $enclose='')
{ {
if ($this->rs->isEmpty()) { if ($this->rs->isEmpty()) {
return '<p><strong>'.__('There is no feed').'</strong></p>'; return '<p><strong>'.__('There is no feed').'</strong></p>';
} }
$pager = new dcPager($page, $this->rs_count ,$nb_per_page, 10); $pager = new dcPager($page, $this->rs_count ,$nb_per_page, 10);
$pager->base_url = $url; $pager->base_url = $url;
$html_block = $html_block =
'<div class="table-outer">'. '<div class="table-outer">'.
'<table class="clear">'. '<table class="clear">'.
'<thead>'. '<thead>'.
'<tr>'. '<tr>'.
'<th class="nowrap first" colspan="2">'.__('Name').'</th>'. '<th class="nowrap first" colspan="2">'.__('Name').'</th>'.
'<th class="nowrap">'.__('Feed').'</th>'. '<th class="nowrap">'.__('Feed').'</th>'.
'<th class="nowrap">'.__('Frequency').'</th>'. '<th class="nowrap">'.__('Frequency').'</th>'.
'<th class="nowrap">'.__('Last update').'</th>'. '<th class="nowrap">'.__('Last update').'</th>'.
'<th class="nowrap">'.__('Entries').'</th>'. '<th class="nowrap">'.__('Entries').'</th>'.
'<th class="nowrap">'.__('Status').'</th>'. '<th class="nowrap">'.__('Status').'</th>'.
'</tr>'. '</tr>'.
'</thead>'. '</thead>'.
'<tbody>%s</tbody>'. '<tbody>%s</tbody>'.
'</table>'. '</table>'.
'</div>'; '</div>';
$res = ''; $res = '';
while ($this->rs->fetch()) { while ($this->rs->fetch()) {
$res .= $this->feedsLine(); $res .= $this->feedsLine();
} }
return return
$pager->getLinks(). $pager->getLinks().
sprintf($enclose, sprintf($html_block, $res)). sprintf($enclose, sprintf($html_block, $res)).
$pager->getLinks(); $pager->getLinks();
} }
private function feedsLine()
{
$combo_status = zoneclearFeedServer::getAllStatus();
$combo_upd_int = zoneclearFeedServer::getAllUpdateInterval();
$status = $this->rs->feed_status ?
'<img src="images/check-on.png" alt="enable" />' :
'<img src="images/check-off.png" alt="disable" />';
$category = $this->rs->cat_id ?
$this->rs->cat_title : __('no categories');
$entries_count = $this->rs->zc->getPostsByFeed(array('feed_id' => $this->rs->feed_id), true)->f(0); private function feedsLine()
$shunk_feed = $this->rs->feed_feed; {
if (strlen($shunk_feed) > 83) { $combo_status = zoneclearFeedServer::getAllStatus();
$shunk_feed = substr($shunk_feed,0,50).'...'.substr($shunk_feed,-20); $combo_upd_int = zoneclearFeedServer::getAllUpdateInterval();
} $status = $this->rs->feed_status ?
'<img src="images/check-on.png" alt="enable" />' :
'<img src="images/check-off.png" alt="disable" />';
$category = $this->rs->cat_id ?
$this->rs->cat_title : __('no categories');
$url = 'plugin.php?p=zoneclearFeedServer&amp;part=feed&amp;feed_id='.$this->rs->feed_id; $entries_count = $this->rs->zc->getPostsByFeed(array('feed_id' => $this->rs->feed_id), true)->f(0);
$shunk_feed = $this->rs->feed_feed;
if (strlen($shunk_feed) > 83) {
$shunk_feed = substr($shunk_feed,0,50).'...'.substr($shunk_feed,-20);
}
return $url = 'plugin.php?p=zoneclearFeedServer&amp;part=feed&amp;feed_id='.$this->rs->feed_id;
'<tr class="line">'."\n".
'<td class="nowrap">'. return
form::checkbox(array('feeds[]'), $this->rs->feed_id, 0). '<tr class="line">'."\n".
'</td>'. '<td class="nowrap">'.
'<td class="nowrap">'. form::checkbox(array('feeds[]'), $this->rs->feed_id, 0).
'<a href="'.$url.'#feed" title="'.__('Edit').'">'. '</td>'.
html::escapeHTML($this->rs->feed_name).'</a>'. '<td class="nowrap">'.
"</td>\n". '<a href="'.$url.'#feed" title="'.__('Edit').'">'.
'<td class="maximal nowrap">'. html::escapeHTML($this->rs->feed_name).'</a>'.
'<a href="'.$this->rs->feed_feed.'" title="'.html::escapeHTML($this->rs->feed_desc).'">'.html::escapeHTML($shunk_feed).'</a>'. "</td>\n".
"</td>\n". '<td class="maximal nowrap">'.
'<td class="nowrap">'. '<a href="'.$this->rs->feed_feed.'" title="'.html::escapeHTML($this->rs->feed_desc).'">'.html::escapeHTML($shunk_feed).'</a>'.
array_search($this->rs->feed_upd_int,$combo_upd_int). "</td>\n".
"</td>\n". '<td class="nowrap">'.
'<td class="nowrap">'. array_search($this->rs->feed_upd_int,$combo_upd_int).
($this->rs->feed_upd_last < 1 ? "</td>\n".
__('never') : '<td class="nowrap">'.
dt::str(__('%Y-%m-%d %H:%M'), $this->rs->feed_upd_last,$this->rs->zc->core->auth->getInfo('user_tz')) ($this->rs->feed_upd_last < 1 ?
). __('never') :
"</td>\n". dt::str(__('%Y-%m-%d %H:%M'), $this->rs->feed_upd_last,$this->rs->zc->core->auth->getInfo('user_tz'))
'<td class="nowrap">'. ).
($entries_count ? "</td>\n".
'<a href="'.$url.'#entries" title="'.__('View entries').'">'.$entries_count.'</a>' : '<td class="nowrap">'.
$entries_count ($entries_count ?
). '<a href="'.$url.'#entries" title="'.__('View entries').'">'.$entries_count.'</a>' :
"</td>\n". $entries_count
'<td>'. ).
$status. "</td>\n".
"</td>\n". '<td>'.
'</tr>'."\n"; $status.
} "</td>\n".
'</tr>'."\n";
}
} }
/** /**
@ -123,82 +123,82 @@ class zcfsFeedsList extends adminGenericList
*/ */
class zcfsEntriesList extends adminGenericList class zcfsEntriesList extends adminGenericList
{ {
public function display($page, $nb_per_page, $url, $enclose='') public function display($page, $nb_per_page, $url, $enclose='')
{ {
if ($this->rs->isEmpty()) { if ($this->rs->isEmpty()) {
return '<p><strong>'.__('No entry').'</strong></p>'; return '<p><strong>'.__('No entry').'</strong></p>';
} }
$pager = new dcPager($page, $this->rs_count, $nb_per_page, 10); $pager = new dcPager($page, $this->rs_count, $nb_per_page, 10);
$pager->base_url = $url; $pager->base_url = $url;
$pager->html_prev = $this->html_prev; $pager->html_prev = $this->html_prev;
$pager->html_next = $this->html_next; $pager->html_next = $this->html_next;
$pager->var_page = 'page'; $pager->var_page = 'page';
$html_block = $html_block =
'<div class="table-outer">'. '<div class="table-outer">'.
'<table class="clear"><tr>'. '<table class="clear"><tr>'.
'<th colspan="2">'.__('Title').'</th>'. '<th colspan="2">'.__('Title').'</th>'.
'<th>'.__('Date').'</th>'. '<th>'.__('Date').'</th>'.
'<th>'.__('Category').'</th>'. '<th>'.__('Category').'</th>'.
'<th>'.__('Author').'</th>'. '<th>'.__('Author').'</th>'.
'<th>'.__('Comments').'</th>'. '<th>'.__('Comments').'</th>'.
'<th>'.__('Trackbacks').'</th>'. '<th>'.__('Trackbacks').'</th>'.
'<th>'.__('Status').'</th>'. '<th>'.__('Status').'</th>'.
'</tr>%s</table></div>'; '</tr>%s</table></div>';
$res = ''; $res = '';
while ($this->rs->fetch()) { while ($this->rs->fetch()) {
$res .= $this->postLine(); $res .= $this->postLine();
} }
return return
$pager->getLinks(). $pager->getLinks().
sprintf($enclose, sprintf($html_block, $res)). sprintf($enclose, sprintf($html_block, $res)).
$pager->getLinks(); $pager->getLinks();
} }
private function postLine() private function postLine()
{ {
$cat_link = $this->core->auth->check('categories', $this->core->blog->id) ? $cat_link = $this->core->auth->check('categories', $this->core->blog->id) ?
'<a href="category.php?id=%s" title="'.__('Edit category').'">%s</a>' '<a href="category.php?id=%s" title="'.__('Edit category').'">%s</a>'
: '%2$s'; : '%2$s';
$cat_title = $this->rs->cat_title ? $cat_title = $this->rs->cat_title ?
sprintf($cat_link,$this->rs->cat_id, html::escapeHTML($this->rs->cat_title)) sprintf($cat_link,$this->rs->cat_id, html::escapeHTML($this->rs->cat_title))
: __('None'); : __('None');
$img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
switch ($this->rs->post_status) { switch ($this->rs->post_status) {
case 1: case 1:
$img_status = sprintf($img, __('published'), 'check-on.png'); $img_status = sprintf($img, __('published'), 'check-on.png');
break; break;
case 0: case 0:
$img_status = sprintf($img, __('unpublished'), 'check-off.png'); $img_status = sprintf($img, __('unpublished'), 'check-off.png');
break; break;
case -1: case -1:
$img_status = sprintf($img, __('scheduled'), 'scheduled.png'); $img_status = sprintf($img, __('scheduled'), 'scheduled.png');
break; break;
case -2: case -2:
$img_status = sprintf($img, __('pending'), 'check-wrn.png'); $img_status = sprintf($img, __('pending'), 'check-wrn.png');
break; break;
} }
return return
'<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'.
' id="p'.$this->rs->post_id.'">'. ' id="p'.$this->rs->post_id.'">'.
'<td class="nowrap">'. '<td class="nowrap">'.
form::checkbox(array('entries[]'), $this->rs->post_id, '', '', '', !$this->rs->isEditable()).'</td>'. form::checkbox(array('entries[]'), $this->rs->post_id, '', '', '', !$this->rs->isEditable()).'</td>'.
'<td class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type, $this->rs->post_id). '<td class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type, $this->rs->post_id).
'" title="'.__('Edit entry').'">'. '" title="'.__('Edit entry').'">'.
html::escapeHTML($this->rs->post_title).'</a></td>'. html::escapeHTML($this->rs->post_title).'</a></td>'.
'<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->post_dt).'</td>'. '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->post_dt).'</td>'.
'<td class="nowrap">'.$cat_title.'</td>'. '<td class="nowrap">'.$cat_title.'</td>'.
'<td class="nowrap">'.$this->rs->user_id.'</td>'. '<td class="nowrap">'.$this->rs->user_id.'</td>'.
'<td class="nowrap">'.$this->rs->nb_comment.'</td>'. '<td class="nowrap">'.$this->rs->nb_comment.'</td>'.
'<td class="nowrap">'.$this->rs->nb_trackback.'</td>'. '<td class="nowrap">'.$this->rs->nb_trackback.'</td>'.
'<td class="nowrap status">'.$img_status.'</td>'. '<td class="nowrap status">'.$img_status.'</td>'.
'</tr>'; '</tr>';
} }
} }

View file

@ -1,19 +1,19 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief zoneclearFeedServer, a plugin for Dotclear 2
# This file is part of zoneclearFeedServer, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis, BG, Pierre Van Glabeke
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
/** /**
@ -25,124 +25,124 @@ if (!defined('DC_RC_PATH')) {
*/ */
class zcfsSoCialMeWriter class zcfsSoCialMeWriter
{ {
public static function soCialMeWriterMarker($rs) public static function soCialMeWriterMarker($rs)
{ {
$rs['zcfscreate'] = array( $rs['zcfscreate'] = array(
'name' => __('New Zoneclear post'), 'name' => __('New Zoneclear post'),
'description' => __('When a feed has new entry'), 'description' => __('When a feed has new entry'),
'action' => array('Message','Link'), 'action' => array('Message','Link'),
'format' => array('Message'), 'format' => array('Message'),
'wildcards' => array('Message' => array( 'wildcards' => array('Message' => array(
'%posttitle%', '%posttitle%',
'%postlink%', '%postlink%',
'%postauthor%', '%postauthor%',
'%posttweeter%', '%posttweeter%',
'%sitetitle%', '%sitetitle%',
'%sitelink%', '%sitelink%',
'%tags' '%tags'
)) ))
); );
} }
public static function zoneclearFeedServerAfterFeedUpdate($core, $is_new_published_entry, $post, $meta) public static function zoneclearFeedServerAfterFeedUpdate($core, $is_new_published_entry, $post, $meta)
{ {
// for now only new post // for now only new post
if(!$is_new_published_entry) { if(!$is_new_published_entry) {
return null; return null;
} }
$key = 'zcfscreate'; $key = 'zcfscreate';
# Is install # Is install
if (!$core->plugins->moduleExists('soCialMe')) { if (!$core->plugins->moduleExists('soCialMe')) {
return null; return null;
} }
# Is active # Is active
if (!$core->blog->settings->soCialMeWriter->active) { if (!$core->blog->settings->soCialMeWriter->active) {
return null; return null;
} }
# Load services # Load services
$soCialMeWriter = new soCialMeWriter($core); $soCialMeWriter = new soCialMeWriter($core);
# List of service per action # List of service per action
$actions = $soCialMeWriter->getMarker('action'); $actions = $soCialMeWriter->getMarker('action');
# List of format per type # List of format per type
$formats = $soCialMeWriter->getMarker('format'); $formats = $soCialMeWriter->getMarker('format');
# prepare data # prepare data
$shortposturl = soCialMeUtils::reduceURL($meta->url); $shortposturl = soCialMeUtils::reduceURL($meta->url);
$shortposturl = $shortposturl ? $shortposturl : $meta->url; $shortposturl = $shortposturl ? $shortposturl : $meta->url;
$shortsiteurl = soCialMeUtils::reduceURL($meta->site); $shortsiteurl = soCialMeUtils::reduceURL($meta->site);
$shortsiteurl = $shortsiteurl ? $shortsiteurl : $meta->site; $shortsiteurl = $shortsiteurl ? $shortsiteurl : $meta->site;
// need this? // need this?
foreach($meta->tags as $k => $tag) { foreach($meta->tags as $k => $tag) {
$tags[$k] = '#'.$tag; $tags[$k] = '#'.$tag;
} }
# sendMessage # sendMessage
if (!empty($formats[$key]['Message']) if (!empty($formats[$key]['Message'])
&& !empty($actions[$key]['Message']) && !empty($actions[$key]['Message'])
) { ) {
// parse message // parse message
$message_txt = str_replace( $message_txt = str_replace(
array( array(
'%posttitle%', '%posttitle%',
'%postlink%', '%postlink%',
'%postauthor%', '%postauthor%',
'%posttweeter%', '%posttweeter%',
'%sitetitle%', '%sitetitle%',
'%sitelink%', '%sitelink%',
'%tags' '%tags'
), ),
array( array(
$post->post_title, $post->post_title,
$shortposturl, $shortposturl,
$meta->author, $meta->author,
$meta->tweeter, $meta->tweeter,
$meta->sitename, $meta->sitename,
$shortsiteurl, $shortsiteurl,
implode(',', $meta->tags) implode(',', $meta->tags)
), ),
$formats[$key]['Message'] $formats[$key]['Message']
); );
// send message // send message
if (!empty($message_txt)) { if (!empty($message_txt)) {
foreach($actions[$key]['Message'] as $service_id) { foreach($actions[$key]['Message'] as $service_id) {
$soCialMeWriter->play( $soCialMeWriter->play(
$service_id, $service_id,
'Message', 'Message',
'Content', 'Content',
$message_txt $message_txt
); );
} }
} }
} }
# sendLink # sendLink
if (!empty($actions[$key]['Link'])) { if (!empty($actions[$key]['Link'])) {
foreach($actions[$key]['Link'] as $service_id) { foreach($actions[$key]['Link'] as $service_id) {
$soCialMeWriter->play( $soCialMeWriter->play(
$service_id, $service_id,
'Link', 'Link',
'Content', 'Content',
$cur->post_title,$shortposturl $cur->post_title,$shortposturl
); );
} }
} }
# sendData # sendData
// not yet implemented // not yet implemented
#sendArticle #sendArticle
// not yet implemented // not yet implemented
} }
} }

View file

@ -1,169 +0,0 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of zoneclearFeedServer, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {
return null;
}
# This file is used with plugin activityReport
$core->activityReport->addGroup(
'zoneclearFeedServer',
__('Plugin zoneclearFeedServer')
);
# from BEHAVIOR zoneclearFeedServerAfterAddFeed in zoneclearFeedServer/inc/class.zoneclear.feed.server.php
$core->activityReport->addAction(
'zoneclearFeedServer',
'create',
__('feed creation'),
__('A new feed named "%s" point to "%s" was added by "%s"'),
'zoneclearFeedServerAfterAddFeed',
array('zoneclearFeedServerActivityReportBehaviors', 'addFeed')
);
# from BEHAVIOR zoneclearFeedServerAfterUpdFeed in in zoneclearFeedServer/inc/class.zoneclear.feed.server.php
$core->activityReport->addAction(
'zoneclearFeedServer',
'updatefeedinfo',
__('updating feed info'),
__('Feed named "%s" point to "%s" has been updated by "%s"'),
'zoneclearFeedServerAfterUpdFeed',
array('zoneclearFeedServerActivityReportBehaviors', 'updFeedInfo')
);
# from BEHAVIOR zoneclearFeedServerAfterUpdFeed in in zoneclearFeedServer/inc/class.zoneclear.feed.server.php
$core->activityReport->addAction(
'zoneclearFeedServer',
'updatefeedrecords',
__('updating feed records'),
__('Records of the feed named "%s" have been updated automatically'),
'zoneclearFeedServerAfterUpdFeed',
array('zoneclearFeedServerActivityReportBehaviors', 'updFeedRecord')
);
# from BEHAVIOR zoneclearFeedServerAfterDelFeed in in zoneclearFeedServer/inc/class.zoneclear.feed.server.php
$core->activityReport->addAction(
'zoneclearFeedServer',
'delete',
__('feed deletion'),
__('Feed named "%s" point to "%s" has been deleted by "%s"'),
'zoneclearFeedServerAfterDelFeed',
array('zoneclearFeedServerActivityReportBehaviors', 'delFeed')
);
# from BEHAVIOR zoneclearFeedServerAfterEnableFeed in in zoneclearFeedServer/inc/class.zoneclear.feed.server.php
$core->activityReport->addAction(
'zoneclearFeedServer',
'status',
__('feed status'),
__('Feed named "%s" point to "%s" has been set to "%s"'),
'zoneclearFeedServerAfterEnableFeed',
array('zoneclearFeedServerActivityReportBehaviors', 'enableFeed')
);
class zoneclearFeedServerActivityReportBehaviors
{
public static function addFeed($cur)
{
global $core;
$logs = array(
$cur->feed_name,
$cur->feed_feed,
$core->auth->getInfo('user_cn')
);
$core->activityReport->addLog(
'zoneclearFeedServer',
'create',
$logs
);
}
public static function updFeedInfo($cur, $id)
{
if (defined('DC_CONTEXT_ADMIN')) {
global $core;
$zc = new zoneclearFeedServer($core);
$rs = $zc->getFeeds(array('feed_id' => $id));
$logs = array(
$rs->feed_name,
$rs->feed_feed,
$core->auth->getInfo('user_cn')
);
$core->activityReport->addLog(
'zoneclearFeedServer',
'updatefeedinfo',
$logs
);
}
}
public static function updFeedRecord($cur,$id)
{
if (!defined('DC_CONTEXT_ADMIN')) {
global $core;
$zc = new zoneclearFeedServer($core);
$rs = $zc->getFeeds(array('feed_id' => $id));
$logs = array(
$rs->feed_name
);
$core->activityReport->addLog(
'zoneclearFeedServer',
'updatefeedrecords',
$logs
);
}
}
public static function delFeed($id)
{
global $core;
$zc = new zoneclearFeedServer($core);
$rs = $zc->getFeeds(array('feed_id' => $id));
$logs = array(
$rs->feed_name,
$rs->feed_feed,
$core->auth->getInfo('user_cn')
);
$core->activityReport->addLog(
'zoneclearFeedServer',
'delete',
$logs
);
}
public static function enableFeed($id, $enable, $time)
{
global $core;
$zc = new zoneclearFeedServer($core);
$rs = $zc->getFeeds(array('feed_id' => $id));
$logs = array(
$rs->feed_name,
$rs->feed_feed,
$enable ? 'enable' : 'disable'
);
$core->activityReport->addLog(
'zoneclearFeedServer',
'status',
$logs
);
}
}

1588
index.php

File diff suppressed because it is too large Load diff

View file

@ -3,7 +3,7 @@ $(function(){
$filtersform = $('#filters-form'); $filtersform = $('#filters-form');
$filtersform.before('<p><a id="filter-control" class="form-control" href="plugin.php?p=zoneclearFeedServer&amp;part=feeds" style="display:inline">'+dotclear.msg.filter_posts_list+'</a></p>') $filtersform.before('<p><a id="filter-control" class="form-control" href="plugin.php?p=zoneclearFeedServer&amp;part=feeds" style="display:inline">'+dotclear.msg.filter_posts_list+'</a></p>')
if( dotclear.msg.show_filters == 'false' ) { if( dotclear.msg.show_filters == 'false' ) {
$filtersform.hide(); $filtersform.hide();
} else { } else {
@ -11,7 +11,7 @@ $(function(){
.addClass('open') .addClass('open')
.text(dotclear.msg.cancel_the_filter); .text(dotclear.msg.cancel_the_filter);
} }
$('#filter-control').click(function() { $('#filter-control').click(function() {
if( $(this).hasClass('open') ) { if( $(this).hasClass('open') ) {
if( dotclear.msg.show_filters == 'true' ) { if( dotclear.msg.show_filters == 'true' ) {

View file

@ -3,7 +3,7 @@ $(function(){
$filtersform = $('#filters-form'); $filtersform = $('#filters-form');
$filtersform.before('<p><a id="filter-control" class="form-control" href="plugin.php?p=zoneclearFeedServer&amp;part=feed#entries" style="display:inline">'+dotclear.msg.filter_posts_list+'</a></p>') $filtersform.before('<p><a id="filter-control" class="form-control" href="plugin.php?p=zoneclearFeedServer&amp;part=feed#entries" style="display:inline">'+dotclear.msg.filter_posts_list+'</a></p>')
if( dotclear.msg.show_filters == 'false' ) { if( dotclear.msg.show_filters == 'false' ) {
$filtersform.hide(); $filtersform.hide();
} else { } else {
@ -11,7 +11,7 @@ $(function(){
.addClass('open') .addClass('open')
.text(dotclear.msg.cancel_the_filter); .text(dotclear.msg.cancel_the_filter);
} }
$('#filter-control').click(function() { $('#filter-control').click(function() {
if( $(this).hasClass('open') ) { if( $(this).hasClass('open') ) {
if( dotclear.msg.show_filters == 'true' ) { if( dotclear.msg.show_filters == 'true' ) {

View file

@ -13,5 +13,5 @@
if (!isset($__resources['help']['zoneclearFeedServer'])) if (!isset($__resources['help']['zoneclearFeedServer']))
{ {
$__resources['help']['zoneclearFeedServer'] = dirname(__FILE__).'/help/zoneclearFeedServer.html'; $__resources['help']['zoneclearFeedServer'] = dirname(__FILE__).'/help/zoneclearFeedServer.html';
} }

View file

@ -13,5 +13,5 @@
if (!isset($__resources['help']['zoneclearFeedServer'])) if (!isset($__resources['help']['zoneclearFeedServer']))
{ {
$__resources['help']['zoneclearFeedServer'] = dirname(__FILE__).'/help/zoneclearFeedServer.html'; $__resources['help']['zoneclearFeedServer'] = dirname(__FILE__).'/help/zoneclearFeedServer.html';
} }