[ajax/add_module] Make add module use ajax

This commit is contained in:
Marc Alexander
2013-11-27 01:09:42 +01:00
parent 3c697881ff
commit 838639ad10
2 changed files with 43 additions and 4 deletions

View File

@@ -448,7 +448,7 @@ class portal_module
}
// do not install if module already exists in that column
if (!$submit && $module_classname != 'custom')
if (!$submit && $module_classname != '\board3\portal\modules\custom')
{
trigger_error($this->user->lang['MODULE_ADD_ONCE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
@@ -579,6 +579,27 @@ class portal_module
'S_MODULE_NAMES' => $options,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
if ($this->request->is_ajax())
{
$this->template->assign_vars(array(
'S_AJAX_REQUEST' => true,
'U_ACTION' => str_replace('&', '&', $this->get_module_link('modules', $module_id)),
));
$this->template->set_filenames(array(
'body' => 'portal/acp_portal_modules.html')
);
$json_response = new \phpbb\json_response;
$json_response->send(array(
'MESSAGE_BODY' => $this->template->assign_display('body'),
'MESSAGE_TITLE' => $this->user->lang['ADD_MODULE'],
'MESSAGE_TEXT' => $this->user->lang['ADD_MODULE'],
'YES_VALUE' => $this->user->lang['SUBMIT'],
'S_CONFIRM_ACTION' => str_replace('&', '&', $this->get_module_link('modules', $module_id)), //inefficient, rewrite whole function
'S_HIDDEN_FIELDS' => $s_hidden_fields
));
}
}
else
{

View File

@@ -1,14 +1,31 @@
<!-- IF S_AJAX_REQUEST -->
<form id="acp_portal_modules" method="post" action="{U_ACTION}">
<fieldset>
<dl>
<dt><label for="module_classname" style="display: inline;">{L_CHOOSE_MODULE}:</label><br /><span>{L_CHOOSE_MODULE_EXP}</span></dt>
<dd><select name="module_classname" id="module_classname">{S_MODULE_NAMES}</select></dd>
</dl>
<p class="submit-buttons">
<input class="button1" type="submit" id="submit" name="submit" value="{L_SUBMIT}" />&nbsp;
<input class="button2" type="reset" id="reset" name="reset" value="{L_RESET}" />
{S_FORM_TOKEN}{S_HIDDEN_FIELDS}
</p>
</fieldset>
</form>
<!-- ELSE -->
<!-- INCLUDE overall_header.html -->
<a name="maincontent"></a>
<!-- IF S_EDIT -->
<h1>{L_ACP_PORTAL_MODULES}</h1>
<p>{L_ACP_PORTAL_MODULES_EXP}</p>
<form id="acp_portal_modules" method="post" action="{U_ACTION}">
<fieldset>
<legend>{L_GENERAL_OPTIONS}</legend>
<dl>
<dt><label for="module_classname">{L_CHOOSE_MODULE}:</label><br /><span>{L_CHOOSE_MODULE_EXP}</span></dt>
<dd><select name="module_classname" id="module_classname">{S_MODULE_NAMES}</select></dd>
@@ -27,7 +44,7 @@
<h1>{L_ACP_PORTAL_MODULES}</h1>
<p>{L_ACP_PORTAL_MODULES_EXP}</p>
<form id="acp_portal_modules" method="post" action="{U_ACTION}">
<form id="acp_portal_modules" method="post" action="{U_ACTION}" data-ajax="true">
<fieldset class="tabulated">
<legend>{L_ACP_PORTAL_MODULES}</legend>
@@ -172,4 +189,5 @@
<!-- ENDIF -->
<!-- INCLUDE overall_footer.html -->
<!-- INCLUDE overall_footer.html -->
<!-- ENDIF -->