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

Home » RADICORE development » Transaction Patterns » Filepicker (Deleting Files / VPD)
Filepicker [message #4600] Thu, 16 October 2014 10:14 Go to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
Hi Tony,

I read the post of deleting files in a filepicker screen with a button in the HOW TO category from 2010. There you told that a new task called 'file(delete)' was added in version 1.42.0. I can't find this task. What expression/pattern do I have to look for?

If there is no possibility to delete files I think there isn't also a possibility to filter images/logos due to the account in a virtual private database, isn't it? If a user cannot delete a file it is possibly the best practice in a VPD to deal with all the logo files. Is this the reason why the framework has no such pattern? Or do you have other reasons/experiences?

Best regards,

Juergen
Re: Filepicker [message #4603 is a reply to message #4600] Sun, 19 October 2014 05:48 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
A 'file(delete)' task was added in version 1.42.0 dated 2008-12-02. You can find it in the 'Miscellaneous Tasks' subsystem and can be loaded from file menu\sql\misc.menu_export.sql

Re: Filepicker [message #5517 is a reply to message #4600] Wed, 27 April 2016 10:58 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
If I create the task file(delete) and add the task to filepicker task I have the following prolem:

My filepicker screen has no select box and if I choose the file hyperlink the file name is written in the table field.

The controller script directs to std.delete2.inc. But:
This will delete a selection of occurrences as identified in $where (as supplied from the previous screen). Note that there is no dialog with the user.

What do I have to do to get the file deleted?

In the meantime I have a solution that only the image files of the user account and of the shared account are visible.
Re: Filepicker [message #5518 is a reply to message #5517] Thu, 28 April 2016 04:24 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
The 'Select' button is missing from that screen simply because it is missing in your screen structure file. If you try the standard 'Batch Log Files' navigation which is available on all menu screens you should see that each row has a selected button by default.

Re: Filepicker [message #5519 is a reply to message #5518] Thu, 28 April 2016 06:03 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
Sorry, I do not understand what you mean with "if you try the standard 'Batch Log Files' navigation".

I inserted a select button in my screen structure file. But if I press the Delete(file) task button to delete the chosen file, nothing happens.

Do I have to create my own specific delete controller file with my own file delete task?
Re: Filepicker [message #5521 is a reply to message #5519] Fri, 29 April 2016 04:33 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
I meant "if you try the standard 'Batch Log Files' navigation button" which is available in the demonstration system. This shows 'select' checkboxes because they are defined in the screen structure file. For image pickers there is the ability to drop the 'select' checkbox and make the image name a clickable link. The 'select' checkbox is not shown because it is missing from the screen structure file.

Re: Filepicker [message #5524 is a reply to message #5521] Sat, 30 April 2016 06:19 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
Thank you, I got it and it works. If I understand right you insert all files in the specified directory in a 'virtual' table called mnu_file. The selected files will be deleted after pressing the Delete button.

Is it possible to combine all the tasks in one screen?

The tasks would be:

1. choose an image file for the specified table from the listed files
2. delete the image file
3. show the image file bigger when pressing the hyperlink
Re: Filepicker [message #5528 is a reply to message #5524] Sun, 01 May 2016 06:47 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
On the filepicker screen which shows image files it is possible to add one navigation button to allow new images to be uploaded, and another navigation button which allows selected files to be deleted. I do not currently have a task which expands the image to full size.

Re: Filepicker [message #5530 is a reply to message #5528] Mon, 02 May 2016 03:51 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
Then I will create one filepicker screen for uploading and deleting the files and one filepicker screen to insert the selected file in the table record. Thank you.
Re: Filepicker [message #5532 is a reply to message #4600] Wed, 04 May 2016 11:08 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
One more question: I want to examine if the the selected file can be deleted. I try to do this in the _cm_pre_DeleteRecord($rowdata) function with the code below.
I will do this with the _cm_getExtraData method. But $data shows only the occurences in the 'virtual' table 'training_plan_uebungen_pic_file' where all the pics are listed. Why I don't get back the occurences of 'training_plan_uebungen'. Isn't the $dbobject linked to 'training_plan_uebungen'?

class training_plan_uebungen_pic_file extends Default_Table
{ ..........

function _cm_pre_deleteRecord ($rowdata)
// perform custom processing before database record is deleted.
// if anything is placed in $this->errors the deletion will be terminated.
{
// this entry exists in the file system, not the database
$filename = $this->picker_subdir .'/' .$rowdata['file'];

// htManager changes
// check if pic belongs to the appropriate account or is related to an exercise in 'training_plan_uebungen'
$prefix_pattern = prefixAccount($_SESSION['rdcaccount_id']);

// get contents of table 'training_plan_uebungen'
-> $dbobject =& RDCsingleton::getInstance('training_plan_uebungen');
$fieldarray['training_plan_uebung_pfad_grafik'] = $filename;

$data = $dbobject->_cm_getExtraData($where, $fieldarray);

// only files with appropriate rdcaccount_id can be deleted
if (preg_match('/^'.$prefix_pattern.'/i', $rowdata['file']) and count($data) == 0)
{
$result = unlink($filename);

}

return $rowdata;

} // _cm_pre_deleteRecord
Re: Filepicker [message #5533 is a reply to message #5532] Thu, 05 May 2016 04:23 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
When you enter the _cm_pre_deleteRecord method the $rowdata argument contains values from the database record which is the subject of this deletion. I see from this code that it has the name $rowdata['file'] which you are then copying into the $filename variable along with the directory name. You are then doing something with a 'training_plan_uebungen' object, but I cannot determine what. You need to step through with your debugger to see where the actual behaviour differs from what you are expecting.

Re: Filepicker [message #5534 is a reply to message #5533] Thu, 05 May 2016 06:16 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
I want to see if the selcted file $rowdata['file'] is listed in a field in the 'training_plan_uebungen' table. If yes, the file shouldn't be deleted.
Re: Filepicker [message #5535 is a reply to message #5534] Thu, 05 May 2016 10:49 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
I found my fault. If I use the following code:

$where2 = "training_plan_uebung_pfad_grafik='$filename'";
$count = $dbobject->getCount($where2);

I get the occurences of $filename as I wanted.
Re: Filepicker [message #5750 is a reply to message #5535] Fri, 22 July 2016 10:33 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
I have created two tasks and two screens for deleting the pictures and the videos. In the screen for deleting the pictures I can see the picture. In my screen for deleting the video files, I don't see the video-image.

I tried to change the specification for the field in the class file but I wasn't successful.

The dict.inc has the following specification:

// field specifications for table htm.training_uebung_video_file
$fieldspec['file_id'] = array('type' => 'string',
'size' => 255);
$fieldspec['filename'] = array('type' => 'string',
'size' => 255);
$fieldspec['file'] = array('type' => 'string',
'size' => 255);
// primary key details
$this->primary_key = array('file');
// default sort sequence
$this->default_orderby = 'file';
// finished

The screen.inc has the following code:
$structure['main']['fields'][] = array('video' => 'Video',
'imagewidth' => 16,
'imageheight' => 16,
'nosort' => 'y');

In _cm_changeConfig() I added this code:
$this->fieldspec['file']['subtype'] = 'video';
$this->fieldspec['file']['notext'] = 'y';

Do I have to add additional code?
Re: Filepicker [message #5751 is a reply to message #5750] Sat, 23 July 2016 12:21 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
I have made a change to std.filepicker.list1.xsl which is attached. I tested it with a new filepicker task which deals only with videos. This requires a different screen structure file which looks like the following:
<?php
$structure['xsl_file'] = 'std.filepicker.list1.xsl';

$structure['tables']['main'] = 'file';

$structure['main']['columns'][] = array('width' => '25%');
$structure['main']['columns'][] = array('width' => '25%');

$structure['main']['fields'][] = array('file' => 'File Name');
$structure['main']['fields'][] = array('video' => 'Video',
                                       'imageheight' => 180,
                                       'imagewidth' => 320,
                                       'nosort' => 'y');

?>

This shows two videos per line. You can select a video by clicking on its name, or you can play a video by activating any of its controls.


Re: Filepicker [message #5753 is a reply to message #5751] Mon, 25 July 2016 10:04 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
I get the following error (attached as video.png). I think the dict.inc specification is wrong.

$fieldspec['file'] = array('type' => 'string', 'subtype' => 'video', 'size' => 255);

Or do I mind something else?
  • Attachment: video.png
    (Size: 171.71KB, Downloaded 811 times)
Re: Filepicker [message #5756 is a reply to message #5753] Tue, 26 July 2016 05:23 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
Why are you defining a field called 'file' in $fieldspec? That is a dummy field that holds nothing but the file name and is read-only, so it does not need any specifications. The only difference between an image picker and a video picker is the screen structure file that I provided previously. In your class file you also need to set $this->picker_subdir to the directory which contains your video files. Those are the only changes I made in my tests, and I do not encounter this error.

Re: Filepicker [message #5758 is a reply to message #5756] Tue, 26 July 2016 10:12 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
The error occurs only in my test environment. In my internet environment everything seems to work fine. Thank you very much.
Re: Filepicker [message #5759 is a reply to message #5758] Tue, 26 July 2016 10:47 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
In my working environment this error occurs if I want to select a video file with this new filepicker task. But this problem I can solve with the 'old', 'normal' filepicker task.
Re: Filepicker [message #5760 is a reply to message #5759] Tue, 26 July 2016 10:52 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
Sorry, it worked only on time. Then the following error was created:

2016-07-26 16:47:34
Fatal Error: XSLTProcessor::transformToXml(): Invalid type (# 256)
Error in line 2165 of file '/var/www/vhosts/mgh-saar.de/includes/include.xml.php5.inc'.
PHP_SELF: /htmanager/htm/htm_training_plan_uebungen_video_vw(filepicke r).php
Re: Filepicker [message #5765 is a reply to message #5760] Thu, 28 July 2016 04:31 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
I cannot reproduce this error on my PC. In order for me to investigate what is happening in your code you will have to send me the following:
1) The ?.class.inc file which is used in this filepicker
2) The ?.dict.inc file
3) The screen structure file


Re: Filepicker [message #5766 is a reply to message #5765] Thu, 28 July 2016 09:15 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
I attached the files in filepicker_files.zip.

If you change 'video' into 'image' in the ..screen.inc file there is no error but the video image will not be shown. You only see the file name.
Re: Filepicker [message #5769 is a reply to message #5766] Fri, 29 July 2016 05:51 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
You cannot access a video file using the 'image' type as it is not possible to access a video file as if it were a still image. To access a video file requires different tags in the HTML output, so you must set the type to 'video'.

Re: Filepicker [message #5770 is a reply to message #5769] Sat, 30 July 2016 05:16 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
You mean in the screen structure file?

$structure['main']['fields'][] = array('video' => 'Video', 'imageheight' => 250, 'imagewidth' => 300, 'nosort' => 'y');

If I change here ... array('video' => ... into ...array('image' => ... the error doesn't appear but you don't see a picture.

The 'video' tpye causes the error.
Re: Filepicker [message #5771 is a reply to message #5770] Sat, 30 July 2016 12:28 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
To display a video file the screen structure file must have the following:
$structure['main']['fields'][] = array('video' => 'Video',

The following is only valid for still images:
$structure['main']['fields'][] = array('image' => 'Image',

I have tried the code you gave me and I cannot reproduce the error. When I set the type to 'video' as shown above I can see the video file.

Can you send me the XML document that was included in the error log?


Re: Filepicker [message #5772 is a reply to message #5771] Sun, 31 July 2016 05:51 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
Do you mean this one?
Re: Filepicker [message #5775 is a reply to message #5772] Mon, 01 August 2016 05:22 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
I ran your XML file and immediately found a problem in my XSL file. Try the attached file and this should fix your problem.

Re: Filepicker [message #5776 is a reply to message #5775] Mon, 01 August 2016 10:26 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
Whoops! I found another bug, so please try this version instead.

Re: Filepicker [message #5778 is a reply to message #5776] Mon, 01 August 2016 15:57 Go to previous message
htManager is currently offline  htManager
Messages: 415
Registered: May 2014
Senior Member
Thank you. Works perfectly.
Previous Topic: list1/list2 - prevent opening detail screen
Next Topic: VPD - PopUp
Goto Forum:
  


Current Time: Thu Mar 28 18:05:19 EDT 2024

Total time taken to generate the page: 0.01884 seconds