tiki-print_pages.php 3.67 KB
Newer Older
ricks99's avatar
ricks99 committed
1
<?php
changi67's avatar
changi67 committed
2 3
// (c) Copyright 2002-2009 by authors of the Tiki Wiki/CMS/Groupware Project
// 
ricks99's avatar
ricks99 committed
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.
changi67's avatar
changi67 committed
6
// $Id: /cvsroot/tikiwiki/tiki/tiki-print_pages.php,v 1.20.2.2 2007-12-24 20:32:32 sylvieg Exp $
ricks99's avatar
ricks99 committed
7 8 9
$section = 'wiki page';
require_once ('tiki-setup.php');
include_once ('lib/structures/structlib.php');
10
$auto_query_args = array('page_ref_id', 'page', 'find', 'pageName', 'structureId', 'offset', 'printpages', 'printstructures');
ricks99's avatar
ricks99 committed
11
if ($prefs['feature_wiki_multiprint'] != 'y') {
changi67's avatar
changi67 committed
12
	$smarty->assign('msg', tra("This feature is disabled") . ": feature_wiki_multiprint");
ricks99's avatar
ricks99 committed
13 14 15 16 17
	$smarty->display("error.tpl");
	die;
}
// Now check permissions if user can view wiki pages
if ($tiki_p_view != 'y') {
18
	$smarty->assign('errortype', 401);
ricks99's avatar
ricks99 committed
19 20 21 22
	$smarty->assign('msg', tra("Permission denied you cannot view this page"));
	$smarty->display("error.tpl");
	die;
}
23
if (!isset($cookietab)) { $cookietab = '1'; }
ricks99's avatar
ricks99 committed
24 25 26
if (!isset($_REQUEST['printpages']) && !isset($_REQUEST['printstructures'])) {
	$printpages = array();
	$printstructures = array();
changi67's avatar
changi67 committed
27
	if (isset($_REQUEST["page_ref_id"])) {
ricks99's avatar
ricks99 committed
28 29 30 31
		$info = $structlib->s_get_page_info($_REQUEST['page_ref_id']);
		if (!empty($info)) {
			$printstructures[] = $_REQUEST['page_ref_id'];
		}
changi67's avatar
changi67 committed
32
	} elseif (isset($_REQUEST["page"]) && $tikilib->page_exists($_REQUEST["page"])) {
ricks99's avatar
ricks99 committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46
		$printpages[] = $_REQUEST["page"];
	}
} else {
	$printpages = unserialize(urldecode($_REQUEST["printpages"]));
	$printstructures = unserialize(urldecode($_REQUEST['printstructures']));
}
if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
} else {
	$find = '';
}
$smarty->assign('find', $find);
if (isset($_REQUEST["addpage"])) {
	if (!in_array($_REQUEST["pageName"], $printpages)) {
changi67's avatar
changi67 committed
47 48 49
		foreach($_REQUEST['pageName'] as $value) {
			$printpages[] = $value;
		}
ricks99's avatar
ricks99 committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
	}
	$cookietab = 2;
}
if (isset($_REQUEST["clearpages"])) {
	$printpages = array();
	$cookietab = 2;
}
if (isset($_REQUEST["clearstructures"])) {
	$printstructures = array();
}
if (isset($_REQUEST['addstructurepages'])) {
	$struct = $structlib->get_subtree($_REQUEST["structureId"]);
	foreach($struct as $struct_page) {
		// Handle dummy last entry
		if ($struct_page["pos"] != '' && $struct_page["last"] == 1) continue;
		$printpages[] = $struct_page["pageName"];
	}
	$cookietab = 2;
}
if (isset($_REQUEST['addstructure'])) {
	$info = $structlib->s_get_page_info($_REQUEST['structureId']);
	if (!empty($info)) {
		$printstructures[] = $_REQUEST['structureId'];
	}
}
$smarty->assign_by_ref('printpages', $printpages);
$smarty->assign_by_ref('printstructures', $printstructures);
$form_printpages = urlencode(serialize($printpages));
$smarty->assign_by_ref('form_printpages', $form_printpages);
$form_printstructures = urlencode(serialize($printstructures));
$smarty->assign_by_ref('form_printstructures', $form_printstructures);
$pages = $tikilib->list_pageNames(0, -1, 'pageName_asc', $find);
$smarty->assign_by_ref('pages', $pages["data"]);
changi67's avatar
changi67 committed
83 84 85 86
$structures = $structlib->list_structures(0, -1, 'pageName_asc', $find);
$smarty->assign_by_ref('structures', $structures["data"]);
foreach($printstructures as $page_ref_id) {
	foreach($structures['data'] as $struct) {
ricks99's avatar
ricks99 committed
87 88 89 90 91 92 93
		if ($struct['page_ref_id'] == $page_ref_id) {
			$printnamestructures[] = $struct['pageName'];
			break;
		}
	}
}
$smarty->assign_by_ref('printnamestructures', $printnamestructures);
changi67's avatar
changi67 committed
94
$smarty->assign('cookietab', $cookietab);
ricks99's avatar
ricks99 committed
95 96 97 98 99 100 101
include_once ('tiki-section_options.php');
ask_ticket('print-pages');
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
// Display the template
$smarty->assign('mid', 'tiki-print_pages.tpl');
$smarty->display("tiki.tpl");