1
Saganxis
An aproach with Xoops and Cakephp
  • 2007/6/22 20:55

  • Saganxis

  • Just popping in

  • Posts: 25

  • Since: 2006/7/20


Hace tiempo que estoy queriendo hacer alguna interfaz de XOOPS con
algún framework conocido, como lo es Cakephp. Busqué bastante si
alguien habia hecho algo con XOOPS y Cakephp y la verdad no encontré nada.
Lo que si encontré fueron algunos artículos muy
interesantes como

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/

y

http://www.gigapromoters.com/blog/2007/02/13/finally-a-practical-solution-joomla-with-cakephp-together-jake/


entonces empecé a intentar crear un puente propio para Xoops.

Aqui les cuento lo que hice. Claro que esto es solo una prueba por lo cual hay muchas cosas por hacer.

Les comento que lo que hice fue seguir la explicación de Jake en sus comienzos y descargando su ejemplo, pude armar este paquete para Xoops.
Por ello quizá los interesados puedan ayudar para que esto tome más forma.

Lo que intenté hacer fue una especie de modulo que contenga a cakephp dentro del directorio principal donde está Xoops.

A este pequeño proyecto lo llamé Koops.

Pueden bajarlo de

AQUI
###############################################
IMPORTANTE:

Ver que el mod_rewrite este habilitado en el apache y correctamente configurado.

###############################################


Los directorios están dispuestos de la siguiente manera:


wwwroot
xoops
cache
class
...
koops
...
y sigue...


1 )


Modificar el archivo header.php del directorio principal de Xoops

Le agregué al final una linea como la siguiente:


require_once( 'koops/cake.php');


Claro está que aqui podemos modificar el directorio en donde se incluirá koops.
Pero despues hay que tener en cuenta las variables de ROOT_PATH para Cakephp.


2 )

Dentro de koops copiamos todo el directorio que contiene a Cakephp.
Quedaría de la siguiente forma:

koops/
app
cake
index.php
...


3 )


Dentro de koops/app/webroot/index.php comentar las dos lineas que siguen:

...

if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
} else {
// $Dispatcher=new Dispatcher();
// $Dispatcher->dispatch($url);
}

....


Luego hay que hacer un trigger que una cake y Xoops. Creamos en el directorio /koops
los archivos cake.php y cake.inc.php:

cake.php

<?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);


?>


y cake.inc.php


<?php

class HTML_cake {

function requestCakePHP($url)
{
$_GET['url']=$url;
require_once ('app/webroot/index.php');

$Dispatcher=new Dispatcher();
$Dispatcher->dispatch($url);


}

}

?>

esto manejará qué controlador/acción/vista le va a llegar a Cakephp.

En este punto el directorio quedaría:



koops/
app
cake
index.php
cake.php
cake.inc.php
...


4 )

Luego en koops/app/config/ modifico/creo los siguiente archivos

bootstrap.php

<?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;
}
?>

con el fin de que interprete y modifique las url que necesita Cakephp.


En el archivo /koops/app/config/core.php seteamos

define('AUTO_SESSION', false);

para que el control de la sesion lo siga haciendo Xoops.



En koops/app/config/database.php

<?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 )

Con esto bastaría por ahora. El el archivo para descargar incluyo un ejemplo.

Para usarlo solo necesitan crear una tabla 'names'
con los campos

id
names


Luego para usarlo

http://localhost/index.php?option=names&task=index


Eso es todo. Esto es solo una primera aproximación. Los interesados serán
bienvenidos, y las sugerencias por supuesto también.


Si alguien pudiese traducirlo al ingles se lo agradecería porque mi ingles no es muy bueno.

Saludos,

Saganxis

2
Anonymous
Re: An aproach with Xoops and Cakephp
  • 2007/6/22 21:25

  • Anonymous

  • Posts: 0

  • Since:


Sorry, but I can't resist this....

Qué?

3
bleu_
Re: An aproach with Xoops and Cakephp
  • 2007/6/23 6:57

  • bleu_

  • Just popping in

  • Posts: 32

  • Since: 2006/8/1 2


A translation to Saganxis post, NOT done by a translator software but by a human being


Since 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 :
<?php

require_once("cake.inc.php");
$xoops_path dirnamedirname__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

<?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

<?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

<?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=index

That's all. This is only an approximation. Those who are interested are welcome, and suggestions also.

4
instantzero
Re: An aproach with Xoops and Cakephp

Hello,

This is very interesting.
CakePhp is an important Framework (and very professional), I really hope that this kind of initiative will be considered.

5
Saganxis
Re: An aproach with Xoops and Cakephp
  • 2007/6/23 13:10

  • Saganxis

  • Just popping in

  • Posts: 25

  • Since: 2006/7/20


Thanks you very muck bleu_ for the traslation.

6
Saganxis
Re: An aproach with Xoops and Cakephp
  • 2007/6/23 13:25

  • Saganxis

  • Just popping in

  • Posts: 25

  • Since: 2006/7/20


I'm really don't know if Cakephp is the best option for Xoops. There are a lot of frameworks which are very interesting like symphony, kumbia, qcodo, etc. This is just an attempt to use XOOPS with a framework.

Login

Who's Online

224 user(s) are online (159 user(s) are browsing Support Forums)


Members: 0


Guests: 224


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits