Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Transaction Patterns » Filepicker - getDir()
Filepicker - getDir() [message #7428] Mon, 23 March 2020 17:11 Go to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
I have problems with some filepicker tasks because of the DIRECTORY_SEPARATOR in an XAMPP installation on my notebook. Some of the tasks work fine but some use the '\' as separator in front of the picture file and so is in line 120 in the std.filepicker1.inc no correct filepath found and an error will be generated. I use the same directory where the pictures are stored for the tasks which work and for those which fail. Do I have to take attention to something special?
Re: Filepicker - getDir() [message #7429 is a reply to message #7428] Tue, 24 March 2020 05:40 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
Line 120 is as follows:
$fileobject->picker_child_dir = $subdir.DIRECTORY_SEPARATOR.$_GET['select'];
Note that DIRECTORY_SEPARATOR is a predefined constant which is set automatically to either '\' or '/' depending on your operating system. If you have a path which cannot be found does it contain other separators which are invalid for that OS?


Re: Filepicker - getDir() [message #7430 is a reply to message #7429] Tue, 24 March 2020 07:56 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
This is the value of $subdir.DIRECTORY_SEPARATOR.$_GET['select'] in xampp:

C:\xampp\htdocs\radicore\includes\std.filepicker1.inc:121:st ring 'pictures/training_uebungen\000006_HTM001000003a.jpg' (length=51)

In line 133 you replace the '\' with '/'. Could this be the problem here, too?

The error message on my linux host is:

Fatal Error: Method 'getDir' does not exist in standard object (# 256)
Error in line 12066 of file '/var/www/vhosts/mgh-saar.de/includes/std.table.class.inc'.
PHP_SELF: /htmanager/htm/orga_tests_grafik_02(filepicker).php
CURRENT DIRECTORY: /var/www/vhosts/mgh-saar.de/htmanager.de/htmanager/htm
REQUEST_URI: /htmanager/htm/orga_tests_grafik_02(filepicker).php?session_ name=menu3&select=000006_HTM001000007.JPG

Inserting from the same directory works fine with an other task.
Re: Filepicker - getDir() [message #7431 is a reply to message #7430] Wed, 25 March 2020 06:54 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
Windows can use either '\' or '/' as the directory separator whereas linux will only allow '/', so the code which converts '\' to '/.' is not an issue.

Your actual problem is shown in the message "Method 'getDir' does not exist in standard object" which means that I did not include the updated version of std.table.class.inc in my last release. I have attached the latest version to this message.


Re: Filepicker - getDir() [message #7432 is a reply to message #7431] Thu, 26 March 2020 05:00 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
Thank you for applying the new std.table.class.inc. Could it be that the include.session.inc has to be updated too?

I get the following error message:
Fatal Error: Uncaught exception from Error, message = Call to undefined function array2string(), code=0, file=C:\xampp\htdocs\radicore\includes\std.table.class.inc, line=5855, file = C:\xampp\htdocs\radicore\includes\include.session.inc
line = 212
function = popupCall
class = Default_Table
Re: Filepicker - getDir() [message #7433 is a reply to message #7432] Thu, 26 March 2020 05:29 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
Whoops! Embarassed I forgot that I had also updated file include.library.inc, so here is the latest copy.

Re: Filepicker - getDir() [message #7434 is a reply to message #7433] Thu, 26 March 2020 07:31 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
Thank you very much. The pouUp is now working.
Now I have the problem that the complete path is inserted in the table. Do I have to change something in the _cm_initialiseFilePicker() method? Normally only the subdir and the image name is stored.
Re: Filepicker - getDir() [message #7435 is a reply to message #7434] Fri, 27 March 2020 05:58 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
If you want to store only the file name in the database and not the full path then you should use code similar to this:
$filename = basename($filepath);


Re: Filepicker - getDir() [message #7436 is a reply to message #7435] Fri, 27 March 2020 12:55 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
Where do I have to place this code?

By now I only identified the subdir in _cm_initialiseFilepicker()

// identify the subdirectory which contains the files
$this->picker_subdir = 'pictures/training_uebungen';

Do I have to store the code here in the _cm_initialiseFilepicker?

$filename = basename($filepath);
Re: Filepicker - getDir() [message #7437 is a reply to message #7436] Fri, 27 March 2020 14:00 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
You need to use that code after a file has been picked but before it is added to the database. This is definitely not the _cm_initialiseFilepicker() method.

Re: Filepicker - getDir() [message #7438 is a reply to message #7437] Fri, 27 March 2020 16:43 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
I thought that it would be in the _cm_filePickerSelect ($selection) method, but the selection will not be shown in this method. Where would it be best?

In the filepicker selection screen you can't see the images anymore. See attached screenshots.

[Updated on: Sat, 28 March 2020 05:36]

Report message to a moderator

Re: Filepicker - getDir() [message #7439 is a reply to message #7438] Sat, 28 March 2020 05:20 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
When the filepicker task exits and returns its selection to the task which called it.

Re: Filepicker - getDir() [message #7440 is a reply to message #7439] Sat, 28 March 2020 05:56 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
Sorry, but I don't understand how to handle this.
I have an upd1 task (htm_orga_mannschaften_tests(upd1)) to open a detail screen in which I have a filepicker control with a filepicker task (htm_orga_tests_grafik_01(filepicker)).

"When the filepicker task exits" means that there must be in orga_mannschaften_tests.class.inc a method where I can change the selected string? But I have no idea which method this could be.

Have you read my complement and seen the screenshot?
Re: Filepicker - getDir() [message #7441 is a reply to message #7440] Sun, 29 March 2020 05:26 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
When the filepicker task exits it returns control to the task which activated it. Upon return to this task the _cm_popupReturn() method is activated which then makes the selection available to that task.

Re: Filepicker - getDir() [message #7442 is a reply to message #7441] Sun, 29 March 2020 09:12 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
I can handle it now. Thank you.
But $filename = basename($filepath) returns only the name of the picture without the 'picker_subdir'. I do now extend $filename with the value of 'picker_subdir' (pictures/training_uebungen/') manually hardcoded. Even storing the value of 'picker_subdir' in $GLOBALS['picker_subdir'] = 'pictures/training_uebungen' doesn't work. When retreiving it in _cm_popUpReturn() it is empty.
Is there a possibility to get the value of 'picker_subdir'?
Re: Filepicker - getDir() [message #7443 is a reply to message #7442] Mon, 30 March 2020 04:53 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
$picker_subdir is defined as a class property within std.table.class.inc so should be addressed as $this->picker_subdir. Its value is usually loaded in the _cm_initialiseFilePicker() method, but can also be loaded in the _cm_initialise() method.

Re: Filepicker - getDir() [message #7444 is a reply to message #7443] Mon, 30 March 2020 10:48 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
Tony, I don't know what it is wrong with my application. I initialized the picker directories in the same way you did in the prototype applications. But it fails.
I looked in xample and in survey and in both application the icons are not correct shown in the picker screen and you can't them choose. See attached file.
I changed the include directory to that from version 2.13.0 and everything works fine. Can it be that there is a problem with the new version 2.14.0?
Re: Filepicker - getDir() [message #7445 is a reply to message #7444] Tue, 31 March 2020 05:24 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
Whoops! Embarassed That problem with the filepicker in the Survey prototype was due to the fact that some while ago in version 2.04.1 I changed the column names used in the screen. This is fixed in the attached script which goes into the \survey\screens\en\ directory.

Re: Filepicker - getDir() [message #7446 is a reply to message #7445] Tue, 31 March 2020 05:26 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
When you say that something is wrong, what exactly is wrong? What is the contents of the $selection argument in _cm_popupReturn() when you return from making a selection in the filepicker screen?

Re: Filepicker - getDir() [message #7447 is a reply to message #7446] Tue, 31 March 2020 09:31 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
In V 2.13.0 the $select_array returns: string 'pictures/training_uebungen/000006_HTM001000002b.JPG' where pictures/training_uebungen/ is the value of $this->picker_subdir, initialised in _cm_initialiseFilePicker(). The icons in filepicker screen are shown correctly.

In V 2.14.0 the $select_array returns: string 'C:/xampp/htdocs/radicore/htm/pictures/training_uebungen/000 006_HTM001000009.JPG'. The icons in filepicker screen aren't shown correctly.
Re: Filepicker - getDir() [message #7448 is a reply to message #7447] Wed, 01 April 2020 05:37 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
It would appear that somewhere in the processing I changed the relative path to an absolute path, so I will fix this in the next release which will follow shortly. In the meantime you can try the following code in the _cm_popupReturn() method:
$selection = $this->picker_subdir .'/' .basename($selection);


Re: Filepicker - getDir() [message #7449 is a reply to message #7448] Wed, 01 April 2020 09:47 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
The problem seems to be that $this->picker_subdir is empty. If I use "$selection = $this->picker_subdir .'/' .basename($selection);" I get: "/whatever.jpg"

I think, I will wait for the new release. Version 2.13.0 is working fine for me.
Re: Filepicker - getDir() [message #7450 is a reply to message #7449] Thu, 02 April 2020 05:00 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
$this->picker_subdir can be set in either _cm_initialiseFilePicker() or in _cm_initialise().

Re: Filepicker - getDir() [message #7452 is a reply to message #7450] Fri, 03 April 2020 04:03 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
I installed Version 2.15.0 and as far as I can see, everything works fine for me again. Thank you.
What did you change to solve this problem?
Re: Filepicker - getDir() [message #7453 is a reply to message #7452] Fri, 03 April 2020 04:39 Go to previous message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
For some reason I had used the realpath() function to turn the relative path into an absolute one. This turned out to be a mistake Embarassed so I reverted the code.

Previous Topic: Output2 - Options / 90° cell rotation
Next Topic: Alternative to the LINK1 pattern
Goto Forum:
  


Current Time: Thu Mar 28 11:48:29 EDT 2024

Total time taken to generate the page: 0.01945 seconds