Revision history for WikkaCake


Revision [23466]

Last edited on 2016-05-20 07:38:48 by BrianKoontz [Replaces old-style internal links with new pipe-split links.]
Additions:
=====Integrating Wikka and [[http://www.cakephp.org | CakePHP]] 1.3=====
[[http://blog.wikkawiki.org/2010/12/30/running-cakephp-in-wikkawiki/ | Wikka Developer Blog]]
[[http://bakery.cakephp.org/articles/brianko/2007/08/20/wikkacake_using_cakephp_as_an_embedded_framework | This article on The Bakery]]
[[WikkaCake11 | WikkaCake using CakePHP 1.1]]
I advocate the use of Wikka as a [[Docs:FlexibleWikka | presentation framework for rapid development]] of Internet-based applications. Wikka does a great job of handling user authentication, session tracking, and presentation, but does not offer much in the way of easily customizable, high-level database read/write access. Enter [[http://www.cakephp.org | CakePHP]]: A rapid-development PHP framework that handles many of the low-level DB access details so you don't have to. While Cake itself offers similar framework functionality as Wikka, my goal was to implement a totally self-contained Cake application within Wikka. The look-and-feel would be all Wikka, while the Cake engine would provide a database abstraction layer independent of Wikka.
My development environment consists of Windows 7, running the latest [[WikkaSVN | 1.3 branch version]] of Wikka. The Cake version I'm currently using is 1.3.6. Please be aware that Cake versions prior to 1.3 have significant API changes that may not be compatible with the setup instructions that follow. I have not tested this setup on Wikka 1.2 or earlier, but other than some directory restructuring, I see no reason why these instructions won't be applicable to earlier Wikka versions.
[[https://github.com/cakephp/cakephp/downloads | Download]] the latest 1.3.x version of Cake and use whatever method is appropriate for your system to unzip/untar the Cake distribution to your ##3rdparty/plugins## directory. As a matter of convenience, Unix/OSX users may want to either create a symlink to the cake distribution directory:
This is the "heart" of the Cake application, as the Dispatcher is what kicks off the Cake core engine. The problem here is that there is a conflict between the way Cake parses a URL (it expects a controller action as the URL target) and what Wikka expects (an action name as the URL target). Thanks to the [[http://debuggable.com/posts/learning-from-the-cakephp-source-code-part-ii:480f4dd6-57fc-4715-8709-439acbdd56cb | work of Felix Geisendorfer]], we have an easy way of overriding the default Cake dispatch mechanism, allowing us to create a new Dispatcher and dispatch us to wherever we want to go. Since Wikka implements handlers as a URL extension (i.e., ##wikka/""CakeTest""/edit## invokes the Wikka editor on the ##""CakeTest""## page), we must use another mechanism to pass actions to Cake. I've chosen to use GET parameters (i.e., ##wikka/""CakeTest""?action=add##). By default, no GET parameters should invoke your controller's ##index()## method directly (don't worry if this doesn't make sense at the moment). Anything else passed as a GET parameter is a Cake action and should be dispatched as such.
This might not make much sense to you if you're learning Cake as you go. My suggestion would be to create a simple Cake application (the [[http://manual.cakephp.org/appendix/blog_tutorial | Cake tutorial]] is an excellent place to start), get it working as a standalone app, and then simply copy everything under your ##app## directory to your ##caketest## action.
Create the following files in order to test your setup. //Please note this is not intended as a ""CakePHP"" tutorial!// I provide just enough here for quick gratification of a job well done. Please consult the [[http://book.cakephp.org/ | CakePHP manual]] for additional information.
At this point, if you're ready to tackle a new Cake application, start with the extensive [[http://book.cakephp.org | Cake documentation]]. The [[http://book.cakephp.org/view/1527/Tutorials-Examplesl | Cake tutorial]] is an excellent hands-on project that lends itself easily to conversion to a WikkaCake app. I've also found [[http://debuggable.com/blog | this blog]] to be an excellent source of information about Cake that's not covered by the Cake manual and API (search for """CakePHP""").
I will be posting a simple WikkaCake application I developed for the [[http://wiki.opennicproject.org | OpenNIC]] wiki to track ""OpenNIC"" [[http://wiki.opennicproject.org/Tier2 | OpenNIC public servers]]. It's based loosely upon the blog tutorial mentioned earlier.
Deletions:
=====Integrating Wikka and [[http://www.cakephp.org CakePHP]] 1.3=====
[[http://blog.wikkawiki.org/2010/12/30/running-cakephp-in-wikkawiki/ Wikka Developer Blog]]
[[http://bakery.cakephp.org/articles/brianko/2007/08/20/wikkacake_using_cakephp_as_an_embedded_framework This article on The Bakery]]
[[WikkaCake11 WikkaCake using CakePHP 1.1]]
I advocate the use of Wikka as a [[Docs:FlexibleWikka presentation framework for rapid development]] of Internet-based applications. Wikka does a great job of handling user authentication, session tracking, and presentation, but does not offer much in the way of easily customizable, high-level database read/write access. Enter [[http://www.cakephp.org CakePHP]]: A rapid-development PHP framework that handles many of the low-level DB access details so you don't have to. While Cake itself offers similar framework functionality as Wikka, my goal was to implement a totally self-contained Cake application within Wikka. The look-and-feel would be all Wikka, while the Cake engine would provide a database abstraction layer independent of Wikka.
My development environment consists of Windows 7, running the latest [[WikkaSVN 1.3 branch version]] of Wikka. The Cake version I'm currently using is 1.3.6. Please be aware that Cake versions prior to 1.3 have significant API changes that may not be compatible with the setup instructions that follow. I have not tested this setup on Wikka 1.2 or earlier, but other than some directory restructuring, I see no reason why these instructions won't be applicable to earlier Wikka versions.
[[https://github.com/cakephp/cakephp/downloads Download]] the latest 1.3.x version of Cake and use whatever method is appropriate for your system to unzip/untar the Cake distribution to your ##3rdparty/plugins## directory. As a matter of convenience, Unix/OSX users may want to either create a symlink to the cake distribution directory:
This is the "heart" of the Cake application, as the Dispatcher is what kicks off the Cake core engine. The problem here is that there is a conflict between the way Cake parses a URL (it expects a controller action as the URL target) and what Wikka expects (an action name as the URL target). Thanks to the [[http://debuggable.com/posts/learning-from-the-cakephp-source-code-part-ii:480f4dd6-57fc-4715-8709-439acbdd56cb work of Felix Geisendorfer]], we have an easy way of overriding the default Cake dispatch mechanism, allowing us to create a new Dispatcher and dispatch us to wherever we want to go. Since Wikka implements handlers as a URL extension (i.e., ##wikka/""CakeTest""/edit## invokes the Wikka editor on the ##""CakeTest""## page), we must use another mechanism to pass actions to Cake. I've chosen to use GET parameters (i.e., ##wikka/""CakeTest""?action=add##). By default, no GET parameters should invoke your controller's ##index()## method directly (don't worry if this doesn't make sense at the moment). Anything else passed as a GET parameter is a Cake action and should be dispatched as such.
This might not make much sense to you if you're learning Cake as you go. My suggestion would be to create a simple Cake application (the [[http://manual.cakephp.org/appendix/blog_tutorial Cake tutorial]] is an excellent place to start), get it working as a standalone app, and then simply copy everything under your ##app## directory to your ##caketest## action.
Create the following files in order to test your setup. //Please note this is not intended as a ""CakePHP"" tutorial!// I provide just enough here for quick gratification of a job well done. Please consult the [[http://book.cakephp.org/ CakePHP manual]] for additional information.
At this point, if you're ready to tackle a new Cake application, start with the extensive [[http://book.cakephp.org Cake documentation]]. The [[http://book.cakephp.org/view/1527/Tutorials-Examplesl Cake tutorial]] is an excellent hands-on project that lends itself easily to conversion to a WikkaCake app. I've also found [[http://debuggable.com/blog this blog]] to be an excellent source of information about Cake that's not covered by the Cake manual and API (search for """CakePHP""").
I will be posting a simple WikkaCake application I developed for the [[http://wiki.opennicproject.org OpenNIC]] wiki to track ""OpenNIC"" [[http://wiki.opennicproject.org/Tier2 OpenNIC public servers]]. It's based loosely upon the blog tutorial mentioned earlier.


Revision [21308]

Edited on 2010-12-30 02:56:25 by BrianKoontz [updated links]
Additions:
[[http://blog.wikkawiki.org/2010/12/30/running-cakephp-in-wikkawiki/ Wikka Developer Blog]]
[[http://bakery.cakephp.org/articles/brianko/2007/08/20/wikkacake_using_cakephp_as_an_embedded_framework This article on The Bakery]]
Deletions:
[[http://blog.wikkawiki.org/2007/08/18/have-your-cakephp-and-eat-it-too/ Wikka Developer Blog]]
[[http://bakery.cakephp.org/articles/view/wikkacake-using-cakephp-as-an-embedded-framework The Bakery]] [[http://web.archive.org/web/20070819094408/http://bakery.cakephp.org/articles/view/wikkacake-using-cakephp-as-an-embedded-framework (archived version)]]


Revision [21307]

Edited on 2010-12-29 21:02:22 by BrianKoontz [Updated for CakePHP 1.3]
Additions:
if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
return;
} else {
$Dispatcher = new Dispatcher();
$Dispatcher->dispatch();
This is the "heart" of the Cake application, as the Dispatcher is what kicks off the Cake core engine. The problem here is that there is a conflict between the way Cake parses a URL (it expects a controller action as the URL target) and what Wikka expects (an action name as the URL target). Thanks to the [[http://debuggable.com/posts/learning-from-the-cakephp-source-code-part-ii:480f4dd6-57fc-4715-8709-439acbdd56cb work of Felix Geisendorfer]], we have an easy way of overriding the default Cake dispatch mechanism, allowing us to create a new Dispatcher and dispatch us to wherever we want to go. Since Wikka implements handlers as a URL extension (i.e., ##wikka/""CakeTest""/edit## invokes the Wikka editor on the ##""CakeTest""## page), we must use another mechanism to pass actions to Cake. I've chosen to use GET parameters (i.e., ##wikka/""CakeTest""?action=add##). By default, no GET parameters should invoke your controller's ##index()## method directly (don't worry if this doesn't make sense at the moment). Anything else passed as a GET parameter is a Cake action and should be dispatched as such.
Assuming your controller is named ##servers_controller.php##, you will want your dispatch code to look like this (comment out the codeblock in the ##else## statement above and replace with the following):
Create the following files in order to test your setup. //Please note this is not intended as a ""CakePHP"" tutorial!// I provide just enough here for quick gratification of a job well done. Please consult the [[http://book.cakephp.org/ CakePHP manual]] for additional information.
Deletions:
if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
} else {
$Dispatcher=new Dispatcher();
$Dispatcher->dispatch($url);
This is the "heart" of the Cake application, as the Dispatcher is what kicks off the Cake core engine. The problem here is that there is a conflict between the way Cake parses a URL (it expects a controller action as the URL target) and what Wikka expects (an action name as the URL target). Thanks to the [[http://debuggable.com/posts/learning-from-the-cakephp-source-code-part-i:480f4dd6-28d0-445e-a1dc-4ceacbdd56c work of]] [[http://debuggable.com/posts/learning-from-the-cakephp-source-code-part-ii:480f4dd6-57fc-4715-8709-439acbdd56cb Felix Geisendorfer]], we have an easy way of overriding the default Cake dispatch mechanism, allowing us to create a new Dispatcher and dispatch us to wherever we want to go. Since Wikka implements handlers as a URL extension (i.e., ##wikka/CakeTest/edit## invokes the Wikka editor on the ##CakeTest## page), we must use another mechanism to pass actions to Cake. I've chosen to use GET parameters (i.e., ##wikka/CakeTest?action=add##). By default, no GET parameters should invoke your controller's ##index()## method directly (don't worry if this doesn't make sense at the moment). Anything else passed as a GET parameter is a Cake action and should be dispatched as such.
Assuming your controller is named ##servers_controller.php##, you will want your dispatch code to look like this (comment out the codeblock in the ##else## statement following ##if(!include(CORE_PATH . 'cake' . DS . 'bootstrap.php'))## and add the following):
Create the following files in order to test your setup. //Please note this is not intended as a ""CakePHP"" tutorial!// I provide just enough here for quick gratification of a job well done. Please consult the [[http://book.cakephp.org/ ""CakePHP"" manual]] for additional information.


Revision [21306]

Edited on 2010-12-29 20:56:00 by BrianKoontz [Updated for CakePHP 1.3]
Additions:
[[http://bakery.cakephp.org/articles/view/wikkacake-using-cakephp-as-an-embedded-framework The Bakery]] [[http://web.archive.org/web/20070819094408/http://bakery.cakephp.org/articles/view/wikkacake-using-cakephp-as-an-embedded-framework (archived version)]]
**Previous versions:**
[[WikkaCake11 WikkaCake using CakePHP 1.1]]
<<
Deletions:
[[WikkaCake11 ""WikkaCase"" using CakePHP 1.1]]
[[http://bakery.cakephp.org/articles/view/wikkacake-using-cakephp-as-an-embedded-framework The Bakery]] [[http://web.archive.org/web/20070819094408/http://bakery.cakephp.org/articles/view/wikkacake-using-cakephp-as-an-embedded-framework (archived version)]]<<


Revision [21305]

Edited on 2010-12-29 20:54:24 by BrianKoontz [Updated for CakePHP 1.3]
Additions:
[[WikkaCake11 ""WikkaCase"" using CakePHP 1.1]]
Deletions:
[[WikkaCase11 ""WikkaCase"" using CakePHP 1.1]]


Revision [21304]

Edited on 2010-12-29 20:53:50 by BrianKoontz [Updated for CakePHP 1.3]
Additions:
These instructions are only applicable to ""CakePHP"" 1.3!
[[WikkaCase11 ""WikkaCase"" using CakePHP 1.1]]
Deletions:
These instructions are only applicable to ""CakePHP"" 1.3!


Revision [21303]

Edited on 2010-12-29 20:52:36 by BrianKoontz [Updated for CakePHP 1.3]
Additions:
=====Integrating Wikka and [[http://www.cakephp.org CakePHP]] 1.3=====
<<**Note:**
These instructions are only applicable to ""CakePHP"" 1.3!
**See also:**
I believe the first three goals have been met (and my two dogs are still happy with me, so I'm confident goal #4 was met as well).
My development environment consists of Windows 7, running the latest [[WikkaSVN 1.3 branch version]] of Wikka. The Cake version I'm currently using is 1.3.6. Please be aware that Cake versions prior to 1.3 have significant API changes that may not be compatible with the setup instructions that follow. I have not tested this setup on Wikka 1.2 or earlier, but other than some directory restructuring, I see no reason why these instructions won't be applicable to earlier Wikka versions.
[[https://github.com/cakephp/cakephp/downloads Download]] the latest 1.3.x version of Cake and use whatever method is appropriate for your system to unzip/untar the Cake distribution to your ##3rdparty/plugins## directory. As a matter of convenience, Unix/OSX users may want to either create a symlink to the cake distribution directory:
ln -s ./cakephp-cakephp-f6748d4 cake
mv cakephp-cakephp-f6748d41 cake
Cake is distributed with its own CSS stylesheet; many of the selectors conflict with the Wikka CSS selectors. As you will see shortly, there is a method that can be invoked in Wikka to include an external stylesheet in the ##<head>## section that's generated by Wikka. I would recommend, at a minimum, that the Cake default CSS file (located at ##3rdparty/plugins/cake/app/webroot/css/cake.generic.css##) be copied to your Wikka ##css## directory. Then, delete all sections but the section marked ##/*Notices and Errors*/##.
For Unix/OSX/Cygwin users:
Here are the steps you need to take. Other than creating your Cake application, this is probably the most complex process involved with Wikka/Cake integration. All of the following steps involve changes to ##webroot/index.php## unless otherwise specified. I recommend making a copy of this file as a backup you can refer to if you get lost.
define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(ROOT)).DS.'3rdparty'.DS.'plugins'.DS.'cake');
Locate the closing brace, ##}##, immediately after the CAKE_CORE_INCLUDE_PATH line and add the following, replacing the URL with your Wikka's URL used to access the caketest action:
define('BASE_URL', $this->Href());
(Since this code has already been called by the Wikka action, the Wikka instance is available via ##$this##.)
Assuming your controller is named ##servers_controller.php##, you will want your dispatch code to look like this (comment out the codeblock in the ##else## statement following ##if(!include(CORE_PATH . 'cake' . DS . 'bootstrap.php'))## and add the following):
Create the following files in order to test your setup. //Please note this is not intended as a ""CakePHP"" tutorial!// I provide just enough here for quick gratification of a job well done. Please consult the [[http://book.cakephp.org/ ""CakePHP"" manual]] for additional information.
**models/server.php**
<?php
class Server extends AppModel
var $name = "Server";
var $useTable = false;
?>
**views/servers/index.ctp**
<h1>Success!</h1>
**controllers/servers_controller.php**
<?php
class ServersController extends AppController {
var $name = "Servers";
function index() {}
?>
Create a new Wikka page and include your action (using the example in this tutorial, ##""{{caketest}}""##). Then, access your page. If you're successful, you'll be greeted with the following:
====== Success! ======
At this point, if you're ready to tackle a new Cake application, start with the extensive [[http://book.cakephp.org Cake documentation]]. The [[http://book.cakephp.org/view/1527/Tutorials-Examplesl Cake tutorial]] is an excellent hands-on project that lends itself easily to conversion to a WikkaCake app. I've also found [[http://debuggable.com/blog this blog]] to be an excellent source of information about Cake that's not covered by the Cake manual and API (search for """CakePHP""").
I will be posting a simple WikkaCake application I developed for the [[http://wiki.opennicproject.org OpenNIC]] wiki to track ""OpenNIC"" [[http://wiki.opennicproject.org/Tier2 OpenNIC public servers]]. It's based loosely upon the blog tutorial mentioned earlier.
Deletions:
=====Integrating Wikka and [[http://www.cakephp.org CakePHP]]=====
<<**See also:**
I believe the first three goals have been met (and my three dogs are still happy with me, so I'm confident goal #4 was met as well).
My development environment consists of Mac OSX 10.3.9, running the latest [[WikkaSVN trunk version]] of Wikka. The Cake version I'm currently using is 1.1.16.5421. Please be aware that Cake versions starting with 1.2 have significant API changes that may not be compatible with the setup instructions that follow. I have not tested this setup on Wikka 1.1.6.3 or earlier, but other than some directory restructuring, I see no reason why these instructions won't be applicable to earlier Wikka versions.
[[http://www.cakephp.org/downloads Download]] the latest 1.1.x version of Cake and use whatever method is appropriate for your system to unzip/untar the Cake distribution to your ##3rdparty/plugins## directory. As a matter of convenience, Unix/OSX users may want to either create a symlink to the cake distribution directory:
ln -s ./cake_1.1.16.5421 cake
mv cake_1.1.16.5421 cake
Cake is distributed with its own CSS stylesheet; many of the selectors conflict with the Wikka CSS selectors. As you will see shortly, there is a method that can be invoked in Wikka to include an external stylesheet in the ##<head>## section that's generated by Wikka. I would recommend, at a minimum, that the Cake default CSS file (located at ##3rdparty/plugins/cake/app/webroot/css/cake.generic.css##) be copied to your Wikka ##css## directory. Then, delete all sections but the section marked ##/*notices and errors*/##.
For Unix/OSX users:
Here are the steps you need to take. Other than creating your Cake application, this is probably the most complex process involved with Wikka/Cake integration. All of the following steps involve changes to ##webroot/index.php## unless otherwise specified. I recommend making a copy of this file as a backup you can refer to if you get lost.
define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(dirname(__FILE__)))).DS.'3rdparty'.DS.'plugins'.DS.'cake');
Due to the fact that Cake is running as an embedded app within Wikka, the base URL that Cake creates doesn't take into account the extra directory levels in which the Cake app resides. Therefore, the BASE_URL parameter must be set explicitly. Locate the closing brace, ##}##, immediately after the CAKE_CORE_INCLUDE_PATH line and add the following, replacing the URL with your Wikka's URL used to access the caketest action:
define('BASE_URL', 'http://alabaster.local/wikka-cake/CakeTest');
Assuming your controller is named ##servers_controller.php##, you will want your dispatch code to look like this (comment out the codeblock after ##require CORE_PATH . 'cake' . DS . 'bootstrap.php';## and add the following):
It is possible to test your configuration without having actually implemented a Cake application. Remember the dispatch code you commented out earlier? Go back and uncomment this block, then **comment out the dispatcher block you added**. Create a new Wikka page and include your action (using the example in this tutorial, ##""{{caketest}}""##). Then, access your page. If you're successful, you'll be greeted with the following:
Your database configuration file is present.
Cake is able to connect to the database.
along with some other information about Cake.
Congratulations!
At this point, if you're ready to tackle a new Cake application, start with the extensive [[http://manual.cakephp.org Cake documentation]]. The [[http://manual.cakephp.org/appendix/blog_tutorial Cake tutorial]] is an excellent hands-on project that lends itself easily to conversion to a WikkaCake app. I've also found the [[http://www.thinkingphp.org ThinkingPHP]] blog to be an excellent source of information about Cake that's not covered by the Cake manual and API.
I will be posting a simple WikkaCake application I developed for the [[http://opennic.jdcomputers.com.au OpenNIC]] wiki to track ""OpenNIC"" [[http://opennic.jdcomputers.com.au/VolunteerHosts public servers]]. It's based loosely upon the blog tutorial mentioned earlier.


Revision [21033]

Edited on 2010-02-15 15:30:28 by RolandStens [Updated for CakePHP 1.3]
Additions:
It is possible to test your configuration without having actually implemented a Cake application. Remember the dispatch code you commented out earlier? Go back and uncomment this block, then **comment out the dispatcher block you added**. Create a new Wikka page and include your action (using the example in this tutorial, ##""{{caketest}}""##). Then, access your page. If you're successful, you'll be greeted with the following:
Deletions:
It is possible to test your configuration without having actually implemented a Cake application. Remember the dispatch code you commented out earlier? Go back and uncomment this block, then **comment out the dispatcher block you added**. Create a new Wikka page and include your action (using the example in this tutorial, ##{{caketest}}##). Then, access your page. If you're successful, you'll be greeted with the following:


Revision [21032]

Edited on 2010-02-15 11:02:34 by BrianKoontz [Updated links]
Additions:
[[http://bakery.cakephp.org/articles/view/wikkacake-using-cakephp-as-an-embedded-framework The Bakery]] [[http://web.archive.org/web/20070819094408/http://bakery.cakephp.org/articles/view/wikkacake-using-cakephp-as-an-embedded-framework (archived version)]]<<
Deletions:
[[http://bakery.cakephp.org/articles/view/wikkacake-using-cakephp-as-an-embedded-framework The Bakery]]<<


Revision [21031]

Edited on 2010-02-15 10:49:10 by BrianKoontz [Updated links]
Additions:
<<**See also:**
WikkaCakeExample
[[http://blog.wikkawiki.org/2007/08/18/have-your-cakephp-and-eat-it-too/ Wikka Developer Blog]]
[[http://bakery.cakephp.org/articles/view/wikkacake-using-cakephp-as-an-embedded-framework The Bakery]]<<
Deletions:
<<**See also:** WikkaCakeExample<<


Revision [21030]

Edited on 2010-02-15 10:45:36 by BrianKoontz [Updated links]
Additions:
This is the "heart" of the Cake application, as the Dispatcher is what kicks off the Cake core engine. The problem here is that there is a conflict between the way Cake parses a URL (it expects a controller action as the URL target) and what Wikka expects (an action name as the URL target). Thanks to the [[http://debuggable.com/posts/learning-from-the-cakephp-source-code-part-i:480f4dd6-28d0-445e-a1dc-4ceacbdd56c work of]] [[http://debuggable.com/posts/learning-from-the-cakephp-source-code-part-ii:480f4dd6-57fc-4715-8709-439acbdd56cb Felix Geisendorfer]], we have an easy way of overriding the default Cake dispatch mechanism, allowing us to create a new Dispatcher and dispatch us to wherever we want to go. Since Wikka implements handlers as a URL extension (i.e., ##wikka/CakeTest/edit## invokes the Wikka editor on the ##CakeTest## page), we must use another mechanism to pass actions to Cake. I've chosen to use GET parameters (i.e., ##wikka/CakeTest?action=add##). By default, no GET parameters should invoke your controller's ##index()## method directly (don't worry if this doesn't make sense at the moment). Anything else passed as a GET parameter is a Cake action and should be dispatched as such.
Deletions:
This is the "heart" of the Cake application, as the Dispatcher is what kicks off the Cake core engine. The problem here is that there is a conflict between the way Cake parses a URL (it expects a controller action as the URL target) and what Wikka expects (an action name as the URL target). Thanks to the [[http://www.thinkingphp.org/2006/09/25/learning-from-the-cakephp-source-code-part-i/ work of Felix Geisendörfer]], we have an easy way of overriding the default Cake dispatch mechanism, allowing us to create a new Dispatcher and dispatch us to wherever we want to go. Since Wikka implements handlers as a URL extension (i.e., ##wikka/CakeTest/edit## invokes the Wikka editor on the ##CakeTest## page), we must use another mechanism to pass actions to Cake. I've chosen to use GET parameters (i.e., ##wikka/CakeTest?action=add##). By default, no GET parameters should invoke your controller's ##index()## method directly (don't worry if this doesn't make sense at the moment). Anything else passed as a GET parameter is a Cake action and should be dispatched as such.


Revision [19331]

Edited on 2008-01-28 00:15:21 by BrianKoontz [Modified links pointing to docs server]
Additions:
I advocate the use of Wikka as a [[Docs:FlexibleWikka presentation framework for rapid development]] of Internet-based applications. Wikka does a great job of handling user authentication, session tracking, and presentation, but does not offer much in the way of easily customizable, high-level database read/write access. Enter [[http://www.cakephp.org CakePHP]]: A rapid-development PHP framework that handles many of the low-level DB access details so you don't have to. While Cake itself offers similar framework functionality as Wikka, my goal was to implement a totally self-contained Cake application within Wikka. The look-and-feel would be all Wikka, while the Cake engine would provide a database abstraction layer independent of Wikka.
Deletions:
I advocate the use of Wikka as a [[FlexibleWikka presentation framework for rapid development]] of Internet-based applications. Wikka does a great job of handling user authentication, session tracking, and presentation, but does not offer much in the way of easily customizable, high-level database read/write access. Enter [[http://www.cakephp.org CakePHP]]: A rapid-development PHP framework that handles many of the low-level DB access details so you don't have to. While Cake itself offers similar framework functionality as Wikka, my goal was to implement a totally self-contained Cake application within Wikka. The look-and-feel would be all Wikka, while the Cake engine would provide a database abstraction layer independent of Wikka.


Revision [17407]

Edited on 2007-08-12 03:09:26 by BrianKoontz [Modified links pointing to docs server]
Additions:
<<**See also:** WikkaCakeExample<<


Revision [17406]

Edited on 2007-08-11 23:33:32 by BrianKoontz [added category]
Additions:
CategoryUserContributions


Revision [17405]

Edited on 2007-08-11 23:30:14 by BrianKoontz [minor edit]
Additions:
It's almost a certainty that **mod_rewrite MUST be enabled AND operational**. This is because Cake (much like Wikka) depends upon the structure of the URL to determine what action gets called. Since both Cake and Wikka (when mod_rewrite is enabled) depend on the same mechanism, there is an inherent conflict that must be resolved by some creative tinkering with the Cake dispatch mechanism. If that was just a bunch of Greek to you, trust me on this: You'll want mod_rewrite enabled!
Deletions:
It's almost a certainly that **mod_rewrite MUST be enabled AND operational**. This is because Cake (much like Wikka) depends upon the structure of the URL to determine what action gets called. Since both Cake and Wikka (when mod_rewrite is enabled) depend on the same mechanism, there is an inherent conflict that must be resolved by some creative tinkering with the Cake dispatch mechanism. If that was just a bunch of Greek to you, trust me on this: You'll want mod_rewrite enabled!


Revision [17404]

Edited on 2007-08-11 23:02:17 by BrianKoontz [minor edit]
Additions:
I will be posting a simple WikkaCake application I developed for the [[http://opennic.jdcomputers.com.au OpenNIC]] wiki to track ""OpenNIC"" [[http://opennic.jdcomputers.com.au/VolunteerHosts public servers]]. It's based loosely upon the blog tutorial mentioned earlier.
Deletions:
I will be posting a simple WikkaCake application I developed for the [[http://opennic.jdcomputers.com.au OpenNIC]] wiki to track ""OpenNIC''" [[http://opennic.jdcomputers.com.au/VolunteerHosts public servers]]. It's based loosely upon the blog tutorial mentioned earlier.


Revision [17403]

Edited on 2007-08-11 23:01:10 by BrianKoontz [minor edit]
Additions:
I will be posting a simple WikkaCake application I developed for the [[http://opennic.jdcomputers.com.au OpenNIC]] wiki to track ""OpenNIC''" [[http://opennic.jdcomputers.com.au/VolunteerHosts public servers]]. It's based loosely upon the blog tutorial mentioned earlier.
Deletions:
I will be posting a simple WikkaCake application I developed for the [[http://opennic.jdcomputers.com.au OpenNIC]] wiki to track ""OpenNIC'' [[http://opennic.jdcomputers.com.au/VolunteerHosts public servers]]. It's based loosely upon the blog tutorial mentioned earlier.


Revision [17402]

Edited on 2007-08-11 23:00:48 by BrianKoontz [minor edit]
Additions:
===Additional resources===
At this point, if you're ready to tackle a new Cake application, start with the extensive [[http://manual.cakephp.org Cake documentation]]. The [[http://manual.cakephp.org/appendix/blog_tutorial Cake tutorial]] is an excellent hands-on project that lends itself easily to conversion to a WikkaCake app. I've also found the [[http://www.thinkingphp.org ThinkingPHP]] blog to be an excellent source of information about Cake that's not covered by the Cake manual and API.
I will be posting a simple WikkaCake application I developed for the [[http://opennic.jdcomputers.com.au OpenNIC]] wiki to track ""OpenNIC'' [[http://opennic.jdcomputers.com.au/VolunteerHosts public servers]]. It's based loosely upon the blog tutorial mentioned earlier.
Have fun!


Revision [17401]

Edited on 2007-08-11 22:54:17 by BrianKoontz [minor edit]
Additions:
Assuming your controller is named ##servers_controller.php##, you will want your dispatch code to look like this (comment out the codeblock after ##require CORE_PATH . 'cake' . DS . 'bootstrap.php';## and add the following):
===Testing===
It is possible to test your configuration without having actually implemented a Cake application. Remember the dispatch code you commented out earlier? Go back and uncomment this block, then **comment out the dispatcher block you added**. Create a new Wikka page and include your action (using the example in this tutorial, ##{{caketest}}##). Then, access your page. If you're successful, you'll be greeted with the following:
Your database configuration file is present.
Cake is able to connect to the database.
along with some other information about Cake.
Congratulations!
Deletions:
Assuming your controller is named ##servers_controller.php##, you will want your dispatch code to look like this (replace the codeblock after ##require CORE_PATH . 'cake' . DS . 'bootstrap.php';## with the following):


Revision [17400]

Edited on 2007-08-11 22:49:08 by BrianKoontz [minor edit]
Additions:
Notice the ##""AddCustomHeader""## call? This is a Wikka hook that allows you to inject additional <meta> or <link> tags into the Wikka-generated <head> section on the output page. If you modified and copied the ##cake.generic.css## file using the instructions earlier, you will need to include this call in order to include the CSS file in your output. Otherwise, you can safely omit this line.
Deletions:
Notice the ##AddCustomHeader## call? This is a Wikka hook that allows you to inject additional <meta> or <link> tags into the Wikka-generated <head> section on the output page. If you modified and copied the ##cake.generic.css## file using the instructions earlier, you will need to include this call in order to include the CSS file in your output. Otherwise, you can safely omit this line.


Revision [17399]

Edited on 2007-08-11 22:48:42 by BrianKoontz [minor edit]
Additions:
define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(dirname(__FILE__)))).DS.'3rdparty'.DS.'plugins'.DS.'cake');
OK, now for a bit of chicanery. You should find a couple of lines towards the end of the file that look like this:
if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
} else {
$Dispatcher=new Dispatcher();
$Dispatcher->dispatch($url);
This is the "heart" of the Cake application, as the Dispatcher is what kicks off the Cake core engine. The problem here is that there is a conflict between the way Cake parses a URL (it expects a controller action as the URL target) and what Wikka expects (an action name as the URL target). Thanks to the [[http://www.thinkingphp.org/2006/09/25/learning-from-the-cakephp-source-code-part-i/ work of Felix Geisendörfer]], we have an easy way of overriding the default Cake dispatch mechanism, allowing us to create a new Dispatcher and dispatch us to wherever we want to go. Since Wikka implements handlers as a URL extension (i.e., ##wikka/CakeTest/edit## invokes the Wikka editor on the ##CakeTest## page), we must use another mechanism to pass actions to Cake. I've chosen to use GET parameters (i.e., ##wikka/CakeTest?action=add##). By default, no GET parameters should invoke your controller's ##index()## method directly (don't worry if this doesn't make sense at the moment). Anything else passed as a GET parameter is a Cake action and should be dispatched as such.
Assuming your controller is named ##servers_controller.php##, you will want your dispatch code to look like this (replace the codeblock after ##require CORE_PATH . 'cake' . DS . 'bootstrap.php';## with the following):
$Dispatcher = new Dispatcher();
$this->AddCustomHeader('<link rel="stylesheet" type="text/css" href="'.BASE_URL.DS.'..'.DS.'css'.DS.'cake.generic.css" />');
if(false===isset($_GET['action']))
{
$Dispatcher->dispatch('/servers/index', array('wakka'=>(object)$this));
}
else if(true===isset($_GET['action']))
{
$Dispatcher->dispatch('/servers/'.$_GET['action'], array('wakka'=>(object)$this));
}
This might not make much sense to you if you're learning Cake as you go. My suggestion would be to create a simple Cake application (the [[http://manual.cakephp.org/appendix/blog_tutorial Cake tutorial]] is an excellent place to start), get it working as a standalone app, and then simply copy everything under your ##app## directory to your ##caketest## action.
Notice the ##AddCustomHeader## call? This is a Wikka hook that allows you to inject additional <meta> or <link> tags into the Wikka-generated <head> section on the output page. If you modified and copied the ##cake.generic.css## file using the instructions earlier, you will need to include this call in order to include the CSS file in your output. Otherwise, you can safely omit this line.
===Database configuration===
Ideally, your new embedded Cake app would use the DB access credentials in ##wikka.config.php##. Since I've not figured out how to best do this in a secure manner, you'll need to configure your DB access credentials in the Cake-supplied ##config/database.php## file (simply copy ##config/database.php.default## to ##config/database.php## and edit). This file should be self-explanatory; only the ##$default## configuration needs to be modified.
Deletions:
define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(dirname(__FILE__)))).DS.'3rdparty'.DS.'plugins');


Revision [17398]

Edited on 2007-08-11 22:22:23 by BrianKoontz [minor edit]
Additions:
Here are the steps you need to take. Other than creating your Cake application, this is probably the most complex process involved with Wikka/Cake integration. All of the following steps involve changes to ##webroot/index.php## unless otherwise specified. I recommend making a copy of this file as a backup you can refer to if you get lost.
Locate the line beginning with ##define('ROOT'...)##, comment it out, and create a new line:
//define('ROOT', dirname(dirname(dirname(__FILE__))));
define('ROOT', dirname(dirname(__FILE__)));
Next, locate the line beginning with ##define('APP_DIR'...)##, comment out and modify:
//define('APP_DIR', 'DIRECTORY NAME OF APPLICATION';
define('APP_DIR', '.');
Comment out/modify CAKE_CORE_INCLUDE_PATH:
//define('CAKE_CORE_INCLUDE_PATH', ROOT);
define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(dirname(__FILE__)))).DS.'3rdparty'.DS.'plugins');
Due to the fact that Cake is running as an embedded app within Wikka, the base URL that Cake creates doesn't take into account the extra directory levels in which the Cake app resides. Therefore, the BASE_URL parameter must be set explicitly. Locate the closing brace, ##}##, immediately after the CAKE_CORE_INCLUDE_PATH line and add the following, replacing the URL with your Wikka's URL used to access the caketest action:
if (!defined('BASE_URL'))
{
define('BASE_URL', 'http://alabaster.local/wikka-cake/CakeTest');
}


Revision [17397]

Edited on 2007-08-11 22:08:59 by BrianKoontz [minor edit]
Additions:
Much of the agony involved with any customized Cake application involves the correct configuration of directories. Wikka itself is also very directory-oriented, so it's doubly important to get this right. There are probably any number of ways this can be accomplished, so my way is not necessarily the only or the best way.
The ##app## directory under your ##3rdparty/plugins/cake## directory contains everything you need to get started. So, the easiest thing to do is simply copy the **contents** of the ##app## directory into the new directory you've created for your action. For instance, if your new action will be called "caketest", then you'll first want to create that directory under ##actions##. Then, copy the **contents** of ##3rdparty/plugins/cake/app## into this newly-created directory.
For Unix/OSX users:
mkdir actions/caketest
cp -pR 3rdparty/plugins/cake/app/* actions/caketest/
If you've done this correctly, there should **not** be a directory named ##app## under ##actions/caketest##! If there is, your action will not work correctly under Wikka.
Wikka expects a PHP file under ##actions/caketest## with the name of ##caketest.php##. Simply copy ##actions/caketest/index.php## to ##actions/caketest/caketest.php##.
The normal entry point for a Cake application is ##webroot/index.php##. You'll notice that ##actions/caketest/index.php## redirects to this webroot file. The webroot ##index.php## file is where initial Cake configuration is accomplished, so setting this up correctly is critical.
Deletions:
Much of the agony involved with any customized Cake application involves the correct configuration of directories. Wikka itself is also very d


Revision [17396]

Edited on 2007-08-11 22:00:48 by BrianKoontz [minor edit]
Additions:
===Project platform===
My development environment consists of Mac OSX 10.3.9, running the latest [[WikkaSVN trunk version]] of Wikka. The Cake version I'm currently using is 1.1.16.5421. Please be aware that Cake versions starting with 1.2 have significant API changes that may not be compatible with the setup instructions that follow. I have not tested this setup on Wikka 1.1.6.3 or earlier, but other than some directory restructuring, I see no reason why these instructions won't be applicable to earlier Wikka versions.
It's almost a certainly that **mod_rewrite MUST be enabled AND operational**. This is because Cake (much like Wikka) depends upon the structure of the URL to determine what action gets called. Since both Cake and Wikka (when mod_rewrite is enabled) depend on the same mechanism, there is an inherent conflict that must be resolved by some creative tinkering with the Cake dispatch mechanism. If that was just a bunch of Greek to you, trust me on this: You'll want mod_rewrite enabled!
===Installing Cake===
[[http://www.cakephp.org/downloads Download]] the latest 1.1.x version of Cake and use whatever method is appropriate for your system to unzip/untar the Cake distribution to your ##3rdparty/plugins## directory. As a matter of convenience, Unix/OSX users may want to either create a symlink to the cake distribution directory:
%%
ln -s ./cake_1.1.16.5421 cake
%%
or simply rename the directory:
%%
mv cake_1.1.16.5421 cake
%%
Windows users will have to opt for choice #2, as Windows does not support symlinks.
Cake is distributed with its own CSS stylesheet; many of the selectors conflict with the Wikka CSS selectors. As you will see shortly, there is a method that can be invoked in Wikka to include an external stylesheet in the ##<head>## section that's generated by Wikka. I would recommend, at a minimum, that the Cake default CSS file (located at ##3rdparty/plugins/cake/app/webroot/css/cake.generic.css##) be copied to your Wikka ##css## directory. Then, delete all sections but the section marked ##/*notices and errors*/##.
(If you decide you don't want to do this, there's a strong likelihood you will not see the error messages generated by the Cake built-in data validation methods!)
===Setting up a Cake application as a Wikka action===
Much of the agony involved with any customized Cake application involves the correct configuration of directories. Wikka itself is also very d
Deletions:
===


Revision [17395]

Edited on 2007-08-11 21:35:44 by BrianKoontz [minor edit]
Additions:
=====Integrating Wikka and [[http://www.cakephp.org CakePHP]]=====
Deletions:
=====Integrating Wikka and CakePHP=====


Revision [17394]

The oldest known version of this page was created on 2007-08-11 21:34:51 by BrianKoontz [minor edit]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki