Firefox PHP

System for embedding Phorum in other applications (early preview)

Posted by Maurice Makaay 
System for embedding Phorum in other applications (early preview)
February 04, 2006 03:58AM
THIS MODULE IS STILL UNDER HEAVY DEVELOPMENT. THIS IS AN EARLY RELEASE
TO SHOW THOSE WHO ARE INTERESTED IN EMBEDDING PHORUM WHAT I'M DOING IN
THIS FIELD. THE EMBEDDING CODE IS WORKING PRETTY GOOD, BUT THERE'S
CURRENTLY A LOCK OF GOOD FINISHED CONNECTORS FOR EMBEDDING PHORUM IN
3rd PARTY APPS.

This module implements functionality for creating an embedded version of Phorum. Embedded means that Phorum will be the slave of a master system. The master system is responsible for feeding the Phorum system with user data and for processing page elements that are produced by Phorum. Since Phorum is a slave application in this setup, things like signup, authentication and settings are no longer handled by Phorum.

Please check the README file in the package for some more information about this project.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce



Edited 13 time(s). Last edit at 05/31/2007 07:12PM by mmakaay.
Attachments:
open | download - embed_phorum-0.0.20_Phorum5.1.tar.gz (73.8 KB)
open | download - embed_phorum-0.0.20_Phorum5.1.zip (133.1 KB)
Re: System for embedding Phorum in other applications (early preview)
February 04, 2006 04:02AM
I'll check this out for sure.
Thanks for the fast alpha/beta preview maurice.

I'm looking forward to be the beta tester for the system.

Sincerely.
Re: System for embedding Phorum in other applications (early preview)
February 04, 2006 06:57AM
I got this message when I try use your example_page_script.php to create a test page to see how it works and I got this message below:
embed_phorum module error: page element "style" is missing in the templates

After I install your embeded templated and got this instead:

Welcome to main page of embeded phorum

Fatal error: Maximum execution time of 30 seconds exceeded in f:\wamp\www\phorum\include\templates.php on line 106

Is there something missing?

Thanks

[opensourceCMS.com]
[ongetc.com]
Chanh Ong



Edited 1 time(s). Last edit at 02/04/2006 07:14AM by chanh.
Re: System for embedding Phorum in other applications (early preview)
February 04, 2006 11:08AM
That max execution time error in templates.php has been seen more often, but I do not know yet where it's coming from (I never have seen it myself and never had a test setup at hand where I could reproduce the problem). Are you testing on a Windows system? You could try to clean up all compiled templates in Phorum's cache dir? I'm also willing to do some debugging on your system if that's possible, to find what's going wrong with the templates.

The example script and connector are fully targeted at my own website's backend, so if you want to try things out, you'll have to write your own versions of them. Else, you will probably get warnings about site_frame stuff that's not available.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: System for embedding Phorum in other applications (early preview)
February 04, 2006 04:04PM
Yes, I am using WXP with WAMP5
Here are what I did:
. I do a fresh phorum install from the latest dev version
. I install your embeded in phorum and your template in phorum
. I turn "on" your mod
. I created a little file call main.php which has the code below at the root and by the way phorum is installed in "phorum" folder
. I then do [localhost] and got that error message in my previous post.

<?php
echo "Welcome to main page of embeded phorum<br />";
// Load the PhorumConnector class.
require_once("./phorum/mods/embed_phorum/PhorumConnectorBase.php");
require_once("./phorum/mods/embed_phorum/connectors/gitaar.net/connector.php");
// Run Phorum and let the PhorumConnector class transfer the output
// to our website framework.
include "./phorum/mods/embed_phorum/phorum_block.php";
?>

This is a very nice idea only if I could see how it work so that I could tailor this setup into my Mambo site.

Please let me know whether I miss something.

Thanks

[opensourceCMS.com]
[ongetc.com]
Chanh Ong
Re: System for embedding Phorum in other applications (early preview)
February 04, 2006 05:54PM
You should not use the connector class for gitaar.net. Each type of master application (in your case Mambo) will need a specific connector that knows how the master application works. I never used Mambo myself, but I have set it up yesterday. Once Phorum is running embedded on my own testsite, I will check if I can create a connector for Mambo and probably some other CMSes too.

By running the script that you have here, nothing will be done with Phorum's output. The phorum_block.php script will be run and that script will capture Phorum's output. After that this output will be given to the connector to handle it. In the gitaar.net connector you'll see that I'm transferring that data into my site's framework code. The example script for gitaar.net shows that in the end header, body and footer are printed. Those three calls will use data that has been transferred by the connector.

What also has to be done to make user logins work as well, is syncing users from Mambo to Phorum. That's something the connector could do from the get_user_id() method. I'll hope to have an example of that soon.

I hope that is clear and useful. Once the software is stable, I'll write some docs on some setups you could make using this.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: System for embedding Phorum in other applications (early preview)
February 04, 2006 07:05PM
Sound great! I will love to see an example of what you said and I am sure Wendy from MODx will love to see it as well.

Thanks for the effort!

[opensourceCMS.com]
[ongetc.com]
Chanh Ong
Re: System for embedding Phorum in other applications (early preview)
February 05, 2006 05:23AM
Hi, I've been trying to run this embed system, but it seems that there is an error with it.

