summaryrefslogtreecommitdiff
path: root/app/Controller/Doc.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-05-28 11:31:54 -0400
committerFrederic Guillot <fred@kanboard.net>2016-05-28 11:31:54 -0400
commitab48a09f0d674b703467975b376c5ac7352670ae (patch)
tree99fbb0cf719acee8c500622d498bd7f6375b62a1 /app/Controller/Doc.php
parent82b5b491bec94cb3d40a5820fbef9959435309be (diff)
Rename controllers
Diffstat (limited to 'app/Controller/Doc.php')
-rw-r--r--app/Controller/Doc.php92
1 files changed, 0 insertions, 92 deletions
diff --git a/app/Controller/Doc.php b/app/Controller/Doc.php
deleted file mode 100644
index 5caf5f5f..00000000
--- a/app/Controller/Doc.php
+++ /dev/null
@@ -1,92 +0,0 @@
-<?php
-
-namespace Kanboard\Controller;
-
-use Parsedown;
-
-/**
- * Documentation Viewer
- *
- * @package controller
- * @author Frederic Guillot
- */
-class Doc extends BaseController
-{
- public function show()
- {
- $page = $this->request->getStringParam('file', 'index');
-
- if (!preg_match('/^[a-z0-9\-]+/', $page)) {
- $page = 'index';
- }
-
- if ($this->language->getCurrentLanguage() === 'fr_FR') {
- $filename = __DIR__.'/../../doc/fr/' . $page . '.markdown';
- } else {
- $filename = __DIR__ . '/../../doc/' . $page . '.markdown';
- }
-
- if (!file_exists($filename)) {
- $filename = __DIR__.'/../../doc/index.markdown';
- }
-
- $this->response->html($this->helper->layout->app('doc/show', $this->render($filename)));
- }
-
- /**
- * Display keyboard shortcut
- */
- public function shortcuts()
- {
- $this->response->html($this->template->render('config/keyboard_shortcuts'));
- }
-
- /**
- * Prepare Markdown file
- *
- * @access private
- * @param string $filename
- * @return array
- */
- private function render($filename)
- {
- $data = file_get_contents($filename);
- $content = preg_replace_callback('/\((.*.markdown)\)/', array($this, 'replaceMarkdownUrl'), $data);
- $content = preg_replace_callback('/\((screenshots.*\.png)\)/', array($this, 'replaceImageUrl'), $content);
-
- list($title, ) = explode("\n", $data, 2);
-
- return array(
- 'content' => Parsedown::instance()->text($content),
- 'title' => $title !== 'Documentation' ? t('Documentation: %s', $title) : $title,
- );
- }
-
- /**
- * Regex callback to replace Markdown links
- *
- * @access public
- * @param array $matches
- * @return string
- */
- public function replaceMarkdownUrl(array $matches)
- {
- return '('.$this->helper->url->to('doc', 'show', array('file' => str_replace('.markdown', '', $matches[1]))).')';
- }
-
- /**
- * Regex callback to replace image links
- *
- * @access public
- * @param array $matches
- * @return string
- */
- public function replaceImageUrl(array $matches)
- {
- if ($this->language->getCurrentLanguage() === 'fr_FR') {
- return '('.$this->helper->url->base().'doc/fr/'.$matches[1].')';
- }
-
- return '('.$this->helper->url->base().'doc/'.$matches[1].')';
- }
-}