Skip to content

Commit

Permalink
Fix wrong preview link fc2blog#297
Browse files Browse the repository at this point in the history
- wrong: `/admin/index.php?mode=entries&process=preview&plugin_id=12&category=1&device_key=1`
- correct `/admin/index.php?mode=entries&process=preview&plugin_id=12&category=1&device_key=1`
- Previously(not correct! but worked) `/testblog2/admin/index.php?mode=entries&process=preview&plugin_id=12&category=1&device_key=1`
- problem appear when use single tenant mode.
- but, that's not strictly correct link when do not use single tenant mode too. Luckily, it was working.
  • Loading branch information
uzulla committed Apr 16, 2021
1 parent b7a4a26 commit cd9d314
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/src/Util/Twig/HtmlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ function (Request $request, $name, $type, array $attrs = [], array $option_attrs
),
new TwigFunction(
'url',
function (Request $request, string $controller, string $action, array $args = [], $reused = false, $full_url = false) {
function (Request $request, string $controller, string $action, array $args = [], $reused = false, $full_url = false, $use_base_dir = true) {
$args = array_merge(
[
'controller' => $controller,
'action' => $action
],
$args
);
return Html::url($request, $args, $reused, $full_url);
return Html::url($request, $args, $reused, $full_url, $use_base_dir);
},
['is_safe' => ['html']]
),
Expand Down
9 changes: 7 additions & 2 deletions app/src/Web/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ class Html
* @param array $args
* @param bool $reused
* @param bool $full_url
* @param bool $use_base_dir
* @return string
*/
public static function url(Request $request, $args = array(), $reused = false, $full_url = false)
public static function url(Request $request, $args = array(), $reused = false, $full_url = false, $use_base_dir = true)
{
// 現在のURLの引数を引き継ぐ
if ($reused == true) {
Expand Down Expand Up @@ -84,7 +85,11 @@ public static function url(Request $request, $args = array(), $reused = false, $
$params[] = $device_name;
}

$url = $request->baseDirectory . Config::get('DIRECTORY_INDEX');
if($use_base_dir) {
$url = $request->baseDirectory . Config::get('DIRECTORY_INDEX');
}else{
$url = "/" . Config::get('DIRECTORY_INDEX');
}
if (count($params)) {
$url .= '?' . implode('&', $params);
}
Expand Down
2 changes: 1 addition & 1 deletion app/twig_templates/admin/blog_plugins/plugin_search.twig
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<a href="{{ url(req, 'blog_plugins', 'download', {id: plugin.id, category: req.get('category'), sig: sig}) }}">{{ _('Download') }}</a>
</td>
<td class="center">
<a href="{{ url(req, 'Entries', 'preview', {blog_id: blog.id, plugin_id: plugin.id, category: req.get('category'), device_key: 1}, false, true) }}" target="_blank">{{ _('Preview') }}</a>
<a href="{{ url(req, 'Entries', 'preview', {blog_id: blog.id, plugin_id: plugin.id, category: req.get('category'), device_key: 1}, false, true, false) }}" target="_blank">{{ _('Preview') }}</a>
</td>
<td class="center">
{% if user_id == plugin.user_id %}
Expand Down

0 comments on commit cd9d314

Please sign in to comment.