Revision history for WikkaCakeExample


Revision [23467]

Last edited on 2016-05-20 07:38:48 by BrianKoontz [Replaces old-style internal links with new pipe-split links.]
Additions:
If you have yet to read the WikkaCake page, I'd suggest starting there first. This is actually an extension of that page, and provides an example of a completely self-contained Wikka action that has been written using the [[http://www.cakephp.org | CakePHP]] framework. This is not a Cake tutorial. Instead, I will simply provide the code as-is and provide comments that are Wikka-specific.
This application is a simple database management app for saving, modifying, and deleting servers. It was developed for managing the public nameserver DB on the [[http://opennic.jdcomputers.com.au | OpenNIC wiki]]. A publicly accessible version will be available shortly once testing is completed.
So, there you have it! A functioning DB application using Wikka as the presentation framework and [[http://www.cakephp.org | CakePHP]] as a modular MVC framework. Once one removes the ##config/database.php## file, this could be zipped/tarred up and distributed as a plugin action.
Deletions:
If you have yet to read the WikkaCake page, I'd suggest starting there first. This is actually an extension of that page, and provides an example of a completely self-contained Wikka action that has been written using the [[http://www.cakephp.org CakePHP]] framework. This is not a Cake tutorial. Instead, I will simply provide the code as-is and provide comments that are Wikka-specific.
This application is a simple database management app for saving, modifying, and deleting servers. It was developed for managing the public nameserver DB on the [[http://opennic.jdcomputers.com.au OpenNIC wiki]]. A publicly accessible version will be available shortly once testing is completed.
So, there you have it! A functioning DB application using Wikka as the presentation framework and [[http://www.cakephp.org CakePHP]] as a modular MVC framework. Once one removes the ##config/database.php## file, this could be zipped/tarred up and distributed as a plugin action.


Revision [21311]

Edited on 2010-12-30 02:59:14 by BrianKoontz [deprecated]
Additions:
This example assumes ""CakePHP"" 1.1. An updated version for WikkaCake 1.3 is in the works.
Deletions:
This example assumes CakePHP 1.1. An updated version for WikkaCake 1.3 is in the works.


Revision [21310]

Edited on 2010-12-30 02:58:54 by BrianKoontz [deprecated]
Additions:
<<**{{color c="red" text="This page is deprecated."}}**
Deletions:
<<**{{color c="red" text="This page is deprecated."}}


Revision [21309]

Edited on 2010-12-30 02:58:33 by BrianKoontz [deprecated]
Additions:
<<**{{color c="red" text="This page is deprecated."}}
This example assumes CakePHP 1.1. An updated version for WikkaCake 1.3 is in the works.
**See also:** WikkaCake<<
Deletions:
<<**See also:** WikkaCake<<


Revision [19332]

Edited on 2008-01-28 00:15:21 by BrianKoontz [Modified links pointing to docs server]

No Differences

Revision [17410]

Edited on 2007-08-12 03:45:50 by BrianKoontz [Modified links pointing to docs server]
Additions:
//Comments:// Note that the Wikka instance is accessible in the views for whatever you might need it for. Also, because of the conflicting way in which Wikka and Cake handle the parsing of URLs, links must be generated using the format shown above. Attempting to format Cake links as per the Cake manual is sure to lead to abject failure.
**views/servers/add.thtml**
<h1>Add Server</h1>
<form method="post" action="<?php echo $html->base; ?>?action=add">
<p>
IP Addr:
<?php echo $html->input('Server/ip_addr', array('size'=>'15')) ?>
<?php echo $html->tagErrorMsg('Server/ip_addr', 'IP address is required.') ?>
</p><p>
Owner:
<?php echo $html->input('Server/owner', array('size'=>'50')) ?>
<?php echo $html->tagErrorMsg('Server/owner', 'Owner is required.') ?>
</p><p>
City:
<?php echo $html->input('Server/city', array('size'=>'50')) ?>
</p><p>
State/Province:
<?php echo $html->input('Server/state', array('size'=>'2')) ?>
</p><p>
Country:
<?php echo $html->input('Server/country', array('size'=>'2')) ?>
<?php echo $html->tagErrorMsg('Server/country', 'Country is required.') ?>
</p><p>
Email (will be obfuscated):
<?php echo $html->input('Server/email', array('size'=>'50')) ?>
</p><p>
Comments:
<?php echo $html->textarea('Server/comments', array('rows'=>'2')) ?>
</p><p>
<?php echo $html->submit('Save') ?>
<?php echo $html->submit('Cancel', array('name'=>'data[Servers][action]')) ?>
</p></form>
//Comments:// Handling the Cancel buttons was somewhat tricky.
**views/servers/modify.thtml**
<h1>Modify Server</h1>
<form method="post" action="<?php echo $html->base; ?>?action=modify">
<?php echo $html->hidden('Server/id'); ?>
<p>
IP Addr:
<?php echo $html->input('Server/ip_addr', array('size'=>'15')) ?>
<?php echo $html->tagErrorMsg('Server/ip_addr', 'IP address is required.') ?>
</p><p>
Owner:
<?php echo $html->input('Server/owner', array('size'=>'50')) ?>
<?php echo $html->tagErrorMsg('Server/owner', 'Owner is required.') ?>
</p><p>
City:
<?php echo $html->input('Server/city', array('size'=>'50')) ?>
</p><p>
State/Province:
<?php echo $html->input('Server/state', array('size'=>'2')) ?>
</p><p>
Country:
<?php echo $html->input('Server/country', array('size'=>'2')) ?>
<?php echo $html->tagErrorMsg('Server/country', 'Country is required.') ?>
</p><p>
Email (will be obfuscated):
<?php echo $html->input('Server/email', array('size'=>'50')) ?>
</p><p>
Comments:
<?php echo $html->textarea('Server/comments', array('rows'=>'2')) ?>
</p><p>
<?php echo $html->submit('Save') ?>
<?php echo $html->submit('Cancel', array('name'=>'data[Servers][action]')) ?>
</p></form>
//Comments:// Straightforward, using the same trick as in ##add.thtml## to differentiate between Save and Cancel button clicks.
===Summary===
So, there you have it! A functioning DB application using Wikka as the presentation framework and [[http://www.cakephp.org CakePHP]] as a modular MVC framework. Once one removes the ##config/database.php## file, this could be zipped/tarred up and distributed as a plugin action.
Deletions:
//Comments://


Revision [17409]

Edited on 2007-08-12 03:36:27 by BrianKoontz [Modified links pointing to docs server]
Additions:
%%(php)
%%(sql)
%%(php)
%%(php)
//Comments:// Look back at the changes you made in your ##webroot/index.php## code. Remember this?
%%(php)
array('wakka'=>(object)$this)
That is how the Wikka instance is passed into the Cake framework so it's accessible in the controller (where the business logic resides). The commented-out construction above indicates that due to the way the Cake core libraries are bootstrapped, the Wikka instance isn't available until *after* the constructor has been called. Nor can it be set as a ##var## (since only static assignments can be made to ##var##-declared variables). So you'll need to call your Wikka lib functions within each method from which you need access.
I could have chosen to use the data filters provided by Wikka, but for simplicity sake I used the Cake built-in "sanitize" class. Also, note that the ##$this->flash(...)## call doesn't redirect properly due to some interaction between Wikka and Cake. The link displays just fine, but one has to actually click the link for the redirect to occur.
**views/layouts/default.thtml**
%%(html)
<?php echo $content_for_layout; ?>
//Comments:// We don't want Cake to output any additional HTML <head> sections, as this is already handled by Wikka.
**views/servers/index.thtml**
%%(html)
<h1>Public Access Servers</h1>
<br/>
<table border="1">
<tr>
<?php if(true===$this->params['wakka']->IsAdmin()): ?>
<th></th>
<?php endif; ?>
<th>IP Addr</th>
<th>InterNIC Hostname</th>
<th>OpenNIC Hostname</th>
<th>Owner</th>
<th>City</th>
<th>State</th>
<th>Country</th>
<th>Email</th>
<th>Last Verified</th>
<th>Comments</th>
</tr>
<?php foreach ($servers as $server): ?>
<tr>
<?php if(true===$this->params['wakka']->IsAdmin()): ?>
<td><a class="keys" href="<?php echo $html->base.'?action=delete&id='.$server['Server']['id'] ?>">X</a> 
<a class="keys" href="<?php echo $html->base.'?action=modify&id='.$server['Server']['id'] ?>">M</a></td>
<?php endif; ?>
<td><?php echo $server['Server']['ip_addr']; ?></td>
<td><?php echo $server['Server']['internic_hn']; ?></td>
<td><?php echo $server['Server']['opennic_hn']; ?></td>
<td><?php echo $server['Server']['owner']; ?></td>
<td><?php echo $server['Server']['city']; ?></td>
<td><?php echo $server['Server']['state']; ?></td>
<td><?php echo $server['Server']['country']; ?></td>
<td><?php echo preg_replace('/@/', ' <at> ', $server['Server']['email']); ?></td>
<td><?php echo $server['Server']['last_verified']; ?></td>
<td><?php echo $server['Server']['comments']; ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php
if(true===$this->params['wakka']->IsAdmin())
echo $html->link('Add server', $html->base.'?action=add');
//Comments://


Revision [17408]

The oldest known version of this page was created on 2007-08-12 03:25:38 by BrianKoontz [Modified links pointing to docs server]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki