2024-05-17 15:47:27 +08:00
|
|
|
<?php
|
|
|
|
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
|
|
|
|
function themeConfig($form) {
|
|
|
|
$logoUrl = new Typecho_Widget_Helper_Form_Element_Text('logoUrl', NULL, NULL, _t('站点 LOGO 地址'));
|
|
|
|
$form->addInput($logoUrl);
|
|
|
|
$icoUrl = new Typecho_Widget_Helper_Form_Element_Text('icoUrl', NULL, NULL, _t('站点 Favicon 地址'));
|
|
|
|
$form->addInput($icoUrl);
|
2024-05-17 16:02:08 +08:00
|
|
|
$jzyear = new Typecho_Widget_Helper_Form_Element_Text('jzyear', NULL, NULL, _t('建站年份'));
|
|
|
|
$form->addInput($jzyear);
|
|
|
|
$instagramurl = new Typecho_Widget_Helper_Form_Element_Text('instagramurl', NULL, NULL, _t('INS'));
|
2024-05-17 15:47:27 +08:00
|
|
|
$form->addInput($instagramurl);
|
2024-05-17 16:02:08 +08:00
|
|
|
$telegramurl = new Typecho_Widget_Helper_Form_Element_Text('telegramurl', NULL, NULL, _t('电报'));
|
2024-05-17 15:47:27 +08:00
|
|
|
$form->addInput($telegramurl);
|
2024-05-17 16:02:08 +08:00
|
|
|
$githuburl = new Typecho_Widget_Helper_Form_Element_Text('githuburl', NULL, NULL, _t('github'));
|
2024-05-17 15:47:27 +08:00
|
|
|
$form->addInput($githuburl);
|
2024-05-17 16:02:08 +08:00
|
|
|
$twitterurl = new Typecho_Widget_Helper_Form_Element_Text('twitterurl', NULL, NULL, _t('twitter'));
|
2024-05-17 15:47:27 +08:00
|
|
|
$form->addInput($twitterurl);
|
2024-05-17 16:02:08 +08:00
|
|
|
$feedurl = new Typecho_Widget_Helper_Form_Element_Text('feedurl', NULL, NULL, _t('网站Feed'));
|
2024-05-17 15:47:27 +08:00
|
|
|
$form->addInput($feedurl);
|
2024-05-17 16:02:08 +08:00
|
|
|
$mastodonurl = new Typecho_Widget_Helper_Form_Element_Text('mastodonurl', NULL, NULL, _t('mastodon'));
|
2024-05-17 15:47:27 +08:00
|
|
|
$form->addInput($mastodonurl);
|
|
|
|
|
|
|
|
$twikoo = new Typecho_Widget_Helper_Form_Element_Textarea('twikoo', NULL, NULL, _t('引用第三方评论'));
|
|
|
|
$form->addInput($twikoo);
|
2024-05-17 16:02:08 +08:00
|
|
|
$addhead = new Typecho_Widget_Helper_Form_Element_Textarea('addhead', NULL, NULL, _t('添加head'));
|
2024-05-17 15:47:27 +08:00
|
|
|
$form->addInput($addhead);
|
|
|
|
$tongji = new Typecho_Widget_Helper_Form_Element_Textarea('tongji', NULL, NULL, _t('统计代码'));
|
|
|
|
$form->addInput($tongji);
|
|
|
|
}
|
2024-05-17 16:02:08 +08:00
|
|
|
function themeFields($layout) {
|
|
|
|
$switchpf = new Typecho_Widget_Helper_Form_Element_Checkbox('switchpf',
|
|
|
|
array('open'=>'显示作者'),
|
|
|
|
NULL,
|
|
|
|
_t('是否文章页面显示作者信息'),
|
|
|
|
_t('勾选后,将在文章页面显示'));
|
|
|
|
$layout->addItem($switchpf);
|
|
|
|
}
|
2024-05-17 15:47:27 +08:00
|
|
|
function get_post_view($archive) {
|
|
|
|
$cid = $archive->cid;
|
|
|
|
$db = Typecho_Db::get();
|
|
|
|
$prefix = $db->getPrefix();
|
|
|
|
if (!array_key_exists('views', $db->fetchRow($db->select()->from('table.contents')))) {
|
|
|
|
$db->query('ALTER TABLE `' . $prefix . 'contents` ADD `views` INT(10) DEFAULT 0;');
|
|
|
|
echo 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$row = $db->fetchRow($db->select('views')->from('table.contents')->where('cid = ?', $cid));
|
|
|
|
if ($archive->is('single')) {
|
|
|
|
$views = Typecho_Cookie::get('extend_contents_views');
|
|
|
|
if (empty($views)) {
|
|
|
|
$views = array();
|
|
|
|
} else {
|
|
|
|
$views = explode(',', $views);
|
|
|
|
}
|
|
|
|
if (!in_array($cid, $views)) {
|
|
|
|
$db->query($db->update('table.contents')->rows(array('views' => (int)$row['views'] + 1))->where('cid = ?', $cid));
|
|
|
|
array_push($views, $cid);
|
|
|
|
$views = implode(',', $views);
|
|
|
|
Typecho_Cookie::set('extend_contents_views', $views); //记录查看cookie
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo $row['views'];
|
|
|
|
}
|