Smilies always in a PopUp

Support area for phpBB's mChat extension
EVO_VV
Posts: 7
Joined: 23 Jun 2017, 16:03

Smilies always in a PopUp

#1

Postby EVO_VV » 15 Jul 2017, 14:50

I would like to have the smilies always appear in a PopUp rather than a long list below the ChatBox.
As far as I can see there is that possibility but I do not see the 'View more Smilies' in Prosilver.
Code for this is inside a <!-- IF S_SHOW_SMILEY_LINK --> <!-- ENDIF --> but so far I cannot find where this is set.

Any hints/pointers on where to look would be appreciated.

User avatar
kasimi
mChat developer
Posts: 293
Joined: 06 Oct 2016, 09:56
Contact:

Re: Smilies always in a PopUp

#2

Postby kasimi » 16 Jul 2017, 09:42

Apply these 2 edits:

    • Open core/mchat.php
    • Find:

      Code: Select all

      'U_MCHAT'         => $this->helper->route('dmzx_mchat_page_custom_controller'),
    • Add after:

      Code: Select all

      'U_MORE_SMILIES'   => append_sid($this->root_path . 'posting.' . $this->php_ext, 'mode=smilies'),

    • Open styles/prosilver/template/mchat_panel.html
    • Find:

      Code: Select all

      data-mchat-toggle="smilies"
    • Replace with:

      Code: Select all

      onclick="popup('{{ U_MORE_SMILIES }}', 300, 350, '_phpbbsmilies'); return false;"

EVO_VV
Posts: 7
Joined: 23 Jun 2017, 16:03

Re: Smilies always in a PopUp

#3

Postby EVO_VV » 16 Jul 2017, 15:10

