Page 2 of 5

Re: A new port of phpBB mChat into WordPress is coming

Posted: Sun Jan 20, 2019 4:27 pm
by axew3
Here we go ...
You can be ready to display the result before then me, because here mChat isn't installed: i will setup the working example in a second time, into another separated test domain.

I think to not have forget nothing here, and that you'll find really easy to execute required steps. Please let me know any problem. You also will experience the nice sensation of users chatting between phpBB and WordPress.

Note that the option on phpBB to: display or not to specified user group the chat, affect if integration run as linked users! So if an user in phpBB can't see the chat, then he can't see nor in wp.

From 1.9.5 all phpBB user's options will be available in WordPress, to check against and activate related feature/option, or not, in WordPress side, if/when needed. This is done easily with a separated query at moment, that will be unified into the main plugin user session query as soon (on next coming release). Leaving all this apart now, let go with the

WordPress phpBB mChat integration procedure

before to follow and apply procedure, it is needed to install this (let name it in this way) RC 1.9.5 in attach:
wp_w3all_WPphpBB_rc_1.9.5_0.zip
(184.35 KiB) Downloaded 259 times
changed files are:
/wp-w3all-phpbb-integration/wp_w3all.php
/wp-w3all-phpbb-integration/class.wp.w3all-phpbb.php
/wp-w3all-phpbb-integration/class.wp.w3all.widgets-phpbb.php
/wp-w3all-phpbb-integration/views/config.php

added:
/wp-w3all-phpbb-integration/views/wp_w3all_phpbb_mchat.php
to display the mChat into a widget. The shortcode is coming soon.

May just replace all files of the plugin 1.9.4 with these new 1.9.5 RC.
Activate the new mChat option on plugin admin page, or activate it after all procedure done
phpBB mChat integration

Activate the new wordpress chat widget when all procedure done

The procedure, require to edit two mChat files at moment and to add a function into the overall_footer.html file: i will ask to kasimi author, whenever he will feel fine on do this, to little change the code of the mChat mod, making it output ABSOLUTE URLs on chat UI, in place of actual relative URLs (for avatars images for example).

So (assuming using prosilver, if not open the one of your theme):
Open with a text editor the file
/your_phpbb/ext/dmzx/mchat/styles/prosilver/template/mchat_body.html
and immediately after this line:

Code: Select all

{% if MCHAT_PAGE in ['custom', 'archive'] %}
add this:

Code: Select all

<script>
	var boardU = "{BOARD_URL}";
