// // ------------------------------------------------------------------------ // // 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 // // ------------------------------------------------------------------------ // include '../../../include/cp_header.php'; include XOOPS_ROOT_PATH.'/modules/xoopsheadline/include/functions.php'; $op = 'list'; if (isset($HTTP_GET_VARS['op']) && ($HTTP_GET_VARS['op'] == 'delete' || $HTTP_GET_VARS['op'] == 'edit')) { $op = $HTTP_GET_VARS['op']; $headline_id = intval($HTTP_GET_VARS['headline_id']); } if (isset($HTTP_POST_VARS)) { foreach ($HTTP_POST_VARS as $k => $v) { ${$k} = $v; } } if ($op == 'list') { include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; $hlman =& xoops_getmodulehandler('headline'); $headlines =& $hlman->getObjects(); $count = count($headlines); xoops_cp_header(); echo "

"._AM_HEADLINES."

"; echo '
'; for ($i = 0; $i < $count; $i++) { echo ''; echo ''; echo ''; echo ''; } echo '
'._AM_SITENAME.''._AM_CACHETIME.''._AM_ENCODING.''._AM_DISPLAY.''._AM_ASBLOCK.''._AM_ORDER.' 
'.$headlines[$i]->getVar('headline_name').' getVar('headline_display')) { echo ' checked="checked"'; } echo ' />getVar('headline_asblock')) { echo ' checked="checked"'; } echo ' />'._EDIT.' '._DELETE.'
'; $form = new XoopsThemeForm(_AM_ADDHEADL, 'xoopsheadline_form_new', 'index.php', 'post', true); $form->addElement(new XoopsFormText(_AM_SITENAME, 'headline_name', 50, 255), true); $form->addElement(new XoopsFormText(_AM_URL, 'headline_url', 50, 255, 'http://'), true); $form->addElement(new XoopsFormText(_AM_URLEDFXML, 'headline_rssurl', 50, 255, 'http://'), true); $form->addElement(new XoopsFormText(_AM_ORDER, 'headline_weight', 4, 3, 0)); $enc_sel = new XoopsFormSelect(_AM_ENCODING, 'headline_encoding', 'utf-8'); $enc_sel->addOptionArray(array('utf-8' => 'UTF-8', 'iso-8859-1' => 'ISO-8859-1', 'us-ascii' => 'US-ASCII')); $form->addElement($enc_sel); $cache_sel = new XoopsFormSelect(_AM_CACHETIME, 'headline_cachetime', 86400); $cache_sel->addOptionArray(array('3600' => _HOUR, '18000' => sprintf(_HOURS, 5), '86400' => _DAY, '259200' => sprintf(_DAYS, 3), '604800' => _WEEK, '2592000' => _MONTH)); $form->addElement($cache_sel); $form->insertBreak(_AM_MAINSETT); $form->addElement(new XoopsFormRadioYN(_AM_DISPLAY, 'headline_display', 1, _YES, _NO)); $form->addElement(new XoopsFormRadioYN(_AM_DISPIMG, 'headline_mainimg', 0, _YES, _NO)); $form->addElement(new XoopsFormRadioYN(_AM_DISPFULL, 'headline_mainfull', 0, _YES, _NO)); $mmax_sel = new XoopsFormSelect(_AM_DISPMAX, 'headline_mainmax', 10); $mmax_sel->addOptionArray(array('1' => 1, '5' => 5, '10' => 10, '15' => 15, '20' => 20, '25' => 25, '30' => 30)); $form->addElement($mmax_sel); $form->insertBreak(_AM_BLOCKSETT); $form->addElement(new XoopsFormRadioYN(_AM_ASBLOCK, 'headline_asblock', 1, _YES, _NO)); $form->addElement(new XoopsFormRadioYN(_AM_DISPIMG, 'headline_blockimg', 0, _YES, _NO)); $bmax_sel = new XoopsFormSelect(_AM_DISPMAX, 'headline_blockmax', 5); $bmax_sel->addOptionArray(array('1' => 1, '5' => 5, '10' => 10, '15' => 15, '20' => 20, '25' => 25, '30' => 30)); $form->addElement($bmax_sel); $form->insertBreak(); $form->addElement(new XoopsFormHidden('op', 'addgo')); $form->addElement(new XoopsFormButton('', 'headline_submit2', _SUBMIT, 'submit')); $form->display(); xoops_cp_footer(); exit(); } if ($op == 'update') { $hlman =& xoops_getmodulehandler('headline');; $i = 0; $msg = ''; foreach ($headline_id as $id) { $hl =& $hlman->get($id); if (!is_object($hl)) { $i++; continue; } $headline_display[$id] = empty($headline_display[$id]) ? 0 : $headline_display[$id]; $headline_asblock[$id] = empty($headline_asblock[$id]) ? 0 : $headline_asblock[$id]; $old_cachetime = $hl->getVar('headline_cachetime'); $hl->setVar('headline_cachetime', $headline_cachetime[$i]); $old_display = $hl->getVar('headline_display'); $hl->setVar('headline_display', $headline_display[$id]); $hl->setVar('headline_weight', $headline_weight[$i]); $old_asblock = $hl->getVar('headline_asblock'); $hl->setVar('headline_asblock', $headline_asblock[$id]); $old_encoding = $hl->getVar('headline_encoding'); if (!$hlman->insert($hl)) { $msg .= '
'.sprintf(_AM_FAILUPDATE, $hl->getVar('headline_name')); } else { if ($hl->getVar('headline_xml') == '') { $renderer =& xoopsheadline_getrenderer($hl); $renderer->updateCache(); } } $i++; } if ($msg != '') { xoops_cp_header(); echo "

