##
## Modified By 2005 CACHE RSSfitJ ##
## ##
###############################################################################
## XOOPS - PHP Content Management System ##
## Copyright (c) 2000 XOOPS.org ##
## ##
###############################################################################
## This program is free software; you can redistribute it and/or modify ##
## it under the terms of the GNU General Public License as published by ##
## the Free Software Foundation; either version 2 of the License, or ##
## (at your option) any later version. ##
## ##
## You may not change or alter any portion of this comment or credits ##
## of supporting developers from this source code or any supporting ##
## source code which is considered copyrighted (c) material of the ##
## original comment or credit authors. ##
## ##
## This program is distributed in the hope that it will be useful, ##
## but WITHOUT ANY WARRANTY; without even the implied warranty of ##
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##
## GNU General Public License for more details. ##
## ##
## You should have received a copy of the GNU General Public License ##
## along with this program; if not, write to the Free Software ##
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ##
###############################################################################
## Author of this file: CACHE ##
## URL: http://gyakubiki.kir.jp/ ##
## Project: RSSFitJ ##
###############################################################################
include 'admin_header.php';
include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
define('_THIS_PAGE', RSSFITJ_URL.'admin/index.php');
$op = '';
if( isset($_POST['op']) ){
$op = trim($_POST['op']);
}elseif( isset($_GET['op']) ){
$op = trim($_GET['op']);
}
switch($op){
default:
adminHtmlHeader();
break;
case 'intro':
adminHtmlHeader();
$intro = grabIntro();
$myts =& MyTextSanitizer::getInstance();
$title = $myts->makeTboxData4Edit($intro['title']);
$content = $myts->makeTareaData4Edit($intro['content']);
$text = new XoopsFormText(_AM_EDIT_INTRO_TITLE, 'title', 50, 255, $title);
$text->setDescription(_AM_EDIT_INTRO_TITLE_DESC);
$tarea = new XoopsFormDhtmlTextArea(_AM_EDIT_INTRO_TEXT, 'content', $content, 15, 60);
$tarea->setDescription(_AM_EDIT_INTRO_TEXT_DESC);
$button = new XoopsFormButton('', 'submit', _AM_SUBMIT, 'submit');
$hidden = new XoopsFormHidden('op', 'saveintro');
$form = new XoopsThemeForm(_AM_EDIT_INTRO, 'editintro', _THIS_PAGE);
$form->addElement($text);
$form->addElement($tarea);
$form->addElement($button);
$form->addElement($hidden);
$form->display();
break;
case 'saveintro':
$myts =& MyTextSanitizer::getInstance();
$title = $myts->makeTboxData4Save($_POST['title']);
$content = $myts->makeTareaData4Save($_POST['content']);
$sql = 'UPDATE '.$xoopsDB->prefix('rssfitJ_misc')." SET misc_title = '".$title."', misc_content = '".$content."' WHERE misc_category = 'intro'";
if( !$result = $xoopsDB->query($sql) ){
$err = $xoopsDB->error();
adminHtmlHeader();
echo $err.'
'.$sql;
}else{
redirect_header(_THIS_PAGE.'?op=intro', 0, _AM_DBUPDATED);
}
break;
case 'plugins':
$ret = '';
adminHtmlHeader();
// activated plugins
$criteria = new Criteria('rssfj_activated', 1);
$criteria->setSort('rssfj_order');
if( $plugins =& $rssfj_mgr->getObjects($criteria) ){
$ret .= "
\n"
."| "._AM_PLUGIN_ACTIVATED." |
\n"
."\n| "._AM_PLUGIN_FILENAME." | \n"
.""._AM_PLUGIN_MODNAME." | \n"
.""._AM_PLUGIN_SHOWXENTRIES." | \n"
.""._AM_PLUGIN_ORDER." | \n"
.""._AM_ACTION." | \n"
."
\n";
foreach( $plugins as $p ){
if( $handler =& $rssfj_mgr->checkPlugin($p) ){
$id = $p->getVar('rssfj_conf_id');
$entries =& new XoopsFormText('', 'rssfj_grab['.$id.']', 3, 2, $p->getVar('rssfj_grab'));
$order =& new XoopsFormText('', 'rssfj_order['.$id.']', 3, 2, $p->getVar('rssfj_order'));
$action =& new XoopsFormSelect('', 'action['.$id.']', '');
$action->addOption('', _SELECT);
$action->addOption('d', _AM_PLUGIN_DEACTIVATE);
$action->addOption('u', _AM_PLUGIN_UNINSTALL);
$ret .= "\n"
."| "
.$p->getVar('rssfj_filename')." | \n"
.""
.$handler->modname." | \n"
.""
.$entries->render()." | \n"
.""
.$order->render()." | \n"
.""
.$action->render()." | \n"
;
$ret .= "
\n";
}else{
$rssfj_mgr->forceDeactivate($p);
}
}
$ret .= "
\n";
}
// inactive plugins
if( $plugins =& $rssfj_mgr->getObjects(new Criteria('rssfj_activated', 0)) ){
$ret .= "
\n\n"
."| "._AM_PLUGIN_INACTIVE." |
\n"
."\n| "._AM_PLUGIN_FILENAME." | \n"
.""._AM_PLUGIN_MODNAME." | \n"
.""._AM_ACTION." | \n"
."
\n";
foreach( $plugins as $p ){
$id = $p->getVar('rssfj_conf_id');
$action =& new XoopsFormSelect('', 'action['.$id.']', '');
$action->addOption('', _SELECT);
$ret .= "\n"
."| "
.$p->getVar('rssfj_filename')." | \n"
."";
if( $handler =& $rssfj_mgr->checkPlugin($p) ){
$ret .= $handler->modname;
$action->addOption('a', _AM_PLUGIN_ACTIVATE);
}else{
if( count($p->getErrors()) > 0 ){
$ret .= ''._ERRORS."\n";
foreach( $p->getErrors() as $e ){
$ret .= ' '.$e;
}
}else{
$ret .= ''._AM_PLUGIN_UNKNOWNERROR."";
}
}
$ret .= " | \n";
$action->addOption('u', _AM_PLUGIN_UNINSTALL);
$ret .= ""
.$action->render()." | \n";
}
$ret .= "
\n";
}
// Non-installed plugins
if( !$filelist =& $rssfj_mgr->getPluginFileList() ){
$filelist = array();
}
$list =& XoopsLists::getFileListAsArray(RSSFITJ_ROOT_PATH.'plugins');
$installable = array();
foreach( $list as $f ){
if( preg_match('/rssfitj\.+[a-zA-Z0-9_]+\.php/', $f) && !in_array($f, $filelist) ){
$installable[] = $f;
}
}
if( count($installable) > 0 ){
$ret .= "
\n\n"
."| "._AM_PLUGIN_NONINSTALLED." |
\n"
."\n| "._AM_PLUGIN_FILENAME." | \n"
.""._AM_PLUGIN_MODNAME." | \n"
.""._AM_PLUGIN_INSTALL." | \n"
."
\n";
foreach( $installable as $i ){
$action =& new XoopsFormCheckbox('', 'install['.$i.']');
$action->addOption('i', ' ');
$ret .= "\n"
."| "
.$i." | \n"
."";
$p =& $rssfj_mgr->create();
$p->setVar('rssfj_filename', $i);
if( $handler =& $rssfj_mgr->checkPlugin($p) ){
$ret .= $handler->modname;
}else{
if( count($p->getErrors()) > 0 ){
$ret .= ''._ERRORS."\n";
foreach( $p->getErrors() as $e ){
$ret .= ' '.$e;
}
}else{
$ret .= ''._AM_PLUGIN_UNKNOWNERROR."";
}
$action->setExtra('disabled="disabled"');
}
$ret .= " | \n";
$ret .= ""
.$action->render()." | \n";
}
$ret .= "
\n";
}
if( !empty($ret) ){
$button = new XoopsFormButton('', 'submit', _AM_SUBMIT, 'submit');
$hidden = new XoopsFormHidden('op', 'saveplugins');
$ret = ""
;
echo $ret;
}
break;
case 'saveplugins':
extract($_POST);
$err = '';
if (isset($action))
$keys = array_keys($action);
else
$keys = array();
foreach( $keys as $k ){
$plugin =& $rssfj_mgr->get($k);
if( isset($rssfj_grab[$k]) ){
$plugin->setVar('rssfj_grab', $rssfj_grab[$k]);
}
if (isset($rssfj_order[$k]))
$plugin->setVar('rssfj_order', $rssfj_order[$k]);
switch($action[$k]){
default:
$result = $rssfj_mgr->insert($plugin);
break;
case 'u': // uninstall
$result = $rssfj_mgr->delete($plugin);
break;
case 'd': // deactivate
$plugin->setVar('rssfj_activated', 0);
$result = $rssfj_mgr->insert($plugin);
break;
case 'a': // activate
$plugin->setVar('rssfj_activated', 1);
$result = $rssfj_mgr->insert($plugin);
break;
}
if( !$result ){
$err .= $plugin->getHtmlErrors();
}
}
if( !empty($install) ){
$files = array_keys($install);
foreach( $files as $f ){
$p =& $rssfj_mgr->create();
$p->setVar('rssfj_filename', $f);
$p->setVar('rssfj_activated', 1);
$p->setVar('rssfj_grab', $xoopsModuleConfig['plugin_entries']);
if( !$result = $rssfj_mgr->insert($p) ){
$err .= $p->getHtmlErrors();
}
}
}
if( !empty($err) ){
adminHtmlHeader();
echo $err;
}else{
redirect_header(_THIS_PAGE.'?op=plugins', 0, _AM_DBUPDATED);
}
break;
case 'param' :
$ret = '';
adminHtmlHeader();
// activated plugins
$criteria = new Criteria('rssfj_activated', 1);
$criteria->setSort('rssfj_order');
if( $plugins =& $rssfj_mgr->getObjects($criteria) ){
$ret .= "\n"
."| "._AM_PLUGIN_ACTIVATED." |
\n"
."\n| "._AM_PLUGIN_FILENAME." | \n"
.""._AM_PLUGIN_MODNAME." | \n"
.""._AM_PLUGIN_PARAMETERS." | \n"
."
\n";
foreach( $plugins as $p ){
if( $handler =& $rssfj_mgr->checkPlugin($p) ){
$id = $p->getVar('rssfj_conf_id');
$entries =& new XoopsFormTextArea('', 'rssfj_param['.$id.']', $p->getVar('rssfj_param'), 5, 60);
$ret .= "\n"
."| "
.$p->getVar('rssfj_filename')." | \n"
.""
.$handler->modname." | \n"
.""
.$entries->render()." | \n"
;
$ret .= "
\n";
}else{
$rssfj_mgr->forceDeactivate($p);
}
}
$ret .= "
\n";
}
if( !empty($ret) ){
$button = new XoopsFormButton('', 'submit', _AM_SUBMIT, 'submit');
$hidden = new XoopsFormHidden('op', 'saveparam');
$ret = ""
;
echo $ret;
}
break;
case 'saveparam' :
extract($_POST);
$err = '';
if( !empty($rssfj_param) ){
$files = array_keys($rssfj_param);
foreach( $files as $f ){
$p =& $rssfj_mgr->get($f);
$p->setVar('rssfj_param', $rssfj_param[$f]);
if( !$result = $rssfj_mgr->insert($p) ){
$err .= $p->getHtmlErrors();
}
}
}
if( !empty($err) ){
adminHtmlHeader();
echo $err;
}else{
redirect_header(_THIS_PAGE.'?op=param', 0, _AM_DBUPDATED);
}
break;
}
include 'footer.php';
xoops_cp_footer();
?>