Skip to content

Commit f0e8204

Browse files
committed
More Twig
1 parent ed8132e commit f0e8204

File tree

9 files changed

+24
-538
lines changed

9 files changed

+24
-538
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"gettext/gettext": "^4.2",
3232
"s9e/text-formatter": "^0.9",
3333
"featherbb/php-utf-8": "dev-master",
34-
"twig/twig": "2.*"
34+
"twig/twig": "1.*|2.*"
3535
},
3636
"support": {
3737
"email": "[email protected]",
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818
namespace FeatherBB\Core;
1919

20-
class RunBBTwig extends \Twig_Extension
20+
class Twig extends \Twig_Extension
2121
{
2222

2323
public function getName()
2424
{
25-
return 'runBB_Twig';
25+
return 'FeatherBB_Twig';
2626
}
2727

2828
public function getFunctions()
@@ -227,6 +227,10 @@ public function getFunctions()
227227
new \Twig_SimpleFunction('unSerialize', function ($var) {
228228
return unserialize($var);
229229
}, ['is_safe' => ['html']]),
230+
231+
new \Twig_SimpleFunction('preg_match', function ($pattern, $subject) {
232+
return preg_match($pattern, $subject);
233+
}, ['is_safe' => ['html']]),
230234
];
231235
}
232236
}

featherbb/Core/View.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function __construct()
5353
if (ForumEnv::get('FEATHER_DEBUG')) {
5454
$this->twig->addExtension(new \Twig_Extension_Debug());
5555
}
56-
$this->twig->addExtension(new \FeatherBB\Core\RunBBTwig());
56+
$this->twig->addExtension(new \FeatherBB\Core\Twig());
5757

5858
return $this;
5959
}
@@ -157,9 +157,9 @@ public function display($nested = true)
157157
$data['currentPage'] = '';
158158

159159
if (file_exists(ForumEnv::get('FEATHER_ROOT').'style/themes/'.$style.'/base_admin.css')) {
160-
$admStyle = '<link rel="stylesheet" type="text/css" href="proxy.php?url=https%3A%2F%2Fgithub.com%2Fthemes%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%3Cspan+class%3D"pl-s1">$style.'/base_admin.css" />';
160+
$admStyle = '<link rel="stylesheet" type="text/css" href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%3Cspan+class%3D"x x-first">'.Url::base().'/style/themes/'.$style.'/base_admin.css" />';
161161
} else {
162-
$admStyle = '<link rel="stylesheet" type="text/css" href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3Cspan+class%3D"x x-first x-last">/imports/base_admin.css" />';
162+
$admStyle = '<link rel="stylesheet" type="text/css" href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%3Cspan+class%3D"x x-first">'.Url::base().'/style/themes/FeatherBB/base_admin.css" />';
163163
}
164164
$data['admStyle'] = $admStyle;
165165

featherbb/View/admin/index.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
</dd>
4343
<dt>{{ trans('Support label') }}</dt>
4444
<dd>
45-
<a href="https://github.com/runcmf/runbb">{{ trans('Forum label') }}</a> - <a
46-
href="#">{{ trans('IRC label') }}</a>
45+
<a href="https://github.com/featherbb/featherbb">{{ trans('Forum label') }}</a> - <a
46+
href="https://gitter.im/featherbb/featherbb">{{ trans('IRC label') }}</a>
4747
</dd>
4848
</dl>
4949
</div>

featherbb/View/admin/menu.html.twig

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
<li{{ page == 'users' ? ' class="isactive"' : '' }}>
1313
<a href="{{ pathFor('adminUsers') }}">{{ trans('Users') }}</a>
1414
</li>
15-
{% if is_admin or userGet('g_mod_ban_users') == '1' %}
15+
{% if isAdmin() or userGet('g_mod_ban_users') == '1' %}
1616
<li{{ page == 'bans' ? ' class="isactive"': '' }}>
1717
<a href="{{ pathFor('adminBans') }}">{{ trans('Bans') }}</a>
1818
</li>
1919
{% endif %}
2020

21-
{% if is_admin or settings('o_report_method') == '0' or settings('o_report_method') == '2' %}
21+
{% if isAdmin() or settings('o_report_method') == '0' or settings('o_report_method') == '2' %}
2222
<li{{ page == 'reports' ? ' class="isactive"' : '' }}>
2323
<a href="{{ pathFor('adminReports') }}">{{ trans('Reports') }}</a>
2424
</li>
@@ -28,39 +28,19 @@
2828
</div>
2929
</div>
3030

31-
{% if is_admin %}
31+
{% if isAdmin() %}
3232

3333
<h2 class="block2"><span>{{ trans('Admin menu') }}</span></h2>
3434
<div class="box">
3535
<div class="inbox">
3636
<ul>
37-
<li{{ page == 'options' ? ' class="isactive"' : '' }}>
38-
<a href="{{ pathFor('adminOptions') }}">{{ trans('Options') }}</a>
39-
</li>
40-
<li{{ page == 'permissions' ? ' class="isactive"' : '' }}>
41-
<a href="{{ pathFor('adminPermissions') }}">{{ trans('Permissions') }}</a>
42-
</li>
43-
<li{{ page == 'categories' ? ' class="isactive"' : '' }}>
44-
<a href="{{ pathFor('adminCategories') }}">{{ trans('Categories') }}</a>
45-
</li>
46-
<li{{ page == 'forums' ? ' class="isactive"' : '' }}>
47-
<a href="{{ pathFor('adminForums') }}">{{ trans('Forums') }}</a>
48-
</li>
49-
<li{{ page == 'groups' ? ' class="isactive"' : '' }}>
50-
<a href="{{ pathFor('adminGroups') }}">{{ trans('User groups') }}</a>
51-
</li>
52-
<li{{ page == 'plugins' ? ' class="isactive"' : '' }}>
53-
<a href="{{ pathFor('adminPlugins') }}">{{ trans('Plugins') }}</a>
54-
</li>
55-
<li{{ page == 'censoring' ? ' class="isactive"' : '' }}>
56-
<a href="{{ pathFor('adminCensoring') }}">{{ trans('Censoring') }}</a>
57-
</li>
58-
<li{{ page == 'parser' ? ' class="isactive"' : '' }}>
59-
<a href="{{ pathFor('adminParser') }}">{{ trans('Parser') }}</a>
60-
</li>
61-
<li{{ page == 'maintenance' ? ' class="isactive"' : '' }}>
62-
<a href="{{ pathFor('adminMaintenance') }}">{{ trans('Maintenance') }}</a>
63-
</li>
37+
{% for perm, data in menu_items %}
38+
{% if preg_match('/^board\..*$/', perm) %}
39+
<li{{ page == data.title|lower ? ' class="isactive"' : '' }}>
40+
<a href="{{ pathFor(data.url) }}">{{ trans(data.title) }}</a>
41+
</li>
42+
{% endif %}
43+
{% endfor %}
6444
</ul>
6545
</div>
6646
</div>
@@ -70,7 +50,7 @@
7050
{#// Did we find any plugins?#}
7151
{% if plugins is not empty %}
7252

73-
<h2 class="block2"><span><?= __('Plugins menu') ?></span></h2>
53+
<h2 class="block2"><span>{{ trans('Plugins menu') }}</span></h2>
7454
<div class="box">
7555
<div class="inbox">
7656
<ul>

featherbb/View/admin/pluginsRepo.html.twig

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)