SMF Ajax Chat

Started by wintstar, May 13, 2015, 10:23:13 AM

Previous topic - Next topic

wintstar

Deine Fehlermeldeung besagt folgendes:

Undefined variable: context in Themes/default/BoardIndex.template.php in der Zeile: 52

Es fehlt die Variable $context.

Gehe von der Zeile: 52 aus nach oben bis eine Zeile mit
Code (php) Select
{
global .....;

anfängt. Überprüfe dann, ob in dieser Zeile $context vorhanden ist. Wenn nein,  füge nach global
Code (php) Select
$context,
ein.

Da es kein Fehler mit den Original Dateien dieser Modifikation besteht, möchte ich dich bitten ein extra Thema zu eröffnen.
Regards Stephan

,,In order for the possible to come into being, the impossible must be attempted again and again."
Hermann Hesse (1877-1962)

My HomepageMy Board - My Atelier

Rifur

Könnte natürlich jetzt ein neues Thema dafür aufmachen. Aber nach meinen letzten versuchen bzw. rum probieren bleibt eigentlich zu 99,9% die Mod übrig.

Hab nun als letzten Versuch das ganze Local getestet. Frische SMF Installationsdatei geladen und installiert. Nur die Installation durchlaufen lassen. Nichts weiter installiert oder eingestellt. Ein wenig im neuen Forum herum geklickt und keine Einträge im Error log. Dann dein Mod nochmal geladen und dort installiert. Und nun wieder die gleichen Fehler. Jeder klick jeder Aufruf haut das Error log voll.

Quote
hxxp:localhost/smf/index.php [nonactive]?
8: Undefined variable: context
File: E:/xampp/htdocs/smf/Themes/default/BoardIndex.template.php (html_above sub template - eval?)
Line: 57

hxxp:localhost/smf/index.php [nonactive]?
8: Undefined variable: context
File: E:/xampp/htdocs/smf/Themes/default/BoardIndex.template.php (html_above sub template - eval?)
Line: 52

Und so weiter und sofort.

Da es aber eine komplett frische Installation ist ohne irgendwas bleibt nur die Mod. Wird die Mod deinstalliert sind die Fehler alle auch wieder weg.

Rifur

So, nachdem ich mich ja nun etliche Wochen damit rumgeschlagen habe und mir die alte Ajax Integration eigentlich total gefiel wollte ich da nicht aufgeben. Hab mich also die letzten Tage bzw fast ja schon Wochen mit Infos von der PHP Seite und die Infos hier wie man Mods und co für SMF entwickelt... nun endlich der Durchbruch. Und ich hab zwar trotz dem ganzen lesen keinen wirklichen Plan was PHP angeht und eine eigene Mod könnte ich wohl immer noch nicht schreiben... aber es liegt wohl doch an der Mod bzw an einer bestimmten Datei.

Die Shout.template.php hat meiner Meinung nach Schuld. Genaugenommen die erste Funktion darin. Du benutzt dort schon die Variable $context, $boardurl und $modsettings. Allerdings taucht die dort noch nirgends als "Globa" auf. Das kommt in der Datei erst in der zweiten und dritten Funktion. Nach dem was ich auf der PHP Seite studiert habe wäre das falsch. Die Variable muss davor definiert sein. Sonst zählt sie für diese Funktion nicht.

Also hatte ich aus dein

function template_shout_script() {
echo'
<link rel="stylesheet" type="text/css" href="', $boardurl, '/chat/css/shoutbox.css" />';

if (!empty($modSettings['chatpopup_enabled'])){
echo '
<script type="text/javascript">
function openWindow(url,width,height,options,name) {
width = width ? width : 800;
height = height ? height : 600;
options = options ? options : \'resizable=yes\';
name = name ? name : \'openWindow\';
window.open(
url,
name,
\'screenX=\'+(screen.width-width)/2+\',screenY=\'+(screen.height-height)/2+\',width=\'+width+\',height=\'+height+\',\'+options
)
}
</script>';
}

// We'll have to use the cookie to remember the shoutBox header...
if ($context['user']['is_guest'])
$options['sb_collapsed'] = !empty($_COOKIE['sb_collapsed']);

echo '
<script language="JavaScript" type="text/javascript">
var sb_current_header = ', empty($options['sb_collapsed']) ? 'false' : 'true', ';

function ajax_shoutBox_collapse(mode)
{';

if ($context['user']['is_guest'])
echo '
document.cookie = "sb_collapsed=" + (mode ? 1 : 0);';
else
echo '
smf_setThemeOption("sb_collapsed", mode ? 1 : 0, null, "', $context['session_id'], '");';

echo '
document.getElementById("ajax_shoutbox_collapse").src = smf_images_url + (mode ? "/expand.gif" : "/collapse.gif");

document.getElementById("ShoutBox").style.display = mode ? "none" : "";

sb_current_header = mode;
}
</script>';

}


Ein
function template_shout_script() {
global $context, $boardurl, modSettings;
echo'
<link rel="stylesheet" type="text/css" href="', $boardurl, '/chat/css/shoutbox.css" />';

if (!empty($modSettings['chatpopup_enabled'])){
echo '
<script type="text/javascript">
function openWindow(url,width,height,options,name) {
width = width ? width : 800;
height = height ? height : 600;
options = options ? options : \'resizable=yes\';
name = name ? name : \'openWindow\';
window.open(
url,
name,
\'screenX=\'+(screen.width-width)/2+\',screenY=\'+(screen.height-height)/2+\',width=\'+width+\',height=\'+height+\',\'+options
)
}
</script>';
}

// We'll have to use the cookie to remember the shoutBox header...
if ($context['user']['is_guest'])
$options['sb_collapsed'] = !empty($_COOKIE['sb_collapsed']);

echo '
<script language="JavaScript" type="text/javascript">
var sb_current_header = ', empty($options['sb_collapsed']) ? 'false' : 'true', ';

function ajax_shoutBox_collapse(mode)
{';

if ($context['user']['is_guest'])
echo '
document.cookie = "sb_collapsed=" + (mode ? 1 : 0);';
else
echo '
smf_setThemeOption("sb_collapsed", mode ? 1 : 0, null, "', $context['session_id'], '");';

echo '
document.getElementById("ajax_shoutbox_collapse").src = smf_images_url + (mode ? "/expand.gif" : "/collapse.gif");

document.getElementById("ShoutBox").style.display = mode ? "none" : "";

sb_current_header = mode;
}
</script>';

}

gemacht und nun geht es. Einfach den Global krams mit eingefügt. Nun ist das log Fehlerfrei und bleibt es auch.

Weiß jetzt nur nicht ob das wirklich alles so korrekt gelöst wurde von mir... aber es geht nun :)

