HuasoFoundries /
phpPgAdmin6
| 1 | <?php |
||
| 2 | |||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 3 | /* |
||
| 4 | * PHPPgAdmin v6.0.0-beta.30 |
||
| 5 | */ |
||
| 6 | |||
| 7 | namespace PHPPgAdmin\Controller; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Base controller class. |
||
| 11 | */ |
||
| 12 | class HelpController extends BaseController |
||
| 13 | { |
||
| 14 | public $controller_name = 'HelpController'; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Default method to render the controller according to the action parameter. |
||
| 18 | */ |
||
| 19 | public function render() |
||
| 20 | { |
||
| 21 | $action = $this->action; |
||
| 22 | |||
| 23 | switch ($action) { |
||
| 24 | case 'browse': |
||
| 25 | $this->doBrowse(); |
||
| 26 | |||
| 27 | break; |
||
| 28 | default: |
||
| 29 | $this->doDefault(); |
||
| 30 | |||
| 31 | break; |
||
| 32 | } |
||
| 33 | } |
||
| 34 | |||
| 35 | public function doDefault() |
||
| 36 | { |
||
| 37 | $lang = $this->lang; |
||
| 38 | $data = $this->misc->getDatabaseAccessor(); |
||
| 39 | |||
| 40 | if (isset($_REQUEST['help'])) { |
||
| 41 | $url = $data->getHelp($_REQUEST['help']); |
||
| 42 | |||
| 43 | \PC::debug(['url' => $url], 'HelpController::doDefault'); |
||
| 44 | if (is_array($url)) { |
||
| 45 | $this->doChoosePage($url); |
||
| 46 | |||
| 47 | return; |
||
| 48 | } |
||
| 49 | |||
| 50 | if ($url) { |
||
| 51 | header("Location: ${url}"); |
||
| 52 | |||
| 53 | return; |
||
| 54 | } |
||
| 55 | } |
||
| 56 | |||
| 57 | $this->doBrowse($lang['strinvalidhelppage']); |
||
| 58 | } |
||
| 59 | |||
| 60 | public function doBrowse($msg = '') |
||
| 61 | { |
||
| 62 | $lang = $this->lang; |
||
| 63 | $data = $this->misc->getDatabaseAccessor(); |
||
| 64 | |||
| 65 | $this->printHeader($lang['strhelppagebrowser']); |
||
| 66 | $this->printBody(); |
||
| 67 | |||
| 68 | $this->printTitle($lang['strselecthelppage']); |
||
| 69 | |||
| 70 | echo $this->printMsg($msg); |
||
| 71 | |||
| 72 | echo "<dl>\n"; |
||
| 73 | |||
| 74 | $pages = $data->getHelpPages(); |
||
| 75 | foreach ($pages as $page => $dummy) { |
||
| 76 | echo "<dt>{$page}</dt>\n"; |
||
| 77 | |||
| 78 | $urls = $data->getHelp($page); |
||
| 79 | if (!is_array($urls)) { |
||
| 80 | $urls = [$urls]; |
||
| 81 | } |
||
| 82 | |||
| 83 | foreach ($urls as $url) { |
||
| 84 | echo "<dd><a href=\"{$url}\">{$url}</a></dd>\n"; |
||
| 85 | } |
||
| 86 | } |
||
| 87 | |||
| 88 | echo "</dl>\n"; |
||
| 89 | |||
| 90 | $this->printFooter(); |
||
| 91 | } |
||
| 92 | |||
| 93 | public function doChoosePage($urls) |
||
| 94 | { |
||
| 95 | $lang = $this->lang; |
||
| 96 | |||
| 97 | $this->printHeader($lang['strhelppagebrowser']); |
||
| 98 | $this->printBody(); |
||
| 99 | |||
| 100 | $this->printTitle($lang['strselecthelppage']); |
||
| 101 | |||
| 102 | echo "<ul>\n"; |
||
| 103 | foreach ($urls as $url) { |
||
| 104 | echo "<li><a href=\"{$url}\">{$url}</a></li>\n"; |
||
| 105 | } |
||
| 106 | echo "</ul>\n"; |
||
| 107 | |||
| 108 | $this->printFooter(); |
||
| 109 | } |
||
| 110 | } |
||
| 111 |