Skip to content

Commit

Permalink
fix 版本号跳跃
Browse files Browse the repository at this point in the history
  • Loading branch information
jzwalk committed May 29, 2014
1 parent e7f090d commit d6bb78a
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -31,7 +31,7 @@ public static function activate()
* @return void
* @throws Typecho_Plugin_Exception
*/
public static function deactivate(){}
public static function deactivate() {}

/**
* 获取插件配置面板
Expand All @@ -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('以“关键词”|(英文半角分隔号)“链接”形式填写每行一组如:<br/>google|http://www.google.com'));
$keywords = new Typecho_Widget_Helper_Form_Element_Textarea('keywords',NULL,'',_t('关键词链接'),_t('以“关键词”|(英文半角分隔号)“链接”形式填写, 每行一组. 如:<br/>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('请填写整数数字')));
}

Expand All @@ -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) {}

/**
* 关键词与标签替换
Expand All @@ -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','<a href="'.$wlarray[1].'" target="_blank" title="'.$wlarray[0].'">'.$wlarray[0].'</a>',$content,$limit);
}
}

if ($tagdata&&$settings->tagslink) {
if ($tagdata && $settings->tagslink) {
foreach ($tagdata as $tag) {
$content = preg_replace('/(?!<[^>]*)('.$tag['name'].')(?![^<]*>)/i','<a href="'.$tag['permalink'].'" target="_blank" title="'.$tag['name'].'">'.$tag['name'].'</a>',$content,$limit);
}
Expand Down

0 comments on commit d6bb78a

Please sign in to comment.