';
if ($core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_pub_active) {
- echo '
'.__('View the public list of feeds').'
';
+ echo '
'.__('View the public list of feeds').'
';
}
echo '
@@ -178,14 +178,14 @@ __('Enable public page').'
'.__('Redirect to original post on:').'
';
foreach($zc->getPublicUrlTypes($core) as $k => $v) {
- echo
- '';
+ echo
+ '';
}
echo '
@@ -195,14 +195,14 @@ echo '
'.__('Show full content on:').'
';
foreach($zc->getPublicUrlTypes($core) as $k => $v) {
- echo
- '';
+ echo
+ '';
}
echo '
diff --git a/_define.php b/_define.php
index e44856d..3d231fe 100644
--- a/_define.php
+++ b/_define.php
@@ -1,36 +1,31 @@
registerModule(
- /* Name */
- "zoneclearFeedServer",
- /* Description*/
- "Mix your blog with a feeds planet",
- /* Author */
- "Jean-Christian Denis, BG, Pierre Van Glabeke",
- /* Version */
- '2015.07.19',
- /* Properies */
- array(
- 'permissions' => 'admin',
- 'type' => 'plugin',
- 'dc_min' => '2.8',
- 'support' => 'http://forum.dotclear.org/viewtopic.php?pid=331158',
- 'details' => 'http://plugins.dotaddict.org/dc2/details/zoneclearFeedServer'
- )
+ 'zoneclearFeedServer',
+ 'Mix your blog with a feeds planet',
+ 'Jean-Christian Denis, BG, Pierre Van Glabeke',
+ '2015.07.19',
+ [
+ 'requires' => [['core', '2.19']],
+ 'permissions' => 'admin',
+ 'type' => 'plugin',
+ 'support' => 'https://github.com/JcDenis/zoneclearFeedServer',
+ 'details' => 'https://plugins.dotaddict.org/dc2/details/pacKman',
+ 'repository' => 'https://raw.githubusercontent.com/JcDenis/zoneclearFeedServer/master/dcstore.xml'
+ ]
);
\ No newline at end of file
diff --git a/_install.php b/_install.php
index 8489f7e..91511c7 100644
--- a/_install.php
+++ b/_install.php
@@ -1,98 +1,98 @@
getVersion($mod_id),
- $core->plugins->moduleInfo($mod_id, 'version'),
- '>='
- )) {
+ # Check module version
+ if (version_compare(
+ $core->getVersion($mod_id),
+ $core->plugins->moduleInfo($mod_id, 'version'),
+ '>='
+ )) {
- return null;
- }
+ return null;
+ }
- # Check Dotclear version
- if (!method_exists('dcUtils', 'versionsCompare')
- || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
- throw new Exception(sprintf(
- '%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);
+ # Check Dotclear version
+ if (!method_exists('dcUtils', 'versionsCompare')
+ || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
+ throw new Exception(sprintf(
+ '%s requires Dotclear %s', $mod_id, $dc_min
+ ));
+ }
- # Set module version
- $core->setVersion(
- $mod_id,
- $core->plugins->moduleInfo($mod_id, 'version')
- );
+ # 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)
- 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) {
- $core->error->add($e->getMessage());
+ $core->error->add($e->getMessage());
- return false;
+ return false;
}
\ No newline at end of file
diff --git a/_prepend.php b/_prepend.php
index 5469c94..faa8b2b 100644
--- a/_prepend.php
+++ b/_prepend.php
@@ -1,25 +1,25 @@
getVersion('zoneclearFeedServer') !=
$core->plugins->moduleInfo('zoneclearFeedServer', 'version')) {
- return null;
+ return null;
}
$d = dirname(__FILE__).'/inc/';
@@ -32,24 +32,24 @@ $__autoload['zcfsDefaultFeedsActions'] = $d.'class.zcfs.feedsactions.php';
# public url for page of description of the flux
$core->url->register(
- 'zoneclearFeedsPage',
- 'zcfeeds',
- '^zcfeeds(.*?)$',
- array('zcfsUrlHandler', 'zcFeedsPage')
+ 'zoneclearFeedsPage',
+ 'zcfeeds',
+ '^zcfeeds(.*?)$',
+ array('zcfsUrlHandler', 'zcFeedsPage')
);
-
+/*
# Add to plugn soCialMe (writer part)
$__autoload['zcfsSoCialMeWriter'] = $d.'lib.zcfs.socialmewriter.php';
$core->addBehavior(
- 'soCialMeWriterMarker',
- array('zcfsSoCialMeWriter', 'soCialMeWriterMarker')
+ 'soCialMeWriterMarker',
+ array('zcfsSoCialMeWriter', 'soCialMeWriterMarker')
);
$core->addBehavior(
- 'zoneclearFeedServerAfterFeedUpdate',
- array('zcfsSoCialMeWriter', 'zoneclearFeedServerAfterFeedUpdate')
+ 'zoneclearFeedServerAfterFeedUpdate',
+ array('zcfsSoCialMeWriter', 'zoneclearFeedServerAfterFeedUpdate')
);
-
+//*/
# Add to report on plugin activityReport
if (defined('ACTIVITY_REPORT')) {
- require_once $d.'lib.zcfs.activityreport.php';
+ require_once $d.'lib.zcfs.activityreport.php';
}
\ No newline at end of file
diff --git a/_public.php b/_public.php
index 459808a..8d3e2ed 100644
--- a/_public.php
+++ b/_public.php
@@ -1,16 +1,15 @@
blog->settings->zoneclearFeedServer;
require_once dirname(__FILE__).'/_widgets.php';
$core->addBehavior(
- 'coreBlogGetPosts',
- array('zcfsPublicBehaviors', 'coreBlogGetPosts')
+ 'coreBlogGetPosts',
+ array('zcfsPublicBehaviors', 'coreBlogGetPosts')
);
if (!$s->zoneclearFeedServer_active) {
- return null;
+ return null;
}
if (1 == $s->zoneclearFeedServer_bhv_pub_upd) {
- $core->addBehavior(
- 'publicBeforeDocument',
- array('zcfsPublicBehaviors', 'publicDocument')
- );
+ $core->addBehavior(
+ 'publicBeforeDocument',
+ array('zcfsPublicBehaviors', 'publicDocument')
+ );
}
elseif (2 == $s->zoneclearFeedServer_bhv_pub_upd) {
- $core->addBehavior(
- 'publicAfterDocument',
- array('zcfsPublicBehaviors', 'publicAfterDocument')
- );
+ $core->addBehavior(
+ 'publicAfterDocument',
+ array('zcfsPublicBehaviors', 'publicAfterDocument')
+ );
}
elseif (3 == $s->zoneclearFeedServer_bhv_pub_upd) {
- $core->addBehavior(
- 'publicHeadContent',
- array('zcfsPublicBehaviors', 'publicHeadContent')
- );
+ $core->addBehavior(
+ 'publicHeadContent',
+ array('zcfsPublicBehaviors', 'publicHeadContent')
+ );
}
# Take care about tweakurls (thanks Mathieu M.)
if (version_compare($core->plugins->moduleInfo('tweakurls', 'version'), '0.8', '>=')) {
- $core->addbehavior(
- 'zoneclearFeedServerAfterPostCreate',
- array('zoneclearFeedServer', 'tweakurlsAfterPostCreate')
- );
+ $core->addbehavior(
+ 'zoneclearFeedServerAfterPostCreate',
+ array('zoneclearFeedServer', 'tweakurlsAfterPostCreate')
+ );
}
# Register tempalte blocks
$tpl_blocks = array(
- 'Feeds',
- 'FeedsFooter',
- 'FeedsHeader',
- 'FeedIf'
+ 'Feeds',
+ 'FeedsFooter',
+ 'FeedsHeader',
+ 'FeedIf'
);
foreach($tpl_blocks as $v) {
- $core->tpl->addBlock('zc'.$v, array('zcfsTemplate', $v));
+ $core->tpl->addBlock('zc'.$v, array('zcfsTemplate', $v));
}
# Register tempalte values
$tpl_values = array(
- 'FeedsCount',
- 'FeedsEntriesCount',
- 'FeedEntriesCount',
- 'FeedCategory',
- 'FeedCategoryID',
- 'FeedCategoryURL',
- 'FeedCategoryShortURL',
- 'FeedID',
- 'FeedIfFirst',
- 'FeedIfOdd',
- 'FeedLang',
- 'FeedName',
- 'FeedOwner',
- 'FeedDesc',
- 'FeedSiteURL',
- 'FeedFeedURL'
+ 'FeedsCount',
+ 'FeedsEntriesCount',
+ 'FeedEntriesCount',
+ 'FeedCategory',
+ 'FeedCategoryID',
+ 'FeedCategoryURL',
+ 'FeedCategoryShortURL',
+ 'FeedID',
+ 'FeedIfFirst',
+ 'FeedIfOdd',
+ 'FeedLang',
+ 'FeedName',
+ 'FeedOwner',
+ 'FeedDesc',
+ 'FeedSiteURL',
+ 'FeedFeedURL'
);
foreach($tpl_values as $v) {
- $core->tpl->addValue('zc'.$v, array('zcfsTemplate', $v));
+ $core->tpl->addValue('zc'.$v, array('zcfsTemplate', $v));
}
/**
@@ -100,87 +99,87 @@ foreach($tpl_values as $v) {
*/
class zcfsPublicBehaviors
{
- /**
- * Remember others post extension.
- *
- * @param record $rs record instance
- */
- public static function coreBlogGetPosts(record $rs)
- {
- $GLOBALS['beforeZcFeedRsExt'] = $rs->extensions();
- $rs->extend('zcfsRsExtPosts');
- }
+ /**
+ * Remember others post extension.
+ *
+ * @param record $rs record instance
+ */
+ public static function coreBlogGetPosts(record $rs)
+ {
+ $GLOBALS['beforeZcFeedRsExt'] = $rs->extensions();
+ $rs->extend('zcfsRsExtPosts');
+ }
- /**
- * Update feeds after contents.
- *
- * @param dcCore $core dcCore instance
- * @return string Document
- */
- public static function publicAfterDocument(dcCore $core)
- {
- # Limit feeds update to home page et feed page
- # Like publishScheduledEntries
- if (!in_array($core->url->type, array('default', 'feed'))) {
+ /**
+ * Update feeds after contents.
+ *
+ * @param dcCore $core dcCore instance
+ * @return string Document
+ */
+ public static function publicAfterDocument(dcCore $core)
+ {
+ # Limit feeds update to home page et feed page
+ # Like publishScheduledEntries
+ if (!in_array($core->url->type, array('default', 'feed'))) {
- return null;
- }
+ return null;
+ }
- self::publicDocument($core);
- }
+ self::publicDocument($core);
+ }
- /**
- * Generic behavior for before and after public content.
- *
- * @param dcCore $core dcCore instance
- * @return null NULL
- */
- public static function publicDocument(dcCore $core)
- {
- $zc = new zoneclearFeedServer($core);
- $zc->checkFeedsUpdate();
+ /**
+ * Generic behavior for before and after public content.
+ *
+ * @param dcCore $core dcCore instance
+ * @return null NULL
+ */
+ public static function publicDocument(dcCore $core)
+ {
+ $zc = new zoneclearFeedServer($core);
+ $zc->checkFeedsUpdate();
- return null;
- }
+ return null;
+ }
- /**
- * Update feeds by an Ajax request (background).
- *
- * @param dcCore $core dcCore instance
- * @param context $_ctx context instance
- * @return string HTML content
- */
- public static function publicHeadContent(dcCore $core, context $_ctx)
- {
- # Limit update to home page
- if ($core->url->type != 'default') {
+ /**
+ * Update feeds by an Ajax request (background).
+ *
+ * @param dcCore $core dcCore instance
+ * @param context $_ctx context instance
+ * @return string HTML content
+ */
+ public static function publicHeadContent(dcCore $core, context $_ctx)
+ {
+ # Limit update to home page
+ if ($core->url->type != 'default') {
- return null;
- }
+ return null;
+ }
- $blog_url = html::escapeJS(
- $core->blog->url.
- $core->url->getBase('zoneclearFeedsPage').
- '/zcfsupd'
- );
- $blog_id = html::escapeJS($core->blog->id);
+ $blog_url = html::escapeJS(
+ $core->blog->url.
+ $core->url->getBase('zoneclearFeedsPage').
+ '/zcfsupd'
+ );
+ $blog_id = html::escapeJS($core->blog->id);
- echo
- "\n \n".
- " \n".
- "\n";
- }
+ echo
+ "\n \n".
+ " \n".
+ "\n";
+ }
}
/**
@@ -190,134 +189,134 @@ class zcfsPublicBehaviors
*/
class zcfsRsExtPosts extends rsExtPost
{
- /**
- * Get feed meta.
- *
- * @param record $rs record instance
- * @param string $info Feed info key
- * @return string Feed info value
- */
- public static function zcFeed($rs, $info)
- {
- $p = array(
- 'post_id' => $rs->post_id,
- 'meta_type' => 'zoneclearfeed_'.$info,
- 'limit' => 1
- );
- $meta = $rs->core->meta->getMetadata($p);
+ /**
+ * Get feed meta.
+ *
+ * @param record $rs record instance
+ * @param string $info Feed info key
+ * @return string Feed info value
+ */
+ public static function zcFeed($rs, $info)
+ {
+ $p = array(
+ 'post_id' => $rs->post_id,
+ 'meta_type' => 'zoneclearfeed_'.$info,
+ 'limit' => 1
+ );
+ $meta = $rs->core->meta->getMetadata($p);
- return $meta->isEmpty() ? null : $meta->meta_id;
- }
+ return $meta->isEmpty() ? null : $meta->meta_id;
+ }
- /**
- * Call other rs extension.
- *
- * @param string $type Type of extension
- * @param array $args Arguments
- * @return mixed record extension ressource
- */
- public static function zcFeedBrother($type, $args)
- {
- if (!empty($GLOBALS['beforeZcFeedRsExt'][$type])) {
- $func = $GLOBALS['beforeZcFeedRsExt'][$type];
- }
- elseif (is_callable('rsExtPostPublic', $type)) {
- $func = array('rsExtPostPublic', $type);
- }
- else {
- $func = array('rsExtPost', $type);
- }
+ /**
+ * Call other rs extension.
+ *
+ * @param string $type Type of extension
+ * @param array $args Arguments
+ * @return mixed record extension ressource
+ */
+ public static function zcFeedBrother($type, $args)
+ {
+ if (!empty($GLOBALS['beforeZcFeedRsExt'][$type])) {
+ $func = $GLOBALS['beforeZcFeedRsExt'][$type];
+ }
+ elseif (is_callable('rsExtPostPublic', $type)) {
+ $func = array('rsExtPostPublic', $type);
+ }
+ else {
+ $func = array('rsExtPost', $type);
+ }
- return call_user_func_array($func, $args);
- }
+ return call_user_func_array($func, $args);
+ }
- /**
- * Get author link from post to feed.
- *
- * @param record $rs record instance
- * @return string Author link
- */
- public static function getAuthorLink($rs)
- {
- $author = $rs->zcFeed('author');
- $site = $rs->zcFeed('site');
- $sitename = $rs->zcFeed('sitename');
+ /**
+ * Get author link from post to feed.
+ *
+ * @param record $rs record instance
+ * @return string Author link
+ */
+ public static function getAuthorLink($rs)
+ {
+ $author = $rs->zcFeed('author');
+ $site = $rs->zcFeed('site');
+ $sitename = $rs->zcFeed('sitename');
- return ($author && $sitename) ?
- $author.' (
'.$sitename.')' :
- self::zcFeedBrother('getAuthorLink', array(&$rs));
- }
+ return ($author && $sitename) ?
+ $author.' (
'.$sitename.')' :
+ self::zcFeedBrother('getAuthorLink', array(&$rs));
+ }
- /**
- * Get author CN from post to feed.
- *
- * @param record $rs record instance
- * @return string Author CN
- */
- public static function getAuthorCN($rs)
- {
- $author = $rs->zcFeed('author');
- return $author ?
- $author :
- self::zcFeedBrother('getAuthorCN', array(&$rs));
- }
+ /**
+ * Get author CN from post to feed.
+ *
+ * @param record $rs record instance
+ * @return string Author CN
+ */
+ public static function getAuthorCN($rs)
+ {
+ $author = $rs->zcFeed('author');
+ return $author ?
+ $author :
+ self::zcFeedBrother('getAuthorCN', array(&$rs));
+ }
- /**
- * Get post link from post to feed.
- *
- * @param record $rs record instance
- * @return string Post link
- */
- public static function getURL($rs)
- {
- $url = $rs->zcFeed('url');
- $types = @unserialize($rs->core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_post_title_redir);
- $full = is_array($types) && in_array($rs->core->url->type, $types);
+ /**
+ * Get post link from post to feed.
+ *
+ * @param record $rs record instance
+ * @return string Post link
+ */
+ public static function getURL($rs)
+ {
+ $url = $rs->zcFeed('url');
+ $types = @unserialize($rs->core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_post_title_redir);
+ $full = is_array($types) && in_array($rs->core->url->type, $types);
- return $url && $full ?
- zoneclearFeedServer::absoluteURL($rs->zcFeed('site'), $url) :
- self::zcFeedBrother('getURL', array(&$rs));
- }
+ return $url && $full ?
+ zoneclearFeedServer::absoluteURL($rs->zcFeed('site'), $url) :
+ self::zcFeedBrother('getURL', array(&$rs));
+ }
- /**
- * Get post content from post to feed.
- *
- * @param record $rs record instance
- * @return string Post content
- */
- public static function getContent($rs, $absolute_urls=false)
- {
- $url = $rs->zcFeed('url');
- $sitename = $rs->zcFeed('sitename');
- $content = self::zcFeedBrother('getContent', array(&$rs,$absolute_urls));
+ /**
+ * Get post content from post to feed.
+ *
+ * @param record $rs record instance
+ * @return string Post content
+ */
+ public static function getContent($rs, $absolute_urls=false)
+ {
+ $url = $rs->zcFeed('url');
+ $sitename = $rs->zcFeed('sitename');
+ $content = self::zcFeedBrother('getContent', array(&$rs,$absolute_urls));
- if ($url && $sitename && $rs->post_type == 'post') {
- $types = @unserialize($rs->core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_post_full_tpl);
+ if ($url && $sitename && $rs->post_type == 'post') {
+ $types = @unserialize($rs->core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_post_full_tpl);
- if (is_array($types) && in_array($rs->core->url->type, $types)) {
+ if (is_array($types) && in_array($rs->core->url->type, $types)) {
- return $content .
- '
'.
- sprintf(__('Original post on %s'), $url, $sitename).
- '
';
- }
- else {
- $content = context::remove_html($content);
- $content = context::cut_string($content,350);
- $content = html::escapeHTML($content);
+ return $content .
+ '
'.
+ sprintf(__('Original post on %s'), $url, $sitename).
+ '
';
+ }
+ else {
+ $content = context::remove_html($content);
+ $content = context::cut_string($content,350);
+ $content = html::escapeHTML($content);
- return
- '
'.$content.'... '.
- ''.__('Continue reading').'
';
- }
- }
- else {
+ return
+ '
'.$content.'... '.
+ ''.__('Continue reading').'
';
+ }
+ }
+ else {
- return $content;
- }
- }
+ return $content;
+ }
+ }
}
/**
@@ -327,86 +326,86 @@ class zcfsRsExtPosts extends rsExtPost
*/
class zcfsUrlHandler extends dcUrlHandlers
{
- /**
- * Feeds source page and update methods.
- *
- * @param array $args Page arguments
- * @return mixed
- */
- public static function zcFeedsPage($args)
- {
- global $core, $_ctx;
- $s = $core->blog->settings->zoneclearFeedServer;
+ /**
+ * Feeds source page and update methods.
+ *
+ * @param array $args Page arguments
+ * @return mixed
+ */
+ public static function zcFeedsPage($args)
+ {
+ global $core, $_ctx;
+ $s = $core->blog->settings->zoneclearFeedServer;
- # Not active
- if (!$s->zoneclearFeedServer_active) {
- self::p404();
+ # Not active
+ if (!$s->zoneclearFeedServer_active) {
+ self::p404();
- return null;
- }
+ return null;
+ }
- # Update feeds (from ajax or other post resquest)
- if ($args == '/zcfsupd'
- && 3 == $s->zoneclearFeedServer_bhv_pub_upd
- ) {
- $msg = '';
- if (!empty($_POST['blogId'])
- && html::escapeJS($core->blog->id) == $_POST['blogId']
- ) {
- try {
- $zc = new zoneclearFeedServer($core);
- if ($zc->checkFeedsUpdate()) {
- $msg = '
ok'.
- 'Feeds updated successfully';
- }
- }
- catch (Exception $e) {}
- }
- if (empty($msg)) {
- $msg = '
failed'.
- 'Failed to update feeds';
- }
+ # Update feeds (from ajax or other post resquest)
+ if ($args == '/zcfsupd'
+ && 3 == $s->zoneclearFeedServer_bhv_pub_upd
+ ) {
+ $msg = '';
+ if (!empty($_POST['blogId'])
+ && html::escapeJS($core->blog->id) == $_POST['blogId']
+ ) {
+ try {
+ $zc = new zoneclearFeedServer($core);
+ if ($zc->checkFeedsUpdate()) {
+ $msg = '
ok'.
+ 'Feeds updated successfully';
+ }
+ }
+ catch (Exception $e) {}
+ }
+ if (empty($msg)) {
+ $msg = '
failed'.
+ 'Failed to update feeds';
+ }
- header('Content-Type: application/xml; charset=UTF-8');
- echo
- ''."\n".
- '
'."\n".
- $msg."\n".
- '';
+ header('Content-Type: application/xml; charset=UTF-8');
+ echo
+ ''."\n".
+ '
'."\n".
+ $msg."\n".
+ '';
- exit(1);
- }
- # Server js
- elseif ($args == '/zcfsupd.js'
- && 3 == $s->zoneclearFeedServer_bhv_pub_upd
- ) {
- $core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates');
- self::serveDocument(
- 'zcfsupd.js',
- 'text/javascript',
- false,
- false
- );
- }
- # Server feeds description page
- elseif (in_array($args, array('', '/'))
- && $s->zoneclearFeedServer_pub_active
- ) {
- $tplset = $core->themes->moduleInfo($core->blog->settings->system->theme,'tplset');
+ exit(1);
+ }
+ # Server js
+ elseif ($args == '/zcfsupd.js'
+ && 3 == $s->zoneclearFeedServer_bhv_pub_upd
+ ) {
+ $core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates');
+ self::serveDocument(
+ 'zcfsupd.js',
+ 'text/javascript',
+ false,
+ false
+ );
+ }
+ # Server feeds description page
+ elseif (in_array($args, array('', '/'))
+ && $s->zoneclearFeedServer_pub_active
+ ) {
+ $tplset = $core->themes->moduleInfo($core->blog->settings->system->theme,'tplset');
if (!empty($tplset) && is_dir(dirname(__FILE__).'/default-templates/'.$tplset)) {
$core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates/'.$tplset);
} else {
$core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates/'.DC_DEFAULT_TPLSET);
}
- self::serveDocument('zcfeeds.html');
- }
- # Unknow
- else {
- self::p404();
- }
+ self::serveDocument('zcfeeds.html');
+ }
+ # Unknow
+ else {
+ self::p404();
+ }
- return null;
- }
+ return null;
+ }
}
/**
@@ -416,321 +415,321 @@ class zcfsUrlHandler extends dcUrlHandlers
*/
class zcfsTemplate
{
- public static function Feeds($a, $c)
- {
- $lastn = -1;
- $p = '';
- if (isset($a['lastn'])) {
- $lastn = abs((integer) $a['lastn'])+0;
- $p .= "\$zcfs_params['limit'] = ".$lastn.";\n";
- }
- if (isset($a['cat_id'])) {
- $p .= "@\$zcfs_params['sql'] .= 'AND Z.cat_id = ".addslashes($a['cat_id'])." ';\n";
- }
- if (isset($a['no_category'])) {
- $p .= "@\$zcfs_params['sql'] .= 'AND Z.cat_id IS NULL ';\n";
- }
- if (!empty($a['site_url'])) {
- $p .= "\$zcfs_params['feed_url'] = '".addslashes($a['site_url'])."';\n";
- }
- if (isset($a['feed_status'])) {
- $p .= "\$zcfs_params['feed_status'] = ".((integer) $a['feed_status']).";\n";
- }
- else {
- $p .= "\$zcfs_params['feed_status'] = 1;\n";
- }
- if (!empty($a['feed_url'])) {
- $p .= "\$zcfs_params['feed_feed'] = '".addslashes($a['feed_url'])."';\n";
- }
- if (isset($a['feed_owner'])) {
- $p .= "@\$zcfs_params['sql'] .= \"AND Z.feed_owner = '".addslashes($a['author'])."' \";\n";
- }
+ public static function Feeds($a, $c)
+ {
+ $lastn = -1;
+ $p = '';
+ if (isset($a['lastn'])) {
+ $lastn = abs((integer) $a['lastn'])+0;
+ $p .= "\$zcfs_params['limit'] = ".$lastn.";\n";
+ }
+ if (isset($a['cat_id'])) {
+ $p .= "@\$zcfs_params['sql'] .= 'AND Z.cat_id = ".addslashes($a['cat_id'])." ';\n";
+ }
+ if (isset($a['no_category'])) {
+ $p .= "@\$zcfs_params['sql'] .= 'AND Z.cat_id IS NULL ';\n";
+ }
+ if (!empty($a['site_url'])) {
+ $p .= "\$zcfs_params['feed_url'] = '".addslashes($a['site_url'])."';\n";
+ }
+ if (isset($a['feed_status'])) {
+ $p .= "\$zcfs_params['feed_status'] = ".((integer) $a['feed_status']).";\n";
+ }
+ else {
+ $p .= "\$zcfs_params['feed_status'] = 1;\n";
+ }
+ if (!empty($a['feed_url'])) {
+ $p .= "\$zcfs_params['feed_feed'] = '".addslashes($a['feed_url'])."';\n";
+ }
+ if (isset($a['feed_owner'])) {
+ $p .= "@\$zcfs_params['sql'] .= \"AND Z.feed_owner = '".addslashes($a['author'])."' \";\n";
+ }
- $sortby = 'feed_creadt';
- $order = 'desc';
- if (isset($a['sortby'])) {
- switch ($a['sortby']) {
- case 'name': $sortby = 'lowername'; break;
- case 'owner' : $sortby = 'feed_owner'; break;
- case 'date' : $sortby = 'feed_dt'; break;
- case 'update' : $sortby = 'feed_upddt'; break;
- case 'id' : $sortby = 'feed_id'; break;
- }
- }
- if (isset($a['order'])
- && preg_match('/^(desc|asc)$/i', $a['order'])
- ) {
- $order = $a['order'];
- }
- $p .= "\$zcfs_params['order'] = '".$sortby." ".$order."';\n";
+ $sortby = 'feed_creadt';
+ $order = 'desc';
+ if (isset($a['sortby'])) {
+ switch ($a['sortby']) {
+ case 'name': $sortby = 'lowername'; break;
+ case 'owner' : $sortby = 'feed_owner'; break;
+ case 'date' : $sortby = 'feed_dt'; break;
+ case 'update' : $sortby = 'feed_upddt'; break;
+ case 'id' : $sortby = 'feed_id'; break;
+ }
+ }
+ if (isset($a['order'])
+ && preg_match('/^(desc|asc)$/i', $a['order'])
+ ) {
+ $order = $a['order'];
+ }
+ $p .= "\$zcfs_params['order'] = '".$sortby." ".$order."';\n";
- return
- 'feeds_params = $zcfs_params;'."\n".
- '$zcfs = new zoneclearFeedServer($core);'."\n".
- '$_ctx->feeds = $zcfs->getFeeds($zcfs_params); unset($zcfs_params,$zcfs);'."\n".
- "?>\n".
- 'feeds->fetch()) : ?>'.$c.'feeds = null; $_ctx->feeds_params = null; ?>';
- }
+ return
+ 'feeds_params = $zcfs_params;'."\n".
+ '$zcfs = new zoneclearFeedServer($core);'."\n".
+ '$_ctx->feeds = $zcfs->getFeeds($zcfs_params); unset($zcfs_params,$zcfs);'."\n".
+ "?>\n".
+ 'feeds->fetch()) : ?>'.$c.'feeds = null; $_ctx->feeds_params = null; ?>';
+ }
- public static function FeedIf($a,$c)
- {
- $if = array();
+ public static function FeedIf($a,$c)
+ {
+ $if = array();
- $operator = isset($a['operator']) ? self::getOperator($a['operator']) : '&&';
+ $operator = isset($a['operator']) ? self::getOperator($a['operator']) : '&&';
- if (isset($a['type'])) {
- $type = trim($a['type']);
- $type = !empty($type) ? $type : 'feed';
- $if[] = '$_ctx->feeds->feed_type == "'.addslashes($type).'"';
- }
- if (isset($a['site_url'])) {
- $url = trim($a['feed_url']);
- if (substr($url, 0, 1) == '!') {
- $url = substr($url, 1);
- $if[] = '$_ctx->feeds->feed_url != "'.addslashes($url).'"';
- }
- else {
- $if[] = '$_ctx->feeds->feed_url == "'.addslashes($url).'"';
- }
- }
- if (isset($a['feed_url'])) {
- $url = trim($a['feed_feed']);
- if (substr($url, 0, 1) == '!') {
- $url = substr($url, 1);
- $if[] = '$_ctx->feeds->feed_feed != "'.addslashes($url).'"';
- }
- else {
- $if[] = '$_ctx->feeds->feed_feed == "'.addslashes($url).'"';
- }
- }
- if (isset($a['category'])) {
- $category = addslashes(trim($a['category']));
- if (substr($category, 0, 1) == '!') {
- $category = substr($category, 1);
- $if[] = '($_ctx->feeds->cat_url != "'.$category.'")';
- }
- else {
- $if[] = '($_ctx->feeds->cat_url == "'.$category.'")';
- }
- }
- if (isset($a['first'])) {
- $sign = (boolean) $a['first'] ? '=' : '!';
- $if[] = '$_ctx->feeds->index() '.$sign.'= 0';
- }
- if (isset($a['odd'])) {
- $sign = (boolean) $a['odd'] ? '=' : '!';
- $if[] = '($_ctx->feeds->index()+1)%2 '.$sign.'= 1';
- }
- if (isset($a['has_category'])) {
- $sign = (boolean) $a['has_category'] ? '' : '!';
- $if[] = $sign.'$_ctx->feeds->cat_id';
- }
- if (isset($a['has_description'])) {
- $sign = (boolean) $a['has_description'] ? '' : '!';
- $if[] = $sign.'$_ctx->feeds->feed_desc';
- }
+ if (isset($a['type'])) {
+ $type = trim($a['type']);
+ $type = !empty($type) ? $type : 'feed';
+ $if[] = '$_ctx->feeds->feed_type == "'.addslashes($type).'"';
+ }
+ if (isset($a['site_url'])) {
+ $url = trim($a['feed_url']);
+ if (substr($url, 0, 1) == '!') {
+ $url = substr($url, 1);
+ $if[] = '$_ctx->feeds->feed_url != "'.addslashes($url).'"';
+ }
+ else {
+ $if[] = '$_ctx->feeds->feed_url == "'.addslashes($url).'"';
+ }
+ }
+ if (isset($a['feed_url'])) {
+ $url = trim($a['feed_feed']);
+ if (substr($url, 0, 1) == '!') {
+ $url = substr($url, 1);
+ $if[] = '$_ctx->feeds->feed_feed != "'.addslashes($url).'"';
+ }
+ else {
+ $if[] = '$_ctx->feeds->feed_feed == "'.addslashes($url).'"';
+ }
+ }
+ if (isset($a['category'])) {
+ $category = addslashes(trim($a['category']));
+ if (substr($category, 0, 1) == '!') {
+ $category = substr($category, 1);
+ $if[] = '($_ctx->feeds->cat_url != "'.$category.'")';
+ }
+ else {
+ $if[] = '($_ctx->feeds->cat_url == "'.$category.'")';
+ }
+ }
+ if (isset($a['first'])) {
+ $sign = (boolean) $a['first'] ? '=' : '!';
+ $if[] = '$_ctx->feeds->index() '.$sign.'= 0';
+ }
+ if (isset($a['odd'])) {
+ $sign = (boolean) $a['odd'] ? '=' : '!';
+ $if[] = '($_ctx->feeds->index()+1)%2 '.$sign.'= 1';
+ }
+ if (isset($a['has_category'])) {
+ $sign = (boolean) $a['has_category'] ? '' : '!';
+ $if[] = $sign.'$_ctx->feeds->cat_id';
+ }
+ if (isset($a['has_description'])) {
+ $sign = (boolean) $a['has_description'] ? '' : '!';
+ $if[] = $sign.'$_ctx->feeds->feed_desc';
+ }
- return empty($if) ?
- $c :
- ''.$c.'';
- }
+ return empty($if) ?
+ $c :
+ ''.$c.'';
+ }
- public static function FeedIfFirst($a)
- {
- $ret = isset($a['return']) ? $a['return'] : 'first';
- $ret = html::escapeHTML($ret);
+ public static function FeedIfFirst($a)
+ {
+ $ret = isset($a['return']) ? $a['return'] : 'first';
+ $ret = html::escapeHTML($ret);
- return
- 'feeds->index() == 0) { '.
- "echo '".addslashes($ret)."'; } ?>";
- }
+ return
+ 'feeds->index() == 0) { '.
+ "echo '".addslashes($ret)."'; } ?>";
+ }
- public static function FeedIfOdd($a)
- {
- $ret = isset($a['return']) ? $a['return'] : 'odd';
- $ret = html::escapeHTML($ret);
+ public static function FeedIfOdd($a)
+ {
+ $ret = isset($a['return']) ? $a['return'] : 'odd';
+ $ret = html::escapeHTML($ret);
- return
- 'feeds->index()+1)%2 == 1) { '.
- "echo '".addslashes($ret)."'; } ?>";
- }
+ return
+ 'feeds->index()+1)%2 == 1) { '.
+ "echo '".addslashes($ret)."'; } ?>";
+ }
- public static function FeedDesc($a)
- {
- return self::getValue($a, '$_ctx->feeds->feed_desc');
- }
+ public static function FeedDesc($a)
+ {
+ return self::getValue($a, '$_ctx->feeds->feed_desc');
+ }
- public static function FeedOwner($a)
- {
- return self::getValue($a, '$_ctx->feeds->feed_owner');
- }
+ public static function FeedOwner($a)
+ {
+ return self::getValue($a, '$_ctx->feeds->feed_owner');
+ }
- public static function FeedCategory($a)
- {
- return self::getValue($a, '$_ctx->feeds->cat_title');
- }
+ public static function FeedCategory($a)
+ {
+ return self::getValue($a, '$_ctx->feeds->cat_title');
+ }
- public static function FeedCategoryID($a)
- {
- return self::getValue($a, '$_ctx->feeds->cat_id');
- }
+ public static function FeedCategoryID($a)
+ {
+ return self::getValue($a, '$_ctx->feeds->cat_id');
+ }
- public static function FeedCategoryURL($a)
- {
- return self::getValue($a, '$core->blog->url.$core->url->getBase(\'category\').\'/\'.html::sanitizeURL($_ctx->feeds->cat_url)');
- }
+ public static function FeedCategoryURL($a)
+ {
+ return self::getValue($a, '$core->blog->url.$core->url->getBase(\'category\').\'/\'.html::sanitizeURL($_ctx->feeds->cat_url)');
+ }
- public static function FeedCategoryShortURL($a)
- {
- return self::getValue($a, '$_ctx->feeds->cat_url');
- }
+ public static function FeedCategoryShortURL($a)
+ {
+ return self::getValue($a, '$_ctx->feeds->cat_url');
+ }
- public static function FeedID($a)
- {
- return self::getValue($a, '$_ctx->feeds->feed_id');
- }
+ public static function FeedID($a)
+ {
+ return self::getValue($a, '$_ctx->feeds->feed_id');
+ }
- public static function FeedLang($a)
- {
- $f = $GLOBALS['core']->tpl->getFilters($a);
+ public static function FeedLang($a)
+ {
+ $f = $GLOBALS['core']->tpl->getFilters($a);
- return empty($a['full']) ?
- 'feeds->feed_lang').'; ?>'
- :
- 'feeds->feed_lang])) { echo '.sprintf($f, '$langs[$_ctx->feeds->feed_lang]').'; } else { echo '.sprintf($f, '$_ctx->feeds->feed_lang').'; } unset($langs); ?>';
- }
+ return empty($a['full']) ?
+ 'feeds->feed_lang').'; ?>'
+ :
+ 'feeds->feed_lang])) { echo '.sprintf($f, '$langs[$_ctx->feeds->feed_lang]').'; } else { echo '.sprintf($f, '$_ctx->feeds->feed_lang').'; } unset($langs); ?>';
+ }
- public static function FeedName($a)
- {
- return self::getValue($a, '$_ctx->feeds->feed_name');
- }
+ public static function FeedName($a)
+ {
+ return self::getValue($a, '$_ctx->feeds->feed_name');
+ }
- public static function FeedSiteURL($a)
- {
- return self::getValue($a, '$_ctx->feeds->feed_url');
- }
+ public static function FeedSiteURL($a)
+ {
+ return self::getValue($a, '$_ctx->feeds->feed_url');
+ }
- public static function FeedFeedURL($a)
- {
- return self::getValue($a, '$_ctx->feeds->feed_feed');
- }
+ public static function FeedFeedURL($a)
+ {
+ return self::getValue($a, '$_ctx->feeds->feed_feed');
+ }
- public static function FeedsHeader($a, $c)
- {
- return "feeds->isStart()) : ?>".$c."";
- }
+ public static function FeedsHeader($a, $c)
+ {
+ return "feeds->isStart()) : ?>".$c."";
+ }
- public static function FeedsFooter($a, $c)
- {
- return "feeds->isEnd()) : ?>".$c."";
- }
+ public static function FeedsFooter($a, $c)
+ {
+ return "feeds->isEnd()) : ?>".$c."";
+ }
- public static function FeedsCount($a)
- {
- $none = 'no sources';
- $one = 'one source';
- $more = '%d sources';
+ public static function FeedsCount($a)
+ {
+ $none = 'no sources';
+ $one = 'one source';
+ $more = '%d sources';
- if (isset($a['none'])) {
- $none = addslashes($a['none']);
- }
- if (isset($a['one'])) {
- $one = addslashes($a['one']);
- }
- if (isset($a['more'])) {
- $more = addslashes($a['more']);
- }
+ if (isset($a['none'])) {
+ $none = addslashes($a['none']);
+ }
+ if (isset($a['one'])) {
+ $one = addslashes($a['one']);
+ }
+ if (isset($a['more'])) {
+ $more = addslashes($a['more']);
+ }
- return
- "feeds->count(); \n".
- "if (\$fcount == 0) {\n".
- " printf(__('".$none."'),\$fcount);\n".
- "} elseif (\$fcount == 1) {\n".
- " printf(__('".$one."'),\$fcount);\n".
- "} else {\n".
- " printf(__('".$more."'),\$fcount);\n".
- "} unset(\$fcount); ?>";
- }
+ return
+ "feeds->count(); \n".
+ "if (\$fcount == 0) {\n".
+ " printf(__('".$none."'),\$fcount);\n".
+ "} elseif (\$fcount == 1) {\n".
+ " printf(__('".$one."'),\$fcount);\n".
+ "} else {\n".
+ " printf(__('".$more."'),\$fcount);\n".
+ "} unset(\$fcount); ?>";
+ }
- public static function FeedsEntriesCount($a)
- {
- $none = __('no entries');
- $one = __('one entry');
- $more = __('%d entries');
+ public static function FeedsEntriesCount($a)
+ {
+ $none = __('no entries');
+ $one = __('one entry');
+ $more = __('%d entries');
- if (isset($a['none'])) {
- $none = addslashes($a['none']);
- }
- if (isset($a['one'])) {
- $one = addslashes($a['one']);
- }
- if (isset($a['more'])) {
- $more = addslashes($a['more']);
- }
+ if (isset($a['none'])) {
+ $none = addslashes($a['none']);
+ }
+ if (isset($a['one'])) {
+ $one = addslashes($a['one']);
+ }
+ if (isset($a['more'])) {
+ $more = addslashes($a['more']);
+ }
- return
- "feeds->zc->getFeeds(); \n".
- "if (!\$allfeeds->isEmpty()) { \n".
- " while (\$allfeeds->fetch()) { ".
- " \$fcount += (integer) \$_ctx->feeds->zc->getPostsByFeed(array('feed_id'=>\$allfeeds->feed_id),true)->f(0); ".
- " } \n".
- "} \n".
- "if (\$fcount == 0) {\n".
- " printf(__('".$none."'),\$fcount);\n".
- "} elseif (\$fcount == 1) {\n".
- " printf(__('".$one."'),\$fcount);\n".
- "} else {\n".
- " printf(__('".$more."'),\$fcount);\n".
- "} unset(\$allfeeds,\$fcount); ?>";
- }
+ return
+ "feeds->zc->getFeeds(); \n".
+ "if (!\$allfeeds->isEmpty()) { \n".
+ " while (\$allfeeds->fetch()) { ".
+ " \$fcount += (integer) \$_ctx->feeds->zc->getPostsByFeed(array('feed_id'=>\$allfeeds->feed_id),true)->f(0); ".
+ " } \n".
+ "} \n".
+ "if (\$fcount == 0) {\n".
+ " printf(__('".$none."'),\$fcount);\n".
+ "} elseif (\$fcount == 1) {\n".
+ " printf(__('".$one."'),\$fcount);\n".
+ "} else {\n".
+ " printf(__('".$more."'),\$fcount);\n".
+ "} unset(\$allfeeds,\$fcount); ?>";
+ }
- public static function FeedEntriesCount($a)
- {
- $none = 'no entries';
- $one = 'one entry';
- $more = '%d entries';
+ public static function FeedEntriesCount($a)
+ {
+ $none = 'no entries';
+ $one = 'one entry';
+ $more = '%d entries';
- if (isset($a['none'])) {
- $none = addslashes($a['none']);
- }
- if (isset($a['one'])) {
- $one = addslashes($a['one']);
- }
- if (isset($a['more'])) {
- $more = addslashes($a['more']);
- }
+ if (isset($a['none'])) {
+ $none = addslashes($a['none']);
+ }
+ if (isset($a['one'])) {
+ $one = addslashes($a['one']);
+ }
+ if (isset($a['more'])) {
+ $more = addslashes($a['more']);
+ }
- return
- "feeds->zc->getPostsByFeed(array('feed_id'=>\$_ctx->feeds->feed_id),true)->f(0); \n".
- "if (\$fcount == 0) {\n".
- " printf(__('".$none."'),\$fcount);\n".
- "} elseif (\$fcount == 1) {\n".
- " printf(__('".$one."'),\$fcount);\n".
- "} else {\n".
- " printf(__('".$more."'),\$fcount);\n".
- "} unset(\$fcount); ?>";
- }
+ return
+ "feeds->zc->getPostsByFeed(array('feed_id'=>\$_ctx->feeds->feed_id),true)->f(0); \n".
+ "if (\$fcount == 0) {\n".
+ " printf(__('".$none."'),\$fcount);\n".
+ "} elseif (\$fcount == 1) {\n".
+ " printf(__('".$one."'),\$fcount);\n".
+ "} else {\n".
+ " printf(__('".$more."'),\$fcount);\n".
+ "} unset(\$fcount); ?>";
+ }
- protected static function getValue($a,$v)
- {
- return 'tpl->getFilters($a), $v).'; ?>';
- }
+ protected static function getValue($a,$v)
+ {
+ return 'tpl->getFilters($a), $v).'; ?>';
+ }
- protected static function getOperator($op)
- {
- switch (strtolower($op))
- {
- case 'or':
- case '||':
- return '||';
- case 'and':
- case '&&':
- default:
- return '&&';
- }
- }
+ protected static function getOperator($op)
+ {
+ switch (strtolower($op))
+ {
+ case 'or':
+ case '||':
+ return '||';
+ case 'and':
+ case '&&':
+ default:
+ return '&&';
+ }
+ }
}
$core->addBehavior('publicBreadcrumb',array('extZcfeeds','publicBreadcrumb'));
diff --git a/_uninstall.php b/_uninstall.php
index ccab7b1..6446888 100644
--- a/_uninstall.php
+++ b/_uninstall.php
@@ -1,83 +1,82 @@
addUserAction(
- /* type */ 'settings',
- /* action */ 'delete_all',
- /* ns */ $mod_id,
- /* desc */ __('delete all settings')
+ /* type */ 'settings',
+ /* action */ 'delete_all',
+ /* ns */ $mod_id,
+ /* desc */ __('delete all settings')
);
$this->addUserAction(
- /* type */ 'tables',
- /* action */ 'delete',
- /* ns */ 'zc_feed',
- /* desc */ __('delete table')
+ /* type */ 'tables',
+ /* action */ 'delete',
+ /* ns */ 'zc_feed',
+ /* desc */ __('delete table')
);
$this->addUserAction(
- /* type */ 'plugins',
- /* action */ 'delete',
- /* ns */ $mod_id,
- /* desc */ __('delete plugin files')
+ /* type */ 'plugins',
+ /* action */ 'delete',
+ /* ns */ $mod_id,
+ /* desc */ __('delete plugin files')
);
$this->addUserAction(
- /* type */ 'versions',
- /* action */ 'delete',
- /* ns */ $mod_id,
- /* desc */ __('delete the version number')
+ /* type */ 'versions',
+ /* action */ 'delete',
+ /* ns */ $mod_id,
+ /* desc */ __('delete the version number')
);
-
$this->addDirectAction(
- /* type */ 'settings',
- /* action */ 'delete_all',
- /* ns */ $mod_id,
- /* desc */ sprintf(__('delete all %s settings'), $mod_id)
+ /* type */ 'settings',
+ /* action */ 'delete_all',
+ /* ns */ $mod_id,
+ /* desc */ sprintf(__('delete all %s settings'), $mod_id)
);
$this->addDirectAction(
- /* type */ 'tables',
- /* action */ 'delete',
- /* ns */ 'zc_feed',
- /* desc */ sprintf(__('delete %s table'), $mod_id)
+ /* type */ 'tables',
+ /* action */ 'delete',
+ /* ns */ 'zc_feed',
+ /* desc */ sprintf(__('delete %s table'), $mod_id)
);
$this->addDirectAction(
- /* type */ 'plugins',
- /* action */ 'delete',
- /* ns */ $mod_id,
- /* desc */ sprintf(__('delete %s plugin files'), $mod_id)
+ /* type */ 'plugins',
+ /* action */ 'delete',
+ /* ns */ $mod_id,
+ /* desc */ sprintf(__('delete %s plugin files'), $mod_id)
);
$this->addDirectAction(
- /* type */ 'versions',
- /* action */ 'delete',
- /* ns */ $mod_id,
- /* desc */ sprintf(__('delete %s version number'), $mod_id)
+ /* type */ 'versions',
+ /* action */ 'delete',
+ /* ns */ $mod_id,
+ /* desc */ sprintf(__('delete %s version number'), $mod_id)
);
$this->addDirectCallback(
- /* function */ 'zoneclearfeedServerUninstall',
- /* desc */ 'delete feeds relations'
+ /* function */ 'zoneclearfeedServerUninstall',
+ /* desc */ 'delete feeds relations'
);
function zoneclearfeedServerUninstall($core, $id)
{
- if ($id != 'zoneclearFeedServer') {
+ if ($id != 'zoneclearFeedServer') {
- return null;
- }
- //...
+ return null;
+ }
+ //...
}
\ No newline at end of file
diff --git a/_widgets.php b/_widgets.php
index 414cf17..72c1dc6 100644
--- a/_widgets.php
+++ b/_widgets.php
@@ -1,28 +1,28 @@
addBehavior(
- 'initWidgets',
- array('zoneclearFeedServerWidget', 'adminSource')
+ 'initWidgets',
+ array('zoneclearFeedServerWidget', 'adminSource')
);
$core->addBehavior(
- 'initWidgets',
- array('zoneclearFeedServerWidget', 'adminNumber')
+ 'initWidgets',
+ array('zoneclearFeedServerWidget', 'adminNumber')
);
/**
@@ -32,282 +32,282 @@ $core->addBehavior(
*/
class zoneclearFeedServerWidget
{
- /**
- * Widget configuration for sources list.
- *
- * @param dcWidget $w dcWidget instance
- */
- public static function adminSource($w)
- {
- $w->create(
- 'zcfssource',
- __('Feeds server: sources'),
- array('zoneclearFeedServerWidget', 'publicSource'),
- null,
- __('List sources of feeds')
- );
- $w->zcfssource->setting(
- 'title',
- __('Title:'),
- __('Feeds sources'),
- 'text'
- );
- $w->zcfssource->setting(
- 'sortby',
- __('Order by:'),
- 'feed_upd_last',
- 'combo',
- array(
- __('Last update') => 'feed_upd_last',
- __('Name') => 'lowername',
- __('Create date') => 'feed_creadt'
- )
- );
- $w->zcfssource->setting(
- 'sort',
- __('Sort:'),
- 'desc',
- 'combo',
- array(
- __('Ascending') => 'asc',
- __('Descending') => 'desc'
- )
- );
- $w->zcfssource->setting(
- 'limit',
- __('Limit:'),
- 10,
- 'text'
- );
- $w->zcfssource->setting('pagelink',__('Link to the list of sources:'),__('All sources'));
- $w->zcfssource->setting(
- 'homeonly',
- __('Display on:'),
- 0,
- 'combo',
- array(
- __('All pages') => 0,
- __('Home page only') => 1,
- __('Except on home page') => 2
- )
- );
- $w->zcfssource->setting('content_only',__('Content only'),0,'check');
- $w->zcfssource->setting('class',__('CSS class:'),'');
- $w->zcfssource->setting('offline',__('Offline'),0,'check');
- }
+ /**
+ * Widget configuration for sources list.
+ *
+ * @param dcWidget $w dcWidget instance
+ */
+ public static function adminSource($w)
+ {
+ $w->create(
+ 'zcfssource',
+ __('Feeds server: sources'),
+ array('zoneclearFeedServerWidget', 'publicSource'),
+ null,
+ __('List sources of feeds')
+ );
+ $w->zcfssource->setting(
+ 'title',
+ __('Title:'),
+ __('Feeds sources'),
+ 'text'
+ );
+ $w->zcfssource->setting(
+ 'sortby',
+ __('Order by:'),
+ 'feed_upd_last',
+ 'combo',
+ array(
+ __('Last update') => 'feed_upd_last',
+ __('Name') => 'lowername',
+ __('Create date') => 'feed_creadt'
+ )
+ );
+ $w->zcfssource->setting(
+ 'sort',
+ __('Sort:'),
+ 'desc',
+ 'combo',
+ array(
+ __('Ascending') => 'asc',
+ __('Descending') => 'desc'
+ )
+ );
+ $w->zcfssource->setting(
+ 'limit',
+ __('Limit:'),
+ 10,
+ 'text'
+ );
+ $w->zcfssource->setting('pagelink',__('Link to the list of sources:'),__('All sources'));
+ $w->zcfssource->setting(
+ 'homeonly',
+ __('Display on:'),
+ 0,
+ 'combo',
+ array(
+ __('All pages') => 0,
+ __('Home page only') => 1,
+ __('Except on home page') => 2
+ )
+ );
+ $w->zcfssource->setting('content_only',__('Content only'),0,'check');
+ $w->zcfssource->setting('class',__('CSS class:'),'');
+ $w->zcfssource->setting('offline',__('Offline'),0,'check');
+ }
- /**
- * Widget configuration for feeds info.
- *
- * @param dcWidget $w dcWidget instance
- */
- public static function adminNumber($w)
- {
- $w->create(
- 'zcfsnumber',
- __('Feeds server: numbers'),
- array('zoneclearFeedServerWidget', 'publicNumber'),
- null,
- __('Show some numbers about feeds')
- );
- $w->zcfsnumber->setting(
- 'title',
- __('Title:')
- ,__('Feeds numbers'),
- 'text'
- );
+ /**
+ * Widget configuration for feeds info.
+ *
+ * @param dcWidget $w dcWidget instance
+ */
+ public static function adminNumber($w)
+ {
+ $w->create(
+ 'zcfsnumber',
+ __('Feeds server: numbers'),
+ array('zoneclearFeedServerWidget', 'publicNumber'),
+ null,
+ __('Show some numbers about feeds')
+ );
+ $w->zcfsnumber->setting(
+ 'title',
+ __('Title:')
+ ,__('Feeds numbers'),
+ 'text'
+ );
- # Feed
- $w->zcfsnumber->setting(
- 'feed_show',
- __('Show feeds count'),
- 1,
- 'check'
- );
- $w->zcfsnumber->setting(
- 'feed_title',
- __('Title for feeds count:'),
- __('Feeds:'),
- 'text'
- );
+ # Feed
+ $w->zcfsnumber->setting(
+ 'feed_show',
+ __('Show feeds count'),
+ 1,
+ 'check'
+ );
+ $w->zcfsnumber->setting(
+ 'feed_title',
+ __('Title for feeds count:'),
+ __('Feeds:'),
+ 'text'
+ );
- # Entry
- $w->zcfsnumber->setting(
- 'entry_show',
- __('Show entries count'),
- 1,
- 'check'
- );
- $w->zcfsnumber->setting(
- 'entry_title',
- __('Title for entries count:'),
- __('Entries:'),
- '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');
- }
+ # Entry
+ $w->zcfsnumber->setting(
+ 'entry_show',
+ __('Show entries count'),
+ 1,
+ 'check'
+ );
+ $w->zcfsnumber->setting(
+ 'entry_title',
+ __('Title for entries count:'),
+ __('Entries:'),
+ 'text'
+ );
- /**
- * Widget for sources list.
- *
- * @param dcWidget $w dcWidget instance
- */
- public static function publicSource($w)
- {
- global $core;
+ $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');
+ }
- if ($w->offline)
- return;
-
- if (!$core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active
- || $w->homeonly == 1 && $core->url->type != 'default'
- || $w->homeonly == 2 && $core->url->type == 'default'
- ) {
- return null;
- }
+ /**
+ * Widget for sources list.
+ *
+ * @param dcWidget $w dcWidget instance
+ */
+ public static function publicSource($w)
+ {
+ global $core;
- $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;
+ if ($w->offline)
+ return;
- $zc = new zoneclearFeedServer($core);
- $rs = $zc->getFeeds($p);
+ if (!$core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active
+ || $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 = '';
- $i = 1;
- while($rs->fetch()) {
- $res .=
- '
'.
- ''.$rs->feed_name.''.
- '';
- $i++;
- }
+ if ($rs->isEmpty()) {
- $res =
- ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
+ return null;
+ }
+
+ $res = '';
+ $i = 1;
+ while($rs->fetch()) {
+ $res .=
+ '
'.
+ ''.$rs->feed_name.''.
+ '';
+ $i++;
+ }
+
+ $res =
+ ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
'
';
- if ($w->pagelink) {
- $res .= '
'.
+ if ($w->pagelink) {
+ $res .= ''.
html::escapeHTML($w->pagelink).'
';
- }
+ }
- 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.
- *
- * @param dcWidget $w dcWidget instance
- */
- public static function publicNumber($w)
- {
- global $core;
+ /**
+ * Widget for feeds info.
+ *
+ * @param dcWidget $w dcWidget instance
+ */
+ public static function publicNumber($w)
+ {
+ global $core;
- if ($w->offline)
- return;
+ if ($w->offline)
+ return;
- if (!$core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active
- || $w->homeonly == 1 && $core->url->type != 'default'
- || $w->homeonly == 2 && $core->url->type == 'default'
- ) {
- return null;
- }
+ if (!$core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active
+ || $w->homeonly == 1 && $core->url->type != 'default'
+ || $w->homeonly == 2 && $core->url->type == 'default'
+ ) {
+ return null;
+ }
- $zc = new zoneclearFeedServer($core);
- $content = '';
+ $zc = new zoneclearFeedServer($core);
+ $content = '';
- # Feed
- if ($w->feed_show) {
- $title = ($w->feed_title ?
- ''.html::escapeHTML($w->feed_title).' ' : '');
+ # Feed
+ if ($w->feed_show) {
+ $title = ($w->feed_title ?
+ ''.html::escapeHTML($w->feed_title).' ' : '');
- $count = $zc->getFeeds(array(),true)->f(0);
+ $count = $zc->getFeeds(array(),true)->f(0);
- if ($count == 0) {
- $text = sprintf(__('no sources'),$count);
- }
- elseif ($count == 1) {
- $text = sprintf(__('one source'),$count);
- }
- else {
- $text = sprintf(__('%d sources'),$count);
- }
- if ($core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_pub_active) {
- $text = ''.$text.'';
- }
+ if ($count == 0) {
+ $text = sprintf(__('no sources'),$count);
+ }
+ elseif ($count == 1) {
+ $text = sprintf(__('one source'),$count);
+ }
+ else {
+ $text = sprintf(__('%d sources'),$count);
+ }
+ if ($core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_pub_active) {
+ $text = ''.$text.'';
+ }
- $content .= sprintf('%s%s',$title,$text);
- }
+ $content .= sprintf('%s%s',$title,$text);
+ }
- # Entry
- if ($w->entry_show) {
- $count = 0;
- $feeds = $zc->getFeeds();
+ # Entry
+ if ($w->entry_show) {
+ $count = 0;
+ $feeds = $zc->getFeeds();
- if (!$feeds->isEmpty()) {
- while ($feeds->fetch()) {
- $count += (integer) $zc->getPostsByFeed(array('feed_id' => $feeds->feed_id), true)->f(0);
- }
- }
- $title = ($w->entry_title ?
- ''.html::escapeHTML($w->entry_title).' ' : '');
+ if (!$feeds->isEmpty()) {
+ while ($feeds->fetch()) {
+ $count += (integer) $zc->getPostsByFeed(array('feed_id' => $feeds->feed_id), true)->f(0);
+ }
+ }
+ $title = ($w->entry_title ?
+ ''.html::escapeHTML($w->entry_title).' ' : '');
- if ($count == 0) {
- $text = sprintf(__('no entries'),$count);
- }
- elseif ($count == 1) {
- $text = sprintf(__('one entry'),$count);
- }
- else {
- $text = sprintf(__('%d entries'),$count);
- }
+ if ($count == 0) {
+ $text = sprintf(__('no entries'),$count);
+ }
+ elseif ($count == 1) {
+ $text = sprintf(__('one entry'),$count);
+ }
+ else {
+ $text = sprintf(__('%d entries'),$count);
+ }
- $content .= sprintf('%s%s',$title,$text);
- }
+ $content .= sprintf('%s%s',$title,$text);
+ }
- # Nothing to display
- if (!$content) {
+ # Nothing to display
+ if (!$content) {
- return null;
- }
+ return null;
+ }
- # Display
- $res =
- ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
+ # Display
+ $res =
+ ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
'';
- return $w->renderDiv($w->content_only,'zoneclear-number '.$w->class,'',$res);
- }
+ return $w->renderDiv($w->content_only,'zoneclear-number '.$w->class,'',$res);
+ }
}
\ No newline at end of file
diff --git a/cron-script.php b/cron-script.php
index dceeab3..c9df48e 100644
--- a/cron-script.php
+++ b/cron-script.php
@@ -1,17 +1,5 @@
#!/usr/bin/env php
setBlog(DC_BLOG_ID);
if ($core->blog->id == null) {
- fwrite(STDERR,"Blog is not defined\n");
- exit(1);
+ fwrite(STDERR,"Blog is not defined\n");
+ exit(1);
}
if (!isset($opts['u']) || !$core->auth->checkUser($opts['u'])) {
- fwrite(STDERR,"Unable to set user\n");
- exit(1);
+ fwrite(STDERR,"Unable to set user\n");
+ exit(1);
}
$core->plugins->loadModules(DC_PLUGINS_ROOT);
@@ -97,9 +85,9 @@ $core->plugins->loadModules(DC_PLUGINS_ROOT);
$core->blog->settings->addNamespace('zoneclearFeedServer');
try {
- $zc = new zoneclearFeedServer($core);
- $zc->checkFeedsUpdate();
+ $zc = new zoneclearFeedServer($core);
+ $zc->checkFeedsUpdate();
} catch (Exception $e) {
- fwrite(STDERR,$e->getMessage()."\n");
- exit(1);
+ fwrite(STDERR,$e->getMessage()."\n");
+ exit(1);
}
\ No newline at end of file
diff --git a/inc/class.zcfs.feedsactions.php b/inc/class.zcfs.feedsactions.php
index 49a71a8..06c54ae 100644
--- a/inc/class.zcfs.feedsactions.php
+++ b/inc/class.zcfs.feedsactions.php
@@ -1,93 +1,87 @@
zcfs = new zoneclearFeedServer($core);
+ public function __construct(dcCore $core, $uri, $redirect_args=array())
+ {
+ $this->zcfs = new zoneclearFeedServer($core);
- parent::__construct($core, $uri, $redirect_args);
- $this->redirect_fields = array(
- 'sortby', 'order', 'page', 'nb'
- );
- $this->field_entries = 'feeds';
- $this->caller_title = __('Feeds');
- $this->loadDefaults();
- }
+ parent::__construct($core, $uri, $redirect_args);
+ $this->redirect_fields = array(
+ 'sortby', 'order', 'page', 'nb'
+ );
+ $this->field_entries = 'feeds';
+ $this->caller_title = __('Feeds');
+ $this->loadDefaults();
+ }
- protected function loadDefaults()
- {
- zcfsDefaultFeedsActions::zcfsFeedsActionsPage($this->core, $this);
- $this->core->callBehavior('zcfsFeedsActionsPage', $this->core, $this);
- }
+ protected function loadDefaults()
+ {
+ zcfsDefaultFeedsActions::zcfsFeedsActionsPage($this->core, $this);
+ $this->core->callBehavior('zcfsFeedsActionsPage', $this->core, $this);
+ }
- public function beginPage($breadcrumb='', $head='')
- {
- echo
- ''.__('Feeds server').''.
- dcPage::jsLoad('js/_posts_actions.js').
- $head.
- ''.
- $breadcrumb.
- ''.
- __('Back to feeds list').'
';
- }
+ public function beginPage($breadcrumb='', $head='')
+ {
+ echo
+ ''.__('Feeds server').''.
+ dcPage::jsLoad('js/_posts_actions.js').
+ $head.
+ ''.
+ $breadcrumb.
+ ''.
+ __('Back to feeds list').'
';
+ }
- public function endPage()
- {
- echo
- '';
- }
+ public function endPage()
+ {
+ echo
+ '';
+ }
- public function error(Exception $e)
- {
- $this->core->error->add($e->getMessage());
- $this->beginPage(dcPage::breadcrumb(array(
- html::escapeHTML($this->core->blog->name) => '',
- $this->getCallerTitle() => $this->getRedirection(true),
- __('Feeds actions') => ''
- )));
- $this->endPage();
- }
+ public function error(Exception $e)
+ {
+ $this->core->error->add($e->getMessage());
+ $this->beginPage(dcPage::breadcrumb(array(
+ html::escapeHTML($this->core->blog->name) => '',
+ $this->getCallerTitle() => $this->getRedirection(true),
+ __('Feeds actions') => ''
+ )));
+ $this->endPage();
+ }
- protected function fetchEntries($from)
- {
- if (!empty($from['feeds'])) {
+ protected function fetchEntries($from)
+ {
+ if (!empty($from['feeds'])) {
- $params['feed_id'] = $from['feeds'];
+ $params['feed_id'] = $from['feeds'];
- $feeds = $this->zcfs->getFeeds($params);
- while ($feeds->fetch()) {
- $this->entries[$feeds->feed_id] = $feeds->feed_name;
- }
- $this->rs = $feeds;
- }
- else {
- $this->rs = $this->core->con->select(
- "SELECT blog_id FROM ".
- $this->core->prefix."blog WHERE false"
- );
- }
- }
+ $feeds = $this->zcfs->getFeeds($params);
+ while ($feeds->fetch()) {
+ $this->entries[$feeds->feed_id] = $feeds->feed_name;
+ }
+ $this->rs = $feeds;
+ }
+ else {
+ $this->rs = $this->core->con->select(
+ "SELECT blog_id FROM ".
+ $this->core->prefix."blog WHERE false"
+ );
+ }
+ }
}
/**
@@ -98,292 +92,292 @@ class zcfsFeedsActionsPage extends dcActionsPage
*/
class zcfsDefaultFeedsActions
{
- public static function zcfsFeedsActionsPage(dcCore $core, zcfsFeedsActionsPage $ap)
- {
- $ap->addAction(
- array(__('Change category') => 'changecat'),
- array('zcfsDefaultFeedsActions', 'doChangeCategory')
- );
- $ap->addAction(
- array(__('Change update interval') => 'changeint'),
- array('zcfsDefaultFeedsActions', 'doChangeInterval')
- );
- $ap->addAction(
- array(__('Disable feed update') => 'disablefeed'),
- array('zcfsDefaultFeedsActions', 'doEnableFeed')
- );
- $ap->addAction(
- array(__('Enable feed update') => 'enablefeed'),
- array('zcfsDefaultFeedsActions', 'doEnableFeed')
- );
- $ap->addAction(
- array(__('Reset last update') => 'resetupdlast'),
- array('zcfsDefaultFeedsActions', 'doResetUpdate')
- );
- $ap->addAction(
- array(__('Update (check) feed') => 'updatefeed'),
- array('zcfsDefaultFeedsActions', 'doUpdateFeed')
- );
- $ap->addAction(
- array(__('Delete related posts') => 'deletepost'),
- array('zcfsDefaultFeedsActions', 'doDeletePost')
- );
- $ap->addAction(
- array(__('Delete feed (without related posts)') => 'deletefeed'),
- array('zcfsDefaultFeedsActions', 'doDeleteFeed')
- );
- }
+ public static function zcfsFeedsActionsPage(dcCore $core, zcfsFeedsActionsPage $ap)
+ {
+ $ap->addAction(
+ array(__('Change category') => 'changecat'),
+ array('zcfsDefaultFeedsActions', 'doChangeCategory')
+ );
+ $ap->addAction(
+ array(__('Change update interval') => 'changeint'),
+ array('zcfsDefaultFeedsActions', 'doChangeInterval')
+ );
+ $ap->addAction(
+ array(__('Disable feed update') => 'disablefeed'),
+ array('zcfsDefaultFeedsActions', 'doEnableFeed')
+ );
+ $ap->addAction(
+ array(__('Enable feed update') => 'enablefeed'),
+ array('zcfsDefaultFeedsActions', 'doEnableFeed')
+ );
+ $ap->addAction(
+ array(__('Reset last update') => 'resetupdlast'),
+ array('zcfsDefaultFeedsActions', 'doResetUpdate')
+ );
+ $ap->addAction(
+ array(__('Update (check) feed') => 'updatefeed'),
+ array('zcfsDefaultFeedsActions', 'doUpdateFeed')
+ );
+ $ap->addAction(
+ array(__('Delete related posts') => 'deletepost'),
+ array('zcfsDefaultFeedsActions', 'doDeletePost')
+ );
+ $ap->addAction(
+ array(__('Delete feed (without related posts)') => 'deletefeed'),
+ array('zcfsDefaultFeedsActions', 'doDeleteFeed')
+ );
+ }
- public static function doEnableFeed(dcCore $core, zcfsFeedsActionsPage $ap, $post)
- {
- $enable = $ap->getAction() == 'enablefeed';
- $ids = $ap->getIDs();
+ public static function doEnableFeed(dcCore $core, zcfsFeedsActionsPage $ap, $post)
+ {
+ $enable = $ap->getAction() == 'enablefeed';
+ $ids = $ap->getIDs();
- if (empty($ids)) {
- throw new Exception(__('No feeds selected'));
- }
+ if (empty($ids)) {
+ throw new Exception(__('No feeds selected'));
+ }
- foreach($ids as $id) {
- $ap->zcfs->enableFeed($id, $enable);
- }
+ foreach($ids as $id) {
+ $ap->zcfs->enableFeed($id, $enable);
+ }
- dcPage::addSuccessNotice(sprintf(
- $enable ?
- __(
- '%d feed has been successfully enabled.',
- '%d feeds have been successfully enabled.',
- count($ids)
- )
- :
- __(
- '%d feed has been successfully disabled.',
- '%d feeds have been successfully disabled.',
- count($ids)
- )
- ,
- count($ids)
- ));
- $ap->redirect(true);
- }
+ dcPage::addSuccessNotice(sprintf(
+ $enable ?
+ __(
+ '%d feed has been successfully enabled.',
+ '%d feeds have been successfully enabled.',
+ count($ids)
+ )
+ :
+ __(
+ '%d feed has been successfully disabled.',
+ '%d feeds have been successfully disabled.',
+ count($ids)
+ )
+ ,
+ count($ids)
+ ));
+ $ap->redirect(true);
+ }
- public static function doDeletePost(dcCore $core, zcfsFeedsActionsPage $ap, $post)
- {
- $types = array(
- 'zoneclearfeed_url',
- 'zoneclearfeed_author',
- 'zoneclearfeed_site',
- 'zoneclearfeed_sitename',
- 'zoneclearfeed_id'
- );
+ public static function doDeletePost(dcCore $core, zcfsFeedsActionsPage $ap, $post)
+ {
+ $types = array(
+ 'zoneclearfeed_url',
+ 'zoneclearfeed_author',
+ 'zoneclearfeed_site',
+ 'zoneclearfeed_sitename',
+ 'zoneclearfeed_id'
+ );
- $ids = $ap->getIDs();
+ $ids = $ap->getIDs();
- if (empty($ids)) {
- throw new Exception(__('No feeds selected'));
- }
+ if (empty($ids)) {
+ throw new Exception(__('No feeds selected'));
+ }
- foreach($ids as $id) {
+ foreach($ids as $id) {
- $posts = $ap->zcfs->getPostsByFeed(array(
- 'feed_id' => $id
- ));
+ $posts = $ap->zcfs->getPostsByFeed(array(
+ 'feed_id' => $id
+ ));
- while($posts->fetch()) {
+ while($posts->fetch()) {
- $core->blog->delPost($posts->post_id);
- $core->con->execute(
- 'DELETE FROM '.$core->prefix.'meta '.
- 'WHERE post_id = '.$posts->post_id.' '.
- 'AND meta_type '.$core->con->in($types).' '
- );
- }
- }
+ $core->blog->delPost($posts->post_id);
+ $core->con->execute(
+ 'DELETE FROM '.$core->prefix.'meta '.
+ 'WHERE post_id = '.$posts->post_id.' '.
+ 'AND meta_type '.$core->con->in($types).' '
+ );
+ }
+ }
- dcPage::addSuccessNotice(
- __('Entries have been successfully deleted.')
- );
- $ap->redirect(true);
- }
+ dcPage::addSuccessNotice(
+ __('Entries have been successfully deleted.')
+ );
+ $ap->redirect(true);
+ }
- public static function doDeleteFeed(dcCore $core, zcfsFeedsActionsPage $ap, $post)
- {
- $ids = $ap->getIDs();
+ public static function doDeleteFeed(dcCore $core, zcfsFeedsActionsPage $ap, $post)
+ {
+ $ids = $ap->getIDs();
- if (empty($ids)) {
- throw new Exception(__('No feeds selected'));
- }
+ if (empty($ids)) {
+ throw new Exception(__('No feeds selected'));
+ }
- foreach($ids as $id) {
- $ap->zcfs->delFeed($id);
- }
+ foreach($ids as $id) {
+ $ap->zcfs->delFeed($id);
+ }
- dcPage::addSuccessNotice(sprintf(
- __(
- '%d feed has been successfully deleted.',
- '%d feeds have been successfully deleted.',
- count($ids)
- ),
- count($ids)
- ));
- $ap->redirect(true);
- }
+ dcPage::addSuccessNotice(sprintf(
+ __(
+ '%d feed has been successfully deleted.',
+ '%d feeds have been successfully deleted.',
+ count($ids)
+ ),
+ count($ids)
+ ));
+ $ap->redirect(true);
+ }
- public static function doUpdateFeed(dcCore $core, zcfsFeedsActionsPage $ap, $post)
- {
- $ids = $ap->getIDs();
+ public static function doUpdateFeed(dcCore $core, zcfsFeedsActionsPage $ap, $post)
+ {
+ $ids = $ap->getIDs();
- if (empty($ids)) {
- throw new Exception(__('No feeds selected'));
- }
+ if (empty($ids)) {
+ throw new Exception(__('No feeds selected'));
+ }
- foreach($ids as $id) {
- $ap->zcfs->checkFeedsUpdate($id, true);
- }
+ foreach($ids as $id) {
+ $ap->zcfs->checkFeedsUpdate($id, true);
+ }
- dcPage::addSuccessNotice(sprintf(
- __(
- '%d feed has been successfully updated.',
- '%d feeds have been successfully updated.',
- count($ids)
- ),
- count($ids)
- ));
- $ap->redirect(true);
- }
+ dcPage::addSuccessNotice(sprintf(
+ __(
+ '%d feed has been successfully updated.',
+ '%d feeds have been successfully updated.',
+ count($ids)
+ ),
+ count($ids)
+ ));
+ $ap->redirect(true);
+ }
- public static function doResetUpdate(dcCore $core, zcfsFeedsActionsPage $ap, $post)
- {
- $ids = $ap->getIDs();
+ public static function doResetUpdate(dcCore $core, zcfsFeedsActionsPage $ap, $post)
+ {
+ $ids = $ap->getIDs();
- if (empty($ids)) {
- throw new Exception(__('No feeds selected'));
- }
+ if (empty($ids)) {
+ throw new Exception(__('No feeds selected'));
+ }
- foreach($ids as $id) {
- $cur = $ap->zcfs->openCursor();
- $cur->feed_upd_last = 0;
- $ap->zcfs->updFeed($id, $cur);
- $ap->zcfs->checkFeedsUpdate($id, true);
- }
+ foreach($ids as $id) {
+ $cur = $ap->zcfs->openCursor();
+ $cur->feed_upd_last = 0;
+ $ap->zcfs->updFeed($id, $cur);
+ $ap->zcfs->checkFeedsUpdate($id, true);
+ }
- dcPage::addSuccessNotice(sprintf(
- __(
- 'Last update of %s feed successfully reseted.',
- 'Last update of %s feeds successfully reseted.',
- count($ids)
- ),
- count($ids)
- ));
- $ap->redirect(true);
- }
+ dcPage::addSuccessNotice(sprintf(
+ __(
+ 'Last update of %s feed successfully reseted.',
+ 'Last update of %s feeds successfully reseted.',
+ count($ids)
+ ),
+ count($ids)
+ ));
+ $ap->redirect(true);
+ }
- public static function doChangeCategory(dcCore $core, zcfsFeedsActionsPage $ap, $post)
- {
- if (isset($post['upd_cat_id'])) {
- $ids = $ap->getIDs();
+ public static function doChangeCategory(dcCore $core, zcfsFeedsActionsPage $ap, $post)
+ {
+ if (isset($post['upd_cat_id'])) {
+ $ids = $ap->getIDs();
- if (empty($ids)) {
- throw new Exception(__('No feeds selected'));
- }
+ if (empty($ids)) {
+ 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) {
- $cur = $ap->zcfs->openCursor();
- $cur->cat_id = $cat_id == 0 ? null : $cat_id;
- $ap->zcfs->updFeed($id, $cur);
- }
+ foreach($ids as $id) {
+ $cur = $ap->zcfs->openCursor();
+ $cur->cat_id = $cat_id == 0 ? null : $cat_id;
+ $ap->zcfs->updFeed($id, $cur);
+ }
- dcPage::addSuccessNotice(sprintf(
- __(
- 'Category of %s feed successfully changed.',
- 'Category of %s feeds successfully changed.',
- count($ids)
- ),
- count($ids)
- ));
- $ap->redirect(true);
- }
- else {
+ dcPage::addSuccessNotice(sprintf(
+ __(
+ 'Category of %s feed successfully changed.',
+ 'Category of %s feeds successfully changed.',
+ count($ids)
+ ),
+ count($ids)
+ ));
+ $ap->redirect(true);
+ }
+ else {
- $categories_combo = dcAdminCombos::getCategoriesCombo(
- $core->blog->getCategories()
- );
+ $categories_combo = dcAdminCombos::getCategoriesCombo(
+ $core->blog->getCategories()
+ );
- $ap->beginPage(
- dcPage::breadcrumb(
- array(
- html::escapeHTML($core->blog->name) => '',
- __('Feeds server') => '',
- $ap->getCallerTitle() => $ap->getRedirection(true),
- __('Change category for this selection') => ''
- )));
+ $ap->beginPage(
+ dcPage::breadcrumb(
+ array(
+ html::escapeHTML($core->blog->name) => '',
+ __('Feeds server') => '',
+ $ap->getCallerTitle() => $ap->getRedirection(true),
+ __('Change category for this selection') => ''
+ )));
- echo
- '';
+ echo
+ '';
- $ap->endPage();
- }
- }
+ $ap->endPage();
+ }
+ }
- public static function doChangeInterval(dcCore $core, zcfsFeedsActionsPage $ap, $post)
- {
- if (isset($post['upd_upd_int'])) {
- $ids = $ap->getIDs();
+ public static function doChangeInterval(dcCore $core, zcfsFeedsActionsPage $ap, $post)
+ {
+ if (isset($post['upd_upd_int'])) {
+ $ids = $ap->getIDs();
- if (empty($ids)) {
- throw new Exception(__('No feeds selected'));
- }
+ if (empty($ids)) {
+ 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) {
- $cur = $ap->zcfs->openCursor();
- $cur->feed_upd_int = $upd_int;
- $ap->zcfs->updFeed($id, $cur);
- }
+ foreach($ids as $id) {
+ $cur = $ap->zcfs->openCursor();
+ $cur->feed_upd_int = $upd_int;
+ $ap->zcfs->updFeed($id, $cur);
+ }
- dcPage::addSuccessNotice(sprintf(
- __(
- 'Update frequency of %s feed successfully changed.',
- 'Update frequency of %s feeds successfully changed.',
- count($ids)
- ),
- count($ids)
- ));
- $ap->redirect(true);
- }
- else {
+ dcPage::addSuccessNotice(sprintf(
+ __(
+ 'Update frequency of %s feed successfully changed.',
+ 'Update frequency of %s feeds successfully changed.',
+ count($ids)
+ ),
+ count($ids)
+ ));
+ $ap->redirect(true);
+ }
+ else {
- $ap->beginPage(
- dcPage::breadcrumb(
- array(
- html::escapeHTML($core->blog->name) => '',
- __('Feeds server') => '',
- $ap->getCallerTitle() => $ap->getRedirection(true),
- __('Change update frequency for this selection') => ''
- )));
+ $ap->beginPage(
+ dcPage::breadcrumb(
+ array(
+ html::escapeHTML($core->blog->name) => '',
+ __('Feeds server') => '',
+ $ap->getCallerTitle() => $ap->getRedirection(true),
+ __('Change update frequency for this selection') => ''
+ )));
- echo
- '';
+ echo
+ '';
- $ap->endPage();
- }
- }
+ $ap->endPage();
+ }
+ }
}
\ No newline at end of file
diff --git a/inc/class.zoneclear.feed.server.php b/inc/class.zoneclear.feed.server.php
index 2a097c3..1645c13 100644
--- a/inc/class.zoneclear.feed.server.php
+++ b/inc/class.zoneclear.feed.server.php
@@ -1,19 +1,19 @@
core = $core;
- $this->con = $core->con;
- $this->blog = $core->con->escape($core->blog->id);
- $this->table = $core->prefix.'zc_feed';
- }
-
- /**
- * Short openCursor.
- *
- * @return cursor cursor instance
- */
- public function openCursor()
- {
- return $this->con->openCursor($this->table);
- }
-
- /**
- * Update feed record.
- *
- * @param integer $id Feed id
- * @param cursor $cur cursor instance
- */
- public function updFeed($id, cursor $cur)
- {
- $this->con->writeLock($this->table);
-
- try {
- $id = (integer) $id;
-
- if ($id < 1) {
- throw new Exception(__('No such ID'));
- }
- $cur->feed_upddt = date('Y-m-d H:i:s');
-
- $cur->update(sprintf(
- "WHERE feed_id = %s AND blog_id = '%s' ",
- $id,
- $this->blog
- ));
- $this->con->unlock();
- $this->trigger();
- }
- catch (Exception $e) {
- $this->con->unlock();
- throw $e;
- }
-
- # --BEHAVIOR-- zoneclearFeedServerAfterUpdFeed
- $this->core->callBehavior(
- 'zoneclearFeedServerAfterUpdFeed',
- $cur,
- $id
- );
- }
-
- /**
- * Add feed record.
- *
- * @param cursor $cur cursor instance
- */
- public function addFeed(cursor $cur)
- {
- $this->con->writeLock($this->table);
-
- try {
- $cur->feed_id = $this->getNextId();
- $cur->blog_id = $this->blog;
- $cur->feed_creadt = date('Y-m-d H:i:s');
- $cur->feed_upddt = date('Y-m-d H:i:s');
-
- //add getFeedCursor here
-
- $cur->insert();
- $this->con->unlock();
- $this->trigger();
- }
- catch (Exception $e) {
- $this->con->unlock();
- throw $e;
- }
-
- # --BEHAVIOR-- zoneclearFeedServerAfterAddFeed
- $this->core->callBehavior(
- 'zoneclearFeedServerAfterAddFeed',
- $cur
- );
-
- return $cur->feed_id;
- }
-
- /**
- * Quick enable / disable feed.
- *
- * @param integer $id Feed Id
- * @param boolean $enable Enable or disable feed
- * @param integer $time Force update time
- */
- public function enableFeed($id, $enable=true, $time=null)
- {
- try {
- $id = (integer) $id;
-
- if ($id < 1) {
- throw new Exception(__('No such ID'));
- }
- $cur = $this->openCursor();
- $this->con->writeLock($this->table);
-
- $cur->feed_upddt = date('Y-m-d H:i:s');
-
- $cur->feed_status = (integer) $enable;
- if (null !== $time) {
- $cur->feed_upd_last = (integer) $time;
- }
-
- $cur->update(sprintf(
- "WHERE feed_id = %s AND blog_id = '%s' ",
- $id,
- $this->blog
- ));
- $this->con->unlock();
- $this->trigger();
- }
- catch (Exception $e) {
- $this->con->unlock();
- throw $e;
- }
-
- # --BEHAVIOR-- zoneclearFeedServerAfterEnableFeed
- $this->core->callBehavior(
- 'zoneclearFeedServerAfterEnableFeed',
- $id,
- $enable,
- $time
- );
- }
-
- #
- /**
- * Delete record (this not deletes post).
- *
- * @param integer $id Feed Id
- */
- public function delFeed($id)
- {
- $id = (integer) $id;
-
- if ($id < 1) {
- throw new Exception(__('No such ID'));
- }
-
- # --BEHAVIOR-- zoneclearFeedServerBeforeDelFeed
- $this->core->callBehavior(
- 'zoneclearFeedServerBeforeDelFeed',
- $id
- );
-
- $this->con->execute(sprintf(
- "DELETE FROM %s WHERE feed_id = %s AND blog_id = '%s' ",
- $this->table,
- $id,
- $this->blog
- ));
- $this->trigger();
- }
-
- /**
- * Get related posts.
- *
- * @param array $params Query params
- * @param boolean $count_only Return only result count
- * @return record record instance
- */
- public function getPostsByFeed($params=array(), $count_only=false)
- {
- if (!isset($params['feed_id'])) {
-
- return null;
- }
-
- $params['from'] =
- 'LEFT JOIN '.$this->core->prefix.'meta F '.
- 'ON P.post_id = F.post_id ';
- $params['sql'] =
- "AND P.blog_id = '".$this->blog."' ".
- "AND F.meta_type = 'zoneclearfeed_id' ".
- "AND F.meta_id = '".$this->con->escape($params['feed_id'])."' ";
-
- unset($params['feed_id']);
-
- return $this->core->blog->getPosts($params, $count_only);
- }
-
- /**
- * Get feed record.
- *
- * @param array $params Query params
- * @param boolean $count_only Return only result count
- * @return record record instance
- */
- public function getFeeds($params=array(), $count_only=false)
- {
- if ($count_only) {
- $strReq = 'SELECT count(Z.feed_id) ';
- }
- else {
- $content_req = '';
- if (!empty($params['columns']) && is_array($params['columns'])) {
- $content_req .= implode(', ',$params['columns']).', ';
- }
-
- $strReq =
- 'SELECT Z.feed_id, Z.feed_creadt, Z.feed_upddt, Z.feed_type, '.
- 'Z.blog_id, Z.cat_id, '.
- 'Z.feed_upd_int, Z.feed_upd_last, Z.feed_status, '.
- $content_req.
- 'LOWER(Z.feed_name) as lowername, Z.feed_name, Z.feed_desc, '.
- 'Z.feed_url, Z.feed_feed, Z.feed_get_tags, '.
- 'Z.feed_tags, Z.feed_owner, Z.feed_tweeter, Z.feed_lang, '.
- 'Z.feed_nb_out, Z.feed_nb_in, '.
- 'C.cat_title, C.cat_url, C.cat_desc ';
- }
-
- $strReq .=
- 'FROM '.$this->table.' Z '.
- 'LEFT OUTER JOIN '.$this->core->prefix.'category C ON Z.cat_id = C.cat_id ';
-
- if (!empty($params['from'])) {
- $strReq .= $params['from'].' ';
- }
-
- $strReq .= "WHERE Z.blog_id = '".$this->blog."' ";
-
- if (isset($params['feed_type'])) {
- $strReq .= "AND Z.feed_type = '".$this->con->escape($params['type'])."' ";
- }
- else {
- $strReq .= "AND Z.feed_type = 'feed' ";
- }
-
- if (!empty($params['feed_id'])) {
- if (is_array($params['feed_id'])) {
- array_walk($params['feed_id'],create_function('&$v,$k','if($v!==null){$v=(integer)$v;}'));
- }
- else {
- $params['feed_id'] = array((integer) $params['feed_id']);
- }
- $strReq .= 'AND Z.feed_id '.$this->con->in($params['feed_id']);
- }
-
- if (isset($params['feed_feed'])) {
- $strReq .= "AND Z.feed_feed = '".$this->con->escape($params['feed_feed'])."' ";
- }
- if (isset($params['feed_url'])) {
- $strReq .= "AND Z.feed_url = '".$this->con->escape($params['feed_url'])."' ";
- }
- if (isset($params['feed_status'])) {
- $strReq .= "AND Z.feed_status = ".((integer) $params['feed_status'])." ";
- }
-
- if (!empty($params['sql'])) {
- $strReq .= $params['sql'].' ';
- }
-
- if (!$count_only) {
- if (!empty($params['order'])) {
- $strReq .= 'ORDER BY '.$this->con->escape($params['order']).' ';
- }
- else {
- $strReq .= 'ORDER BY Z.feed_upddt DESC ';
- }
- }
-
- if (!$count_only && !empty($params['limit'])) {
- $strReq .= $this->con->limit($params['limit']);
- }
-
- $rs = $this->con->select($strReq);
- $rs->zc = $this;
-
- return $rs;
- }
-
- /**
- * Get next table id.
- *
- * @return record record instance
- */
- private function getNextId()
- {
- return $this->con->select(
- 'SELECT MAX(feed_id) FROM '.$this->table
- )->f(0) + 1;
- }
-
- /**
- * Lock a file to see if an update is ongoing.
- *
- * @return boolean True if file is locked
- */
- public function lockUpdate()
- {
- try {
- # Need flock function
- if (!function_exists('flock')) {
- throw New Exception("Can't call php function named flock");
- }
- # Cache writable ?
- if (!is_writable(DC_TPL_CACHE)) {
- throw new Exception("Can't write in cache fodler");
- }
- # Set file path
- $f_md5 = md5($this->blog);
- $cached_file = sprintf(
- '%s/%s/%s/%s/%s.txt',
- DC_TPL_CACHE,
- 'periodical',
- substr($f_md5, 0, 2),
- substr($f_md5, 2, 2),
- $f_md5
- );
- # Real path
- $cached_file = path::real($cached_file, false);
- # Make dir
- if (!is_dir(dirname($cached_file))) {
- files::makeDir(dirname($cached_file), true);
- }
- # Make file
- if (!file_exists($cached_file)) {
- !$fp = @fopen($cached_file, 'w');
- if ($fp === false) {
- throw New Exception("Can't create file");
- }
- fwrite($fp, '1', strlen('1'));
- fclose($fp);
- }
- # Open file
- if (!($fp = @fopen($cached_file, 'r+'))) {
- throw New Exception("Can't open file");
- }
- # Lock file
- if (!flock($fp, LOCK_EX)) {
- throw New Exception("Can't lock file");
- }
- $this->lock = $fp;
-
- return true;
- }
- catch (Exception $e) {
- throw $e;
- }
-
- return false;
- }
-
- /**
- * Unlock file of update process.
- *
- */
- public function unlockUpdate()
- {
- @fclose($this->lock);
- $this->lock = null;
- }
-
- /**
- * Check and add/update post related to record if needed.
- *
- * @param integer $id Feed Id
- * @param boolean $throw Throw exception or end silently
- * @return boolean True if process succeed
- */
- public function checkFeedsUpdate($id=null, $throw=false)
- {
- # Limit to one update at a time
- try {
- $this->lockUpdate();
- }
- catch (Exception $e) {
- if ($throw) {
- throw $e;
- }
-
- return false;
- }
-
- dt::setTZ($this->core->blog->settings->system->blog_timezone);
- $time = time();
- $s = $this->core->blog->settings->zoneclearFeedServer;
-
- # All feeds or only one (from admin)
- $f = !$id ?
- $this->getFeeds(array(
- 'feed_status'=>1,
- 'order'=>'feed_upd_last ASC'
- )) :
- $this->getFeeds(array(
- 'feed_id'=>$id
- ));
-
- # No feed
- if ($f->isEmpty()) {
-
- return false;
- }
-
- # Set feeds user
- $this->enableUser($s->zoneclearFeedServer_user);
-
- $updates = false;
- $loop_mem = array();
-
- $limit = abs((integer) $s->zoneclearFeedServer_update_limit);
- if ($limit < 1) {
- $limit = 10;
- }
- $i = 0;
-
- $cur_post = $this->con->openCursor($this->core->prefix.'post');
- $cur_meta = $this->con->openCursor($this->core->prefix.'meta');
-
- while($f->fetch()) {
- # Check if feed need update
- if ($id || $i < $limit && $f->feed_status == 1
- && $time > $f->feed_upd_last + $f->feed_upd_int
- ) {
- $i++;
- $feed = self::readFeed($f->feed_feed);
-
- # Nothing to parse
- if (!$feed) {
- # Keep active empty feed or disable it ?
- if (!$s->zoneclearFeedServer_keep_empty_feed) {
- $this->enableFeed($f->feed_id, false);
- }
- else {
- # Set update time of this feed
- $this->enableFeed($f->feed_id, true, $time);
- }
- $i++;
- }
- # Not updated since last visit
- elseif (!$id
- && '' != $feed->pubdate
- && strtotime($feed->pubdate) < $f->feed_upd_last
- ) {
- # Set update time of this feed
- $this->enableFeed($f->feed_id, true, $time);
- $i++;
- }
- else {
- # Set update time of this feed
- $this->enableFeed($f->feed_id, $f->feed_status, $time);
-
- $this->con->begin();
-
- foreach ($feed->items as $item) {
- $item_TS = $item->TS ? $item->TS : $time;
-
- // I found that mercurial atom feed did not repect standard
- $item_link = @$item->link;
- if (!$item_link) {
- $item_link = @$item->guid;
- }
- # Unknow feed item link
- if (!$item_link) {
- continue;
- }
-
- $item_link = $this->con->escape($item_link);
- $is_new_published_entry = false;
-
- # Not updated since last visit
- if (!$id && $item_TS < $f->feed_upd_last) {
- continue;
- }
-
- # Fix loop twin
- if (in_array($item_link, $loop_mem)) {
- continue;
- }
- $loop_mem[] = $item_link;
-
- # Check if entry exists
- $old_post = $this->con->select(
- 'SELECT P.post_id, P.post_status '.
- 'FROM '.$this->core->prefix.'post P '.
- 'INNER JOIN '.$this->core->prefix.'meta M '.
- 'ON P.post_id = M.post_id '.
- "WHERE blog_id='".$this->blog."' ".
- "AND meta_type = 'zoneclearfeed_url' ".
- "AND meta_id = '".$item_link."' "
- );
-
- # Prepare entry cursor
- $cur_post->clean();
- $cur_post->post_dt = date('Y-m-d H:i:s', $item_TS);
- if ($f->cat_id) {
- $cur_post->cat_id = $f->cat_id;
- }
- $post_content = $item->content ? $item->content : $item->description;
- $cur_post->post_content = html::absoluteURLs($post_content,$feed->link);
- $cur_post->post_title = $item->title ? $item->title : text::cutString(html::clean($cur_post->post_content),60);
- $creator = $item->creator ? $item->creator : $f->feed_owner;
-
- try {
- # Create entry
- if ($old_post->isEmpty()) {
- # Post
- $cur_post->user_id = $this->core->auth->userID();
- $cur_post->post_format = 'xhtml';
- $cur_post->post_status = (integer) $s->zoneclearFeedServer_post_status_new;
- $cur_post->post_open_comment = 0;
- $cur_post->post_open_tb = 0;
-
- # --BEHAVIOR-- zoneclearFeedServerBeforePostCreate
- $this->core->callBehavior(
- 'zoneclearFeedServerBeforePostCreate',
- $cur_post
- );
-
- $post_id = $this->core->auth->sudo(
- array($this->core->blog, 'addPost'),
- $cur_post
- );
-
- # --BEHAVIOR-- zoneclearFeedServerAfterPostCreate
- $this->core->callBehavior(
- 'zoneclearFeedServerAfterPostCreate',
- $cur_post,
- $post_id
- );
-
- # Auto tweet new post
- if ($cur_post->post_status == 1) {
- $is_new_published_entry = true;
- }
- }
- # Update entry
- else {
- $post_id = $old_post->post_id;
-
- # --BEHAVIOR-- zoneclearFeedServerBeforePostUpdate
- $this->core->callBehavior(
- 'zoneclearFeedServerBeforePostUpdate',
- $cur_post,
- $post_id
- );
-
- $this->core->auth->sudo(
- array($this->core->blog, 'updPost'),
- $post_id,
- $cur_post
- );
-
- # Quick delete old meta
- $this->con->execute(
- 'DELETE FROM '.$this->core->prefix.'meta '.
- 'WHERE post_id = '.$post_id.' '.
- "AND meta_type LIKE 'zoneclearfeed_%' "
- );
- # Delete old tags
- $this->core->auth->sudo(
- array($this->core->meta, 'delPostMeta'),
- $post_id,
- 'tag'
- );
-
- # --BEHAVIOR-- zoneclearFeedServerAfterPostUpdate
- $this->core->callBehavior(
- 'zoneclearFeedServerAfterPostUpdate',
- $cur_post,
- $post_id
- );
- }
-
- # Quick add new meta
- $meta = new ArrayObject();
- $meta->tweeter = $f->feed_tweeter;
-
- $cur_meta->clean();
- $cur_meta->post_id = $post_id;
- $cur_meta->meta_type = 'zoneclearfeed_url';
- $cur_meta->meta_id = $meta->url = $item_link;
- $cur_meta->insert();
-
- $cur_meta->clean();
- $cur_meta->post_id = $post_id;
- $cur_meta->meta_type = 'zoneclearfeed_author';
- $cur_meta->meta_id = $meta->author = $creator;
- $cur_meta->insert();
-
- $cur_meta->clean();
- $cur_meta->post_id = $post_id;
- $cur_meta->meta_type = 'zoneclearfeed_site';
- $cur_meta->meta_id = $meta->site = $f->feed_url;
- $cur_meta->insert();
-
- $cur_meta->clean();
- $cur_meta->post_id = $post_id;
- $cur_meta->meta_type = 'zoneclearfeed_sitename';
- $cur_meta->meta_id = $meta->sitename = $f->feed_name;
- $cur_meta->insert();
-
- $cur_meta->clean();
- $cur_meta->post_id = $post_id;
- $cur_meta->meta_type = 'zoneclearfeed_id';
- $cur_meta->meta_id = $meta->id = $f->feed_id;
- $cur_meta->insert();
-
- # Add new tags
- $tags = $this->core->meta->splitMetaValues($f->feed_tags);
- if ($f->feed_get_tags) {
-
- # Some feed subjects contains more than one tag
- foreach($item->subject as $subjects) {
- $tmp = $this->core->meta->splitMetaValues($subjects);
- $tags = array_merge($tags, $tmp);
- }
- $tags = array_unique($tags);
- }
- $formated_tags = array();
- foreach ($tags as $tag) {
-
- # Change tags case
- switch((integer) $s->zoneclearFeedServer_tag_case) {
- case 3: $tag = strtoupper($tag); break;
- case 2: $tag = strtolower($tag); break;
- case 1: $tag = ucfirst(strtolower($tag)); break;
- default: /* do nothing */ break;
- }
- if (!in_array($tag, $formated_tags)) {
- $formated_tags[] = $tag;
- $this->core->auth->sudo(
- array($this->core->meta, 'setPostMeta'),
- $post_id,
- 'tag',
- dcMeta::sanitizeMetaID($tag)
- );
- }
- }
- $meta->tags = $formated_tags;
-
- # --BEHAVIOR-- zoneclearFeedServerAfterFeedUpdate
- $this->core->callBehavior(
- 'zoneclearFeedServerAfterFeedUpdate',
- $this->core,
- $is_new_published_entry,
- $cur_post,
- $meta
- );
-
- }
- catch (Exception $e) {
- $this->con->rollback();
- $this->enableUser(false);
- $this->unlockUpdate();
- throw $e;
- }
- $updates = true;
- }
- $this->con->commit();
- }
- }
- }
- $this->enableUser(false);
- $this->unlockUpdate();
-
- return true;
- }
-
- /**
- * Set permission to update post table.
- *
- * @param boolean $enable Enable or disable perm
- */
- public function enableUser($enable=false)
- {
- # Enable
- if ($enable) {
- if (!$this->core->auth->checkUser($enable)) {
- throw new Exception('Unable to set user');
- }
- }
- # Disable
- else {
- $this->core->auth = null;
- $this->core->auth = new dcAuth($this->core);
- }
- }
-
- /**
- * Read and parse external feeds.
- *
- * @param string $f Feed URL
- * @return arrayObject Parsed feed
- */
- public static function readFeed($f)
- {
- try {
- $feed_reader = new feedReader;
- $feed_reader->setCacheDir(DC_TPL_CACHE);
- $feed_reader->setTimeout(self::$nethttp_timeout);
- $feed_reader->setMaxRedirects(self::$nethttp_maxredirect);
- $feed_reader->setUserAgent(self::$nethttp_agent);
-
- return $feed_reader->parse($f);
- }
- catch (Exception $e) {
-
- return null;
- }
- }
-
- /**
- * Trigger.
- */
- private function trigger()
- {
- $this->core->blog->triggerBlog();
- }
-
- /**
- * Check if an URL is well formed
- *
- * @param string $url URL
- * @return Boolean True if URL is allowed
- */
- public static function validateURL($url)
- {
- return false !== strpos($url, 'http://')
- || false !== strpos($url, 'https://');
- }
-
- /**
- * Get full URL.
- *
- * Know bugs: anchor is not well parsed.
- *
- * @param string $root Root URL
- * @param string $url An URL
- * @return string Parse URL
- */
- public static function absoluteURL($root, $url)
- {
- $host = preg_replace(
- '|^([a-z]{3,}://)(.*?)/(.*)$|',
- '$1$2',
- $root
- );
-
- $parse = parse_url($url);
-
- if (empty($parse['scheme'])) {
- if (strpos($url,'/') === 0) {
- $url = $host.$url;
- }
- elseif (strpos($url, '#') === 0) {
- $url = $root.$url;
- }
- elseif (preg_match('|/$|', $root)) {
- $url = $root.$url;
- }
- else {
- $url = dirname($root).'/'.$url;
- }
- }
-
- return $url;
- }
-
- /**
- * Get list of feeds status.
- *
- * @return array List of names/values of feeds status
- */
- public static function getAllStatus()
- {
- return array(
- __('Disabled') => '0',
- __('Enabled') => '1'
- );
- }
-
- /**
- * Get list of predefined interval.
- *
- * @return array List of Name/time of intervals
- */
- public static function getAllUpdateInterval()
- {
- return array(
- __('Every hour') => 3600,
- __('Every two hours') => 7200,
- __('Two times per day') => 43200,
- __('Every day') => 86400,
- __('Every two days') => 172800,
- __('Every week') => 604800
- );
- }
-
- /**
- * Get list of (super)admins of current blog.
- *
- * @return array List of UserCNs/UserIds
- */
- public function getAllBlogAdmins()
- {
- $admins = array();
-
- # Get super admins
- $rs = $this->con->select(
- 'SELECT user_id, user_super, user_name, user_firstname, user_displayname '.
- 'FROM '.$this->con->escapeSystem($this->core->prefix.'user').' '.
- 'WHERE user_super = 1 AND user_status = 1 '
- );
-
- if (!$rs->isEmpty()) {
- while ($rs->fetch()) {
- $user_cn = dcUtils::getUserCN(
- $rs->user_id,
- $rs->user_name,
- $rs->user_firstname,
- $rs->user_displayname
- );
- $admins[$user_cn.' (super admin)'] = $rs->user_id;
- }
- }
-
- # Get admins
- $rs = $this->con->select(
- 'SELECT U.user_id, U.user_super, U.user_name, U.user_firstname, U.user_displayname '.
- 'FROM '.$this->con->escapeSystem($this->core->prefix.'user').' U '.
- 'LEFT JOIN '.$this->con->escapeSystem($this->core->prefix.'permissions').' P '.
- 'ON U.user_id=P.user_id '.
- 'WHERE U.user_status = 1 '.
- "AND P.blog_id = '".$this->blog."' ".
- "AND P.permissions LIKE '%|admin|%' "
- );
-
- if (!$rs->isEmpty()) {
- while ($rs->fetch()) {
- $user_cn = dcUtils::getUserCN(
- $rs->user_id,
- $rs->user_name,
- $rs->user_firstname,
- $rs->user_displayname
- );
- $admins[$user_cn.' (admin)'] = $rs->user_id;
- }
- }
-
- return $admins;
- }
-
- /**
- * Get list of urls where entries could be hacked.
- *
- * @param dcCore $core dcCore instance
- * @return array List of names/types of URLs
- */
- public static function getPublicUrlTypes(dcCore $core)
- {
- $types = array();
-
- # --BEHAVIOR-- zoneclearFeedServerPublicUrlTypes
- $core->callBehavior('zoneclearFeedServerPublicUrlTypes', $types);
-
- $types[__('Home page')] = 'default';
- $types[__('Entries pages')] = 'post';
- $types[__('Tags pages')] = 'tag';
- $types[__('Archives pages')] = 'archive';
- $types[__('Category pages')] = 'category';
- $types[__('Entries feed')] = 'feed';
-
- return $types;
- }
-
- /**
- * Take care about plugin tweakurls (thanks Mathieu M.).
- *
- * @param cursor $cur cursor instance
- * @param integer $id Post Id
- */
- public static function tweakurlsAfterPostCreate(cursor $cur, $id)
- {
- global $core;
- $cur->post_url = tweakUrls::tweakBlogURL($cur->post_url);
- $core->auth->sudo(array($core->blog, 'updPost'), $id, $cur);
- }
+ public static $nethttp_timeout = 5;
+ public static $nethttp_agent = 'zoneclearFeedServer - http://zoneclear.org';
+ public static $nethttp_maxredirect = 2;
+
+ public $core;
+ public $con;
+ private $blog;
+ private $table;
+ private $lock = null;
+
+ /**
+ * Constructor.
+ *
+ * @param dcCore $core dcCore instance
+ */
+ public function __construct(dcCore $core)
+ {
+ $this->core = $core;
+ $this->con = $core->con;
+ $this->blog = $core->con->escape($core->blog->id);
+ $this->table = $core->prefix.'zc_feed';
+ }
+
+ /**
+ * Short openCursor.
+ *
+ * @return cursor cursor instance
+ */
+ public function openCursor()
+ {
+ return $this->con->openCursor($this->table);
+ }
+
+ /**
+ * Update feed record.
+ *
+ * @param integer $id Feed id
+ * @param cursor $cur cursor instance
+ */
+ public function updFeed($id, cursor $cur)
+ {
+ $this->con->writeLock($this->table);
+
+ try {
+ $id = (integer) $id;
+
+ if ($id < 1) {
+ throw new Exception(__('No such ID'));
+ }
+ $cur->feed_upddt = date('Y-m-d H:i:s');
+
+ $cur->update(sprintf(
+ "WHERE feed_id = %s AND blog_id = '%s' ",
+ $id,
+ $this->blog
+ ));
+ $this->con->unlock();
+ $this->trigger();
+ }
+ catch (Exception $e) {
+ $this->con->unlock();
+ throw $e;
+ }
+
+ # --BEHAVIOR-- zoneclearFeedServerAfterUpdFeed
+ $this->core->callBehavior(
+ 'zoneclearFeedServerAfterUpdFeed',
+ $cur,
+ $id
+ );
+ }
+
+ /**
+ * Add feed record.
+ *
+ * @param cursor $cur cursor instance
+ */
+ public function addFeed(cursor $cur)
+ {
+ $this->con->writeLock($this->table);
+
+ try {
+ $cur->feed_id = $this->getNextId();
+ $cur->blog_id = $this->blog;
+ $cur->feed_creadt = date('Y-m-d H:i:s');
+ $cur->feed_upddt = date('Y-m-d H:i:s');
+
+ //add getFeedCursor here
+
+ $cur->insert();
+ $this->con->unlock();
+ $this->trigger();
+ }
+ catch (Exception $e) {
+ $this->con->unlock();
+ throw $e;
+ }
+
+ # --BEHAVIOR-- zoneclearFeedServerAfterAddFeed
+ $this->core->callBehavior(
+ 'zoneclearFeedServerAfterAddFeed',
+ $cur
+ );
+
+ return $cur->feed_id;
+ }
+
+ /**
+ * Quick enable / disable feed.
+ *
+ * @param integer $id Feed Id
+ * @param boolean $enable Enable or disable feed
+ * @param integer $time Force update time
+ */
+ public function enableFeed($id, $enable=true, $time=null)
+ {
+ try {
+ $id = (integer) $id;
+
+ if ($id < 1) {
+ throw new Exception(__('No such ID'));
+ }
+ $cur = $this->openCursor();
+ $this->con->writeLock($this->table);
+
+ $cur->feed_upddt = date('Y-m-d H:i:s');
+
+ $cur->feed_status = (integer) $enable;
+ if (null !== $time) {
+ $cur->feed_upd_last = (integer) $time;
+ }
+
+ $cur->update(sprintf(
+ "WHERE feed_id = %s AND blog_id = '%s' ",
+ $id,
+ $this->blog
+ ));
+ $this->con->unlock();
+ $this->trigger();
+ }
+ catch (Exception $e) {
+ $this->con->unlock();
+ throw $e;
+ }
+
+ # --BEHAVIOR-- zoneclearFeedServerAfterEnableFeed
+ $this->core->callBehavior(
+ 'zoneclearFeedServerAfterEnableFeed',
+ $id,
+ $enable,
+ $time
+ );
+ }
+
+ #
+ /**
+ * Delete record (this not deletes post).
+ *
+ * @param integer $id Feed Id
+ */
+ public function delFeed($id)
+ {
+ $id = (integer) $id;
+
+ if ($id < 1) {
+ throw new Exception(__('No such ID'));
+ }
+
+ # --BEHAVIOR-- zoneclearFeedServerBeforeDelFeed
+ $this->core->callBehavior(
+ 'zoneclearFeedServerBeforeDelFeed',
+ $id
+ );
+
+ $this->con->execute(sprintf(
+ "DELETE FROM %s WHERE feed_id = %s AND blog_id = '%s' ",
+ $this->table,
+ $id,
+ $this->blog
+ ));
+ $this->trigger();
+ }
+
+ /**
+ * Get related posts.
+ *
+ * @param array $params Query params
+ * @param boolean $count_only Return only result count
+ * @return record record instance
+ */
+ public function getPostsByFeed($params=array(), $count_only=false)
+ {
+ if (!isset($params['feed_id'])) {
+
+ return null;
+ }
+
+ $params['from'] =
+ 'LEFT JOIN '.$this->core->prefix.'meta F '.
+ 'ON P.post_id = F.post_id ';
+ $params['sql'] =
+ "AND P.blog_id = '".$this->blog."' ".
+ "AND F.meta_type = 'zoneclearfeed_id' ".
+ "AND F.meta_id = '".$this->con->escape($params['feed_id'])."' ";
+
+ unset($params['feed_id']);
+
+ return $this->core->blog->getPosts($params, $count_only);
+ }
+
+ /**
+ * Get feed record.
+ *
+ * @param array $params Query params
+ * @param boolean $count_only Return only result count
+ * @return record record instance
+ */
+ public function getFeeds($params=array(), $count_only=false)
+ {
+ if ($count_only) {
+ $strReq = 'SELECT count(Z.feed_id) ';
+ }
+ else {
+ $content_req = '';
+ if (!empty($params['columns']) && is_array($params['columns'])) {
+ $content_req .= implode(', ',$params['columns']).', ';
+ }
+
+ $strReq =
+ 'SELECT Z.feed_id, Z.feed_creadt, Z.feed_upddt, Z.feed_type, '.
+ 'Z.blog_id, Z.cat_id, '.
+ 'Z.feed_upd_int, Z.feed_upd_last, Z.feed_status, '.
+ $content_req.
+ 'LOWER(Z.feed_name) as lowername, Z.feed_name, Z.feed_desc, '.
+ 'Z.feed_url, Z.feed_feed, Z.feed_get_tags, '.
+ 'Z.feed_tags, Z.feed_owner, Z.feed_tweeter, Z.feed_lang, '.
+ 'Z.feed_nb_out, Z.feed_nb_in, '.
+ 'C.cat_title, C.cat_url, C.cat_desc ';
+ }
+
+ $strReq .=
+ 'FROM '.$this->table.' Z '.
+ 'LEFT OUTER JOIN '.$this->core->prefix.'category C ON Z.cat_id = C.cat_id ';
+
+ if (!empty($params['from'])) {
+ $strReq .= $params['from'].' ';
+ }
+
+ $strReq .= "WHERE Z.blog_id = '".$this->blog."' ";
+
+ if (isset($params['feed_type'])) {
+ $strReq .= "AND Z.feed_type = '".$this->con->escape($params['type'])."' ";
+ }
+ else {
+ $strReq .= "AND Z.feed_type = 'feed' ";
+ }
+
+ if (!empty($params['feed_id'])) {
+ if (is_array($params['feed_id'])) {
+ array_walk($params['feed_id'],create_function('&$v,$k','if($v!==null){$v=(integer)$v;}'));
+ }
+ else {
+ $params['feed_id'] = array((integer) $params['feed_id']);
+ }
+ $strReq .= 'AND Z.feed_id '.$this->con->in($params['feed_id']);
+ }
+
+ if (isset($params['feed_feed'])) {
+ $strReq .= "AND Z.feed_feed = '".$this->con->escape($params['feed_feed'])."' ";
+ }
+ if (isset($params['feed_url'])) {
+ $strReq .= "AND Z.feed_url = '".$this->con->escape($params['feed_url'])."' ";
+ }
+ if (isset($params['feed_status'])) {
+ $strReq .= "AND Z.feed_status = ".((integer) $params['feed_status'])." ";
+ }
+
+ if (!empty($params['sql'])) {
+ $strReq .= $params['sql'].' ';
+ }
+
+ if (!$count_only) {
+ if (!empty($params['order'])) {
+ $strReq .= 'ORDER BY '.$this->con->escape($params['order']).' ';
+ }
+ else {
+ $strReq .= 'ORDER BY Z.feed_upddt DESC ';
+ }
+ }
+
+ if (!$count_only && !empty($params['limit'])) {
+ $strReq .= $this->con->limit($params['limit']);
+ }
+
+ $rs = $this->con->select($strReq);
+ $rs->zc = $this;
+
+ return $rs;
+ }
+
+ /**
+ * Get next table id.
+ *
+ * @return record record instance
+ */
+ private function getNextId()
+ {
+ return $this->con->select(
+ 'SELECT MAX(feed_id) FROM '.$this->table
+ )->f(0) + 1;
+ }
+
+ /**
+ * Lock a file to see if an update is ongoing.
+ *
+ * @return boolean True if file is locked
+ */
+ public function lockUpdate()
+ {
+ try {
+ # Need flock function
+ if (!function_exists('flock')) {
+ throw New Exception("Can't call php function named flock");
+ }
+ # Cache writable ?
+ if (!is_writable(DC_TPL_CACHE)) {
+ throw new Exception("Can't write in cache fodler");
+ }
+ # Set file path
+ $f_md5 = md5($this->blog);
+ $cached_file = sprintf(
+ '%s/%s/%s/%s/%s.txt',
+ DC_TPL_CACHE,
+ 'periodical',
+ substr($f_md5, 0, 2),
+ substr($f_md5, 2, 2),
+ $f_md5
+ );
+ # Real path
+ $cached_file = path::real($cached_file, false);
+ # Make dir
+ if (!is_dir(dirname($cached_file))) {
+ files::makeDir(dirname($cached_file), true);
+ }
+ # Make file
+ if (!file_exists($cached_file)) {
+ !$fp = @fopen($cached_file, 'w');
+ if ($fp === false) {
+ throw New Exception("Can't create file");
+ }
+ fwrite($fp, '1', strlen('1'));
+ fclose($fp);
+ }
+ # Open file
+ if (!($fp = @fopen($cached_file, 'r+'))) {
+ throw New Exception("Can't open file");
+ }
+ # Lock file
+ if (!flock($fp, LOCK_EX)) {
+ throw New Exception("Can't lock file");
+ }
+ $this->lock = $fp;
+
+ return true;
+ }
+ catch (Exception $e) {
+ throw $e;
+ }
+
+ return false;
+ }
+
+ /**
+ * Unlock file of update process.
+ *
+ */
+ public function unlockUpdate()
+ {
+ @fclose($this->lock);
+ $this->lock = null;
+ }
+
+ /**
+ * Check and add/update post related to record if needed.
+ *
+ * @param integer $id Feed Id
+ * @param boolean $throw Throw exception or end silently
+ * @return boolean True if process succeed
+ */
+ public function checkFeedsUpdate($id=null, $throw=false)
+ {
+ # Limit to one update at a time
+ try {
+ $this->lockUpdate();
+ }
+ catch (Exception $e) {
+ if ($throw) {
+ throw $e;
+ }
+
+ return false;
+ }
+
+ dt::setTZ($this->core->blog->settings->system->blog_timezone);
+ $time = time();
+ $s = $this->core->blog->settings->zoneclearFeedServer;
+
+ # All feeds or only one (from admin)
+ $f = !$id ?
+ $this->getFeeds(array(
+ 'feed_status'=>1,
+ 'order'=>'feed_upd_last ASC'
+ )) :
+ $this->getFeeds(array(
+ 'feed_id'=>$id
+ ));
+
+ # No feed
+ if ($f->isEmpty()) {
+
+ return false;
+ }
+
+ # Set feeds user
+ $this->enableUser($s->zoneclearFeedServer_user);
+
+ $updates = false;
+ $loop_mem = array();
+
+ $limit = abs((integer) $s->zoneclearFeedServer_update_limit);
+ if ($limit < 1) {
+ $limit = 10;
+ }
+ $i = 0;
+
+ $cur_post = $this->con->openCursor($this->core->prefix.'post');
+ $cur_meta = $this->con->openCursor($this->core->prefix.'meta');
+
+ while($f->fetch()) {
+ # Check if feed need update
+ if ($id || $i < $limit && $f->feed_status == 1
+ && $time > $f->feed_upd_last + $f->feed_upd_int
+ ) {
+ $i++;
+ $feed = self::readFeed($f->feed_feed);
+
+ # Nothing to parse
+ if (!$feed) {
+ # Keep active empty feed or disable it ?
+ if (!$s->zoneclearFeedServer_keep_empty_feed) {
+ $this->enableFeed($f->feed_id, false);
+ }
+ else {
+ # Set update time of this feed
+ $this->enableFeed($f->feed_id, true, $time);
+ }
+ $i++;
+ }
+ # Not updated since last visit
+ elseif (!$id
+ && '' != $feed->pubdate
+ && strtotime($feed->pubdate) < $f->feed_upd_last
+ ) {
+ # Set update time of this feed
+ $this->enableFeed($f->feed_id, true, $time);
+ $i++;
+ }
+ else {
+ # Set update time of this feed
+ $this->enableFeed($f->feed_id, $f->feed_status, $time);
+
+ $this->con->begin();
+
+ foreach ($feed->items as $item) {
+ $item_TS = $item->TS ? $item->TS : $time;
+
+ // I found that mercurial atom feed did not repect standard
+ $item_link = @$item->link;
+ if (!$item_link) {
+ $item_link = @$item->guid;
+ }
+ # Unknow feed item link
+ if (!$item_link) {
+ continue;
+ }
+
+ $item_link = $this->con->escape($item_link);
+ $is_new_published_entry = false;
+
+ # Not updated since last visit
+ if (!$id && $item_TS < $f->feed_upd_last) {
+ continue;
+ }
+
+ # Fix loop twin
+ if (in_array($item_link, $loop_mem)) {
+ continue;
+ }
+ $loop_mem[] = $item_link;
+
+ # Check if entry exists
+ $old_post = $this->con->select(
+ 'SELECT P.post_id, P.post_status '.
+ 'FROM '.$this->core->prefix.'post P '.
+ 'INNER JOIN '.$this->core->prefix.'meta M '.
+ 'ON P.post_id = M.post_id '.
+ "WHERE blog_id='".$this->blog."' ".
+ "AND meta_type = 'zoneclearfeed_url' ".
+ "AND meta_id = '".$item_link."' "
+ );
+
+ # Prepare entry cursor
+ $cur_post->clean();
+ $cur_post->post_dt = date('Y-m-d H:i:s', $item_TS);
+ if ($f->cat_id) {
+ $cur_post->cat_id = $f->cat_id;
+ }
+ $post_content = $item->content ? $item->content : $item->description;
+ $cur_post->post_content = html::absoluteURLs($post_content,$feed->link);
+ $cur_post->post_title = $item->title ? $item->title : text::cutString(html::clean($cur_post->post_content),60);
+ $creator = $item->creator ? $item->creator : $f->feed_owner;
+
+ try {
+ # Create entry
+ if ($old_post->isEmpty()) {
+ # Post
+ $cur_post->user_id = $this->core->auth->userID();
+ $cur_post->post_format = 'xhtml';
+ $cur_post->post_status = (integer) $s->zoneclearFeedServer_post_status_new;
+ $cur_post->post_open_comment = 0;
+ $cur_post->post_open_tb = 0;
+
+ # --BEHAVIOR-- zoneclearFeedServerBeforePostCreate
+ $this->core->callBehavior(
+ 'zoneclearFeedServerBeforePostCreate',
+ $cur_post
+ );
+
+ $post_id = $this->core->auth->sudo(
+ array($this->core->blog, 'addPost'),
+ $cur_post
+ );
+
+ # --BEHAVIOR-- zoneclearFeedServerAfterPostCreate
+ $this->core->callBehavior(
+ 'zoneclearFeedServerAfterPostCreate',
+ $cur_post,
+ $post_id
+ );
+
+ # Auto tweet new post
+ if ($cur_post->post_status == 1) {
+ $is_new_published_entry = true;
+ }
+ }
+ # Update entry
+ else {
+ $post_id = $old_post->post_id;
+
+ # --BEHAVIOR-- zoneclearFeedServerBeforePostUpdate
+ $this->core->callBehavior(
+ 'zoneclearFeedServerBeforePostUpdate',
+ $cur_post,
+ $post_id
+ );
+
+ $this->core->auth->sudo(
+ array($this->core->blog, 'updPost'),
+ $post_id,
+ $cur_post
+ );
+
+ # Quick delete old meta
+ $this->con->execute(
+ 'DELETE FROM '.$this->core->prefix.'meta '.
+ 'WHERE post_id = '.$post_id.' '.
+ "AND meta_type LIKE 'zoneclearfeed_%' "
+ );
+ # Delete old tags
+ $this->core->auth->sudo(
+ array($this->core->meta, 'delPostMeta'),
+ $post_id,
+ 'tag'
+ );
+
+ # --BEHAVIOR-- zoneclearFeedServerAfterPostUpdate
+ $this->core->callBehavior(
+ 'zoneclearFeedServerAfterPostUpdate',
+ $cur_post,
+ $post_id
+ );
+ }
+
+ # Quick add new meta
+ $meta = new ArrayObject();
+ $meta->tweeter = $f->feed_tweeter;
+
+ $cur_meta->clean();
+ $cur_meta->post_id = $post_id;
+ $cur_meta->meta_type = 'zoneclearfeed_url';
+ $cur_meta->meta_id = $meta->url = $item_link;
+ $cur_meta->insert();
+
+ $cur_meta->clean();
+ $cur_meta->post_id = $post_id;
+ $cur_meta->meta_type = 'zoneclearfeed_author';
+ $cur_meta->meta_id = $meta->author = $creator;
+ $cur_meta->insert();
+
+ $cur_meta->clean();
+ $cur_meta->post_id = $post_id;
+ $cur_meta->meta_type = 'zoneclearfeed_site';
+ $cur_meta->meta_id = $meta->site = $f->feed_url;
+ $cur_meta->insert();
+
+ $cur_meta->clean();
+ $cur_meta->post_id = $post_id;
+ $cur_meta->meta_type = 'zoneclearfeed_sitename';
+ $cur_meta->meta_id = $meta->sitename = $f->feed_name;
+ $cur_meta->insert();
+
+ $cur_meta->clean();
+ $cur_meta->post_id = $post_id;
+ $cur_meta->meta_type = 'zoneclearfeed_id';
+ $cur_meta->meta_id = $meta->id = $f->feed_id;
+ $cur_meta->insert();
+
+ # Add new tags
+ $tags = $this->core->meta->splitMetaValues($f->feed_tags);
+ if ($f->feed_get_tags) {
+
+ # Some feed subjects contains more than one tag
+ foreach($item->subject as $subjects) {
+ $tmp = $this->core->meta->splitMetaValues($subjects);
+ $tags = array_merge($tags, $tmp);
+ }
+ $tags = array_unique($tags);
+ }
+ $formated_tags = array();
+ foreach ($tags as $tag) {
+
+ # Change tags case
+ switch((integer) $s->zoneclearFeedServer_tag_case) {
+ case 3: $tag = strtoupper($tag); break;
+ case 2: $tag = strtolower($tag); break;
+ case 1: $tag = ucfirst(strtolower($tag)); break;
+ default: /* do nothing */ break;
+ }
+ if (!in_array($tag, $formated_tags)) {
+ $formated_tags[] = $tag;
+ $this->core->auth->sudo(
+ array($this->core->meta, 'setPostMeta'),
+ $post_id,
+ 'tag',
+ dcMeta::sanitizeMetaID($tag)
+ );
+ }
+ }
+ $meta->tags = $formated_tags;
+
+ # --BEHAVIOR-- zoneclearFeedServerAfterFeedUpdate
+ $this->core->callBehavior(
+ 'zoneclearFeedServerAfterFeedUpdate',
+ $this->core,
+ $is_new_published_entry,
+ $cur_post,
+ $meta
+ );
+
+ }
+ catch (Exception $e) {
+ $this->con->rollback();
+ $this->enableUser(false);
+ $this->unlockUpdate();
+ throw $e;
+ }
+ $updates = true;
+ }
+ $this->con->commit();
+ }
+ }
+ }
+ $this->enableUser(false);
+ $this->unlockUpdate();
+
+ return true;
+ }
+
+ /**
+ * Set permission to update post table.
+ *
+ * @param boolean $enable Enable or disable perm
+ */
+ public function enableUser($enable=false)
+ {
+ # Enable
+ if ($enable) {
+ if (!$this->core->auth->checkUser($enable)) {
+ throw new Exception('Unable to set user');
+ }
+ }
+ # Disable
+ else {
+ $this->core->auth = null;
+ $this->core->auth = new dcAuth($this->core);
+ }
+ }
+
+ /**
+ * Read and parse external feeds.
+ *
+ * @param string $f Feed URL
+ * @return arrayObject Parsed feed
+ */
+ public static function readFeed($f)
+ {
+ try {
+ $feed_reader = new feedReader;
+ $feed_reader->setCacheDir(DC_TPL_CACHE);
+ $feed_reader->setTimeout(self::$nethttp_timeout);
+ $feed_reader->setMaxRedirects(self::$nethttp_maxredirect);
+ $feed_reader->setUserAgent(self::$nethttp_agent);
+
+ return $feed_reader->parse($f);
+ }
+ catch (Exception $e) {
+
+ return null;
+ }
+ }
+
+ /**
+ * Trigger.
+ */
+ private function trigger()
+ {
+ $this->core->blog->triggerBlog();
+ }
+
+ /**
+ * Check if an URL is well formed
+ *
+ * @param string $url URL
+ * @return Boolean True if URL is allowed
+ */
+ public static function validateURL($url)
+ {
+ return false !== strpos($url, 'http://')
+ || false !== strpos($url, 'https://');
+ }
+
+ /**
+ * Get full URL.
+ *
+ * Know bugs: anchor is not well parsed.
+ *
+ * @param string $root Root URL
+ * @param string $url An URL
+ * @return string Parse URL
+ */
+ public static function absoluteURL($root, $url)
+ {
+ $host = preg_replace(
+ '|^([a-z]{3,}://)(.*?)/(.*)$|',
+ '$1$2',
+ $root
+ );
+
+ $parse = parse_url($url);
+
+ if (empty($parse['scheme'])) {
+ if (strpos($url,'/') === 0) {
+ $url = $host.$url;
+ }
+ elseif (strpos($url, '#') === 0) {
+ $url = $root.$url;
+ }
+ elseif (preg_match('|/$|', $root)) {
+ $url = $root.$url;
+ }
+ else {
+ $url = dirname($root).'/'.$url;
+ }
+ }
+
+ return $url;
+ }
+
+ /**
+ * Get list of feeds status.
+ *
+ * @return array List of names/values of feeds status
+ */
+ public static function getAllStatus()
+ {
+ return array(
+ __('Disabled') => '0',
+ __('Enabled') => '1'
+ );
+ }
+
+ /**
+ * Get list of predefined interval.
+ *
+ * @return array List of Name/time of intervals
+ */
+ public static function getAllUpdateInterval()
+ {
+ return array(
+ __('Every hour') => 3600,
+ __('Every two hours') => 7200,
+ __('Two times per day') => 43200,
+ __('Every day') => 86400,
+ __('Every two days') => 172800,
+ __('Every week') => 604800
+ );
+ }
+
+ /**
+ * Get list of (super)admins of current blog.
+ *
+ * @return array List of UserCNs/UserIds
+ */
+ public function getAllBlogAdmins()
+ {
+ $admins = array();
+
+ # Get super admins
+ $rs = $this->con->select(
+ 'SELECT user_id, user_super, user_name, user_firstname, user_displayname '.
+ 'FROM '.$this->con->escapeSystem($this->core->prefix.'user').' '.
+ 'WHERE user_super = 1 AND user_status = 1 '
+ );
+
+ if (!$rs->isEmpty()) {
+ while ($rs->fetch()) {
+ $user_cn = dcUtils::getUserCN(
+ $rs->user_id,
+ $rs->user_name,
+ $rs->user_firstname,
+ $rs->user_displayname
+ );
+ $admins[$user_cn.' (super admin)'] = $rs->user_id;
+ }
+ }
+
+ # Get admins
+ $rs = $this->con->select(
+ 'SELECT U.user_id, U.user_super, U.user_name, U.user_firstname, U.user_displayname '.
+ 'FROM '.$this->con->escapeSystem($this->core->prefix.'user').' U '.
+ 'LEFT JOIN '.$this->con->escapeSystem($this->core->prefix.'permissions').' P '.
+ 'ON U.user_id=P.user_id '.
+ 'WHERE U.user_status = 1 '.
+ "AND P.blog_id = '".$this->blog."' ".
+ "AND P.permissions LIKE '%|admin|%' "
+ );
+
+ if (!$rs->isEmpty()) {
+ while ($rs->fetch()) {
+ $user_cn = dcUtils::getUserCN(
+ $rs->user_id,
+ $rs->user_name,
+ $rs->user_firstname,
+ $rs->user_displayname
+ );
+ $admins[$user_cn.' (admin)'] = $rs->user_id;
+ }
+ }
+
+ return $admins;
+ }
+
+ /**
+ * Get list of urls where entries could be hacked.
+ *
+ * @param dcCore $core dcCore instance
+ * @return array List of names/types of URLs
+ */
+ public static function getPublicUrlTypes(dcCore $core)
+ {
+ $types = array();
+
+ # --BEHAVIOR-- zoneclearFeedServerPublicUrlTypes
+ $core->callBehavior('zoneclearFeedServerPublicUrlTypes', $types);
+
+ $types[__('Home page')] = 'default';
+ $types[__('Entries pages')] = 'post';
+ $types[__('Tags pages')] = 'tag';
+ $types[__('Archives pages')] = 'archive';
+ $types[__('Category pages')] = 'category';
+ $types[__('Entries feed')] = 'feed';
+
+ return $types;
+ }
+
+ /**
+ * Take care about plugin tweakurls (thanks Mathieu M.).
+ *
+ * @param cursor $cur cursor instance
+ * @param integer $id Post Id
+ */
+ public static function tweakurlsAfterPostCreate(cursor $cur, $id)
+ {
+ global $core;
+ $cur->post_url = tweakUrls::tweakBlogURL($cur->post_url);
+ $core->auth->sudo(array($core->blog, 'updPost'), $id, $cur);
+ }
}
\ No newline at end of file
diff --git a/inc/lib.zcfs.list.php b/inc/lib.zcfs.list.php
index 011a90d..b2ee487 100644
--- a/inc/lib.zcfs.list.php
+++ b/inc/lib.zcfs.list.php
@@ -1,19 +1,19 @@
rs->isEmpty()) {
+ public function feedsDisplay($page, $nb_per_page, $url, $enclose='')
+ {
+ if ($this->rs->isEmpty()) {
- return ''.__('There is no feed').'
';
- }
+ return ''.__('There is no feed').'
';
+ }
- $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 =
- ''.
- '
'.
- ''.
- ''.
- ''.__('Name').' | '.
- ''.__('Feed').' | '.
- ''.__('Frequency').' | '.
- ''.__('Last update').' | '.
- ''.__('Entries').' | '.
- ''.__('Status').' | '.
- '
'.
- ''.
- '%s'.
- '
'.
- '
';
+ $html_block =
+ ''.
+ '
'.
+ ''.
+ ''.
+ ''.__('Name').' | '.
+ ''.__('Feed').' | '.
+ ''.__('Frequency').' | '.
+ ''.__('Last update').' | '.
+ ''.__('Entries').' | '.
+ ''.__('Status').' | '.
+ '
'.
+ ''.
+ '%s'.
+ '
'.
+ '
';
- $res = '';
- while ($this->rs->fetch()) {
- $res .= $this->feedsLine();
- }
+ $res = '';
+ while ($this->rs->fetch()) {
+ $res .= $this->feedsLine();
+ }
- return
- $pager->getLinks().
- sprintf($enclose, sprintf($html_block, $res)).
- $pager->getLinks();
- }
-
- private function feedsLine()
- {
- $combo_status = zoneclearFeedServer::getAllStatus();
- $combo_upd_int = zoneclearFeedServer::getAllUpdateInterval();
- $status = $this->rs->feed_status ?
- '' :
- '';
- $category = $this->rs->cat_id ?
- $this->rs->cat_title : __('no categories');
+ return
+ $pager->getLinks().
+ sprintf($enclose, sprintf($html_block, $res)).
+ $pager->getLinks();
+ }
- $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);
- }
+ private function feedsLine()
+ {
+ $combo_status = zoneclearFeedServer::getAllStatus();
+ $combo_upd_int = zoneclearFeedServer::getAllUpdateInterval();
+ $status = $this->rs->feed_status ?
+ '' :
+ '';
+ $category = $this->rs->cat_id ?
+ $this->rs->cat_title : __('no categories');
- $url = 'plugin.php?p=zoneclearFeedServer&part=feed&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
- ''."\n".
- ''.
- form::checkbox(array('feeds[]'), $this->rs->feed_id, 0).
- ' | '.
- ''.
- ''.
- html::escapeHTML($this->rs->feed_name).''.
- " | \n".
- ''.
- ''.html::escapeHTML($shunk_feed).''.
- " | \n".
- ''.
- array_search($this->rs->feed_upd_int,$combo_upd_int).
- " | \n".
- ''.
- ($this->rs->feed_upd_last < 1 ?
- __('never') :
- dt::str(__('%Y-%m-%d %H:%M'), $this->rs->feed_upd_last,$this->rs->zc->core->auth->getInfo('user_tz'))
- ).
- " | \n".
- ''.
- ($entries_count ?
- ''.$entries_count.'' :
- $entries_count
- ).
- " | \n".
- ''.
- $status.
- " | \n".
- '
'."\n";
- }
+ $url = 'plugin.php?p=zoneclearFeedServer&part=feed&feed_id='.$this->rs->feed_id;
+
+ return
+ ''."\n".
+ ''.
+ form::checkbox(array('feeds[]'), $this->rs->feed_id, 0).
+ ' | '.
+ ''.
+ ''.
+ html::escapeHTML($this->rs->feed_name).''.
+ " | \n".
+ ''.
+ ''.html::escapeHTML($shunk_feed).''.
+ " | \n".
+ ''.
+ array_search($this->rs->feed_upd_int,$combo_upd_int).
+ " | \n".
+ ''.
+ ($this->rs->feed_upd_last < 1 ?
+ __('never') :
+ dt::str(__('%Y-%m-%d %H:%M'), $this->rs->feed_upd_last,$this->rs->zc->core->auth->getInfo('user_tz'))
+ ).
+ " | \n".
+ ''.
+ ($entries_count ?
+ ''.$entries_count.'' :
+ $entries_count
+ ).
+ " | \n".
+ ''.
+ $status.
+ " | \n".
+ '
'."\n";
+ }
}
/**
@@ -123,82 +123,82 @@ class zcfsFeedsList extends adminGenericList
*/
class zcfsEntriesList extends adminGenericList
{
- public function display($page, $nb_per_page, $url, $enclose='')
- {
- if ($this->rs->isEmpty()) {
+ public function display($page, $nb_per_page, $url, $enclose='')
+ {
+ if ($this->rs->isEmpty()) {
- return ''.__('No entry').'
';
- }
+ return ''.__('No entry').'
';
+ }
- $pager = new dcPager($page, $this->rs_count, $nb_per_page, 10);
- $pager->base_url = $url;
- $pager->html_prev = $this->html_prev;
- $pager->html_next = $this->html_next;
- $pager->var_page = 'page';
+ $pager = new dcPager($page, $this->rs_count, $nb_per_page, 10);
+ $pager->base_url = $url;
+ $pager->html_prev = $this->html_prev;
+ $pager->html_next = $this->html_next;
+ $pager->var_page = 'page';
- $html_block =
- ''.
- '
'.
- ''.__('Title').' | '.
- ''.__('Date').' | '.
- ''.__('Category').' | '.
- ''.__('Author').' | '.
- ''.__('Comments').' | '.
- ''.__('Trackbacks').' | '.
- ''.__('Status').' | '.
- '
%s
';
+ $html_block =
+ ''.
+ '
'.
+ ''.__('Title').' | '.
+ ''.__('Date').' | '.
+ ''.__('Category').' | '.
+ ''.__('Author').' | '.
+ ''.__('Comments').' | '.
+ ''.__('Trackbacks').' | '.
+ ''.__('Status').' | '.
+ '
%s
';
- $res = '';
- while ($this->rs->fetch()) {
- $res .= $this->postLine();
- }
+ $res = '';
+ while ($this->rs->fetch()) {
+ $res .= $this->postLine();
+ }
- return
- $pager->getLinks().
- sprintf($enclose, sprintf($html_block, $res)).
- $pager->getLinks();
- }
+ return
+ $pager->getLinks().
+ sprintf($enclose, sprintf($html_block, $res)).
+ $pager->getLinks();
+ }
- private function postLine()
- {
- $cat_link = $this->core->auth->check('categories', $this->core->blog->id) ?
- '%s'
- : '%2$s';
+ private function postLine()
+ {
+ $cat_link = $this->core->auth->check('categories', $this->core->blog->id) ?
+ '%s'
+ : '%2$s';
- $cat_title = $this->rs->cat_title ?
- sprintf($cat_link,$this->rs->cat_id, html::escapeHTML($this->rs->cat_title))
- : __('None');
+ $cat_title = $this->rs->cat_title ?
+ sprintf($cat_link,$this->rs->cat_id, html::escapeHTML($this->rs->cat_title))
+ : __('None');
- $img = '';
- switch ($this->rs->post_status) {
- case 1:
- $img_status = sprintf($img, __('published'), 'check-on.png');
- break;
- case 0:
- $img_status = sprintf($img, __('unpublished'), 'check-off.png');
- break;
- case -1:
- $img_status = sprintf($img, __('scheduled'), 'scheduled.png');
- break;
- case -2:
- $img_status = sprintf($img, __('pending'), 'check-wrn.png');
- break;
- }
+ $img = '';
+ switch ($this->rs->post_status) {
+ case 1:
+ $img_status = sprintf($img, __('published'), 'check-on.png');
+ break;
+ case 0:
+ $img_status = sprintf($img, __('unpublished'), 'check-off.png');
+ break;
+ case -1:
+ $img_status = sprintf($img, __('scheduled'), 'scheduled.png');
+ break;
+ case -2:
+ $img_status = sprintf($img, __('pending'), 'check-wrn.png');
+ break;
+ }
- return
- ''.
- ''.
- form::checkbox(array('entries[]'), $this->rs->post_id, '', '', '', !$this->rs->isEditable()).' | '.
- ''.
- html::escapeHTML($this->rs->post_title).' | '.
- ''.dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->post_dt).' | '.
- ''.$cat_title.' | '.
- ''.$this->rs->user_id.' | '.
- ''.$this->rs->nb_comment.' | '.
- ''.$this->rs->nb_trackback.' | '.
- ''.$img_status.' | '.
- '
';
- }
+ return
+ ''.
+ ''.
+ form::checkbox(array('entries[]'), $this->rs->post_id, '', '', '', !$this->rs->isEditable()).' | '.
+ ''.
+ html::escapeHTML($this->rs->post_title).' | '.
+ ''.dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->post_dt).' | '.
+ ''.$cat_title.' | '.
+ ''.$this->rs->user_id.' | '.
+ ''.$this->rs->nb_comment.' | '.
+ ''.$this->rs->nb_trackback.' | '.
+ ''.$img_status.' | '.
+ '
';
+ }
}
\ No newline at end of file
diff --git a/inc/lib.zcfs.socialmewriter.php b/inc/lib.zcfs.socialmewriter.php
index 9b206db..c28536f 100644
--- a/inc/lib.zcfs.socialmewriter.php
+++ b/inc/lib.zcfs.socialmewriter.php
@@ -1,19 +1,19 @@
__('New Zoneclear post'),
- 'description' => __('When a feed has new entry'),
- 'action' => array('Message','Link'),
- 'format' => array('Message'),
- 'wildcards' => array('Message' => array(
- '%posttitle%',
- '%postlink%',
- '%postauthor%',
- '%posttweeter%',
- '%sitetitle%',
- '%sitelink%',
- '%tags'
- ))
- );
- }
+ public static function soCialMeWriterMarker($rs)
+ {
+ $rs['zcfscreate'] = array(
+ 'name' => __('New Zoneclear post'),
+ 'description' => __('When a feed has new entry'),
+ 'action' => array('Message','Link'),
+ 'format' => array('Message'),
+ 'wildcards' => array('Message' => array(
+ '%posttitle%',
+ '%postlink%',
+ '%postauthor%',
+ '%posttweeter%',
+ '%sitetitle%',
+ '%sitelink%',
+ '%tags'
+ ))
+ );
+ }
- public static function zoneclearFeedServerAfterFeedUpdate($core, $is_new_published_entry, $post, $meta)
- {
- // for now only new post
- if(!$is_new_published_entry) {
+ public static function zoneclearFeedServerAfterFeedUpdate($core, $is_new_published_entry, $post, $meta)
+ {
+ // for now only new post
+ if(!$is_new_published_entry) {
- return null;
- }
+ return null;
+ }
- $key = 'zcfscreate';
+ $key = 'zcfscreate';
- # Is install
- if (!$core->plugins->moduleExists('soCialMe')) {
+ # Is install
+ if (!$core->plugins->moduleExists('soCialMe')) {
- return null;
- }
+ return null;
+ }
- # Is active
- if (!$core->blog->settings->soCialMeWriter->active) {
+ # Is active
+ if (!$core->blog->settings->soCialMeWriter->active) {
- return null;
- }
+ return null;
+ }
- # Load services
- $soCialMeWriter = new soCialMeWriter($core);
+ # Load services
+ $soCialMeWriter = new soCialMeWriter($core);
- # List of service per action
- $actions = $soCialMeWriter->getMarker('action');
+ # List of service per action
+ $actions = $soCialMeWriter->getMarker('action');
- # List of format per type
- $formats = $soCialMeWriter->getMarker('format');
+ # List of format per type
+ $formats = $soCialMeWriter->getMarker('format');
- # prepare data
- $shortposturl = soCialMeUtils::reduceURL($meta->url);
- $shortposturl = $shortposturl ? $shortposturl : $meta->url;
+ # prepare data
+ $shortposturl = soCialMeUtils::reduceURL($meta->url);
+ $shortposturl = $shortposturl ? $shortposturl : $meta->url;
- $shortsiteurl = soCialMeUtils::reduceURL($meta->site);
- $shortsiteurl = $shortsiteurl ? $shortsiteurl : $meta->site;
+ $shortsiteurl = soCialMeUtils::reduceURL($meta->site);
+ $shortsiteurl = $shortsiteurl ? $shortsiteurl : $meta->site;
- // need this?
- foreach($meta->tags as $k => $tag) {
- $tags[$k] = '#'.$tag;
- }
+ // need this?
+ foreach($meta->tags as $k => $tag) {
+ $tags[$k] = '#'.$tag;
+ }
- # sendMessage
- if (!empty($formats[$key]['Message'])
- && !empty($actions[$key]['Message'])
- ) {
- // parse message
- $message_txt = str_replace(
- array(
- '%posttitle%',
- '%postlink%',
- '%postauthor%',
- '%posttweeter%',
- '%sitetitle%',
- '%sitelink%',
- '%tags'
- ),
- array(
- $post->post_title,
- $shortposturl,
- $meta->author,
- $meta->tweeter,
- $meta->sitename,
- $shortsiteurl,
- implode(',', $meta->tags)
- ),
- $formats[$key]['Message']
- );
+ # sendMessage
+ if (!empty($formats[$key]['Message'])
+ && !empty($actions[$key]['Message'])
+ ) {
+ // parse message
+ $message_txt = str_replace(
+ array(
+ '%posttitle%',
+ '%postlink%',
+ '%postauthor%',
+ '%posttweeter%',
+ '%sitetitle%',
+ '%sitelink%',
+ '%tags'
+ ),
+ array(
+ $post->post_title,
+ $shortposturl,
+ $meta->author,
+ $meta->tweeter,
+ $meta->sitename,
+ $shortsiteurl,
+ implode(',', $meta->tags)
+ ),
+ $formats[$key]['Message']
+ );
- // send message
- if (!empty($message_txt)) {
- foreach($actions[$key]['Message'] as $service_id) {
- $soCialMeWriter->play(
- $service_id,
- 'Message',
- 'Content',
- $message_txt
- );
- }
- }
- }
+ // send message
+ if (!empty($message_txt)) {
+ foreach($actions[$key]['Message'] as $service_id) {
+ $soCialMeWriter->play(
+ $service_id,
+ 'Message',
+ 'Content',
+ $message_txt
+ );
+ }
+ }
+ }
- # sendLink
- if (!empty($actions[$key]['Link'])) {
- foreach($actions[$key]['Link'] as $service_id) {
- $soCialMeWriter->play(
- $service_id,
- 'Link',
- 'Content',
- $cur->post_title,$shortposturl
- );
- }
- }
+ # sendLink
+ if (!empty($actions[$key]['Link'])) {
+ foreach($actions[$key]['Link'] as $service_id) {
+ $soCialMeWriter->play(
+ $service_id,
+ 'Link',
+ 'Content',
+ $cur->post_title,$shortposturl
+ );
+ }
+ }
- # sendData
- // not yet implemented
+ # sendData
+ // not yet implemented
- #sendArticle
- // not yet implemented
- }
+ #sendArticle
+ // not yet implemented
+ }
}
\ No newline at end of file
diff --git a/inc/lib.zcfsr.activityreport.php b/inc/lib.zcfsr.activityreport.php
deleted file mode 100644
index b6a76f5..0000000
--- a/inc/lib.zcfsr.activityreport.php
+++ /dev/null
@@ -1,169 +0,0 @@
-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
- );
- }
-}
\ No newline at end of file
diff --git a/index.php b/index.php
index 4b3f838..03a3828 100644
--- a/index.php
+++ b/index.php
@@ -1,25 +1,25 @@
getVersion('zoneclearFeedServer') !=
$core->plugins->moduleInfo('zoneclearFeedServer', 'version')) {
- return null;
+ return null;
}
dcPage::check('admin');
@@ -34,649 +34,649 @@ $zcfs = new zoneclearFeedServer($core);
if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
- $feed_id = '';
- $feed_name = '';
- $feed_desc = '';
- $feed_owner = '';
- $feed_tweeter = '';
- $feed_url = '';
- $feed_feed = '';
- $feed_lang = $core->auth->getInfo('user_lang');
- $feed_tags = '';
- $feed_get_tags = '0';
- $feed_cat_id = '';
- $feed_status = '0';
- $feed_upd_int = 3600;
-
- $can_view_page = true;
-
- $feed_headlink = '';
- $feed_link = '%s';
-
- $next_link = $prev_link = $next_headlink = $prev_headlink = null;
-
- # Combos
- $combo_langs = l10n::getISOcodes(true);
- $combo_status = $zcfs->getAllStatus();
- $combo_upd_int = $zcfs->getAllUpdateInterval();
- $combo_categories = array('-' => '');
- try {
- $categories = $core->blog->getCategories(array(
- 'post_type' => 'post'
- ));
- while ($categories->fetch()) {
- $combo_categories[
- str_repeat(' ', $categories->level-1).
- '• '.html::escapeHTML($categories->cat_title)
- ] = $categories->cat_id;
- }
- }
- catch (Exception $e) {
- $core->error->add($e->getMessage());
- }
-
- # Get entry informations
- if (!empty($_REQUEST['feed_id'])) {
- $feed = $zcfs->getFeeds(array('feed_id' => $_REQUEST['feed_id']));
-
- if ($feed->isEmpty()) {
- $core->error->add(__('This feed does not exist.'));
- $can_view_page = false;
- }
- else {
- $feed_id = $feed->feed_id;
- $feed_name = $feed->feed_name;
- $feed_desc = $feed->feed_desc;
- $feed_owner = $feed->feed_owner;
- $feed_tweeter = $feed->feed_tweeter;
- $feed_url = $feed->feed_url;
- $feed_feed = $feed->feed_feed;
- $feed_lang = $feed->feed_lang;
- $feed_tags = $feed->feed_tags;
- $feed_get_tags = $feed->feed_get_tags;
- $feed_cat_id = $feed->cat_id;
- $feed_status = $feed->feed_status;
- $feed_upd_int = $feed->feed_upd_int;
-
- $next_params = array(
- 'sql' => 'AND feed_id < '.$feed_id.' ',
- 'limit' => 1
- );
- $next_rs = $zcfs->getFeeds($next_params);
- $prev_params = array(
- 'sql' => 'AND feed_id > '.$feed_id.' ',
- 'limit' => 1
- );
- $prev_rs = $zcfs->getFeeds($prev_params);
-
- if (!$next_rs->isEmpty()) {
- $next_link = sprintf($feed_link,$next_rs->feed_id,
- html::escapeHTML($next_rs->feed_name), __('next feed').' »');
- $next_headlink = sprintf($feed_headlink, 'next',
- html::escapeHTML($next_rs->feed_name), $next_rs->feed_id);
- }
-
- if (!$prev_rs->isEmpty()) {
- $prev_link = sprintf($feed_link,$prev_rs->feed_id,
- html::escapeHTML($prev_rs->feed_name), '« '.__('previous feed'));
- $prev_headlink = sprintf($feed_headlink, 'previous',
- html::escapeHTML($prev_rs->feed_name), $prev_rs->feed_id);
- }
- }
- }
-
- if (!empty($_POST['action']) && $_POST['action'] == 'savefeed') {
- try {
- $feed_name = $_POST['feed_name'];
- $feed_desc = $_POST['feed_desc'];
- $feed_owner = $_POST['feed_owner'];
- $feed_tweeter = $_POST['feed_tweeter'];
- $feed_url = $_POST['feed_url'];
- $feed_feed = $_POST['feed_feed'];
- $feed_lang = $_POST['feed_lang'];
- $feed_tags = $_POST['feed_tags'];
- $feed_get_tags = empty($_POST['feed_get_tags']) ? 0 : 1;
- $feed_cat_id = $_POST['feed_cat_id'];
- if (isset($_POST['feed_status'])) {
- $feed_status = (integer) $_POST['feed_status'];
- }
- $feed_upd_int = $_POST['feed_upd_int'];
-
- $testfeed_params['feed_feed'] = $feed_feed;
- if ($feed_id) {
- $testfeed_params['sql'] ='AND feed_id <> '.$feed_id.' ';
- }
- if ($zcfs->getFeeds($testfeed_params, true)->f(0)) {
- throw new Exception(__('Record with same feed URL already exists.'));
- }
- if (empty($feed_name)) {
- throw new Exception(__('You must provide a name.'));
- }
- if (empty($feed_owner)) {
- throw new Exception(__('You must provide an owner.'));
- }
- if (!zoneclearFeedServer::validateURL($feed_url)) {
- throw new Exception(__('You must provide valid site URL.'));
- }
- if (!zoneclearFeedServer::validateURL($feed_feed)) {
- throw new Exception(__('You must provide valid feed URL.'));
- }
- $get_feed_cat_id = $core->blog->getCategory($feed_cat_id);
- if ($feed_cat_id != '' && !$get_feed_cat_id) {
- throw new Exception(__('You must provide valid category.'));
- }
- }
- catch (Exception $e) {
- $core->error->add($e->getMessage());
- }
- }
-
- if (!empty($_POST['action']) && $_POST['action'] == 'savefeed'
- && !$core->error->flag()
- ) {
-
- $cur = $zcfs->openCursor();
- $cur->feed_name = $feed_name;
- $cur->feed_desc = $feed_desc;
- $cur->feed_owner = $feed_owner;
- $cur->feed_tweeter = $feed_tweeter;
- $cur->feed_url = $feed_url;
- $cur->feed_feed = $feed_feed;
- $cur->feed_lang = $feed_lang;
- $cur->feed_tags = $feed_tags;
- $cur->feed_get_tags = (integer) $feed_get_tags;
- $cur->cat_id = $feed_cat_id != '' ? (integer) $feed_cat_id : null;
- $cur->feed_status = (integer) $feed_status;
- $cur->feed_upd_int = (integer) $feed_upd_int;
-
- # Update feed
- if ($feed_id) {
- try {
- # --BEHAVIOR-- adminBeforeZoneclearFeedServerFeedUpdate
- $core->callBehavior(
- 'adminBeforeZoneclearFeedServerFeedUpdate',
- $cur,
- $feed_id
- );
-
- $zcfs->updFeed($feed_id, $cur);
-
- # --BEHAVIOR-- adminAfterZoneclearFeedServerFeedUpdate
- $core->callBehavior(
- 'adminAfterZoneclearFeedServerFeedUpdate',
- $cur,
- $feed_id
- );
-
- dcPage::addSuccessNotice(
- __('Feed successfully updated.')
- );
- http::redirect(
- $p_url.'&part=feed&feed_id='.$feed_id
- );
- }
- catch (Exception $e) {
- $core->error->add($e->getMessage());
- }
- }
- else {
- try {
- # --BEHAVIOR-- adminBeforeZoneclearFeedServerFeedCreate
- $core->callBehavior(
- 'adminBeforeZoneclearFeedServerFeedCreate',
- $cur
- );
-
- $return_id = $zcfs->addFeed($cur);
-
- # --BEHAVIOR-- adminAfterZoneclearFeedServerFeedCreate
- $core->callBehavior(
- 'adminAfterZoneclearFeedServerFeedCreate',
- $cur,
- $return_id
- );
-
- dcPage::addSuccessNotice(
- __('Feed successfully created.')
- );
- http::redirect(
- $p_url.'&part=feed&feed_id='.$return_id
- );
- }
- catch (Exception $e) {
- $core->error->add($e->getMessage());
- }
- }
- }
-
- # Prepared entries list
- if ($feed_id && $can_view_page) {
- try {
- # Getting categories
- $categories = $core->blog->getCategories(array(
- 'post_type' => 'post'
- ));
-
- # Getting authors
- $users = $core->blog->getPostsUsers();
-
- # Getting dates
- $dates = $core->blog->getDates(array(
- 'type' => 'month'
- ));
-
- # Getting langs
- $langs = $core->blog->getLangs();
- }
- catch (Exception $e) {
- $core->error->add($e->getMessage());
- }
-
- # Creating filter combo boxes
- if (!$core->error->flag()) {
-
- $users_combo = array_merge(
- array('-' => ''),
- dcAdminCombos::getUsersCombo($users)
- );
-
- $categories_combo = array_merge(
- array(
- new formSelectOption('-', ''),
- new formSelectOption(__('(No cat)'), 'NULL')
- ),
- dcAdminCombos::getCategoriesCombo($categories, false)
- );
- $categories_values = array();
- foreach ($categories_combo as $cat) {
- if (isset($cat->value)) {
- $categories_values[$cat->value] = true;
- }
- }
-
- $status_combo = array_merge(
- array('-' => ''),
- dcAdminCombos::getPostStatusesCombo()
- );
-
- $selected_combo = array(
- '-' => '',
- __('Selected') => '1',
- __('Not selected') => '0'
- );
-
- $dt_m_combo = array_merge(
- array('-' => ''),
- dcAdminCombos::getDatesCombo($dates)
- );
-
- $lang_combo = array_merge(
- array('-' => ''),
- dcAdminCombos::getLangsCombo($langs,false)
- );
-
- $sortby_combo = array(
- __('Date') => 'post_dt',
- __('Title') => 'post_title',
- __('Category') => 'cat_title',
- __('Author') => 'user_id',
- __('Status') => 'post_status',
- __('Selected') => 'post_selected'
- );
-
- $order_combo = array(
- __('Descending') => 'desc',
- __('Ascending') => 'asc'
- );
- }
-
- # Posts action
- $posts_actions_page = new dcPostsActionsPage(
- $core,
- 'plugin.php',
- array(
- 'p' => 'zoneclearFeedServer',
- 'part' => 'feed',
- 'feed_id' => $feed_id,
- '_ANCHOR' => 'entries'
- )
- );
-
- if ($posts_actions_page->process()) {
- return null;
- }
-
- /* Get posts
- -------------------------------------------------------- */
- $user_id = !empty($_GET['user_id']) ? $_GET['user_id'] : '';
- $cat_id = !empty($_GET['cat_id']) ? $_GET['cat_id'] : '';
- $status = isset($_GET['status']) ? $_GET['status'] : '';
- $selected = isset($_GET['selected']) ? $_GET['selected'] : '';
- $month = !empty($_GET['month']) ? $_GET['month'] : '';
- $lang = !empty($_GET['lang']) ? $_GET['lang'] : '';
- $sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'post_dt';
- $order = !empty($_GET['order']) ? $_GET['order'] : 'desc';
-
- $show_filters = false;
-
- $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1;
- $nb_per_page = 30;
-
- if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) {
- if ($nb_per_page != $_GET['nb']) {
- $show_filters = true;
- }
- $nb_per_page = (integer) $_GET['nb'];
- }
-
- $params['limit'] = array((($page-1)*$nb_per_page), $nb_per_page);
- $params['no_content'] = true;
-
- # - User filter
- if ($user_id !== '' && in_array($user_id, $users_combo)) {
- $params['user_id'] = $user_id;
- $show_filters = true;
- }
- # - Categories filter
- if ($cat_id !== '' && in_array($cat_id, $categories_combo)) {
- $params['cat_id'] = $cat_id;
- $show_filters = true;
- }
- # - Status filter
- if ($status !== '' && in_array($status, $status_combo)) {
- $params['post_status'] = $status;
- $show_filters = true;
- }
- # - Selected filter
- if ($selected !== '' && in_array($selected, $selected_combo)) {
- $params['post_selected'] = $selected;
- $show_filters = true;
- }
- # - Month filter
- if ($month !== '' && in_array($month, $dt_m_combo)) {
- $params['post_month'] = substr($month, 4, 2);
- $params['post_year'] = substr($month, 0, 4);
- $show_filters = true;
- }
- # - Lang filter
- if ($lang !== '' && in_array($lang, $lang_combo)) {
- $params['post_lang'] = $lang;
- $show_filters = true;
- }
- # - Sortby and order filter
- if ($sortby !== '' && in_array($sortby, $sortby_combo)) {
- if ($order !== '' && in_array($order, $order_combo)){
- $params['order'] = $sortby.' '.$order;
- }
- if ($sortby != 'post_dt' || $order != 'desc') {
- $show_filters = true;
- }
- }
-
- # Get posts
- try {
- $params['feed_id'] = $feed_id;
- $posts = $zcfs->getPostsByFeed($params);
- $counter = $zcfs->getPostsByFeed($params,true);
- $post_list = new zcfsEntriesList(
- $core,
- $posts,
- $counter->f(0)
- );
- }
- catch (Exception $e) {
- $core->error->add($e->getMessage());
- }
- }
-
- # Display
- echo
- ''.__('Feeds server').''.
- ($feed_id && !$core->error->flag() ?
- dcPage::jsLoad(
- 'index.php?pf=periodical/js/postsfilter.js'
- ).
- '\n"
- : '').
- dcPage::jsPageTabs().
- $next_headlink."\n".$prev_headlink.
-
- # --BEHAVIOR-- packmanAdminHeader
- $core->callBehavior('zcfsAdminHeader', $core).
-
- ''.
-
- dcPage::breadcrumb(
- array(
- html::escapeHTML($core->blog->name) => '',
- __('Feeds server') => '',
- __('Feeds') => $p_url,
- ($feed_id ? __('Edit feed') : __('New feed')) => ''
- )
- ).
- dcPage::notices();
-
- # Feed
- if ($can_view_page) {
-
- # nav link
- if ($feed_id && ($next_link || $prev_link)) {
- echo '';
- if ($prev_link) {
- echo $prev_link;
- }
- if ($next_link && $prev_link) {
- echo ' - ';
- }
- if ($next_link) {
- echo $next_link;
- }
- echo '
';
- }
-
- echo '
- ';
- }
-
- # Entries
- if ($feed_id && $can_view_page && !$core->error->flag()) {
- echo
- ''.
-
- '
'.
-
- # Show posts
- $post_list->display($page, $nb_per_page,
-
- $p_url.
- '&part=feed'.
- '&tab=entries'.
- '&feed_id='.$feed_id.
- '&user_id='.$user_id.
- '&cat_id='.$cat_id.
- '&status='.$status.
- '&selected='.$selected.
- '&month='.$month.
- '&lang='.$lang.
- '&sortby='.$sortby.
- '&order='.$order.
- '&nb='.$nb_per_page.
- '&page=%s',
-
- '
'
- );
-
- echo
- '
';
- }
+ $feed_id = '';
+ $feed_name = '';
+ $feed_desc = '';
+ $feed_owner = '';
+ $feed_tweeter = '';
+ $feed_url = '';
+ $feed_feed = '';
+ $feed_lang = $core->auth->getInfo('user_lang');
+ $feed_tags = '';
+ $feed_get_tags = '0';
+ $feed_cat_id = '';
+ $feed_status = '0';
+ $feed_upd_int = 3600;
+
+ $can_view_page = true;
+
+ $feed_headlink = '';
+ $feed_link = '%s';
+
+ $next_link = $prev_link = $next_headlink = $prev_headlink = null;
+
+ # Combos
+ $combo_langs = l10n::getISOcodes(true);
+ $combo_status = $zcfs->getAllStatus();
+ $combo_upd_int = $zcfs->getAllUpdateInterval();
+ $combo_categories = array('-' => '');
+ try {
+ $categories = $core->blog->getCategories(array(
+ 'post_type' => 'post'
+ ));
+ while ($categories->fetch()) {
+ $combo_categories[
+ str_repeat(' ', $categories->level-1).
+ '• '.html::escapeHTML($categories->cat_title)
+ ] = $categories->cat_id;
+ }
+ }
+ catch (Exception $e) {
+ $core->error->add($e->getMessage());
+ }
+
+ # Get entry informations
+ if (!empty($_REQUEST['feed_id'])) {
+ $feed = $zcfs->getFeeds(array('feed_id' => $_REQUEST['feed_id']));
+
+ if ($feed->isEmpty()) {
+ $core->error->add(__('This feed does not exist.'));
+ $can_view_page = false;
+ }
+ else {
+ $feed_id = $feed->feed_id;
+ $feed_name = $feed->feed_name;
+ $feed_desc = $feed->feed_desc;
+ $feed_owner = $feed->feed_owner;
+ $feed_tweeter = $feed->feed_tweeter;
+ $feed_url = $feed->feed_url;
+ $feed_feed = $feed->feed_feed;
+ $feed_lang = $feed->feed_lang;
+ $feed_tags = $feed->feed_tags;
+ $feed_get_tags = $feed->feed_get_tags;
+ $feed_cat_id = $feed->cat_id;
+ $feed_status = $feed->feed_status;
+ $feed_upd_int = $feed->feed_upd_int;
+
+ $next_params = array(
+ 'sql' => 'AND feed_id < '.$feed_id.' ',
+ 'limit' => 1
+ );
+ $next_rs = $zcfs->getFeeds($next_params);
+ $prev_params = array(
+ 'sql' => 'AND feed_id > '.$feed_id.' ',
+ 'limit' => 1
+ );
+ $prev_rs = $zcfs->getFeeds($prev_params);
+
+ if (!$next_rs->isEmpty()) {
+ $next_link = sprintf($feed_link,$next_rs->feed_id,
+ html::escapeHTML($next_rs->feed_name), __('next feed').' »');
+ $next_headlink = sprintf($feed_headlink, 'next',
+ html::escapeHTML($next_rs->feed_name), $next_rs->feed_id);
+ }
+
+ if (!$prev_rs->isEmpty()) {
+ $prev_link = sprintf($feed_link,$prev_rs->feed_id,
+ html::escapeHTML($prev_rs->feed_name), '« '.__('previous feed'));
+ $prev_headlink = sprintf($feed_headlink, 'previous',
+ html::escapeHTML($prev_rs->feed_name), $prev_rs->feed_id);
+ }
+ }
+ }
+
+ if (!empty($_POST['action']) && $_POST['action'] == 'savefeed') {
+ try {
+ $feed_name = $_POST['feed_name'];
+ $feed_desc = $_POST['feed_desc'];
+ $feed_owner = $_POST['feed_owner'];
+ $feed_tweeter = $_POST['feed_tweeter'];
+ $feed_url = $_POST['feed_url'];
+ $feed_feed = $_POST['feed_feed'];
+ $feed_lang = $_POST['feed_lang'];
+ $feed_tags = $_POST['feed_tags'];
+ $feed_get_tags = empty($_POST['feed_get_tags']) ? 0 : 1;
+ $feed_cat_id = $_POST['feed_cat_id'];
+ if (isset($_POST['feed_status'])) {
+ $feed_status = (integer) $_POST['feed_status'];
+ }
+ $feed_upd_int = $_POST['feed_upd_int'];
+
+ $testfeed_params['feed_feed'] = $feed_feed;
+ if ($feed_id) {
+ $testfeed_params['sql'] ='AND feed_id <> '.$feed_id.' ';
+ }
+ if ($zcfs->getFeeds($testfeed_params, true)->f(0)) {
+ throw new Exception(__('Record with same feed URL already exists.'));
+ }
+ if (empty($feed_name)) {
+ throw new Exception(__('You must provide a name.'));
+ }
+ if (empty($feed_owner)) {
+ throw new Exception(__('You must provide an owner.'));
+ }
+ if (!zoneclearFeedServer::validateURL($feed_url)) {
+ throw new Exception(__('You must provide valid site URL.'));
+ }
+ if (!zoneclearFeedServer::validateURL($feed_feed)) {
+ throw new Exception(__('You must provide valid feed URL.'));
+ }
+ $get_feed_cat_id = $core->blog->getCategory($feed_cat_id);
+ if ($feed_cat_id != '' && !$get_feed_cat_id) {
+ throw new Exception(__('You must provide valid category.'));
+ }
+ }
+ catch (Exception $e) {
+ $core->error->add($e->getMessage());
+ }
+ }
+
+ if (!empty($_POST['action']) && $_POST['action'] == 'savefeed'
+ && !$core->error->flag()
+ ) {
+
+ $cur = $zcfs->openCursor();
+ $cur->feed_name = $feed_name;
+ $cur->feed_desc = $feed_desc;
+ $cur->feed_owner = $feed_owner;
+ $cur->feed_tweeter = $feed_tweeter;
+ $cur->feed_url = $feed_url;
+ $cur->feed_feed = $feed_feed;
+ $cur->feed_lang = $feed_lang;
+ $cur->feed_tags = $feed_tags;
+ $cur->feed_get_tags = (integer) $feed_get_tags;
+ $cur->cat_id = $feed_cat_id != '' ? (integer) $feed_cat_id : null;
+ $cur->feed_status = (integer) $feed_status;
+ $cur->feed_upd_int = (integer) $feed_upd_int;
+
+ # Update feed
+ if ($feed_id) {
+ try {
+ # --BEHAVIOR-- adminBeforeZoneclearFeedServerFeedUpdate
+ $core->callBehavior(
+ 'adminBeforeZoneclearFeedServerFeedUpdate',
+ $cur,
+ $feed_id
+ );
+
+ $zcfs->updFeed($feed_id, $cur);
+
+ # --BEHAVIOR-- adminAfterZoneclearFeedServerFeedUpdate
+ $core->callBehavior(
+ 'adminAfterZoneclearFeedServerFeedUpdate',
+ $cur,
+ $feed_id
+ );
+
+ dcPage::addSuccessNotice(
+ __('Feed successfully updated.')
+ );
+ http::redirect(
+ $p_url.'&part=feed&feed_id='.$feed_id
+ );
+ }
+ catch (Exception $e) {
+ $core->error->add($e->getMessage());
+ }
+ }
+ else {
+ try {
+ # --BEHAVIOR-- adminBeforeZoneclearFeedServerFeedCreate
+ $core->callBehavior(
+ 'adminBeforeZoneclearFeedServerFeedCreate',
+ $cur
+ );
+
+ $return_id = $zcfs->addFeed($cur);
+
+ # --BEHAVIOR-- adminAfterZoneclearFeedServerFeedCreate
+ $core->callBehavior(
+ 'adminAfterZoneclearFeedServerFeedCreate',
+ $cur,
+ $return_id
+ );
+
+ dcPage::addSuccessNotice(
+ __('Feed successfully created.')
+ );
+ http::redirect(
+ $p_url.'&part=feed&feed_id='.$return_id
+ );
+ }
+ catch (Exception $e) {
+ $core->error->add($e->getMessage());
+ }
+ }
+ }
+
+ # Prepared entries list
+ if ($feed_id && $can_view_page) {
+ try {
+ # Getting categories
+ $categories = $core->blog->getCategories(array(
+ 'post_type' => 'post'
+ ));
+
+ # Getting authors
+ $users = $core->blog->getPostsUsers();
+
+ # Getting dates
+ $dates = $core->blog->getDates(array(
+ 'type' => 'month'
+ ));
+
+ # Getting langs
+ $langs = $core->blog->getLangs();
+ }
+ catch (Exception $e) {
+ $core->error->add($e->getMessage());
+ }
+
+ # Creating filter combo boxes
+ if (!$core->error->flag()) {
+
+ $users_combo = array_merge(
+ array('-' => ''),
+ dcAdminCombos::getUsersCombo($users)
+ );
+
+ $categories_combo = array_merge(
+ array(
+ new formSelectOption('-', ''),
+ new formSelectOption(__('(No cat)'), 'NULL')
+ ),
+ dcAdminCombos::getCategoriesCombo($categories, false)
+ );
+ $categories_values = array();
+ foreach ($categories_combo as $cat) {
+ if (isset($cat->value)) {
+ $categories_values[$cat->value] = true;
+ }
+ }
+
+ $status_combo = array_merge(
+ array('-' => ''),
+ dcAdminCombos::getPostStatusesCombo()
+ );
+
+ $selected_combo = array(
+ '-' => '',
+ __('Selected') => '1',
+ __('Not selected') => '0'
+ );
+
+ $dt_m_combo = array_merge(
+ array('-' => ''),
+ dcAdminCombos::getDatesCombo($dates)
+ );
+
+ $lang_combo = array_merge(
+ array('-' => ''),
+ dcAdminCombos::getLangsCombo($langs,false)
+ );
+
+ $sortby_combo = array(
+ __('Date') => 'post_dt',
+ __('Title') => 'post_title',
+ __('Category') => 'cat_title',
+ __('Author') => 'user_id',
+ __('Status') => 'post_status',
+ __('Selected') => 'post_selected'
+ );
+
+ $order_combo = array(
+ __('Descending') => 'desc',
+ __('Ascending') => 'asc'
+ );
+ }
+
+ # Posts action
+ $posts_actions_page = new dcPostsActionsPage(
+ $core,
+ 'plugin.php',
+ array(
+ 'p' => 'zoneclearFeedServer',
+ 'part' => 'feed',
+ 'feed_id' => $feed_id,
+ '_ANCHOR' => 'entries'
+ )
+ );
+
+ if ($posts_actions_page->process()) {
+ return null;
+ }
+
+ /* Get posts
+ -------------------------------------------------------- */
+ $user_id = !empty($_GET['user_id']) ? $_GET['user_id'] : '';
+ $cat_id = !empty($_GET['cat_id']) ? $_GET['cat_id'] : '';
+ $status = isset($_GET['status']) ? $_GET['status'] : '';
+ $selected = isset($_GET['selected']) ? $_GET['selected'] : '';
+ $month = !empty($_GET['month']) ? $_GET['month'] : '';
+ $lang = !empty($_GET['lang']) ? $_GET['lang'] : '';
+ $sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'post_dt';
+ $order = !empty($_GET['order']) ? $_GET['order'] : 'desc';
+
+ $show_filters = false;
+
+ $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1;
+ $nb_per_page = 30;
+
+ if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) {
+ if ($nb_per_page != $_GET['nb']) {
+ $show_filters = true;
+ }
+ $nb_per_page = (integer) $_GET['nb'];
+ }
+
+ $params['limit'] = array((($page-1)*$nb_per_page), $nb_per_page);
+ $params['no_content'] = true;
+
+ # - User filter
+ if ($user_id !== '' && in_array($user_id, $users_combo)) {
+ $params['user_id'] = $user_id;
+ $show_filters = true;
+ }
+ # - Categories filter
+ if ($cat_id !== '' && in_array($cat_id, $categories_combo)) {
+ $params['cat_id'] = $cat_id;
+ $show_filters = true;
+ }
+ # - Status filter
+ if ($status !== '' && in_array($status, $status_combo)) {
+ $params['post_status'] = $status;
+ $show_filters = true;
+ }
+ # - Selected filter
+ if ($selected !== '' && in_array($selected, $selected_combo)) {
+ $params['post_selected'] = $selected;
+ $show_filters = true;
+ }
+ # - Month filter
+ if ($month !== '' && in_array($month, $dt_m_combo)) {
+ $params['post_month'] = substr($month, 4, 2);
+ $params['post_year'] = substr($month, 0, 4);
+ $show_filters = true;
+ }
+ # - Lang filter
+ if ($lang !== '' && in_array($lang, $lang_combo)) {
+ $params['post_lang'] = $lang;
+ $show_filters = true;
+ }
+ # - Sortby and order filter
+ if ($sortby !== '' && in_array($sortby, $sortby_combo)) {
+ if ($order !== '' && in_array($order, $order_combo)){
+ $params['order'] = $sortby.' '.$order;
+ }
+ if ($sortby != 'post_dt' || $order != 'desc') {
+ $show_filters = true;
+ }
+ }
+
+ # Get posts
+ try {
+ $params['feed_id'] = $feed_id;
+ $posts = $zcfs->getPostsByFeed($params);
+ $counter = $zcfs->getPostsByFeed($params,true);
+ $post_list = new zcfsEntriesList(
+ $core,
+ $posts,
+ $counter->f(0)
+ );
+ }
+ catch (Exception $e) {
+ $core->error->add($e->getMessage());
+ }
+ }
+
+ # Display
+ echo
+ ''.__('Feeds server').''.
+ ($feed_id && !$core->error->flag() ?
+ dcPage::jsLoad(
+ 'index.php?pf=periodical/js/postsfilter.js'
+ ).
+ '\n"
+ : '').
+ dcPage::jsPageTabs().
+ $next_headlink."\n".$prev_headlink.
+
+ # --BEHAVIOR-- packmanAdminHeader
+ $core->callBehavior('zcfsAdminHeader', $core).
+
+ ''.
+
+ dcPage::breadcrumb(
+ array(
+ html::escapeHTML($core->blog->name) => '',
+ __('Feeds server') => '',
+ __('Feeds') => $p_url,
+ ($feed_id ? __('Edit feed') : __('New feed')) => ''
+ )
+ ).
+ dcPage::notices();
+
+ # Feed
+ if ($can_view_page) {
+
+ # nav link
+ if ($feed_id && ($next_link || $prev_link)) {
+ echo '';
+ if ($prev_link) {
+ echo $prev_link;
+ }
+ if ($next_link && $prev_link) {
+ echo ' - ';
+ }
+ if ($next_link) {
+ echo $next_link;
+ }
+ echo '
';
+ }
+
+ echo '
+ ';
+ }
+
+ # Entries
+ if ($feed_id && $can_view_page && !$core->error->flag()) {
+ echo
+ ''.
+
+ '
'.
+
+ # Show posts
+ $post_list->display($page, $nb_per_page,
+
+ $p_url.
+ '&part=feed'.
+ '&tab=entries'.
+ '&feed_id='.$feed_id.
+ '&user_id='.$user_id.
+ '&cat_id='.$cat_id.
+ '&status='.$status.
+ '&selected='.$selected.
+ '&month='.$month.
+ '&lang='.$lang.
+ '&sortby='.$sortby.
+ '&order='.$order.
+ '&nb='.$nb_per_page.
+ '&page=%s',
+
+ '
'
+ );
+
+ echo
+ '
';
+ }
}
############################################################
@@ -687,162 +687,162 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
else {
- # Actions page
- $feeds_actions_page = new zcfsFeedsActionsPage(
- $core,
- 'plugin.php',
- array('p' => 'zoneclearFeedServer', 'part' => 'feeds')
- );
+ # Actions page
+ $feeds_actions_page = new zcfsFeedsActionsPage(
+ $core,
+ 'plugin.php',
+ array('p' => 'zoneclearFeedServer', 'part' => 'feeds')
+ );
- if ($feeds_actions_page->process()) {
+ if ($feeds_actions_page->process()) {
- return null;
- }
+ return null;
+ }
- # Combos
- $combo_sortby = array(
- __('Date') => 'feed_upddt',
- __('Name') => 'lowername',
- __('Frequency') => 'feed_upd_int',
- __('Date of update') => 'feed_upd_last',
- __('Status') => 'feed_status'
- );
+ # Combos
+ $combo_sortby = array(
+ __('Date') => 'feed_upddt',
+ __('Name') => 'lowername',
+ __('Frequency') => 'feed_upd_int',
+ __('Date of update') => 'feed_upd_last',
+ __('Status') => 'feed_status'
+ );
- $combo_order = array(
- __('Descending') => 'desc',
- __('Ascending') => 'asc'
- );
+ $combo_order = array(
+ __('Descending') => 'desc',
+ __('Ascending') => 'asc'
+ );
- # Prepared lists
- $show_filters = false;
- $sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'feed_upddt';
- $order = !empty($_GET['order']) ? $_GET['order'] : 'desc';
- $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1;
- $nb_per_page = 30;
- if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) {
- if ($nb_per_page != $_GET['nb']) $show_filters = true;
- $nb_per_page = (integer) $_GET['nb'];
- }
+ # Prepared lists
+ $show_filters = false;
+ $sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'feed_upddt';
+ $order = !empty($_GET['order']) ? $_GET['order'] : 'desc';
+ $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1;
+ $nb_per_page = 30;
+ if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) {
+ if ($nb_per_page != $_GET['nb']) $show_filters = true;
+ $nb_per_page = (integer) $_GET['nb'];
+ }
- $params = array();
- $params['limit'] = array((($page-1)*$nb_per_page), $nb_per_page);
+ $params = array();
+ $params['limit'] = array((($page-1)*$nb_per_page), $nb_per_page);
- if ($sortby != '' && in_array($sortby, $combo_sortby)) {
- if ($order != '' && in_array($order, $combo_order)) {
- $params['order'] = $sortby.' '.$order;
- }
- if ($sortby != 'feed_upddt' || $order != 'desc') {
- $show_filters = true;
- }
- }
+ if ($sortby != '' && in_array($sortby, $combo_sortby)) {
+ if ($order != '' && in_array($order, $combo_order)) {
+ $params['order'] = $sortby.' '.$order;
+ }
+ if ($sortby != 'feed_upddt' || $order != 'desc') {
+ $show_filters = true;
+ }
+ }
- $pager_base_url = $p_url.
- '&part=feeds'.
- '&sortby='.$sortby.
- '&order='.$order.
- '&nb='.$nb_per_page.
- '&page=%s';
+ $pager_base_url = $p_url.
+ '&part=feeds'.
+ '&sortby='.$sortby.
+ '&order='.$order.
+ '&nb='.$nb_per_page.
+ '&page=%s';
- try {
- $feeds = $zcfs->getFeeds($params);
- $feeds_counter = $zcfs->getFeeds($params, true)->f(0);
- $feeds_list = new zcfsFeedsList(
- $core,
- $feeds,
- $feeds_counter,
- $pager_base_url
- );
- }
- catch (Exception $e) {
- $core->error->add($e->getMessage());
- }
+ try {
+ $feeds = $zcfs->getFeeds($params);
+ $feeds_counter = $zcfs->getFeeds($params, true)->f(0);
+ $feeds_list = new zcfsFeedsList(
+ $core,
+ $feeds,
+ $feeds_counter,
+ $pager_base_url
+ );
+ }
+ catch (Exception $e) {
+ $core->error->add($e->getMessage());
+ }
- # Display
- echo
- ''.__('Feeds server').''.
- dcPage::jsLoad(
- 'index.php?pf=zoneclearFeedServer/js/feedsfilter.js'
- ).
- '\n".
- dcPage::jsPageTabs().
+ # Display
+ echo
+ ''.__('Feeds server').''.
+ dcPage::jsLoad(
+ 'index.php?pf=zoneclearFeedServer/js/feedsfilter.js'
+ ).
+ '\n".
+ dcPage::jsPageTabs().
- # --BEHAVIOR-- packmanAdminHeader
- $core->callBehavior('zcfsAdminHeader', $core).
+ # --BEHAVIOR-- packmanAdminHeader
+ $core->callBehavior('zcfsAdminHeader', $core).
- ''.
+ ''.
- dcPage::breadcrumb(
- array(
- html::escapeHTML($core->blog->name) => '',
- __('Feeds server') => '',
- __('Feeds') => ''
- )
- ).
- dcPage::notices().
+ dcPage::breadcrumb(
+ array(
+ html::escapeHTML($core->blog->name) => '',
+ __('Feeds server') => '',
+ __('Feeds') => ''
+ )
+ ).
+ dcPage::notices().
- ''.
- ''.
- __('New feed').'
'.
+ ''.
+ ''.
+ __('New feed').'
'.
- ''.
+ ''.
+ form::hidden(array('p'), 'zoneclearFeedServer').
+ form::hidden(array('part'), 'feeds').
+ '
'. //Opera sucks
+ ''.
- $feeds_list->feedsDisplay($page, $nb_per_page, $pager_base_url,
- ''
- );
+ $feeds_list->feedsDisplay($page, $nb_per_page, $pager_base_url,
+ ''
+ );
}
echo
diff --git a/js/feedsfilter.js b/js/feedsfilter.js
index 188882b..eb7021d 100644
--- a/js/feedsfilter.js
+++ b/js/feedsfilter.js
@@ -3,7 +3,7 @@ $(function(){
$filtersform = $('#filters-form');
$filtersform.before(''+dotclear.msg.filter_posts_list+'
')
-
+
if( dotclear.msg.show_filters == 'false' ) {
$filtersform.hide();
} else {
@@ -11,7 +11,7 @@ $(function(){
.addClass('open')
.text(dotclear.msg.cancel_the_filter);
}
-
+
$('#filter-control').click(function() {
if( $(this).hasClass('open') ) {
if( dotclear.msg.show_filters == 'true' ) {
diff --git a/js/postsfilter.js b/js/postsfilter.js
index 2a12570..6565bac 100644
--- a/js/postsfilter.js
+++ b/js/postsfilter.js
@@ -3,7 +3,7 @@ $(function(){
$filtersform = $('#filters-form');
$filtersform.before(''+dotclear.msg.filter_posts_list+'
')
-
+
if( dotclear.msg.show_filters == 'false' ) {
$filtersform.hide();
} else {
@@ -11,7 +11,7 @@ $(function(){
.addClass('open')
.text(dotclear.msg.cancel_the_filter);
}
-
+
$('#filter-control').click(function() {
if( $(this).hasClass('open') ) {
if( dotclear.msg.show_filters == 'true' ) {
diff --git a/locales/en/resources.php b/locales/en/resources.php
index c453820..920562b 100644
--- a/locales/en/resources.php
+++ b/locales/en/resources.php
@@ -13,5 +13,5 @@
if (!isset($__resources['help']['zoneclearFeedServer']))
{
- $__resources['help']['zoneclearFeedServer'] = dirname(__FILE__).'/help/zoneclearFeedServer.html';
+ $__resources['help']['zoneclearFeedServer'] = dirname(__FILE__).'/help/zoneclearFeedServer.html';
}
\ No newline at end of file
diff --git a/locales/fr/resources.php b/locales/fr/resources.php
index c453820..920562b 100644
--- a/locales/fr/resources.php
+++ b/locales/fr/resources.php
@@ -13,5 +13,5 @@
if (!isset($__resources['help']['zoneclearFeedServer']))
{
- $__resources['help']['zoneclearFeedServer'] = dirname(__FILE__).'/help/zoneclearFeedServer.html';
+ $__resources['help']['zoneclearFeedServer'] = dirname(__FILE__).'/help/zoneclearFeedServer.html';
}
\ No newline at end of file