Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
e0757dd5
Commit
e0757dd5
authored
Mar 18, 2019
by
Eloy Lafuente
Browse files
Merge branch 'MDL-63074-master' of
git://github.com/bmbrands/moodle
parents
c8467842
48507e16
Changes
7
Hide whitespace changes
Inline
Side-by-side
admin/tool/customlang/classes/output/renderer.php
0 → 100644
View file @
e0757dd5
<?php
// 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/>.
/**
* Renderer class for tool customlang
*
* @package tool_customlang
* @category output
* @copyright 2019 Bas Brands <bas@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
tool_customlang\output
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
/**
* Renderer for the customlang tool.
*
* @copyright 2019 Bas Brands <bas@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
renderer
extends
\
plugin_renderer_base
{
/**
* Defer to template.
*
* @param tool_customlang_translator $translator
* @return string Html for the translator
*/
protected
function
render_tool_customlang_translator
(
\
tool_customlang_translator
$translator
)
{
$renderabletranslator
=
new
translator
(
$translator
);
$templatevars
=
$renderabletranslator
->
export_for_template
(
$this
);
return
$this
->
render_from_template
(
'tool_customlang/translator'
,
$templatevars
);
}
/**
* Defer to template.
*
* @param tool_customlang_menu $menu
* @return string html the customlang menu buttons
*/
protected
function
render_tool_customlang_menu
(
\
tool_customlang_menu
$menu
)
{
$output
=
''
;
foreach
(
$menu
->
get_items
()
as
$item
)
{
$output
.
=
$this
->
single_button
(
$item
->
url
,
$item
->
title
,
$item
->
method
);
}
return
$this
->
box
(
$output
,
'menu'
);
}
}
admin/tool/customlang/classes/output/translator.php
0 → 100644
View file @
e0757dd5
<?php
// 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/>.
/**
* customlang specific renderers.
*
* @package tool_customlang
* @copyright 2019 Moodle
* @author Bas Brands
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
tool_customlang\output
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
use
renderable
;
use
templatable
;
use
renderer_base
;
use
stdClass
;
/**
* Class containing data for customlang translator page
*
* @copyright 2019 Bas Brands
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
translator
implements
renderable
,
templatable
{
/**
* @var tool_customlang_translator $translator object.
*/
private
$translator
;
/**
* Construct this renderable.
*
* @param tool_customlang_translator $translator The translator object.
*/
public
function
__construct
(
\
tool_customlang_translator
$translator
)
{
$this
->
translator
=
$translator
;
}
/**
* Export the data.
*
* @param renderer_base $output
* @return stdClass
*/
public
function
export_for_template
(
renderer_base
$output
)
{
$data
=
new
stdClass
();
$data
->
nostrings
=
$output
->
notification
(
get_string
(
'nostringsfound'
,
'tool_customlang'
));
$data
->
formurl
=
$this
->
translator
->
handler
;
$data
->
currentpage
=
$this
->
translator
->
currentpage
;
$data
->
sesskey
=
sesskey
();
$data
->
strings
=
[];
if
(
!
empty
(
$this
->
translator
->
strings
))
{
$data
->
hasstrings
=
true
;
foreach
(
$this
->
translator
->
strings
as
$string
)
{
// Find strings that use placeholders.
if
(
preg_match
(
'/\{\$a(->.+)?\}/'
,
$string
->
master
))
{
$string
->
placeholderhelp
=
$output
->
help_icon
(
'placeholder'
,
'tool_customlang'
,
get_string
(
'placeholderwarning'
,
'tool_customlang'
));
}
if
(
!
is_null
(
$string
->
local
)
and
$string
->
outdated
)
{
$string
->
outdatedhelp
=
$output
->
help_icon
(
'markinguptodate'
,
'tool_customlang'
);
$string
->
checkupdated
=
true
;
}
if
(
$string
->
original
!==
$string
->
master
)
{
$string
->
showoriginalvsmaster
=
true
;
}
$string
->
local
=
s
(
$string
->
local
);
$data
->
strings
[]
=
$string
;
}
}
return
$data
;
}
}
\ No newline at end of file
admin/tool/customlang/renderer.php
deleted
100644 → 0
View file @
c8467842
<?php
// 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/>.
/**
* Output rendering of Language customization admin tool
*
* @package tool
* @subpackage customlang
* @copyright 2010 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined
(
'MOODLE_INTERNAL'
)
||
die
();
/**
* Rendering methods for the tool widgets
*/
class
tool_customlang_renderer
extends
plugin_renderer_base
{
/**
* Renders customlang tool menu
*
* @return string HTML
*/
protected
function
render_tool_customlang_menu
(
tool_customlang_menu
$menu
)
{
$output
=
''
;
foreach
(
$menu
->
get_items
()
as
$item
)
{
$output
.
=
$this
->
single_button
(
$item
->
url
,
$item
->
title
,
$item
->
method
);
}
return
$this
->
box
(
$output
,
'menu'
);
}
/**
* Renders customlang translation table
*
* @param tool_customlang_translator $translator
* @return string HTML
*/
protected
function
render_tool_customlang_translator
(
tool_customlang_translator
$translator
)
{
$output
=
''
;
if
(
empty
(
$translator
->
strings
))
{
return
$this
->
notification
(
get_string
(
'nostringsfound'
,
'tool_customlang'
));
}
$table
=
new
html_table
();
$table
->
id
=
'translator'
;
$table
->
head
=
array
(
get_string
(
'headingcomponent'
,
'tool_customlang'
),
get_string
(
'headingstringid'
,
'tool_customlang'
),
get_string
(
'headingstandard'
,
'tool_customlang'
),
get_string
(
'headinglocal'
,
'tool_customlang'
),
);
foreach
(
$translator
->
strings
as
$string
)
{
$cells
=
array
();
// component name
$cells
[
0
]
=
new
html_table_cell
(
$string
->
component
);
$cells
[
0
]
->
attributes
[
'class'
]
=
'component'
;
// string identification code
$cells
[
1
]
=
new
html_table_cell
(
html_writer
::
tag
(
'div'
,
s
(
$string
->
stringid
),
array
(
'class'
=>
'stringid'
)));
$cells
[
1
]
->
attributes
[
'class'
]
=
'stringid'
;
// master translation of the string
$master
=
html_writer
::
tag
(
'div'
,
s
(
$string
->
master
),
array
(
'class'
=>
'preformatted'
));
$minheight
=
strlen
(
$string
->
master
)
/
200
;
if
(
preg_match
(
'/\{\$a(->.+)?\}/'
,
$string
->
master
))
{
$master
.
=
html_writer
::
tag
(
'div'
,
$this
->
help_icon
(
'placeholder'
,
'tool_customlang'
,
get_string
(
'placeholderwarning'
,
'tool_customlang'
)),
array
(
'class'
=>
'placeholderinfo'
));
}
$cells
[
2
]
=
new
html_table_cell
(
$master
);
$cells
[
2
]
->
attributes
[
'class'
]
=
'standard master'
;
// local customization of the string
$textareaattributes
=
array
(
'name'
=>
'cust['
.
$string
->
id
.
']'
,
'cols'
=>
40
,
'rows'
=>
3
);
if
(
$minheight
>
1
)
{
$textareaattributes
[
'style'
]
=
'min-height:'
.
(
int
)
4
*
$minheight
.
'em;'
;
}
$textarea
=
html_writer
::
tag
(
'textarea'
,
s
(
$string
->
local
),
$textareaattributes
);
$cells
[
3
]
=
new
html_table_cell
(
$textarea
);
if
(
!
is_null
(
$string
->
local
)
and
$string
->
outdated
)
{
$mark
=
html_writer
::
empty_tag
(
'input'
,
array
(
'type'
=>
'checkbox'
,
'id'
=>
'update_'
.
$string
->
id
,
'name'
=>
'updates[]'
,
'value'
=>
$string
->
id
));
$help
=
$this
->
help_icon
(
'markinguptodate'
,
'tool_customlang'
);
$mark
.
=
html_writer
::
tag
(
'label'
,
get_string
(
'markuptodate'
,
'tool_customlang'
)
.
$help
,
array
(
'for'
=>
'update_'
.
$string
->
id
));
$mark
=
html_writer
::
tag
(
'div'
,
$mark
,
array
(
'class'
=>
'uptodatewrapper'
));
}
else
{
$mark
=
''
;
}
$cells
[
3
]
=
new
html_table_cell
(
$textarea
.
"
\n
"
.
$mark
);
$cells
[
3
]
->
attributes
[
'class'
]
=
'local'
;
$cells
[
3
]
->
id
=
'id_'
.
$string
->
id
;
if
(
!
is_null
(
$string
->
local
))
{
$cells
[
3
]
->
attributes
[
'class'
]
.
=
' customized'
;
}
if
(
$string
->
outdated
)
{
$cells
[
3
]
->
attributes
[
'class'
]
.
=
' outdated'
;
}
if
(
$string
->
modified
)
{
$cells
[
3
]
->
attributes
[
'class'
]
.
=
' modified'
;
}
if
(
$string
->
original
!==
$string
->
master
)
{
$cells
[
0
]
->
rowspan
=
$cells
[
1
]
->
rowspan
=
$cells
[
3
]
->
rowspan
=
2
;
}
$row
=
new
html_table_row
(
$cells
);
$table
->
data
[]
=
$row
;
if
(
$string
->
original
!==
$string
->
master
)
{
$cells
=
array
();
// original of the string
$cells
[
2
]
=
new
html_table_cell
(
html_writer
::
tag
(
'div'
,
s
(
$string
->
original
),
array
(
'class'
=>
'preformatted'
)));
$cells
[
2
]
->
attributes
[
'class'
]
=
'standard original'
;
$row
=
new
html_table_row
(
$cells
);
$table
->
data
[]
=
$row
;
}
}
$output
.
=
html_writer
::
start_tag
(
'form'
,
array
(
'method'
=>
'post'
,
'action'
=>
$translator
->
handler
->
out
()));
$output
.
=
html_writer
::
start_tag
(
'div'
);
$output
.
=
html_writer
::
empty_tag
(
'input'
,
array
(
'type'
=>
'hidden'
,
'name'
=>
'translatorsubmitted'
,
'value'
=>
1
));
$output
.
=
html_writer
::
empty_tag
(
'input'
,
array
(
'type'
=>
'hidden'
,
'name'
=>
'sesskey'
,
'value'
=>
sesskey
()));
$output
.
=
html_writer
::
empty_tag
(
'input'
,
array
(
'type'
=>
'hidden'
,
'name'
=>
'p'
,
'value'
=>
$translator
->
currentpage
));
$save1
=
html_writer
::
empty_tag
(
'input'
,
array
(
'type'
=>
'submit'
,
'name'
=>
'savecontinue'
,
'value'
=>
get_string
(
'savecontinue'
,
'tool_customlang'
),
'class'
=>
'btn btn-secondary'
));
$save2
=
html_writer
::
empty_tag
(
'input'
,
array
(
'type'
=>
'submit'
,
'name'
=>
'savecheckin'
,
'value'
=>
get_string
(
'savecheckin'
,
'tool_customlang'
),
'class'
=>
'btn btn-secondary'
));
$output
.
=
html_writer
::
tag
(
'fieldset'
,
$save1
.
' '
.
$save2
,
array
(
'class'
=>
'buttonsbar'
));
$output
.
=
html_writer
::
table
(
$table
);
$output
.
=
html_writer
::
tag
(
'fieldset'
,
$save1
.
' '
.
$save2
,
array
(
'class'
=>
'buttonsbar'
));
$output
.
=
html_writer
::
end_tag
(
'div'
);
$output
.
=
html_writer
::
end_tag
(
'form'
);
return
$output
;
}
}
admin/tool/customlang/styles.css
deleted
100644 → 0
View file @
c8467842
.path-admin-tool-customlang
.langselectorbox
,
.path-admin-tool-customlang
fieldset
.buttonsbar
,
.path-admin-tool-customlang
.menu
{
margin
:
5px
auto
;
text-align
:
center
;
}
.path-admin-tool-customlang
.menu
.singlebutton
,
.path-admin-tool-customlang
.menu
.singlebutton
form
,
.path-admin-tool-customlang
.menu
.singlebutton
form
div
{
display
:
inline
;
}
.path-admin-tool-customlang
.mform.filterform
{
width
:
70%
;
margin-left
:
auto
;
margin-right
:
auto
;
}
.path-admin-tool-customlang
.mform.filterform
.fitem
.fitemtitle
{
width
:
30%
;
}
.path-admin-tool-customlang
.mform.filterform
.fitem
.felement
{
width
:
60%
;
margin-left
:
31%
;
}
.path-admin-tool-customlang
#translator
{
width
:
100%
;
}
.path-admin-tool-customlang
#translator
.standard
,
.path-admin-tool-customlang
#translator
.local
{
min-width
:
35%
;
}
.path-admin-tool-customlang
#translator
.customized
{
background-color
:
#e7f1c3
;
}
.path-admin-tool-customlang
#translator
.customized.outdated
{
background-color
:
#f3f2aa
;
}
.path-admin-tool-customlang
#translator
.modified
{
background-color
:
#ffd3d9
;
}
.path-admin-tool-customlang
#translator
.customized.modified
{
background-color
:
#d2ebff
;
}
.path-admin-tool-customlang
#translator
textarea
{
width
:
100%
;
min-height
:
4em
;
}
.path-admin-tool-customlang
#translator
.placeholderinfo
{
text-align
:
center
;
border
:
1px
dotted
#ddd
;
background-color
:
#f6f6f6
;
margin-top
:
0.5em
;
}
#page-admin-tool-customlang-index
.continuebutton
{
margin-top
:
1em
;
}
.path-admin-tool-customlang
#translator
.standard.master.cell.c2
{
word-break
:
break-all
;
}
admin/tool/customlang/templates/translator.mustache
0 → 100644
View file @
e0757dd5
{{
!
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
tool_customlang
/
translator
Template
for
the
custom
language
translator
page.
Classes
required
for
JS
:
-
Data
attributes
required
for
JS
:
-
Context
variables
required
for
this
template
:
*
strings
Example
context
(
json
)
:
{
"hasstrings"
:
true
,
"formurl"
:
"admin/tool/customlang/edit.php?lng=en"
,
"currentpage"
:
0
,
"sesskey"
:
"AZyeeQgmcs"
,
"strings"
:
[
{
"id"
:
11
,
"component"
:
"core"
,
"componentid"
:
1
,
"stringid"
:
"course"
,
"original"
:
"Course"
,
"master"
:
"Cursus"
,
"local"
:
"Hoofdstuk"
,
"outdated"
:
0
,
"modified"
:
1
}
]
}
}}
{{^
hasstrings
}}
{{{
nostrings
}}}
{{/
hasstrings
}}
{{#
hasstrings
}}
<form
method=
"post"
action=
"
{{{
formurl
}}}
"
>
<input
type=
"hidden"
name=
"translatorsubmitted"
value=
"1"
>
<input
type=
"hidden"
name=
"sesskey"
value=
"
{{{
sesskey
}}}
"
>
<input
type=
"hidden"
name=
"p"
value=
"
{{
currentpage
}}
"
>
<fieldset
class=
"m-a-1 m-3"
>
<button
type=
"submit"
name=
"savecontinue"
class=
"btn btn-secondary"
>
{{#
str
}}
savecontinue, tool_customlang
{{/
str
}}
</button>
<button
type=
"submit"
name=
"savecheckin"
class=
"btn btn-secondary"
>
{{#
str
}}
savecheckin, tool_customlang
{{/
str
}}
</button>
</fieldset>
<div
class=
"list-group"
>
<div
class=
"container-fluid d-none d-md-block list-group-item border-bottom-0"
>
<div
class=
"row-fluid"
>
<div
class=
"col-sm-4 col-md-2 span2"
>
<strong>
{{#
str
}}
headingcomponent, tool_customlang
{{/
str
}}
</strong>
</div>
<div
class=
"col-sm-4 col-md-2 span2"
>
<strong>
{{#
str
}}
headingstringid, tool_customlang
{{/
str
}}
</strong>
</div>
<div
class=
"col-sm-4 col-md-2 span2"
>
<strong>
{{#
str
}}
headingstandard, tool_customlang
{{/
str
}}
</strong>
</div>
<div
class=
"col-sm-12 col-md-6 span6"
>
<span
class=
"p-l-1 pl-3"
>
<strong>
{{#
str
}}
headinglocal, tool_customlang
{{/
str
}}
</strong>
</span>
</div>
</div>
</div>
</div>
<div
class=
"list-group"
>
{{#
strings
}}
<div
class=
"container-fluid list-group-item
{{#
local
}}
list-group-item-info
{{/
local
}}
{{#
outdated
}}
list-group-item-warning
{{/
outdated
}}
{{#
modified
}}
list-group-item-info
{{/
modified
}}
"
>
<div
class=
"row-fluid "
>
<div
class=
"col-sm-4 col-md-2 span2"
>
<div
class=
"d-md-none"
>
<strong>
{{#
str
}}
headingcomponent, tool_customlang
{{/
str
}}
</strong>
</div>
{{{
component
}}}
</div>
<div
class=
"col-sm-4 col-md-2 span2 text-break"
>
<div
class=
"d-md-none"
>
<strong>
{{#
str
}}
headingstringid, tool_customlang
{{/
str
}}
</strong>
</div>
{{{
stringid
}}}
</div>
<div
class=
"col-sm-4 col-md-2 span2"
>
<div
class=
"d-md-none"
>
<strong>
{{#
str
}}
headingstandard, tool_customlang
{{/
str
}}
</strong>
</div>
{{{
master
}}}
<div
class=
"info"
>
{{{
placeholderhelp
}}}
{{{
outdatedhelp
}}}
</div>
{{#
showoriginalvsmaster
}}
<div
class=
"alert-secondary mt-3 m-t-1"
>
{{{
original
}}}
</div>
{{/
showoriginalvsmaster
}}
</div>
<div
class=
"col-sm-12 col-md-6 mt-sm-3 mt-md-0 span6"
>
<div
class=
"d-md-none"
>
<strong>
{{#
str
}}
headinglocal, tool_customlang
{{/
str
}}
</strong>
</div>
<div
class=
"py-2 py-md-0 px-md-3"
>
<textarea
class=
"form-control w-100 border-box"
name=
"cust[
{{
id
}}
]"
cols=
"40"
rows=
"3"
>
{{{
local
}}}
</textarea>
{{#
checkupdated
}}
<div
class=
"uptodatewrapper"
>
<div
class=
"form-check"
>
<input
id=
"update_
{{
id
}}
"
class=
"form-check-input"
name=
"updates[]"
type=
"checkbox"
value=
"
{{
id
}}
"
>
<label
for=
"update_
{{
id
}}
"
class=
"form-check-label"
>
{{#
str
}}
markuptodate, tool_customlang
{{/
str
}}
</label>
{{{
outdatedhelp
}}}
</div>
</div>
{{/
checkupdated
}}
</div>
</div>
</div>
</div>
{{/
strings
}}
</div>
</form>
{{/
hasstrings
}}
theme/boost/scss/moodle/core.scss
View file @
e0757dd5
...
...
@@ -2262,3 +2262,7 @@ $switch-transition: .2s all !default;
.overflow-hidden
{
overflow
:
hidden
!
important
;
/* stylelint-disable-line declaration-no-important */
}
.text-break
{
overflow-wrap
:
break-word
!
important
;
/* stylelint-disable-line declaration-no-important */
}
theme/boost/style/moodle.css
View file @
e0757dd5
...
...
@@ -10540,6 +10540,10 @@ div.editor_atto_toolbar button .icon {
overflow
:
hidden
!important
;
/* stylelint-disable-line declaration-no-important */
}
.text-break
{
overflow-wrap
:
break-word
!important
;
/* stylelint-disable-line declaration-no-important */
}
.icon
{
font-size
:
16px
;
width
:
16px
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment