From 833bd3f8a90b604f4ab289dab9366c0032ce5216 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sat, 19 Jul 2014 22:08:07 -0230 Subject: Add Task CSV export and Kanboard CLI --- app/Core/Cli.php | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ app/Core/Registry.php | 1 + app/Core/Response.php | 21 ++++++++++---- app/Core/Tool.php | 34 ++++++++++++++++++++++ app/Core/Translator.php | 26 +++++++++++++++-- 5 files changed, 150 insertions(+), 7 deletions(-) create mode 100644 app/Core/Cli.php create mode 100644 app/Core/Tool.php (limited to 'app/Core') diff --git a/app/Core/Cli.php b/app/Core/Cli.php new file mode 100644 index 00000000..13533b9a --- /dev/null +++ b/app/Core/Cli.php @@ -0,0 +1,75 @@ +commands[$command] = $callback; + } + + /** + * Execute a command + * + * @access public + * @param string $command Command name + */ + public function call($command) + { + if (isset($this->commands[$command])) { + $this->commands[$command](); + exit; + } + } + + /** + * Determine which command to execute + * + * @access public + */ + public function execute() + { + if (php_sapi_name() !== 'cli') { + die('This script work only from the command line.'); + } + + if ($GLOBALS['argc'] === 1) { + $this->call($this->default_command); + } + + $this->call($GLOBALS['argv'][1]); + $this->call($this->default_command); + } +} diff --git a/app/Core/Registry.php b/app/Core/Registry.php index 0311dc62..d8b9063e 100644 --- a/app/Core/Registry.php +++ b/app/Core/Registry.php @@ -1,6 +1,7 @@ status($status_code); + $this->nocache(); + header('Content-Type: text/csv'); + Tool::csv($data); + exit; + } + /** * Send a Json response * @@ -83,7 +99,6 @@ class Response $this->nocache(); header('Content-Type: application/json'); echo json_encode($data); - exit; } @@ -100,7 +115,6 @@ class Response $this->nocache(); header('Content-Type: text/plain; charset=utf-8'); echo $data; - exit; } @@ -117,7 +131,6 @@ class Response $this->nocache(); header('Content-Type: text/html; charset=utf-8'); echo $data; - exit; } @@ -134,7 +147,6 @@ class Response $this->nocache(); header('Content-Type: text/xml; charset=utf-8'); echo $data; - exit; } @@ -169,7 +181,6 @@ class Response header('Content-Transfer-Encoding: binary'); header('Content-Type: application/octet-stream'); echo $data; - exit; } diff --git a/app/Core/Tool.php b/app/Core/Tool.php new file mode 100644 index 00000000..ade99cad --- /dev/null +++ b/app/Core/Tool.php @@ -0,0 +1,34 @@ +get($identifier, $identifier)); - foreach ($args as &$arg) { - $arg = htmlspecialchars($arg, ENT_QUOTES, 'UTF-8', false); + if (self::$enable_escaping) { + foreach ($args as &$arg) { + $arg = htmlspecialchars($arg, ENT_QUOTES, 'UTF-8', false); + } } return call_user_func_array( -- cgit v1.2.3