if( /\/forum\//ig.exec(document.referrer) == null && (document.referrer.indexOf(boardU) > -1) == false )
{	
	var w3_chat_phpBBpage = true;
}
</script>
Change forum with the page name you use (and that you built for the WP template forum page if you are using iframe mode, if not using iframe mode, the fact that you change or not this not affect, but the code as is, in any case need to be added).
Save and replace (may remember to recompile templates and leave the option active almost until not finished with procedure, or better, do this when all applied).

This is the ready mchat.php file, for mChat version 2.1.1 modified to render absolute URLS:
mchat.zip
(10.47 KiB) Downloaded 236 times
download and open with a text editor:
Search for this line (you'll find 2 times):

Code: Select all

$w3allU = 'https://localhost/root_integrations/phpbb323/'; // NOTE: add FINAL slash here
change the URL to MATCH your phpBB real url, add final slash, and nothing else after. Note that there are two lines of this to change.

Save and Replace the default one with this one you've edit on folder:
/your_phpbb/ext/dmzx/mchat/core/mchat.php
The file has been changed into another point also and if you like to know how all the joke has been done, check for these lines:

Code: Select all

// START w3all mod
there are 3 in total.
Now the final step: on the overall_footer.html of your theme, where this line (or before the other iframe resizer added code):

add this code:

Code: Select all

<script>
// a simple mChat style/display example setup for WP because ...
// may phpBB header,footer, and some common behaviors need to be modified in this way: but the joke could be accomplished in several other ways
// the file ext/dmzx/mchat/styles/prosilver/template/mchat_body.html (or any other theme you'll use)
// need to be edited adding the needed js code for this to work ... could be done in some other way
// but this will work simple as is ...
if( typeof w3_chat_phpBBpage != 'undefined' ){	
$( document ).ready(function() {
$( "#page-header,#page-footer" ).css( { "height" : "0px","overflow": "hidden" } ); // can't be none, or events will not affect
$( "body" ).css( "padding", "0px" );
$( "div#page-body.page-body h2" ).css( "display", "none" );
$( "div.mchat-text blockquote div cite a" ).click(function(e) {
		if( /\?jumpto=/ig.exec(this.href) == null ){
		e.preventDefault();
		window.open(this.href,'_blank');
		return;
	}
});
});
$( "div.list-inner span.mchat-title a" ).click(function(e) {
		e.preventDefault();
		window.open(this.href,'_blank');
		return;
});
$( "a[href='#']" ).click(function(e) {
		e.preventDefault();
		return;
});
$( ".username,.username-coloured,#mchat-legend a" ).click(function(e) {
	var href = $(this).attr("href");
	if( typeof href != 'undefined' ){
		e.preventDefault();
		window.open(href,'_blank');
		return;
	}
});
}
</script>

Activate the new mChat widget in WordPress!


This has been tested working ok on prosilver theme, hope that will be ok also for others theme. It is easy to adapt.
mchatwpw3all.png
mchatwpw3all.png (54.24 KiB) Viewed 6285 times
I will re-think the code of this on fly hack/integration to make it more easy, may the mChat author will help on make it more comfortable in the way i explained above (absolute urls), and so, even if it easy to do as is, will be not necessary to edit the mchat.php or the mchat_body.html files, and integrate the mChat in WordPress will be a joke for all.

Re: A new port of phpBB mChat into WordPress is coming

Posted: Sun Jan 20, 2019 11:29 pm
by axew3

Re: A new port of phpBB mChat into WordPress is coming

Posted: Mon Jan 21, 2019 8:29 am
by axew3
shortcode test on online example has been applied:

Code: Select all

 [w3allphpbbmchat]
to display chat into any page/post which as is right now into the online example:
phpBB mChat into wordpress
But once!
There is no need to do something like this but whenever the idea is to try out:
will NOT be possible to activate multiple chat widgets or chat shortcode on same page.
One of the two will not answer correctly as code is.
Only possible: one chat widget OR one shortcode x page.

Re: A new port of phpBB mChat into WordPress is coming

Posted: Mon Jan 21, 2019 10:41 pm
by xray
Plugin installed and code added. I see the chat in the plugin feature to add and I see it as a widget. However, when I tried to add the widget to wp it is not showing. changed the features for logged in to yes and no still not visible. I will double-check. I am using a different theme, but added the code to that theme. In the code you provided regarding the mchat style following the path for prosilver, i wonder if I need to change that path?

I will play around it with it more.

Re: A new port of phpBB mChat into WordPress is coming

Posted: Mon Jan 21, 2019 10:57 pm
by axew3
Hi, first of all check that the file version mchat.php is for 2.2.1 and not latest 2.2.2, i will provide the correct ready file for the latest version of the mod tomorrow my time, or follow steps on the file editing the one for the 2.2.2 that should be +- the same.

x not display:
try to go ACP and for the groups you want display the chat, set option can view as yes if it is still not and click save all.
I also yesterday had problem, because the mChat mod not setup values by default on table, so i should check to change the code for a different behavior: actually check for a value and if not found, the function return false, so nothing.

I experienced the same yesterday, i need to re-check the code. I will provide RC2 that fix for not linked mode the chat and some more.

I will provide also an example that will display a chat floating button, that will display the chat on bottom and onclick.
This the more smarty way i think, because you'll not need a preloader when waiting for the chat to display.

Re: A new port of phpBB mChat into WordPress is coming

Posted: Tue Jan 22, 2019 3:38 am
by xray
Oh yes I have 2.2 version... Also when my chat showed in widget it was actually seeing the forum login to include header. Once logged in the widget went to the chat, but still showed the header.

I think having the header is too much, just the chat for the wishes is better