<?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>.:: Kohaci Site ::. &#187; Open Source</title>
	<atom:link href="http://kohaci.com/topik/open-source/feed" rel="self" type="application/rss+xml" />
	<link>http://kohaci.com</link>
	<description></description>
	<lastBuildDate>Sat, 09 Jul 2011 12:06:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Template Engine Sederhana</title>
		<link>http://kohaci.com/2011/03/08/template-engine-sederhana.html</link>
		<comments>http://kohaci.com/2011/03/08/template-engine-sederhana.html#comments</comments>
		<pubDate>Tue, 08 Mar 2011 01:50:52 +0000</pubDate>
		<dc:creator>kohaci</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming-Q]]></category>
		<category><![CDATA[Project-Q]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[template engine]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://kohaci.com/?p=307</guid>
		<description><![CDATA[Beberapa waktu lalu, sempat terpikir oleh gw, untuk sistem (web) yang sederhana (dari segi fitur) __ yang mungkin __ terlalu boros jika dibikin pakai framework ataupun berorientasi objek sehingga dibuat alurnya prosedural saja, tapi strukturnya masih rapi, minimal ada pemisahan kode php dengan template. Tidak perlu memakai template engine yang sudah komplek seperti Smarty atau [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_453" class="wp-caption alignleft" style="width: 160px"><img class="size-thumbnail wp-image-453" title=".php" src="https://lh6.googleusercontent.com/_IL56WrTPeME/TXWFXFRo7eI/AAAAAAAAEes/ejl0F9_xckc/s144/php-logo1.jpg" alt=".php" width="150" /><p class="wp-caption-text">.php</p></div>
<p style="text-align: justify;">Beberapa waktu lalu, sempat terpikir oleh gw, untuk sistem (web) yang sederhana (dari segi fitur) __ yang mungkin __ terlalu boros jika dibikin pakai framework ataupun berorientasi objek sehingga dibuat alurnya prosedural saja, tapi strukturnya masih rapi, minimal ada pemisahan kode php dengan template. Tidak perlu memakai template engine yang sudah komplek seperti Smarty atau  yang lainnya, karena ya itu terlalu boros (dilihat ukuran size aplikasinya).</p>
<p><span id="more-307"></span></p>
<p style="text-align: justify;">So iseng-iseng gw coba bikin.</p>
<p style="text-align: justify;">Jadi strukturnya kira-kira seperti ini :</p>
<p><center>
<dl id="attachment_451" class="wp-caption aligncenter" style="width: 205px;">
<dt class="wp-caption-dt"><a href="http://localhost/kohaci/wp-content/uploads/2011/03/struktur.jpg"><img class="size-full wp-image-451" title="Struktur sederhana" src="https://lh5.googleusercontent.com/_IL56WrTPeME/TXWFYMXXnGI/AAAAAAAAEeY/MpTQqHCYcQI/s800/struktur.jpg" alt="Struktur sederhana" width="195" height="112" /></a></dt>
<dd class="wp-caption-dd">Struktur sederhana</dd>
</dl>
<p></center></p>
<p style="text-align: justify;">
<p style="text-align: justify;">Strukturnya mungkin seperti CodeIgniter (karena inspirasinya di sana), <strong>simple.templating.php</strong> adalah librari-nya, <strong>welcome_view.php</strong> adalah contoh file templatenya (HTML/web page) , dan file <strong>welcome.php </strong>yang terletak di luar folder <strong>lib</strong> dan <strong>views</strong> adalah contoh &#8220;controller&#8221;nya.</p>
<p style="text-align: justify;">simple.templating.php</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'EXT'</span>        <span style="color: #339933;">,</span> <span style="color: #0000ff;">'.php'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'VIEWPATH'</span>   <span style="color: #339933;">,</span> <span style="color: #0000ff;">'views/'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Load View
 *
 * @access	public
 * @param	string $file file location (no extension (.php))
 * @param	string $data array nor not
 * @param	mixed  $string print results (FALSE) or save results to string (TRUE)
 * @return	string
 */</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> load_view<span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span><span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span><span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</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: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// this is like &quot;value to variable&quot;, see my artcle on http://kohaci.com/2010/03/24/value-to-variable.html</span>
        <span style="color: #666666; font-style: italic;">// check more on http://php.net/manual/en/function.extract.php</span>
        <span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">include</span> <span style="color: #009900;">&#40;</span> VIEWPATH <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">.</span> EXT <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ob_get_clean</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span>    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span> <span style="color: #339933;">;</span>
    <span style="color: #b1b100;">else</span>            <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$content</span> <span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* End of file simple.templating.php */</span>
<span style="color: #666666; font-style: italic;">/* Location: ./lib/simple.templating.php */</span></pre></td></tr></table></div>

<p style="text-align: justify;">Jika di CodeIgniter, untuk me-load view dijalankan seperti ini :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$WEB_PAGE</span><span style="color: #339933;">,</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span></pre></div></div>

<p style="text-align: justify;">Maka di <strong>simple template engine</strong> kali ini jalannya :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">load_view<span style="color: #009900;">&#40;</span><span style="color: #000088;">$WEB_PAGE</span><span style="color: #339933;">,</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span></pre></div></div>

<p style="text-align: justify;">Ataupun hasil templating disimpan dulu ke variable, di CodeIgniter :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$WEB_PAGE</span><span style="color: #339933;">,</span><span style="color: #000088;">$data</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span></pre></div></div>

<p style="text-align: justify;">Di simple template engine :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> load_view<span style="color: #009900;">&#40;</span><span style="color: #000088;">$WEB_PAGE</span><span style="color: #339933;">,</span><span style="color: #000088;">$data</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span></pre></div></div>

<p style="text-align: justify;">Contoh view di welcome_view.php</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
        &lt;title&gt;&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$welcome</span> <span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p style="text-align: justify;">Contoh &#8220;controller&#8221;nya di welcome.php</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">'lib/simple.templating.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'welcome'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;halo ...&quot;</span> <span style="color: #339933;">;</span>
&nbsp;
load_view<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'welcome_view'</span><span style="color: #339933;">,</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* End of file welcome.php */</span>
<span style="color: #666666; font-style: italic;">/* Location: ./welcome.php */</span></pre></td></tr></table></div>

<p style="text-align: justify;">Download kode di atas <a title="download here!" href="https://github.com/kohaci/Simple-Template-Engine" target="_blank">di sini</a>.</p>
<p style="text-align: justify;">Semoga bermanfaat.</p>
]]></content:encoded>
			<wfw:commentRss>http://kohaci.com/2011/03/08/template-engine-sederhana.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome To My PC, BlankOn</title>
		<link>http://kohaci.com/2008/12/21/welcome-to-my-pc-blankon.html</link>
		<comments>http://kohaci.com/2008/12/21/welcome-to-my-pc-blankon.html#comments</comments>
		<pubDate>Sun, 21 Dec 2008 13:26:24 +0000</pubDate>
		<dc:creator>kohaci</dc:creator>
				<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://kohaci.com/?p=137</guid>
		<description><![CDATA[Akhirnya, setelah hampir setahun menggunakan Ubuntu 7.04 (Feisty Fawn) akhirnya gw migrasi ke BlankOn 4.0 dengan kode nama Meuligoe yang merupakan turunan Ubuntu 8.10. Tidak ada alasan khusus untuk migrasi, hanya ingin mencoba sesuatu yang baru plus mencoba fitur multi tab di nautilus Persiapan migrasi ini sudah lama, dimulai mengunduh Ubuntu 8.10 pas di hari [...]]]></description>
			<content:encoded><![CDATA[<div class="wp-caption aligncenter" style="width: 410px"><a href="http://picasaweb.google.com/lh/photo/BY6V0xZPRX74KlW8U5Rljw?feat=embedwebsite"><img title="My Dekstop" src="http://lh3.ggpht.com/_IL56WrTPeME/SU5BV601bQI/AAAAAAAACK8/e99xuSHWllc/s400/desktop.jpg" alt="BlankOn 4.0 (Meuligoe) di PC gw" width="400" height="320" /></a><p class="wp-caption-text">BlankOn 4.0 (Meuligoe) di PC gw</p></div>
<p style="text-align: justify;">Akhirnya, setelah hampir setahun menggunakan Ubuntu 7.04 (Feisty Fawn) akhirnya gw migrasi ke <a href="http://blankonlinux.or.id/download.html">BlankOn 4.0</a> dengan kode nama Meuligoe yang merupakan turunan <a href="http://www.ubuntu.com/getubuntu/download">Ubuntu 8.10</a>. Tidak ada alasan khusus untuk migrasi, hanya ingin mencoba sesuatu yang baru plus mencoba fitur multi tab di nautilus <img src='http://kohaci.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <span id="more-137"></span>Persiapan migrasi ini sudah lama, dimulai mengunduh <a href="http://www.ubuntu.com/getubuntu/download">Ubuntu 8.10</a> pas di hari pertama rilis .. tapi tidak langsung instal karena masih menunggu DVD repositorinya, kemudian unduh <a href="http://blankonlinux.or.id/download.html">BlankOn 4.0</a> sejak dua hari setelah rilis. Kemudian memesan DVD repositorinya di <a href="http://juragan.kambing.ui.edu/">Juragan Kambing</a>.</p>
<p style="text-align: justify;">Banyak pengorbanan yang gw lakukan dan umumnya karena keteledoran sendiri, salah satunya lupa mem<em>backup</em> data yang akibatnya hilang saat diformat, waktu direcoverinya juga ga bisa keambil datanya <img src='http://kohaci.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  . Tapi biarin aja dech, yang penting bukan gw-nya yang diformat <img src='http://kohaci.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p style="text-align: justify;">So, Welcome to My PC, BlankOn !</p>
]]></content:encoded>
			<wfw:commentRss>http://kohaci.com/2008/12/21/welcome-to-my-pc-blankon.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

