<?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>Erhan is typing... &#187; PHP</title> <atom:link href="http://www.erhanabay.com/category/php/feed/" rel="self" type="application/rss+xml" /><link>http://www.erhanabay.com</link> <description>WebDevelopment , PHP, Javascript, CakePHP, ExtJS</description> <lastBuildDate>Wed, 11 Jan 2012 13:04:15 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>WordPress Plugin: Gemius Tracking Code</title><link>http://www.erhanabay.com/2012/01/11/wordpress-plugin-gemius-tracking-code/</link> <comments>http://www.erhanabay.com/2012/01/11/wordpress-plugin-gemius-tracking-code/#comments</comments> <pubDate>Wed, 11 Jan 2012 13:04:15 +0000</pubDate> <dc:creator>Erhan Abay</dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[gemius]]></category> <guid
isPermaLink="false">http://erhanabay.com/?p=547</guid> <description><![CDATA[Integrates Gemius and WordPress by adding Gemius tracking code. Plugin Page: http://wordpress.org/extend/plugins/gemius-plugin/ Development: https://github.com/eabay/wordpress-gemius-plugin Built with OO-Wordpress. Related Posts: Object-Oriented WordPress Plugin Development Bitbucket Repo Sync Application
Related Posts:<ul><li><a
href='http://www.erhanabay.com/2012/01/09/object-oriented-wordpress-plugin-development/' rel='bookmark' title='Object-Oriented WordPress Plugin Development'>Object-Oriented WordPress Plugin Development</a></li><li><a
href='http://www.erhanabay.com/2012/01/06/bitbucket-repo-sync-application/' rel='bookmark' title='Bitbucket Repo Sync Application'>Bitbucket Repo Sync Application</a></li></ul>]]></description> <content:encoded><![CDATA[<blockquote><p>Integrates <a
href="http://www.gemius.com" onclick="pageTracker._trackPageview('/outgoing/www.gemius.com?referer=');">Gemius</a> and <a
href="http://wordpress.org" onclick="pageTracker._trackPageview('/outgoing/wordpress.org?referer=');">WordPress</a> by adding Gemius tracking code.</p></blockquote><p>Plugin Page: <a
href="http://wordpress.org/extend/plugins/gemius-plugin/" onclick="pageTracker._trackPageview('/outgoing/wordpress.org/extend/plugins/gemius-plugin/?referer=');">http://wordpress.org/extend/plugins/gemius-plugin/</a></p><p>Development: <a
href="https://github.com/eabay/wordpress-gemius-plugin" onclick="pageTracker._trackPageview('/outgoing/github.com/eabay/wordpress-gemius-plugin?referer=');">https://github.com/eabay/wordpress-gemius-plugin</a></p><p><strong><em>Built with <a
href="https://github.com/eabay/oo-wordpress" onclick="pageTracker._trackPageview('/outgoing/github.com/eabay/oo-wordpress?referer=');">OO-Wordpress</a>.</em></strong></p><p>Related Posts:<ul><li><a
href='http://www.erhanabay.com/2012/01/09/object-oriented-wordpress-plugin-development/' rel='bookmark' title='Object-Oriented WordPress Plugin Development'>Object-Oriented WordPress Plugin Development</a></li><li><a
href='http://www.erhanabay.com/2012/01/06/bitbucket-repo-sync-application/' rel='bookmark' title='Bitbucket Repo Sync Application'>Bitbucket Repo Sync Application</a></li></ul></p>]]></content:encoded> <wfw:commentRss>http://www.erhanabay.com/2012/01/11/wordpress-plugin-gemius-tracking-code/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Object-Oriented WordPress Plugin Development</title><link>http://www.erhanabay.com/2012/01/09/object-oriented-wordpress-plugin-development/</link> <comments>http://www.erhanabay.com/2012/01/09/object-oriented-wordpress-plugin-development/#comments</comments> <pubDate>Mon, 09 Jan 2012 11:52:49 +0000</pubDate> <dc:creator>Erhan Abay</dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[WordPress]]></category> <guid
isPermaLink="false">http://erhanabay.com/?p=545</guid> <description><![CDATA[I released a new open source library to ease WordPress development, OO-WordPress. Related Posts: WordPress Plugin: Gemius Tracking Code
Related Posts:<ul><li><a
href='http://www.erhanabay.com/2012/01/11/wordpress-plugin-gemius-tracking-code/' rel='bookmark' title='WordPress Plugin: Gemius Tracking Code'>WordPress Plugin: Gemius Tracking Code</a></li></ul>]]></description> <content:encoded><![CDATA[<p>I released a new open source library to ease WordPress development, <a
href="https://github.com/eabay/oo-wordpress" onclick="pageTracker._trackPageview('/outgoing/github.com/eabay/oo-wordpress?referer=');">OO-WordPress</a>.</p><p>Related Posts:<ul><li><a
href='http://www.erhanabay.com/2012/01/11/wordpress-plugin-gemius-tracking-code/' rel='bookmark' title='WordPress Plugin: Gemius Tracking Code'>WordPress Plugin: Gemius Tracking Code</a></li></ul></p>]]></content:encoded> <wfw:commentRss>http://www.erhanabay.com/2012/01/09/object-oriented-wordpress-plugin-development/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Bitbucket Repo Sync Application</title><link>http://www.erhanabay.com/2012/01/06/bitbucket-repo-sync-application/</link> <comments>http://www.erhanabay.com/2012/01/06/bitbucket-repo-sync-application/#comments</comments> <pubDate>Fri, 06 Jan 2012 21:26:10 +0000</pubDate> <dc:creator>Erhan Abay</dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[bitbucket]]></category> <category><![CDATA[git]]></category> <guid
isPermaLink="false">http://erhanabay.com/?p=501</guid> <description><![CDATA[I always shift+delete (or rm -rf) my old project files and keep my workspace &#8220;very&#8221; clean. Let&#8217;s say it&#8217;s a bad habit after working with SVN for several years and relying on server backups. Oh yes, I am not keeping backups of my projects and so comfortable with it! Bitbucket is cool with unlimited private repos but the [...]
Related Posts:<ul><li><a
href='http://www.erhanabay.com/2012/01/11/wordpress-plugin-gemius-tracking-code/' rel='bookmark' title='WordPress Plugin: Gemius Tracking Code'>WordPress Plugin: Gemius Tracking Code</a></li><li><a
href='http://www.erhanabay.com/2012/01/09/object-oriented-wordpress-plugin-development/' rel='bookmark' title='Object-Oriented WordPress Plugin Development'>Object-Oriented WordPress Plugin Development</a></li></ul>]]></description> <content:encoded><![CDATA[<p>I always shift+delete (or rm -rf) my old project files and keep my workspace &#8220;very&#8221; clean. Let&#8217;s say it&#8217;s a bad habit after working with SVN for several years and relying on server backups. Oh yes, I am not keeping backups of my projects and so comfortable with it!</p><p><a
href="http://bitbucket.org/" onclick="pageTracker._trackPageview('/outgoing/bitbucket.org/?referer=');">Bitbucket</a> is cool with unlimited private repos but the <a
href="http://blog.bitbucket.org/2012/01/05/unplanned-downtime-today/" onclick="pageTracker._trackPageview('/outgoing/blog.bitbucket.org/2012/01/05/unplanned-downtime-today/?referer=');">downtime</a> they had yesterday proved that you shouldn&#8217;t rely on it if you don&#8217;t have copies of your repositories on your own disk. I wrote a small console application using <a
href="http://symfony.com/doc/2.0/components/console.html" onclick="pageTracker._trackPageview('/outgoing/symfony.com/doc/2.0/components/console.html?referer=');">symfony console component</a> to sync all repositories of a user by utilizing bitbucket API.</p><p>Basically, you give your bitbucket credentials and it clones all your git repositories.</p><h3>Installation and Usage</h3><pre>git clone git@bitbucket.org:eabay/bitbucket-repo-sync.git
cd bitbucket-repo-sync
php <a href="http://packagist.org/" onclick="pageTracker._trackPageview('/outgoing/packagist.org/?referer=');">composer.phar</a> install
php src/console.php bitbucket:sync <em>username password</em></pre><p>You can choose the path of repositories:</p><pre>php src/console.php bitbucket:sync <em>username password -d /some/where</em></pre><p>To get help about the command:</p><pre>php src/console.php help bitbucket:sync</pre><p>The ironic part is that project is <a
href="https://bitbucket.org/eabay/bitbucket-repo-sync" onclick="pageTracker._trackPageview('/outgoing/bitbucket.org/eabay/bitbucket-repo-sync?referer=');">hosted</a> at bitbucket. I think I should define another remote like github. <img
src='http://www.erhanabay.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p><em><strong>Notice that repositories are cloned over https schema including your username and password. I mean repositories will have origins with uris like https://username:password@bitbucket.org/&#8230;. If this is a security problem for you, don&#8217;t use the application!</strong></em></p><p>Related Posts:<ul><li><a
href='http://www.erhanabay.com/2012/01/11/wordpress-plugin-gemius-tracking-code/' rel='bookmark' title='WordPress Plugin: Gemius Tracking Code'>WordPress Plugin: Gemius Tracking Code</a></li><li><a
href='http://www.erhanabay.com/2012/01/09/object-oriented-wordpress-plugin-development/' rel='bookmark' title='Object-Oriented WordPress Plugin Development'>Object-Oriented WordPress Plugin Development</a></li></ul></p>]]></content:encoded> <wfw:commentRss>http://www.erhanabay.com/2012/01/06/bitbucket-repo-sync-application/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Ext.Direct for CakePHP</title><link>http://www.erhanabay.com/2009/11/28/ext-direct-for-cakephp/</link> <comments>http://www.erhanabay.com/2009/11/28/ext-direct-for-cakephp/#comments</comments> <pubDate>Sat, 28 Nov 2009 02:19:51 +0000</pubDate> <dc:creator>Erhan Abay</dc:creator> <category><![CDATA[CakePHP]]></category> <category><![CDATA[ExtJS]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[MVC]]></category> <category><![CDATA[PHP]]></category> <guid
isPermaLink="false">http://erhanabay.com/?p=385</guid> <description><![CDATA[Finally, I completed the basic implementation of Ext.Direct server-side stack for CakePHP. You can clone a working copy from http://github.com/eabay/directcakephp. It is not that good but it works! http://www.extjs.com/forum/showthread.php?t=86501]]></description> <content:encoded><![CDATA[<p>Finally, I completed the basic implementation of Ext.Direct server-side stack for CakePHP.</p><p>You can clone a working copy from <a
href="http://github.com/eabay/directcakephp" onclick="pageTracker._trackPageview('/outgoing/github.com/eabay/directcakephp?referer=');">http://github.com/eabay/directcakephp</a>.</p><p>It is not that good but it works! <img
src='http://www.erhanabay.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p><a
href="http://www.extjs.com/forum/showthread.php?t=86501" onclick="pageTracker._trackPageview('/outgoing/www.extjs.com/forum/showthread.php?t=86501&amp;referer=');">http://www.extjs.com/forum/showthread.php?t=86501</a></p> ]]></content:encoded> <wfw:commentRss>http://www.erhanabay.com/2009/11/28/ext-direct-for-cakephp/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>CakePHP Helper for rakaz Combine</title><link>http://www.erhanabay.com/2009/11/19/cakephp-helper-for-rakaz-combine/</link> <comments>http://www.erhanabay.com/2009/11/19/cakephp-helper-for-rakaz-combine/#comments</comments> <pubDate>Thu, 19 Nov 2009 20:49:41 +0000</pubDate> <dc:creator>Erhan Abay</dc:creator> <category><![CDATA[CakePHP]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[cakephp helper]]></category> <category><![CDATA[combine]]></category> <category><![CDATA[compress]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[helpers]]></category> <guid
isPermaLink="false">http://erhanabay.com/?p=373</guid> <description><![CDATA[Combine is still my favorite javascript/css combine and compress script. I posted a solution how to use it in a CakePHP application and here is a little helper to make it more useful: Add it to controller&#8217;s helpers property: And call it by passing an array of file names in your view: Don&#8217;t forget to [...]]]></description> <content:encoded><![CDATA[<p>Combine is still my favorite javascript/css combine and compress script.</p><p>I <a
href="http://erhanabay.com/2009/01/29/using-rakaz-combine-with-your-cakephp-application/" onclick="pageTracker._trackPageview('/outgoing/erhanabay.com/2009/01/29/using-rakaz-combine-with-your-cakephp-application/?referer=');">posted</a> a solution how to use it in a CakePHP application and here is a little helper to make it more useful:</p><pre class="brush: php; title: ; notranslate">
&lt;?php
//app/views/helpers/combine.php
class CombineHelper extends AppHelper
{
	public $helpers = array('Html', 'Javascript');
	private $_pattern = '../combine.php?type=:type&amp;files=:files';
	public function js($files)
	{
		echo $this-&gt;Javascript-&gt;link($this-&gt;_format($files));
	}
	public function css($files)
	{
		echo $this-&gt;Html-&gt;css($this-&gt;_format($files, 'css'));
	}
	private function _format($files = array(), $type = 'javascript')
	{
		return String::insert($this-&gt;_pattern, array('type' =&gt; $type, 'files' =&gt; implode(',', $files)));
	}
}
</pre><p>Add it to controller&#8217;s helpers property:</p><pre class="brush: php; title: ; notranslate">
&lt;?php
class MyController extends AppController
{
	public $helpers = array('Combine');
</pre><p>And call it by passing an array of file names in your view:</p><pre class="brush: php; title: ; notranslate">
$combine-&gt;js(array(
    'javascript1.js',
    'javascript2.js',
    'javascript3.js'
));
$combine-&gt;css(array(
    'stylesheet1.css',
    'stylesheet2.css',
    'stylesheet3.css'
));
</pre><blockquote><p>Don&#8217;t forget to add file extensions!</p></blockquote><blockquote><p>If you want to add only one file, you don&#8217;t have to use combine helper. Directives added to .htaccess file let combine script to compress the file(<a
href="http://erhanabay.com/2009/01/29/using-rakaz-combine-with-your-cakephp-application/" onclick="pageTracker._trackPageview('/outgoing/erhanabay.com/2009/01/29/using-rakaz-combine-with-your-cakephp-application/?referer=');">See related post</a>). Just use <em>$javascript->link(&#8216;filename&#8217;)</em>.</p></blockquote> ]]></content:encoded> <wfw:commentRss>http://www.erhanabay.com/2009/11/19/cakephp-helper-for-rakaz-combine/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>PHP: lcfirst</title><link>http://www.erhanabay.com/2009/07/01/php-lcfirst/</link> <comments>http://www.erhanabay.com/2009/07/01/php-lcfirst/#comments</comments> <pubDate>Wed, 01 Jul 2009 20:00:32 +0000</pubDate> <dc:creator>Erhan Abay</dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[PHP 5.3]]></category> <guid
isPermaLink="false">http://erhanabay.com/?p=273</guid> <description><![CDATA[I need to make the first character of the string lowercase. I know ucfirst exists and I supposed that there is a &#8220;lcfirst&#8221; one as well. When I started to type &#8220;lcfirst&#8221;, Zend Studio didn&#8217;t suggest me a function with this name and it was interesting. PHP documentation says that it is available but it [...]]]></description> <content:encoded><![CDATA[<p>I need to make the first character of the string lowercase. I know ucfirst exists and I supposed that there is a &#8220;<a
href="http://us2.php.net/manual/en/function.lcfirst.php" onclick="pageTracker._trackPageview('/outgoing/us2.php.net/manual/en/function.lcfirst.php?referer=');">lcfirst</a>&#8221; one as well.</p><p>When I started to type &#8220;lcfirst&#8221;, Zend Studio didn&#8217;t suggest me a function with this name and it was interesting. PHP documentation says that it is available but it throws an exception. What the hack goes wrong?</p><p>Here is the answer: It was too late and too hard to keep my eyes open <img
src='http://www.erhanabay.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p>lcfirst function is available in <a
href="http://www.php.net/archive/2009.php#id2009-06-30-1" onclick="pageTracker._trackPageview('/outgoing/www.php.net/archive/2009.php_id2009-06-30-1?referer=');">newly released version of PHP, 5.3</a>. I am still using 5.2.9. Here is a code snippet:</p><pre class="brush: php; title: ; notranslate">
if (!function_exists('lcfirst')) {
    function lcfirst($string) {
        return substr_replace($string, strtolower(substr($string, 0, 1)), 0, 1);
    }
}
</pre><p>It is unbelivable that I don&#8217;t ever need the function lcfirst before. <img
src='http://www.erhanabay.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://www.erhanabay.com/2009/07/01/php-lcfirst/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Image Rotator For Your SilverStripe Application</title><link>http://www.erhanabay.com/2009/01/30/image-rotator-for-your-silverstripe-application/</link> <comments>http://www.erhanabay.com/2009/01/30/image-rotator-for-your-silverstripe-application/#comments</comments> <pubDate>Fri, 30 Jan 2009 00:15:43 +0000</pubDate> <dc:creator>Erhan Abay</dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[SilverStripe]]></category> <category><![CDATA[image rotator]]></category> <category><![CDATA[widget]]></category> <guid
isPermaLink="false">http://erhanabay.com/?p=195</guid> <description><![CDATA[I used SilverStripe to develop couple of projects and I really liked it. I am still a fan of CakePHP but you should give a try if you don&#8217;t want to build a new CMS from scratch with CakePHP. I want to show you how easy to add an image rotator to your SilverStripe site [...]]]></description> <content:encoded><![CDATA[<p>I used <a
href="http://www.silverstripe.org" onclick="pageTracker._trackPageview('/outgoing/www.silverstripe.org?referer=');">SilverStripe</a> to develop couple of projects and I really liked it. I am still a fan of <a
href="http://cakephp.org" onclick="pageTracker._trackPageview('/outgoing/cakephp.org?referer=');">CakePHP</a> but you should give a try if you don&#8217;t want to build a new CMS from scratch with CakePHP.</p><p>I want to show you how easy to add an image rotator to your SilverStripe site by using <a
href="http://www.longtailvideo.com/players/jw-image-rotator/" onclick="pageTracker._trackPageview('/outgoing/www.longtailvideo.com/players/jw-image-rotator/?referer=');">JW Image Rotator</a>. You can see it in action at <a
href="http://sumpa.com.tr/" onclick="pageTracker._trackPageview('/outgoing/sumpa.com.tr/?referer=');">sumpa.com.tr</a>.</p><p>First <a
href="http://www.longtailvideo.com/players/jw-image-rotator/" onclick="pageTracker._trackPageview('/outgoing/www.longtailvideo.com/players/jw-image-rotator/?referer=');">download</a> the greatest flash image rotator, JW Image Rotator. Then copy/move it to your SilverStripe project folder. I prefer &#8220;images&#8221; folder.</p><p><img
class="size-full wp-image-198 aligncenter" title="ss01" src="http://erhanabay.com/wp-content/uploads/2009/01/ss01.png" alt="ss01" width="229" height="576" /></p><p>In order to add or remove new images (or swf files) to your rotator easily, we are going to use a folder in our &#8220;Uploads&#8221; directory and list all the files in this folder. Let&#8217;s assume that our directory name is &#8220;flash&#8221;. To do that, go to your admin panel in SilverStripe, switch to &#8220;Files &amp; Images&#8221; tab in your menu and create a new directory called &#8220;flash&#8221;.</p><p><a
href="http://erhanabay.com/wp-content/uploads/2009/01/ss02.png" onclick="pageTracker._trackPageview('/outgoing/erhanabay.com/wp-content/uploads/2009/01/ss02.png?referer=');"><img
class="aligncenter size-full wp-image-199" title="ss02" src="http://erhanabay.com/wp-content/uploads/2009/01/ss02.png" alt="ss02" width="332" height="254" /></a></p><p>In your Page class, define a new method called ImageRotator().</p><pre class="brush: php; title: ; notranslate">
// myproject/code/Page.php
class Page extends SiteTree {
  static $db = array();
  static $has_one = array();
  function ImageRotator() {
    return DataObject::get('File', 'ClassName &lt;&gt; &quot;Folder&quot; AND ParentID = (SELECT ID FROM File WHERE ClassName = &quot;Folder&quot; AND Name = &quot;flash&quot; LIMIT 0,1)');
  }
}
</pre><p>Create a new file &#8220;ImageRotator.ss&#8221; in &#8220;myproject/templates/&#8221;</p><pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;playlist version=&quot;1&quot; xmlns=&quot;http://xspf.org/ns/0/&quot;&gt;
  &lt;trackList&gt;
  &lt;% if ImageRotator %&gt;
    &lt;% control ImageRotator %&gt;
    &lt;track&gt;
      &lt;title&gt;$Title.XML&lt;/title&gt;
      &lt;location&gt;$BaseHref$Filename.XML&lt;/location&gt;
    &lt;/track&gt;
    &lt;% end_if %&gt;
  &lt;% end_control %&gt;
  &lt;/trackList&gt;
&lt;/playlist&gt;
</pre><p> </p><p>Create a new file &#8220;Flash.ss&#8221; in &#8220;myproject/templates/Includes&#8221;</p><pre class="brush: xml; title: ; notranslate">
&lt;!--
Don't change the &quot;file&quot; variable. This is the URI of our XML which contains images
You can change other settings or add/remove.
--&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var introFlashvars = {
  width: &quot;950&quot;,
  height: &quot;300&quot;,
  file: &quot;$URLSegment/ImageRotatorXML&quot;,
  shownavigation: false,
  screencolor: &quot;0xFFFFFF&quot;,
  rotatetime: 15
};
var params = {
  wmode: &quot;transparent&quot;
}
&lt;/script&gt;
&lt;!--
Following div with id &quot;Intro&quot; is used as a container for our image rotator.
Browsers which are not supporting Javascript, &quot;dummyimage.jpg&quot; image linked to the home page is displayed
Don't forget to add swfobject.js into your head tag!
You can download it from http://code.google.com/p/swfobject/
--&gt;
&lt;div id=&quot;Intro&quot;&gt;&lt;a href=&quot;/&quot;&gt;&lt;img src=&quot;dummyimage.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
  swfobject.embedSWF(&quot;$ThemeDir/images/imagerotator.swf&quot;, &quot;Intro&quot;, introFlashvars.width, introFlashvars.height, &quot;8&quot;, false, introFlashvars, params);
&lt;/script&gt;
</pre><p>We complete the steps to create our rotator. Now, you can call it from any page that you want with the following include directive:</p><pre class="brush: xml; title: ; notranslate">
&lt;% include Flash %&gt;
</pre><p>Upload your images and swf files into your &#8220;flash&#8221; directory and open the page by adding &#8220;?flush=1&#8243; to URI. It will refresh the cache.</p><p>I know, it should be a widget so that it can easily be added to the pages without hardcoding. I am not planning to do that kind of work but if you find it useful, convert it to a widget and <a
href="http://www.silverstripe.org/widgets/" onclick="pageTracker._trackPageview('/outgoing/www.silverstripe.org/widgets/?referer=');">share with community</a>. You are free to do that! No license, no restrictions&#8230; <img
src='http://www.erhanabay.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p>Contributions are welcome&#8230;</p> ]]></content:encoded> <wfw:commentRss>http://www.erhanabay.com/2009/01/30/image-rotator-for-your-silverstripe-application/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Using rakaz Combine With Your CakePHP Application</title><link>http://www.erhanabay.com/2009/01/29/using-rakaz-combine-with-your-cakephp-application/</link> <comments>http://www.erhanabay.com/2009/01/29/using-rakaz-combine-with-your-cakephp-application/#comments</comments> <pubDate>Thu, 29 Jan 2009 03:42:13 +0000</pubDate> <dc:creator>Erhan Abay</dc:creator> <category><![CDATA[CakePHP]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[combine]]></category> <category><![CDATA[compress]]></category> <category><![CDATA[CSS]]></category> <guid
isPermaLink="false">http://erhanabay.com/?p=189</guid> <description><![CDATA[Combine is a small PHP script and some clever URL rewriting designed to speed up the loading of pages that use many or large css and javascript files. It is good but how can you integrate it with your CakePHP project? And solution comes with the question . Download a copy of combine.php and drop [...]]]></description> <content:encoded><![CDATA[<blockquote><p><a
href="http://rakaz.nl/extra/code/combine" onclick="pageTracker._trackPageview('/outgoing/rakaz.nl/extra/code/combine?referer=');">Combine</a> is a small PHP script and some clever URL rewriting designed to speed up the loading of pages that use many or large css and javascript files.</p></blockquote><p>It is good but how can you integrate it with your CakePHP project? And solution comes with the question <img
src='http://www.erhanabay.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p><p><a
href="http://rakaz.nl/projects/combine/combine.phps" onclick="pageTracker._trackPageview('/outgoing/rakaz.nl/projects/combine/combine.phps?referer=');">Download</a> a copy of combine.php and drop it into your &#8220;app/webroot&#8221; directory (or whatever your application folder name is XXX/webroot/).</p><p>Open the file in your text editor and change lines:</p><pre class="brush: php; title: ; notranslate">
$cachedir = dirname(__FILE__) . '/cache';
$cssdir   = dirname(__FILE__) . '/css';
$jsdir    = dirname(__FILE__) . '/javascript';
</pre><p>with</p><pre class="brush: php; title: ; notranslate">
$cachedir = dirname(__FILE__) . '/../tmp/cache';
$cssdir   = dirname(__FILE__) . '/css';
$jsdir    = dirname(__FILE__) . '/js';
</pre><p>Open your &#8220;app/webroot/.htaccess&#8221; file and add those two lines</p><pre class="brush: php; title: ; notranslate">
RewriteRule ^css/(.*\.css) combine.php?type=css&amp;files=$1
RewriteRule ^js/(.*\.js) combine.php?type=javascript&amp;files=$1
</pre><p>That&#8217;s all! Check download times of your css and javascript files with a tool like Firebug. A fatty 527KB ext-all.js javascript framework file compressed to 140KB! Amazing ha?</p><p><a
href="http://erhanabay.com/wp-content/uploads/2009/01/combinephp.jpg" onclick="pageTracker._trackPageview('/outgoing/erhanabay.com/wp-content/uploads/2009/01/combinephp.jpg?referer=');"><img
src="http://erhanabay.com/wp-content/uploads/2009/01/combinephp.jpg" alt="rakaz combine" title="rakaz combine" width="865" height="292" class="aligncenter size-full wp-image-190" /></a></p> ]]></content:encoded> <wfw:commentRss>http://www.erhanabay.com/2009/01/29/using-rakaz-combine-with-your-cakephp-application/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>CakePHP RequestHandler Extended</title><link>http://www.erhanabay.com/2009/01/29/cakephp-requesthandler-extended/</link> <comments>http://www.erhanabay.com/2009/01/29/cakephp-requesthandler-extended/#comments</comments> <pubDate>Thu, 29 Jan 2009 03:14:34 +0000</pubDate> <dc:creator>Erhan Abay</dc:creator> <category><![CDATA[CakePHP]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[components]]></category> <category><![CDATA[extending cakephp component]]></category> <guid
isPermaLink="false">http://erhanabay.com/?p=181</guid> <description><![CDATA[A CakePHP component which extends built-in RequestHandler component by adding some useful geolocation information. It requires MaxMind WebService license key to work properly. Save it with the name request_handler_ext.php into your application components directory under controllers. You can call the following methods within your controller (e.g. $this->RequestHandlerExt->methodName()): getClientCountryCode() : ISO 3166 Two-letter Country Code getClientRegionCode() [...]]]></description> <content:encoded><![CDATA[<p>A CakePHP component which extends built-in RequestHandler component by adding some useful geolocation information. It requires MaxMind WebService license key to work properly.</p><p>Save it with the name request_handler_ext.php into your application components directory under controllers.</p><p>You can call the following methods within your controller (e.g. $this->RequestHandlerExt->methodName()):</p><blockquote><p> getClientCountryCode() : ISO 3166 Two-letter Country Code<br
/> getClientRegionCode() : Region Code<br
/> getClientCity() : City<br
/> getClientPostalCode() : Postal Code<br
/> getClientLatitude() : Latitude<br
/> getClientLongitude() : Longitude<br
/> getClientMetropolitanCode() : Metropolitan Code<br
/> getClientMetropolitanCode() : Area Code<br
/> getClientIsp() : ISP<br
/> getClientOrganization() : Organization</p></blockquote><pre class="brush: php; title: ; notranslate">
&lt;?php
/**
 * Extends RequestHandler component by adding some useful geolocation information.
 *
 * Requires MaxMind WebService license key to work properly
 *
 * @copyright     2009 Erhan Abay
 * @package       app
 * @subpackage    app.controllers.components
 * @version       $Revision$
 * @lastmodified  $Date$
 */