"._AM_HEADLINES."

"; xoops_error($msg); xoops_cp_footer(); exit(); } redirect_header('index.php', 2, _AM_DBUPDATED); } if ($op == 'addgo') { if ($GLOBALS['xoopsSecurity']->check()) { $hlman =& xoops_getmodulehandler('headline');; $hl =& $hlman->create(); $hl->setVar('headline_name', $headline_name); $hl->setVar('headline_url', $headline_url); $hl->setVar('headline_rssurl', $headline_rssurl); $hl->setVar('headline_display', $headline_display); $hl->setVar('headline_weight', $headline_weight); $hl->setVar('headline_asblock', $headline_asblock); $hl->setVar('headline_encoding', $headline_encoding); $hl->setVar('headline_cachetime', $headline_cachetime); $hl->setVar('headline_mainfull', $headline_mainfull); $hl->setVar('headline_mainimg', $headline_mainimg); $hl->setVar('headline_mainmax', $headline_mainmax); $hl->setVar('headline_blockimg', $headline_blockimg); $hl->setVar('headline_blockmax', $headline_blockmax); if (!$hlman->insert($hl)) { $msg = sprintf(_AM_FAILUPDATE, $hl->getVar('headline_name')); $msg .= '
'.$hl->getErrors(); xoops_cp_header(); echo "

"._AM_HEADLINES."

"; xoops_error($msg); xoops_cp_footer(); exit(); } else { if ($hl->getVar('headline_xml') == '') { $renderer =& xoopsheadline_getrenderer($hl); $renderer->updateCache(); } } } else { redirect_header('index.php', 2, implode('
', $GLOBALS['xoopsSecurity']->getErrors())); } redirect_header('index.php', 2, _AM_DBUPDATED); } if ($op == 'edit') { if ($headline_id <= 0) { xoops_cp_header(); echo "

"._AM_HEADLINES."

"; xoops_error(_AM_INVALIDID); xoops_cp_footer(); exit(); } $hlman =& xoops_getmodulehandler('headline');; $hl =& $hlman->get($headline_id); if (!is_object($hl)) { xoops_cp_header(); echo "

"._AM_HEADLINES."

"; xoops_error(_AM_OBJECTNG); xoops_cp_footer(); exit(); } include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; $form = new XoopsThemeForm(_AM_EDITHEADL, 'xoopsheadline_form', 'index.php', 'post', true); $form->addElement(new XoopsFormText(_AM_SITENAME, 'headline_name', 50, 255, $hl->getVar('headline_name')), true); $form->addElement(new XoopsFormText(_AM_URL, 'headline_url', 50, 255, $hl->getVar('headline_url')), true); $form->addElement(new XoopsFormText(_AM_URLEDFXML, 'headline_rssurl', 50, 255, $hl->getVar('headline_rssurl')), true); $form->addElement(new XoopsFormText(_AM_ORDER, 'headline_weight', 4, 3, $hl->getVar('headline_weight'))); $enc_sel = new XoopsFormSelect(_AM_ENCODING, 'headline_encoding', $hl->getVar('headline_encoding')); $enc_sel->addOptionArray(array('utf-8' => 'UTF-8', 'iso-8859-1' => 'ISO-8859-1', 'us-ascii' => 'US-ASCII')); $form->addElement($enc_sel); $cache_sel = new XoopsFormSelect(_AM_CACHETIME, 'headline_cachetime', $hl->getVar('headline_cachetime')); $cache_sel->addOptionArray(array('3600' => _HOUR, '18000' => sprintf(_HOURS, 5), '86400' => _DAY, '259200' => sprintf(_DAYS, 3), '604800' => _WEEK, '2592000' => _MONTH)); $form->addElement($cache_sel); $form->insertBreak(_AM_MAINSETT); $form->addElement(new XoopsFormRadioYN(_AM_DISPLAY, 'headline_display', $hl->getVar('headline_display'), _YES, _NO)); $form->addElement(new XoopsFormRadioYN(_AM_DISPIMG, 'headline_mainimg', $hl->getVar('headline_mainimg'), _YES, _NO)); $form->addElement(new XoopsFormRadioYN(_AM_DISPFULL, 'headline_mainfull', $hl->getVar('headline_mainfull'), _YES, _NO)); $mmax_sel = new XoopsFormSelect(_AM_DISPMAX, 'headline_mainmax', $hl->getVar('headline_mainmax')); $mmax_sel->addOptionArray(array('1' => 1, '5' => 5, '10' => 10, '15' => 15, '20' => 20, '25' => 25, '30' => 30)); $form->addElement($mmax_sel); $form->insertBreak(_AM_BLOCKSETT); $form->addElement(new XoopsFormRadioYN(_AM_ASBLOCK, 'headline_asblock', $hl->getVar('headline_asblock'), _YES, _NO)); $form->addElement(new XoopsFormRadioYN(_AM_DISPIMG, 'headline_blockimg', $hl->getVar('headline_blockimg'), _YES, _NO)); $bmax_sel = new XoopsFormSelect(_AM_DISPMAX, 'headline_blockmax', $hl->getVar('headline_blockmax')); $bmax_sel->addOptionArray(array('1' => 1, '5' => 5, '10' => 10, '15' => 15, '20' => 20, '25' => 25, '30' => 30)); $form->addElement($bmax_sel); $form->insertBreak(); $form->addElement(new XoopsFormHidden('headline_id', $hl->getVar('headline_id'))); $form->addElement(new XoopsFormHidden('op', 'editgo')); $form->addElement(new XoopsFormButton('', 'headline_submit', _SUBMIT, 'submit')); xoops_cp_header(); echo "

