Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function insertLink()

/** 过滤XSS */
$link['name'] = $this->request->filter('xss')->name;
$link['city'] = $this->request->filter('xss')->city;
$link['sort'] = $this->request->filter('xss')->sort;
$link['description'] = $this->request->filter('xss')->description;
$link['user'] = $this->request->filter('xss')->user;
Expand Down
1 change: 1 addition & 0 deletions Mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CREATE TABLE `typecho_links` (
`sort` varchar(50) DEFAULT NULL COMMENT 'links分类',
`email` varchar(50) DEFAULT NULL COMMENT 'links邮箱',
`image` varchar(200) DEFAULT NULL COMMENT 'links图片',
`city` varchar(200) DEFAULT NULL COMMENT 'links城市',
`description` varchar(200) DEFAULT NULL COMMENT 'links描述',
`user` varchar(200) DEFAULT NULL COMMENT '自定义',
`state` int(10) DEFAULT '1' COMMENT 'links状态',
Expand Down
29 changes: 22 additions & 7 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
*
* @package Links
* @author 懵仙兔兔
* @version 1.2.7
* @version 1.2.8
* @dependence 14.10.10-*
* @link https://2dph.com
*
*
* version 1.2.8 at 2024-09-29 by 小布丁
* 数据库增加城市选项,用户可根据城市定义标签云
* 调整了友链链接框报警server error 以http:// 或者 https:// 开头
*
* version 1.2.7 at 2024-06-21 by 泽泽社长
* 解决php8.2一处报错问题
*
Expand Down Expand Up @@ -132,7 +136,7 @@ public static function config(Typecho_Widget_Helper_Form $form)
echo '
<ul class="typecho-option">
<li>
<label class="typecho-label">管理】→【友情链接】进入操作页面</label>
<label class="typecho-label">管理】→【友情链接】进入操作页面</label>
<div class="Mejituu"><br>
<center>
<div>
Expand Down Expand Up @@ -200,6 +204,10 @@ public static function config(Typecho_Widget_Helper_Form $form)
<tr>
<td class="field">{image}</td>
<td>' . _t('友链图片') . '</td>
</tr>
<tr>
<td class="field">{city}</td>
<td>' . _t('城市') . '</td>
</tr>
<tr>
<td class="field">{size}</td>
Expand Down Expand Up @@ -290,7 +298,7 @@ public static function linksInstall()
('SQLite' == $type && ('HY000' == $code || 1 == $code))
) {
try {
$script = 'SELECT `lid`, `name`, `url`, `sort`, `email`, `image`, `description`, `user`, `state`, `order` from `' . $prefix . 'links`';
$script = 'SELECT `lid`, `name`, `url`, `sort`, `email`, `image`, `city`, `description`, `user`, `state`, `order` from `' . $prefix . 'links`';
$installDb->query($script, Typecho_Db::READ);
return _t('检测到友情链接数据表,友情链接插件启用成功');
} catch (Typecho_Db_Exception $e) {
Expand Down Expand Up @@ -345,7 +353,7 @@ public static function form($action = null)
$form->addInput($name);

/** 友链地址 */
$url = new Typecho_Widget_Helper_Form_Element_Text('url', null, "http://", _t('友链地址*'));
$url = new Typecho_Widget_Helper_Form_Element_Text('url', null, null, _t('友链地址*'),_t('需要以http://或https://开头.'));
$form->addInput($url);

/** 友链分类 */
Expand All @@ -359,6 +367,10 @@ public static function form($action = null)
/** 友链图片 */
$image = new Typecho_Widget_Helper_Form_Element_Text('image', null, null, _t('友链图片'), _t('需要以http://或https://开头,留空表示没有友链图片'));
$form->addInput($image);

/** 友链城市 */
$city = new Typecho_Widget_Helper_Form_Element_Text('city', null, null, _t('友链城市'), _t('填写友链城市'));
$form->addInput($city);

/** 友链描述 */
$description = new Typecho_Widget_Helper_Form_Element_Textarea('description', null, null, _t('友链描述'));
Expand Down Expand Up @@ -387,6 +399,7 @@ public static function form($action = null)
$form->addItem($submit);
$request = Typecho_Request::getInstance();


if (isset($request->lid) && 'insert' != $action) {
/** 更新模式 */
$db = Typecho_Db::get();
Expand All @@ -401,6 +414,7 @@ public static function form($action = null)
$sort->value($link['sort']);
$email->value($link['email']);
$image->value($link['image']);
$city->value($link['city']);
$description->value($link['description']);
$user->value($link['user']);
$state->value($link['state']);
Expand Down Expand Up @@ -430,6 +444,7 @@ public static function form($action = null)
$sort->addRule('maxLength', _t('友链分类最多包含50个字符'), 50);
$email->addRule('maxLength', _t('友链邮箱最多包含50个字符'), 50);
$image->addRule('maxLength', _t('友链图片最多包含200个字符'), 200);
$city->addRule('maxLength', _t('友链城市最多包含200个字符'), 200);
$description->addRule('maxLength', _t('友链描述最多包含200个字符'), 200);
$user->addRule('maxLength', _t('自定义数据最多包含200个字符'), 200);
}
Expand Down Expand Up @@ -494,8 +509,8 @@ public static function output_str($widget, array $params)
}
if ($link['state'] == 1) {
$str .= str_replace(
array('{lid}', '{name}', '{url}', '{sort}', '{title}', '{description}', '{image}', '{user}', '{size}'),
array($link['lid'], $link['name'], $link['url'], $link['sort'], $link['description'], $link['description'], $link['image'], $link['user'], $size),
array('{lid}', '{name}', '{url}', '{sort}', '{title}', '{description}', '{image}', '{city}', '{user}', '{size}'),
array($link['lid'], $link['name'], $link['url'], $link['sort'], $link['description'], $link['description'], $link['image'], $link['city'], $link['user'], $size),
$pattern
);
}
Expand Down
7 changes: 6 additions & 1 deletion manage-links.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<col width=""/>
<col width="15%"/>
<col width="10%"/>
<col width="11%"/><!-- 添加city选项 by 小布丁 2024.09.29-->
<col width="12%"/>
</colgroup>
<thead>
Expand All @@ -69,6 +70,7 @@
<th><?php _e('友链地址'); ?></th>
<th><?php _e('分类'); ?></th>
<th><?php _e('图片'); ?></th>
<th><?php _e('城市'); ?></th><!-- 添加city选项 by 小布丁 2024.09.29-->
<th><?php _e('状态'); ?></th>
</tr>
</thead>
Expand All @@ -89,6 +91,7 @@
echo '<img class="avatar" src="'.$nopic_url.'" alt="NOPIC" width="32" height="32"/>';
}
?></td>
<td><?php echo $link['city']; ?></td>
<td><?php
if ($link['state'] == 1) {
echo '正常';
Expand Down Expand Up @@ -176,11 +179,13 @@
});

<?php if (isset($request->lid)): ?>
$('.typecho-mini-panel').effect('highlight', '#AACB36');
$('.typecho-mini-panel').effect('highlight', '#aacb36');
<?php endif; ?>
});
})();

</script>

<?php include 'footer.php'; ?>

<?php /** Links by 懵仙兔兔 */ ?>