News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Signature Area BBCode Buttons

Started by vbgamer45, September 03, 2006, 08:38:54 PM

Previous topic - Next topic

vbgamer45

I don't remember might be just be SMF support version change.
Community Suite for SMF - Grow your forum with SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com - Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

shadav

 :laugh: thanks, just wanted to check

[chrisB]

2.1.3 upgrade 🤞🏻

[Sorry, I've only just found this, but it would be super useful]
I'm stuck in a time warp from the early 00's.

Grammy

@vbgamer45

I was able to get this mod working for 2.1.4 and it does save the signature, and all that.  I just wondered if you could explain the Preview weirdness (and I know it's because of an edit I made).  I'd just like to know what I should have done differently.  Here are the screenshots.  The first one is without the mod and you can see that in Preview, you see both the current signature and the previewed signature that I'm about to save:

You cannot view this attachment.

The next screenshot is after adding the mod.  In Preview, you see the current signature and the preview signature as the same thing (even though what you see in the box is what actually saved, and is now showing in my profile and on the forum). 

You cannot view this attachment.

The Profile.template.php file was straightforward (I was using 2.0.18 edits) and it did fine.  The source file (Profile-Modify.php) had to be tweaked.  The first find string for the source file is actually
global $modSettings, $context, $txt, $cur_profile, $memberContext, $smcFunc;I replaced it with
global $modSettings, $context, $txt, $cur_profile, $memberContext, $smcFunc, $sourcedir;
The second edit is where I seem to have created a problem.  The "find" string is
$context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<br/>', '<br />', '<', '>', '"', '\''), array("\n", "\n", "\n", '&lt;', '&gt;', '&quot;', '&#039;'), $cur_profile['signature']);ADD AFTER
// Signature Area BBCode Buttons start
$modSettings['disable_wysiwyg'] = !empty($modSettings['disable_wysiwyg']) || empty($modSettings['enableBBC']);
require_once($sourcedir . '/Subs-Editor.php');
$editorOptions = array(
'id' => 'signature',
'value' => $context['member']['signature'],
'width' => '90%',
);
create_control_richedit($editorOptions);
$context['post_box_name'] = $editorOptions['id'];

  // Signature Area BBCode Buttons end
The issue I ran into was a white page because just before the "find" string there is this bit of existing code (affecting Preview):
if (empty($context['do_preview']))
Every validator I tried took issue with the "else" that comes just after where this mod's edits end.  The only way (for me, not for a coder) to get rid of the white page was not only to move that bit of code to just before "else" and to edit it to
if (empty($context['do_preview']));
So that entire section from the "find" string and past the "else" section now looks like this:
$context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<br/>', '<br />', '<', '>', '"', '\''), array("\n", "\n", "\n", '&lt;', '&gt;', '&quot;', '&#039;'), $cur_profile['signature']);
// Signature Area BBCode Buttons start
$modSettings['disable_wysiwyg'] = !empty($modSettings['disable_wysiwyg']) || empty($modSettings['enableBBC']);
require_once($sourcedir . '/Subs-Editor.php');
$editorOptions = array(
'id' => 'signature',
'value' => $context['member']['signature'],
'width' => '90%',
);
create_control_richedit($editorOptions);
$context['post_box_name'] = $editorOptions['id'];

  // Signature Area BBCode Buttons end
if (empty($context['do_preview']));
else
{
$signature = $_POST['signature'] = !empty($_POST['signature']) ? $smcFunc['normalize']($_POST['signature']) : '';
$validation = profileValidateSignature($signature);
if (empty($context['post_errors']))
{
loadLanguage('Errors');
$context['post_errors'] = array();
}
$context['post_errors'][] = 'signature_not_yet_saved';
if ($validation !== true && $validation !== false)
$context['post_errors'][] = $validation;

censorText($context['member']['signature']);
$context['member']['current_signature'] = $context['member']['signature'];
censorText($signature);
$context['member']['signature_preview'] = parse_bbc($signature, true, 'sig' . $memberContext[$context['id_member']], get_signature_allowed_bbc_tags());
$context['member']['signature'] = $_POST['signature'];
}

That has to be what's causing the Preview function to be misfiring.  Would you please explain why my edit broke it?  (I'm sorry to bother you with it, but at the same time, I'm very happy to have it working.  It's a great mod!)    :)

