diff --git a/Plugin.php b/Plugin.php
index b713366..08ae6b9 100644
--- a/Plugin.php
+++ b/Plugin.php
@@ -5,7 +5,7 @@
* 自动为文章中出现的关键词添加链接
* @package Keywords
* @author 羽中
- * @version 1.1.1
+ * @version 1.0.3
* @dependence 13.12.12-*
* @link http://www.jzwalk.com/archives/net/keywords-for-typecho
*/
@@ -31,7 +31,7 @@ public static function activate()
* @return void
* @throws Typecho_Plugin_Exception
*/
- public static function deactivate(){}
+ public static function deactivate() {}
/**
* 获取插件配置面板
@@ -42,13 +42,13 @@ public static function deactivate(){}
*/
public static function config(Typecho_Widget_Helper_Form $form)
{
- $keywords = new Typecho_Widget_Helper_Form_Element_Textarea('keywords',NULL,"",_t('关键词链接'),_t('以“关键词”|(英文半角分隔号)“链接”形式填写,每行一组。如:
google|http://www.google.com'));
+ $keywords = new Typecho_Widget_Helper_Form_Element_Textarea('keywords',NULL,'',_t('关键词链接'),_t('以“关键词”|(英文半角分隔号)“链接”形式填写, 每行一组. 如:
google|http://www.google.com'));
$keywords->input->setAttribute('style','width:345px;height:150px;');
$form->addInput($keywords);
$tagslink = new Typecho_Widget_Helper_Form_Element_Checkbox('tagslink',array('true'=>'自动替换'),NULL,_t('标签链接'),_t('文中若出现与本站标签相同的关键词则自动添加标签页链接'));
$form->addInput($tagslink);
- $limits = new Typecho_Widget_Helper_Form_Element_Text('limits',NULL,"1",_t('链接频率'),_t('文中有多个重复关键词或标签时可限制链接替换次数'));
- $limits->input->setAttribute('style','width:60px');
+ $limits = new Typecho_Widget_Helper_Form_Element_Text('limits',NULL,'1',_t('链接频率'),_t('文中有多个重复关键词或标签时可限制链接替换次数'));
+ $limits->input->setAttribute('style','width:50px');
$form->addInput($limits->addRule('isInteger',_t('请填写整数数字')));
}
@@ -59,7 +59,7 @@ public static function config(Typecho_Widget_Helper_Form $form)
* @param Typecho_Widget_Helper_Form $form
* @return void
*/
- public static function personalConfig(Typecho_Widget_Helper_Form $form){}
+ public static function personalConfig(Typecho_Widget_Helper_Form $form) {}
/**
* 关键词与标签替换
@@ -70,25 +70,25 @@ public static function personalConfig(Typecho_Widget_Helper_Form $form){}
*/
public static function kwparse($content,$widget,$lastResult)
{
- $content = empty($lastResult)?$content:$lastResult;
+ $content = empty($lastResult) ? $content : $lastResult;
$db = Typecho_Db::get();
$settings = Helper::options()->plugin('Keywords');
$limit = $settings->limits;
- $tagselect = $db->select()->from('table.metas')->where('type=?','tag');
+ $tagselect = $db->select()->from('table.metas')->where('type = ?','tag');
$tagdata = $db->fetchAll($tagselect,array($widget->widget('Widget_Abstract_Metas'),'filter'));
- $wlsets = explode("\n", $settings->keywords);
+ $wlsets = explode('\n',$settings->keywords);
- if (!empty($settings->keywords)&&true==strchr($settings->keywords,'|')) {
+ if (!empty($settings->keywords) && true == strchr($settings->keywords,'|')) {
foreach ($wlsets as $wlset) {
- $wlarray = explode("|",$wlset);
+ $wlarray = explode('|',$wlset);
$content = preg_replace('/(?!<[^>]*)('.$wlarray[0].')(?![^<]*>)/i',''.$wlarray[0].'',$content,$limit);
}
}
- if ($tagdata&&$settings->tagslink) {
+ if ($tagdata && $settings->tagslink) {
foreach ($tagdata as $tag) {
$content = preg_replace('/(?!<[^>]*)('.$tag['name'].')(?![^<]*>)/i',''.$tag['name'].'',$content,$limit);
}