tiki-slideshow.php 4.64 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
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.
changi67's avatar
changi67 committed
6
// $Id: /cvsroot/tikiwiki/tiki/tiki-slideshow.php,v 1.27 2007-10-12 07:55:32 nyloth Exp $
7
$section = 'wiki page';
8
require_once ('tiki-setup.php');
9
if ($prefs['feature_wiki'] != 'y') {
changi67's avatar
changi67 committed
10
	$smarty->assign('msg', tra("This feature is disabled") . ": feature_wiki");
11
	$smarty->display("error.tpl");
12
	die;
13 14 15
}
//print($GLOBALS["HTTP_REFERER"]);
// Create the HomePage if it doesn't exist
16 17
if (!$tikilib->page_exists($prefs['wikiHomePage'])) {
	$tikilib->create_page($prefs['wikiHomePage'], 0, '', $tikilib->now, 'Tiki initialization');
18 19
}
// Get the page from the request var or default it to HomePage
20
if (!isset($_REQUEST["page"])) {
21 22 23
	$_REQUEST["page"] = $prefs['wikiHomePage'];
	$page = $prefs['wikiHomePage'];
	$smarty->assign('page', $prefs['wikiHomePage']);
24
} else {
25 26
	$page = $_REQUEST["page"];
	$smarty->assign_by_ref('page', $_REQUEST["page"]);
27 28
}
// If the page doesn't exist then display an error
29 30 31
if (!($info = $tikilib->get_page_info($page))) {
	$smarty->assign('msg', tra('Page cannot be found'));
	$smarty->display('error.tpl');
32 33
	die;
}
34
// Now check permissions to access this page
changi67's avatar
changi67 committed
35
$tikilib->get_perm_object($page, 'wiki page', $info);
36
if ($tiki_p_view != 'y') {
37
	$smarty->assign('errortype', 401);
38
	$smarty->assign('msg', tra("Permission denied you cannot view this page"));
39
	$smarty->display("error.tpl");
40
	die;
41 42 43 44
}
// BreadCrumbNavigation here
// Get the number of pages from the default or userPreferences
// Remember to reverse the array when posting the array
45
$anonpref = $prefs['userbreadCrumb'];
46 47
if (!isset($_SESSION["breadCrumb"])) {
	$_SESSION["breadCrumb"] = array();
48
}
49
if (!in_array($page, $_SESSION["breadCrumb"])) {
50
	if (count($_SESSION["breadCrumb"]) > $prefs['userbreadCrumb']) {
changi67's avatar
changi67 committed
51
		array_shift($_SESSION["breadCrumb"]);
52 53
	}
	array_push($_SESSION["breadCrumb"], $page);
54
} else {
55 56
	// If the page is in the array move to the last position
	$pos = array_search($page, $_SESSION["breadCrumb"]);
changi67's avatar
changi67 committed
57
	unset($_SESSION["breadCrumb"][$pos]);
58
	array_push($_SESSION["breadCrumb"], $page);
59
}
60
//print_r($_SESSION["breadCrumb"]);
61
// Now increment page hits since we are visiting this page
62
if ($prefs['count_admin_pvs'] == 'y' || $user != 'admin') {
63
	$tikilib->add_hit($page);
64
}
65 66
// Get page data
$info = $tikilib->get_page_info($page);
67
$smarty->assign('page_info', $info);
68
// Verify lock status
69 70
if ($info["flag"] == 'L') {
	$smarty->assign('lock', true);
71
} else {
72
	$smarty->assign('lock', false);
73 74
}
// If not locked and last version is user version then can undo
75 76 77
$smarty->assign('canundo', 'n');
if ($info["flag"] != 'L' && (($tiki_p_edit == 'y' && $info["user"] == $user) || ($tiki_p_remove == 'y'))) {
	$smarty->assign('canundo', 'y');
78
}
79 80 81
if ($tiki_p_admin_wiki == 'y') {
	$smarty->assign('canundo', 'y');
}
82
//Now process the pages
83 84 85 86 87
preg_match_all("/-=([^=]+)=-/", $info["data"], $reqs);
$slides = split("-=[^=]+=-", $info["data"]);
if (count($slides) < 2) {
	$slides = explode("...page...", $info["data"]);
	array_unshift($slides, '');
lrargerich's avatar
lrargerich committed
88
}
89
if (!isset($_REQUEST["slide"]) or $_REQUEST["slide"] < 0) {
90
	$_REQUEST["slide"] = 0;
91
}
92 93 94
if (!isset($slides[$_REQUEST["slide"] + 1])) {
	$_REQUEST["slide"] = count($slides) - 2;
}
95 96 97
$smarty->assign('prev_slide', $_REQUEST["slide"] - 1);
$smarty->assign('next_slide', $_REQUEST["slide"] + 1);
if (isset($reqs[1][$_REQUEST["slide"]])) {
lrargerich's avatar
lrargerich committed
98 99 100 101
	$slide_title = $reqs[1][$_REQUEST["slide"]];
} else {
	$slide_title = '';
}
102 103 104
$slide_data = $tikilib->parse_data($slides[$_REQUEST["slide"] + 1]);
if (isset($reqs[1][$_REQUEST["slide"] - 1])) {
	$slide_prev_title = $reqs[1][$_REQUEST["slide"] - 1];
105
} else {
106
	$slide_prev_title = '';
107
}
108 109
if (isset($reqs[1][$_REQUEST["slide"] + 1])) {
	$slide_next_title = $reqs[1][$_REQUEST["slide"] + 1];
110
} else {
111
	$slide_next_title = '';
112
}
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
$smarty->assign('slide_prev_title', $slide_prev_title);
$smarty->assign('slide_next_title', $slide_next_title);
$smarty->assign('slide_title', $slide_title);
$smarty->assign('slide_data', $slide_data);
$total_slides = count($slides) - 1;
$current_slide = $_REQUEST["slide"] + 1;
$smarty->assign('total_slides', $total_slides);
$smarty->assign('current_slide', $current_slide);
$smarty->assign_by_ref('lastModif', $info["lastModif"]);
if (empty($info["user"])) {
	$info["user"] = 'anonymous';
}
$smarty->assign_by_ref('lastUser', $info["user"]);
include_once ('tiki-section_options.php');
$smarty->assign('wiki_extras', 'y');
128
ask_ticket('slideshow');
129
// Display the Index Template
130
$smarty->assign('dblclickedit', 'y');
131
$smarty->assign('mid', 'tiki-show_page.tpl');
132
$smarty->display("tiki-slideshow.tpl");