<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>水草树 &#187; 唐诗</title>
	<atom:link href="http://mifunny.info/tag/%e5%94%90%e8%af%97/feed" rel="self" type="application/rss+xml" />
	<link>http://mifunny.info</link>
	<description>走走停停看看，恍然大悟。</description>
	<lastBuildDate>Sat, 27 Aug 2011 18:25:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>自定义个性&#8221;唐诗宋词&#8221;模块</title>
		<link>http://mifunny.info/make-own-module-for-chinese-poem-96.html</link>
		<comments>http://mifunny.info/make-own-module-for-chinese-poem-96.html#comments</comments>
		<pubDate>Sat, 30 Aug 2008 12:27:15 +0000</pubDate>
		<dc:creator>LD</dc:creator>
				<category><![CDATA[plugins]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[唐诗]]></category>
		<category><![CDATA[宋词]]></category>
		<category><![CDATA[模块]]></category>

		<guid isPermaLink="false">http://mifunny.info/make-own-module-for-chinese-poem-96.html</guid>
		<description><![CDATA[通过本文你将学到 自定义&#8221;唐诗宋词&#8221;模块来实现： 每日一句拽言牛语; 随机显示一条名言警句，并安置在Blog首页的浏览器标题栏; 随机显示图片(小心，可能是我的忽悠哦); 当我开始写&#8221;唐诗宋词&#8220;之前根本没有想到要输出&#8221;唐诗300 首&#8221;，因为当时在开始接触 设计模式，所以想用PHP写个东西玩玩，当时那些默认模块(唐诗300、宋词100、增广贤文、谚语&#8230;&#8230;)已经被人用shell写成conky的脚本长期定居于我的linux桌面上，那么材料就是它了。实际上这个东西写法类似于设计模式中的策略模式(Strategy), 每加一个模块，只要根据接口重写一个函数即可。最简单的莫过于显示单句了，请看下面这个例子： 1.每日一句拽言牛语 这个和 &#8220;每日一句警言&#8221; 同类，只不过材料不同。网络上有很多拽言牛语，那么要是每天在blog上显示一句，拽就一个字。ok，首先选用 &#8220;2008最新的100句超牛的语言&#8221; 作为原料，按照下面的组识形式写入文件 &#8220;niuyu2008&#8243; ,编码为UTF-8。 再牛b的肖邦，也弹不出老子的悲伤！%我左青龙，右白虎，肩膀纹个米老鼠。%秃驴，敢跟贫道抢师太?% 每一句牛语后换行加一个 &#8220;%&#8221; 号，头可乱格式不能乱！ 至于怎么把这么多句子格式化，随你写脚本、用程序 or 徒手…… whatever. 改好后把 &#8220;niuyu2008&#8243; 移到&#8221;唐诗宋词&#8221;插件的根目录下。使用支持UTF-8的编辑器打开文件 &#8220;poem-models.php&#8221; ，你会发现文件结尾有一段注释: /* Add-Ons 自定义模块 */ 就是这里了，在下面添加代码即可。 class niuyu2008 implements Poem_Inter { public function format_poem($poem_src) { $poem_array = preg_split(&#8216;/\n/&#8217; , $poem_src, -1, PREG_SPLIT_NO_EMPTY); return $poem_array[0]; } //END [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://lh5.ggpht.com/kldscs/SLkCW5aMzrI/AAAAAAAAAvw/G5zX-FGIi1g/s400/conky-poem.png"><img class="frame" src="http://lh5.ggpht.com/kldscs/SLkCW5aMzrI/AAAAAAAAAvw/G5zX-FGIi1g/s400/conky-poem.png" align="right" title="请看最下方的'格言妙语'(点击查看大图)"  alt="conky 格言妙语" /></a><br />
通过本文你将学到 自定义&#8221;唐诗宋词&#8221;模块来实现：</p>
<ul style="list-style-type: disc" >
<li><a href="#08niuyu">每日一句拽言牛语</a>;</li>
<li><a href="#wisdom">随机显示一条名言警句</a>，并安置在Blog首页的浏览器标题栏;</li>
<li><a href="#image">随机显示图片</a>(小心，可能是我的忽悠哦);</li>
</ul>
<p style="text-indent: 2em" >当我开始写&#8221;<a href="http://mifunny.info/wp-plugin-chinese-poem-84.html" title="Wordpress插件：唐诗宋词" alt="wordpress 插件 唐诗 宋词" >唐诗宋词</a>&#8220;之前根本没有想到要输出&#8221;唐诗300 首&#8221;，因为当时在开始接触 设计模式，所以想用PHP写个东西玩玩，当时那些默认模块(唐诗300、宋词100、增广贤文、谚语&#8230;&#8230;)已经被人用shell写成conky的脚本长期定居于我的linux桌面上，那么材料就是它了。实际上这个东西写法类似于设计模式中的<i>策略模式(Strategy)</i>, 每加一个模块，只要根据接口重写一个函数即可。最简单的莫过于显示单句了，请看下面这个例子：</p>
<p><span id="more-96"></span><br />
<strong>1.<a name="08niuyu">每日一句拽言牛语</a></strong></p>
<p style="text-indent: 2em" >这个和 &#8220;每日一句警言&#8221; 同类，只不过材料不同。网络上有很多拽言牛语，那么要是每天在blog上显示一句，拽就一个字。ok，首先选用 &#8220;2008最新的100句超牛的语言&#8221; 作为原料，按照下面的组识形式写入文件 &#8220;niuyu2008&#8243; ,编码为UTF-8。<br />
<table style="border:2px solid #E0E0E0;" >
<tbody>
<tr>
<td>再牛b的肖邦，也弹不出老子的悲伤！<br />%<br />我左青龙，右白虎，肩膀纹个米老鼠。<br />%<br />秃驴，敢跟贫道抢师太?<br />%</td>
</tr>
</tbody>
</table>
<p>每一句牛语后换行加一个 &#8220;%&#8221; 号，头可乱格式不能乱！ 至于怎么把这么多句子格式化，随你写脚本、用程序 or 徒手…… whatever.</p>
<p style="text-indent: 2em" >改好后把 &#8220;niuyu2008&#8243; 移到&#8221;唐诗宋词&#8221;插件的根目录下。使用支持UTF-8的编辑器打开文件 &#8220;poem-models.php&#8221; ，你会发现文件结尾有一段注释: /* Add-Ons  自定义模块 */ 就是这里了，在下面添加代码即可。</p>
<p><coolcode lang="php" ><br />
class niuyu2008 implements Poem_Inter {<br />
	public function format_poem($poem_src) {<br />
		$poem_array = preg_split(&#8216;/\n/&#8217; , $poem_src, -1, PREG_SPLIT_NO_EMPTY);<br />
		return $poem_array[0];<br />
	} //END func format_poem<br />
} //END class niuyu2008<br />
</coolcode><br />
保存后在你blog皮肤中需要显示的地方插入：<br />
<coolcode lang="php" ><br />
< ?php<br />
if (function_exists(show_chinese_poetry))<br />
	show_chinese_poetry(array('niuyu2008'), FALSE, 1440);<br />
?><br />
</coolcode></p>
<p style="text-indent: 2em" >函数 show_chinese_poetry 能根据时间更新（<span sytle="color:red">需要注意的是：</span>使用该函数必须保证插件目录下的 &#8220;poem.tmp&#8221;文件全局可写(权限为666),可以用命令 chmod 666 poem.tmp  来修改，或者FTP工具也可。）， 一天的时间是<span style="color:blue">1440</span>分钟，自己按需要改吧。至于中间的 &#8216;FALSE&#8217;, 是CSS风格参数，为默认模块设计的，自己看poem.css文件吧。 如果是每次刷新换一条牛语，就用 show_chinese_poem ，比 show_chinese_poetry 函数少了时间参数。如果你想在Widget里显示，可以使用0.2版提供的widget配置选项。</p>
<p style="text-indent: 2em" >最后解释一下第一段代码： 每一个模块需要有原料文件（&#8221;niuyu2008&#8243;）、 段处理类（class niuyu2008） 和类中的 文本段处理函数（function format_poem）。 原料文件只要注意格式即可，类名必须和原料文件相同，类需实现 Poem_Inter 接口，重载 format_poem 函数。
</p>
<p style="text-indent: 2em" >最后是 format_poem 函数， 从参数 $poem_src 得到的是一个文本段，如下<br />
<table style="border:2px solid #E0E0E0;" >
<tbody>
<tr>
<td>道，可道，非恒道。<br />名，可名，非恒名。<br />无名，天地之始；<br />有名，万物之母。<br />故常无欲，以观其妙；<br />常有欲，以观其徼。<br />此两者同出而异名，同谓之玄。<br />玄之又玄，众妙之门。<br />　　－－《道德经》<br />%</td>
</tr>
</tbody>
</table>
<p>注意文本段是包含换行符 和 &#8220;%&#8221;的，所以我们要做的就是截取需要的，第一段代码中此函数的第一句就是把文本段分行存入 $poem_array 数组中，然后return 需要的文本（字符串）即可，同时也可处理一下字符串，去除不规范字符什么的。</p>
<p><span style="color:gray;">我不反对用 &#8220;2007年度里最拽最经典的只言片语&#8221; ,但这个文本块不是一行，自己修改一下，或是参考&#8221;默认模块&#8221;。</span></p>
<p>
<strong>2.<a name="wisdom">随机显示一条名言警句，并安置在Blog首页的浏览器标题栏</a></strong></p>
<p style="text-indent: 2em" >前辈<a href="http://yskin.net/">Yskin</a>写过一个WP插件：<a href="http://yskin.net/2006/10/wisdom-title.html">Wisdom Title</a>，可以在在Blog首页的浏览器标题栏随机显示一条名言警句。没错，就是VeryCD首页的效果。 现在我们也来给&#8221;<a href="http://mifunny.info/wp-plugin-chinese-poem-84.html" title="Wordpress插件：唐诗宋词" alt="wordpress 插件 唐诗 宋词" >唐诗宋词</a>&#8220;加一个类似的模块。首先和<a href="#08niuyu">上面</a>相同,搜集一些名言警句，这里先偷个懒，借前辈的劳动成果用一下，把原料按格式保存到插件目录下的 &#8220;wisdom&#8221; 文件中。接着写代码&#8230; 老样子，在 文件 &#8220;poem-models.php&#8221; 最后的注释（/* Add-Ons  自定义模块 */）后面加入：</p>
<p><coolcode lang="php"><br />
/**<br />
 * wisdom:    名言警句<br />
 * 用于blog首页的浏览器标题栏显示<br />
 */<br />
class wisdom implements Poem_Inter {<br />
	/**<br />
	 * @see Poem_Inter::format_poem()<br />
	 *<br />
	 * @param string $poem_src<br />
	 */<br />
	public function format_poem($poem_src) {<br />
		$poem_array = preg_split(&#8216;/\n/&#8217; , $poem_src, -1, PREG_SPLIT_NO_EMPTY);<br />
		$title_add = trim($poem_array[0]);<br />
		$js_code = &#8220;<script type=\"text/javascript\"> document.title = document.title+' - '+'".$title_add."'; </script>&#8220;;<br />
		return $js_code;<br />
	} //END func format_poem<br />
} //END class wisdom<br />
</coolcode><br />
代码完成, 在 WordPress 皮肤的 &#8220;header.php&#8221; 中的标记 &lt;/head&gt; 前加入:<br />
<coolcode lang="php"><br />
< ?php<br />
if (is_home() &#038;&#038; function_exists(show_chinese_poem))<br />
	show_chinese_poem(array('wisdom'), FALSE);<br />
?><br />
</coolcode><br />
<span style="color:red">注意：</span>一定加上 is_home() 这个判断，不然所有的页面浏览器标题都会加上一句警言了哦。 显示的函数选择 show_chinese_poem 。</p>
<p style="text-indent: 2em" >假如很不巧你的博客名字是这样的： &#8220;水草树 &#8211; 大树底下好乘凉&#8221; ,而不是单单的 &#8220;水草树&#8221; ，那么javascript就得换一个版本了。使用正则表达式就可以解决。</p>
<p><coolcode lang="javascript"><br />
<script type="text/javascript">
var patrn = /^.+ - /;
var title =  patrn.exec(document.title)[0];
document.title = title + '".$title_add."'; 
</script><br />
</coolcode></p>
<p>
<strong>3.<a name="image" >随机显示图片</a></strong></p>
<p style="text-indent: 2em" >到这里实在没什么了，如果你明白上面两个例子，就不用说了。因为完成这个功能需要把图片的URL按格式写入文本文件中，谁会这么无聊？ 说我忽悠也行，给出个class了事。</p>
<p><coolcode lang="php"><br />
class image implements Poem_Inter {<br />
	public function format_poem($poem_src) {<br />
		$poem_array = preg_split(&#8216;/\n/&#8217; , $poem_src, -1, PREG_SPLIT_NO_EMPTY);<br />
		return &#8220;<img src=\"".$poem_array[0]."\" \\ />&#8220;;<br />
	} //END func format_poem<br />
} //END class image<br />
</coolcode></p>
<p>本文所用到的原料和添加的代码下载： <a href="http://mifunny.info/blog/uploads/2008/08/modules-addon.zip">modules-addon.zip</a><br />
</p>
<p style="text-indent: 2em; color:gray;" ><b>小结：</b>当时接触设计模式，很好奇，手痒，写了这个东东。 这个插件就到此为止吧，没什么有用的功能，后来的代码也乱了，实在不想说&#8221;小华哥&#8221;经常说的那两个字。</p>
]]></content:encoded>
			<wfw:commentRss>http://mifunny.info/make-own-module-for-chinese-poem-96.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WP插件：唐诗宋词 更新至0.2版，加入widget</title>
		<link>http://mifunny.info/add-widget-to-chinese-poem-93.html</link>
		<comments>http://mifunny.info/add-widget-to-chinese-poem-93.html#comments</comments>
		<pubDate>Fri, 29 Aug 2008 09:02:33 +0000</pubDate>
		<dc:creator>LD</dc:creator>
				<category><![CDATA[plugins]]></category>
		<category><![CDATA[widget]]></category>
		<category><![CDATA[唐诗]]></category>
		<category><![CDATA[宋词]]></category>

		<guid isPermaLink="false">http://mifunny.info/add-widget-to-chinese-poem-93.html</guid>
		<description><![CDATA[昨天花了点时间，为&#8221;唐诗宋词&#8221;插件加了个 Widget (效果临时摆在本博客右侧栏的Last.fm挂件下)，配置界面的11个模块一个一个加太麻烦…… 主要更新内容如下： 加入了 show_chinese_poetry 函数，可以控制刷新时间; 为插件写了个Widget; 为widget添加配置界面(截图见文章最后); 实际上2和3就是同一个，不过我无聊，呵呵。 使用说明和下载地址见&#8221;唐诗宋词&#8221;的发布页： WP插件 ─ 唐诗宋词 Widget 配置窗口]]></description>
			<content:encoded><![CDATA[<p style="text-indent: 2em" >昨天花了点时间，为&#8221;唐诗宋词&#8221;插件加了个 Widget (效果临时摆在本博客右侧栏的Last.fm挂件下)，配置界面的11个模块一个一个加太麻烦…… 主要更新内容如下：</p>
<ol style="list-style-type: decimal">
<li>加入了 show_chinese_poetry 函数，可以控制刷新时间;</li>
<li>为插件写了个Widget;</li>
<li>为widget添加配置界面(截图见文章最后);</li>
</ol>
<p>实际上2和3就是同一个，不过我无聊，呵呵。 </p>
<p style="text-indent: 2em" >使用说明和下载地址见&#8221;唐诗宋词&#8221;的发布页： <a href="http://mifunny.info/wp-plugin-chinese-poem-84.html" title="唐诗宋词" alt="唐诗宋词" >WP插件 ─ 唐诗宋词</a></p>
<p><span id="more-93"></span></p>
<p align="center" ><a href="http://lh5.ggpht.com/kldscs/SLeyN8a-JgI/AAAAAAAAAvo/XRU4qw3UXCo/s800/chinese-poem-widget.png" target="_bank" ><img class="frame" src="http://lh5.ggpht.com/kldscs/SLeyN8a-JgI/AAAAAAAAAvo/XRU4qw3UXCo/s400/chinese-poem-widget.png" title="唐诗宋词 配置窗口" alt="唐诗宋词 widget chinese poem" /></a><br />Widget 配置窗口</p>
]]></content:encoded>
			<wfw:commentRss>http://mifunny.info/add-widget-to-chinese-poem-93.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[原创]wordpress插件：唐诗宋词</title>
		<link>http://mifunny.info/wp-plugin-chinese-poem-84.html</link>
		<comments>http://mifunny.info/wp-plugin-chinese-poem-84.html#comments</comments>
		<pubDate>Fri, 22 Aug 2008 15:25:38 +0000</pubDate>
		<dc:creator>LD</dc:creator>
				<category><![CDATA[plugins]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[唐诗]]></category>
		<category><![CDATA[宋词]]></category>

		<guid isPermaLink="false">http://mifunny.info/?p=84</guid>
		<description><![CDATA[就如你所看到的，这个唐诗宋词(chinese poem)插件默认随机显示唐诗300首、宋诗或宋词中的一首。当然了，上面的《出塞》只是图片,真实示例可以查看我的留言板。 === Plugin Name ===唐诗宋词(chinese poem) Contributors: LD KingDonate link: nullTags(有多少写多少，哈哈): tang300,唐诗300首, songproses宋词, song100,宋诗100首, caigentan,菜根谭, dao,道德经, joke,笑话, lunyu,论语, maoshici,毛泽东诗词, maoyulu,毛泽东语录, proverb,谚语, zengguang,增广贤文, poem Requires at least: 2.6Tested up to: 2.6.1Stable tag: 0.2PHP Requires: 5.2.xLicense: GPL v3 == Description ==这个插件允许在Wordpress中随机显示唐诗宋词, 你可以在widget的配置界面选择需要的模块。This plugin show poetry random in WordPress. Downloadchinese-poem.0.3.zipchinese-poem.0.2.zipchinese-poem.0.1.zip 暂时放在Google Code里。也可通过SVN获得： svn checkout http://nothing-at-all.googlecode.com/svn/tags/chinese-poem_0_3svn checkout http://nothing-at-all.googlecode.com/svn/tags/chinese-poem_0_2svn [...]]]></description>
			<content:encoded><![CDATA[<p align="center" ><a href="http://lh5.ggpht.com/kldscs/SK6AqqK0B6I/AAAAAAAAAuo/GUJJS29ONjE/s800/text.png" target="_bank" ><img class="frame" src="http://lh5.ggpht.com/kldscs/SK6AqqK0B6I/AAAAAAAAAuo/GUJJS29ONjE/s800/text.png" title="唐诗300首" alt="王之涣 出塞" /></a></p>
<p style="text-indent: 2em" >就如你所看到的，这个<a href="http://mifunny.info/wp-plugin-chinese-poem-84.html" >唐诗宋词(chinese poem)</a>插件默认随机显示唐诗300首、宋诗或宋词中的一首。当然了，上面的《出塞》只是图片,真实示例可以查看我的<a href="http://mifunny.info/guestbook" target="_bank" title="留言板"  alt="guestbook" >留言板</a>。</p>
<p><span id="more-84"></span><br />
<hr />
<p>=== <b>Plugin Name</b> ===<br />唐诗宋词(chinese poem)</p>
<p>Contributors: LD King<br />Donate link:  null<br />Tags(有多少写多少，哈哈): tang300,唐诗300首, songproses宋词, song100,宋诗100首, caigentan,菜根谭, dao,道德经, joke,笑话, lunyu,论语, maoshici,毛泽东诗词, maoyulu,毛泽东语录, proverb,谚语, zengguang,增广贤文, poem <br />Requires at least: 2.6<br />Tested up to: 2.6.1<br />Stable tag:<span style="color:blue"> 0.2</span><br />PHP Requires: 5.2.x<br />License: <a href="http://www.fsf.org/licensing/licenses/gpl.html" target="_bank" title="GNU General Public License" >GPL v3</a></p>
<p>== <b>Description</b> ==<br />这个插件允许在Wordpress中随机显示唐诗宋词, 你可以在widget的配置界面选择需要的<a href="#modules">模块</a>。<br />This plugin show poetry random in WordPress.</p>
<p><strong>Download</strong><br /><a href="http://nothing-at-all.googlecode.com/files/chinese-poem.0.3.zip" title="唐诗宋词(chinese poem)" alt="chinese poem 0.3" >chinese-poem.0.3.zip</a><br /><a href="http://nothing-at-all.googlecode.com/files/chinese-poem.0.2.zip" title="唐诗宋词(chinese poem)" alt="chinese poem 0.2" >chinese-poem.0.2.zip</a><br /><a href="http://nothing-at-all.googlecode.com/files/chinese-poem.0.1.zip" title="唐诗宋词(chinese poem)" alt="chinese poem 0.1" >chinese-poem.0.1.zip</a><br /> 暂时放在Google Code里。也可通过SVN获得：<br />
<table style="border:2px solid #E0E0E0;" >
<tbody>
<tr>
<td>svn checkout http://nothing-at-all.googlecode.com/svn/tags/chinese-poem_0_3<br />svn checkout http://nothing-at-all.googlecode.com/svn/tags/chinese-poem_0_2<br />svn checkout http://nothing-at-all.googlecode.com/svn/tags/chinese-poem_0_1</td>
</tr>
</tbody>
</table>
<p>第一个是0.3版的Tag，主支在 http://nothing-at-all.googlecode.com/svn/trunk/chinese-poem  </p>
<p><strong>功能说明[Usage]</strong></p>
<p style="text-indent: 2em" >0.2版加入了Widget支持，所以只要启用插件，在Widget界面配置即可。</p>
<p align="center" ><a href="http://lh5.ggpht.com/kldscs/SLeyN8a-JgI/AAAAAAAAAvo/XRU4qw3UXCo/s800/chinese-poem-widget.png" target="_bank" ><img class="frame" src="http://lh5.ggpht.com/kldscs/SLeyN8a-JgI/AAAAAAAAAvo/XRU4qw3UXCo/s400/chinese-poem-widget.png" title="唐诗宋词 配置窗口" alt="唐诗宋词 widget chinese poem" /></a><br />Widget 配置窗口</p>
<p style="text-indent: 2em" >同时0.2还加入了一个可以控制刷新时间的函数 show_chinese_poetry，它比原函数多了个 timespan 参数，<br />
<coolcode lang="php" ><br />
< ?php<br />
if (function_exists(show_chinese_poetry))<br />
	show_chinese_poetry(array('tang300', 'song100', 'songproses'), TRUE, 30);<br />
?><br />
</coolcode><br />
这样就可以每隔30分钟更新一次诗词，<span style="color:red">需要注意的是：</span>使用该函数必须保证插件目录下的 &#8220;poem.tmp&#8221;文件全局可写(权限为666),可以用命令 chmod 666 poem.tmp  来修改，或者FTP工具也可。    <br />详细使用方法可以参考<a href="#onepoem" >函数 show_chinese_poem()</a>。自定义模块也挺简单的，需要的可以参考这篇文章： <a href="http://mifunny.info/make-own-module-for-chinese-poem-96.html" target="_bank" title="自定义 个性 唐诗宋词 模块" alt="自定义 个性 唐诗 宋词 模块" >自定义 个性“唐诗宋词”模块</a>。</p>
<p style="text-indent: 2em" >在<a href="#install">安装完插件</a>后，<a name="onepoem">默认使用以下的代码</a>，将随机从tang300、song100、songproses三个文件中取出一首诗。也就是在我的<a href="http://mifunny.info/guestbook" target="_bank" title="留言板"  alt="guestbook" >留言板</a>中看到的那样，会是唐诗300首、宋诗100首或宋词中的其中之一。</p>
<p><coolcode lang="php" ><br />
< ?php if (function_exists(show_chinese_poem)) show_chinese_poem(); ?><br />
</coolcode></p>
<p align="center" ><img class="frame" src="http://lh5.ggpht.com/kldscs/SK6AquuM7bI/AAAAAAAAAug/jw9mLviZOPc/s800/sidebar.png" title="唐诗300首" alt="杜甫 春望" /><br />放在Sidebar里的唐诗</p>
<p style="text-indent: 2em" >当然，前面的<a href="#modules" >可用模块</a>确实是可以使用的，首先说明一下show_chinese_poem()函数的2个参数：<br />
<coolcode lang="php" ><br />
function show_chinese_poem($modules = array(&#8216;tang300&#8242;, &#8216;song100&#8242;, &#8216;songproses&#8217;), $css = TRUE)<br />
</coolcode><br />
第一个参数$modules 是一维数组，插件会在$modules的模块中自动选择一个作为输出; 而$css是布尔型，TRUE表示加载插件的CSS文件。</p>
<p style="text-indent: 2em" >比如模块中有一个&#8221;毛泽东诗词&#8221;，我希望只在&#8221;毛泽东诗词&#8221;中挑选诗词输出，那么可以这么写：<br />
<coolcode lang="php" ><br />
< ?php<br />
if (function_exists(show_chinese_poem))<br />
	show_chinese_poem(array('maoshici'));<br />
?><br />
</coolcode></p>
<p align="center" ><img class="frame" src="http://lh6.ggpht.com/kldscs/SK6fV0bI0_I/AAAAAAAAAvI/fTbgwgn4dJg/s800/maoshici.png" title="毛泽东诗词" alt="七律 人民解放军占领南京" /></p>
<p style="text-indent: 2em" >此外需要说明的是,输出HTML格式，基本所有模块的输出都和下面的定义差不多,可以据此修改poem.css中的风格。<br />
<coolcode lang="html" ><br />
<span class="poem-title">诗词标题</span><br /><span class="poem-author">诗歌作者</span><br /><span class="poem-content">诗歌内容</span><br />
</coolcode></p>
<p><a name="modules" ><strong>可用模块</strong></a></p>
<ul style="list-style-type: none" >
<li>caigentan:   菜根谭</li>
<li>dao:	     道德经</li>
<li>joke:	     笑话集</li>
<li>lunyu:	     论语</li>
<li>maoshici:    毛泽东诗词</li>
<li>maoyulu:     毛泽东语录</li>
<li>proverb:     谚语</li>
<li>song100:     宋诗100首</li>
<li>songproses:  宋词</li>
<li>tang300:     唐诗300首</li>
<li>zengguang:   增广贤文</li>
</ul>
<p>诗词原始资料来源于<a href="http://code.google.com/p/chinese-fortune/" title="中文fortune" >chinese-fortune</a></p>
<p>== <b><a name="install" >Installation</a></b> ==
<ul style="list-style-type: decimal" >
<li>Upload the Plugin folder to the `/wp-content/plugins/` directory</li>
<li>Activate the plugin through the `Plugins` menu in WordPress</li>
<li>Add Anywhere:  &lt;?php show_chinese_poem() ?&gt;</li>
<li>If you need to configure the CSS style of 唐诗宋词(chinese poem), open and edit: <br />/wp-content/plugins/chinese-poem/poem.css</li>
</ul>
<p><b>后记:</b>
<p style="text-indent: 2em; font-size: 0.9em ; color: gray;" >有一个很有名的开源项目：<a href="http://chinese-fortune.googlecode.com" title="fortune-mode-zh" target="_bank" >fortune-mode-zh</a>，里面有丰富的诗词文件，很早之前，我托ubuntu论坛里大牛的福在一直在conky中使用着。最近在看PHP，干脆写成Wordpress的插件，第一次写插件，还有很多不足，慢慢改吧。</p>
]]></content:encoded>
			<wfw:commentRss>http://mifunny.info/wp-plugin-chinese-poem-84.html/feed</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
	</channel>
</rss>

