tiki-print_pages.php 3.6 KB
Newer Older
ricks99's avatar
ricks99 committed
1
<?php
2
// (c) Copyright 2002-2011 by authors of the Tiki Wiki CMS Groupware Project
changi67's avatar
changi67 committed
3
// 
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$
7

ricks99's avatar
ricks99 committed
8 9 10
$section = 'wiki page';
require_once ('tiki-setup.php');
include_once ('lib/structures/structlib.php');
11
$auto_query_args = array('page_ref_id', 'page', 'find', 'pageName', 'structureId', 'offset', 'printpages', 'printstructures');
12 13 14

$access->check_feature('feature_wiki_multiprint');
$access->check_permission('tiki_p_view');
15
//get_strings tra('Multiple Print');
16
$smarty->assign('headtitle', tra('Print'));
17
if (!isset($cookietab)) { $cookietab = '1'; }
ricks99's avatar
ricks99 committed
18 19 20
if (!isset($_REQUEST['printpages']) && !isset($_REQUEST['printstructures'])) {
	$printpages = array();
	$printstructures = array();
changi67's avatar
changi67 committed
21
	if (isset($_REQUEST["page_ref_id"])) {
ricks99's avatar
ricks99 committed
22 23 24 25
		$info = $structlib->s_get_page_info($_REQUEST['page_ref_id']);
		if (!empty($info)) {
			$printstructures[] = $_REQUEST['page_ref_id'];
		}
changi67's avatar
changi67 committed
26
	} elseif (isset($_REQUEST["page"]) && $tikilib->page_exists($_REQUEST["page"])) {
ricks99's avatar
ricks99 committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40
		$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
41 42 43
		foreach($_REQUEST['pageName'] as $value) {
			$printpages[] = $value;
		}
ricks99's avatar
ricks99 committed
44 45 46
	}
	$cookietab = 2;
}
47 48 49 50 51 52 53
if (isset($_REQUEST["removepage"])) {
		foreach($_REQUEST['selectedpages'] as $value) {
			unset($printpages[$value]);
		}
		$printpages = array_merge($printpages);
	$cookietab = 2;
}
ricks99's avatar
ricks99 committed
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 83
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
84 85 86 87
$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
88 89 90 91 92 93 94
		if ($struct['page_ref_id'] == $page_ref_id) {
			$printnamestructures[] = $struct['pageName'];
			break;
		}
	}
}
$smarty->assign_by_ref('printnamestructures', $printnamestructures);
changi67's avatar
changi67 committed
95
$smarty->assign('cookietab', $cookietab);
ricks99's avatar
ricks99 committed
96 97 98 99
include_once ('tiki-section_options.php');
ask_ticket('print-pages');
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
killianebel's avatar
killianebel committed
100
$smarty->assign('pdf_export', ($prefs['print_pdf_from_url'] != 'none') ? 'y' : 'n');
ricks99's avatar
ricks99 committed
101 102
$smarty->assign('mid', 'tiki-print_pages.tpl');
$smarty->display("tiki.tpl");