public function saveBook($book, $inputFormat = 'jsons', $outputFormat = 'dbs') { //$book = stripslashes($book); $newBook = new Book(); switch ($inputFormat) { case 'json': default: $json_obj = json_decode($book); if (!isset($json_obj)) { $error = new GsError(401, "Ups!!! Sorry, Book has not received properly to server. Be aware you are running an alpha version."); if ($error->isDebugging()) { $error->addContentElement("Recieved data", $book); } throw $error; } //TODO: Remove when user functionalities added $json_obj->userId = 0; $newBook->fromJson($json_obj); break; } if ($outputFormat == 'db') { // Permission check if (is_numeric($newBook->bookId)) { $this->security->checkWrite($newBook->bookId); } else { $this->security->checkCreate(); } $newBook->save(); } else { $controller = new ExportController(); switch ($outputFormat) { case 'xls': $controller->generateBook($newBook, $outputFormat); break; case 'xlsx': $controller->generateBook($newBook, $outputFormat); break; case 'pdf': $controller->generateBook($newBook, $outputFormat); break; case 'ods': $controller->generateBook($newBook, $outputFormat); break; default: $errors = $newBook->save(); if (!$errors) { throw new Success('Book saved succesfully', "{'BookId':" . $newBook->getId() . "}"); } else { $error = new GsError(302, "Error saving book."); throw $error; } break; } } }
public static function export($class, $metodo, $filename) { $val = parse_all_arr($_GET['params']); $dadosHead = parse_all_arr($_GET['head']); $head = self::formatHead($dadosHead); self::$exception = isset($_GET['exception']) ? $_GET['exception'] : false; $classe = $class; $metodo = $metodo; $parametros = $val; $retorno = call_user_func_array(array(new $classe(), $metodo), $parametros); $aux = $retorno; $filename = $filename . "_" . date('d-m-Y H:i:s'); $csv = self::geraLinha($head); foreach ($retorno as $val) { foreach ($val as $key_val => $value_val) { $val[$key_val] = $value_val === null ? '' : $value_val; } $csv .= self::geraLinha($val, $dadosHead); } header("Content-type: text/csv;charset=UTF-8"); header("Content-Disposition: attachment; filename={$filename}.csv"); header("Pragma: no-cache"); header("Expires: 0"); echo mb_convert_encoding($csv, 'UTF-16LE', 'UTF-8'); }
/** * End the export and close the export file. * * This method must be called if BeginExport() has been called or else the export file will not be closed. */ public function endExport() { $this->endTime = microtime(true); $this->totalTime = $this->endTime - $this->beginTime; $this->comment($this->path); $this->comment('Export Completed: ' . date('Y-m-d H:i:s')); $this->comment(sprintf('Elapsed Time: %s', self::formatElapsed($this->totalTime))); if ($this->testMode || $this->controller->param('dumpsql') || $this->captureOnly) { $queries = implode("\n\n", $this->queries); if ($this->destination == 'database') { fwrite($this->file, $queries); } else { $this->comment($queries, true); } } if ($this->useCompression() && function_exists('gzopen')) { gzclose($this->file); } else { fclose($this->file); } }
/** * End the export and close the export file. * * This method must be called if BeginExport() has been called or else the export file will not be closed. */ public function EndExport() { $this->EndTime = microtime(true); $this->TotalTime = $this->EndTime - $this->BeginTime; $this->Comment($this->Path); $this->Comment('Export Completed: ' . date('Y-m-d H:i:s')); $this->Comment(sprintf('Elapsed Time: %s', self::FormatElapsed($this->TotalTime))); if ($this->TestMode || $this->Controller->Param('dumpsql') || $this->CaptureOnly) { $Queries = implode("\n\n", $this->Queries); if ($this->Destination == 'database') { fwrite($this->File, $Queries); } else { $this->Comment($Queries, true); } } if ($this->UseCompression() && function_exists('gzopen')) { gzclose($this->File); } else { fclose($this->File); } }
public function testRepliesExport() { $builders = $this->buildData(); $this->simulateLogin('*****@*****.**'); $_GET['u'] = 'someuser1'; $_GET['n'] = 'twitter'; $_GET['type'] = 'replies'; $_GET['post_id'] = '1'; $controller = new ExportController(true); $this->assertTrue(isset($controller)); ob_start(); $controller->control(); $results = ob_get_contents(); ob_end_clean(); $this->assertPattern("/Reply to first post/", $results); }
* * ThinkUp/webapp/post/export.php * * Copyright (c) 2009-2015 Gina Trapani, Christoffer Viken, Mark Wilkie * * LICENSE: * * This file is part of ThinkUp (http://thinkup.com). * * ThinkUp is free software: you can redistribute it and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any * later version. * * ThinkUp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with ThinkUp. If not, see * <http://www.gnu.org/licenses/>. * * * @author Gina Trapani <ginatrapani[at]gmail[dot]com> * @author Christoffer Viken <christoffer[at]viken[dot]me> * @author Mark Wilkie <mark[at]bitterpill[dot]org> * @license http://www.gnu.org/licenses/gpl.html * @copyright 2009-2015 Gina Trapani, Christoffer Viken, Mark Wilkie */ chdir(".."); require_once 'init.php'; $controller = new ExportController(); echo $controller->go();
<?php // coding: latin1 /** * Fanzub - Export * * Copyright 2011 Fanzub.com. All rights reserved. * Do not distribute this file whole or in part without permission. * * $Id$ * @package Fanzub */ require_once '../lib/class.fanzub.php'; require_once '../lib/class.render.php'; class ExportController extends Controller { public function ActionDefault() { header('Content-Type: text/plain; charset=utf-8'); ob_start('ob_gzhandler'); $render = new ExportRender($GLOBALS['config']['url']['base']); echo $render->View(); } } // Display $controller = new ExportController(); echo $controller->Run();