This commit is contained in:
joyqi 2021-09-02 16:13:32 +08:00
parent 403f96fdc0
commit 4791cd978e
6 changed files with 50 additions and 12 deletions

View File

@ -147,12 +147,12 @@ class Contents extends Base implements QueryInterface
/**
* 为内容应用缩略名
*
* @param string $slug 缩略名
* @param string|null $slug 缩略名
* @param mixed $cid 内容id
* @return string
* @throws Exception
*/
public function applySlug(string $slug, $cid): string
public function applySlug(?string $slug, $cid): string
{
if ($cid instanceof Query) {
$cid = $this->db->fetchObject($cid->select('cid')

View File

@ -548,12 +548,12 @@ class Edit extends Contents implements ActionInterface
* 设置内容标签
*
* @param integer $cid
* @param string $tags
* @param string|null $tags
* @param boolean $beforeCount 是否参与计数
* @param boolean $afterCount 是否参与计数
* @throws DbException
*/
public function setTags(int $cid, string $tags, bool $beforeCount = true, bool $afterCount = true)
public function setTags(int $cid, ?string $tags, bool $beforeCount = true, bool $afterCount = true)
{
$tags = str_replace('', ',', $tags);
$tags = array_unique(array_map('trim', explode(',', $tags)));
@ -1023,7 +1023,7 @@ class Edit extends Contents implements ActionInterface
protected function ___draft(): ?array
{
if ($this->have()) {
if ('post_draft' == $this->type) {
if ('post_draft' == $this->type || 'page_draft' == $this->type) {
return $this->row;
} else {
return $this->db->fetchRow(Contents::alloc()->select()

View File

@ -33,6 +33,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) {
* @property string $pluginUrl
* @property string $adminUrl
* @property string $loginUrl
* @property string $originalSiteUrl
* @property string $loginAction
* @property string $registerUrl
* @property string $registerAction
@ -48,6 +49,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) {
* @property int $timezone
* @property string $charset
* @property string $contentType
* @property string $generator
* @property string $software
* @property string $version
* @property bool $markdown
@ -61,6 +63,33 @@ if (!defined('__TYPECHO_ROOT_DIR__')) {
* @property string $actionTable
* @property string $panelTable
* @property bool $commentsThreaded
* @property bool $defaultAllowComment
* @property bool $defaultAllowPing
* @property bool $defaultAllowFeed
* @property string $commentDateFormat
* @property string $commentsAvatarRating
* @property string $commentsPageDisplay
* @property int $commentsPageSize
* @property string $commentsOrder
* @property bool $commentsMarkdown
* @property bool $commentsShowUrl
* @property bool $commentsUrlNofollow
* @property bool $commentsAvatar
* @property bool $commentsPageBreak
* @property bool $commentsRequireModeration
* @property bool $commentsWhitelist
* @property bool $commentsRequireMail
* @property bool $commentsRequireURL
* @property bool $commentsCheckReferer
* @property bool $commentsAntiSpam
* @property bool $commentsAutoClose
* @property bool $commentsPostIntervalEnable
* @property string $commentsHTMLTagAllowed
* @property bool $allowRegister
* @property bool $allowXmlRpc
* @property int $postsListSize
* @property bool $feedFullText
* @property int $defaultCategory
*/
class Options extends Base
{

View File

@ -256,15 +256,23 @@ class Discussion extends Options implements ActionInterface
$commentsPostOptionsValue[] = 'commentsPostIntervalEnable';
}
$commentsPost = new Form\Element\Checkbox('commentsPost', $commentsPostOptions,
$commentsPostOptionsValue, _t('评论提交'));
$commentsPost = new Form\Element\Checkbox(
'commentsPost',
$commentsPostOptions,
$commentsPostOptionsValue,
_t('评论提交')
);
$form->addInput($commentsPost->multiMode());
/** 允许使用的HTML标签和属性 */
$commentsHTMLTagAllowed = new Form\Element\Textarea('commentsHTMLTagAllowed', null,
$commentsHTMLTagAllowed = new Form\Element\Textarea(
'commentsHTMLTagAllowed',
null,
$this->options->commentsHTMLTagAllowed,
_t('允许使用的HTML标签和属性'), _t('默认的用户评论不允许填写任何的HTML标签, 你可以在这里填写允许使用的HTML标签.') . '<br />'
. _t('比如: %s', '<code>&lt;a href=&quot;&quot;&gt; &lt;img src=&quot;&quot;&gt; &lt;blockquote&gt;</code>'));
_t('允许使用的HTML标签和属性'),
_t('默认的用户评论不允许填写任何的HTML标签, 你可以在这里填写允许使用的HTML标签.') . '<br />'
. _t('比如: %s', '<code>&lt;a href=&quot;&quot;&gt; &lt;img src=&quot;&quot;&gt; &lt;blockquote&gt;</code>')
);
$commentsHTMLTagAllowed->input->setAttribute('class', 'mono');
$form->addInput($commentsHTMLTagAllowed);

View File

@ -245,7 +245,8 @@ RewriteRule . {$basePath}index.php [L]
} elseif (!isset($patterns[$postPatternValue])) {
$customPatternValue = $this->decodeRule($postPatternValue);
}
$patterns['custom'] = _t('个性化定义') . ' <input type="text" class="w-50 text-s mono" name="customPattern" value="' . $customPatternValue . '" />';
$patterns['custom'] = _t('个性化定义') .
' <input type="text" class="w-50 text-s mono" name="customPattern" value="' . $customPatternValue . '" />';
$postPattern = new Form\Element\Radio(
'postPattern',

View File

@ -429,7 +429,7 @@ class Upload extends Contents implements ActionInterface
* @param string $ext 扩展名
* @return boolean
*/
public static function checkFileType($ext)
public static function checkFileType(string $ext): bool
{
$options = Options::alloc();
return in_array($ext, $options->allowedAttachmentTypes);