tiki-admin_rssmodules.php 3.94 KB
Newer Older
lrargerich's avatar
lrargerich committed
1
<?php
2 3
// (c) Copyright 2002-2009 by authors of the Tiki Wiki/CMS/Groupware Project
// 
4 5
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6
// $Id: /cvsroot/tikiwiki/tiki/tiki-admin_rssmodules.php,v 1.26 2007-10-12 07:55:24 nyloth Exp $
7 8
require_once ('tiki-setup.php');
include_once ('lib/rss/rsslib.php');
changi67's avatar
changi67 committed
9
$auto_query_args = array(
10 11 12 13 14
	'rssId',
	'offset',
	'maxRecords',
	'sort_mode',
	'find'
changi67's avatar
changi67 committed
15
);
16
if (!isset($rsslib)) {
17
	$rsslib = new RssLib;
lrargerich's avatar
lrargerich committed
18
}
changi67's avatar
changi67 committed
19
if ($tiki_p_admin_rssmodules != 'y') {
20 21 22 23
	$smarty->assign('errortype', 401);
	$smarty->assign('msg', tra("You do not have permission to use this feature"));
	$smarty->display("error.tpl");
	die;
lrargerich's avatar
lrargerich committed
24
}
25
if (isset($_REQUEST["rssId"])) {
26
	$smarty->assign('rssId', $_REQUEST["rssId"]);
lrargerich's avatar
lrargerich committed
27
}
28 29
$smarty->assign('preview', 'n');
if (isset($_REQUEST["view"])) {
30 31 32 33 34 35 36 37
	$smarty->assign('preview', 'y');
	$data = $rsslib->get_rss_module_content($_REQUEST["view"]);
	$items = $rsslib->parse_rss_data($data, $_REQUEST["view"]);
	if ($items[0]["isTitle"] == "y") {
		$smarty->assign_by_ref('feedtitle', $items[0]);
		$items = array_slice($items, 1);
	}
	$smarty->assign_by_ref('items', $items);
lrargerich's avatar
lrargerich committed
38
}
39
if (isset($_REQUEST["rssId"])) {
40
	$info = $rsslib->get_rss_module($_REQUEST["rssId"]);
lrargerich's avatar
lrargerich committed
41
} else {
42 43 44 45 46 47 48 49
	$info = array();
	// default for new rss feed:
	$info["name"] = '';
	$info["description"] = '';
	$info["url"] = '';
	$info["refresh"] = 1800;
	$info["showTitle"] = 'n';
	$info["showPubDate"] = 'n';
lrargerich's avatar
lrargerich committed
50
}
51 52 53 54
$smarty->assign('name', $info["name"]);
$smarty->assign('description', $info["description"]);
$smarty->assign('url', $info["url"]);
$smarty->assign('refresh', $info["refresh"]);
55 56
$smarty->assign('showTitle', $info["showTitle"]);
$smarty->assign('showPubDate', $info["showPubDate"]);
57
if (isset($_REQUEST["refresh"])) {
58
	$rsslib->get_rss_module_content($_REQUEST["refresh"], true);
59
}
60
if (isset($_REQUEST["remove"])) {
61 62 63 64 65 66 67
	$area = 'delrss';
	if ($prefs['feature_ticketlib2'] != 'y' or (isset($_POST['daconfirm']) and isset($_SESSION["ticket_$area"]))) {
		key_check($area);
		$rsslib->remove_rss_module($_REQUEST["remove"]);
	} else {
		key_get($area);
	}
lrargerich's avatar
lrargerich committed
68
}
69
if (isset($_REQUEST["save"])) {
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
	check_ticket('admin-rssmodules');
	if (isset($_REQUEST['showTitle']) == 'on') {
		$smarty->assign('showTitle', 'y');
		$info["showTitle"] = 'y';
	} else {
		$smarty->assign('showTitle', 'n');
		$info["showTitle"] = 'n';
	}
	if (isset($_REQUEST['showPubDate']) == 'on') {
		$smarty->assign('showPubDate', 'y');
		$info["showPubDate"] = 'y';
	} else {
		$smarty->assign('showPubDate', 'n');
		$info["showPubDate"] = 'n';
	}
	$rsslib->replace_rss_module($_REQUEST["rssId"], $_REQUEST["name"], $_REQUEST["description"], $_REQUEST["url"], $_REQUEST["refresh"], $info["showTitle"], $info["showPubDate"]);
	$smarty->assign('rssId', 0);
	$smarty->assign('name', '');
	$smarty->assign('description', '');
	$smarty->assign('url', '');
	$smarty->assign('refresh', 900);
	$smarty->assign('showTitle', 'n');
	$smarty->assign('showPubDate', 'n');
lrargerich's avatar
lrargerich committed
93
}
94
if (!isset($_REQUEST["sort_mode"])) {
95
	$sort_mode = 'name_desc';
lrargerich's avatar
lrargerich committed
96
} else {
97
	$sort_mode = $_REQUEST["sort_mode"];
98 99
}
if (!isset($_REQUEST["offset"])) {
100
	$offset = 0;
lrargerich's avatar
lrargerich committed
101
} else {
102
	$offset = $_REQUEST["offset"];
lrargerich's avatar
lrargerich committed
103
}
104 105
$smarty->assign_by_ref('offset', $offset);
if (isset($_REQUEST["find"])) {
106
	$find = $_REQUEST["find"];
lrargerich's avatar
lrargerich committed
107
} else {
108
	$find = '';
lrargerich's avatar
lrargerich committed
109
}
110 111 112
$smarty->assign('find', $find);
$smarty->assign_by_ref('sort_mode', $sort_mode);
$channels = $rsslib->list_rss_modules($offset, $maxRecords, $sort_mode, $find);
113 114
$cant = $channels['cant'];
$smarty->assign_by_ref('cant', $cant);
115
$temp_max = count($channels["data"]);
116 117
for ($i = 0; $i < $temp_max; $i++) {
	$channels['data'][$i]['size'] = strlen($channels['data'][$i]['content']);
118
}
119
$smarty->assign_by_ref('channels', $channels["data"]);
120
ask_ticket('admin-rssmodules');
121 122
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
lrargerich's avatar
lrargerich committed
123
// Display the template
124
$smarty->assign('mid', 'tiki-admin_rssmodules.tpl');
125
$smarty->display("tiki.tpl");