Implement a simple form to save custom markdown-enabled content in the
forge's admin area that is displayed instead of the default project list. Sanitize the URLs that we're using and make a redirect to the listProjects page when no custom forge page is enabled.
This commit is contained in:
@@ -32,20 +32,40 @@ Pluf::loadFunction('Pluf_Shortcuts_GetFormForModel');
|
||||
class IDF_Views_Admin
|
||||
{
|
||||
/**
|
||||
* Home page of the administration.
|
||||
*
|
||||
* It should provide an overview of the forge status.
|
||||
* Start page of the administration.
|
||||
*/
|
||||
public $home_precond = array('Pluf_Precondition::staffRequired');
|
||||
public function home($request, $match)
|
||||
public $forge_precond = array('Pluf_Precondition::staffRequired');
|
||||
public function forge($request, $match)
|
||||
{
|
||||
$title = __('Forge Management');
|
||||
return Pluf_Shortcuts_RenderToResponse('idf/gadmin/home.html',
|
||||
$forge = IDF_Forge::instance();
|
||||
if ($request->method == 'POST') {
|
||||
$form = new IDF_Form_Admin_ForgeConf($request->POST);
|
||||
if ($form->isValid()) {
|
||||
$forge->setCustomForgePageEnabled($form->cleaned_data['enabled']);
|
||||
$forge->setCustomForgePageContent($form->cleaned_data['content']);
|
||||
$request->user->setMessage(__('The forge configuration has been saved.'));
|
||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Admin::forge');
|
||||
return new Pluf_HTTP_Response_Redirect($url);
|
||||
}
|
||||
} else {
|
||||
$params = array();
|
||||
$params['enabled'] = $forge->isCustomForgePageEnabled();
|
||||
if (($content = $forge->getCustomForgePageContent(false)) !== false) {
|
||||
$params['content'] = $content;
|
||||
}
|
||||
if (count($params) == 0) {
|
||||
$params = null; //Nothing in the db, so new form.
|
||||
}
|
||||
$form = new IDF_Form_Admin_ForgeConf($params);
|
||||
}
|
||||
return Pluf_Shortcuts_RenderToResponse('idf/gadmin/forge/index.html',
|
||||
array(
|
||||
'page_title' => $title,
|
||||
),
|
||||
'page_title' => $title,
|
||||
'form' => $form,
|
||||
),
|
||||
$request);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Projects overview.
|
||||
|
Reference in New Issue
Block a user