Forum Index   -   Topic Index
   Modules
     Bake modules for XOOPS with CakePHP
Register To Post

Threaded | Newest First Previous Topic | Next Topic | Bottom
Poster Thread
kiang
Posted on: 2007/11/24 9:48
Just popping in
Joined: 2005/12/31
From:
Posts: 14
Bake modules for XOOPS with CakePHP
I've posted this article in XOOPS. Maybe somebody here also intereated. :)

---

This article will tell you how to build up modules for XOOPS with bake. :)

Enviornments:
Windows XP Pro SP2
XAMPP 1.6.0a / PHP Version 5.2.4
CakePHP 1.2.0.5875 pre-beta
XOOPS 2.0.17.1
PDT 1.0

1. Setup XOOPS in XAMPP, open a project in PDT and point the workspace to the root of XOOPS.
2. Download and exact Cake 1.2, move the cake folder into the root of XOOPS (D:\xampp\htdocs\xoops\cake)
3. Open PDT,
Run -> External Tools -> Open External Tools Dialog
In Program, add one item
Quote:
Name : BakeXOOPS
Main->Location: D:\xampp\php\php.exe
Working Directory: ${workspace_loc:/xoops/cake/console}
Arguments: cake.php bake -working ../../modules/test/


*The name 'test' is the module name you want to build.
4. Execute BakeXOOPS twice to have basic skeleton of cake and setup database for the new module(test).
5. Open http://localhost/xoops/modules/test/ in your browser to see if cake works in test module.
6. Modify xoops/modules/test/webroot/index.php , in the beginning add the following lines:

    $xoops_path = dirname( dirname(dirname( dirname( __FILE__ ))));
    require_once( $xoops_path . '/mainfile.php' );
    include XOOPS_ROOT_PATH."/header.php";


And at the end:

    include XOOPS_ROOT_PATH."/footer.php";


7. Modify xoops/modules/test/views/layouts/default.ctp , the results:

<?php
global $xoopsTpl;
$xoopsTpl->assign('xoops_module_header', $html->css('cake.generic') . $scripts_for_layout);
if ($session->check('Message.flash')):
    $session->flash();
endif;
echo $content_for_layout;
echo $cakeDebug;


8. Modify xoops/modules/test/webroot/css/cake.generic.css , Try to remove conflict lines , the results:

table tr.altrow td {
	background: #f4f4f4;
}
td.actions {
	text-align: center;
	white-space: nowrap;
}
td.actions a {
	display: inline;
	margin: 0px 6px;
}
.cakeSqlLog table {
	background: #f4f4f4;
}
.cakeSqlLog td {
	padding: 4px 8px;
	text-align: left;
}

/* Paging */
div.paging {
	color: #ccc;
	margin-bottom: 2em;
}
div.paging div.disabled {
	color: #ddd;
	display: inline;
}

/* Notices and Errors */
div.message {
	clear: both;
	color: #900;
	font-size: 140%;
	font-weight: bold;
	margin: 1em 0;
}
div.error-message {
	clear: both;
	color: #900;
	font-weight: bold;
}
div.error em {
	font-size: 140%;
	color: #003d4c;
}
span.notice {
	background-color: #c6c65b;
	color: #fff;
	display: block;
	font-size: 140%;
	padding: 0.5em;
	margin: 1em 0;
}
/*  Actions  */
div.index div.actions {
	clear: both;
	margin-top: .4em;
	text-align: left;
}
div.view div.actions {
	clear: both;
	margin-top: .4em;
	text-align: left;
	width: 60%;
}
div.actions ul {
	margin: 0px 0;
	padding: 0;
}
div.actions li {
	display: inline;
	list-style-type: none;
	line-height: 2em;
	margin: 0 2em 0 0;
	white-space: nowrap;
}
div.actions ul li a {
	color: #003d4c;
	text-decoration: none;
}
div.actions ul li a:hover {
	color: #333;
	text-decoration: underline;
}

/* Related */
div.related {
	clear: both;
	display: block;
}

/* Debugging */
pre.cake-debug {
	background: #ffcc00;
	font-size: 120%;
	line-height: 18px;
	margin: 4px 2px;
	overflow: auto;
	position: relative;
}
div.cake-stack-trace {
	background: #fff;
	color: #333;
	margin: 4px 2px;
	padding: 4px;
	font-size: 120%;
	line-height: 18px;
	overflow: auto;
	position: relative;
}
div.cake-code-dump pre {
	position: relative;
	overflow: auto;
}
div.cake-stack-trace pre, div.cake-code-dump pre {
	color: #000000;
	background-color: #F0F0F0;
	border: 1px dotted #606060;
	margin: 4px 2px;
	padding: 4px;
	overflow: auto;
}
div.cake-code-dump pre, div.cake-code-dump pre code {
	clear: both;
	font-size: 12px;
	line-height: 5px;
	margin: 4px 2px;
	padding: 4px;
	overflow: auto;
}
div.cake-code-dump span.code-highlight {
	background-color: #FFFF00;
}


