2006-12-02 04:36:16 +00:00
< ? php
/*
2009-11-18 02:03:35 +00:00
* e107 website system
*
* Copyright ( C ) 2008 - 2009 e107 Inc ( e107 . org )
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
*
*
* $Source : / cvs_backup / e107_0 . 8 / e107_plugins / rss_menu / admin_prefs . php , v $
2010-02-10 18:18:01 +00:00
* $Revision $
* $Date $
* $Author $
2009-11-18 02:03:35 +00:00
*/
2006-12-02 04:36:16 +00:00
/*
Notes :
- array_flip method deprecated for delete item detection .
- using form handler is deprecated and present only for backwards compatibility .
- using generic terms like EDIT and DELETE in Language file is deprecated , use LAN_EDIT etc . instead .
- using terms like created , update , options etc .. deprecated should use built in terms .
- generic admin icons used . ADMIN_ICON_EDIT etc .
- using $caption = " whatever " , is unneccessary .
*/
require_once ( " ../../class2.php " );
2009-09-18 19:05:50 +00:00
if ( ! getperms ( " P " ) || ! e107 :: isInstalled ( 'rss_menu' ))
2008-12-13 12:34:53 +00:00
{
header ( " location: " . e_BASE . " index.php " );
2012-08-10 11:37:20 +00:00
exit ;
2008-12-13 12:34:53 +00:00
}
2012-12-06 21:41:53 -08:00
2009-08-15 11:55:30 +00:00
include_lan ( e_PLUGIN . " rss_menu/languages/ " . e_LANGUAGE . " _admin_rss_menu.php " );
2012-12-06 21:41:53 -08:00
// XXX THIS IS SET UP FOR LATER USE.
class rss_admin extends e_admin_dispatcher
{
protected $modes = array (
'main' => array (
'controller' => 'rss_ui' ,
'path' => null ,
'ui' => 'rss_form_ui' ,
'uipath' => null
),
);
protected $adminMenu = array (
'main/list' => array ( 'caption' => LAN_MANAGE , 'perm' => 'P' ),
'main/create' => array ( 'caption' => LAN_CREATE , 'perm' => 'P' ),
/*
'main/prefs' => array ( 'caption' => LAN_PREFS , 'perm' => 'P' ),
'main/custom' => array ( 'caption' => 'Custom Page' , 'perm' => 'P' )
*/
);
protected $adminMenuAliases = array (
'main/edit' => 'main/list'
);
protected $menuTitle = 'RSS' ;
}
2013-06-18 20:21:39 -07:00
//TODO - Use this .. .
2012-12-06 21:41:53 -08:00
class rss_ui extends e_admin_ui
{
protected $pluginTitle = 'RSS' ;
protected $pluginName = 'myplugin' ;
protected $table = 'rss' ;
protected $pid = 'rss_id' ;
protected $perPage = 10 ;
protected $fields = array ( 'checkboxes' => array ( 'title' => '' , 'type' => '' , 'data' => '' , 'width' => '5%' , 'thclass' => 'center' , 'forced' => '1' , 'class' => 'center' , 'toggle' => 'e-multiselect' , ),
'rss_id' => array ( 'title' => 'LAN_ID' , 'data' => 'int' , 'width' => '5%' , 'help' => '' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'left' , 'thclass' => 'left' , ),
'rss_name' => array ( 'title' => 'LAN_TITLE' , 'type' => 'text' , 'data' => 'int' , 'width' => 'auto' , 'help' => '' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'left' , 'thclass' => 'left' , ),
'rss_url' => array ( 'title' => 'LAN_URL' , 'type' => 'text' , 'data' => 'str' , 'width' => 'auto' , 'help' => '.{Type}.{Topic id}' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'left' , 'thclass' => 'left' , ),
'rss_topicid' => array ( 'title' => 'Topic id' , 'type' => 'text' , 'data' => 'int' , 'width' => 'auto' , 'help' => '' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'center' , 'thclass' => 'center' , ),
'rss_path' => array ( 'title' => 'Path' , 'type' => 'text' , 'data' => 'int' , 'width' => 'auto' , 'help' => '' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'left' , 'thclass' => 'left' , ),
'rss_text' => array ( 'title' => 'Text' , 'type' => 'textarea' , 'data' => 'str' , 'width' => 'auto' , 'help' => '' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'center' , 'thclass' => 'center' , ),
'rss_datestamp' => array ( 'title' => 'LAN_DATESTAMP' , 'type' => 'datestamp' , 'data' => 'int' , 'width' => 'auto' , 'filter' => true , 'help' => '' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'left' , 'thclass' => 'left' , ),
'rss_class' => array ( 'title' => 'LAN_VISIBILITY' , 'type' => 'method' , 'data' => 'int' , 'width' => 'auto' , 'batch' => true , 'filter' => true , 'help' => '' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'left' , 'thclass' => 'left' , ),
'rss_limit' => array ( 'title' => 'Limit' , 'type' => 'number' , 'data' => 'int' , 'width' => 'auto' , 'help' => '' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'left' , 'thclass' => 'left' , ),
'options' => array ( 'title' => 'LAN_OPTIONS' , 'type' => null , 'data' => '' , 'width' => '10%' , 'thclass' => 'center last' , 'class' => 'center last' , 'forced' => '1' , ),
);
protected $fieldpref = array ( 'checkboxes' , 'rss_name' , 'rss_url' , 'rss_topicid' , 'rss_path' , 'rss_class' , 'options' );
/*
protected = array (
'pref_type' => array ( 'title' => 'type' , 'type' => 'text' , 'data' => 'string' , 'validate' => true ),
'pref_folder' => array ( 'title' => 'folder' , 'type' => 'boolean' , 'data' => 'integer' ),
'pref_name' => array ( 'title' => 'name' , 'type' => 'text' , 'data' => 'string' , 'validate' => 'regex' , 'rule' => '#^[\w]+$#i' , 'help' => 'allowed characters are a-zA-Z and underscore' )
);
// optional
public function init ()
{
}
public function customPage ()
{
$ns = e107 :: getRender ();
$text = 'Hello World!' ;
$ns -> tablerender ( 'Hello' , $text );
}
*/
}
class rss_form_ui extends e_admin_form_ui
{
// Custom Method/Function
function rss_class ( $curVal , $mode )
{
$frm = e107 :: getForm ();
$array = array ( RSS_LAN_ADMIN_21 , RSS_LAN_ADMIN_22 , RSS_LAN_ADMIN_23 );
switch ( $mode )
{
case 'read' : // List Page
return vartrue ( $array [ $curVal ]);
break ;
case 'write' : // Edit Page
2013-04-25 17:29:46 -07:00
return $frm -> select ( 'rss_class' , $array , $curVal );
2012-12-06 21:41:53 -08:00
break ;
case 'filter' :
case 'batch' :
return $array ;
break ;
}
}
}
/*
new rss_admin ();
require_once ( e_ADMIN . " auth.php " );
e107 :: getAdminUI () -> runPage ();
require_once ( e_ADMIN . " footer.php " );
exit ;
*/
2006-12-02 04:36:16 +00:00
require_once ( e_ADMIN . " auth.php " );
2009-07-07 07:25:27 +00:00
$imagedir = e_IMAGE . " admin_images/ " ;
2006-12-02 04:36:16 +00:00
require_once ( e_PLUGIN . 'rss_menu/rss_shortcodes.php' );
$rss = new rss ;
global $tp ;
2012-11-27 19:56:35 -08:00
$mes = e107 :: getMessage ();
2006-12-02 04:36:16 +00:00
2009-09-18 19:05:50 +00:00
// Delete entry
2008-12-13 12:34:53 +00:00
if ( isset ( $_POST [ 'delete' ]))
{
2006-12-02 04:36:16 +00:00
$d_idt = array_keys ( $_POST [ 'delete' ]);
2008-12-13 12:34:53 +00:00
$message = ( $sql -> db_Delete ( " rss " , " rss_id= " . intval ( $d_idt [ 0 ]))) ? LAN_DELETED : LAN_DELETED_FAILED ;
$admin_log -> log_event ( 'RSS_01' , 'ID: ' . intval ( $d_idt [ 0 ]) . ' - ' . $message , E_LOG_INFORMATIVE , '' );
2006-12-02 04:36:16 +00:00
$e107cache -> clear ( " rss " );
}
2009-09-18 19:05:50 +00:00
// Create rss feed
2008-12-13 12:34:53 +00:00
if ( isset ( $_POST [ 'create_rss' ]))
{
2006-12-02 04:36:16 +00:00
$message = $rss -> dbrss ( " create " );
}
2009-09-18 19:05:50 +00:00
// Update rss feed
2008-12-13 12:34:53 +00:00
if ( isset ( $_POST [ 'update_rss' ]))
{
2006-12-02 04:36:16 +00:00
$message = $rss -> dbrss ( " update " );
}
2009-09-18 19:05:50 +00:00
// Import rss feed
2008-12-13 12:34:53 +00:00
if ( isset ( $_POST [ 'import_rss' ]))
{
2006-12-02 04:36:16 +00:00
$message = $rss -> dbrssimport ();
}
2009-09-18 19:05:50 +00:00
// Update_limit
2008-12-13 12:34:53 +00:00
if ( isset ( $_POST [ 'update_limit' ]))
{
2006-12-02 04:36:16 +00:00
$message = $rss -> dbrsslimit ();
}
2008-12-13 12:34:53 +00:00
2009-09-18 19:05:50 +00:00
// Update options
2008-12-13 12:34:53 +00:00
if ( isset ( $_POST [ 'updatesettings' ]))
{
2006-12-02 04:36:16 +00:00
$message = $rss -> dboptions ();
}
2009-09-18 19:05:50 +00:00
// Config check
2008-12-13 12:34:53 +00:00
if ( $rss -> file_check ())
{
2009-09-18 19:05:50 +00:00
$message = RSS_LAN_ERROR_2 ; // Space found in file.
2006-12-02 04:36:16 +00:00
}
2009-09-18 19:05:50 +00:00
// Render message
2008-12-13 12:34:53 +00:00
if ( isset ( $message ))
{
2012-11-27 19:56:35 -08:00
$mes -> add ( $message );
// $rss->show_message('', $message);
2006-12-02 04:36:16 +00:00
}
2009-09-18 19:05:50 +00:00
// Get template
2012-11-27 19:56:35 -08:00
/*
2008-12-13 12:34:53 +00:00
if ( is_readable ( THEME . " rss_template.php " ))
{
2006-12-02 04:36:16 +00:00
require_once ( THEME . " rss_template.php " );
2008-12-13 12:34:53 +00:00
}
else
{
2006-12-02 04:36:16 +00:00
require_once ( e_PLUGIN . " rss_menu/rss_template.php " );
2012-11-27 19:56:35 -08:00
} */
$frm = e107 :: getForm ();
// Admin : rss listing
if ( ! isset ( $RSS_ADMIN_LIST_HEADER ))
{
$RSS_ADMIN_LIST_HEADER = "
< div style = 'text-align:center;' >
< form action = '".e_SELF.(e_QUERY ? "?".e_QUERY : "")."' id = 'dataform' method = 'post' >
< table class = 'table adminlist' >
< thead >
< tr >
< th style = 'white-space:nowrap;' > { RSS_ADMIN_CAPTION = id , RSS_LAN_ADMIN_2 } </ th >
< th style = 'white-space:nowrap;' > { RSS_ADMIN_CAPTION = name , RSS_LAN_ADMIN_4 } </ th >
< th style = 'white-space:nowrap;' > { RSS_ADMIN_CAPTION = path , RSS_LAN_ADMIN_3 } </ th >
< th style = 'white-space:nowrap;' > { RSS_ADMIN_CAPTION = url , RSS_LAN_ADMIN_5 } </ th >
< th style = 'white-space:nowrap;' > " .RSS_LAN_ADMIN_12. " </ th >
< th style = 'white-space:nowrap;' > { RSS_ADMIN_CAPTION = limit , RSS_LAN_ADMIN_7 } </ th >
< th style = 'white-space:nowrap;' > " .LAN_OPTIONS. " </ th >
</ tr >
</ thead >
< tbody > " ;
}
if ( ! isset ( $RSS_ADMIN_LIST_TABLE ))
{
$RSS_ADMIN_LIST_TABLE = "
< tr >
< td > { RSS_ADMIN_ID } </ td >
< td > { RSS_ADMIN_NAME } </ td >
< td > { RSS_ADMIN_PATH } </ td >
< td > { RSS_ADMIN_URL } </ td >
< td > { RSS_ADMIN_TOPICID } </ td >
< td > { RSS_ADMIN_LIMIT } </ td >
< td class = 'center' > { RSS_ADMIN_OPTIONS } </ td >
</ tr > " ;
}
if ( ! isset ( $RSS_ADMIN_LIST_FOOTER ))
{
$RSS_ADMIN_LIST_FOOTER = "
< tr >
< td class = 'buttons-bar center' colspan = '7' >
{ RSS_ADMIN_LIMITBUTTON }
</ td >
</ tr >
</ tbody >
</ table >
</ form >
</ div > " ;
}
// Admin : rss create/edit
if ( ! isset ( $RSS_ADMIN_CREATE_TABLE ))
{
$RSS_ADMIN_CREATE_TABLE = "
< form action = '".e_SELF.(e_QUERY ? "?".e_QUERY : "")."' id = 'dataform' method = 'post' >
< table class = 'table adminform' >
< tr >
< td style = 'width:12%' > " .RSS_LAN_ADMIN_4. " </ td >
< td > { RSS_ADMIN_FORM_NAME } </ td >
</ tr >
< tr >
< td > " .RSS_LAN_ADMIN_5. " </ td >
< td > { RSS_ADMIN_FORM_URL } </ td >
</ tr >
< tr >
< td > " .RSS_LAN_ADMIN_12. " </ td >
< td > { RSS_ADMIN_FORM_TOPICID } </ td >
</ tr >
< tr >
< td > " .RSS_LAN_ADMIN_3. " </ td >
< td > { RSS_ADMIN_FORM_PATH } </ td >
</ tr >
< tr >
< td > " .RSS_LAN_ADMIN_6. " </ td >
< td > { RSS_ADMIN_FORM_TEXT } </ td >
</ tr >
< tr >
< td > " .RSS_LAN_ADMIN_7. " </ td >
< td > { RSS_ADMIN_FORM_LIMIT } </ td >
</ tr >
< tr >
< td > " .RSS_LAN_ADMIN_8. " </ td >
< td > { RSS_ADMIN_FORM_CLASS } </ td >
</ tr >
< tr >
2012-12-08 15:52:40 +01:00
< td colspan = '2' style = 'text-align:center;' > { RSS_ADMIN_FORM_CREATEBUTTON } </ td >
2012-11-27 19:56:35 -08:00
</ tr >
</ table >
</ form >
</ div > " ;
}
// Admin : rss options
if ( ! isset ( $RSS_ADMIN_OPTIONS_TABLE ))
{
$RSS_ADMIN_OPTIONS_TABLE = "
< form action = '".e_SELF.(e_QUERY ? "?".e_QUERY : "")."' id = 'dataform' method = 'post' >
2012-12-08 15:52:40 +01:00
< table class = 'table adminform' >
2012-11-27 19:56:35 -08:00
< tr >
< td > " .RSS_LAN_ADMIN_13. " </ td >
< td >
2012-12-08 15:52:40 +01:00
< input type = 'checkbox' name = 'rss_othernews' value = '1' " .(vartrue( $pref['rss_othernews'] ) == 1 ? " checked = 'checked' " : " " ). " />
2012-11-27 19:56:35 -08:00
</ td >
</ tr >
< tr >
< td > " .RSS_LAN_ADMIN_19. " </ td >
< td >
2012-12-08 15:52:40 +01:00
< input type = 'checkbox' name = 'rss_summarydiz' value = '1' " .(vartrue( $pref['rss_summarydiz'] ) == 1 ? " checked = 'checked' " : " " ). " />
2012-11-27 19:56:35 -08:00
</ td >
</ tr >
< tr >
< td > " .RSS_LAN_ADMIN_33. " </ td >
< td >
2012-12-08 15:52:40 +01:00
< input type = 'checkbox' name = 'rss_shownewsimage' value = '1' " .(vartrue( $pref['rss_shownewsimage'] ) == 1 ? " checked = 'checked' " : " " ). " />
2012-11-27 19:56:35 -08:00
</ td >
</ tr >
</ table >
< div class = 'buttons-bar center' >
2012-12-08 15:52:40 +01:00
" . $frm->admin_button ('updatesettings', LAN_UPDATE, 'update'). "
2012-11-27 19:56:35 -08:00
</ div >
2012-12-08 15:52:40 +01:00
</ form > " ;
2012-11-27 19:56:35 -08:00
}
// Admin : rss import
if ( ! isset ( $RSS_ADMIN_IMPORT_HEADER ))
{
$RSS_ADMIN_IMPORT_HEADER = "
< form action = '".e_SELF."' id = 'imlistform' method = 'post' >
2012-12-08 15:52:40 +01:00
< table class = 'table adminform' >
2012-11-27 19:56:35 -08:00
< tr >
< th > " .RSS_LAN_ADMIN_16. " </ td >
< th > " .RSS_LAN_ADMIN_3. " </ td >
2013-06-18 20:21:39 -07:00
< th > " .LAN_NAME. " </ td >
2012-11-27 19:56:35 -08:00
< th > " .RSS_LAN_ADMIN_5. " </ td >
< th > " .RSS_LAN_ADMIN_12. " </ td >
</ tr > " ;
}
if ( ! isset ( $RSS_ADMIN_IMPORT_TABLE ))
{
$RSS_ADMIN_IMPORT_TABLE = "
< tr >
< td > { RSS_ADMIN_IMPORT_CHECK } </ td >
< td > { RSS_ADMIN_IMPORT_PATH } </ td >
< td >< b > { RSS_ADMIN_IMPORT_NAME } </ b >< br /> { RSS_ADMIN_IMPORT_TEXT } </ td >
< td > { RSS_ADMIN_IMPORT_URL } </ td >
< td > { RSS_ADMIN_IMPORT_TOPICID } </ td >
</ tr > " ;
}
if ( ! isset ( $RSS_ADMIN_IMPORT_FOOTER ))
{
$RSS_ADMIN_IMPORT_FOOTER = "
</ table >
< div class = 'buttons-bar center' >
2012-12-08 15:52:40 +01:00
" . $frm->admin_button ('import_rss',RSS_LAN_ADMIN_17,'submit'). "
2012-11-27 19:56:35 -08:00
</ div >
</ form >
2012-12-08 15:52:40 +01:00
" ;
2006-12-02 04:36:16 +00:00
}
2009-09-18 19:05:50 +00:00
// Listing
2008-12-13 12:34:53 +00:00
if ( e_QUERY )
{
2006-12-02 04:36:16 +00:00
$qs = explode ( " . " , e_QUERY );
}
2008-12-13 12:34:53 +00:00
$action = varset ( $qs [ 0 ], 'list' );
$field = varset ( $qs [ 1 ], '' );
$feedID = intval ( varset ( $qs [ 2 ], 0 ));
2009-09-18 19:05:50 +00:00
switch ( $action )
{
case 'create' :
if ( $_POST )
{ // List
2008-12-13 12:34:53 +00:00
$rss -> rssadminlist ();
2009-09-18 19:05:50 +00:00
}
else
{ // Create
$rss -> rssadmincreate ( $field , $feedID );
}
break ;
case 'import' :
$rss -> rssadminimport ();
break ;
case 'options' :
$rss -> rssadminoptions ();
break ;
case 'r3' :
$rss -> show_message ( '' , RSS_LAN_ADMIN_31 ); // Intentionally fall straight through after showing message
case 'list' :
default :
$rss -> rssadminlist ();
}
2008-12-13 12:34:53 +00:00
2006-12-02 04:36:16 +00:00
require_once ( e_ADMIN . " footer.php " );
// ##### Display options --------------------------------------------------------------------------
2008-12-13 12:34:53 +00:00
function admin_prefs_adminmenu ()
{
2012-11-27 19:56:35 -08:00
global $sql ;
$qs = explode ( " . " , e_QUERY );
2006-12-02 04:36:16 +00:00
2008-12-13 12:34:53 +00:00
$act = varset ( $qs [ 0 ], 'list' );
2006-12-02 04:36:16 +00:00
$var [ 'list' ][ 'text' ] = RSS_LAN_ADMINMENU_2 ;
$var [ 'list' ][ 'link' ] = e_SELF . " ?list " ;
$var [ 'create' ][ 'text' ] = LAN_CREATE ;
$var [ 'create' ][ 'link' ] = e_SELF . " ?create " ;
$var [ 'import' ][ 'text' ] = RSS_LAN_ADMINMENU_4 ;
$var [ 'import' ][ 'link' ] = e_SELF . " ?import " ;
$var [ 'options' ][ 'text' ] = LAN_OPTIONS ;
$var [ 'options' ][ 'link' ] = e_SELF . " ?options " ;
show_admin_menu ( RSS_LAN_ADMINMENU_1 , $act , $var );
}
// ##### End --------------------------------------------------------------------------------------
2008-12-13 12:34:53 +00:00
class rss
{
2009-09-18 19:05:50 +00:00
// Check for config
2008-12-13 12:34:53 +00:00
function file_check ()
{
2006-12-02 04:36:16 +00:00
$arrays = file_get_contents ( e_BASE . " e107_config.php " );
2008-12-13 12:34:53 +00:00
$arrays2 = file_get_contents ( e_PLUGIN . " rss_menu/languages/ " . e_LANGUAGE . " _admin_rss_menu.php " );
if ( $arrays [ 0 ] != " < " || $arrays2 [ 0 ] != " < " )
{
2006-12-02 04:36:16 +00:00
return TRUE ;
}
2008-12-13 12:34:53 +00:00
return FALSE ;
2006-12-02 04:36:16 +00:00
}
2009-09-18 19:05:50 +00:00
// Admin : list : existing rss feeds
2008-12-13 12:34:53 +00:00
function rssadminlist ()
{
2012-11-27 19:56:35 -08:00
$tp = e107 :: getParser ();
$mes = e107 :: getMessage ();
$ns = e107 :: getRender ();
$sql = e107 :: getDb ();
global $field , $sort , $rss_shortcodes , $row , $RSS_ADMIN_LIST_HEADER , $RSS_ADMIN_LIST_TABLE , $RSS_ADMIN_LIST_FOOTER ;
2006-12-02 04:36:16 +00:00
$fieldstag = array ( 'id' => 'rss_id' , 'path' => 'rss_path' , 'name' => 'rss_name' , 'url' => 'rss_url' , 'limit' => 'rss_limit' );
$order = ( isset ( $fieldstag [ $field ])) ? " ORDER BY " . $fieldstag [ $field ] . " " . $sort : " ORDER BY rss_id " ;
$query = " SELECT * FROM #rss " . $order ;
if ( ! $sql -> db_Select_gen ( $query ))
{
$this -> show_message ( LAN_ERROR , RSS_LAN_ERROR_3 );
}
else
{
$text = $tp -> parseTemplate ( $RSS_ADMIN_LIST_HEADER , FALSE , $rss_shortcodes );
while ( $row = $sql -> db_Fetch ())
{
$text .= $tp -> parseTemplate ( $RSS_ADMIN_LIST_TABLE , FALSE , $rss_shortcodes );
}
$text .= $tp -> parseTemplate ( $RSS_ADMIN_LIST_FOOTER , FALSE , $rss_shortcodes );
2012-11-27 19:56:35 -08:00
$ns -> tablerender ( RSS_LAN_ADMIN_1 , $mes -> render () . $text );
2006-12-02 04:36:16 +00:00
}
}
2009-09-18 19:05:50 +00:00
// Create or edit - put up a form
2008-12-13 12:34:53 +00:00
function rssadmincreate ( $action , $id = 0 )
{
2012-11-27 19:56:35 -08:00
$mes = e107 :: getMessage ();
$ns = e107 :: getRender ();
$tp = e107 :: getParser ();
$sql = e107 :: getDb ();
global $rss_shortcodes , $row , $RSS_ADMIN_CREATE_TABLE ;
2006-12-02 04:36:16 +00:00
2008-12-13 12:34:53 +00:00
if (( $action == " edit " ) && $id )
{
if ( ! $sql -> db_Select ( " rss " , " * " , " rss_id= " . $id ))
{
2006-12-02 04:36:16 +00:00
$this -> show_message ( LAN_ERROR , RSS_LAN_ERROR_5 );
2008-12-13 12:34:53 +00:00
}
else
{
2006-12-02 04:36:16 +00:00
$row = $sql -> db_Fetch ();
$row [ 'rss_name' ] = $tp -> toForm ( $row [ 'rss_name' ]);
$row [ 'rss_path' ] = $tp -> toForm ( $row [ 'rss_path' ]);
$row [ 'rss_url' ] = $tp -> toForm ( $row [ 'rss_url' ]);
$row [ 'rss_text' ] = $tp -> toForm ( $row [ 'rss_text' ]);
}
}
2012-11-27 19:56:35 -08:00
$text = $tp -> parseTemplate ( $RSS_ADMIN_CREATE_TABLE , FALSE , $rss_shortcodes );
$ns -> tablerender ( RSS_LAN_ADMIN_10 , $mes -> render () . $text );
2006-12-02 04:36:16 +00:00
}
2009-09-18 19:05:50 +00:00
// Import - put up the list of possible feeds to import
2008-12-13 12:34:53 +00:00
function rssadminimport ()
{
2012-11-27 19:56:35 -08:00
$sql = e107 :: getDb ();
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
$tp = e107 :: getParser ();
global $i , $rss_shortcodes , $feed , $pref ;
2006-12-02 04:36:16 +00:00
global $RSS_ADMIN_IMPORT_HEADER , $RSS_ADMIN_IMPORT_TABLE , $RSS_ADMIN_IMPORT_FOOTER ;
$sqli = new db ;
$feedlist = array ();
2009-09-18 19:05:50 +00:00
// News
2006-12-02 04:36:16 +00:00
$feed [ 'name' ] = ADLAN_0 ;
2009-09-18 19:05:50 +00:00
$feed [ 'url' ] = 'news' ; // The identifier for the rss feed url
$feed [ 'topic_id' ] = '' ; // The topic_id, empty on default (to select a certain category)
$feed [ 'path' ] = 'news' ; // This is the plugin path location
2006-12-02 04:36:16 +00:00
$feed [ 'text' ] = RSS_PLUGIN_LAN_7 ;
$feed [ 'class' ] = '0' ;
$feed [ 'limit' ] = '9' ;
$feedlist [] = $feed ;
2009-09-18 19:05:50 +00:00
// News categories
2008-12-13 12:34:53 +00:00
if ( $sqli -> db_Select ( " news_category " , " * " , " category_id!='' ORDER BY category_name " ))
{
while ( $rowi = $sqli -> db_Fetch ())
{
2006-12-02 04:36:16 +00:00
$feed [ 'name' ] = ADLAN_0 . ' > ' . $rowi [ 'category_name' ];
$feed [ 'url' ] = 'news' ;
$feed [ 'topic_id' ] = $rowi [ 'category_id' ];
$feed [ 'path' ] = 'news' ;
$feed [ 'text' ] = RSS_PLUGIN_LAN_10 . ' ' . $rowi [ 'category_name' ];
$feed [ 'class' ] = '0' ;
$feed [ 'limit' ] = '9' ;
2009-09-18 19:05:50 +00:00
// $feed['exclude_class'] = '';
2006-12-02 04:36:16 +00:00
$feedlist [] = $feed ;
}
}
2009-09-18 19:05:50 +00:00
/* // Download
2006-12-02 04:36:16 +00:00
$feed [ 'name' ] = ADLAN_24 ;
$feed [ 'url' ] = 'download' ;
$feed [ 'topic_id' ] = '' ;
$feed [ 'path' ] = 'download' ;
$feed [ 'text' ] = RSS_PLUGIN_LAN_8 ;
$feed [ 'class' ] = '0' ;
$feed [ 'limit' ] = '9' ;
$feedlist [] = $feed ;
2009-09-18 19:05:50 +00:00
// Download categories
2008-12-13 12:34:53 +00:00
if ( $sqli -> db_Select ( " download_category " , " * " , " download_category_id!='' ORDER BY download_category_order " ))
{
while ( $rowi = $sqli -> db_Fetch ())
{
2006-12-02 04:36:16 +00:00
$feed [ 'name' ] = ADLAN_24 . ' > ' . $rowi [ 'download_category_name' ];
$feed [ 'url' ] = 'download' ;
$feed [ 'topic_id' ] = $rowi [ 'download_category_id' ];
$feed [ 'path' ] = 'download' ;
$feed [ 'text' ] = RSS_PLUGIN_LAN_11 . ' ' . $rowi [ 'download_category_name' ];
$feed [ 'class' ] = '0' ;
$feed [ 'limit' ] = '9' ;
$feedlist [] = $feed ;
}
}
2009-09-18 19:05:50 +00:00
*/
// Comments
2006-12-02 04:36:16 +00:00
$feed [ 'name' ] = RSS_PLUGIN_LAN_14 ;
$feed [ 'url' ] = 'comments' ;
$feed [ 'topic_id' ] = '' ;
$feed [ 'path' ] = 'comments' ;
$feed [ 'text' ] = RSS_PLUGIN_LAN_9 ;
$feed [ 'class' ] = '0' ;
$feed [ 'limit' ] = '9' ;
$feedlist [] = $feed ;
2009-09-18 19:05:50 +00:00
// Plugin rss feed, using e_rss.php in plugin folder
2006-12-02 04:36:16 +00:00
$plugin_feedlist = array ();
foreach ( $pref [ 'e_rss_list' ] as $val )
{
2013-06-18 20:21:39 -07:00
$eplug_rss_feed = array ();
2008-12-13 12:34:53 +00:00
if ( is_readable ( e_PLUGIN . $val . " /e_rss.php " ))
{
2006-12-02 04:36:16 +00:00
require_once ( e_PLUGIN . $val . " /e_rss.php " );
2013-06-18 20:21:39 -07:00
$className = $val . " _rss " ;
$data = false ;
if ( ! $data = e107 :: callMethod ( $className , 'config' ))
{
$data = $eplug_rss_feed ;
}
foreach ( $data as $v )
{
2013-06-18 21:12:47 -07:00
$v [ 'path' ] = $val ;
2013-06-18 20:21:39 -07:00
array_push ( $plugin_feedlist , $v );
}
2006-12-02 04:36:16 +00:00
}
}
$feedlist = array_merge ( $feedlist , $plugin_feedlist );
2013-06-18 20:21:39 -07:00
2013-06-18 21:12:47 -07:00
// print_a($feedlist);
2006-12-02 04:36:16 +00:00
$render = FALSE ;
$i = 0 ;
$text = $RSS_ADMIN_IMPORT_HEADER ;
2008-12-13 12:34:53 +00:00
foreach ( $feedlist as $k => $feed )
{
2006-12-02 04:36:16 +00:00
$feed [ 'topic_id' ] = $tp -> toDB ( $feed [ 'topic_id' ]);
$feed [ 'url' ] = $tp -> toDB ( $feed [ 'url' ]);
2009-09-18 19:05:50 +00:00
// Check if feed is not yet present
2013-06-18 20:21:39 -07:00
if ( ! $sql -> select ( " rss " , " * " , " rss_path=' " . $feed [ 'path' ] . " ' AND rss_url=' " . $feed [ 'url' ] . " ' AND rss_topicid=' " . $feed [ 'topic_id' ] . " ' " ))
2006-12-02 04:36:16 +00:00
{
$render = TRUE ;
$text .= $tp -> parseTemplate ( $RSS_ADMIN_IMPORT_TABLE , FALSE , $rss_shortcodes );
$i ++ ;
}
}
$text .= $tp -> parseTemplate ( $RSS_ADMIN_IMPORT_FOOTER , FALSE , $rss_shortcodes );
2008-12-13 12:34:53 +00:00
if ( ! $render )
{
2006-12-02 04:36:16 +00:00
$this -> show_message ( RSS_LAN_ADMIN_11 , RSS_LAN_ERROR_6 );
2008-12-13 12:34:53 +00:00
}
else
{
2012-11-27 19:56:35 -08:00
$ns -> tablerender ( RSS_LAN_ADMIN_11 , $mes -> render () . $text );
2006-12-02 04:36:16 +00:00
}
}
2009-09-18 19:05:50 +00:00
// Options - display form
2008-12-13 12:34:53 +00:00
function rssadminoptions ()
{
2012-11-27 19:56:35 -08:00
$mes = e107 :: getMessage ();
$ns = e107 :: getRender ();
$tp = e107 :: getParser ();
global $rss_shortcodes , $row , $RSS_ADMIN_OPTIONS_TABLE ;
2006-12-02 04:36:16 +00:00
$text = $tp -> parseTemplate ( $RSS_ADMIN_OPTIONS_TABLE , FALSE , $rss_shortcodes );
2012-11-27 19:56:35 -08:00
$ns -> tablerender ( LAN_OPTIONS , $mes -> render () . $text );
2006-12-02 04:36:16 +00:00
return ;
}
2009-09-18 19:05:50 +00:00
// Render message
2008-12-13 12:34:53 +00:00
function show_message ( $caption = '' , $text = '' )
{
2006-12-02 04:36:16 +00:00
global $ns ;
$ns -> tablerender ( $caption , " <div style='text-align:center'><b> $text </b></div> " );
}
2009-09-18 19:05:50 +00:00
// Db:create/update
2008-12-13 12:34:53 +00:00
function dbrss ( $mode = 'create' )
{
global $sql , $ns , $tp , $e107cache , $admin_log ;
2006-12-02 04:36:16 +00:00
2008-12-13 12:34:53 +00:00
if ( $_POST [ 'rss_name' ] && $_POST [ 'rss_url' ] && $_POST [ 'rss_path' ])
{
$rssVals = array ();
$rssVals [ 'rss_name' ] = $tp -> toDB ( trim ( $_POST [ 'rss_name' ]));
$rssVals [ 'rss_url' ] = $tp -> toDB ( $_POST [ 'rss_url' ]);
$rssVals [ 'rss_topicid' ] = $tp -> toDB ( $_POST [ 'rss_topicid' ]);
$rssVals [ 'rss_path' ] = $tp -> toDB ( $_POST [ 'rss_path' ]);
$rssVals [ 'rss_text' ] = $tp -> toDB ( $_POST [ 'rss_text' ]);
$rssVals [ 'rss_class' ] = ( intval ( $_POST [ 'rss_class' ]) ? intval ( $_POST [ 'rss_class' ]) : '0' );
$rssVals [ 'rss_limit' ] = intval ( $_POST [ 'rss_limit' ]);
2009-09-18 19:05:50 +00:00
// $rssVals['rss_exclude_class'] = intval($_POST['rss_exclude_class']);
2008-12-13 12:34:53 +00:00
if ( isset ( $_POST [ 'rss_datestamp' ]) && $_POST [ 'rss_datestamp' ] != '' )
{
$rssVals [ 'rss_datestamp' ] = intval ( $_POST [ 'rss_datestamp' ]);
}
else
{
$rssVals [ 'rss_datestamp' ] = time ();
}
2006-12-02 04:36:16 +00:00
2008-12-13 12:34:53 +00:00
switch ( $mode )
{
case 'create' :
$message = ( $sql -> db_Insert ( 'rss' , $rssVals )) ? LAN_CREATED : LAN_CREATED_FAILED ;
$admin_log -> logArrayAll ( 'RSS_02' , $rssVals , $message );
$e107cache -> clear ( 'rss' );
break ;
case 'update' :
$message = ( $sql -> db_UpdateArray ( 'rss' , $rssVals , " WHERE rss_id = " . intval ( $_POST [ 'rss_id' ]))) ? LAN_UPDATED : LAN_UPDATED_FAILED ;
$admin_log -> logArrayAll ( 'RSS_03' , $rssVals , $message );
$e107cache -> clear ( 'rss' );
break ;
2006-12-02 04:36:16 +00:00
}
2008-12-13 12:34:53 +00:00
}
else
{
2006-12-02 04:36:16 +00:00
$message = RSS_LAN_ERROR_7 ;
}
return $message ;
}
2009-09-18 19:05:50 +00:00
// Import rss feeds
2008-12-13 12:34:53 +00:00
function dbrssimport ()
{
global $sql , $tp , $admin_log ;
2006-12-02 04:36:16 +00:00
foreach ( $_POST [ 'importid' ] as $key => $value )
{
2008-12-13 12:34:53 +00:00
$rssVals = array ();
$rssVals [ 'rss_topicid' ] = $tp -> toDB ( varset ( $_POST [ 'topic_id' ][ $key ], '' ));
$rssVals [ 'rss_url' ] = $tp -> toDB ( varset ( $_POST [ 'url' ][ $key ], '' ));
$rssVals [ 'rss_path' ] = $tp -> toDB ( varset ( $_POST [ 'path' ][ $key ], '' ));
$rssVals [ 'rss_name' ] = $tp -> toDB ( varset ( $_POST [ 'name' ][ $key ], '' ));
$rssVals [ 'rss_text' ] = $tp -> toDB ( varset ( $_POST [ 'text' ][ $key ], '' ));
$rssVals [ 'rss_datestamp' ] = time ();
$rssVals [ 'rss_class' ] = intval ( varset ( $_POST [ 'class' ][ $key ], '0' ));
$rssVals [ 'rss_limit' ] = intval ( varset ( $_POST [ 'limit' ][ $key ], '0' ));
$sql -> db_Insert ( " rss " , $rssVals );
$admin_log -> logArrayAll ( 'RSS_04' , $rssVals );
2006-12-02 04:36:16 +00:00
}
$message = count ( $_POST [ 'importid' ]) . " " . RSS_LAN_ADMIN_18 ;
return $message ;
}
2008-12-13 12:34:53 +00:00
function dbrsslimit ()
{
global $sql , $tp , $admin_log ;
$limitVals = array ();
2006-12-02 04:36:16 +00:00
foreach ( $_POST [ 'limit' ] as $key => $value )
{
2008-12-13 12:34:53 +00:00
$key = intval ( $key );
$value = intval ( $value );
$limitVals [ $key ] = $value ;
$sql -> db_Update ( " rss " , " rss_limit = " . $value . " WHERE rss_id = " . $key );
2006-12-02 04:36:16 +00:00
}
2008-12-13 12:34:53 +00:00
$admin_log -> logArrayAll ( 'RSS_05' , $limitVals );
2006-12-02 04:36:16 +00:00
header ( " location: " . e_SELF . " ?r3 " );
}
2009-09-18 19:05:50 +00:00
// Update options
2008-12-13 12:34:53 +00:00
function dboptions ()
{
global $tp , $pref , $admin_log ;
$temp = array ();
$temp [ 'rss_othernews' ] = $_POST [ 'rss_othernews' ];
$temp [ 'rss_summarydiz' ] = $_POST [ 'rss_summarydiz' ];
2009-09-18 19:05:50 +00:00
$temp [ 'rss_shownewsimage' ] = $_POST [ 'rss_shownewsimage' ];
2008-12-13 12:34:53 +00:00
if ( $admin_log -> logArrayDiffs ( $temp , $pref , 'RSS_06' ))
{
save_prefs (); // Only save if changes
return LAN_SAVED ;
}
else
{
return RSS_LAN_ADMIN_28 ;
}
2006-12-02 04:36:16 +00:00
}
2009-09-18 19:05:50 +00:00
} // End class rss
?>