From cfde5745d2e2594e0659a46aa5530922a7e51c56 Mon Sep 17 00:00:00 2001 From: Naomi Guyer Date: Tue, 24 Feb 2015 10:14:28 +1300 Subject: [PATCH] Admin (bootstrap) Bug 1465107: Use Bootstrap CSS Framework Admin area File browser fixes Style resume pages excluding collapsible elements Change-Id: Ica76a112b6fcf589f34bcb667ecc1cf426bd7339 --- htdocs/admin/site/license-edit.php | 1 + htdocs/admin/site/licenses.php | 1 + htdocs/admin/site/menu.php | 2 + htdocs/admin/site/networking.php | 5 + htdocs/admin/site/options.php | 15 + htdocs/admin/site/pages.php | 2 + htdocs/admin/site/shareviews.php | 1 + htdocs/admin/site/views.php | 1 + htdocs/artefact/file/js/filebrowser.js | 7 +- htdocs/artefact/file/js/filedropzone.js | 1 + htdocs/artefact/file/sitefiles.php | 1 + htdocs/artefact/resume/editcomposite.php | 1 + htdocs/artefact/resume/editgoalsandskills.php | 1 + htdocs/artefact/resume/lib.php | 31 +- htdocs/collection/edit.php | 2 + htdocs/collection/index.php | 1 + htdocs/collection/views.php | 2 + .../pieforms/pieform/elements/calendar.php | 10 +- .../pieforms/pieform/elements/fieldset.php | 184 +++++----- htdocs/lib/pieforms/pieform/renderers/div.php | 27 +- htdocs/lib/web.php | 4 - .../artefact/file/templates/files.tpl | 30 +- .../file/templates/form/filebrowser.tpl | 26 +- .../artefact/file/templates/form/filelist.tpl | 233 ++++++------ .../resume/templates/fragments/book.tpl | 7 +- .../templates/fragments/certification.tpl | 7 +- .../templates/fragments/educationhistory.tpl | 7 +- .../templates/fragments/employmenthistory.tpl | 7 +- .../resume/templates/fragments/membership.tpl | 7 +- .../static/js/bootstrap-accessibility.min.js | 4 + htdocs/theme/bootstrap/static/js/theme.js | 5 +- .../static/sass/components/_attachments.scss | 2 +- .../sass/components/_contextual-help.scss | 7 + .../static/sass/components/_custom.scss | 16 +- .../sass/components/_dashboard-widget.scss | 338 +++++++++--------- .../sass/components/_dropzone-previews.scss | 22 ++ .../static/sass/components/_filebrowser.scss | 19 - .../static/sass/components/_forms.scss | 161 +++++---- .../sass/components/_input-as-icon.scss | 79 ++++ .../static/sass/components/_layout.scss | 7 +- .../sass/components/_list-elements.scss | 2 +- .../static/sass/components/_panel-items.scss | 146 ++++---- .../sass/components/_pieform-fieldset.scss | 93 +++++ .../static/sass/components/_post.scss | 42 +-- .../static/sass/components/_switches.scss | 23 +- .../static/sass/components/_typography.scss | 105 ++++-- .../static/sass/components/_ui-draggable.scss | 50 +++ htdocs/theme/bootstrap/static/sass/style.scss | 6 + .../utilities/var/_bootstrap-variables.scss | 6 +- .../static/sass/utilities/var/_brand.scss | 6 +- htdocs/theme/bootstrap/static/style/style.css | 4 +- .../templates/admin/site/licenses.tpl | 108 +++--- .../bootstrap/templates/admin/site/menu.tpl | 47 ++- .../templates/admin/site/networking.tpl | 30 +- .../templates/admin/site/options.tpl | 13 +- .../bootstrap/templates/admin/site/pages.tpl | 24 +- .../bootstrap/templates/admin/statistics.tpl | 48 +-- .../bootstrap/templates/collection/index.tpl | 2 +- .../bootstrap/templates/collection/views.tpl | 124 ++++--- .../theme/bootstrap/templates/form/files.tpl | 14 +- .../bootstrap/templates/form/viewacl.tpl | 6 +- .../theme/bootstrap/templates/header/head.tpl | 1 + .../theme/bootstrap/templates/view/index.tpl | 126 ++++--- 63 files changed, 1400 insertions(+), 910 deletions(-) create mode 100644 htdocs/theme/bootstrap/static/js/bootstrap-accessibility.min.js create mode 100644 htdocs/theme/bootstrap/static/sass/components/_dropzone-previews.scss create mode 100644 htdocs/theme/bootstrap/static/sass/components/_input-as-icon.scss create mode 100644 htdocs/theme/bootstrap/static/sass/components/_pieform-fieldset.scss create mode 100644 htdocs/theme/bootstrap/static/sass/components/_ui-draggable.scss diff --git a/htdocs/admin/site/license-edit.php b/htdocs/admin/site/license-edit.php index f594dd0587..b4f035478b 100644 --- a/htdocs/admin/site/license-edit.php +++ b/htdocs/admin/site/license-edit.php @@ -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'); diff --git a/htdocs/admin/site/licenses.php b/htdocs/admin/site/licenses.php index 41e43b465f..a4b2ce1fe7 100644 --- a/htdocs/admin/site/licenses.php +++ b/htdocs/admin/site/licenses.php @@ -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')); diff --git a/htdocs/admin/site/menu.php b/htdocs/admin/site/menu.php index d41b519efd..936d091047 100644 --- a/htdocs/admin/site/menu.php +++ b/htdocs/admin/site/menu.php @@ -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('', '')); $smarty->assign('PAGEHEADING', TITLE); +$smarty->assign('PAGEICON', 'fa fa-bars'); $smarty->assign('footerform', $footerform); $smarty->display('admin/site/menu.tpl'); diff --git a/htdocs/admin/site/networking.php b/htdocs/admin/site/networking.php index 462c84474a..dbee6930ef 100644 --- a/htdocs/admin/site/networking.php +++ b/htdocs/admin/site/networking.php @@ -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'); diff --git a/htdocs/admin/site/options.php b/htdocs/admin/site/options.php index 2fcc51052c..afaefc5ba4 100644 --- a/htdocs/admin/site/options.php +++ b/htdocs/admin/site/options.php @@ -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'); diff --git a/htdocs/admin/site/pages.php b/htdocs/admin/site/pages.php index 4ec3ac8eb4..08833f4b7c 100644 --- a/htdocs/admin/site/pages.php +++ b/htdocs/admin/site/pages.php @@ -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'); diff --git a/htdocs/admin/site/shareviews.php b/htdocs/admin/site/shareviews.php index 9e93c0a97c..050ddd9708 100644 --- a/htdocs/admin/site/shareviews.php +++ b/htdocs/admin/site/shareviews.php @@ -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'); diff --git a/htdocs/admin/site/views.php b/htdocs/admin/site/views.php index adba072475..1a255ae366 100644 --- a/htdocs/admin/site/views.php +++ b/htdocs/admin/site/views.php @@ -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'); diff --git a/htdocs/artefact/file/js/filebrowser.js b/htdocs/artefact/file/js/filebrowser.js index 71785cb21a..d3234c379e 100644 --- a/htdocs/artefact/file/js/filebrowser.js +++ b/htdocs/artefact/file/js/filebrowser.js @@ -494,7 +494,7 @@ function FileBrowser(idprefix, folderid, config, globalconfig) { return false; } }); - ul.append($j('
  • ').append(link)); + ul.append($j('
  • ').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 = {}; } } diff --git a/htdocs/artefact/file/js/filedropzone.js b/htdocs/artefact/file/js/filedropzone.js index 56c0e1e885..432c891084 100644 --- a/htdocs/artefact/file/js/filedropzone.js +++ b/htdocs/artefact/file/js/filedropzone.js @@ -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. diff --git a/htdocs/artefact/file/sitefiles.php b/htdocs/artefact/file/sitefiles.php index 6d43af84cd..cdec34fc46 100644 --- a/htdocs/artefact/file/sitefiles.php +++ b/htdocs/artefact/file/sitefiles.php @@ -26,6 +26,7 @@ $js = ArtefactTypeFileBase::files_js(); $smarty = smarty(); $smarty->assign('descriptionstrargs', array('', '')); $smarty->assign('PAGEHEADING', TITLE); +$smarty->assign('PAGEICON', 'fa fa-file-image-o'); $smarty->assign('institution', 'mahara'); $smarty->assign('form', $form); $smarty->assign('INLINEJAVASCRIPT', $js); diff --git a/htdocs/artefact/resume/editcomposite.php b/htdocs/artefact/resume/editcomposite.php index 2d20159133..e6eb3a04ad 100644 --- a/htdocs/artefact/resume/editcomposite.php +++ b/htdocs/artefact/resume/editcomposite.php @@ -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', ); diff --git a/htdocs/artefact/resume/editgoalsandskills.php b/htdocs/artefact/resume/editgoalsandskills.php index ed24bfe176..954e859a5a 100644 --- a/htdocs/artefact/resume/editgoalsandskills.php +++ b/htdocs/artefact/resume/editgoalsandskills.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', ), diff --git a/htdocs/artefact/resume/lib.php b/htdocs/artefact/resume/lib.php index 65fc28e7ff..2506f36b0e 100644 --- a/htdocs/artefact/resume/lib.php +++ b/htdocs/artefact/resume/lib.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 .= << 'submit', + 'class' => 'btn btn-success', 'value' => get_string('save'), ); $elements['compositetype'] = array( diff --git a/htdocs/collection/edit.php b/htdocs/collection/edit.php index f8a092d431..ca1284ec4a 100644 --- a/htdocs/collection/edit.php +++ b/htdocs/collection/edit.php @@ -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'); diff --git a/htdocs/collection/index.php b/htdocs/collection/index.php index 6a87efabdb..caf675fb20 100644 --- a/htdocs/collection/index.php +++ b/htdocs/collection/index.php @@ -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'); diff --git a/htdocs/collection/views.php b/htdocs/collection/views.php index 7bbf8c8fa3..3295193c9f 100644 --- a/htdocs/collection/views.php +++ b/htdocs/collection/views.php @@ -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); diff --git a/htdocs/lib/pieforms/pieform/elements/calendar.php b/htdocs/lib/pieforms/pieform/elements/calendar.php index d76ecc795a..483c64db10 100644 --- a/htdocs/lib/pieforms/pieform/elements/calendar.php +++ b/htdocs/lib/pieforms/pieform/elements/calendar.php @@ -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 .= ' }); '; diff --git a/htdocs/lib/pieforms/pieform/elements/fieldset.php b/htdocs/lib/pieforms/pieform/elements/fieldset.php index 8bd32c4bd5..eb15cfdb84 100644 --- a/htdocs/lib/pieforms/pieform/elements/fieldset.php +++ b/htdocs/lib/pieforms/pieform/elements/fieldset.php @@ -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 = "\nget_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 = '
    '; + + // 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 = ''; + + if (!empty($element['iconclass'])){ + $legendcontent .= ' '; } + $legendcontent .= Pieform::hsc($element['legend']); + $legendcontent .= ' '; + + $legendcontent .= ''; } - $result .= ' class="' . implode(' ', $classes) . '"'; - $result .= ">\n"; + + // Render legend and associated objects if (isset($element['legend'])) { - $result .= '

    '; - if (!empty($element['collapsible'])) { - $result .= '' . Pieform::hsc($element['legend']) . ''; - if (isset($openparam)) { - $result .= ''; - } - } - else { - $result .= Pieform::hsc($element['legend']); - } + $fieldset .= '

    ' . $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 .= '?'; + $fieldset .= '?'; } } - $result .= "

    \n"; + $fieldset .= "

    \n"; } + // Render the body of the fieldset + $stateClass = $iscollapsed ? '':'in'; + + $fieldset.='
    '; + + 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 .= "
    \n"; - return $result; -}/*}}}*/ + $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 <<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 = '"; + + if (!isset($element['legend']) || $element['legend'] === '') { + Pieform::info('Collapsible fieldsets should have a legend so they can be toggled'); + } + + return true; +} + + +function pieform_element_fieldset_get_headdata() { + global $_PIEFORM_FIELDSETS; // Used below to try to work out whether pieform_update_legends is defined $_PIEFORM_FIELDSETS['head'] = true; return array($result); -}/*}}}*/ +} /** @@ -252,9 +276,7 @@ function pieform_element_fieldset_views_js(Pieform $form, $element) { global $_PIEFORM_FIELDSETS; $result = ''; - if (!isset($_PIEFORM_FIELDSETS['head'])) { - $result .= pieform_element_fieldset_js(); - } + $result .= "pieform_update_legends('instconf');"; foreach ($element['elements'] as $subelement) { diff --git a/htdocs/lib/pieforms/pieform/renderers/div.php b/htdocs/lib/pieforms/pieform/renderers/div.php index e187f955da..e6b2c86ffb 100644 --- a/htdocs/lib/pieforms/pieform/renderers/div.php +++ b/htdocs/lib/pieforms/pieform/renderers/div.php @@ -39,21 +39,27 @@ function pieform_renderer_div(Pieform $form, $element) {/*{{{*/ if (isset($element['name'])) { $result .= ' id="' . $formname . '_' . Pieform::hsc($element['name']) . '_container"'; } - if (!empty($element['class'])) { + - // add form-group classes to all real form fields - if (strpos($element['class'],'html') === false) { - $element['class'] = $element['class'] . ' form-group'; - } + // add form-group classes to all real form fields - // add bootstrap has-error class to any error fields - if (strpos($element['class'],'error') !== false) { - $element['class'] = $element['class'] . ' has-error'; - } + if(isset($element['class'])){ + $element['class'] = $element['class'] . ' form-group'; + } else { + $element['class'] = 'form-group'; + } - $result .= ' class="' . Pieform::hsc($element['class']) . '"'; + if (isset($element['collapsible'])) { + $element['class'] = $element['class'] . ' collapsible-group'; + } + // add bootstrap has-error class to any error fields + if (strpos($element['class'],'error') !== false) { + $element['class'] = $element['class'] . ' has-error'; } + + $result .= ' class="' . Pieform::hsc($element['class']) . '"'; + $result .= '>'; if (isset($element['labelhtml'])) { @@ -64,7 +70,6 @@ function pieform_renderer_div(Pieform $form, $element) {/*{{{*/ $result .= '' . $element['prehtml'] . ''; } - //$result .= $builtelement; $result .= $element['html']; if (isset($element['posthtml'])) { diff --git a/htdocs/lib/web.php b/htdocs/lib/web.php index 761afb4789..f3f84f7f69 100644 --- a/htdocs/lib/web.php +++ b/htdocs/lib/web.php @@ -2082,11 +2082,7 @@ function get_help_icon($plugintype, $pluginname, $form, $element, $page='', $sec json_encode($pluginname) . ',' . json_encode($page) . ',' . json_encode($section) . ',this); return false;' -<<<<<<< HEAD - ) . '">Help'; -======= ) . '">'. get_string('Help') . ''; ->>>>>>> Dashboard and fontawesome (bootstrap) } function pieform_get_help(Pieform $form, $element) { diff --git a/htdocs/theme/bootstrap/artefact/file/templates/files.tpl b/htdocs/theme/bootstrap/artefact/file/templates/files.tpl index 0d358dda85..5b3c89e61a 100644 --- a/htdocs/theme/bootstrap/artefact/file/templates/files.tpl +++ b/htdocs/theme/bootstrap/artefact/file/templates/files.tpl @@ -2,19 +2,25 @@ {if $institution} {$institutionselector|safe} {/if} -{if $institution && $institution == 'mahara'} -

    {str tag="adminfilespagedescription2" section="admin" args=$descriptionstrargs}

    -{else} - {if $institution} -

    {str tag='institutionfilespagedescription1' section='artefact.file'}

    - {else} - {if $group} -

    {str tag='groupfilespagedescription1' section='artefact.file'}

    + + {if $institution && $institution == 'mahara'} +

    {str tag="adminfilespagedescription2" section="admin" args=$descriptionstrargs}

    {else} -

    {str tag='filespagedescription1' section='artefact.file'}

    + {if $institution} +

    {str tag='institutionfilespagedescription1' section='artefact.file'}

    + {else} + {if $group} +

    {str tag='groupfilespagedescription1' section='artefact.file'}

    + {else} +

    {str tag='filespagedescription1' section='artefact.file'}

    + {/if} + {/if} {/if} - {/if} -{/if} -
    {$form|safe}
    + + + + + {$form|safe} + {include file="footer.tpl"} diff --git a/htdocs/theme/bootstrap/artefact/file/templates/form/filebrowser.tpl b/htdocs/theme/bootstrap/artefact/file/templates/form/filebrowser.tpl index eb7f0c8aa3..9ad87060cc 100644 --- a/htdocs/theme/bootstrap/artefact/file/templates/form/filebrowser.tpl +++ b/htdocs/theme/bootstrap/artefact/file/templates/form/filebrowser.tpl @@ -17,7 +17,7 @@ {if $config.selectone} {else} - {/if} @@ -28,7 +28,7 @@ {/if} {if $config.select} -