<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Modules</title>
	<atom:link href="http://akrabat.com/php/modules/feed/" rel="self" type="application/rss+xml" />
	<link>http://akrabat.com/php/modules/</link>
	<description>Developing PHP software in the Real World, by Rob Allen</description>
	<lastBuildDate>Wed, 10 Mar 2010 21:44:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: William Barry</title>
		<link>http://akrabat.com/php/modules/#comment-23427</link>
		<dc:creator>William Barry</dc:creator>
		<pubDate>Wed, 12 Nov 2008 23:25:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.akrabat.com/2007/02/03/modules/#comment-23427</guid>
		<description>Hey,

I&#039;ve seen the topic of an admin module come up several times and I wanted to share a simple solution that worked for me.

Create an AdminController in your default module that forwards the request to &quot;Admin Actions.&quot;

For example, if you have a BooksController that allows anyone to view a list of books but only a small group of admins to edit the books, you would create two methods:

BooksController::viewAction

BooksController::editAdminAction

The first method would be tied to the /books/view using the normal action naming convention.  Rather than using /books/edit-admin to get to the second method, the AdminController would simply forward /admin/books/edit to the second method.

There is most likely cleaner code to do this, but here&#039;s one way that works:

&lt;pre class=&quot;phpcode&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;class&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;AdminController&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;extends&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;Zend_Controller_Action&#160;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;{&lt;br /&gt;&#160;&#160;&#160;&#160;public&#160;function&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;preDispatch&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;()&lt;br /&gt;&#160;&#160;&#160;&#160;{&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$uri&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;getUri&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;();&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$count&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$uri&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if&#160;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$count&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;&gt;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;)&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$controller&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$uri&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;];&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$action&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$count&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;&gt;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;2&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;?&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$uri&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]&#160;:&#160;&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;index&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$action&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;toCamelCase&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$action&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if&#160;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;class_exists&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$controller&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;))&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;_forward&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$action&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;-admin&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$controller&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}&lt;br /&gt;&#160;&#160;&#160;&#160;}&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;br /&gt;&#160;&#160;&#160;&#160;public&#160;function&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;getURI&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;()&lt;br /&gt;&#160;&#160;&#160;&#160;{&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$uri&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;_request&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;getRequestUri&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;();&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$uri&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;substr&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$uri&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$uri&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;preg_replace&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;/^(.*?)?.*?$/&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&#160;&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;$1&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$uri&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if&#160;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;strlen&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$uri&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;)&#160;&gt;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;0&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;&amp;&amp;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;substr&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$uri&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&#160;-&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;)&#160;==&#160;&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;/&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;)&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$uri&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;substr&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$uri&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&#160;-&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;return&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;explode&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;/&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$uri&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&#160;&#160;&#160;&#160;}&lt;br /&gt;&#160;&#160;&#160;&#160;&lt;br /&gt;&#160;&#160;&#160;&#160;public&#160;function&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;toCamelCase&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$str&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;)&lt;br /&gt;&#160;&#160;&#160;&#160;{&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$str&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;str_replace&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;-&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&#160;&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;_&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$str&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$str&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;explode&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;_&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;strtolower&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$str&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;));&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$count&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$str&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for&#160;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$count&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;++)&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$str&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]&#160;=&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;ucfirst&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$str&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]);&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$str&#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;implode&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$str&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;return&#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$str&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&#160;&#160;&#160;&#160;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

Hope this helps someone.</description>
		<content:encoded><![CDATA[<p>Hey,</p>
<p>I've seen the topic of an admin module come up several times and I wanted to share a simple solution that worked for me.</p>
<p>Create an AdminController in your default module that forwards the request to "Admin Actions."</p>
<p>For example, if you have a BooksController that allows anyone to view a list of books but only a small group of admins to edit the books, you would create two methods:</p>
<p>BooksController::viewAction</p>
<p>BooksController::editAdminAction</p>
<p>The first method would be tied to the /books/view using the normal action naming convention.  Rather than using /books/edit-admin to get to the second method, the AdminController would simply forward /admin/books/edit to the second method.</p>
<p>There is most likely cleaner code to do this, but here's one way that works:</p>
<pre class="phpcode"><span style="color: #0000BB">
</span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">AdminController&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">Zend_Controller_Action&nbsp;
</span><span style="color: #007700">{
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">preDispatch</span><span style="color: #007700">()
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$uri&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getUri</span><span style="color: #007700">();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$count&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">count</span><span style="color: #007700">(</span><span style="color: #0000BB">$uri</span><span style="color: #007700">);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$count&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$controller&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$uri</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$action&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$count&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">2&nbsp;</span><span style="color: #007700">?&nbsp;</span><span style="color: #0000BB">$uri</span><span style="color: #007700">[</span><span style="color: #0000BB">2</span><span style="color: #007700">]&nbsp;:&nbsp;</span><span style="color: #DD0000">'index'</span><span style="color: #007700">;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$action&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">toCamelCase</span><span style="color: #007700">(</span><span style="color: #0000BB">$action</span><span style="color: #007700">);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">class_exists</span><span style="color: #007700">(</span><span style="color: #0000BB">$controller</span><span style="color: #007700">))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">_forward</span><span style="color: #007700">(</span><span style="color: #0000BB">$action&nbsp;</span><span style="color: #007700">.</span><span style="color: #DD0000">'-admin'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$controller</span><span style="color: #007700">);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">getURI</span><span style="color: #007700">()
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$uri&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">_request</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getRequestUri</span><span style="color: #007700">();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$uri&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$uri</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$uri&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">preg_replace</span><span style="color: #007700">(</span><span style="color: #DD0000">'/^(.*?)?.*?$/'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'$1'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$uri</span><span style="color: #007700">);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$uri</span><span style="color: #007700">)&nbsp;&gt;&nbsp;</span><span style="color: #0000BB">0&nbsp;</span><span style="color: #007700">&amp;&amp;&nbsp;</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$uri</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">)&nbsp;==&nbsp;</span><span style="color: #DD0000">'/'</span><span style="color: #007700">)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$uri&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$uri</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">1</span><span style="color: #007700">);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">explode</span><span style="color: #007700">(</span><span style="color: #DD0000">'/'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$uri</span><span style="color: #007700">);
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">toCamelCase</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">str_replace</span><span style="color: #007700">(</span><span style="color: #DD0000">'-'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'_'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$str</span><span style="color: #007700">);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">explode</span><span style="color: #007700">(</span><span style="color: #DD0000">'_'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">strtolower</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">));
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$count&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">count</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(</span><span style="color: #0000BB">$i</span><span style="color: #007700">=</span><span style="color: #0000BB">1</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">$count</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$str</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">ucfirst</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">implode</span><span style="color: #007700">(</span><span style="color: #DD0000">""</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$str</span><span style="color: #007700">);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$str</span><span style="color: #007700">;
&nbsp;&nbsp;&nbsp;&nbsp;}
}
</span>
</pre>
<p>Hope this helps someone.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gog</title>
		<link>http://akrabat.com/php/modules/#comment-20959</link>
		<dc:creator>gog</dc:creator>
		<pubDate>Thu, 03 Apr 2008 00:37:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.akrabat.com/2007/02/03/modules/#comment-20959</guid>
		<description>Hi,

I&#039;m struggling with the some problem. I am currently planning my CMS, and for now I think I am going to stick as well with just the two module - site &amp; admin.

The thing I am wondering is what to do with some of the directives in my bootstrap file.

I am initializing Zend_Layout MVC helper with something like this:

Zend_Layout::startMvc(array(&#039;layoutPath&#039; =&gt; ROOT_DIR.&#039;/application/views/layouts&#039;)); 

Which works great if you are nor using module.

As far as I can tell, there is only one right way to do it, and that is to write your own front controller plugin that will set the appropriate path, see http://www.nabble.com/Setup-Zend_Layout-based-on-module-td16036883.html

There is some more insight in a comment from Matthew Weier O&#039;Phinney on http://framework.zend.com/wiki/display/ZFPROP/Zend_Layout#Zend_Layout-3.ComponentRequirements%2CConstraints%2CandAcceptanceCriteria that kind of clarifies why this Zend_Layout isn&#039;t coupled with a rewrite router.

But, I would still be very happy if I could specify layout folder in the same way I can specify a modular structure by passing an array of modules/paths.

Do you maybe have some other ideas?</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I'm struggling with the some problem. I am currently planning my CMS, and for now I think I am going to stick as well with just the two module - site &amp; admin.</p>
<p>The thing I am wondering is what to do with some of the directives in my bootstrap file.</p>
<p>I am initializing Zend_Layout MVC helper with something like this:</p>
<p>Zend_Layout::startMvc(array('layoutPath' =&gt; ROOT_DIR.'/application/views/layouts')); </p>
<p>Which works great if you are nor using module.</p>
<p>As far as I can tell, there is only one right way to do it, and that is to write your own front controller plugin that will set the appropriate path, see <a href="http://www.nabble.com/Setup-Zend_Layout-based-on-module-td16036883.html" rel="nofollow">http://www.nabble.com/Setup-Zend_Layout-based-on-module-td16036883.html</a></p>
<p>There is some more insight in a comment from Matthew Weier O'Phinney on <a href="http://framework.zend.com/wiki/display/ZFPROP/Zend_Layout#Zend_Layout-3.ComponentRequirements%2CConstraints%2CandAcceptanceCriteria" rel="nofollow">http://framework.zend.com/wiki/display/ZFPROP/Zend_Layout#Zend_Layout-3.ComponentRequirements%2CConstraints%2CandAcceptanceCriteria</a> that kind of clarifies why this Zend_Layout isn't coupled with a rewrite router.</p>
<p>But, I would still be very happy if I could specify layout folder in the same way I can specify a modular structure by passing an array of modules/paths.</p>
<p>Do you maybe have some other ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DamionKutaeff</title>
		<link>http://akrabat.com/php/modules/#comment-20738</link>
		<dc:creator>DamionKutaeff</dc:creator>
		<pubDate>Sun, 23 Mar 2008 13:45:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.akrabat.com/2007/02/03/modules/#comment-20738</guid>
		<description>Hello everybody, my name is Damion, and I&#039;m glad to join your conmunity, 
and wish to assit as far as possible.</description>
		<content:encoded><![CDATA[<p>Hello everybody, my name is Damion, and I'm glad to join your conmunity,<br />
and wish to assit as far as possible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob...</title>
		<link>http://akrabat.com/php/modules/#comment-10462</link>
		<dc:creator>Rob...</dc:creator>
		<pubDate>Wed, 06 Jun 2007 05:59:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.akrabat.com/2007/02/03/modules/#comment-10462</guid>
		<description>Patrick,

Not yet. I haven&#039;t had time, so have been using two modules: default and admin.

Regards,

Rob...</description>
		<content:encoded><![CDATA[<p>Patrick,</p>
<p>Not yet. I haven't had time, so have been using two modules: default and admin.</p>
<p>Regards,</p>
<p>Rob...</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick Nijs</title>
		<link>http://akrabat.com/php/modules/#comment-10447</link>
		<dc:creator>Patrick Nijs</dc:creator>
		<pubDate>Tue, 05 Jun 2007 09:49:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.akrabat.com/2007/02/03/modules/#comment-10447</guid>
		<description>[quote]
Matthew,

Putting the admin within the module keeps everything together which is the biggest win. I quite like the idea of using a rewrite rule so that I can use URLs of the form /admin/{module}/{controller}/{action}. 

I’ll definitely have to play with this layout. 
[/quote]

Have you figured out how you should write this rewrite rule?
I am currently implementing an admin-subdirectory too in my controllers directory, and /module/admin/controller/action is just more beautiful than /module/admin_controller/action...</description>
		<content:encoded><![CDATA[<p>[quote]<br />
Matthew,</p>
<p>Putting the admin within the module keeps everything together which is the biggest win. I quite like the idea of using a rewrite rule so that I can use URLs of the form /admin/{module}/{controller}/{action}. </p>
<p>I’ll definitely have to play with this layout.<br />
[/quote]</p>
<p>Have you figured out how you should write this rewrite rule?<br />
I am currently implementing an admin-subdirectory too in my controllers directory, and /module/admin/controller/action is just more beautiful than /module/admin_controller/action...</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff</title>
		<link>http://akrabat.com/php/modules/#comment-9636</link>
		<dc:creator>Jeff</dc:creator>
		<pubDate>Mon, 30 Apr 2007 22:04:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.akrabat.com/2007/02/03/modules/#comment-9636</guid>
		<description>Ok, I figured out how to access my views by using the 

$view-&gt;addScriptPath(&#039;../application/moduleLocation/views&#039;);
and executed this in my index.php

I see the post by Kyle
&quot;If I want different models with each module then I have a Zend_Controller plugin that adds to the include path using something like: “..app/”.$request-&gt;getModuleName().”/models/”
&quot;

I suppose there isn&#039;t a getModuleName() function already?

I&#039;ll work on this.  Thanks for your comments.</description>
		<content:encoded><![CDATA[<p>Ok, I figured out how to access my views by using the </p>
<p>$view-&gt;addScriptPath('../application/moduleLocation/views');<br />
and executed this in my index.php</p>
<p>I see the post by Kyle<br />
"If I want different models with each module then I have a Zend_Controller plugin that adds to the include path using something like: “..app/”.$request-&gt;getModuleName().”/models/”<br />
"</p>
<p>I suppose there isn't a getModuleName() function already?</p>
<p>I'll work on this.  Thanks for your comments.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff</title>
		<link>http://akrabat.com/php/modules/#comment-9585</link>
		<dc:creator>Jeff</dc:creator>
		<pubDate>Thu, 26 Apr 2007 21:54:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.akrabat.com/2007/02/03/modules/#comment-9585</guid>
		<description>By the way, I&#039;m using version .9.0</description>
		<content:encoded><![CDATA[<p>By the way, I'm using version .9.0</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff</title>
		<link>http://akrabat.com/php/modules/#comment-9584</link>
		<dc:creator>Jeff</dc:creator>
		<pubDate>Thu, 26 Apr 2007 21:54:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.akrabat.com/2007/02/03/modules/#comment-9584</guid>
		<description>I think I missed something here.  When I&#039;m trying to access the views and models, do I need to put their path somewhere?  What I really want is to automatically detect the view/model locations associated with the controller in the module.

Any thoughts?</description>
		<content:encoded><![CDATA[<p>I think I missed something here.  When I'm trying to access the views and models, do I need to put their path somewhere?  What I really want is to automatically detect the view/model locations associated with the controller in the module.</p>
<p>Any thoughts?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob...</title>
		<link>http://akrabat.com/php/modules/#comment-9360</link>
		<dc:creator>Rob...</dc:creator>
		<pubDate>Sun, 15 Apr 2007 18:48:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.akrabat.com/2007/02/03/modules/#comment-9360</guid>
		<description>Kyle,

Fixed the pre tag :)

Regards,

Rob...</description>
		<content:encoded><![CDATA[<p>Kyle,</p>
<p>Fixed the pre tag :)</p>
<p>Regards,</p>
<p>Rob...</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kyle</title>
		<link>http://akrabat.com/php/modules/#comment-9358</link>
		<dc:creator>Kyle</dc:creator>
		<pubDate>Sun, 15 Apr 2007 17:58:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.akrabat.com/2007/02/03/modules/#comment-9358</guid>
		<description>That got boned. My pre tags were stripped.</description>
		<content:encoded><![CDATA[<p>That got boned. My pre tags were stripped.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
