Skip to content

Commit

Permalink
Working on #2972 Template Conversion to Twig Format (usercp_options) (#…
Browse files Browse the repository at this point in the history
…3243)

* Converted usercp options

* Converted themeselector and lang fixes to templates

* Fixes indent and minor syntax change
  • Loading branch information
Shade- authored and euantorano committed Jun 2, 2019
1 parent b279b66 commit b6e71f5
Show file tree
Hide file tree
Showing 4 changed files with 334 additions and 254 deletions.
25 changes: 10 additions & 15 deletions inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4254,12 +4254,12 @@ function get_current_location($fields=false, $ignore=array(), $quick=false)
*/
function build_theme_select($name, $selected=-1, $tid=0, $depth="", $usergroup_override=false, $footer=false, $count_override=false)
{
global $db, $themeselect, $tcache, $lang, $mybb, $limit, $templates, $num_themes, $themeselect_option;
global $db, $themeselect, $tcache, $lang, $mybb, $limit, $templates, $num_themes, $themeselect_options;

if ($tid == 0) {
$tid = 1;
$num_themes = 0;
$themeselect_option = '';
$themeselect_options = [];

if (!isset($lang->use_default)) {
$lang->use_default = $lang->lang_select_default;
Expand All @@ -4276,16 +4276,12 @@ function build_theme_select($name, $selected=-1, $tid=0, $depth="", $usergroup_o

if (is_array($tcache[$tid])) {
foreach ($tcache[$tid] as $theme) {
$sel = "";
// Show theme if allowed, or if override is on
if (is_member($theme['allowedgroups']) || $theme['allowedgroups'] == "all" || $usergroup_override == true) {
if ($theme['tid'] == $selected) {
$sel = " selected=\"selected\"";
}

if ($theme['pid'] != 0) {
$theme['name'] = htmlspecialchars_uni($theme['name']);
eval("\$themeselect_option .= \"".$templates->get("usercp_themeselector_option")."\";");
$theme['depth'] = $depth;
$themeselect_options[] = $theme;
++$num_themes;
$depthit = $depth."--";
}
Expand All @@ -4298,13 +4294,12 @@ function build_theme_select($name, $selected=-1, $tid=0, $depth="", $usergroup_o
}

if ($tid == 1 && ($num_themes > 1 || $count_override == true)) {
if ($footer == true) {
eval("\$themeselect = \"".$templates->get("footer_themeselector")."\";");
} else {
eval("\$themeselect = \"".$templates->get("usercp_themeselector")."\";");
}

return $themeselect;
return \MyBB\template('misc/themeselect.twig', [
'footer' => $footer,
'selected' => $selected,
'options' => $themeselect_options,
'name' => $name
]);
} else {
return false;
}
Expand Down
14 changes: 14 additions & 0 deletions inc/views/base/misc/themeselect.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<select name="{{ name }}"{% if footer %} onchange="MyBB.changeTheme();"{% endif %}>
{% if footer != true %}
<option value="0">{{ lang.use_default }}</option>
<option value="0">-----------</option>
{% else %}
<optgroup label="{{ lang.select_theme }}">
{% endif %}
{% for option in options %}
<option value="{{ option.tid }}"{% if option.tid == selected %} selected {% endif %}>{{ option.depth }}{{ option.name }}</option>
{% endfor %}
{% if footer != true %}
</optgroup>
{% endif %}
</select>

0 comments on commit b6e71f5

Please sign in to comment.