MDL-64953 templates: Add example contexts & documentation

This is a follow up from CiBot warnings from MDL-58428
This commit is contained in:
Mathew May 2019-04-08 16:32:36 +08:00
parent f622ee97e3
commit 28cbff4a2d
26 changed files with 521 additions and 13 deletions

View File

@ -1,3 +1,32 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template block_search_forums/search_form
This template renders the search form.
Example context (json):
{
"actionurl": "https://domain.example/mod/forum/search.php",
"courseid": "2",
"advancedsearchurl": "https://domain.example/mod/forum/search.php?id=2",
"helpicon": "<a class='btn'><i class='icon fa fa-question-circle'></i></a>"
}
}}
<div class="searchform">
<form action="{{actionurl}}" class="form-inline">
<input type="hidden" name="id" value="{{courseid}}">

View File

@ -1,3 +1,32 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template block_settings/search_form
This template renders the search form.
Example context (json):
{
"action": "https://domain.example/admin/search.php",
"label": "Search in settings",
"searchvalue": "Find this setting",
"quote": "Search"
}
}}
<form method="get" action="{{action}}" class="adminsearchform form-inline" role="search">
<div class="form-group">
<label class="sr-only" for="adminsearchquery">{{label}}</label>

View File

@ -14,6 +14,21 @@
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core_course/course_search_form
This template renders the search form.
Example context (json):
{
"searchurl": "https://domain.example/course/search.php",
"id": "coursesearch",
"inputid": "coursesearchbox",
"inputsize": "30",
"value": "Find in course",
"helpicon": "<a class='btn'><i class='icon fa fa-question-circle'></i></a>"
}
}}
<form action="{{searchurl}}" id="{{id}}" method="get" class="form-inline">
<fieldset class="coursesearchbox invisiblefieldset">
<label for="{{inputid}}">{{#str}}searchcourses{{/str}}</label>

View File

@ -1,3 +1,45 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template gradereport_history/user_button
Template which defines a forum post for sending in a single-post HTML email.
Classes required for JS:
* none
Data attributes required for JS:
* none
Example context (json):
{
"name": "showreport",
"label": "Select users",
"value": "1",
"classes": "singlebutton selectusersbutton gradereport_history_plugin",
"method": "get",
"url": "/grade/report/history/index.php",
"formid": "selectusersbutton{generated}",
"params": "true",
"id": "single_button{generated}",
"tooltip": "Select users",
"disabled": ""
}
}}
<div class="{{classes}}">
<div method="{{method}}" action="{{url}}" id="{{formid}}">
{{#params}}

View File

@ -15,7 +15,25 @@
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template gradereport_singleview/bulk_insert
Bulk insert attribute.
Example context (json):
{
"applyname": "Apply-name",
"applylabel": "Perform bulk insert",
"label": "Bulk insert",
"menuname": "Menu-name",
"menulabel": "For",
"menuoptions": "JSON object",
"value": "all",
"selected": "",
"name": "All grades",
"valuename": "Value-name",
"valuelabel": "Insert value",
"valuefield": "PARSED HTML"
}
}}
<div class="enable">
<input type="checkbox" name="{{applyname}}" value="1" id="{{applyname}}">

View File

