Commit cfde5745 authored by Naomi Guyer's avatar Naomi Guyer Committed by Aaron Wells

Admin (bootstrap)

Bug 1465107: Use Bootstrap CSS Framework
Admin area
File browser fixes
Style resume pages excluding collapsible elements

Change-Id: Ica76a112b6fcf589f34bcb667ecc1cf426bd7339
parent fbd59ac7
......@@ -115,6 +115,7 @@ function license_submit(Pieform $form, $values) {
$smarty = smarty();
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('form', $form);
$smarty->assign('enabled', get_config('licensemetadata'));
$smarty->display('admin/site/license-edit.tpl');
......@@ -44,6 +44,7 @@ $extralicenses = get_column_sql("
$smarty = smarty();
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('PAGEICON', 'fa fa-legal');
$smarty->assign('licenses', $licenses);
$smarty->assign('extralicenses', $extralicenses);
$smarty->assign('enabled', get_config('licensemetadata'));
......
......@@ -283,6 +283,7 @@ foreach ($all as $k => $v) {
);
}
$footerelements['submit'] = array(
'class' => 'btn btn-success',
'type' => 'submit',
'value' => get_string('savechanges', 'admin')
);
......@@ -324,5 +325,6 @@ $smarty->assign('INLINEJAVASCRIPT', $ijs);
$smarty->assign('MENUS', $menulist);
$smarty->assign('descriptionstrargs', array('<a href="' . get_config('wwwroot') . 'artefact/file/sitefiles.php">', '</a>'));
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('PAGEICON', 'fa fa-bars');
$smarty->assign('footerform', $footerform);
$smarty->display('admin/site/menu.tpl');
......@@ -28,6 +28,8 @@ $xmlrpcext = extension_loaded('xmlrpc');
if (!$opensslext || !$curlext || !$xmlrpcext) {
$smarty = smarty();
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('PAGEICON', 'fa fa-exchange');
$missingextensions = array();
!$opensslext && $missingextensions[] = 'openssl';
!$curlext && $missingextensions[] = 'curl';
......@@ -89,10 +91,12 @@ $networkingform = pieform(
'options' => $yesno,
),
'submit' => array(
'class' => 'btn btn-success',
'type' => 'submit',
'value' => get_string('savechanges','admin')
),
'deletesubmit' => array(
'class' => 'btn btn-danger',
'type' => 'submit',
'title' => get_string('deletekey', 'admin'),
'value' => get_string('delete')
......@@ -158,5 +162,6 @@ function networkingform_submit(Pieform $form, $values) {
$smarty = smarty();
$smarty->assign('networkingform', $networkingform);
$smarty->assign('PAGEICON', 'fa fa-exchange');
$smarty->assign('PAGEHEADING', TITLE);
$smarty->display('admin/site/networking.tpl');
......@@ -46,6 +46,7 @@ $siteoptionform = array(
'jssuccesscallback' => 'checkReload',
'elements' => array(
'sitesettings' => array(
'iconclass' => 'globe',
'type' => 'fieldset',
'collapsible' => true,
'collapsed' => true,
......@@ -113,6 +114,7 @@ $siteoptionform = array(
),
),
'usersettings' => array(
'iconclass' => 'user',
'type' => 'fieldset',
'collapsible' => true,
'collapsed' => true,
......@@ -228,6 +230,7 @@ $siteoptionform = array(
),
),
'searchsettings' => array(
'iconclass' => 'search',
'type' => 'fieldset',
'collapsible' => true,
'collapsed' => true,
......@@ -246,6 +249,7 @@ $siteoptionform = array(
),
),
'groupsettings' => array(
'iconclass' => 'users',
'type' => 'fieldset',
'collapsible' => true,
'collapsed' => true,
......@@ -285,6 +289,7 @@ $siteoptionform = array(
),
),
'institutionsettings' => array(
'iconclass' => 'university',
'type' => 'fieldset',
'collapsible' => true,
'collapsed' => true,
......@@ -323,6 +328,7 @@ $siteoptionform = array(
),
),
'accountsettings' => array(
'iconclass'=>'clock-o',
'type' => 'fieldset',
'collapsible' => true,
'collapsed' => true,
......@@ -386,6 +392,7 @@ $siteoptionform = array(
),
),
'securitysettings' => array(
'iconclass'=>'lock',
'type' => 'fieldset',
'collapsible' => true,
'collapsed' => true,
......@@ -465,6 +472,7 @@ $siteoptionform = array(
),
# TODO: this should become "Network Settings" at some point
'proxysettings' => array(
'iconclass'=>'exchange',
'type' => 'fieldset',
'collapsible' => true,
'collapsed' => true,
......@@ -498,6 +506,7 @@ $siteoptionform = array(
),
),
'emailsettings' => array(
'iconclass'=>'envelope',
'type' => 'fieldset',
'collapsible' => true,
'collapsed' => true,
......@@ -556,6 +565,7 @@ $siteoptionform = array(
),
),
'notificationsettings' => array(
'iconclass'=>'bell',
'type' => 'fieldset',
'collapsible' => true,
'collapsed' => true,
......@@ -571,6 +581,7 @@ $siteoptionform = array(
$notificationelements),
),
'generalsettings' => array(
'iconclass'=>'cog',
'type' => 'fieldset',
'collapsible' => true,
'collapsed' => true,
......@@ -713,6 +724,8 @@ $siteoptionform = array(
),
),
'loggingsettings' => array(
'iconclass'=>'exclamation-triangle',
'class' => 'last',
'type' => 'fieldset',
'collapsible' => true,
'collapsed' => true,
......@@ -746,6 +759,7 @@ $siteoptionform = array(
$siteoptionform['elements']['submit'] = array(
'type' => 'submit',
'class' => 'btn btn-success mtm',
'value' => get_string('updatesiteoptions', 'admin')
);
......@@ -956,5 +970,6 @@ $thispage = json_encode(get_config('wwwroot') . 'admin/site/options.php');
$smarty = smarty(array('adminsiteoptions'));
$smarty->assign('siteoptionform', $siteoptionform);
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('PAGEICON', 'fa fa-cogs');
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->display('admin/site/options.tpl');
......@@ -65,6 +65,7 @@ $form = pieform(array(
)
),
'submit' => array(
'class' => 'btn btn-success',
'type' => 'submit',
'value' => get_string('savechanges', 'admin')
),
......@@ -91,5 +92,6 @@ function editsitepage_submit(Pieform $form, $values) {
$smarty = smarty(array('adminsitepages'), array(), array('admin' => array('discardpageedits')));
$smarty->assign('pageeditform', $form);
$smarty->assign('PAGEICON', 'fa fa-pencil');
$smarty->assign('PAGEHEADING', TITLE);
$smarty->display('admin/site/pages.tpl');
......@@ -19,6 +19,7 @@ define('TITLE', get_string('share', 'view'));
$accesslists = View::get_accesslists(null, null, 'mahara');
$smarty = smarty();
$smarty->assign('PAGEICON', 'fa fa-key');
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('accesslists', $accesslists);
$smarty->display('view/share.tpl');
......@@ -60,6 +60,7 @@ $createviewform = pieform(create_view_form(null, 'mahara'));
$smarty = smarty(array('paginator'));
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('PAGEICON', 'fa fa-file-text');
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('views', $views);
$smarty->assign('institution', 'mahara');
......
......@@ -494,7 +494,7 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
return false;
}
});
ul.append($j('<li><span class="fa fa-share-alt prm"></span>').append(link));
ul.append($j('<li><span class="fa fa-folder prm"></span>').append(link));
}
else {
movefoldercount --;
......@@ -606,12 +606,13 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
setStyle(elem, {
'position': 'absolute',
'border': '2px solid #aaa'
});
setElementDimensions(elem, dimensions);
}
},
// This is actually an 'ondragfail' methodm, rather than a user revert
revert: function (element) {
if (self.drag.clone) {
removeElement(element);
forEach(Draggables.drags, function(drag) {
......@@ -620,7 +621,7 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
}
});
element = null;
self.make_icon_draggable(self.drag.clone);
// /self.make_icon_draggable(self.drag.clone);
self.drag = {};
}
}
......
......@@ -10,6 +10,7 @@
// set up the dropzone
jQuery(document).ready(function() {
// to avoid any clashes with other javascript
var j = jQuery.noConflict();
// turn on the 'drop file here' area for browsers that can handle it.
......
......@@ -26,6 +26,7 @@ $js = ArtefactTypeFileBase::files_js();
$smarty = smarty();
$smarty->assign('descriptionstrargs', array('<a href="' . get_config('wwwroot') . 'admin/site/menu.php">', '</a>'));
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('PAGEICON', 'fa fa-file-image-o');
$smarty->assign('institution', 'mahara');
$smarty->assign('form', $form);
$smarty->assign('INLINEJAVASCRIPT', $js);
......
......@@ -76,6 +76,7 @@ $elements['filebrowser'] = array(
// Add other necessary pieform elements
$elements['submitform'] = array(
'type' => 'submitcancel',
'class' => 'btn btn-success',
'value' => array(get_string('save'), get_string('cancel')),
'goto' => get_config('wwwroot') . 'artefact/resume/' . $tabs[$type] . '.php',
);
......
......@@ -108,6 +108,7 @@ $form = pieform(array(
),
'submitform' => array(
'type' => 'submitcancel',
'class' => 'btn btn-success',
'value' => array(get_string('save'), get_string('cancel')),
'goto' => get_config('wwwroot') . 'artefact/resume/goalsandskills.php',
),
......
......@@ -955,10 +955,12 @@ function toggleCompositeForm(type) {
if (elem.hasClass('hidden')) {
elem.removeClass('hidden');
elem.find(':input').first().focus();
\$j('#add' + type + 'button').html({$cancelstr});
\$j('#add' + type + 'button').removeClass('btn-success');
\$j('#add' + type + 'button').addClass('btn-danger').html({$cancelstr});
}
else {
\$j('#add' + type + 'button').html({$addstr});
\$j('#add' + type + 'button').removeClass('btn-danger');
\$j('#add' + type + 'button').addClass('btn-success').html({$addstr});
elem.addClass('hidden');
}
}
......@@ -1022,7 +1024,7 @@ EOF;
e.stop();
return showhideComposite(r, {$bodystring}, {$attachstring});
});
var extra = DIV(null, {$extrastring});
var extra = DIV({'class': 'detail'}, {$extrastring});
return TD({'id': 'composite-' + r.artefact + '-' + r.id}, DIV({'class': 'expandable-head'}, link, extra));
},
";
......@@ -1084,7 +1086,10 @@ EOF;
function (r, d) {
var buttons = [];
if (r._rownumber > 1) {
var up = A({'href': ''}, IMG({'src': {$imagemoveblockup}, 'alt':'{$upstr}'}));
var up =
A({'href': '', 'class': 'btn btn-default btn-xs'},
SPAN({'class': 'fa fa-arrow-up'}),
SPAN({'class': 'sr-only'}, '{$upstr}'));
connect(up, 'onclick', function (e) {
e.stop();
return moveComposite(d.type, r.id, r.artefact, 'up');
......@@ -1092,7 +1097,10 @@ EOF;
buttons.push(up);
}
if (!r._last) {
var down = A({'href': '', 'class':'movedown'}, IMG({'src': {$imagemoveblockdown}, 'alt':'{$downstr}'}));
var down =
A({'href': '', 'class':'btn btn-default btn-xs movedown'},
SPAN({'class': 'fa fa-arrow-down'}),
SPAN({'class': 'sr-only'}, '{$downstr}'));
connect(down, 'onclick', function (e) {
e.stop();
return moveComposite(d.type, r.id, r.artefact, 'down');
......@@ -1108,8 +1116,14 @@ EOF;
$js .= <<<EOF
function (r, d) {
var editlink = A({'href': 'editcomposite.php?id=' + r.id + '&artefact=' + r.artefact, 'title': {$editstr}}, IMG({'src': config.theme['images/btn_edit.png'], 'alt':{$editjsstr}}));
var dellink = A({'href': '', 'title': {$delstr}}, IMG({'src': config.theme['images/btn_deleteremove.png'], 'alt': {$deljsstr}}));
var editlink =
A({'href': 'editcomposite.php?id=' + r.id + '&artefact=' + r.artefact, 'title': {$editstr}, 'class': 'btn btn-default btn-xs'},
SPAN({'class': 'fa fa-pencil'}),
SPAN({'class': 'sr-only'}, {$editstr}));
var dellink =
A({'href': '', 'title': {$delstr}, 'class': 'btn btn-danger btn-xs'},
SPAN({'class': 'fa fa-trash'}),
SPAN({'class': 'sr-only'}, {$deljsstr}));
connect(dellink, 'onclick', function (e) {
e.stop();
return deleteComposite(d.type, r.id, r.artefact);
......@@ -1153,7 +1167,7 @@ function listAttachments(attachments) {
var link = A({'href': href}, {$downloadstr});
appendChildNodes(tbody, TR(null, TD(null, item.title + ' (' + formatSize(item.size) + ') - ', STRONG(null, link))));
}
return TABLE({'class': 'cb attachments fullwidth'}, thead, tbody);
return TABLE({'class': 'cb attachments fullwidth table'}, thead, tbody);
}
else {
// No attachments
......@@ -1170,6 +1184,7 @@ EOF;
$elements = call_static_method(generate_artefact_class_name($compositetype), 'get_addform_elements');
$elements['submit'] = array(
'type' => 'submit',
'class' => 'btn btn-success',
'value' => get_string('save'),
);
$elements['compositetype'] = array(
......
......@@ -121,7 +121,9 @@ if (!empty($groupid)) {
else {
$smarty->assign('PAGEHEADING', SUBTITLE);
}
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('PAGEICON', 'fa fa-folder-open');
$smarty->assign_by_ref('form', $form);
$smarty->display('collection/edit.tpl');
......
......@@ -130,5 +130,6 @@ $smarty->assign('urlparamsstr', $urlparamsstr);
$smarty->assign('collections', $data->data);
$smarty->assign('pagination', $pagination['html']);
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('PAGEICON', 'fa fa-folder-open');
$smarty->assign('PAGESUBHEADING', SUBTITLE);
$smarty->display('collection/index.tpl');
......@@ -125,6 +125,7 @@ if ($available = Collection::available_views($owner, $groupid, $institutionname)
);
}
$elements['submit'] = array(
'class' => 'btn btn-primary pull-right input-with-icon icon-arrow-right',
'type' => 'submit',
'value' => get_string('addviews','collection'),
'goto' => get_config('wwwroot') . 'collection/views.php?id='.$id,
......@@ -292,6 +293,7 @@ if (!empty($groupid)) {
else {
$smarty->assign('PAGEHEADING', SUBTITLE);
}
$smarty->assign('PAGEICON', 'fa fa-folder-open');
$smarty->assign('INLINEJAVASCRIPT', $inlinejs);
$smarty->assign('baseurl', $baseurl);
$smarty->assign('displayurl', get_config('wwwroot') . 'collection/views.php?id=' . $id);
......
......@@ -107,11 +107,11 @@ function pieform_element_calendar(Pieform $form, $element) {/*{{{*/
},
';
if (isset($element['imagefile'])) {
$result .= 'showOn: "button",
buttonImage: "' . $element['imagefile'] . '",
buttonText: "' . get_string('element.calendar.opendatepicker', 'pieforms') . '",';
}
// if (isset($element['imagefile'])) {
// $result .= 'showOn: "button",
// buttonImage: "' . $element['imagefile'] . '",
// buttonText: "' . get_string('element.calendar.opendatepicker', 'pieforms') . '",';
// }
$result .= '
});
</script>';
......
......@@ -35,81 +35,92 @@ $_PIEFORM_FIELDSETS = array();
* @param array $element The element to render
* @return string The HTML for the element
*/
function pieform_element_fieldset(Pieform $form, $element) {/*{{{*/
function pieform_element_fieldset(Pieform $form, $element) {
global $_PIEFORM_FIELDSETS;
$result = "\n<fieldset";
$classes = array('pieform-fieldset');
$openparam = false;
$formname = $form->get_name();
$legendcontent = Pieform::hsc($element['legend']);
$iscollapsible = pieform_is_collapsible($element);
$iscollapsed = pieform_is_collapsed($form, $element);
$classes = array('pieform-fieldset', 'collapsible');
if (!empty($element['class'])) {
$classes[] = Pieform::hsc($element['class']);
}
if (!empty($element['collapsible'])) {
if (!isset($element['legend']) || $element['legend'] === '') {
Pieform::info('Collapsible fieldsets should have a legend so they can be toggled');
}
$classes[] = 'collapsible';
$formname = $form->get_name();
$fieldset = '<fieldset class="' . implode(' ', $classes) . '">';
// if fieldset is collapsible, we need to adjust the legend html
if ($iscollapsible) {
// Why is this here? What does it do that is different with collapsible fieldsets?
if (!isset($_PIEFORM_FIELDSETS['forms'][$formname])) {
$_PIEFORM_FIELDSETS['forms'][$formname] = array('formname' => $formname);
}
if (isset($element['name'])) {
$openparam = $formname . '_' . $element['name'] . '_open';
}
// Work out whether any of the children have errors on them
$error = false;
foreach ($element['elements'] as $subelement) {
if (isset($subelement['error'])) {
$error = true;
break;
}
}
if (!empty($element['collapsed']) && !$error
&& (!isset($element['name'])
|| (param_alphanumext('fs', null) != $element['name'] && !param_boolean($openparam, false)))) {
$classes[] = 'collapsed';
$triggerclass = $iscollapsed ? 'collapsed': '';
$legendcontent = '<a href="#' . $openparam . '" data-toggle="collapse" aria-expanded="'.$iscollapsed.'" aria-controls="' . $openparam . '" class="'.$triggerclass.'">';
if (!empty($element['iconclass'])){
$legendcontent .= '<span class="fa fa-'.$element['iconclass'].' prl type-icon"> </span>';
}
$legendcontent .= Pieform::hsc($element['legend']);
$legendcontent .= '<span class="fa fa-chevron-down pls collapse-indicator pull-right"> </span> ';
$legendcontent .= '</a>';
}
$result .= ' class="' . implode(' ', $classes) . '"';
$result .= ">\n";
// Render legend and associated objects
if (isset($element['legend'])) {
$result .= '<legend><h4>';
if (!empty($element['collapsible'])) {
$result .= '<a href="">' . Pieform::hsc($element['legend']) . '</a>';
if (isset($openparam)) {
$result .= '<input type="hidden" name="' . hsc($openparam) . '" class="open-fieldset-input" '
. 'value="' . intval(!in_array('collapsed', $classes)) . '">';
}
}
else {
$result .= Pieform::hsc($element['legend']);
}
$fieldset .= '<legend><h4>' . $legendcontent;
// Help icon
if (!empty($element['help'])) {
$function = $form->get_property('helpcallback');
if (function_exists($function)) {
$result .= $function($form, $element);
$fieldset .= $function($form, $element);
}
else {
$result .= '<span class="help"><a href="" title="' . Pieform::hsc($element['help']) . '" onclick="return false;">?</a></span>';
$fieldset .= '<span class="help"><a href="" title="' . Pieform::hsc($element['help']) . '" onclick="return false;">?</a></span>';
}
}
$result .= "</h4></legend>\n";
$fieldset .= "</h4></legend>\n";
}
// Render the body of the fieldset
$stateClass = $iscollapsed ? '':'in';
$fieldset.='<div class="fieldset-body collapse '.$stateClass.'" id="'.$openparam.'">';
if (!empty($element['renderer']) && $element['renderer'] == 'multicolumnfieldsettable') {
$result .= _render_elements_as_multicolumn($form, $element);
$fieldset .= _render_elements_as_multicolumn($form, $element);
}
else {
foreach ($element['elements'] as $subname => $subelement) {
if ($subelement['type'] == 'hidden') {
throw new PieformException("You cannot put hidden elements in fieldsets");
}
$result .= "\t" . pieform_render_element($form, $subelement);
$fieldset .= "\t" . pieform_render_element($form, $subelement);
}
}
$result .= "</fieldset>\n";
return $result;
}/*}}}*/
$fieldset .= '</div>';
$fieldset .= "</fieldset>\n";
return $fieldset;
}
function _render_elements_as_multicolumn($form, $element) {
// we want to render the elements as div within each table cell
......@@ -190,52 +201,65 @@ function _render_elements_as_multicolumn($form, $element) {
return $result;
}
function pieform_element_fieldset_js() {/*{{{*/
return <<<EOF
function pieform_update_legends(element) {
if (!element) {
element = getFirstElementByTagAndClassName('body');
}
forEach(getElementsByTagAndClassName('fieldset', 'collapsible', element), function(fieldset) {
if (!hasElementClass(fieldset, 'pieform-fieldset')) {
return;
}
var legend = getFirstElementByTagAndClassName('legend', null, fieldset);
var legendh4 = getFirstElementByTagAndClassName('h4', null, legend);
if (legendh4.firstChild.tagName == 'A') {
connect(legendh4.firstChild, 'onclick', function(e) {
toggleElementClass('collapsed', fieldset);
var isCollapsed = hasElementClass(fieldset, 'collapsed');
if (!isCollapsed) {
jQuery(fieldset).find(':input').not('.open-fieldset-input').first().focus();
}
var input = getFirstElementByTagAndClassName('input', 'open-fieldset-input', legendh4);
if (input) {
input.value = !isCollapsed;
}
e.stop();
});
/**
* Check if the form is supposed to be collapsed
* @param array $element The element to render
* @return boolean if the fieldset should be collapsed
*/
function pieform_is_collapsed(Pieform $form, $element) {
$formname = $form->get_name();
$iscollapsed = !empty($element['collapsed']);
//if name element is not set, element should not be collapsed
$iscollapsed = !isset($element['name']) ? false : $iscollapsed;
$valid = param_alphanumext('fs', null) !== $element['name'];
// Work out whether any of the children have errors on them
foreach ($element['elements'] as $subelement) {
if (isset($subelement['error'])) {
return false; // collapsible element should be open
}
});
}
if (isset($element['name'])) {
$openparam = $formname . '_' . $element['name'] . '_open';
}
if ($iscollapsed && $valid && !param_boolean($openparam, false)) {
return true;
}
return false;
}
EOF;
}/*}}}*/
function pieform_element_fieldset_get_headdata() {/*{{{*/
global $_PIEFORM_FIELDSETS;
/**
* Check if the fieldset is supposed to be collapsible
* @param array $element The element to render
* @return boolean If the fieldset is collapsible
*/
function pieform_is_collapsible($element) {
$result = '<script type="application/javascript">';
$result .= pieform_element_fieldset_js();
foreach ($_PIEFORM_FIELDSETS['forms'] as $fieldsetform) {
$result .= "\nPieformManager.connect('onload', '{$fieldsetform['formname']}', partial(pieform_update_legends, '{$fieldsetform['formname']}'));";
if (empty($element['collapsible']) || !$element['collapsible']) {