tiki-admin_html_pages.php 2.99 KB
Newer Older
lrargerich's avatar
lrargerich committed
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
6
// 
7 8
// 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.
9
// $Id$
changi67's avatar
changi67 committed
10

11 12
require_once ('tiki-setup.php');
include_once ('lib/htmlpages/htmlpageslib.php');
13 14
$access->check_feature('feature_html_pages');
$access->check_permission('tiki_p_edit_html_pages');
15
if (!isset($_REQUEST["pageName"])) {
16
	$_REQUEST["pageName"] = '';
lrargerich's avatar
lrargerich committed
17
}
18 19
$smarty->assign('pageName', $_REQUEST["pageName"]);
if ($_REQUEST["pageName"]) {
20
	$info = $htmlpageslib->get_html_page($_REQUEST["pageName"]);
lrargerich's avatar
lrargerich committed
21
} else {
22 23 24 25 26
	$info = array();
	$info["pageName"] = '';
	$info["content"] = '';
	$info["refresh"] = 0;
	$info["type"] = 's';
lrargerich's avatar
lrargerich committed
27
}
28 29
$smarty->assign('info', $info);
if (isset($_REQUEST["remove"])) {
30 31
	$access->check_authenticity();
	$htmlpageslib->remove_html_page($_REQUEST["remove"]);
lrargerich's avatar
lrargerich committed
32
}
33
if (isset($_REQUEST["templateId"]) && $_REQUEST["templateId"] > 0) {
34
	$template_data = TikiLib::lib('template')->get_template($_REQUEST["templateId"]);
35 36
	$_REQUEST["content"] = $template_data["content"];
	$_REQUEST["preview"] = 1;
lrargerich's avatar
lrargerich committed
37
}
38 39
$smarty->assign('preview', 'n');
if (isset($_REQUEST["preview"])) {
40 41 42 43 44 45 46 47 48
	$smarty->assign('preview', 'y');
	//$parsed = $tikilib->parse_data($_REQUEST["content"]);
	$parsed = $htmlpageslib->parse_html_page($_REQUEST["pageName"], $_REQUEST["content"]);
	$smarty->assign('parsed', $parsed);
	$info["content"] = $_REQUEST["content"];
	$info["refresh"] = $_REQUEST["refresh"];
	$info["pageName"] = $_REQUEST["pageName"];
	$info["type"] = $_REQUEST["type"];
	$smarty->assign('info', $info);
lrargerich's avatar
lrargerich committed
49
}
50
if (isset($_REQUEST["save"]) && !empty($_REQUEST["pageName"])) {
51 52 53 54 55 56 57 58
	check_ticket('admin-html-pages');
	$tid = $htmlpageslib->replace_html_page($_REQUEST["pageName"], $_REQUEST["type"], $_REQUEST["content"], $_REQUEST["refresh"]);
	$smarty->assign("pageName", '');
	$info["pageName"] = '';
	$info["content"] = '';
	$info["regresh"] = 0;
	$info["type"] = 's';
	$smarty->assign('info', $info);
lrargerich's avatar
lrargerich committed
59
}
60
if (!isset($_REQUEST["sort_mode"])) {
61
	$sort_mode = 'created_desc';
lrargerich's avatar
lrargerich committed
62
} else {
63
	$sort_mode = $_REQUEST["sort_mode"];
64 65
}
if (!isset($_REQUEST["offset"])) {
66
	$offset = 0;
lrargerich's avatar
lrargerich committed
67
} else {
68
	$offset = $_REQUEST["offset"];
lrargerich's avatar
lrargerich committed
69
}
70 71
$smarty->assign_by_ref('offset', $offset);
if (isset($_REQUEST["find"])) {
72
	$find = $_REQUEST["find"];
lrargerich's avatar
lrargerich committed
73
} else {
74
	$find = '';
lrargerich's avatar
lrargerich committed
75
}
76 77 78
$smarty->assign('find', $find);
$smarty->assign_by_ref('sort_mode', $sort_mode);
$channels = $htmlpageslib->list_html_pages($offset, $maxRecords, $sort_mode, $find);
79
$smarty->assign_by_ref('cant_pages', $channels["cant"]);
80
$smarty->assign_by_ref('channels', $channels["data"]);
81 82
$templates = TikiLib::lib('template')->list_templates('html', 0, -1, 'name_asc', '');

83
$smarty->assign_by_ref('templates', $templates["data"]);
84
ask_ticket('admin-html-pages');
85 86
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
lrargerich's avatar
lrargerich committed
87
// Display the template
88
$smarty->assign('mid', 'tiki-admin_html_pages.tpl');
89
$smarty->display("tiki.tpl");