<?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>Melbourne Web Developer, Website Design &#38; Development &#187; Tech.</title>
	<atom:link href="http://blog.koumei.net/category/tech/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.koumei.net</link>
	<description>= fn(n){n xor 0xFFFF004B eq 0x0 ? n : fn(n - 0x1)}</description>
	<lastBuildDate>Sat, 31 Jul 2010 16:18:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>REMIX10 &#8211; Share the Web Love, Late Update</title>
		<link>http://blog.koumei.net/2010/06/19/remix10-share-the-web-love-late-update/</link>
		<comments>http://blog.koumei.net/2010/06/19/remix10-share-the-web-love-late-update/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 15:01:09 +0000</pubDate>
		<dc:creator>Koumei</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Interesting]]></category>
		<category><![CDATA[Living in Victoria]]></category>
		<category><![CDATA[Tech.]]></category>

		<guid isPermaLink="false">http://blog.koumei.net/?p=585</guid>
		<description><![CDATA[I almost forget the interesting 2-day event or you can say &#8220;meeting&#8221; in Melbourne. The idea of this conference is to show Microsoft developer the latest development kits and to let technical or IT people catch up each other. $300 for joining the meeting but I got it for free. Thanks to my boss to [...]]]></description>
			<content:encoded><![CDATA[<p>I almost forget the interesting 2-day event or you can say &#8220;meeting&#8221; in Melbourne. The idea of this conference is to show Microsoft developer the latest development kits and to let technical or IT people catch up each other. $300 for joining the meeting but I got it for free. Thanks to my boss to give me such great opportunity to join the great event.</p>
<p>I got 2 souvenirs, such as t-shirt, caps, but all are related to Microsoft stuff. You want to get the t-shirt? well, need to make some efforts. Everyone who attends the meeting will get a magic cube from the host, and need to fix the cube to a designated image. After all, once cubes are fixed, the host sorts them out and put them in a frame, to shape a IE icon:</p>
<div id="attachment_586" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.koumei.net/wp-content/uploads/2010/06/IMG00293-20100602-1056.jpg"><img class="size-medium wp-image-586" title="The Frame of Magic cubes" src="http://blog.koumei.net/wp-content/uploads/2010/06/IMG00293-20100602-1056-300x225.jpg" alt="The Frame of Magic cubes" width="300" height="225" /></a><p class="wp-caption-text">The Frame of Magic cubes,Everyone is involved</p></div>
<p>I think the most useful sessions are about how jQuery works peacefully with ASP.NET and VS.NET 2010 new features, and one interesting session talking about the future data representation, and introduce Pivot. Microsoft considers the cooperation with jQuery is a giant step forward, and shows its ambitions to open source community. Microsoft starts to contribute to open source community and make a lot of effort towards it, look forward to seeing its powerful tool released in months to come.</p>
<div id="attachment_587" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.koumei.net/wp-content/uploads/2010/06/IMG00294-20100602-1255.jpg"><img class="size-medium wp-image-587" title="Frankly Speaking - Talk Show in REMIX10" src="http://blog.koumei.net/wp-content/uploads/2010/06/IMG00294-20100602-1255-300x224.jpg" alt="Frankly Speaking - Talk Show in REMIX10" width="300" height="224" /></a><p class="wp-caption-text">Frankly Speaking - Talk Show in REMIX10</p></div>
<p>One thing somehow a little bit disappointed me is on this event, Microsoft doesn&#8217;t show any thing about HTML5 and CSS3, I think because Microsoft more focuses on sliverlight technology?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.koumei.net/2010/06/19/remix10-share-the-web-love-late-update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Use of Lambda Expression to Create Complicated Query</title>
		<link>http://blog.koumei.net/2010/03/10/use-lambda-expression-to-create-complicated-query/</link>
		<comments>http://blog.koumei.net/2010/03/10/use-lambda-expression-to-create-complicated-query/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 07:12:31 +0000</pubDate>
		<dc:creator>Koumei</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Lab]]></category>
		<category><![CDATA[Tech.]]></category>

		<guid isPermaLink="false">http://blog.koumei.net/?p=465</guid>
		<description><![CDATA[.NET FX introduces a powerful weapon for creating the compact, breezy and elegant code in your project. The weapon&#8217;s name is as complicated as the mathematical stuff, called Lambda expression.
As the name implies, the great convenience comes great complication inside. Lambda expression is too important to understand, it is useful and I think it is [...]]]></description>
			<content:encoded><![CDATA[<p>.NET FX introduces a powerful weapon for creating the compact, breezy and elegant code in your project. The weapon&#8217;s name is as complicated as the mathematical stuff, called Lambda expression.</p>
<p>As the name implies, the great convenience comes great complication inside. Lambda expression is too important to understand, it is useful and I think it is good to know how it works. Well, it&#8217;s not as complicated as we think, just a little bit confusing when using it.</p>
<p>First of all, Lambda is used for 2 purposes. 1 is to simplify delegation, 2 is to create expression tree. In my case, I need to create lambda expression to create dynamic query.</p>
<p>Imagine the following usecase:</p>
<p>In your product table, there is a field called &#8220;Tags&#8221; and it&#8217;s used for storing the CSV (comma separated value) like &#8220;car, mazda, suv, luxury&#8221;, you have many records:</p>
<p>Product Table: (Table name: ProductTable)</p>
<p><span style="text-decoration: underline;"><strong>ID    ProductName    Tags</strong></span><br />
1    Tow bar        car,mazda,suv,luxury<br />
2    Cup holder    car,luxury<br />
3    Phone holder    car,mazda<br />
4    FM Transmitter    car,suv<br />
5    Queens bed    luxury<br />
6    DVD Burner    car,BMW,x5,luxury</p>
<p>When your searching criteria is<br />
&#8220;mazda&#8221; and &#8220;luxury&#8221;, the following records would be selected out:</p>
<p><span style="text-decoration: underline;"><strong>ID    ProductName    Tags</strong></span><br />
1    Tow bar        car,mazda,suv,luxury<br />
2    Cup holder    car,luxury<br />
3    Phone holder    car,mazda<br />
5    Queens bed    luxury<br />
6    DVD Burner    car,BMW,x5,luxury</p>
<p>In ancient SQL age, you would probably write a SQL like this:</p>
<address>string SQL = &#8220;SELECT * FORM ProductTable WHERE Tags LIKE&#8217;%mazda%&#8217; OR Tags LIKE &#8216;%luxury%&#8217;&#8221;;</address>
<p>It is IMpossible to create SQL like above except the project scope tells you the fixed keywords that would be used, the keywords should flexible. Then the code would be as much as:</p>
<address>string[] tags = new string[]{&#8220;mazda&#8221;, &#8220;luxury&#8221;};</address>
<address>string SQL = &#8220;SELECT * FROM ProductTable WHERE 1=1&#8243;;<br />
foreach(string tag in tags)<br />
{<br />
SQL += string.format(@&#8221; AND Tags like &#8216;%{0}%&#8217;&#8221;, tag);<br />
}</address>
<p>You must be very exciting that your code supports as many keywrods as it can. (I did before, I mean I would be very exciting when the code filled with logical stuff, LOL, of course, not now, that&#8217;s what geek did before~ )</p>
<p>Back to the reality, to the modern age, with the lambda expression, what you need to do is:</p>
<p>(pre-condition: you have created corresponding domain model which mapped to the database.)<br />
The domain object or entity would look like:</p>
<address>[Table("ProductTable")] Class ProductTable{<br />
[Column]public int Id{get; set;}<br />
[Column]public string ProductName{get; set;}<br />
[Column]public string Tags{get; set;}<br />
}</address>
<p>to fullfill the same kind of logic as the stone-aged people do, you just need to</p>
<address>DataContext db = new DataContext(&#8220;&lt;connection-string&gt;&#8221;);<br />
Table&lt;ProductTable&gt; table = db.GetTable&lt;ProductTable&gt;();</address>
<address>string tag1 = &#8220;mazda&#8221;;<br />
string tag2 = &#8220;luxury&#8221;;</address>
<address>var data = table.where(x=&gt;x.Tags.Contains(tag1)).where(x=&gt;x.Tags.Contains(tag2)) select new ProductTable;<br />
return data.AsQueryable();</address>
<p>Since so far, you still feel comfortable with this, but after minute, you would probably wanna go back stone age, how do we dynamically create the query in this case? Unfortunately, there is no short-cut for this, but many people provide lots of solutions on the Internet. We can either download some source codes about dynamically query on Internet or just grab the codes from the blogger&#8217;s website.( Most of time, you can&#8217;t use all of their codes posted on the blog, the codes are broken and bad structure, remember what Koumei always suggests, absorb the mind from the other coders, do not copy the code they provided. )</p>
<p>But in here, I would rather to use Expression Tree to implement the dynamic query.</p>
<p>First of all, we need to create an expression, because it would be applied to IQueryable.Where(Expression&lt;Func&lt;ProductTable, bool&gt;&gt; expression), so the expression should be defined as:</p>
<address>public static System.Linq.Expressions.Expression&lt;Func&lt;ProductTable, bool&gt;&gt; ApplyTags(IEnumerable&lt;string&gt; tags) //parameter is the collection of tags<br />
{</address>
<address>ParameterExpression c = Expression.Parameter(typeof(ProductTable), &#8220;c&#8221;); //Get the parameter from Func&lt;ProductTable, bool&gt;, remember? this is the advanced and lazy version of delegation, we need to craete ParameterExpression to hold this</address>
<address>var tagsProperty = Expression.Property(c, typeof(ProductTable).GetProperty(&#8220;Tags&#8221;)); //Here is the expression for get the Tags value from ProductTable object</address>
<address>Type[] ContainsTypes = new Type[1];</address>
<address>ContainsTypes[0] = typeof(string);</address>
<address>System.Reflection.MethodInfo myContainsInfo = typeof(string).GetMethod(&#8220;Contains&#8221;, ContainsTypes);</address>
<address>//Create the expression collection (based on the tags collection from parameter)<br />
List&lt;Expression&gt; myTagExpressions = new List&lt;Expression&gt;();</address>
<address>foreach (var t in tags)<br />
{<br />
myTagExpressions.Add(Expression.Call(Expression.Call(tagsProperty, &#8220;ToString&#8221;, null, null), myContainsInfo, Expression.Constant(t)));<br />
}</address>
<address>Expression OrExpression = null;</address>
<address>foreach (Expression myTagExpression in myTagExpressions)<br />
{<br />
if (OrExpression == null)<br />
{<br />
OrExpression = myTagExpression;<br />
}<br />
else<br />
{<br />
//Need to implement OR relationship among all the expressions<br />
OrExpression = Expression.Or(myTagExpression, OrExpression);<br />
}<br />
}</address>
<address>//This is how Expression would be extracted to expression tree later on.<br />
Expression&lt;Func&lt;ProductTable, bool&gt;&gt; predicate = Expression.Lambda&lt;Func&lt;ProductTable, bool&gt;&gt;(OrExpression, c);</address>
<address>return predicate;</address>
<address>}</address>
<p>Again, you can&#8217;t copy the code, since you would NOT have the same object like ProductTable and the same &#8220;Tags&#8221; property as I do. Luckily, you still can copy the code that I provide later, which is using the magic of template or generic programming. Before that, let us see how to use it:</p>
<address>IQueryable all = table.Where(ApplyTags(new List{&#8220;mazda&#8221;,&#8221;luxury&#8221;})).AsQueryable();</address>
<p>Since so far, I am 100% sure you can do it like refactoring, re-structuring to optimize your code. However, I would like to provide the code which can be general used:</p>
<address>public static System.Linq.Expressions.Expression&lt;Func&lt;T, bool&gt;&gt; ApplyFilter&lt;T&gt;(IEnumerable&lt;string&gt; filters, string property)<br />
{<br />
//Get parameter<br />
ParameterExpression c = Expression.Parameter(typeof(T), &#8220;c&#8221;);</address>
<address>//Get property from &lt;T&gt;<br />
var tagsProperty = Expression.Property(c, typeof(T).GetProperty(property));</address>
<address>Type[] ContainsTypes = new Type[1];<br />
ContainsTypes[0] = typeof(string);<br />
System.Reflection.MethodInfo myContainsInfo = typeof(string).GetMethod(&#8220;Contains&#8221;, ContainsTypes);<br />
List&lt;Expression&gt; myTagExpressions = new List&lt;Expression&gt;();<br />
foreach (var t in filters)<br />
{<br />
myTagExpressions.Add(Expression.Call(Expression.Call(tagsProperty, &#8220;ToString&#8221;, null, null), myContainsInfo, Expression.Constant(t)));<br />
}<br />
Expression OrExpression = null;<br />
foreach (Expression myTagExpression in myTagExpressions)<br />
{<br />
if (OrExpression == null)<br />
{<br />
OrExpression = myTagExpression;<br />
}<br />
else<br />
{<br />
OrExpression = Expression.Or(myTagExpression, OrExpression);<br />
}<br />
}<br />
Expression&lt;Func&lt;T, bool&gt;&gt; predicate = Expression.Lambda&lt;Func&lt;T, bool&gt;&gt;(OrExpression, c);<br />
return predicate;<br />
}</address>
<p>The usage is similiar:</p>
<address>IQueryable all = table.Where(ApplyFilter&lt;ProductTable&gt;(new List{&#8220;mazda&#8221;,&#8221;luxury&#8221;}, &#8220;Tags&#8221;)).AsQueryable();</address>
<p>Not that hard, right?</p>
<p>Enjoy the powerful weapon, but don&#8217;t hurt yourself, bacause the deadline is ahead!</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 114px; width: 1px; height: 1px;">6    DVD Burner    car,BMW,x5,luxury</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.koumei.net/2010/03/10/use-lambda-expression-to-create-complicated-query/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>My Webklip Plugin For Wordpress: Goes Multiple-RSS!</title>
		<link>http://blog.koumei.net/2009/03/29/my-webklip-plugin-for-wordpress-goes-multiple-rss/</link>
		<comments>http://blog.koumei.net/2009/03/29/my-webklip-plugin-for-wordpress-goes-multiple-rss/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 16:58:15 +0000</pubDate>
		<dc:creator>Koumei</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tech.]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[web klip]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.koumei.net/?p=293</guid>
		<description><![CDATA[Today I refactory the source code and add new features to Webklip, it becomes 1.2 and, most encouraging, multiple rss supports!
The improvement includes:

Uses template engine to show widget. No more embedded HTML.
Moves all functions to a util class
Supports up to 5 RSS
Still reads RSS feed dynamically on client-side

The feature version will be released next day [...]]]></description>
			<content:encoded><![CDATA[<p>Today I refactory the source code and add new features to Webklip, it becomes 1.2 and, most encouraging, multiple rss supports!</p>
<p>The improvement includes:</p>
<ul>
<li>Uses template engine to show widget. No more embedded HTML.</li>
<li>Moves all functions to a util class</li>
<li>Supports up to 5 RSS</li>
<li>Still reads RSS feed dynamically on client-side</li>
</ul>
<p>The feature version will be released next day or two, will enhance javascript flexibility. E.g., not compulsorily needs jQuery framework.</p>
<p>You can download the widget on <a title="wp-webKlip.zip" href="/download/wp-webKlip.zip" target="_blank">http://www.koumei.net/download/wp-webKlip.zip</a></p>
<p>Relative article:</p>
<p><a title="Permanent Link to Wordpress Widget: Client-side RSS util, The Web Klip Released!" rel="bookmark" href="http://blog.koumei.net/2009/03/21/wordpress-widget-client-side-rss-util-the-web-klip-released/">Wordpress Widget: Client-side RSS util, The Web Klip Released!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.koumei.net/2009/03/29/my-webklip-plugin-for-wordpress-goes-multiple-rss/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Virtuemart: Ajax Effect on IE 8 Fix List based on Virtuemart 1.1.3(stable release since 22, Jan)</title>
		<link>http://blog.koumei.net/2009/03/23/virtuemart-ajax-effect-in-ie-8-fix-list-based-on-virtuemart-113stable-release-since-22-jan/</link>
		<comments>http://blog.koumei.net/2009/03/23/virtuemart-ajax-effect-in-ie-8-fix-list-based-on-virtuemart-113stable-release-since-22-jan/#comments</comments>
		<pubDate>Sun, 22 Mar 2009 13:27:54 +0000</pubDate>
		<dc:creator>Koumei</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tech.]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[IE8]]></category>
		<category><![CDATA[mooTools]]></category>
		<category><![CDATA[virtuemart]]></category>

		<guid isPermaLink="false">http://www.koumei.net/?p=286</guid>
		<description><![CDATA[Virtuemart utilizes Ajax mostly by mooTools. It works fine in many browsers except microsoft newly released browser IE 8. Especially when user try to add a product to shopping cart using Ajax, the mooPrompt (a pop-up window) fails, and nothing happen on that page&#8230; Maybe the first thing you are about to do is to [...]]]></description>
			<content:encoded><![CDATA[<p>Virtuemart utilizes Ajax mostly by mooTools. It works fine in many browsers except microsoft newly released browser IE 8. Especially when user try to add a product to shopping cart using Ajax, the mooPrompt (a pop-up window) fails, and nothing happen on that page&#8230; Maybe the first thing you are about to do is to upgrade mooTools. Yes, that&#8217;s seems a great idea, however mooTools&#8217;s updates from 1.11 to 1.21 is totally a nightmare for developer. Many things change, you have to revise the code manually for Virtuemart. </p>
<p>The following files should be updated (if you want to satisfy IE 8 users):</p>
<ul>
<li>\components\com_virtuemart\js\mootools\mootools-release-1.11.js  (update to 1.21)</li>
<li><strong>\components\com_virtuemart\js\mootools\mooPrompt.js</strong> (you have to revise it manually. Should change a lot of JS class definitions in accordance with mootools 1.21 syntax)</li>
<li>\components\com_virtuemart\js\slimbox (update to slimbox for mootools 1.21)</li>
<li><strong>\components\com_virtuemart\themes\default\theme.js</strong> (you have to revise it manually. Should fix a bug on line 59, change to <em>var timeoutID = setTimeout( &#8216;document.boxB.close()&#8217;, 3000 );</em>)</li>
</ul>
<p>Besides updating corresponding files, you can also disable Ajax function on the administration page. Or.. Wait until next stable release of VM). If you need the files above, just leave me a message, and I will pack them up for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.koumei.net/2009/03/23/virtuemart-ajax-effect-in-ie-8-fix-list-based-on-virtuemart-113stable-release-since-22-jan/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Web Klip Enhancement &#8211; Special Effect Applied</title>
		<link>http://blog.koumei.net/2009/03/22/web-klip-enhancement-special-effect-applied/</link>
		<comments>http://blog.koumei.net/2009/03/22/web-klip-enhancement-special-effect-applied/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 14:14:43 +0000</pubDate>
		<dc:creator>Koumei</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tech.]]></category>

		<guid isPermaLink="false">http://www.koumei.net/?p=283</guid>
		<description><![CDATA[Currect release: 1.1
Download: http://www.koumei.net/download/wp-webKlip.zip
Not too much special effects. In order to make the contents which read from the underneath javascript show themselves up naturally. Not in a harsh.
]]></description>
			<content:encoded><![CDATA[<p>Currect release: 1.1</p>
<p>Download: <a title="wp-webKlip.zip" href="http://www.koumei.net/download/wp-webKlip.zip" target="_blank">http://www.koumei.net/download/wp-webKlip.zip</a></p>
<p>Not too much special effects. In order to make the contents which read from the underneath javascript show themselves up naturally. Not in a harsh.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.koumei.net/2009/03/22/web-klip-enhancement-special-effect-applied/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wordpress Widget: Client-side RSS util, The Web Klip Released!</title>
		<link>http://blog.koumei.net/2009/03/21/wordpress-widget-client-side-rss-util-the-web-klip-released/</link>
		<comments>http://blog.koumei.net/2009/03/21/wordpress-widget-client-side-rss-util-the-web-klip-released/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 16:33:14 +0000</pubDate>
		<dc:creator>Koumei</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tech.]]></category>
		<category><![CDATA[RSS util]]></category>
		<category><![CDATA[web klip]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.koumei.net/?p=272</guid>
		<description><![CDATA[The original Wordpress (2.7+) provides RSS clip widget from the other website. It looks good but it is server-side script that may occupy the server resource to interpret the RSS. I don&#8217;t like that approach. So I decide to create a client-side script that loads rss from other website or blog.
If you want to try, [...]]]></description>
			<content:encoded><![CDATA[<p>The original Wordpress (2.7+) provides RSS clip widget from the other website. It looks good but it is server-side script that may occupy the server resource to interpret the RSS. I don&#8217;t like that approach. So I decide to create a client-side script that loads rss from other website or blog.</p>
<p>If you want to try, just download the widget on <a title="wp-webKlip.zip" href="http://www.koumei.net/download/wp-webKlip.zip" target="_blank">http://www.koumei.net/download/wp-webKlip.zip</a> , then unzip to wp-content/plug-ins/ folder, and activate the plugin and add widget to you wordpress blog.</p>
<p>Before using this widget, there are some notes you should know:</p>
<ol>
<li><strong>Defects</strong>:<br />
Currently only support ONE RSS excerpt.<br />
Only shows the first RSS item.<br />
<span style="text-decoration: underline;">jQuery should be included on your blog. </span></li>
<li><strong>Usability</strong>:<br />
Site that provide at least 1 item RSS feed could be refered by this widget.</li>
<li><strong>Extension</strong>:<br />
Multiple-RSS and rollover will be available  on next release.</li>
</ol>
<p>The Demo:</p>
<address><img class="alignnone size-full wp-image-274" title="webklip_1" src="/wp-content/uploads/2009/03/webklip_1.jpg" alt="webklip_1" width="586" height="41" /><br />
<em> Picture 1. The plugin will be shown after you copy the unzipped file to your plugin folder</em></address>
<address><img class="alignnone size-full wp-image-275" title="webklip_2" src="/wp-content/uploads/2009/03/webklip_2.jpg" alt="webklip_2" width="298" height="228" /><br />
<em> Picture 2. Add the widget to the &#8220;Widgets&#8221; menu on your administration panel. You can add a RSS feed to this widget</em></address>
<p>You can  find the demo on the right side of my blog.</p>
<p> <img src='http://blog.koumei.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.koumei.net/2009/03/21/wordpress-widget-client-side-rss-util-the-web-klip-released/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A Simple Rss2Json Service Released!</title>
		<link>http://blog.koumei.net/2009/03/20/a-simple-rss2json-service-released/</link>
		<comments>http://blog.koumei.net/2009/03/20/a-simple-rss2json-service-released/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 14:33:43 +0000</pubDate>
		<dc:creator>Koumei</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tech.]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[RSS]]></category>

		<guid isPermaLink="false">http://www.koumei.net/?p=264</guid>
		<description><![CDATA[Now I simply add a Rss2Json service on my blog, it just return the very first post from the target website as JSON and, of course, the target should be RSS format. The reason why I create this interface is because I would like to utilize cool AJAX to obtain the content from my friend&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Now I simply add a Rss2Json service on my blog, it just return the very first post from the target website as JSON and, of course, the target should be RSS format. The reason why I create this interface is because I would like to utilize cool AJAX to obtain the content from my friend&#8217;s blog, yet the browser secure prevent me crossing the boundary to other domain. Could it be working using iFrame? Negative. The only approach to cross the border is using JSON.</p>
<p>The definition of my interface is:</p>
<p><strong>Name</strong>: Rss2JSon<br />
<strong>Interface</strong>: http://www.koumei.net/rss2json/<br />
<strong>Method</strong>: GET<br />
<strong>Parameter 1</strong>:  rss  &#8211; The URL of the rss content<br />
<strong>Parameter 2</strong>: cb &#8212; The javascript callback function<br />
<strong>Return</strong>: application/x-javascript<br />
<strong>Example</strong>: http://www.koumei.net/rss2json/?rss=http://www.blogjava.net/max/rss&amp;cb=&lt;callback&gt;  (A blog of my friend)</p>
<p>The callback function is very <strong><span style="font-family: mceinline;"><span style="text-decoration: underline;">significant</span></span></strong>. Don&#8217;t forget to define a callback JS function on your script. The definition of the callback function should be similar as below ( parameter rss is an object, containing &#8220;title&#8221;, &#8220;link&#8221; and &#8220;description&#8221; and so forth&lt;please go through RSS schema on item tag&gt;.)</p>
<p><em>&lt;script type=&#8221;text/javascript&#8221;&gt; </em></p>
<p><em>function myCallback(rss){<br />
    var title = rss["title"];   // or rss.title<br />
    var link = rss["link"];  // or rss.link<br />
    var desc = rss["description"];  // or rss.description.<br />
}</em></p>
<p><em>&lt;/script&gt;</em></p>
<p>Now, you can embed the script to wherever you need.<br />
&lt;script type=&#8221;text/javascript&#8221; src=&#8221;http://www.koumei.net/rss2json/?rss=http://www.blogjava.net/max/rss&amp;cb=myCallback&#8221;&gt;&lt;/script&gt; </p>
<p>Enjoy scripting.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.koumei.net/2009/03/20/a-simple-rss2json-service-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An idea for &#8220;Add to Favorite&#8221; function for virtuemart</title>
		<link>http://blog.koumei.net/2009/03/18/a-idea-for-add-to-favorite-function-for-virtuemart/</link>
		<comments>http://blog.koumei.net/2009/03/18/a-idea-for-add-to-favorite-function-for-virtuemart/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 12:58:04 +0000</pubDate>
		<dc:creator>Koumei</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tech.]]></category>
		<category><![CDATA[favorite]]></category>
		<category><![CDATA[virtuemart]]></category>

		<guid isPermaLink="false">http://www.koumei.net/?p=255</guid>
		<description><![CDATA[The original Virtuemart provides RSS feed to every product, so that users can &#8220;eat&#8221; the feed if they like the product. The idea is cool, but actually, I prefer an on-line favorite subscribe function for the user than RSS subscribe. The RSS subscription is good to track back to a single category or a whole [...]]]></description>
			<content:encoded><![CDATA[<p>The original Virtuemart provides RSS feed to every product, so that users can &#8220;eat&#8221; the feed if they like the product. The idea is cool, but actually, I prefer an on-line favorite subscribe function for the user than RSS subscribe. The RSS subscription is good to track back to a single category or a whole website, not so good to track each product. How many chance you would like to change the product&#8217;s description or product&#8217;s price to let the users know the newest status of product? So your product categories and website will be renew every now and then, even everyday, but not a single product, right? So the single product is good to be traced on the website&#8217;s favorite function. Unfortunately, Virtuemart doesn&#8217;t come with such a function for people to trace their own favorite product. The favorite products mean the products are probationary, users don&#8217;t buy them, but could buy them later. So what I think the &#8220;Add to Favorite&#8221; function could be specified as:</p>
<ol>
<li>It&#8217;s managable. User could easily add product to favorite list just a single click, better not refresh the page after they click a button.</li>
<li>User can review the favorite list. </li>
<li>The product in the favorite list will be shown when the product is published.</li>
</ol>
<p>I think this little gadget could help user shopping with happiness.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.koumei.net/2009/03/18/a-idea-for-add-to-favorite-function-for-virtuemart/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Howto: Create “Cash on Delivery” payment Varied from Different Postcodes for Virtuemart</title>
		<link>http://blog.koumei.net/2009/03/17/howto-create-cash-on-delivery-payment/</link>
		<comments>http://blog.koumei.net/2009/03/17/howto-create-cash-on-delivery-payment/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 10:58:39 +0000</pubDate>
		<dc:creator>Koumei</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tech.]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[virtuemart]]></category>

		<guid isPermaLink="false">http://www.koumei.net/?p=220</guid>
		<description><![CDATA[Actually Virtuemart has done a great job on cash on delivery support, but what if cash on delivery cost a fee not only the total amount of purchase but also the different postcode? Here comes a tutorial on how to calculate the different rates based on users&#8217; postcode.
Of course, before doing that, you need to [...]]]></description>
			<content:encoded><![CDATA[<p>Actually Virtuemart has done a great job on cash on delivery support, but what if cash on delivery cost a fee not only the total amount of purchase but also the different postcode? Here comes a tutorial on how to calculate the different rates based on users&#8217; postcode.</p>
<p>Of course, before doing that, you need to have a workable Virtuemart distribution on joomla. You can find more tutorials on <a title="Joomla!" href="http://www.joomla.org" target="_blank">joomla official </a>website or <a title="Virtuemart" href="http://www.virtuemart.net" target="_blank">virtuemart website</a>.</p>
<p>There are only two steps of this simple tutorial:</p>
<ol>
<li>Create a new payment method on Cash on Delivery. Actually the orignal virtuemart comes with an option of &#8220;COD&#8221;, but at this time I don&#8217;t want to ruin its file structure. I prefer to create a new one. Actually creating new payment method helps you to know more about joomla.</li>
<li>Revise &#8220;ps_checkout.php&#8221; to make it works.</li>
</ol>
<p>Let&#8217;s dive to details.</p>
<p><strong>Create a new payment method on Cash on Delivery.</strong></p>
<p>Sooner or later will you find that creating payment method couldn&#8217;t be easier. What you need to do is to create a class, and of course, you write some methods which is recoginzed by joomla framework. You can find bunch of original payment classes on /administrator/components/com_virtuemart/classes/payment/ folder. If you see carefully, you can see each payment class comes with a config file. For instance, you can see a payment class called ps_paypal.php, should come with a config named ps_paypal.cfg.php. I won&#8217;t use config file, so I don&#8217;t need the cfg.php file. Now here&#8217;s my turn on creating such a class:  create a file name &#8220;ps_codonpc.php&#8221; (which means &#8220;Cash On Delivery On PostCodes&#8221;), never mind its name, but I think you better follow the naming convention of Virtuemart. Open this file with any kind of text-editor, I recommend to use <a title="notepad++" href="http://notepad-plus.sourceforge.net/uk/download.php" target="_blank">notepad++</a>. Create a skeleton below.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'_VALID_MOS'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #339933;">!</span><span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'_JEXEC'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Direct Access to '</span><span style="color: #339933;">.</span><span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' is not allowed.'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> ps_codonpc<span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$classname</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;ps_codonpc&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$payment_code</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;PU&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> show_configuration<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>  
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> has_configuration<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> get_payment_rate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sum</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ship_to_info_id</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #009900;">&#125;</span>  
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> configfile_writeable<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> configfile_readable<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> write_configuration<span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$d</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> process_payment<span style="color: #009900;">&#40;</span><span style="color: #000088;">$order_number</span><span style="color: #339933;">,</span> <span style="color: #000088;">$order_total</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I know what you must be thinking.  You must be wondering if there is any necessity to create those functions within the class. Yes, you have to. That&#8217;s the weakness as well as fexibility of the characteristic  object-oriented of PHP. Well, it makes senses, because PHP is runtime dynamic language, not compile-time language. The payment classes on /payment folder are dynamically recognized by the framework, they use the same functions naming convention to make the polymorphism works.  I mean the ps_paypal.php and ps_paymate.php are of the same functions&#8217; name, and created by the framework, however the framework doesn&#8217;t need to know the existance of payment classes and doesn&#8217;t know what they are doing. The framework only knows their functions&#8217; name. Confused? Never mind.  Forget this paragraph. You can do the same thing on java using &#8220;reflection&#8221;.</p>
<p>You can see a function called &#8220;get_payment_rate&#8221; in this class. Well, not all the classes in /payment folder have this function. Why? That&#8217;s because virtuemart framework will only calculate the payment rate if the &#8220;get_payment_rate&#8221; function is defined. Actually, there is only one parameter is need: $sum, but since we need to calculate the fee by post code, I add an additional paramter(ship_to_info_id)  and give it a default value(null).</p>
<p>Now you need to fill the &#8220;get_payment_rate&#8221; logic to make it works. I add a simple logic to calculate the payment rate.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> get_payment_rate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sum</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ship_to_info_id</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//Get the ship_to_info_id if the parameter is null</span>
		<span style="color: #666666; font-style: italic;">//Normally the item is passed from checkout module</span>
		<span style="color: #666666; font-style: italic;">//We need to change ps_payment_method.php to pass the parameter to this object.</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$ship_to_info_id</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		    <span style="color: #000088;">$sdb</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ps_DB<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		    <span style="color: #000088;">$sdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setQuery</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;SELECT user_info_id FROM #__{vm}_user_info WHERE user_id=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$auth</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user_id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; AND address_type='BT'&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		    <span style="color: #000088;">$ship_to_info_id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$sdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadResult</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//Get the zip(post code) from user info table</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$ship_to_info_id</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #000088;">$sdb</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ps_DB<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000088;">$qry</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT `zip` FROM `#__{vm}_user_info` WHERE user_info_id='&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$ship_to_info_id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000088;">$sdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$qry</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000088;">$sdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">next_record</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000088;">$postcode</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$sdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">f</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'zip'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>  
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$postcode</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$postcode</span> <span style="color: #339933;">&gt;=</span> <span style="color: #0000ff;">'3000'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$postcode</span> <span style="color: #339933;">&lt;</span> <span style="color: #0000ff;">'3050'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">//these areas are free</span>
			<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$postcode</span> <span style="color: #339933;">&gt;=</span> <span style="color: #0000ff;">'3050'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$postcode</span> <span style="color: #339933;">&lt;</span> <span style="color: #0000ff;">'3150'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #990000;">floatval</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'CURRENCY'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">convert</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">//these areas cost $5</span>
			<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #990000;">floatval</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'CURRENCY'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">convert</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//the othes cost $10</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//unknow post code, use default</span>
			<span style="color: #b1b100;">return</span> <span style="color: #990000;">floatval</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'CURRENCY'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">convert</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//the othes cost $10</span>
		<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Can you see the return value? it&#8217;s negative, that&#8217;s because the get_payment_rate function return the payment discount (according to the definition of this function), the name should be changed to get_payment_discount. Otherwise would be a little bit confused. If you return a positive, the users will get a discount from this payment; a negative, the users will pay an extra fee.</p>
<p>OK. That&#8217;s fine. </p>
<p><strong>Revise &#8220;ps_checkout.php&#8221; to make it works.</strong></p>
<p>And now go to ps_checkout.php, and find a line 1673, change &#8220;return $_PAYMENT-&gt;get_payment_rate($subtotal);&#8221; to<br />
&#8221;<br />
$ship_to_info_id = $_REQUEST['ship_to_info_id'];<br />
return $_PAYMENT-&gt;get_payment_rate($subtotal, $ship_to_info_id);<br />
&#8220;.</p>
<p>Okey dokey, Now add the Cash On Delivery paymethod on your administration page, and then go through the check out process and find out more excitement. Of course, the logic provided here is very simple, you can judge the rate from a post code data table and apply new features.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.koumei.net/2009/03/17/howto-create-cash-on-delivery-payment/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Howto: Show your images using fla-img-sw</title>
		<link>http://blog.koumei.net/2009/03/15/howto-show-your-images-using-fla-img-sw/</link>
		<comments>http://blog.koumei.net/2009/03/15/howto-show-your-images-using-fla-img-sw/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 14:06:12 +0000</pubDate>
		<dc:creator>Koumei</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tech.]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[opensource]]></category>

		<guid isPermaLink="false">http://www.koumei.net/?p=194</guid>
		<description><![CDATA[&#8220;fla-img-sw&#8221; is a flash movie clip that enables several images loading by passing the images&#8217; URL to the flash parameter. &#8220;fla-img-sw&#8221; is annouced by myself, you can get the source code or get the package on http://code.google.com/p/fla-img-switch/ .
Using AJAX to improve the loading phrase of the website is considered to be a good pratice on presentation tier. [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;fla-img-sw&#8221; is a flash movie clip that enables several images loading by passing the images&#8217; URL to the flash parameter. &#8220;fla-img-sw&#8221; is annouced by myself, you can get the source code or get the <a title="fla-img-switch package" href="http://fla-img-switch.googlecode.com/files/fla-img-switch.zip" target="_blank"><strong>package</strong></a> on <a style="text-decoration: none;" href="http://code.google.com/p/fla-img-switch/" target="_blank">http://code.google.com/p/fla-img-switch/</a> .</p>
<p>Using AJAX to improve the loading phrase of the website is considered to be a good pratice on presentation tier. Actually, Flash movie cilp can do the same thing as AJAX. Imagine there are several images are to be loaded in one page, it takes user&#8217;s time on loading the page. If you show a thumbnail in that page, then if users would like to see the detail of the image, they have to click on that image link, your website then pop-up a window to show the original size of the picture. It waste users&#8217; time, according to <a title="even faster web sites PPT" href="http://stevesouders.com/docs/google-20090305.ppt" target="_blank">Even Faster Web Sites</a> (Steve Souders), Life is too short, we should write code faster then even (means saving your users&#8217; life and time <img src='http://blog.koumei.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </p>
<p>But I am not here to talk about how to utilize AJAX to improve the website, but gonna show a tutorial on how to use my open source gadget to show images on your website. Before that, just take a look at the example of how the gadget work: (click to enlarge, please note that the demo below is a snapshot of the commercial usage, the open source version is somehow a little bit different from the commercial one, like I depict on the previous post.)<br />
<a href="http://www.koumei.net/wp-content/uploads/2009/03/fla-img-switch.jpg" target="_blank"><img class="alignnone size-medium wp-image-196" title="fla-img-switch" src="http://www.koumei.net/wp-content/uploads/2009/03/fla-img-switch-300x213.jpg" alt="fla-img-switch" width="300" height="213" /></a> <br />
You can see a thumbnail on the right side, and the main picture which is selected will display on the big left side.</p>
<p>It&#8217;s easy to use. Once you get the package, you will see a file call &#8220;ImgSwitch.html&#8221;, that is the demo file, double click this file and you can see a demo locally. If you feel enough for the demo and being inclined to use it, just open the &#8220;ImgSwitch.html&#8221; and you will see how it works.</p>
<p>Easy to proceed:</p>
<ol>
<li>Copy &#8220;ImgSwitch.swf&#8221; to a appropriate position which you can refer from your HTML</li>
<li>Copy the code below to where you would like to show the images:<br />
<em><span style="font-family: mceinline;"> &lt;object classid=&#8221;clsid:d27cdb6e-ae6d-11cf-96b8-444553540000&#8243; codebase=&#8221;http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0&#8243; width=&#8221;690&#8243; height=&#8221;492&#8243; id=&#8221;ImgSwitch&#8221; align=&#8221;middle&#8221;&gt;<br />
&lt;param name=&#8221;movie&#8221; value=&#8221;ImgSwitch.swf&#8221; /&gt;<br />
&lt;param name=&#8221;quality&#8221; value=&#8221;high&#8221; /&gt;<br />
&lt;param name=&#8221;bgcolor&#8221; value=&#8221;#c2b29a&#8221; /&gt;<br />
&lt;param name=&#8221;FlashVars&#8221; value=&#8221;picurl=1.jpg;2.jpg;3.jpg;4.jpg;5.jpg&amp;maxpic=5&amp;modelNo=TestTing&#8221; /&gt;<br />
&lt;embed src=&#8221;ImgSwitch.swf&#8221; quality=&#8221;high&#8221; bgcolor=&#8221;#352B68&#8243; width=&#8221;690&#8243; height=&#8221;492&#8243; name=&#8221;ImgSwitch&#8221; align=&#8221;middle&#8221; allowScriptAccess=&#8221;sameDomain&#8221; type=&#8221;application/x-shockwave-flash&#8221; pluginspage=&#8221;http://www.macromedia.com/go/getflashplayer&#8221;  FlashVars=&#8221;picurl=1.jpg;2.jpg;3.jpg;4.jpg;5.jpg&amp;maxpic=5&amp;modelNo=TestTing&#8221;/&gt;<br />
&lt;/object&gt;</span></em></li>
<li>Change the parameters:<br />
A. Replace &#8220;<strong>picurl</strong>&#8221; paramter with your image url, note that if your images are from www, don&#8217;t forget to quote the images&#8217; URL starting with &#8220;http://&#8221;. And the URL is separated by <strong>semi-colon(;)</strong>.<br />
B. Replace &#8220;<strong>maxpic</strong>&#8221; parameter with the actual images quantity you would like to show. <br />
C. Replace &#8220;<strong>modelNo</strong>&#8221; paramter with the title(name) of this group of images.</li>
</ol>
<p>Done.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.koumei.net/2009/03/15/howto-show-your-images-using-fla-img-sw/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