TE

Quote from: Rifur on April 24, 2016, 09:28:56 PM
Weiß jetzt nur nicht ob das wirklich alles so korrekt gelöst wurde von mir... aber es geht nun :)
Deine Lösung ist vollkommen richtig. Wenn du Variablen in einer Funktion nutzen willst müssen sie entweder innerhalb der Funktion definiert werden oder über  das Schlüsselwort "global" bekannt gemacht werden.
http://php.net/manual/de/language.variables.scope.php

wintstar

Sorry, ist ein Fehler des Paket  :-[

Schau doch bitte mal in der Datei Shout.template.php ob dort noch die Version 1.0.0 RC3 angegeben ist, wenn ja ist das die falsche Datei.

Code (php) Select
/**
* www.Scaricare.de
*
* @package SMF Ajax Chat
* @author wintstar
* @copyright 2015 Scaricare.de
* @license http://opensource.org/licenses/gpl-2.0.php GPL-2.0
*
* @version 1.0.0 RC3
*/


Dies ist die korrekte Datei
Shout.template.php
Code (php) Select
<?php
/**
 * www.Scaricare.de
 *
 * @package SMF Ajax Chat
 * @author wintstar
 * @copyright 2015 Scaricare.de
 * @license http://opensource.org/licenses/gpl-2.0.php GPL-2.0
 *
 * @version 1.0.0
 */

function template_shout_script() {
    global 
$modSettings$context$options$settings$txt$boardurl;
/******************************************************************************
Please retain the full copyright notice below including the link to blueimp.net.
This not only gives respect to the amount of time given freely by the developer
but also helps build interest, traffic and use of AJAX Chat.
Thanks,
Sebastian Tschan
*******************************************************************************/
                
echo'
        <link rel="stylesheet" type="text/css" href="'
$boardurl'/chat/css/shoutbox.css" />';

    if (!empty(
$modSettings['chatpopup_enabled'])){
        echo 
'
            <script type="text/javascript">
                function openWindow(url,width,height,options,name) {
                    width = width ? width : 800;
                    height = height ? height : 600;
                    options = options ? options : \'resizable=yes\';
                    name = name ? name : \'openWindow\';
                    window.open(
                        url,
                        name,
                        \'screenX=\'+(screen.width-width)/2+\',screenY=\'+(screen.height-height)/2+\',width=\'+width+\',height=\'+height+\',\'+options
                    )
                }
            </script>'
;
    }

            
// We'll have to use the cookie to remember the shoutBox header...
            
if ($context['user']['is_guest'])
                
$options['sb_collapsed'] = !empty($_COOKIE['sb_collapsed']);

            echo 
'
        <script language="JavaScript" type="text/javascript">
            var sb_current_header = '
, empty($options['sb_collapsed']) ? 'false' 'true'';

            function ajax_shoutBox_collapse(mode)
            {'
;

            if (
$context['user']['is_guest'])
                echo 
'
                document.cookie = "sb_collapsed=" + (mode ? 1 : 0);'
;
            else
                echo 
'
                smf_setThemeOption("sb_collapsed", mode ? 1 : 0, null, "'
$context['session_id'], '");';

            echo 
'
                document.getElementById("ajax_shoutbox_collapse").src = smf_images_url + (mode ? "/expand.gif" : "/collapse.gif");

                document.getElementById("ShoutBox").style.display = mode ? "none" : "";

                sb_current_header = mode;
                }
        </script>'
;

}

function 
template_shout_above() {
    global 
$modSettings$context$options$settings$txt$boardurl;
    
    if (!empty(
$modSettings['shoutabove_enabled'])){
            
$flag allowedTo('shout_view');
        if (
$flag){

            if (!empty(
$modSettings['anypageshout_enabled']) || isset($context['chat_isHome'])){
                echo
'
    <div class="cat_bar">
        <h3 class="catbg">
                <span class="floatright"><a rel="nofollow" href="#" onclick="ajax_shoutBox_collapse(!sb_current_header)"><img id="ajax_shoutbox_collapse" src="'
$settings['images_url'], empty($options['sb_collapsed']) ? '/collapse.gif' '/expand.gif','" alt="*" style="margin: 0 5px 0 8px;padding-top:7px"  /></a></span>''
                <span class="floatright"><a href="https://blueimp.net/ajax/"><font size="1">AJAX Chat</font></a><font size="1"> &copy; <a href="https://blueimp.net">blueimp.net</a>&nbsp;|&nbsp; </font> <a href="http://www.simplemachines.org/"><font size="1">Integrated with SMF</font></a></span>
            '
$txt['shoutBox'], '
        </h3>
    </div>
    <div id="ShoutBox"'
, empty($options['sb_collapsed']) ? '' ' style="display: none;"''>
    <span class="clear upperframe"><span></span></span>
    <div class="roundframe"><div class="innerframe">
        <div style="margin-bottom:-5px;">
            '
getShoutBoxContent() ,'
        </div>
    </div></div>
    <span class="lowerframe"><span></span></span>
    </div>
    <br class="clear" />'
;
            }
        }
    }
}

function 
template_shout_below() {
    global 
$modSettings$context$options$settings$txt$boardurl;

    if (!empty(
$modSettings['shoutbelow_enabled'])){
            
$flag allowedTo('shout_view');
        if (
$flag){

    echo
'
    <span class="clear upperframe"><span></span></span>
    <div class="roundframe"><div class="innerframe">
    <div class="cat_bar">
        <h3 class="catbg">
                <span class="floatright"><a rel="nofollow" href="#" onclick="ajax_shoutBox_collapse(!sb_current_header)"><img id="ajax_shoutbox_collapse" src="'
$settings['images_url'], empty($options['sb_collapsed']) ? '/collapse.gif' '/expand.gif','" alt="*" style="margin: 0 5px 0 8px;padding-top:7px"  /></a></span>''
                <span class="floatright"><a href="https://blueimp.net/ajax/"><font size="1">AJAX Chat</font></a><font size="1"> &copy; <a href="https://blueimp.net">blueimp.net</a>&nbsp;|&nbsp; </font> <a href="http://www.simplemachines.org/"><font size="1">Integrated with SMF</font></a></span>
            '
$txt['shoutBox'], '
        </h3>
    </div>
    <div id="ShoutBox"'
, empty($options['sb_collapsed']) ? '' ' style="display: none;"''>
        <div style="margin-bottom:-5px;">
            '
getShoutBoxContent() ,'
        </div>
    </div></div>
    </div>
    <span class="lowerframe"><span></span></span>
    <br class="clear" />'
;
        }
    }
}

?>


Danke für deine hartnäckigkeit. Werde zum Wochenende das Paket aktualisieren  :)
Regards Stephan

,,In order for the possible to come into being, the impossible must be attempted again and again."
Hermann Hesse (1877-1962)

My HomepageMy Board - My Atelier

Rifur

Quote from: wintstar on April 25, 2016, 02:30:50 AM
Sorry, ist ein Fehler des Paket  :-[

Schau doch bitte mal in der Datei Shout.template.php ob dort noch die Version 1.0.0 RC3 angegeben ist, wenn ja ist das die falsche Datei.

Danke für deine hartnäckigkeit. Werde zum Wochenende das Paket aktualisieren  :)

Ja, bei meiner steht noch das RC3 mit dran. Dann ist wohl wirklich die falsche Datei mit drin. Hatte nämlich gestern wo ich es nochmal wissen wollte ;) die Datei komplett neu runtergeladen und die dann genommen zum weiteren probieren.

Und kein Problem, hatte gestern ja auch ein mächtiges Erfolgserlebnis als es dann nach all der Zeit endlich ging *gg*

wintstar

SMF Ajax Chat auf Version 1.0.1 aktualisiert :)


Änderungen zu  1.0.1

Bugs behoben

       
  • boardurl in Shout.template.php nicht gesetzt
  • shoutbox.css konnte nicht gefunden werden
    • Ajax Chat:
    • Französische Übersetzung typo behoben
    • Datenbank userID undnd channel Felder geändert zu unsigned int

Funktion entfernt

           
  • Info im Header
Neue Funktion

       
  • Titel der Shoutbox frei wählbar
  • Höhe der Shoutbox frei wählbar
  • Neuer Konfigurationsbereich im Admin-Center
  • Einfachere Installation durch hooks (SMF Hakensystem)
Regards Stephan

,,In order for the possible to come into being, the impossible must be attempted again and again."
Hermann Hesse (1877-1962)

My HomepageMy Board - My Atelier

Softie

Bekommt der Ajax Chat für SMF 2.0.13 eigentlich ein Update? Weil wenn ich jetzt 2.0.13 als Upgrade installiere - wird es vermutlich Probleme mit dem Ajax Chat 1.0.1 geben. Hatte sowas schon einmal, als ich auf 2.0.12 geupgradet habe. Danach konnte ich den Ajax Chat 1.0.0 nicht mehr deinstallieren.

Advertisement: