public static function main() { $tpl['MESSAGE'] = NULL; $message = RSS_Admin::getMessage(); PHPWS_Core::initModClass('rss', 'Feed.php'); PHPWS_Core::initModClass('rss', 'Channel.php'); if (!Current_User::allow('rss')) { Current_User::disallow(); } $panel = RSS_Admin::adminPanel(); if (isset($_REQUEST['command'])) { $command = $_REQUEST['command']; } elseif (isset($_REQUEST['tab'])) { $command = $_REQUEST['tab']; } else { $command = $panel->getCurrentTab(); } if (isset($_REQUEST['channel_id'])) { $channel = new RSS_Channel($_REQUEST['channel_id']); } else { $channel = new RSS_Channel(); } if (isset($_REQUEST['feed_id'])) { $feed = new RSS_Feed($_REQUEST['feed_id']); } else { $feed = new RSS_Feed(); } switch ($command) { case 'channels': $tpl = RSS_Admin::channels(); break; case 'settings': $tpl = RSS_Admin::settings(); break; case 'save_settings': $result = RSS_Admin::save_settings(); if (!$result) { PHPWS_Settings::save('rss'); $result = dgettext('rss', 'Settings saved successfully.'); } $tpl = RSS_Admin::settings(); $tpl['MESSAGE'] =& $result; break; case 'save_feed': $result = $feed->post(); if (is_array($result)) { $tpl = RSS_Admin::editFeed($feed); $tpl['MESSAGE'] = implode('<br />', $result); Layout::nakedDisplay(PHPWS_Template::process($tpl, 'rss', 'main.tpl')); exit; } else { $result = $feed->save(); javascript('close_refresh'); } break; case 'edit_channel': $tpl = RSS_Admin::editChannel($channel); break; case 'post_channel': $result = $channel->post(); if (is_array($result)) { $message = implode('<br />', $result); $tpl = RSS_Admin::editChannel($channel); } else { $result = $channel->save(); if (PHPWS_Error::isError($result)) { RSS_Admin::sendMessage(dgettext('rss', 'An error occurred when saving your channel.'), 'channels'); } else { RSS_Admin::sendMessage(dgettext('rss', 'Channel saved.'), 'channels'); } } break; case 'reset_feed': $feed->reset(); case 'import': $tpl = RSS_Admin::import(); break; case 'turn_on_display': $feed->display = 1; $feed->save(); $tpl = RSS_Admin::import(); break; case 'turn_off_display': $feed->display = 0; $feed->save(); $tpl = RSS_Admin::import(); break; case 'add_feed': $tpl = RSS_Admin::editFeed($feed); Layout::nakedDisplay(PHPWS_Template::process($tpl, 'rss', 'main.tpl')); exit; break; case 'edit_feed': $tpl = RSS_Admin::editFeed($feed); Layout::nakedDisplay(PHPWS_Template::process($tpl, 'rss', 'main.tpl')); exit; break; case 'delete_feed': $feed->delete(); $tpl = RSS_Admin::import(); break; default: PHPWS_Core::errorPage('404'); break; } if (!empty($message)) { $tpl['MESSAGE'] = $message; } $content = PHPWS_Template::process($tpl, 'rss', 'main.tpl'); $panel->setContent($content); $content = $panel->display(); Layout::add(PHPWS_ControlPanel::display($content)); }
public static function import() { $source_http = PHPWS_SOURCE_HTTP; $script = "<script src='{$source_http}mod/rss/javascript/feed.js'></script>"; javascript('jquery'); \Layout::addJSHeader($script); PHPWS_Core::requireConfig('rss'); if (!ini_get('allow_url_fopen')) { $tpl['TITLE'] = dgettext('rss', 'Sorry'); $tpl['CONTENT'] = dgettext('rss', 'You must enable allow_url_fopen in your php.ini file.'); return $tpl; } PHPWS_Core::initCoreClass('DBPager.php'); PHPWS_Core::initModClass('rss', 'Feed.php'); $content = NULL; $template['ADD_LINK'] = '<button class="btn btn-success edit-feed"><i></i> Add Feed</button>'; /* $vars['address'] = 'index.php?module=rss&command=add_feed'; $vars['label'] = dgettext('rss', 'Add feed'); $vars['width'] = '450'; $vars['height'] = '350'; $template['ADD_LINK'] = javascript('open_window', $vars); * */ $template['TITLE_LABEL'] = dgettext('rss', 'Title'); $template['ADDRESS_LABEL'] = dgettext('rss', 'Address'); $template['DISPLAY_LABEL'] = dgettext('rss', 'Display?'); $template['ACTION_LABEL'] = dgettext('rss', 'Action'); $template['REFRESH_TIME_LABEL'] = dgettext('rss', 'Refresh feed'); $modal = new \Modal('rss-modal'); $modal->addButton('<button class="btn btn-primary" id="save-feed"><i class="fa fa-save"></i> Save</button>'); $modal_content = RSS_Admin::editFeed(); $modal->setContent($modal_content); $modal->setTitle('Edit feed'); $modal->setWidthPixel('400'); $template['MODAL'] = $modal->get(); $pager = new DBPager('rss_feeds', 'RSS_Feed'); $pager->setModule('rss'); $pager->setTemplate('admin_feeds.tpl'); $pager->addPageTags($template); $pager->addRowTags('pagerTags'); $content = $pager->get(); $tpl['TITLE'] = dgettext('rss', 'Import RSS Feeds'); $tpl['CONTENT'] = $content; if (!defined('ALLOW_CACHE_LITE') || !ALLOW_CACHE_LITE) { $tpl['MESSAGE'] = dgettext('rss', 'Please enable Cache Lite in your config/core/config.php file.'); } return $tpl; }
<?php /** * @author Matthew McNaney <mcnaney at gmail dot com> * @version $Id$ */ if (!defined('PHPWS_SOURCE_DIR')) { include '../../core/conf/404.html'; exit; } if ((isset($_REQUEST['command']) || isset($_REQUEST['tab'])) && Current_User::allow('rss')) { PHPWS_Core::initModClass('rss', 'Admin.php'); RSS_Admin::main(); } elseif (isset($_GET['mod_title'])) { PHPWS_Core::initModClass('rss', 'RSS.php'); RSS::viewChannel($_GET['mod_title']); } elseif (isset($_GET['id'])) { PHPWS_Core::initModClass('rss', 'RSS.php'); RSS::viewChannel($_GET['id']); } else { PHPWS_Core::errorPage('404'); }