"._AM_HEADLINES."


"; //echo ''. _AM_HLMAIN .' »» '.$hl->getVar('headline_name').'

'; $form->display(); xoops_cp_footer(); exit(); } if ($op == 'editgo') { $headline_id = intval($headline_id); if ($headline_id <= 0) { xoops_cp_header(); echo "

"._AM_HEADLINES."

"; xoops_error(_AM_INVALIDID); xoops_cp_footer(); exit(); } $hlman =& xoops_getmodulehandler('headline');; $hl =& $hlman->get($headline_id); if (!is_object($hl)) { xoops_cp_header(); echo "

"._AM_HEADLINES."

"; xoops_error(_AM_OBJECTNG); xoops_cp_footer(); exit(); } $hl->setVar('headline_name', $headline_name); $hl->setVar('headline_url', $headline_url); $hl->setVar('headline_encoding', $headline_encoding); $hl->setVar('headline_rssurl', $headline_rssurl); $hl->setVar('headline_display', $headline_display); $hl->setVar('headline_weight', $headline_weight); $hl->setVar('headline_asblock', $headline_asblock); $hl->setVar('headline_cachetime', $headline_cachetime); $hl->setVar('headline_mainfull', $headline_mainfull); $hl->setVar('headline_mainimg', $headline_mainimg); $hl->setVar('headline_mainmax', $headline_mainmax); $hl->setVar('headline_blockimg', $headline_blockimg); $hl->setVar('headline_blockmax', $headline_blockmax); if (!$GLOBALS['xoopsSecurity']->check() || !$hlman->insert($hl)) { $msg = sprintf(_AM_FAILUPDATE, $hl->getVar('headline_name')); $msg .= '
'.$hl->getErrors(); $msg .= '
'.implode('
', $GLOBALS['xoopsSecurity']->getErrors()); xoops_cp_header(); echo "

"._AM_HEADLINES."

"; xoops_error($msg); xoops_cp_footer(); exit(); } else { if ($hl->getVar('headline_xml') == '') { $renderer =& xoopsheadline_getrenderer($hl); $renderer->updateCache(); } } redirect_header('index.php', 2, _AM_DBUPDATED); } if ($op == 'delete') { if ($headline_id <= 0) { xoops_cp_header(); echo "

"._AM_HEADLINES."

"; xoops_error(_AM_INVALIDID); xoops_cp_footer(); exit(); } $hlman =& xoops_getmodulehandler('headline');; $hl =& $hlman->get($headline_id); if (!is_object($hl)) { xoops_cp_header(); echo "

"._AM_HEADLINES."

"; xoops_error(_AM_OBJECTNG); xoops_cp_footer(); exit(); } xoops_cp_header(); $name = $hl->getVar('headline_name'); echo "

"._AM_HEADLINES."

"; //echo ''. _AM_HLMAIN .' »» '.$name.'

'; xoops_confirm(array('op' => 'deletego', 'headline_id' => $hl->getVar('headline_id')), 'index.php', sprintf(_AM_WANTDEL, $name)); xoops_cp_footer(); exit(); } if ($op == 'deletego') { $headline_id = intval($headline_id); if ($headline_id <= 0) { xoops_cp_header(); echo "

"._AM_HEADLINES."

"; xoops_error(_AM_INVALIDID); xoops_cp_footer(); exit(); } $hlman =& xoops_getmodulehandler('headline');; $hl =& $hlman->get($headline_id); if (!is_object($hl)) { xoops_cp_header(); echo "

"._AM_HEADLINES."

"; xoops_error(_AM_OBJECTNG); xoops_cp_footer(); exit(); } if (!$GLOBALS['xoopsSecurity']->check() || !$hlman->delete($hl)) { xoops_cp_header(); echo "

"._AM_HEADLINES."

"; xoops_error(sprintf(_AM_FAILDELETE, $hl->getVar('headline_name'))."
".implode('
', $GLOBALS['xoopsSecurity']->getErrors())); xoops_cp_footer(); exit(); } redirect_header('index.php', 2, _AM_DBUPDATED); } ?>