<?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>cakealot &#187; admin</title>
	<atom:link href="http://cakealot.com/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakealot.com</link>
	<description>CakePHP &#38; Stuff</description>
	<lastBuildDate>Thu, 08 Dec 2011 13:46:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>TwigView &#8211; The CakePHP 2.x way</title>
		<link>http://cakealot.com/2011/12/twigview-the-cakephp-2-x-way/</link>
		<comments>http://cakealot.com/2011/12/twigview-the-cakephp-2-x-way/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 13:38:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[twig]]></category>

		<guid isPermaLink="false">http://cakealot.com/?p=102</guid>
		<description><![CDATA[Graham Weldon (aka Predominant) recently cloned my TwigView repository on GitHub and changed it to be fully 2.x compliant. One important note on his work is that the changes break 1.x support on purpose. So if you are on CakePHP 2.x looking for a Twig plugin, feel free to head over to his repository for [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://grahamweldon.com" title="Homepage">Graham Weldon</a> (aka Predominant) recently cloned my <strong>TwigView</strong> repository on GitHub and <a title="Original blogpost by Graham Weldon"  href="http://grahamweldon.com/posts/view/twigview-plugin-for-cakephp-2-0">changed it to be fully 2.x compliant</a>. One important note on his work is that <strong>the changes break 1.x support on purpose</strong>. So if you are on CakePHP 2.x looking for a <a href="http://twig.sensiolabs.org" title="Homepage">Twig</a> plugin, feel free to head over to <a href="https://github.com/predominant/TwigView">his repository</a> for now / from now on. It has all the goodies of mine, but is designed for 2.x.</p>
<p>I plan to keep <a href="https://github.com/m3nt0r/cakephp-twig-view">my repo</a> compatible to 1.x for now so don&#8217;t worry. I will keep an eye on Grahams port and try to incorporate any additions he may add in the future. I really liked the way he <a href="https://github.com/predominant/TwigView/commit/cd43404b89c728009fbfb72b82113c4fb4cab880">reuses debug values to adjust the core settings</a> for example. Good stuff! When i have the time to work on the plugin again i will merge the two somehow (as a branch or something).</p>
<p>Enjoy!</p>
<p><strong>TL;DR</strong></p>
<ul>
<li>TwigView for CakePHP 1.x/2.x-dev &bull; <a href="https://github.com/m3nt0r/cakephp-twig-view" rel="me">https://github.com/m3nt0r/cakephp-twig-view</a></li>
<li>TwigView for CakePHP 2.x only &bull; <a href="https://github.com/predominant/TwigView">https://github.com/predominant/TwigView</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://cakealot.com/2011/12/twigview-the-cakephp-2-x-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>QuickTip: Environment &amp; Database.php</title>
		<link>http://cakealot.com/2011/05/environment-database-php/</link>
		<comments>http://cakealot.com/2011/05/environment-database-php/#comments</comments>
		<pubDate>Sat, 21 May 2011 07:14:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Quicktips]]></category>
		<category><![CDATA[bootstrap]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[environment]]></category>
		<category><![CDATA[example]]></category>

		<guid isPermaLink="false">http://www.cakealot.com/?p=83</guid>
		<description><![CDATA[In this post i am going to explain how to use the Environment library from Rafael Bandeira to automatically configure your Database connection based on the environment your app is running. Environment looks at the SERVER_NAME (or configurable conditions) and gives it a name and applies a defined set of core options. The method i [...]]]></description>
			<content:encoded><![CDATA[<p>In this post i am going to explain how to use the <a href="https://github.com/m3nt0r/cakephp-env-example/blob/master/vendors/environment.php">Environment library from Rafael Bandeira</a> to automatically configure your Database connection based on the environment your app is running.</p>
<p><span id="more-83"></span></p>
<p>Environment looks at the <code>SERVER_NAME</code> (or configurable conditions) and gives it a name and applies a defined set of core options. The method i am explaining uses this info to choose which database config to load, by adding some magic into <code>Database::__construct</code>.</p>
<p>A good practice is to create a file in <code>config</code> with all your environment configs.</p>
<pre class="prettyprint lang-php"><code>// environments.php
App::import('Vendor', 'Environment');
// config
Environment::configure('development',
  array(
    'server' =&gt; 'localhost' //&lt; if SERVER_NAME == 'localhost'
   ),
   array(
     'debug' =&gt; 2 //&gt; Configure::write('debug', 2)
   )
);
Environment::configure('staging',
  array(
    'server' =&gt; 'dev.myapp.com' //&lt; if SERVER_NAME == 'dev.myapp.com'
  ),
  array(
    'debug' =&gt; 1 //&gt; Configure::write('debug', 1)
  )
);
Environment::configure('production',
  true, //&lt; any other host is production
  array(
     'debug' =&gt; 0 //&gt; Configure::write('debug', 0)
  )
);
// run
Environment::start();
</code></pre>
<p>To use this file when starting the app (visiting it in your browser) add it to the <code>config/bootstrap.php</code></p>
<pre class="prettyprint lang-php"><code>config('environments');
</code></pre>
<p>Now to the final part. The <code>config/database.php</code></p>
<pre class="prettyprint lang-php"><code>// database.php
class DATABASE_CONFIG {

  // This is the default, generate by bake

  var $default = array(
    'driver' =&gt; 'mysql',
    'persistent' =&gt; false,
    'host' =&gt; 'localhost',
    'login' =&gt; 'root',
    'password' =&gt; '',
    'database' =&gt; 'test',
    'encoding' =&gt; 'utf8'
  );

  // Add properties for each of our environments

  var $development = array(
    'login' =&gt; 'dev',
    'password' =&gt; 'dev-pw',
    'database' =&gt; 'myapp_development',
  );

  var $staging = array(
    'login' =&gt; 'staging',
    'password' =&gt; 'staging-pw',
    'database' =&gt; 'myapp_staging',
  );

  var $production = array(
    'login' =&gt; 'live',
    'password' =&gt; 'live-pw',
    'database' =&gt; 'myapp_live',
  );

  // Then add a __construct to this class to run some code when cake loads it

  function __construct() {

    // once Environment has decided where we at, it will write the name into Configure.
    if ($environment = Configure::read('Environment.name')) {

      // now i am gonna test if theres a property of the same name
      if (isset($this-&gt;{$environment})) {

        // if so, i then merge any options into $default.
        $this-&gt;default = array_merge($this-&gt;default, $this-&gt;{$environment});
      }
    }

    // if everything above went smooth, $this-&gt;default now has the correct login info.
    // Since we are using $default i dont need to change anything else in my app.
  }
}
</code></pre>
<p>Pretty neat, eh? If you want to check it out i&#8217;ve create a <a href="https://github.com/m3nt0r/cakephp-env-example">repo on GitHub</a> where you can download/fork a working 1.3 example.</p>
<p><a href="https://github.com/m3nt0r/cakephp-env-example">https://github.com/m3nt0r/cakephp-env-example</a></p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakealot.com/2011/05/environment-database-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twig for CakePHP: Updates</title>
		<link>http://cakealot.com/2011/05/twig-for-cakephp-updates/</link>
		<comments>http://cakealot.com/2011/05/twig-for-cakephp-updates/#comments</comments>
		<pubDate>Sat, 07 May 2011 03:22:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[ctp]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[twig]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://www.cakealot.com/?p=65</guid>
		<description><![CDATA[New features have been added to TwigView just recently. New filters, Better readme, Access to view object and experimental CakePHP 2.0-dev support. CakePHP 2.x Support This one is experimental. Using changes made by BigClick in his fork i&#8217;ve remodeled the methods to act as proxy and detect if 2.x is being used. So this feature [...]]]></description>
			<content:encoded><![CDATA[<p>New features have been added to TwigView just recently. New filters, Better readme, Access to view object and experimental CakePHP 2.0-dev support.</p>
<p><span id="more-65"></span></p>
<h3>CakePHP 2.x Support</h3>
<p>This one is experimental. Using changes made by BigClick in <a href="https://github.com/bigclick/cakephp-twig-view">his fork</a> i&#8217;ve remodeled the methods to act as proxy and detect if 2.x is being used. So this feature is completely transparent and the plugin will work in 1.2+, 1.3x and 2.0-dev without any changes required. At least in my quick tests it did ;) Enjoy.</p>
<h3>View Object</h3>
<p>You can now access the view object within a template</p>
<pre><code>{{ _view.action }}   //=&gt; 'display'</code></pre>
<h3>Two new filter sets</h3>
<p>&#8216;basic&#8217; und &#8216;number&#8217; and as the name suggest are shortcuts to the NumberHelper (me) and basic.php (Hiroshi Hoaki)</p>
<p>Display the debug (pre+print_r) output</p>
<pre><code>{{ user|debug }}</code></pre>
<p>Display just the print_r output</p>
<pre><code>{{ user|pr }}</code></pre>
<p>Display the value from a environment variable</p>
<pre><code>{{ 'HTTP_HOST'|env }}</code></pre>
<p>Convert byte integer to a humand readable size</p>
<pre><code>{{ '3535839525'|size }}    //=&gt; 3.29 GB</code></pre>
<p>Formats a number with a level of precision.</p>
<pre><code>{{ '0.555'|p(2) }}    //=&gt; 0.56</code></pre>
<p>Display floating point value as currency value. USD, GBP and EUR only</p>
<pre><code>{{ '5999'|curr }}         // default, $5,999.00
{{ '5999'|curr('GBP') }}  // £5,999.00
{{ '5999'|curr('EUR') }}  // €5.999,00 </code></pre>
<p>Formats a number into a percentage string.</p>
<pre><code>{{ '2.3'|pct }}    //=&gt; 2.30%</code></pre>
<h3>Fancy Readme</h3>
<p>I&#8217;ve added a decent readme with install and usage instructions.</p>
<p><a href="https://github.com/m3nt0r/cakephp-twig-view">https://github.com/m3nt0r/cakephp-twig-view</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cakealot.com/2011/05/twig-for-cakephp-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cakealot is back!</title>
		<link>http://cakealot.com/2011/05/hello-world-2/</link>
		<comments>http://cakealot.com/2011/05/hello-world-2/#comments</comments>
		<pubDate>Fri, 06 May 2011 20:18:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.cakealot.com/?p=1</guid>
		<description><![CDATA[It&#8217;s me again :) Due to a chain of unfortunate events the entire blog went down and i had to find a new host, dns and all that stuff. Also lost all my old posts in the process. :/ But i&#8217;m gonna try to restore them asap and start posting again.]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s me again :)</p>
<p>Due to a chain of unfortunate events the entire blog went down and i had to find a new host, dns and all that stuff. Also lost all my old posts in the process. :/</p>
<p>But i&#8217;m gonna try to restore them asap and start posting again.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakealot.com/2011/05/hello-world-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twig Templates in CakePHP (cont.)</title>
		<link>http://cakealot.com/2010/09/twig-templates-in-cakephp-continued/</link>
		<comments>http://cakealot.com/2010/09/twig-templates-in-cakephp-continued/#comments</comments>
		<pubDate>Fri, 24 Sep 2010 15:33:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[ctp]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[twig]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://www.cakealot.com/?p=9</guid>
		<description><![CDATA[The TwigView got it’s own repository shortly after the initial gist. I am using the same TwigView for a few days now and i am not missing anything so far. Everything runs smoothly and i really enjoy working with Twig. At first it was awkward.. How to write loops, etc. Had to refer to the [...]]]></description>
			<content:encoded><![CDATA[<p>The TwigView got it’s own repository shortly after the initial <em>gist</em>. I am using the same <a href="http://github.com/m3nt0r/cakephp-twig-view">TwigView</a> for a few days now and i am not missing anything so far. Everything runs smoothly and i really enjoy working with Twig.</p>
<p><span id="more-9"></span></p>
<p>At first it was awkward.. How to write loops, etc. Had to refer to the  manual alot. But with all new technology you just need some time to get  used to it. I wasn’t turned off cause views simply started to looked  alot nicer than they usually do. All the variable, method calling crap  is out of the way. Helps alot when building nicely structured XHTML.</p>
<p>Custom helpers, loops, conditions and elements work. I am also using it  for different output formats like JSON and even emails. For emails i was  really happy about a working <code>{% trans %}</code> block implementation (everything in between is passed to i18n).</p>
<pre><code>{% trans %}
   Hello {{ username }}!

   This is my mail body and i can translate it in X languages now.
   We love it ... {{ someotherVar }}
{% endtrans %}</code></pre>
<p>I think the most interesting aspect with custom view renderers is how you work with helpers. I decided to drop <code>$this-&gt;</code> for readability sake. I never had problems with collisions in my apps,  so why bother. You can access all helpers like you could pre-1.3.</p>
<pre class="prettyprint lang-php"><code>{{ time.nice(user.created) }}</code></pre>
<p>What you also can do is using the “helpers” that twig offers. There are some handy filters. Here’s a example with “date”</p>
<pre class="prettyprint lang-php"><code>{{ user.created|date("m/d/Y") }}</code></pre>
<p>My favorite is the “trans” filter. It will pass the value to <code>__('', true)</code>. Such a time saver..</p>
<pre class="prettyprint lang-php"><code>{{
 form.input('message', [
   'label': 'Your message'| trans,
   'error': [
     'notempty': 'Please enter a message'| trans
   ]
 ])
}}</code></pre>
<p>These are just some examples, but the format will stay. Here’s a final example using a custom helper and a cake array.</p>
<pre class="prettyprint lang-php"><code>{{
   gravatar.image(post.User.email, [
     'size': '30',
     'default': 'identicon'
   ])
 }}</code></pre>
<p>As you can see, there is hardly anything you can’t do with the  current implementation. Well.. except for one thing: embeded PHP. But  who would want that with Twig, right?</p>
<p><strong>The SQL Dump:</strong></p>
<p>The original sql-dump element is 80% php code and that’s not very  “twig”. Logic like that should be either in a helper, controller or  model. But i don’t wanna discuss practices here. I guess for what it  does it works. You prolly could write the <code>sql_dump.ctp</code> in twig somehow.. i was too scared. ;) For the said sql-dump i installed DebugKit which renders the log just as good.<br />
<strong></strong></p>
<p><strong>About elements</strong></p>
<p>What i forgot to mention was the <code>element()</code> command. I’ve implemented it as twig tag.</p>
<pre class="prettyprint lang-php"><code>{% element 'some/element' %}</code></pre>
<p><strong>Bottom Line</strong></p>
<p>Twig is fun to write views with. There’s a TextMate bundle available and a good documentation over at <a href="http://twig-project.org/" target="_blank">twig-project.org</a>. Couple that with ZenCoding and writing views is so much faster =)</p>
<p>Extending is fun too! I’ve started to add some filters that route to  cakephp helpers. The first one was “timeAgoInWords”. Shortened down to <code>user.created|ago</code>.  Other possible candidates are the NumberHelper and most of the  TimeHelper…. well. sky’s the limit and nothing stops you from using the  default interface that i described above.</p>
<p>I think Twig and Cake is a powerful combination. And i haven’t even talked about Twigs own filter arsenal.<br />
You can <a href="http://github.com/m3nt0r/cakephp-twig-view">get the Plugin at GitHub</a>. Feel free to play around with it. See the “examples” directory for all default layouts.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakealot.com/2010/09/twig-templates-in-cakephp-continued/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Twig with CakePHP</title>
		<link>http://cakealot.com/2010/09/using-twig-with-cakephp/</link>
		<comments>http://cakealot.com/2010/09/using-twig-with-cakephp/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 20:47:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Kitchen]]></category>
		<category><![CDATA[ctp]]></category>
		<category><![CDATA[gist]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[twig]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://www.cakealot.com/?p=15</guid>
		<description><![CDATA[Having fun with Twig right now. Here’s a draft View implementation with i18n support. Just a gist, but works very well for me. For those who don’t know what Twig is: - Twig is a template language. - http://www.twig-project.org The good old default.ctp in Twig &#60;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> &#60;html> &#60;head> {{ html.charset() [...]]]></description>
			<content:encoded><![CDATA[<p>Having fun with <a href="http://www.twig-project.org/" target="_blank">Twig</a> right now. Here’s a draft View implementation with i18n support. Just a gist, but works very well for me.</p>
<p>For those who don’t know what Twig is:<br />
- Twig is a template language.<br />
- <a href="http://www.twig-project.org/" target="_blank">http://www.twig-project.org</a><span id="more-15"></span></p>
<h3>The good old <code>default.ctp</code> in Twig</h3>
<pre class="prettyprint lang-php"><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
&lt;html>
  &lt;head>
	{{ html.charset() }}
	&lt;title>{{ 'CakePHP: the rapid development php framework'|trans }}: {{ title_for_layout }}&lt;/title>
	{{ html.meta('icon') }}
	{{ html.css('cake.generic') }}
	{{ scripts_for_layout }}
  &lt;/head>
  &lt;body>
	&lt;div id="container">
		&lt;div id="header">
			&lt;h1>{{
				html.link('CakePHP: the rapid development php framework'|trans, 'http://cakephp.org')
			}}&lt;/h1>
		&lt;/div>
		&lt;div id="content">
			{{ session.flash() }}{{ session.flash('auth') }}
			{{ content_for_layout }}
		&lt;/div>
		&lt;div id="footer">
		{{
			html.image('cake.power.gif', [
				'alt': 'Powered by CakePHP'|trans,
				'url': 'http://cakephp.org'
			])
		}}
		&lt;/div>
	&lt;/div>
  &lt;/body>
&lt;/html></code></pre>
<h3>Here’s my <code>TwigView</code> class</h3>
<pre><code>==UPDATED==
It's a repo now:
 > http://github.com/m3nt0r/cakephp-twig-view</code></pre>
<p>There are also more examples and examples using <strong>FormHelper</strong> at github.</p>
<p>View the full gist: <a href="http://gist.github.com/589273">http://gist.github.com/589273</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cakealot.com/2010/09/using-twig-with-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jailson! Access Control for CakePHP</title>
		<link>http://cakealot.com/2010/09/jailson-access-control-for-cakephp/</link>
		<comments>http://cakealot.com/2010/09/jailson-access-control-for-cakephp/#comments</comments>
		<pubDate>Sun, 19 Sep 2010 20:55:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[acl]]></category>
		<category><![CDATA[auth]]></category>
		<category><![CDATA[jailson]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.cakealot.com/?p=18</guid>
		<description><![CDATA[I&#8217;ve written a access control plugin for CakePHP dubbed Jailson. It is completly transparent and auto integrates with Auth if present. Some examples from the README, because code says more than a thousand words.. =) // simple in and out $this-&#62;User-&#62;lockAs('client'); $this-&#62;User-&#62;release('client'); // related to another model $this-&#62;User-&#62;lockAs('admin_of', $this-&#62;Project); // testing $this-&#62;User-&#62;is('admin_of', $this-&#62;Project); // true [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve written a access control plugin for CakePHP dubbed <strong>Jailson</strong>. It is completly transparent and auto integrates with Auth if present.</p>
<p><span id="more-18"></span></p>
<p>Some examples from the README, because code says more than a thousand words.. =)</p>
<p>// simple in and out</p>
<pre class="prettyprint lang-php"><code>$this-&gt;User-&gt;lockAs('client');
$this-&gt;User-&gt;release('client');</code></pre>
<p>// related to another model</p>
<pre class="prettyprint lang-php"><code>$this-&gt;User-&gt;lockAs('admin_of', $this-&gt;Project);</code></pre>
<p>// testing</p>
<pre class="prettyprint lang-php"><code>$this-&gt;User-&gt;is('admin_of', $this-&gt;Project); // true
$this-&gt;User-&gt;isNot('admin_of', $this-&gt;Project); // false</code></pre>
<p>// array support</p>
<pre class="prettyprint lang-php"><code>$this-&gt;User-&gt;lockAs(array('admin', 'member', 'reporter'), $this-&gt;Project);</code></pre>
<p>// and-testing</p>
<pre class="prettyprint lang-php"><code>$this-&gt;User-&gt;is(array('member', 'reporter'), $this-&gt;Project); // true
$this-&gt;User-&gt;is(array('member', 'reporter', 'watcher'), $this-&gt;Project); // false
$this-&gt;User-&gt;is(array('member', 'reporter', 'admin'), $this-&gt;Project); // true</code></pre>
<p>// clear everything</p>
<pre class="prettyprint lang-php"><code>$this-&gt;User-&gt;free();</code></pre>
<p>// commit a test</p>
<pre class="prettyprint lang-php"><code>$this-&gt;User-&gt;is('watcher_of', $this-&gt;Project, true); // where 'true' means: Create
$this-&gt;User-&gt;isNot('watcher_of', $this-&gt;Project, true); // where 'true' means: Delete</code></pre>
<p>That was the simple interface to setup roles.</p>
<p>Here is how it integrates Auth.</p>
<pre class="prettyprint lang-php"><code>public $components = array(
  'Jailson.AclAuth' =&gt; array(
    'deny' =&gt; array('*'),
    'allow' =&gt; array(
       'index' =&gt; array('member'),
       'view' =&gt; array('member')
       'add' =&gt; array('admin')
       'edit' =&gt; array('admin')
    )
  )
);</code></pre>
<p>You can even do this on <code>AppController</code> level. The Allow/Deny rules will inherit if the actions match. For more information have a look at the README.</p>
<p><a href="http://github.com/m3nt0r/cakephp-jailson">http://github.com/m3nt0r/cakephp-jailson</a></p>
<p>Open for suggestions.<br />
Leave a comment or two.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakealot.com/2010/09/jailson-access-control-for-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>QuickTip: Did you know? image() can has url!</title>
		<link>http://cakealot.com/2010/05/quicktip-did-you-know-image-can-has-url/</link>
		<comments>http://cakealot.com/2010/05/quicktip-did-you-know-image-can-has-url/#comments</comments>
		<pubDate>Thu, 06 May 2010 21:42:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Quicktips]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html-helper]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://www.cakealot.com/?p=44</guid>
		<description><![CDATA[How to save you alot of code on image links while still being able to use the full power of the cakephp router. Most of you probably know the following piece of code from the default.ctp: echo $html-&#62;link( $html-&#62;image('cake.power.gif', array( 'alt'=&#62; __("CakePHP...", true), 'border'=&#62;"0" )), 'http://www.cakephp.org/', array('target' =&#62; '_blank'), null, false ); This displays the [...]]]></description>
			<content:encoded><![CDATA[<p>How to save you alot of code on image links while still being able to use the full power of the cakephp router.</p>
<p><span id="more-44"></span></p>
<p>Most of you probably know the following piece of code from the <strong>default.ctp</strong>:</p>
<pre class="prettyprint lang-php"><code>echo $html-&gt;link(
   $html-&gt;image('cake.power.gif', array(
       'alt'=&gt; __("CakePHP...", true),
       'border'=&gt;"0"
   )),
   'http://www.cakephp.org/',
   array('target' =&gt; '_blank'), null, false
);</code></pre>
<p>This displays the small “CakePHP Power” badge with a link to the CakePHP website.</p>
<p>Much code for just a image surrounded with a link, eh?</p>
<p>The <code>$html-&gt;image()</code> method has a option called ‘url’ that basicly does the same thing. Only limitation is that you can’t pass attributes to the link tag. But it isn&#8217;t always needed. If that&#8217;s true in your case try the following.</p>
<p>The <em>same</em> thing, only without the clutter:</p>
<pre class="prettyprint lang-php"><code>echo $html-&gt;image('cake.power.gif', array(
   <strong>'url' =&gt; 'http://www.cakephp.org',</strong>
   'alt' =&gt; __('CakePHP...', true),
   'border' =&gt; 0
));</code></pre>
<p>There you have it. Of course <code>‘url’</code> accepts arrays and everything else you would expect since it passes the value straight to <code>Helper::url()</code>.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakealot.com/2010/05/quicktip-did-you-know-image-can-has-url/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>QuickTip: How to overwrite HtmlHelper tags</title>
		<link>http://cakealot.com/2010/02/quicktip-how-to-overwrite-htmlhelper-tags/</link>
		<comments>http://cakealot.com/2010/02/quicktip-how-to-overwrite-htmlhelper-tags/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 21:38:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Quicktips]]></category>
		<category><![CDATA[helper]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html-helper]]></category>
		<category><![CDATA[html-tags]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://www.cakealot.com/?p=40</guid>
		<description><![CDATA[In some cases you find it desirable to overwrite the tag templates used by the HtmlHelper. For example if you put all your assets onto a CDN and don’t want to put the hostname in front of all paths (messy..). With this small modification in the AppHelper class you can do that in bootstrap using [...]]]></description>
			<content:encoded><![CDATA[<p>In some cases you find it desirable to overwrite the tag templates  used by the HtmlHelper. For example if you put all your assets onto a CDN and don’t want to put the hostname in front of all paths (messy..).</p>
<p><span id="more-40"></span></p>
<p>With this small modification in the AppHelper class you can do that  in bootstrap using Configure, which also allows you to make the tags  conditional if you want.. In short: <em>flexibility</em>, wee!</p>
<pre class="prettyprint lang-php"><code>// The code:
class AppHelper extends Helper {
  function __construct() {
    if ($this-&gt;toString() == 'HtmlHelper') {
      $tags = Configure::read('HtmlHelper.tags');
      if (is_null($tags)) $tags = array();
         $this-&gt;tags = am($this-&gt;tags, $tags);
    }
  }
}</code></pre>
<p>With this in place (file goes to app root and is called  app_helper.php) you can now configure your tags whereever you like  passing an array with sprintf templates, like so:</p>
<pre class="prettyprint lang-php"><code>Configure::write('HtmlHelper.tags', array(
  'image' =&gt; '&lt;img src="http://cdn.domain.com%s" %s/&gt;',
));</code></pre>
<p>yay!</p>
<p><small><strong>Note</strong>: is_null checks if Configure value is set. This way you are not forced to set a empty array to your bootstrap.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://cakealot.com/2010/02/quicktip-how-to-overwrite-htmlhelper-tags/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eventful &#8211; Event Driven CakePHP Development</title>
		<link>http://cakealot.com/2009/04/eventful-a-cakephp-event-system/</link>
		<comments>http://cakealot.com/2009/04/eventful-a-cakephp-event-system/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 21:06:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[behavior]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[eventful]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.cakealot.com/?p=24</guid>
		<description><![CDATA[As promised i&#8217;ve created a repo for the event system i was working on. It’s currently under heavy development, yet ready to use. I don’t think the interface will change much from here on out. The installation is similar to the DebugKit. Put the “eventful” plugin into your plugins folder and add the Behavior or [...]]]></description>
			<content:encoded><![CDATA[<p>As promised i&#8217;ve created a repo for the event system i was working on.</p>
<p>It’s currently under heavy development, yet ready to use. I don’t think  the interface will change much from here on out. The installation is  similar to the DebugKit. </p>
<p><span id="more-24"></span></p>
<p>Put the “eventful” plugin into your plugins  folder and add the Behavior or Component to your app. This will include  all dependencies and the system is ready to use.</p>
<p>Only one thing is different from regular plugins. There is a seperate  “events” folder which is a empty layout for the system and the place for  your event listener classes.</p>
<p>The System is also plugin aware. If you want to enrich your base  application with event handlers from plugins just copy the “events”  folder layout into the plugin directory and prefix the class filenames  with the plugin name. (just like app_controller).</p>
<pre class="prettyprint lang-php"><code># /app/plugins/pizza/events/controller/pizza_users_controller_events.php
class PizzaUsersControllerEvents extends AppControllerEvents {
    // your event handlers
}</code></pre>
<p>I’ve created a (messy) README which goes on about how to use it, but basicly the workflow is: <strong></strong></p>
<ol>
<li><strong></strong>add the component/behavior,</li>
<li><strong></strong>use the dispatch/dispatchEvent method in your actions/methods,</li>
<li><strong></strong>create or modify the event listener class and add a matching “on” method. <strong></strong></li>
<li><strong></strong>go nuts.</li>
</ol>
<pre class="prettyprint lang-php"><code>// step 1
class UsersController extends AppController {
  var $components = array('Eventful.Event');
}

// step 2
class UsersController extends AppController {
  var $components = array('Eventful.Event');

  function logout() {
    // send a event called "UserLogout"
    $this-&gt;Event-&gt;dispatch('UserLogout', array(
      'auth' =&gt; $this-&gt;Auth-&gt;user()
    ));
    $this-&gt;Auth-&gt;logout();
  }
}

// step 3
 // File: /app/events/controller/users_controller_events.php
class UsersControllerEvents extends AppControllerEvents {

  // do something on "UserLogout";
  function <strong>on</strong>UserLogout() {
    $this-&gt;log('User logged out...');
  }
}</code></pre>
<p>Unlike the original implementation the current <strong>triggers all handlers of  the same name</strong>. So if you have a “UserLogout” event fired from <code>UsersController::logout()</code> action the <code>dispatchEvent()</code> method will trigger all possible <em>candidates</em>. Regardless in which listener class (f.e. UnrelatedControllerEvents) the event handler is defined. So in addition to the above. the following is executed too:</p>
<pre class="prettyprint lang-php"><code>class MembersControllerEvents extends AppControllerEvents {

  // do something on "UserLogout"
  function onUserLogout($event) { // import $event data from call param
    if ($event-&gt;auth['isMember'])
        $this-&gt;log('Member '.$event-&gt;auth['name'].' logged out...');
  }
}</code></pre>
<p>Enjoy! You can find it on github:<br />
<a title="GitHub.com Repository" href="http://github.com/m3nt0r/eventful-cakephp">http://github.com/m3nt0r/eventful-cakephp</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cakealot.com/2009/04/eventful-a-cakephp-event-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

