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 11$section = 'sheet'; 12require_once('tiki-setup.php'); 13$sheetlib = TikiLib::lib("sheet"); 14 15$access->check_feature('feature_sheet'); 16 17$info = $sheetlib->get_sheet_info($_REQUEST['sheetId']); 18if (empty($info)) { 19 $smarty->assign('Incorrect parameter'); 20 $smarty->display('error.tpl'); 21 die; 22} 23 24$objectperms = Perms::get('sheet', $_REQUEST['sheetId']); 25if ($tiki_p_admin != 'y' && ! $objectperms->view_sheet && ! ($user && $info['author'] == $user)) { 26 $smarty->assign('msg', tra('Permission denied')); 27 $smarty->display('error.tpl'); 28 die; 29} 30$smarty->assign('sheetId', $_REQUEST["sheetId"]); 31 32$smarty->assign('title', $info['title']); 33$smarty->assign('description', $info['description']); 34 35$smarty->assign('page_mode', 'form'); 36 37// Process the insertion or modification of a gallery here 38 39$grid = new TikiSheet; 40 41if ($_SERVER['REQUEST_METHOD'] == 'POST') { 42 $smarty->assign('page_mode', 'submit'); 43 44 $sheetId = $_REQUEST['sheetId']; 45 $handler = $_REQUEST['handler']; 46 $encoding = $_REQUEST['encoding']; 47 48 // Instanciate the handler 49 switch ($handler) { 50 case 'TikiSheetWikiTableHandler': // Well known, special handlers 51 $handler = new $handler($_POST['page']); 52 break; 53 default: // All file based handlers registered 54 if (! in_array($handler, TikiSheet::getHandlerList())) { 55 $smarty->assign('msg', "Handler is not allowed."); 56 $smarty->display("error.tpl"); 57 die; 58 } 59 $handler = new $handler($_FILES['file']['tmp_name'], $encoding, 'UTF-8'); 60 } 61 62 if (! $grid->import($handler)) { 63 $smarty->assign('msg', "Impossible to import the file."); 64 $smarty->display("error.tpl"); 65 die; 66 } 67 68 $handler = new TikiSheetDatabaseHandler($sheetId); 69 $grid->export($handler); 70 71 ob_start(); 72 $handler = new TikiSheetOutputHandler; 73 $grid->export($handler); 74 $smarty->assign("grid_content", ob_get_contents()); 75 ob_end_clean(); 76} else { 77 $list = []; 78 $encoding = new Encoding(); 79 $charsetList = $encoding->get_input_supported_encodings(); 80 81 $handlers = TikiSheet::getHandlerList(); 82 83 foreach ($handlers as $key => $handler) { 84 $temp = new $handler; 85 if (! $temp->supports(TIKISHEET_LOAD_DATA | TIKISHEET_LOAD_CALC)) { 86 continue; 87 } 88 89 $list[$key] = [ 90 "name" => $temp->name(), 91 "version" => $temp->version(), 92 "class" => $handler 93 ]; 94 } 95 96 $smarty->assign_by_ref("handlers", $list); 97 $smarty->assign_by_ref("charsets", $charsetList); 98} 99 100$cat_type = 'sheet'; 101$cat_objid = $_REQUEST["sheetId"]; 102include_once("categorize_list.php"); 103 104include_once('tiki-section_options.php'); 105 106ask_ticket('sheet'); 107 108// disallow robots to index page: 109$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW'); 110 111// Display the template 112$smarty->assign('mid', 'tiki-import-sheets.tpl'); 113$smarty->display("tiki.tpl"); 114