@ -15,6 +15,14 @@
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template gradereport_singleview/button
Button.
Example context (json):
{
"type": "submit",
"value": "Save"
}
}}
<input type="{{type}}" value={{#quote}}{{value}}{{/quote}} class="btn btn-secondary">

View File

@ -15,7 +15,18 @@
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template gradereport_singleview/dropdown_attribute
Dropdown attribute.
Example context (json):
{
"name": "Awesome-test",
"disabled": "true",
"options": "true",
"value": "1",
"selected": "true"
}
}}
<select id="{{name}}" name="{{name}}" class="custom-select" tabindex="1" {{#disabled}}disabled{{/disabled}}>
{{#options}}

View File

@ -15,7 +15,18 @@
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template gradereport_singleview/text_attribute
Text attribute.
Example context (json):
{
"name": "Awesome-report",
"label": "Text label",
"value": "Text information",
"tabindex": "1",
"disabled": "true"
}
}}
<label for="{{name}}" class="accesshide">{{label}}</label>
<input id="{{name}}" name="{{name}}" type="text" value="{{value}}" class="form-control" {{#tabindex}}tabindex="{{.}}"{{/tabindex}} {{#disabled}}disabled{{/disabled}}>

View File

@ -15,7 +15,22 @@
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core_grades/edit_tree
Edit tree.
Example context (json):
{
"actionurl": "https://domain.example/grade/edit/tree/index.php?id=4",
"sesskey": "fakesesskey",
"notification": "",
"table": "<table class='generaltable simple setup-grades' id='grade_edit_tree_table'><thead> <tr><th>Name</th><th>Weights</th><th>Max grade</th><th>Actions</th> </tr></thead><tbody></tbody></table>",
"showsave": "true",
"showbulkmove": "true",
"bulkmoveoptions": "{'value' : '1', 'name' : 'Test grade category'}",
"value": "1",
"name": "Test grade category"
}
}}
<form id="gradetreeform" method="post" action="{{actionurl}}">

View File

@ -15,7 +15,16 @@
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core_grades/weight_field
Weight field.
Example context (json):
{
"itemname": "Awesome test",
"id": "2",
"value": "100"
}
}}
<label class="accesshide" for="weight_{{id}}">
{{#str}}extracreditvalue, grades, {{itemname}}{{/str}}

View File

@ -15,7 +15,17 @@
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
Weight field.
@template core_grades/weight_override_field
Weight override field.
Example context (json):
{
"itemname": "Awesome test",
"id": "2",
"checked": "true",
"value": "100"
}
}}
<div class="form-inline">
<label class="accesshide" for="weightoverride_{{id}}">

View File

