tiki-list_articles.php 6.58 KB
Newer Older
1
<?php
2
// (c) Copyright 2002-2009 by authors of the Tiki Wiki/CMS/Groupware Project
changi67's avatar
changi67 committed
3
// 
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$
mose's avatar
mose committed
7
$section = 'cms';
8 9
require_once ('tiki-setup.php');
include_once ('lib/articles/artlib.php');
changi67's avatar
changi67 committed
10
$smarty->assign('headtitle', tra('List Articles'));
11 12
$access->check_feature('feature_articles');
$access->check_permission('tiki_p_read_article');
13 14 15 16 17 18 19 20 21 22 23
if ($prefs["gmap_article_list"] == 'y') {
	$smarty->assign('gmapbuttons', true);
} else {
	$smarty->assign('gmapbuttons', false);
}
if (isset($_REQUEST["mapview"]) && $_REQUEST["mapview"] == 'y' && !isset($_REQUEST["searchmap"]) && !isset($_REQUEST["searchlist"]) || isset($_REQUEST["searchmap"]) && !isset($_REQUEST["searchlist"])) {
	$smarty->assign('mapview', true);
}
if (isset($_REQUEST["mapview"]) && $_REQUEST["mapview"] == 'n' && !isset($_REQUEST["searchmap"]) && !isset($_REQUEST["searchlist"]) || isset($_REQUEST["searchlist"]) && !isset($_REQUEST["searchmap"]) ) {
	$smarty->assign('mapview', false);
}
24
if (isset($_REQUEST["remove"])) {
25 26 27
	$artperms = Perms::get( array( 'type' => 'article', 'object' => $_REQUEST['remove'] ) );

	if ($artperms->remove_article != 'y') {
28
		$smarty->assign('errortype', 401);
29
		$smarty->assign('msg', tra("Permission denied you cannot remove articles"));
30
		$smarty->display("error.tpl");
31 32
		die;
	}
33 34
	$access->check_authenticity();
	$artlib->remove_article($_REQUEST["remove"]);
35
}
36 37 38 39
// This script can receive the thresold
// for the information as the number of
// days to get in the log 1,3,4,etc
// it will default to 1 recovering information for today
40 41
if (!isset($_REQUEST["sort_mode"])) {
	$sort_mode = 'publishDate_desc';
42
} else {
43 44 45
	$sort_mode = $_REQUEST["sort_mode"];
}
$smarty->assign_by_ref('sort_mode', $sort_mode);
46 47 48
// If offset is set use it if not then use offset =0
// use the maxRecords php variable to set the limit
// if sortMode is not set then use lastModif_desc
49 50
if (!isset($_REQUEST["offset"])) {
	$offset = 0;
51
} else {
52
	$offset = $_REQUEST["offset"];
53
}
54
$smarty->assign_by_ref('offset', $offset);
sylvieg's avatar
sylvieg committed
55 56
if (!empty($_REQUEST['maxRecords'])) {
	$maxRecords = $_REQUEST['maxRecords'];
57
} else {
58
	$maxRecords = $maxRecords;
sylvieg's avatar
sylvieg committed
59
}
sylvieg's avatar
typo  
sylvieg committed
60
$smarty->assign_by_ref('maxRecords', $maxRecords);
61 62

$visible_only = 'y';
changi67's avatar
changi67 committed
63 64
if (($tiki_p_admin == 'y') || ($tiki_p_admin_cms == 'y')) {
	$date_max = '';
65
	$visible_only = "n";
changi67's avatar
changi67 committed
66 67 68 69 70 71 72 73
} elseif (isset($_SESSION["thedate"])) {
	if ($_SESSION["thedate"] < $tikilib->now) {
		// If the session is older then set it to today
		// so you can list articles
		$date_max = $tikilib->now;
	} else {
		$date_max = $_SESSION["thedate"];
	}
74
} else {
75
	$date_max = $tikilib->now;
76
}
77
if (isset($_REQUEST["find_from_Month"]) && isset($_REQUEST["find_from_Day"]) && isset($_REQUEST["find_from_Year"])) {
78
	$date_min = $tikilib->make_time(0, 0, 0, $_REQUEST["find_from_Month"], $_REQUEST["find_from_Day"], $_REQUEST["find_from_Year"]);
79 80 81 82 83 84
	$smarty->assign('find_date_from', $date_min);
} else {
	$date_min = 0;
	$smarty->assign('find_date_from', $tikilib->now - 365*24*3600);
}
if (isset($_REQUEST["find_to_Month"]) && isset($_REQUEST["find_to_Day"]) && isset($_REQUEST["find_to_Year"])) {
85
	$t_date_max = $tikilib->make_time(23, 59, 59, $_REQUEST["find_to_Month"], $_REQUEST["find_to_Day"], $_REQUEST["find_to_Year"]);
86 87 88 89 90 91
	if ($t_date_max < $date_max || $date_max == '') {
		$date_max = $t_date_max;
		$visible_only = 'y';
	}
}
$smarty->assign('find_date_to', $date_max);
92 93
if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
94
} else {
95
	$find = '';
96
}
97 98 99
$smarty->assign('find', $find);
if (!isset($_REQUEST["type"])) {
	$_REQUEST["type"] = '';
lrargerich's avatar
lrargerich committed
100
}
101 102
if (!isset($_REQUEST["topic"])) {
	$_REQUEST["topic"] = '';
lrargerich's avatar
lrargerich committed
103
}
104 105 106 107 108 109 110 111 112