fopen(./templates/embed_phorum/settings.tpl): failed to open stream: No such file or directory

I checked the chdir value, and it's directed to the right dir, but it seems that when including the template, it's not working.
Any thought on this?

FYI, I'm able to get the phorum embeded on MODx with this script that I attached. Hope it will help solve the problem. I'm assuming there got to be something related to the modules, but I'm not 100% sure.

Pardon me for pasting the whole code on the forum, because I can't attached a file on the forum.
-----------------------------------------------------
// -- $phorumPath
// -- -- Full path on the server to where phorum being installed
if(!isset($phorumPath)) $phorumPath = $modx->config['base_path']."assets/modules/phorum";

// -- $phorumIndex (0)
// -- -- To set the starting folder of the phorum
// -- -- Set to 0, to load default index
if(!isset($phorumIndex)) $phorumIndex = 0;

// -- $phorumDB (false)
// -- -- To enabled different database from default installed or use the same info
// -- -- If this is set to true, then all the snippet parameter for db need to be filled
if(isset($phorumDB) && strtolower($phorumDB) == true) $phorumDB = true;
else $phorumDB = false;

// -- $pdbType, $pdbServer, $pdbName, $pdbUser, $pdbPass, $pdbPrefix
// -- -- Use this in conjunction with $phorumDB set to true
if(!isset($pdbType)) $pdbType = '';
if(!isset($pdbServer)) $pdbServer = '';
if(!isset($pdbName)) $pdbName = '';
if(!isset($pdbUser)) $pdbUser = '';
if(!isset($pdbPass)) $pdbPass = '';
if(!isset($pdbPrefix)) $pdbPrefix = '';



//---------------------------------
// Phorum Portable Configuration
//

// Database Configuration
// -- Set to use different database info
if($phorumDB && $pdbtype != '' && $pdbName != '' && $pdbServer != '' && $pdbUser != '' && $pdbPass != '' && $pdbPrefix != '') {
define("PHORUM_WRAPPER",1); // Enable using different db info
// Set the databse settings for this Phorum Install
$PHORUM_ALT_DBCONFIG=array(
"type" => $pdbType,
"name" => $pdbName,
"server" => $pdbServer,
"user" => $pdbUser,
"password" => $pdbPass,
"table_prefix" => $pdbPrefix
);
}
// -- Set to use a default installed database info
else {
define("PHORUM_WRAPPER",0);
}

// Defined function to alter the phorum url
function phorum_custom_get_url ($page, $query_items, $suffix) {
$PHORUM=$GLOBALS["PHORUM"];
// Use MODx URL appended with the querystring for phorum
$url = "[~[*id*]~]?$page";
// Default phorum querystring parser
if(count($query_items)) $url.=",".implode(",", $query_items);
if(!empty($suffix)) $url.=$suffix;
// Return the parsed url
return $url;
}

// Change default directory specific for phorum
chdir($phorumPath);

// Set default page and parse customized querystring for phorum
// to parsed, instead of default server querystring
if(substr($_SERVER["QUERY_STRING"],0,2)=='q=') {
$pos = strpos($_SERVER["QUERY_STRING"],'&') + 1;
$qs = substr($_SERVER["QUERY_STRING"],$pos);
if($pos == 1) {
$page = 'index';
if($phorumIndex != 0)
$GLOBALS["PHORUM_CUSTOM_QUERY_STRING"] = $phorumIndex;
}
else {
if(preg_match("/^([a-z]+),?/", $qs, $match)){
$GLOBALS["PHORUM_CUSTOM_QUERY_STRING"] = str_replace($match[0], "", $qs);
$page = basename($match[1]);
}
}
}
else if(preg_match("/^([a-z]+),?/", $_SERVER["QUERY_STRING"], $match)){
$GLOBALS["PHORUM_CUSTOM_QUERY_STRING"] = str_replace($match[0], "", $_SERVER["QUERY_STRING"]);
$page = basename($match[1]);
}
elseif(isset($_REQUEST["page"])){
$page = basename($_REQUEST["page"]);
}
else {
$page="index";
if($phorumIndex != 0)
$GLOBALS["PHORUM_CUSTOM_QUERY_STRING"] = $phorumIndex;
}

// Checking start page existence
if(file_exists("./$page.php")){
phorum_namespace($page);
}

// Create a namespace for Phorum
function phorum_namespace($page) {
global $PHORUM; // globalize the $PHORUM array
include_once("./$page.php");
}

// Change back to MODx default directory
chdir($modx->config['base_path']);
-----------------------------------------------------
Re: System for embedding Phorum in other applications (early preview)
February 05, 2006 05:26AM
FYI, I already copy thw whole template-dist folder to the templates folder and rename the folder to embed_forum, but it's still not working.
Re: System for embedding Phorum in other applications (early preview)
February 05, 2006 02:13PM
That's a strange error you get here. I have no clue why you would get that error message. Once chdir() has been done to the phorum directory, template files should be found.

Wait... you copied the template to "template_forum"? It should be "embed_phorum", looking at the error message you get. In my connector class, I set the template fixed to "embed_phorum". If you are working based on that class, you'll have to match the template name used in there. If you do not set the template from your connector, you should be able to select it as the template to use from your admin interface. I find it most convenient to set the template directly from the connector though.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login