Grammy

 :) (Or any coder, really, who might want to weigh in?)   You cannot view this attachment.

Thank you.

Grammy

I put the bit of code back where it was originally and now it validates as being correct, with no white page, but the mod still only previews the current signature and not the one you wish to change it to.  Not really optimistic about learning why this is, so I'll stop bothering you guys about it.  But anyway...  Here's what the entire section looks like, and the mod works on 2.1.4, if forum members don't mind the preview thing.  @vbgamer45

if (empty($context['do_preview'])) {
$context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<br/>', '<br />', '<', '>', '"', '\''), array("\n", "\n", "\n", '&lt;', '&gt;', '&quot;', '&#039;'), $cur_profile['signature']);
// Signature Area BBCode Buttons start
$modSettings['disable_wysiwyg'] = !empty($modSettings['disable_wysiwyg']) || empty($modSettings['enableBBC']);
require_once($sourcedir . '/Subs-Editor.php');
$editorOptions = array(
'id' => 'signature',
'value' => $context['member']['signature'],
'width' => '90%',
);
create_control_richedit($editorOptions);
$context['post_box_name'] = $editorOptions['id'];

  // Signature Area BBCode Buttons end
}
else
{
$signature = $_POST['signature'] = !empty($_POST['signature']) ? $smcFunc['normalize']($_POST['signature']) : '';
$validation = profileValidateSignature($signature);
if (empty($context['post_errors']))
{
loadLanguage('Errors');
$context['post_errors'] = array();
}
$context['post_errors'][] = 'signature_not_yet_saved';
if ($validation !== true && $validation !== false)
$context['post_errors'][] = $validation;

censorText($context['member']['signature']);
$context['member']['current_signature'] = $context['member']['signature'];
censorText($signature);
$context['member']['signature_preview'] = parse_bbc($signature, true, 'sig' . $memberContext[$context['id_member']], get_signature_allowed_bbc_tags());
$context['member']['signature'] = $_POST['signature'];
}

// Load the spell checker?
if ($context['show_spellchecking'])
loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck');

return true;
}

vbgamer45

Community Suite for SMF - Grow your forum with SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com - Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Grammy

Quote from: vbgamer45 on February 19, 2025, 08:24:05 AMCan you share the whole file?

Yes, and thank you so much!  I'm attaching both the Profile-Modify.php and the Profile-template.php (just in case, ha).  Thank you so much for taking a look at them.   :)

(I don't know if this tells you anything but the other thing to notice is that when you go to your profile to change your existing signature, the current signature is already sitting in the post box, whether WYSIWYG is on (without tags, but with the effects of tags) or off (text surrounded by tags).  Should that box be empty, before putting anything in it?)

vbgamer45

I think the issue is  with
Themes\default\scripts\profile.js(87): function ajax_getSignaturePreview (showPreview)


Since you are using the Editor the function to get the text from editor changes.
Community Suite for SMF - Grow your forum with SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com - Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Grammy

Quote from: vbgamer45 on February 19, 2025, 03:30:10 PMI think the issue is  with
Themes\default\scripts\profile.js(87): function ajax_getSignaturePreview (showPreview)


Since you are using the Editor the function to get the text from editor changes.

To be honest, @vbgamer45 I'm not sure what to do.  Do you mean if (empty($context['do_preview'])) should be 'showPreview'?  I'm lost, I'm sorry.  You should see the wide-eyed expression on my face, ha!  I'm not near a mirror, but I can feel it!   :)

vbgamer45

I thinking the issue is actually in javascript file Themes\default\scripts\profile.js

in the fucntion
function ajax_getSignaturePreview (showPreview)


Not anything in PHP side.

Community Suite for SMF - Grow your forum with SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com - Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Grammy

Quote from: vbgamer45 on February 19, 2025, 03:50:17 PMI thinking the issue is actually in javascript file Themes\default\scripts\profile.js

in the fucntion
function ajax_getSignaturePreview (showPreview)


Not anything in PHP side.



@vbgamer45   

Oh, I see what you mean.  Would I need to be asking this in the 2.1 support topic, then, if it's JS related, and not the PHP code?

vbgamer45

It is a coding issue so probably not support forums
probably
SMF Coding and Discussion


Basically you want to get the value from the editor from javascript.
Community Suite for SMF - Grow your forum with SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com - Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Grammy

Quote from: vbgamer45 on February 19, 2025, 03:56:54 PMIt is a coding issue so probably not support forums
probably
SMF Coding and Discussion


Basically you want to get the value from the editor from javascript.

Oh, I see.  Thank you so much for taking the time to look at it.    :)

Grammy

@vbgamer45 I asked at the coding board and live627 gave me the edits that fixed the conflict with the JS file.  So this makes the mod entirely compatible with 2.1.4 default, now (so happy)!

In Themes/default/Profile-template.php, find:

<textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br>';
Replace with:
';
                            // Signature Area BBCode Buttons start               

        // load the post variables
loadLanguage('Post');
   
                       
            echo'<div id="bbcBox_message"></div>';
    echo'<div id="smileyBox_message"></div>';
        //You know that on bryandeakin.com you can speak to some of the largest names of SMF History.
    echo template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');


// Signature Area BBCode Buttons end
       

In Sources/Profile-Modify.php find:

global $modSettings, $context, $txt, $cur_profile, $memberContext, $smcFunc;
Replace with:

global $modSettings, $context, $txt, $cur_profile, $memberContext, $smcFunc, $sourcedir;
Find:
if (empty($context['do_preview']))
Add after:
{
                            // Signature Area BBCode Buttons start           
        $modSettings['disable_wysiwyg'] = !empty($modSettings['disable_wysiwyg']) || empty($modSettings['enableBBC']);
    require_once($sourcedir . '/Subs-Editor.php');
    $editorOptions = array(
        'id' => 'signature',
        'value' => $context['member']['signature'],
        'width' => '90%',
    );
            add_integration_function('integrate_sceditor_options', 'signature_sce_options', false);
    create_control_richedit($editorOptions);
    $context['post_box_name'] = $editorOptions['id'];
   
    // Signature Area BBCode Buttons end       
               

Find: 
$context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<br/>', '<br />', '<', '>', '"', '\''), array("\n", "\n", "\n", '&lt;', '&gt;', '&quot;', '&#039;'), $cur_profile['signature']);
Add after:
}
At end of file, find:
?>
Add before:

function signature_sce_options(array &$sce_options): void
{
    $sce_options['autoUpdate'] = true;
}

The only thing I've noticed is that if you go back to change your signature again, you see html in the box, whether WYSIWYG is on or off, so something like:

<span style="color: limegreen;" class="bbc_color">Does this siggy change and does it preview?</span>
That's whether or not html is enabled in the settings.  But I just clear it all out and it's not a problem.

It's previewing and saving beautifully, with WYSIWYG on or off.  Thanks so much for a great mod!  :)

vbgamer45

Perfect great job on the edits!!
Community Suite for SMF - Grow your forum with SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com - Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

DarkAngel612

So do we use the installer then add the codes or just edit the files showing above with these codes?
Fantasy Attic ::  Fantasies Realm Market :: SMF 2.1.4 with various mods and TinyPortal

vbgamer45

Use edits above, haven't merged into main file yet... no time currently.
Community Suite for SMF - Grow your forum with SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com - Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

DarkAngel612

Fantasy Attic ::  Fantasies Realm Market :: SMF 2.1.4 with various mods and TinyPortal

DarkAngel612

I was just wondering, after installling the text into the 2 files, when entering the code [bbc code] into the box then hitting preview, it changes to html text and yes if you redo anythig you have to redo the code by removing the one and re-entering it. Is that right?
Fantasy Attic ::  Fantasies Realm Market :: SMF 2.1.4 with various mods and TinyPortal

Advertisement: