Page 3 of 3

Re: Expandcontract with IMG_BUTTON

Posted: Sat Mar 10, 2018 10:14 pm
by Tata
One more idea to solve:
I have in config.php

Code: Select all

...
$plugin_cf['expandcontract']['use_inline_links']="";
$plugin_cf['expandcontract']['use_inline_images']="true";
$plugin_cf['expandcontract']['use_inline_buttons']="";
...
in metaconfig.php

Code: Select all

...
/*
$plugin_mcf['expandcontract']['use_inline_links']="enum: link,buttons,images";
*/
$plugin_mcf['expandcontract']['use_inline_links']="bool";
$plugin_mcf['expandcontract']['use_inline_images']="bool";
$plugin_mcf['expandcontract']['use_inline_buttons']="bool";
...
If I leave only the

Code: Select all

$plugin_mcf['expandcontract']['use_inline_links']="enum: link,buttons,images";
in metaconfig, I see nice dropdown list in the configuration. But I don't know, how to use the choise in index.php.

Re: Expandcontract with IMG_BUTTON

Posted: Sat Mar 10, 2018 11:29 pm
by cmb
Tata wrote:
Sat Mar 10, 2018 10:14 pm
If I leave only the

Code: Select all

$plugin_mcf['expandcontract']['use_inline_links']="enum: link,buttons,images";
in metaconfig, I see nice dropdown list in the configuration. But I don't know, how to use the choise in index.php.
Well, maybe something like:

Code: Select all

if ($plugin_cf['expandcontract']['use_inline_links'] == 'link') {
    // do something
} elseif ($plugin_cf['expandcontract']['use_inline_links'] == 'buttons') {
    // do something else
} else {
    // do something different
}

Re: Expandcontract with IMG_BUTTON

Posted: Sun Mar 11, 2018 2:19 pm
by Tata
Here is (i think rc version) of
expandcontract-0.7mod3.zip
Changelog:
  • Added new link type "image". This option allows using icons or images as link buttons.
    Accepted are PNG, JPG, BMP, GIF, SVG.
  • Icons/images shall be preferably of the same size.
  • The names of icon MUST be exact equal to the first word of the page title.
NOTE: If there are special characters used in page title, in some cases the image name may be unrecognized. In this case:
  • try either change the page title or
    try to rewrite/save the image names directly in filemanager
  • uncheck the option in configuration to hide the titles[/l
  • ist]

    I tried resultless to use

    Code: Select all

    $image_name = $first_page_title_word;
    $image_name = mb_convert_encoding($first_page_title_word, "UTF-8");
    to allow using images with simplified names. This is the last problem I have found so far.
    I would warmly appreciate any comments, hints or suggestions.

Re: Expandcontract with IMG_BUTTON

Posted: Sun Mar 11, 2018 2:37 pm
by cmb
Tata wrote:
Sun Mar 11, 2018 2:19 pm
I tried resultless to use

Code: Select all

$image_name = $first_page_title_word;
$image_name = mb_convert_encoding($first_page_title_word, "UTF-8");
to allow using images with simplified names. This is the last problem I have found so far.
I would warmly appreciate any comments, hints or suggestions.
This won't work, since $first_page_title_word is already UTF-8 encoded. In your case you can try:

Code: Select all

$image_name = $first_page_title_word;
$image_name = mb_convert_encoding($first_page_title_word, 'ISO-8859-2', 'UTF-8');
See also https://github.com/cmsimple-xh/cmsimple-xh/issues/109.

Re: Expandcontract with IMG_BUTTON

Posted: Sun Mar 11, 2018 3:37 pm
by Tata
Well, this works. But the problem I wanted to solve is not affected.
It is that if there is a Page <h2>Čimižková blabla blabla</h2>, there MUST exist the file Čimičková.png to be used as the expand_icon. But such file name is not recognized, until re-entered in FTP or filemanager. The simplest would be to make a file Cizmickova.jpg acceptable. All other files.* containing no special chars work fine.
There is still something with the config and metaconfig and also in the index.php. Using extended call some parameters are not evaluated.

Code: Select all

function expand($link = '', $linktext = '', $withheading = '', $closebutton = '', $limitheight = '', $link_type = '', $image_title = '', $link_type_image_format = '')
expandcontract-0.7mod3.3.zip

Re: Expandcontract with IMG_BUTTON

Posted: Mon Mar 12, 2018 8:57 pm
by Tata
There still remained some bugs in communication among config.php, metaconfig.php and index.php. And I cant find the reason. Some switches in config are not evaluated correctly in index or are ignored at all.
Also using specified command on the page is not fully reliable, if there are set some variables in config.
expandcontract-0.7mod4.zip
Another problem:
The problem with encoding file names still remains. Using

Code: Select all

$first_page_title_word = explode(' ', trim($h[$value])) [0];
$image_name = mb_convert_encoding($first_page_title_word, 'ISO-8859-2', 'UTF-8');
$image_name = $first_page_title_word;
did not help.
I tried to use the old way with cmsimple scripting to make it possible to define unique icon for each page used with the expandcontract plugin.

Code: Select all

#cmsimple $icon = "my_icon";#
The image "my_icon.jpg" was not found.
Also installing the morepagedata plugin did not help. I don't know why these variables do not work. They do within the template.

Re: Expandcontract with IMG_BUTTON

Posted: Tue Mar 13, 2018 12:05 am
by cmb
Tata wrote:
Sun Mar 11, 2018 3:37 pm
It is that if there is a Page <h2>Čimižková blabla blabla</h2>, there MUST exist the file Čimičková.png to be used as the expand_icon. But such file name is not recognized, until re-entered in FTP or filemanager.
It seems that your working on a machine with a non-UTF-8 encoded filesystem. Then you move Čimičková.png to CMSimple_XH's userfiles/ folder. Then the file is shown in the standard filebrowser similar to "Cimickov�.png", and not even the link to the file works. (Windows users can easily reproduce this with CMSimple_XH 1.7.2 on PHP < 7.1, by the way.)
Tata wrote:
Sun Mar 11, 2018 3:37 pm
The simplest would be to make a file Cizmickova.jpg acceptable. All other files.* containing no special chars work fine.
Have you considered employing uenc() (which uses urichar_org/new)? Something like

Code: Select all

$image_name = $first_page_title_word;
$image_name = uenc($first_page_title_word);
I'll try to catch up with the other issues as soon as possible! :)

Re: Expandcontract with IMG_BUTTON

Posted: Tue Mar 13, 2018 12:20 am
by Tata
Thanks for the hint. I'll give a try.
RESULT:
1. Created the hidden h2 page Čulibrčko
2. Created Culibrcko.png

The image not found. In web inspector the code shows

Code: Select all

<img src="./userfiles/images/expand_icons/Culibrcko.png" alt="Culibrcko" width="" height="">
The same is it both on server and on the localhost. I have checked my iMAC settings. It is UTF-8 for sure. I am not sure about the server. But I doubt it runs other than UTF-8.
EDIT (after slept well :D )
The uenc function was placed on wrong place. Placing it this morning correctly, made the expected result.

Code: Select all

...$page_title = $h[$value]; 
// get the first word from the page title and look for the image "first_page_title_word.*"
$first_page_title_word = explode(' ', trim($h[$value])) [0];
$image_name = $first_page_title_word;
// convert the image name to UTF8 - use $urichar_old / $urichar_new
$image_name = uenc($first_page_title_word);

$o.= '<form method="post" class="expand_button_image" action="?' . $u[$value] . $js . '">';
$o.= '<button type="submit" value="';
$o.= $linktext ? $linktext : $h[$value];
$o.= '">
			
<img src="' . $pth['folder']['images'] . $plugin_cf['expandcontract']['link_image_folder'] . '/'. $image_name . '.' . $plugin_cf['expandcontract']['link_image_format'] .'" alt="' . $h[$value] . '">'; 
...
Commented DEMO