Commit a0e20e2e authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files

$LARGE amount of admin screen refactoring. Now it's all in saner

categories, i18n-ised, correctly menued and y2k compliant.
parent 32d5b15c
......@@ -26,6 +26,8 @@
define('INTERNAL', 1);
define('ADMIN', 1);
define('MENUITEM', 'configextensions');
define('SUBMENUITEM', 'pluginadmin');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('pieforms/pieform.php');
......@@ -75,7 +77,7 @@ $smarty->assign('form', pieform($form));
$smarty->assign('plugintype', $plugintype);
$smarty->assign('pluginname', $pluginname);
$smarty->assign('type', $type);
$smarty->display('admin/plugins/pluginconfig.tpl');
$smarty->display('admin/extensions/pluginconfig.tpl');
function pluginconfig_submit($values) {
......
......@@ -26,6 +26,8 @@
define('INTERNAL', 1);
define('ADMIN', 1);
define('MENUITEM', 'configextensions');
define('SUBMENUITEM', 'pluginadmin');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require('upgrade.php');
......@@ -132,6 +134,6 @@ $smarty = smarty();
$smarty->assign('INLINEJAVASCRIPT', $javascript);
$smarty->assign('plugins', $plugins);
$smarty->assign('installlink', 'installplugin');
$smarty->display('admin/plugins/index.tpl');
$smarty->display('admin/extensions/plugins.tpl');
?>
......@@ -252,9 +252,9 @@ foreach ($menulist as &$menu) {
}
$style = '<style type="text/css">.invisible{display:none;}</style>';
$smarty = smarty(array(),array($style));
$smarty->assign('INLINEJAVASCRIPT',$ijs);
$smarty->assign('MENUS',$menulist);
$smarty->display('admin/editmenu.tpl');
$smarty = smarty(array(), array($style));
$smarty->assign('INLINEJAVASCRIPT', $ijs);
$smarty->assign('MENUS', $menulist);
$smarty->display('admin/site/menu.tpl');
?>
......@@ -126,7 +126,7 @@ function siteoptions_submit($values) {
}
$smarty = smarty();
$smarty->assign('SITEOPTIONFORM',$siteoptionform);
$smarty->display('admin/options/index.tpl');
$smarty->assign('SITEOPTIONFORM', $siteoptionform);
$smarty->display('admin/site/options.tpl');
?>
......@@ -27,7 +27,7 @@
define('INTERNAL', 1);
define('ADMIN', 1);
define('MENUITEM', 'configsite');
define('SUBMENUITEM', 'pageeditor');
define('SUBMENUITEM', 'sitepages');
require(dirname(dirname(dirname(__FILE__))).'/init.php');
require_once('pieforms/pieform.php');
......@@ -107,7 +107,7 @@ function requestPageText(removeMessage) {
if (getEditorContent() != originalcontent) {
var answer = confirm({$getstring['discardpageedits']});
if (!answer) {
$('pagename').value = oldpagename;
$('editsitepage_pagename').value = oldpagename;
return;
}
}
......@@ -118,13 +118,13 @@ function requestPageText(removeMessage) {
}
editsitepage_remove_error('pagetext');
logDebug(get_string('loadingpagecontent', 'admin'));
var d = loadJSONDoc('editchangepage.json.php',{'pagename':$('pagename').value});
var d = loadJSONDoc('editchangepage.json.php',{'pagename':$('editsitepage_pagename').value});
d.addCallback(function(data) {
if (!data.error) {
logDebug(get_string('sitepageloaded', 'admin'));
setEditorContent(data.content);
originalcontent = getEditorContent();
oldpagename = $('pagename').value;
oldpagename = $('editsitepage_pagename').value;
}
else {
displayMessage(get_string('loadsitepagefailed', 'admin'));
......@@ -149,12 +149,12 @@ function onLoad() {
getEditorContent = tinyMCE.getContent;
}
else {
setEditorContent = function (c) { $('pagetext').value = c; };
getEditorContent = function () { return $('pagetext').value; };
setEditorContent = function (c) { $('editsitepage_pagetext').value = c; };
getEditorContent = function () { return $('editsitepage_pagetext').value; };
}
originalcontent = getEditorContent();
requestPageText();
connect('pagename', 'onchange', requestPageText);
connect('editsitepage_pagename', 'onchange', requestPageText);
}
addLoadEvent(onLoad);
......@@ -163,6 +163,6 @@ EOJS;
$smarty = smarty($js);
$smarty->assign('pageeditform', $form);
$smarty->assign('INLINEJAVASCRIPT', $ijs);
$smarty->display('admin/editsitepage.tpl');
$smarty->display('admin/site/pages.tpl');
?>
......@@ -73,6 +73,6 @@ function adminusers_submit($values) {
}
$smarty->assign('adminusersform', pieform($form));
$smarty->display('admin/usermanagement/adminusers.tpl');
$smarty->display('admin/users/admin.tpl');
?>
......@@ -47,7 +47,7 @@ if ($institution || $add) {
}
function delete_cancel_submit() {
redirect(get_config('wwwroot') . 'admin/institutions.php');
redirect(get_config('wwwroot') . 'admin/users/institutions.php');
}
function delete_submit($values) {
......@@ -59,7 +59,7 @@ if ($institution || $add) {
db_commit();
$SESSION->add_ok_msg(get_string('institutiondeletedsuccessfully', 'admin'));
redirect(get_config('wwwroot') . 'admin/institutions.php');
redirect(get_config('wwwroot') . 'admin/users/institutions.php');
}
$form = array(
'name' => 'delete',
......@@ -79,7 +79,7 @@ if ($institution || $add) {
)
);
$smarty->assign('delete_form', pieform($form));
$smarty->display('admin/institutions.tpl');
$smarty->display('admin/users/institutions.tpl');
exit;
}
......@@ -234,13 +234,13 @@ function institution_submit($values) {
$message = ($add) ? 'institutionaddedsuccessfully' : 'institutionupdatedsuccessfully';
$SESSION->add_ok_msg(get_string($message, 'admin'));
redirect(get_config('wwwroot') . 'admin/institutions.php');
redirect(get_config('wwwroot') . 'admin/users/institutions.php');
}
function institution_cancel_submit() {
redirect(get_config('wwwroot') . 'admin/institutions.php');
redirect(get_config('wwwroot') . 'admin/users/institutions.php');
}
$smarty->display('admin/institutions.tpl');
$smarty->display('admin/users/institutions.tpl');
?>
......@@ -31,6 +31,6 @@ define('SUBMENUITEM', 'adminnotifications');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$smarty = smarty();
$smarty->display('admin/usermanagement/adminnotifications.tpl');
$smarty->display('admin/users/notifications.tpl');
?>
......@@ -72,6 +72,6 @@ function staffusers_submit($values) {
}
$smarty->assign('staffusersform', pieform($form));
$smarty->display('admin/usermanagement/staffusers.tpl');
$smarty->display('admin/users/staff.tpl');
?>
......@@ -31,6 +31,6 @@ define('SUBMENUITEM', 'suspendedusers');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$smarty = smarty();
$smarty->display('admin/usermanagement/suspendedusers.tpl');
$smarty->display('admin/users/suspended.tpl');
?>
......@@ -171,7 +171,7 @@ function uploadcsv_submit($values) {
$id = insert_record('usr', $user, 'id', true);
$i = 2;
safe_require('artefact', 'internal', 'lib.php');
safe_require('artefact', 'internal');
foreach (ArtefactTypeProfile::get_mandatory_fields() as $field => $type) {
set_profile_field($id, $field, $record[$i++]);
}
......@@ -180,11 +180,11 @@ function uploadcsv_submit($values) {
$SESSION->add_ok_msg(get_string('uploadcsvusersaddedsuccessfully', 'admin'));
// @todo support relative URLs here
redirect(get_config('wwwroot') . 'admin/usermanagement/uploadcsv.php');
redirect(get_config('wwwroot') . 'admin/users/uploadcsv.php');
}
$smarty = smarty();
$smarty->assign('uploadcsvform', pieform($form));
$smarty->display('admin/usermanagement/uploadcsv.tpl');
$smarty->display('admin/users/uploadcsv.tpl');
?>
......@@ -47,21 +47,38 @@ $string['noupgrades'] = 'Nothing to upgrade! You are fully up to date!';
$string['fixtemplatescontinue'] = 'Try fixing this and continuing here (templates were not installed)';
// Admin navigation menu
$string['adminhome'] = 'Admin home';
$string['configsite'] = 'Configure Site';
$string['configusers'] = 'Manage Users';
$string['configextensions'] = 'Administer Extensions';
// Admin homepage strings
$string['siteoptions'] = 'Site options';
$string['siteoptionsdescription'] = 'Configure basic site options such as the name, language and theme';
$string['sitepages'] = 'Site pages';
$string['sitepagesdescription'] = 'Edit the text of the basic pages';
$string['sitemenu'] = 'Site menu';
$string['sitemenudescription'] = 'Manage the links and file that appear in the menus';
$string['adminfiles'] = 'Admin Files';
$string['adminfilesdescription'] = 'Upload and administer files that can be put in the menus (note: not implemented yet)';
$string['suspendedusers'] = 'Suspended Users';
$string['suspendedusersdescription'] = 'Suspend or unsuspend users from logging in to the site (note: not implemented yet)';
$string['staffusers'] = 'Staff Users';
$string['staffusersdescription'] = 'Choose which users can have staff permissions';
$string['adminusers'] = 'Admin Users';
$string['adminusersdescription'] = 'Choose which users are administrators for the site';
$string['institutions'] = 'Institutions';
$string['adminplugins'] = 'Administer Plugins';
$string['files'] = 'Files';
$string['adminhome'] = 'Admin home';
$string['institutionsdescription'] = 'Install and manage installed institutions';
$string['adminnotifications'] = 'Admin Notifications';
$string['adminnotificationsdescription'] = 'Configure how administrators receive system notifications (note: not implemented yet)';
$string['uploadcsv'] = 'Add Users by CSV';
$string['uploadcsvdescription'] = 'Upload a CSV file containing new users';
$string['pluginadmin'] = 'Plugin Administration';
$string['pluginadmindescription'] = 'Install and configure plugins';
$string['templatesadmin'] = 'Configure View Templates';
$string['templatesadmindescription'] = 'View installed templates to check their validity';
// Site options
$string['allowpublicviews'] = 'Allow public views';
......@@ -134,26 +151,21 @@ $string['uploadcsverrorinvalidusername'] = 'Error on line %s of your file: The u
$string['uploadcsverrorincorrectfieldcount'] = 'Line %s of the file does not have the correct number of fields';
$string['uploadcsverrormandatoryfieldnotspecified'] = 'Line %s of the file does not have the required "%s" field';
$string['uploadcsverroruseralreadyexists'] = 'Line %s of the file specifies the username "%s" that already exists';
$string['uploadcsv'] = 'Add Users by CSV';
$string['uploadcsvfile'] = 'Upload CSV File';
$string['uploadcsvfiledescription'] = 'You may use this facility to upload new users via a <acronym title="Comma Separated Values">CSV</acronym> file. Each record in the file must have a username, e-mail address and password.';
$string['uploadcsvpagedescription'] = 'You may use this facility to upload new users via a <acronym title="Comma Separated Values">CSV</acronym> file. Each record in the file must have a username, e-mail address and password.';
$string['uploadcsvusersaddedsuccessfully'] = 'The users in the file have been added successfully';
// Admin Users
$string['adminusers'] = 'Admin Users';
$string['adminusersdescription'] = 'Here you may choose which users are administrators. Admin users are listed in the right box, and potential administrators are on the left.';
$string['adminuserspagedescription'] = 'Here you can choose which users are administrators for the site. The current administrators are on the right, and potential administrators are on the left.';
$string['adminusersupdated'] = 'Admin users updated';
// Staff Users
$string['staffusers'] = 'Staff Users';
$string['staffusersdescription'] = 'Here you may choose which users are staff users. Staff users are listed in the right box, and potential staff users are on the left.';
$string['staffuserspagedescription'] = 'Here you can choose which users are staff for the site. The current staff are on the right, and potential staff are on the left.';
$string['staffusersupdated'] = 'Staff users updated';
// Admin Notifications
$string['adminnotifications'] = 'Admin Notifications';
// Suspended Users
$string['suspendedusers'] = 'Suspended Users';
// Institutions
$string['addinstitution'] = 'Add Institution';
......
......@@ -66,7 +66,6 @@ function pieform($data) {
//
// - more form element types (inc. types like autocomplete and date picker and wyswiyg)
// - support processing of data before validation occurs (e.g. trim(), strtoupper())
// - do onsubmit for ajax stuff by mochikit connect()
// - Basic validation is possible as there's a callback function for checking,
// but some helper functions could be written to make people's job validating
// stuff much easier (form_validate_email, form_validate_date etc).
......@@ -328,7 +327,6 @@ class Pieform {
$formdefaults = array(
'method' => 'get',
'action' => '',
'onsubmit' => '',
'ajaxpost' => false,
'preajaxsubmitcallback' => '',
'postajaxsubmitcallback' => '',
......@@ -354,7 +352,6 @@ class Pieform {
$this->action = $data['action'];
$this->validate = $data['validate'];
$this->submit = $data['submit'];
$this->onsubmit = $data['onsubmit'];
$this->autofocus = $data['autofocus'];
$this->language = $data['language'];
......@@ -683,9 +680,6 @@ class Pieform {
if ($this->fileupload) {
$result .= ' enctype="multipart/form-data"';
}
if ($this->ajaxpost) {
$result .= ' onsubmit="' . $this->name . '_submit(); return false;"';
}
$result .= ">\n";
// @todo masks attempts in pieform_render_element, including the error handling there
......@@ -871,7 +865,8 @@ class Pieform {
private function submit_js() {
// @todo nigel should disable all buttons on this form while the submit is happening
$result = <<<EOF
function {$this->name}_submit() {
connect($('{$this->name}'), 'onsubmit', function (e) {
// eventually we should check input types for wysiwyg before doing this
// Also should only save wysiwyg elements in the form, not all of them...
if (typeof(tinyMCE) != 'undefined') { tinyMCE.triggerSave(); }
......@@ -961,8 +956,8 @@ EOF;
$result .= <<<EOF
});
{$this->name}_message('{$strprocessingform}', 'info');
return false;
}
e.stop();
});
EOF;
......@@ -1110,12 +1105,15 @@ EOF;
* @param array $exclude Any attributes to explicitly exclude from adding
* @return string The attributes for the element
*/
public static function element_attributes($element, $exclude=array()) {
public function element_attributes($element, $exclude=array()) {
static $attributes = array('accesskey', 'class', 'dir', 'id', 'lang', 'name', 'onclick', 'size', 'style', 'tabindex');
$elementattributes = array_diff($attributes, $exclude);
$result = '';
foreach ($elementattributes as $attribute) {
if (isset($element[$attribute]) && $element[$attribute] !== '') {
if ($attribute == 'id') {
$element[$attribute] = $this->name . '_' . $element[$attribute];
}
$result .= ' ' . $attribute . '="' . self::hsc($element[$attribute]) . '"';
}
}
......
......@@ -38,7 +38,7 @@ function pieform_render_button($element, Pieform $form) {
throw new PieformException('Button elements must have a value');
}
return '<input type="button"'
. Pieform::element_attributes($element)
. $form->element_attributes($element)
. ' value="' . Pieform::hsc($element['value']) . '">';
}
......
......@@ -38,7 +38,7 @@ function pieform_render_cancel($element, Pieform $form) {
throw new PieformException('Cancel elements must have a value');
}
$attributes = Pieform::element_attributes($element);
$attributes = $form->element_attributes($element);
$attributes = preg_replace('/name="(.*)"/', 'name="cancel_$1"', $attributes);
$attributes = preg_replace('/id="(.*)"/', 'id="cancel_$1"', $attributes);
return '<input type="submit"'
......
......@@ -46,7 +46,7 @@ function pieform_render_checkbox($element, Pieform $form) {
}
return '<input type="checkbox"'
. Pieform::element_attributes($element)
. $form->element_attributes($element)
. ($checked ? ' checked="checked"' : '')
. '>';
}
......
......@@ -33,7 +33,7 @@
*/
function pieform_render_file($element, Pieform $form) {
return '<input type="file"'
. Pieform::element_attributes($element) . '>';
. $form->element_attributes($element) . '>';
}
function pieform_get_value_file($element, Pieform $form) {
......
......@@ -32,8 +32,6 @@
* @return string The HTML for the element
*/
function pieform_render_hidden($element, Pieform $form) {
// @todo use the exclude parameter of element_attributes for this
unset($element['tabindex']);
$value = $form->get_value($element);
if (is_array($value)) {
$result = '';
......@@ -44,7 +42,7 @@ function pieform_render_hidden($element, Pieform $form) {
return $result;
}
return '<input type="hidden"'
. Pieform::element_attributes($element)
. $form->element_attributes($element, array('accesskey', 'onclick', 'size', 'style', 'tabindex'))
. ' value="' . Pieform::hsc($form->get_value($element)) . "\">\n";
}
......
......@@ -33,7 +33,7 @@
*/
function pieform_render_image($element, Pieform $form) {
return '<input type="image" src="' . Pieform::hsc($element['src']) . '"'
. Pieform::element_attributes($element)
. $form->element_attributes($element)
. ' value="' . Pieform::hsc($form->get_value($element)) . '">';
}
......
......@@ -33,7 +33,7 @@
*/
function pieform_render_password($element, Pieform $form) {
return '<input type="password"'
. Pieform::element_attributes($element)
. $form->element_attributes($element)
. ' value="' . Pieform::hsc($form->get_value($element)) . '">';
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment