add placeholders for comment script
This commit is contained in:
parent
d4623f453d
commit
7d7432a374
|
|
@ -20,14 +20,11 @@ class Utils
|
||||||
* Get the value of key in an array if index exist
|
* Get the value of key in an array if index exist
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param array $array
|
* @param array $array
|
||||||
* @return string|boolean
|
* @return string|boolean
|
||||||
*/
|
*/
|
||||||
public static function getValue($key, $array) {
|
public static function getValue($key, $array) {
|
||||||
if (array_key_exists($key, $array)) {
|
return array_key_exists($key, $array) ? $array[$key] : false;
|
||||||
return $array[$key];
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -66,6 +63,14 @@ class Utils
|
||||||
return $fname;
|
return $fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate omitted string
|
||||||
|
*
|
||||||
|
* @param string $str
|
||||||
|
* @param int $length
|
||||||
|
* @param boolean $append
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public static function getStringOmitted($str, $length, $append = true)
|
public static function getStringOmitted($str, $length, $append = true)
|
||||||
{
|
{
|
||||||
$str = trim($str);
|
$str = trim($str);
|
||||||
|
|
@ -96,4 +101,19 @@ class Utils
|
||||||
return $newstr;
|
return $newstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace content of string according to given rules
|
||||||
|
*
|
||||||
|
* @param string $str
|
||||||
|
* @param array $rules
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getStringReplaced($str, $rules)
|
||||||
|
{
|
||||||
|
foreach ($rules as $search => $replace) {
|
||||||
|
$str = str_replace($search, $replace, $str);
|
||||||
|
}
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
@section('style')
|
@section('style')
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
.box-body > textarea { height: 200px; }
|
.box-body > textarea { height: 200px; }
|
||||||
|
.description { margin: 7px 0 0 0; color: #555; }
|
||||||
</style>
|
</style>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
|
@ -123,7 +124,8 @@
|
||||||
<i class="fa fa-question-circle" title="就是 Disqus,多说,畅言等评论服务提供的代码。留空以停用评论功能" data-toggle="tooltip" data-placement="top"></i>
|
<i class="fa fa-question-circle" title="就是 Disqus,多说,畅言等评论服务提供的代码。留空以停用评论功能" data-toggle="tooltip" data-placement="top"></i>
|
||||||
</td>
|
</td>
|
||||||
<td class="value">
|
<td class="value">
|
||||||
<textarea class="form-control" rows="4" name="comment_script">{{ Option::get('comment_script') }}</textarea>
|
<textarea class="form-control" rows="6" name="comment_script">{{ Option::get('comment_script') }}</textarea>
|
||||||
|
<p class="description">评论代码内可使用占位符,<code>{tid}</code> 将会被自动替换为材质的 id,<code>{name}</code> 会被替换为材质名称,<code>{url}</code> 会被替换为当前页面地址。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
@ -151,6 +153,7 @@
|
||||||
} ?>
|
} ?>
|
||||||
|
|
||||||
<textarea name="announcement" class="form-control" rows="3">{{ Option::get('announcement') }}</textarea>
|
<textarea name="announcement" class="form-control" rows="3">{{ Option::get('announcement') }}</textarea>
|
||||||
|
<p class="description">站点公告内容不会被转义,因此您可以使用 HTML 进行排版</p>
|
||||||
|
|
||||||
</div><!-- /.box-body -->
|
</div><!-- /.box-body -->
|
||||||
<div class="box-footer">
|
<div class="box-footer">
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td class="key">发布时间:</td>
|
<td class="key">发布时间:</td>
|
||||||
<td class="value">
|
<td class="value">
|
||||||
{{ date('Y-m-d H:i:s', $updater->getUpdateInfo()['releases'][$updater->current_version]['release_time']) }}
|
{{ @date('Y-m-d H:i:s', $updater->getUpdateInfo()['releases'][$updater->current_version]['release_time']) }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
||||||
|
|
@ -144,9 +144,10 @@
|
||||||
<h3 class="box-title">评论区</h3>
|
<h3 class="box-title">评论区</h3>
|
||||||
</div><!-- /.box-header -->
|
</div><!-- /.box-header -->
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<div id="disqus_thread"></div>
|
|
||||||
@if (Option::get('comment_script') != "")
|
@if (Option::get('comment_script') != "")
|
||||||
{!! Option::get('comment_script') !!}
|
<!-- Comment Start -->
|
||||||
|
{!! Utils::getStringReplaced(Option::get('comment_script'), ['{tid}' => $texture->tid, '{name}' => $texture->name, '{url}' => Http::getCurrentUrl()]) !!}
|
||||||
|
<!-- Comment End -->
|
||||||
@else
|
@else
|
||||||
<p style="text-align: center; margin: 30px 0;">本站未开启评论服务</p>
|
<p style="text-align: center; margin: 30px 0;">本站未开启评论服务</p>
|
||||||
@endif
|
@endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user