@ -1232,7 +1232,7 @@ class behat_config_util {
* Return the theme config for a given theme name.
* This is done so we can mock it in PHPUnit.
*
* @param $themename name of theme
* @param string $themename name of theme
* @return theme_config
*/
public function get_theme_config($themename) {

View File

@ -383,7 +383,7 @@ class renderer_base {
/**
* Whether we should display the main logo.
*
* @param int $headinglevel
* @param int $headinglevel The heading level we want to check against.
* @return bool
*/
public function should_display_main_logo($headinglevel = 1) {

View File

@ -1,3 +1,35 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core/custom_menu_item
This template renders a node as part of a submenu.
Example context (json):
{
"divider": "",
"haschildren": "1",
"uniqid": "Unique string",
"text": "Moodle community",
"children": "[custom_menu_item object]",
"title": "Moodle community",
"url": "https://moodle.org"
}
}}
{{^divider}}
{{#haschildren}}
<li class="dropdown nav-item">

View File

@ -1,5 +1,29 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core/filemanager_confirmdialog
This template renders the popup confirm dialogue windows.
Example context (json):
{}
}}
<div class="filemanager fp-dlg">
<p class="fp-dlg-text"></p>
<button class="fp-dlg-butconfirm btn-primary btn">{{#str}}ok{{/str}}</button>
<button class="fp-dlg-butcancel btn-secondary btn">{{#str}}cancel{{/str}}</button>
</div>
</div>

View File

@ -1,4 +1,28 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core/filemanager_default_searchform
This template renders the default repository searchform to be passed to Filepicker.
Example context (json):
{}
}}
<div class="fp-def-search form-group">
<label class="sr-only">{{#str}}searchrepo, repository{{/str}}</label>
<input type="search" class="form-control" id="reposearch" name="s" placeholder="{{#str}}search, repository{{/str}}"/>
</div>
</div>

View File

@ -1,3 +1,29 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core/filemanager_fileselect
This template renders the window with file information/actions.
Example context (json):
{
"helpicon": "<a class='btn ..'><i class='icon fa fa-question-circle ..'></i></a>"
}
}}
<div class="filemanager fp-select">
<div class="fp-select-loading">
{{#pix}}i/loading_small{{/pix}}

View File

@ -1,3 +1,27 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core/filemanager_modal_generallayout
This template renders the general layout (not QuickUpload).
Example context (json):
{}
}}
<div class="container">
<div tabindex="0" class="file-picker fp-generallayout row" role="dialog" aria-live="assertive">
<div class="fp-repo-area col-md-3 pr-2 nav nav-pills flex-column" role="tablist">
@ -60,4 +84,4 @@
</div>
</div>
</div>
</div>
</div>

View File

@ -1,3 +1,31 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core/filemanager_page_generallayout
This template renders the html for displaying one file manager
Example context (json):
{
"client_id": "Unique-string",
"restrictions": "<span>Maximum size for new files: Unlimited</span>",
"helpicon": "<a class='btn'><i class='icon fa fa-question-circle'></i></a>"
}
}}
<div id="filemanager-{{{client_id}}}" class="filemanager w-100 fm-loading">
<div class="fp-restrictions">
{{{restrictions}}}

View File

@ -1,3 +1,27 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core/filemanager_processexistingfile
This template renders the popup dialogue window asking for action when file with the same name already exists.
Example context (json):
{}
}}
<div class="file-picker fp-dlg">
<p class="fp-dlg-text"></p>
<div class="fp-dlg-buttons">
@ -5,4 +29,4 @@
<button class="fp-dlg-butrename btn btn-primary"></button>
<button class="fp-dlg-butcancel btn btn-secondary">{{#str}}cancel{{/str}}</button>
</div>
</div>
</div>

View File

@ -1,3 +1,28 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core/filemanager_processexistingfilemultiple
This template renders the popup dialogue window asking for action when file with the same name already exists
* (multiple-file version).
Example context (json):
{}
}}
<div class="file-picker fp-dlg">
<p class="fp-dlg-text"></p>
<a class="fp-dlg-butoverwrite btn btn-primary" href="#">{{#str}}overwrite, repository{{/str}}</a>
@ -6,4 +31,4 @@
<br/>
<a class="fp-dlg-butoverwriteall btn btn-primary" href="#">{{#str}}overwriteall, repository{{/str}}</a>
<a class="fp-dlg-butrenameall btn btn-primary" href="#">{{#str}}renameall, repository{{/str}}</a>
</div>
</div>

View File

@ -1,3 +1,27 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core/filemanager_selectlayout
This template renders the window appearing to select a file.
Example context (json):
{}
}}
<div class="file-picker fp-select">
<div class="fp-select-loading">
<span class="sr-only">{{#str}}loadinghelp{{/str}}</span>

View File

@ -1,3 +1,27 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core/filemanager_uploadform
This template renders the 'Upload file' repository.
Example context (json):
{}
}}
<div class="fp-upload-form">
<div class="fp-content-center">
<form enctype="multipart/form-data" method="POST" class="form">
@ -26,4 +50,4 @@
<button class="fp-upload-btn btn-primary btn">{{#str}}upload, repository{{/str}}</button>
</div>
</div>
</div>
</div>

View File

@ -15,7 +15,7 @@
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template boost/header
@template core/full_header
This template renders the header.
@ -27,8 +27,6 @@
"navbar": "navbar_if_available",
"courseheader": "course_header_html"
}
Page header.
}}
<header id="page-header" class="row">
<div class="col-12 pt-3 pb-3">
@ -63,4 +61,4 @@
</div>
</div>
</div>
</header>
</header>

View File

@ -1,4 +1,33 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core/preferences_groups
This template renders the preferences groups.
Example context (json):
{
"groups": "[preferences_group Object]",
"nodes": "navigation_node_collection Object",
"get_title": "User account",
"action": "https://domain.example/user/editadvanced.php?id=2&course=1",
"get_content": "Edit profile"
}
}}
<div class="row">
{{#groups}}
<div class="col-md-4">

View File

@ -1,3 +1,32 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template mod_forum/quick_search_form
This template renders the search form within forums.
Example context (json):
{
"actionurl": "https://domain.example/mod/forum/search.php",
"courseid": "2",
"helpicon": "<a class='btn'><i class='icon fa fa-question-circle'></i></a>",
"query": "find this post"
}
}}
<div class="forumsearch">
<form action="{{actionurl}}" class="form-inline">
<input type="hidden" name="id" value="{{courseid}}">