2015-04-25 19:25:03 +00:00
< ? php
2021-09-11 09:56:57 +00:00
/**
* @ brief zoneclearFeedServer , a plugin for Dotclear 2
2021-11-06 15:30:19 +00:00
*
2021-09-11 09:56:57 +00:00
* @ package Dotclear
* @ subpackage Plugin
2021-11-06 15:30:19 +00:00
*
2021-09-11 09:56:57 +00:00
* @ author Jean - Christian Denis , BG , Pierre Van Glabeke
2021-11-06 15:30:19 +00:00
*
2021-09-11 09:56:57 +00:00
* @ copyright Jean - Christian Denis
* @ copyright GPL - 2.0 https :// www . gnu . org / licenses / gpl - 2.0 . html
*/
2015-04-25 19:25:03 +00:00
if ( ! defined ( 'DC_CONTEXT_ADMIN' )) {
2021-09-11 09:56:57 +00:00
return null ;
2021-11-06 15:30:19 +00:00
}
2015-04-25 19:25:03 +00:00
$mod_id = 'zoneclearFeedServer' ;
2021-09-12 19:14:12 +00:00
$dc_min = $this -> modules [ $mod_id ][ 'requires' ][ 0 ][ 1 ];
2015-04-25 19:25:03 +00:00
try {
2021-09-11 09:56:57 +00:00
# Check module version
if ( version_compare (
$core -> getVersion ( $mod_id ),
2021-09-12 19:14:12 +00:00
$this -> moduleInfo ( $mod_id , 'version' ),
2021-09-11 09:56:57 +00:00
'>='
)) {
return null ;
}
2015-04-25 19:25:03 +00:00
2021-09-11 09:56:57 +00:00
# Check Dotclear version
2021-11-06 15:30:19 +00:00
if ( ! method_exists ( 'dcUtils' , 'versionsCompare' )
2021-09-16 19:50:26 +00:00
|| dcUtils :: versionsCompare ( DC_VERSION , $dc_min , '<' , false )
) {
2021-09-11 09:56:57 +00:00
throw new Exception ( sprintf (
2021-11-06 15:30:19 +00:00
'%s requires Dotclear %s' ,
$mod_id ,
$dc_min
2021-09-11 09:56:57 +00:00
));
}
2015-04-25 19:25:03 +00:00
2021-09-11 09:56:57 +00:00
# Tables
$t = new dbStruct ( $core -> con , $core -> prefix );
$t -> zc_feed
2021-09-12 19:14:12 +00:00
-> 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 )
2015-04-25 19:25:03 +00:00
2021-09-11 09:56:57 +00:00
-> primary ( 'pk_zcfs' , 'feed_id' )
-> index ( 'idx_zcfs_type' , 'btree' , 'feed_type' )
-> index ( 'idx_zcfs_blog' , 'btree' , 'blog_id' );
2021-11-06 15:30:19 +00:00
$ti = new dbStruct ( $core -> con , $core -> prefix );
2021-09-11 09:56:57 +00:00
$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 );
2021-11-06 15:30:19 +00:00
$s -> put ( 'zoneclearFeedServer_user' , '' , 'string' , 'User id that has right on post' , false , true );
$s -> put ( 'zoneclearFeedServer_post_full_tpl' , serialize ([ 'post' , 'category' , 'tag' , 'archive' ]), 'string' , 'List of templates types for full feed' , false , true );
$s -> put ( 'zoneclearFeedServer_post_title_redir' , serialize ([ 'feed' ]), 'string' , 'List of templates types for redirection to original post' , false , true );
2021-09-11 09:56:57 +00:00
# Set module version
$core -> setVersion (
$mod_id ,
2021-09-12 19:14:12 +00:00
$this -> moduleInfo ( $mod_id , 'version' )
2021-09-11 09:56:57 +00:00
);
2021-11-06 15:30:19 +00:00
2021-09-11 09:56:57 +00:00
return true ;
2021-09-12 19:14:12 +00:00
} catch ( Exception $e ) {
2021-09-11 09:56:57 +00:00
$core -> error -> add ( $e -> getMessage ());
2015-04-25 19:25:03 +00:00
2021-09-11 09:56:57 +00:00
return false ;
2021-11-06 15:30:19 +00:00
}