Refactor server_engines templates

Signed-off-by: Leonardo Strozzi <laps15@inf.ufpr.br>
This commit is contained in:
Leonardo Strozzi 2018-06-27 17:50:40 -03:00
parent 28d890f7f7
commit 36ceaee55a
3 changed files with 22 additions and 42 deletions

View File

@ -43,6 +43,7 @@ class ServerEnginesController extends Controller
'type' => 'engines',
])
);
$html = '';
/**
* Did the user request information about a certain storage engine?
@ -50,50 +51,29 @@ class ServerEnginesController extends Controller
if (empty($_REQUEST['engine'])
|| ! StorageEngine::isValid($_REQUEST['engine'])
) {
$this->response->addHTML($this->_getHtmlForAllServerEngines());
$html = $this->template->render('server/engines/list_engines', [
'engines' => StorageEngine::getStorageEngines(),
]);
} else {
$engine = StorageEngine::getEngine($_REQUEST['engine']);
$this->response->addHTML($this->_getHtmlForServerEngine($engine));
$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : '';
$pageOutput = ! empty($page) ? $engine->getPage($page) : '';
/**
* Displays details about a given Storage Engine
*/
$html = $this->template->render('server/engines/show_engine', [
'title' => $engine->getTitle(),
'help_page' => $engine->getMysqlHelpPage(),
'comment' => $engine->getComment(),
'info_pages' => $engine->getInfoPages(),
'support' => $engine->getSupportInformationMessage(),
'variables' => $engine->getHtmlVariables(),
'page_output' => $pageOutput,
'page' => $page,
'engine' => $_REQUEST['engine'],
]);
}
}
/**
* Return HTML with all Storage Engine information
*
* @return string
*/
private function _getHtmlForAllServerEngines()
{
return $this->template->render('server/engines/engines', [
'engines' => StorageEngine::getStorageEngines(),
]);
}
/**
* Return HTML for a given Storage Engine
*
* @param StorageEngine $engine storage engine
*
* @return string
*/
private function _getHtmlForServerEngine(StorageEngine $engine)
{
$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : '';
$pageOutput = ! empty($page) ? $engine->getPage($page) : '';
/**
* Displays details about a given Storage Engine
*/
return $this->template->render('server/engines/engine', [
'title' => $engine->getTitle(),
'help_page' => $engine->getMysqlHelpPage(),
'comment' => $engine->getComment(),
'info_pages' => $engine->getInfoPages(),
'support' => $engine->getSupportInformationMessage(),
'variables' => $engine->getHtmlVariables(),
'page_output' => $pageOutput,
'page' => $page,
'engine' => $_REQUEST['engine'],
]);
$this->response->addHTML($html);
}
}