App::import('Component', 'RequestHandler');
class RequestHandlerExtComponent extends RequestHandlerComponent
{
	/**
	 * Required to query MaxMind WebService
	 *
	 * Provide your own key by replacing XXXXX.
	 */
	const MM_LICENSE_KEY = 'XXXXXX';
	public function startup(&amp;amp;amp;amp;amp;$controller)
	{
		parent::startup(&amp;amp;amp;amp;amp;$controller);
		$this-&gt;controller =&amp;amp;amp;amp;amp; $controller;
	}
	/**
	 * Searches key value in array returned by function getGeoLocation()
	 *
	 * @param string $name Name of the method
	 * @param unknown_type $arguments Not used, required not to give error
	 * @return string if key found
	 *         null else
	 */
	public function __call($name, $raw = false)
	{
		$var = Inflector::underscore(preg_replace('/getClient/i', '', $name));
		$geo_location = (array)$this-&gt;getGeoLocation($raw);
		return array_key_exists($var, $geo_location) ? $geo_location[$var] : null;
	}
	/**
	 * Queries to the MaxMind WebService and returns an array of information
	 *
	 * @param bool $raw
	 * @return null if IP address is local
	 *         bool false if webservice returns error code
	 *         string if $raw is set true
	 *         array else
	 */
  public function getGeoLocation($raw = false)
  {
  	if ($this-&gt;isLocalIP()) {
  		return null;
  	}
  	if ($this-&gt;controller-&gt;Session-&gt;check('User.GeoLocation')) {
  		return $raw ? $this-&gt;controller-&gt;Session-&gt;read('User.GeoLocation.raw') : $this-&gt;controller-&gt;Session-&gt;read('User.GeoLocation');
  	}
    App::import('HttpSocket');
    $http = new HttpSocket();
    /*
     * Returns in order:
     *
     * 0  ISO 3166 Two-letter Country Code,
     * 1  Region Code,
     * 2  City,
     * 3  Postal Code,
     * 4  Latitude,
     * 5  Longitude,
     * 6  Metropolitan Code,
     * 7  Area Code,
     * 8  ISP,
     * 9  Organization,
     * 10 Error code
     */
    $result = $http-&gt;get('http://geoip1.maxmind.com/f', array(
      'l' =&gt; self::MM_LICENSE_KEY,
      'i' =&gt; $this-&gt;getClientIP()
    ));
    $values = explode(',', $result);
    if (isset($values[10])) {
      return false;
    }
    if ($raw) {
    	return $result;
    }
    $keys = array('country_code', 'region_code', 'city', 'postal_code', 'latitude', 'longitude', 'metropolitan_code', 'area_code', 'isp', 'organization');
    $data = array_combine($keys, $values);
    $data['coords'] = $values[4].','.$values[5];
    $data['raw'] = $result;
    $this-&gt;controller-&gt;Session-&gt;write('User.GeoLocation', $data);
    return $data;
  }
  /**
   * Detects whether IP address is local or not
   *
   * @param string $ip IP address to check
   * @return bool
   */
  public function isLocalIP($ip = null) {
  	$ip = is_null($ip) ? $this-&gt;getClientIP() : $ip;
  	$regex = '/(192\.168\.[0-9]{1,3}\.[0-9]{1,3})';
	$regex .= '|(10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})';
	$regex .= '|(172\.0?([1][6-9])Â¦([2][0-9])Â¦([3][0-1])\.[0-9]{1,3}\.[0-9]{1,3})';
	$regex .= '|(127\.0\.0\.1)/';
  	return (bool)preg_match($regex, $ip);
  }
}
?&gt;
</pre>]]></content:encoded> <wfw:commentRss>http://www.erhanabay.com/2009/01/29/cakephp-requesthandler-extended/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Make CakePHP Email Component Reusable</title><link>http://www.erhanabay.com/2009/01/29/make-cakephp-email-component-reusable/</link> <comments>http://www.erhanabay.com/2009/01/29/make-cakephp-email-component-reusable/#comments</comments> <pubDate>Thu, 29 Jan 2009 02:52:36 +0000</pubDate> <dc:creator>Erhan Abay</dc:creator> <category><![CDATA[CakePHP]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[components]]></category> <category><![CDATA[extending cakephp component]]></category> <guid
isPermaLink="false">http://erhanabay.com/?p=175</guid> <description><![CDATA[I know the title of this post a little bit confusing but let me explain what I want to tell. You are using CakePHP&#8216;s email component and you should set the same information in each time before you send your email like server address, username, password etc. Just create a new file mailer.php with the [...]]]></description> <content:encoded><![CDATA[<p>I know the title of this post a little bit confusing but let me explain what I want to tell.</p><p>You are using <a
href="http://cakephp.org" onclick="pageTracker._trackPageview('/outgoing/cakephp.org?referer=');">CakePHP</a>&#8216;s email component and you should set the same information in each time before you send your email like server address, username, password etc.</p><p>Just create a new file mailer.php with the following content and drop it into your CakePHP application components folder (I like convention over configuration! <img
src='http://www.erhanabay.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ).</p><pre class="brush: php; title: ; notranslate">
&lt;?php
App::import('Component', 'Email');
class MailerComponent extends EmailComponent
{
  var $from = 'ME &lt;me@localhost&gt;';
  var $replyTo = 'noreply@localhost';
  var $sendAs = 'both';
  var $delivery = 'smtp';
  var $xMailer = 'Postman';
  var $smtpOptions = array(
    'port'=&gt; 25,
    'host' =&gt; 'serveradress',
    'timeout' =&gt; 30,
    'username' =&gt; 'username',
    'password' =&gt; 'password'
  );
}
?&gt;
</pre><p>And right now you have a new component with the name &#8220;Mailer&#8221; and its server configuration is predefined. You can reuse it without being affected by any kind of mail server change.</p><p>You can define a new function inside your controller (_sendEmail() in our case) and make the email sending process more painless.</p><pre class="brush: php; title: ; notranslate">
class AnyController extends AppController
{
  function contact()
  {
    if ($this-&gt;_sendEmail('Name', 'blabla@fakeemail', 'Grate site!')) {
      $this-&gt;Session-&gt;setFlash(__(&quot;Thank you&quot;, true));
    } else {
      $this-&gt;Session-&gt;setFlash('Damn it!');
    }
  }
  function _sendEmail($name, $email, $message)
  {
    $this-&gt;Mailer-&gt;to = 'info@localhost';
    $this-&gt;Mailer-&gt;subject = __(&quot;Site Contact&quot;, true);
    $this-&gt;Mailer-&gt;template = 'contact';
    $this-&gt;set('name', $name);
    $this-&gt;set('email', $email);
    $this-&gt;set('message', $message);
    $this-&gt;Mailer-&gt;send();
    $this-&gt;log( $this-&gt;Mailer-&gt;subject . ' -&gt; Name:'. $name .' | E-posta: '. $email .' | Message: '. $message .' | smtp error: '. serialize($this-&gt;Mailer-&gt;smtpError) );
    return $this-&gt;Mailer-&gt;smtpError ? false : true;
  }
}
</pre><p>That&#8217;s all! Check <a
href="http://bakery.cakephp.org/" onclick="pageTracker._trackPageview('/outgoing/bakery.cakephp.org/?referer=');">Bakery</a> for other cakes <img
src='http://www.erhanabay.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://www.erhanabay.com/2009/01/29/make-cakephp-email-component-reusable/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> </channel> </rss>