$filter['categId'] = 0;
if ($prefs['feature_categories'] == 'y' && !empty($_REQUEST['cat_categories'])) {
	$filter['categId'] = $_REQUEST['cat_categories'];
	if (count($_REQUEST['cat_categories']) > 1) {
		$smarty->assign('find_cat_categories', $_REQUEST['cat_categories']);
		unset($_REQUEST['categId']);
	} else {
		$_REQUEST['categId'] = $_REQUEST['cat_categories'][0];
113
		unset($_REQUEST['cat_categories']);
114 115 116 117 118 119 120
	}
} else {
		$_REQUEST['cat_categories'] = array();
}
if ($prefs['feature_categories'] == 'y' && !empty($_REQUEST['categId'])) {
	$filter['categId'] = $_REQUEST['categId'];
	$smarty->assign('find_categId', $_REQUEST['categId']);
121
}
122 123 124
if (!isset($_REQUEST['lang'])) {
	$_REQUEST['lang'] = '';
}
125 126
$smarty->assign('find_topic', $_REQUEST["topic"]);
$smarty->assign('find_type', $_REQUEST["type"]);
127
$smarty->assign('find_lang', $_REQUEST['lang']);
128
// Get a list of last changes to the Wiki database
129
$listpages = $artlib->list_articles($offset, $maxRecords, $sort_mode, $find, $date_min, $date_max, $user, $_REQUEST["type"], $_REQUEST["topic"], $visible_only, '', $filter["categId"], '', '', $_REQUEST['lang']);
130
// If there're more records then assign next_offset
131
$smarty->assign_by_ref('cant', $listpages['cant']);
132
$smarty->assign_by_ref('listpages', $listpages["data"]);
133

134 135 136 137 138 139 140 141 142 143 144 145 146
if ($prefs["gmap_article_list"] == 'y') {
	// Generate Google map plugin data
	global $gmapobjectarray;
	$gmapobjectarray = array();
	foreach ($listpages["data"] as $art) {
		$gmapobjectarray[] = array('type' => 'article',
			'id' => $art["articleId"],
			'title' => $art["title"],
			'href' => 'tiki-read_article.php?articleId=' . $art["articleId"],
		);
	}
}

147
$topics = $artlib->list_topics();
148
$smarty->assign_by_ref('topics', $topics);
149 150
$types = $artlib->list_types();
$smarty->assign_by_ref('types', $types);
151
if ($prefs['feature_categories'] == 'y') {
changi67's avatar
changi67 committed
152 153
	global $categlib;
	include_once ('lib/categories/categlib.php');
154
	$categories = $categlib->get_all_categories_respect_perms(null, 'view_category');
155
	$smarty->assign_by_ref('categories', $categories);
156
	$smarty->assign('cat_tree', $categlib->generate_cat_tree($categories, true, $_REQUEST['cat_categories']));	
157
}
158
if ($prefs['feature_multilingual'] == 'y') {
sylvieg's avatar
sylvieg committed
159 160 161 162
	$languages = array();
	$languages = $tikilib->list_languages(false, 'y');
	$smarty->assign_by_ref('languages', $languages);
}
163
if ($tiki_p_edit_article != 'y' && $tiki_p_remove_article != 'y') { //check one editable
changi67's avatar
changi67 committed
164
	foreach($listpages['data'] as $page) {
165 166 167 168 169 170
		if ($page['author'] == $user && $page['creator_edit'] == 'y') {
			$smarty->assign('oneEditPage', 'y');
			break;
		}
	}
}
171
include_once ('tiki-section_options.php');
changi67's avatar
changi67 committed
172
if ($prefs['feature_mobile'] == 'y' && isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'mobile') {
nhuffschmid's avatar
nhuffschmid committed
173 174 175
	include_once ("lib/hawhaw/hawtikilib.php");
	HAWTIKI_list_articles($listpages, $tiki_p_read_article, $offset, $maxRecords, $listpages["cant"]);
}
176
ask_ticket('list-articles');
177
// Display the template
178
$smarty->assign('mid', 'tiki-list_articles.tpl');
179
$smarty->display("tiki.tpl");