Than you very much for that kasimi, I'll give it a try.
Just before I came on I found another solution that worked with one minor problem.
There is an Extension from Alex75 (https://www.phpbb.com/customise/db/exte ... scroll_box).
To make this work I only had to copy two of the events in it and rename them to match the events that are in mChat.
posting editor smilies before --> dmzx_mchat_buttons_container_after
posting editor smiles after --> dmzx_mchat_body_smiley_after
The only problem is that the outline of the box that appears below the Chat Box remains when the smilies have been toggled off.
If your method provides a popup just like the rules then that is what I would prefer.
I'll give it a try tomorrow, bit late for me over here in the far east. :)

EVO_VV
Posts: 7
Joined: 23 Jun 2017, 16:03

Re: Smilies always in a PopUp

#4

Postby EVO_VV » 17 Jul 2017, 13:52

The code edits you provided worked perfectly in both Prosilver and Mobern3.1
Thank you so much for that.

EVO_VV
Posts: 7
Joined: 23 Jun 2017, 16:03

Re: Smilies always in a PopUp

#5

Postby EVO_VV » 18 Jul 2017, 16:37

As kasimi's edits worked so well I thought I'd have a go at making the 'PopUp' optional.
Surprisingly (to me) my attempt worked perfectly on my test board.
Here is what I did :-

In core/mchat.php
Find

Code: Select all

$template_data = array(
         'MCHAT_NAVBAR_LINK'   => $navbar_link,
         'MCHAT_CUSTOM_PAGE'   => $custom_page,
         'MCHAT_TITLE'      => $this->user->lang('MCHAT_TITLE'),
         'MCHAT_TITLE_HINT'   => $this->user->lang('MCHAT_TITLE'),
         'U_MCHAT'      => $this->helper->route('dmzx_mchat_page_custom_controller'),
         'U_MORE_SMILIES'   => append_sid($this->root_path . 'posting.' . $this->php_ext, 'mode=smilies'),
      );


Insert Before

Code: Select all

      if ($this->settings->cfg('mchat_popup_smilies'))
      {


Add After

Code: Select all

}else{
      $template_data = array(
         'MCHAT_NAVBAR_LINK'   => $navbar_link,
         'MCHAT_CUSTOM_PAGE'   => $custom_page,
         'MCHAT_TITLE'      => $this->user->lang('MCHAT_TITLE'),
         'MCHAT_TITLE_HINT'   => $this->user->lang('MCHAT_TITLE'),
         'U_MCHAT'      => $this->helper->route('dmzx_mchat_page_custom_controller'),
      );
      }


That was a bit of a hack as I could not find the right syntax to get array_push to just add an element on the end of the array.

In styles/prosilver/template/mchat_panel.html
Find

Code: Select all

data-mchat-toggle="smilies"


Replace with

Code: Select all

<!-- IF MCHAT_POPUP_SMILIES -->onclick="popup('{{ U_MORE_SMILIES }}', 350, 350, '_phpbbsmilies'); return false;"<!-- ELSE --> data-mchat-toggle="smilies"<!-- ENDIF -->


In adm/style/acp_mchat_globalsettings
After

Code: Select all

      <dl>
         <dt><label for="mchat_override_smilie_limit">{L_MCHAT_OVERRIDE_SMILIE_LIMIT}{L_COLON}</label><br />
            <span>{L_MCHAT_OVERRIDE_SMILIE_LIMIT_EXPLAIN}</span></dt>
         <dd><label><input type="radio" class="radio" name="mchat_override_smilie_limit" value="1"<!-- IF MCHAT_OVERRIDE_SMILIE_LIMIT --> id="mchat_override_smilie_limit" checked="checked"<!-- ENDIF --> /> {L_YES}</label>
            <label><input type="radio" class="radio" name="mchat_override_smilie_limit" value="0"<!-- IF not MCHAT_OVERRIDE_SMILIE_LIMIT --> id="mchat_override_smilie_limit" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd>
      </dl>


Insert

Code: Select all

      <dl>
         <dt><label for="mchat_popup_smilies">{L_MCHAT_POPUP_SMILIES}{L_COLON}</label><br />
            <span>{L_MCHAT_POPUP_SMILIES_EXPLAIN}</span></dt>
         <dd><label><input type="radio" class="radio" name="mchat_popup_smilies" value="1"<!-- IF MCHAT_POPUP_SMILIES --> id="mchat_popup_smilies" checked="checked"<!-- ENDIF --> /> {L_YES}</label>
            <label><input type="radio" class="radio" name="mchat_popup_smilies" value="0"<!-- IF not MCHAT_POPUP_SMILIES --> id="mchat_popup_smilies" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd>
      </dl>


In core/settings.php
Find

Code: Select all

'mchat_override_smilie_limit'   => array('default' => 0),


Insert After

Code: Select all

'mchat_popup_smilies'   => array('default' => 0),


In core/mchat.php
Find

Code: Select all

'MCHAT_ALLOW_SMILES'         => $this->settings->cfg('allow_smilies') && $this->auth->acl_get('u_mchat_smilies')


Insert After

Code: Select all

'MCHAT_POPUP_SMILIES'         => $this->settings->cfg('mchat_popup_smilies'),


In language/en/mchat_acp
Find

Code: Select all

MCHAT_OVERRIDE_SMILIE_LIMIT_EXPLAIN


Insert After

Code: Select all

   'MCHAT_POPUP_SMILIES'               => 'PopUp or Box below',
   'MCHAT_POPUP_SMILIES_EXPLAIN'            => 'Set to yes to have the Smilies appear in a PopUp',


Finally a setting needs to be added to the config.
As I am testing on a non-live board, the method I used was what would be have been done if the edits were included in the last update.
In migrations/mchat_2_0_1.php
Find

Code: Select all

array('config.add', array('mchat_popup_smilies', 0)),


Insert After

Code: Select all

array('config.add', array('mchat_popup_smilies', 0)),


I'm not sure if just a 'disable' the extension in the ACP and then an 'enable' would add that to the config or not.
Another way would be to add the config using phpMyAdmin or simlilar.

It does work if you 'delete data' as well as 'disable' but that might not be suitable for a live board.

Making the PopUp optional for users I did think about but decided that it would be better for the Admin to control it as they are the ones who decide how many smilies to have in the first place.

terry2
Donor
Posts: 36
Joined: 22 Oct 2016, 18:22

Re: Smilies always in a PopUp

#6

Postby terry2 » 21 Jul 2017, 11:09

I would have just changed the smiley button to this.

Code: Select all

<!-- IF MCHAT_ALLOW_SMILES and .smiley -->
                  <input type="button" class="<!-- IF IS_PHPBB31 -->button2<!-- ELSEIF IS_PHPBB32 -->button2<!-- ENDIF -->" onclick="popup('./posting.php?mode=smilies&f=0', 550, 375); return false;"value="{L_MCHAT_SMILES}" />
               <!-- ENDIF -->

I'm lazy :lol:
1.png
1.png (71.36 KiB) Viewed 79 times
1.png
1.png (71.36 KiB) Viewed 79 times

User avatar
kasimi
mChat developer
Posts: 293
Joined: 06 Oct 2016, 09:56
Contact:

Re: Smilies always in a PopUp

#7

Postby kasimi » 26 Jul 2017, 09:37

EVO_VV wrote:I'm not sure if just a 'disable' the extension in the ACP and then an 'enable' would add that to the config or not.


Disabling an extension isn't enough to make phpBB apply an edited migration file, you'll have to delete data. Put your database changes in a new migration file and disabling without deleting data will work.

I haven't tested your edits but I trust they are working wonderfully. :D

@terry2, hardcoding the URL isn't recommended as the session ID might have to be added to it. Without it the link won't work for some users. The edits in the first post effectively do the same but with the correct URL.


Who is online

Users browsing this forum: No registered users and 2 guests