Ajax Chat Shoutbox Modul


Topic author
Peyah
Active Member
Posts: 2
Joined: 5. February 2014 14:57

Ajax Chat Shoutbox Modul

Post by Peyah »

Hi,

ich möchte gerne ein eigenes Portal Modul für den Ajax Chat erstellen, eine Shoutbox.

Ich habe nun schon einiges ergoogled, mit einem workaround funktioniert es auch.

Basierend auf diesem Thread: viewtopic.php?f=23&t=9253
insbesondere auf den Post von Kirk viewtopic.php?f=23&t=9253#p32936

habe ich folgendes gemacht:

Folgende Änderungen an includes/functions.php

Code: Select all

'SHOUTBOX'                      => getShoutBoxContent(),

Code: Select all

/**
* Shoutbox function
*
*/
function getShoutBoxContent() {
        // URL to the chat directory:
        if(!defined('AJAX_CHAT_URL')) {
                define('AJAX_CHAT_URL', './chat/');
        }

        // Path to the chat directory:
        if(!defined('AJAX_CHAT_PATH')) {
                define('AJAX_CHAT_PATH', realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/chat').'/');
        }

        // Validate the path to the chat:
        if(@is_file(AJAX_CHAT_PATH.'lib/classes.php')) {

                // Include Class libraries:
                require_once(AJAX_CHAT_PATH.'lib/classes.php');

                // Initialize the shoutbox:
                $ajaxChat = new CustomAJAXChatShoutBox();

                // Parse and return the shoutbox template content:
                return $ajaxChat->getShoutBoxContent();
        }

        return null;
}
unter phpBB3/portal/modules portal_shoutbox.php angelegt:

Code: Select all

<?php
/**
*
* @package - Board3portal v2 Shoutbox
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
    exit;
}

/**
* @package Shoutbox
*/
class portal_shoutbox_module
{
    /**
    * Allowed columns: Just sum up your options (Exp: left + right = 10)
    * top        1
    * left        2
    * center    4
    * right        8
    * bottom    16
    */
    public $columns = 21;

    /**
    * Default modulename
    */
    public $name = 'SHOUTBOX';

    /**
    * Default module-image:
    * file must be in "{T_THEME_PATH}/images/portal/"
    */
    public $image_src = '';

    /**
    * module-language file
    * file must be in "language/{$user->lang}/mods/portal/"
    */
    public $language = 'portal_shoutbox_module';

    /**
    * custom acp template
    * file must be in "adm/style/portal/"
    */
    public $custom_acp_tpl = '';

    /**
    * hide module name in ACP configuration page
    */
    public $hide_name = false;

    public function get_template_center($module_id)
    {
        global $config, $template, $user, $phpbb_root_path, $phpEx;

// Show all errors:
error_reporting(E_ALL);

// Path to the chat directory:
define('AJAX_CHAT_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/chat/');

// Include custom libraries and initialization code:
require(AJAX_CHAT_PATH.'lib/custom.php');

// Include Class libraries:
require(AJAX_CHAT_PATH.'lib/classes.php');

// Initialize the chat:
$ajaxChat = new CustomAJAXChat();


        return 'portal_shoutbox_side.html';
    }

    public function get_template_acp($module_id)
    {
        return array(
            'title'    => 'PORTAL_SHOUTBOX',
            'vars'    => array(),
        );
    }

    /**
    * API functions
    */
    public function install($module_id)
    {
        return true;
    }

    public function uninstall($module_id)
    {
        return true;
    }
}
?>
unter phpBB3/language/en/mods/portal/ portal_shoutbox_module.php angelegt:

Code: Select all

<?php
/**
*
* @package - Board3portal v2 Shoutbox
* @version 1.0.0
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
    exit;
}

if (empty($lang) || !is_array($lang))
{
    $lang = array();
}

// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine

$lang = array_merge($lang, array(
    'PORTAL_SHOUTBOX'             => 'Shoutbox',


));
?>
unter phpBB3/styles/<stylename>/template/portal/modules portal_shoutbox_side.html

Code: Select all

<!--version $Id: latest_members.html 544 2009-09-10 12:35:25Z christian_n $ //-->
{$LR_BLOCK_H_L}<!-- IF $S_BLOCK_ICON --><img src="{T_IMAGESET_PATH}/prosilver/portal/portal_members.png" width="16" height="16" alt="" />&nbsp;<!-- ENDIF -->SHOUTBOX{$LR_BLOCK_H_R}
        <!-- IF not S_IS_BOT -->
        <div style="font-size: 1.2em; margin-bottom: 20px;">{SHOUTBOX}</div>
        <!-- ELSE -->
        <div id="ajaxChatCopyright"><a href="https://blueimp.net/ajax/">AJAX Chat</a> © <a href="https://blueimp.net">blueimp.net</a></div>
        <!-- ENDIF -->
{$LR_BLOCK_F_L}{$LR_BLOCK_F_R}

Nun zum eigentlichen Problem:
Wie kann ich das Modul nun zum Portal hinzufügen? Im ACP ist es bei den Portal Modulen nicht auswählbar?

Als workarround habe ich nun einfach portal_shoutbox_side.html in attachments_side.html umbenannt, und das Attachments Modul hinzugefügt.
Hätte es aber gern als eigenständiges Modul, damit es auch beim nächsten Portalupdate noch funktioniert.
User avatar

Kirk
Dev
Posts: 1956
Joined: 27. July 2010 18:02
phpBB.de User: Kirk

Re: Ajax Chat Shoutbox Modul

Post by Kirk »

Hallo
  1. Du hast das hier public $columns = 21; eingetragen, die 21 steht aber für die Mitte, für die Seite musst du 10 eintragen.
  2. Ändere das hier public $name = 'SHOUTBOX'; in public $name = 'PORTAL_SHOUTBOX'; um,
    du hast ja in deiner Language Datei auch PORTAL_SHOUTBOX drin stehen.
  3. Das hier:

    Code: Select all

    public function get_template_center($module_id)
    steht für die Mitte, ändere es so um:

    Code: Select all

    public function get_template_side($module_id)
  4. Ändere mal in deiner portal_shoutbox_side.html die ersten beiden Zeilen in das um:

    Code: Select all

    {$LR_BLOCK_H_L}<!-- IF $S_BLOCK_ICON --><img src="{$IMAGE_SRC}" width="{$IMAGE_WIDTH}" height="{$IMAGE_HEIGHT}" alt="" />&nbsp;<!-- ENDIF -->{$TITLE}{$LR_BLOCK_H_R}
Gruß Udo

Topic author
Peyah
Active Member
Posts: 2
Joined: 5. February 2014 14:57

Re: Ajax Chat Shoutbox Modul

Post by Peyah »

Das kommt dabei raus wenn man zuviel C&P nutzt und nicht drüber nachdenkt :oops:

Danke für die Hilfe.

Funktioniert jetzt wie gewünscht, außer dass die eigentliche Funktion weiterhin über includes/functions.php aufgerufen wird. Die Funktion in der portal_shoutbox.php hat irgendwie nicht funktioniert, ruft jetzt nur noch die .html auf.
User avatar

talonos
Portal Specialist
Posts: 242
Joined: 7. June 2009 15:12
phpBB.com User: talonos

Re: Ajax Chat Shoutbox Modul

Post by talonos »

just reading over the code and noticed the block title image is set wrong.

theres 2 different ways to have it set right.

/portal/modules portal_shoutbox.php:

find:

Code: Select all

public $image_src = '';
replace with:

Code: Select all

public $image_src = 'portal_members.png';
/styles/<stylename>/template/portal/modules portal_shoutbox_side.html:

find:

Code: Select all

{$LR_BLOCK_H_L}<!-- IF $S_BLOCK_ICON --><img src="{T_IMAGESET_PATH}/prosilver/portal/portal_members.png" width="16" height="16" alt="" />&nbsp;<!-- ENDIF -->SHOUTBOX{$LR_BLOCK_H_R}
replace with:

Code: Select all

{$LR_BLOCK_H_L}<!-- IF $S_BLOCK_ICON --><img src="{$IMAGE_SRC}" width="{$IMAGE_WIDTH}" height="{$IMAGE_HEIGHT}" alt="" />&nbsp;<!-- ENDIF -->{$TITLE}{$LR_BLOCK_H_R}
OR just edit the html file so it points to the right place.

find:

Code: Select all

{$LR_BLOCK_H_L}<!-- IF $S_BLOCK_ICON --><img src="{T_IMAGESET_PATH}/prosilver/portal/portal_members.png" width="16" height="16" alt="" />&nbsp;<!-- ENDIF -->SHOUTBOX{$LR_BLOCK_H_R}
replace with:

Code: Select all

{$LR_BLOCK_H_L}<!-- IF $S_BLOCK_ICON --><img src="{T_IMAGESET_PATH}/portal/portal_members.png" width="16" height="16" alt="" />&nbsp;<!-- ENDIF -->{$TITLE}{$LR_BLOCK_H_R}
you will notice in the above edits that you have

Code: Select all

{$TITLE}
instead of the name of the block. that is so any edits to language files are carried into the title of the block aswell.
Creating board3 website? check the sites out below for board3 compatible extensions
Talonos: Pretereo stormrage EU OFFLINE!

Return to “Modifications Support”