A translation to Saganxis post, NOT done by a translator software but by a human beingSince some time ago I've been wanting to to do an interface with XOOPS with a known framework, like Cakephp. I searched alot if someone had done something with XOOPS and Cakephp and I couldn't find anything.
What I did find was several interesting articles like:
http://www.gigapromoters.com/blog/2007/01/28/joining-powers-of-two-great-systems-joomla-and-cakephp/http://www.thinkingphp.org/2006/05/04/using-cakephp-in-external-php-systems-cmss-weblogs-etc/and
http://www.gigapromoters.com/blog/2007/02/13/finally-a-practical-solution-joomla-with-cakephp-together-jake/so I started trying to create a bridge for XOOPS.
I will tell you here what I did. Of course this is just an expermiment/try so therefore there are many things left to do.
I explain to you that what I tried to do was follow the explanation of Jake in his initiation to this and downloading his example, and from that I was able to build this package for XOOPS,
Those who are interested can help for this to get a better a structure.
What I tried to do was a sort of module that contained Cakephp inside the main directory where XOOPS is.
This small project was named Koops.
You can download it from
HERE###############################################
IMPORTANT:
Make sure that mod_rewrite is set to True in the Apache, and configured correctly
###############################################
The directories are set this way:
wwwroot
xoops
cache
class
...
koops
...
an so on...
1 )
Modify the file header.php of the main XOOPS directory
Adding at the end the following line:
require_once( 'koops/cake.php');
We can of course modify here the directory where koops will be included, but afterwards we must have in mind the ROOT_PATH variables for Cakephp.
2 )
Inside koops we copy all that is contained in the Cakephp directory.
It would result this way:
koops/
app
cake
index.php
...
3 )
Inside koops/app/webroot/index.php comment the two following lines:
...
if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
} else {
// $Dispatcher=new Dispatcher();
// $Dispatcher->dispatch($url);
}
....
Then a trigger has to be made to unite cake and XOOPS. Create en the directory /koops
the archives cake.php and cake.inc.php:
cake.php :
require_once("cake.inc.php");
$xoops_path = dirname( dirname( __FILE__ ) );
require_once( $xoops_path . '/mainfile.php' );
$controller= $_GET['option'];
$action=$_GET['task'];
$param = $_GET[ 'id' ];
HTML_cake::requestCakePHP('/'.$controller.'/'.$action.'/'.$param);
?>
and cake.inc.php
class HTML_cake {
function requestCakePHP($url)
{
$_GET['url']=$url;
require_once ('app/webroot/index.php');
$Dispatcher=new Dispatcher();
$Dispatcher->dispatch($url);
}
}
?>
This will manage that controlador/acción/vista will reach Cakephp.
At this point the directory will look like this:
koops/
app
cake
index.php
cake.php
cake.inc.php
...
4 )
Then in koops/app/config/ modifico/ create the following files:
bootstrap.php
function reform_url($url)
{
$temp=explode('/',$url);
$controller=$temp[1];
$action=$temp[2];
$param=@$temp[3];
$url=XOOPS_URL.'/index.php?option='.$controller.'&task='.$action;
if($param)
$url=$url.'&id='.$param;
return $url;
}
?>
With the aim that it interprets and modifies the URL's that Cakephp needs.
In the following file: /koops/app/config/core.php
We configure this:
define('AUTO_SESSION', false);
So the session control is still being kept done by XOOPS.
In koops/app/config/database.php
class DATABASE_CONFIG
{
var $default = array('driver' => XOOPS_DB_TYPE,
'connect' => 'mysql_connect',
'host' => XOOPS_DB_HOST,
'login' => XOOPS_DB_USER,
'password' => XOOPS_DB_PASS,
'database' => XOOPS_DB_NAME,
'prefix' => 'yourprefix_' );
}
?>
5 )
With this it would be enough for now. The download archive includes an example.
To use it all you have to do is create a table 'names' with the following fields:
id
names
Then to use it:
http://localhost/index.php?option=names&task=indexThat's all. This is only an approximation. Those who are interested are welcome, and suggestions also.