1<?php 2/** 3 * @package tikiwiki 4 */ 5// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 6// 7// All Rights Reserved. See copyright.txt for details and a complete list of authors. 8// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 9// $Id$ 10 11require_once('tiki-setup.php'); 12$adminlib = TikiLib::lib('admin'); 13 14$access->check_permission('tiki_p_admin'); 15 16if (! isset($_REQUEST["extwikiId"])) { 17 $_REQUEST["extwikiId"] = 0; 18} 19$smarty->assign('extwikiId', $_REQUEST["extwikiId"]); 20if ($_REQUEST["extwikiId"]) { 21 $info = $adminlib->get_extwiki($_REQUEST["extwikiId"]); 22} else { 23 $info = [ 24 'name' => '', 25 'extwiki' => '', 26 'indexname' => '', 27 'groups' => [], 28 ]; 29} 30$smarty->assign('info', $info); 31if (isset($_REQUEST["remove"]) && $access->checkCsrfForm(tr('Remove external wiki?'))) { 32 $result = $adminlib->remove_extwiki($_REQUEST["remove"]); 33 if ($result && $result->numRows()) { 34 Feedback::success(tr('External wiki removed')); 35 } else { 36 Feedback::error(tr('External wiki not removed')); 37 } 38} 39if (isset($_REQUEST["save"]) && $access->checkCsrf()) { 40 $selector = TikiLib::lib('objectselector'); 41 $items = $selector->readMultipleSimple('group', $jitRequest->groups->text(), ';'); 42 $items = array_map(function ($i) { 43 return $i['id']; 44 }, $items); 45 46 $result = $adminlib->replace_extwiki($_REQUEST["extwikiId"], $_REQUEST["extwiki"], $_REQUEST['name'], $jitRequest->indexname->word(), $items); 47 $info = [ 48 'name' => '', 49 'extwiki' => '', 50 'indexname' => '', 51 'groups' => [], 52 ]; 53 if ($result) { 54 Feedback::success(tr('External wiki saved')); 55 } else { 56 Feedback::error(tr('External wiki not saved')); 57 } 58 $smarty->assign('info', $info); 59 $smarty->assign('name', ''); 60} 61if (! isset($_REQUEST["sort_mode"])) { 62 $sort_mode = 'extwikiId_desc'; 63} else { 64 $sort_mode = $_REQUEST["sort_mode"]; 65} 66if (! isset($_REQUEST["offset"])) { 67 $offset = 0; 68} else { 69 $offset = $_REQUEST["offset"]; 70} 71$smarty->assign_by_ref('offset', $offset); 72if (isset($_REQUEST["find"])) { 73 $find = $_REQUEST["find"]; 74} else { 75 $find = ''; 76} 77$smarty->assign('find', $find); 78$smarty->assign_by_ref('sort_mode', $sort_mode); 79$channels = $adminlib->list_extwiki($offset, $maxRecords, $sort_mode, $find); 80$smarty->assign_by_ref('cant_pages', $channels["cant"]); 81$smarty->assign_by_ref('channels', $channels["data"]); 82// disallow robots to index page: 83$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW'); 84// Display the template 85$smarty->assign('mid', 'tiki-admin_external_wikis.tpl'); 86$smarty->display("tiki.tpl"); 87