Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Commit

Permalink
Code | 代码质量 #19
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyingSky-CN committed Jan 15, 2020
1 parent c95e1f6 commit 304bda9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 47 deletions.
17 changes: 17 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1238,4 +1238,21 @@ function WordCount($cid) {
$rs=$db->fetchRow($db->select ('table.contents.text')->from('table.contents')->where('table.contents.cid=?',$cid)->order('table.contents.cid',Typecho_Db::SORT_ASC)->limit(1));
$text = preg_replace("/[^\x{4e00}-\x{9fa5}]/u","",$rs['text']);
echo mb_strlen($text,'UTF-8').'';
}

/* function 许可协议 */
function license($license) {
$licenselist = array(
'BY' => '署名 4.0 国际 (CC BY 4.0)',
'BY-SA' => '署名-相同方式共享 4.0 国际 (CC BY-SA 4.0)',
'BY-ND' => '署名-禁止演绎 4.0 国际 (CC BY-ND 4.0)',
'BY-NC' => '署名-非商业性使用 4.0 国际 (CC BY-NC 4.0)',
'BY-NC-SA' => '署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)',
'BY-NC-ND' => '署名-非商业性使用-禁止演绎 4.0 国际 (CC BY-NC-ND 4.0)'
);
if (isset($license) && $license != 'NONE') {
echo '<div class="copyright">本篇文章采用 <a rel="noopener" href="https://creativecommons.org/licenses/'.strtolower($license).'/4.0/deed.zh" target="_blank" class="external">'.$licenselist[$license].'</a> 许可协议进行许可。</div>';
} else {
echo '<div class="copyright">本篇文章未指定许可协议。</div>';
}
}
23 changes: 1 addition & 22 deletions page.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,7 @@
</div>
<div class="mdui-card-content mdui-typo" style="padding: 0px 16px 16px 16px;">
<?php $this->content(); ?>

<?php
// linceses
$linceses = $this->fields->linceses;
if ($linceses && $linceses != 'NONE') {
$linceseslist = array(
'BY' => '署名 4.0 国际 (CC BY 4.0)',
'BY-SA' => '署名-相同方式共享 4.0 国际 (CC BY-SA 4.0)',
'BY-ND' => '署名-禁止演绎 4.0 国际 (CC BY-ND 4.0)',
'BY-NC' => '署名-非商业性使用 4.0 国际 (CC BY-NC 4.0)',
'BY-NC-SA' => '署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)',
'BY-NC-ND' => '署名-非商业性使用-禁止演绎 4.0 国际 (CC BY-NC-ND 4.0)');
$lincesestext = $linceseslist[$linceses];
?>
<div class="copyright">本篇文章采用 <a rel="noopener" href="https://creativecommons.org/licenses/<?=strtolower($linceses)?>/4.0/deed.zh" target="_blank" class="external"><?=$lincesestext?></a> 许可协议进行许可。
</div>
<?php
} else {
?>
<div class="copyright">本篇文章未指定许可协议。
</div>
<?php }; ?>
<?php license($this->fields->linceses); ?>
</div>
</div>
<?php $this->need('comments.php'); ?>
Expand Down
23 changes: 1 addition & 22 deletions post.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,7 @@
<?php } ?>
<?php endif; ?>
<?php $this->content(); ?>

<?php
// linceses
$linceses = $this->fields->linceses;
if ($linceses && $linceses != 'NONE') {
$linceseslist = array(
'BY' => '署名 4.0 国际 (CC BY 4.0)',
'BY-SA' => '署名-相同方式共享 4.0 国际 (CC BY-SA 4.0)',
'BY-ND' => '署名-禁止演绎 4.0 国际 (CC BY-ND 4.0)',
'BY-NC' => '署名-非商业性使用 4.0 国际 (CC BY-NC 4.0)',
'BY-NC-SA' => '署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)',
'BY-NC-ND' => '署名-非商业性使用-禁止演绎 4.0 国际 (CC BY-NC-ND 4.0)');
$lincesestext = $linceseslist[$linceses];
?>
<div class="copyright">本篇文章采用 <a rel="noopener" href="https://creativecommons.org/licenses/<?=strtolower($linceses)?>/4.0/deed.zh" target="_blank" class="external"><?=$lincesestext?></a> 许可协议进行许可。
</div>
<?php
} else {
?>
<div class="copyright">本篇文章未指定许可协议。
</div>
<?php }; ?>
<?php license($this->fields->linceses); ?>
</div>
</div>
<p class="tags mdui-typo" style="margin-bottom: 0px;">标签: <?php $this->tags(', ', true, 'none'); ?></p>
Expand Down
3 changes: 0 additions & 3 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,4 @@ button, input[type=submit], .menu-parent a, .rewards a {
}
.avatar {
border-radius:50%
}
.noties {
top:61px!important
}

0 comments on commit 304bda9

Please sign in to comment.