9. Modify xoops/modules/test/config/database.php , the results:

<?php
if(!isset($xoopsOption)) {
    $xoopsOption['nocommon'] = 1;
    $xoops_path = dirname( dirname(dirname( dirname( __FILE__ ))));
    require_once( $xoops_path . '/mainfile.php' );
}
define('CAKE_DB_PREFIX', XOOPS_DB_PREFIX . '_');
class DATABASE_CONFIG {

    var $default = array(
        'driver' => XOOPS_DB_TYPE,
        'persistent' => false,
        'host' => XOOPS_DB_HOST,
        'port' => '',
        'login' => XOOPS_DB_USER,
        'password' => XOOPS_DB_PASS,
        'database' => XOOPS_DB_NAME,
        'schema' => '',
        'prefix' => CAKE_DB_PREFIX,
        'encoding' => ''
    );
}


10. Modify xoops/modules/test/config/core.php

Disable this setting:
Configure::write('Session.start', true); 


11. Modify the cache setting in xoops/modules/test/config/core.php

	Cache::config('default',array(
	'engine' => 'File',
	'path' => XOOPS_ROOT_PATH . '/cache',
	'prefix' => 'cake_'
	));


12. Modify xoops/cake/libs/cache/file.php
Disable line 79:
$this->settings['path'] = $this->__File->Folder->cd($this->settings['path']);


13. Then you could start baking modules. :)

Known problems:
1. In xoops_version.php of the module, I can't use $modversion['sub'] to add submenu as other modules of XOOPS.
2. Sometimes I met blank page, switch the debug setting or refresh the page could bring me correct results.
3. I can't turn on the debug settings in both at the same time.
4. I met many problems about variable scope, it's not the same as building XOOPS modules like past.
5. "Never" using the results in production without taking care more, more, ... and more.
onokazu
Posted on: 2007/11/25 17:34
Just can't stay away
Joined: 2005/9/19
From:
Posts: 107
Re: Bake modules for XOOPS with CakePHP
That actually is a very interesting article. As long as the XOOPS/Cube core does not try to force too many things on the module side, we can use any web application framework to develop modules.
onokazu
Posted on: 2007/11/25 23:49
Just can't stay away
Joined: 2005/9/19
From:
Posts: 107
Re: Bake modules for XOOPS with CakePHP
You could've made this an article for Xigg, by the way.
gigamaster
Posted on: 2007/11/28 3:00
Home away from home
Joined: 2005/12/30
From: Switzerland
Posts: 1227
Re: Bake modules for XOOPS with CakePHP


It can always be moved to xigg and as a tutorial to wiki!
whatever you decide it would be nice to give it a try ^^


----------------
Xoops Cube Support

MAC OSX - Apache 2.2 - MySQL 5.5 - PHP 5.3
Free BSD - Apache 2.2 - MySQL 5.5 - PHP 5.2

einstein
Posted on: 2007/11/28 6:58
Not too shy to talk
Joined: 2006/5/6
From: Brazil
Posts: 37
Re: Bake modules for XOOPS with CakePHP
Can I use the xoops group permissions on these baked modules?
kiang
Posted on: 2007/11/30 13:38
Just popping in
Joined: 2005/12/31
From:
Posts: 14
Re: Bake modules for XOOPS with CakePHP
Quote:

einstein wrote:
Can I use the xoops group permissions on these baked modules?

You could always use it as you wish. Just need some time to study.
kiang
Posted on: 2007/11/30 13:41
Just popping in
Joined: 2005/12/31
From:
Posts: 14
Re: Bake modules for XOOPS with CakePHP
The reason I posted the article in forum is that I tested with XOOPS only. Maybe somebody could give it a try in XOOPSCUBE and post a news here. :)
kiang
Posted on: 2007/12/2 13:20
Just popping in
Joined: 2005/12/31
From:
Posts: 14
Re: Bake modules for XOOPS with CakePHP
Let's talk about relative topics here:
http://groups.google.com/group/cakephpxoops

:)
Threaded | Newest First Previous Topic | Next Topic | Top

Register To Post
 

Who's Online
18 user(s) are online (8 user(s) are browsing Forums)

Members: 0
Guests: 18

more...

Welcome | News | Overview | Documentation | Forum | Tutorialstop
Brasilian | French | German | Greek | Japanese | Korean | Russian | T-Chinese
Powered by XOOPS Cube © 2001-2011 The XOOPS Cube Project