Home » RADICORE » How To » Update 4
|
|
|
|
|
|
|
Re: Update 4 [message #895 is a reply to message #894] |
Fri, 29 June 2007 15:32   |
AJM
Messages: 2378 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
When you bring up the list of files from the chosen source, is it your intention to process all of them, or just a selection of them? Are you moving them to a different destination, or is other processing involved?
When you are attempting something which is rather complicated it may appear that there is not a pattern which fits the job 100%, but in that case you must try the nearest match then insert custom code which can override the default behaviour of that pattern. Every different pattern executes a different set of methods in a predeterined sequence. All of the methods which begin with '_cm_' are customisable, which means that you can copy the empty stub from 'std.table.class.inc' into your table class, then insert your own code which will be executed when that method is called. You should find a '_cm_pre_' and '_cm_post_' method either side of each standard method, so you have the opportunity to execute your own code before and after each standard method.
Once you become more familiar with the framework you should realise that the ability to have your own code executed in several different places along the processing flow is a really powerful tool. The biggest difficulty is being able to pick the most appropriate pattern, then knowing what code to put where. It gets easier with experience (or so I'm told)
|
|
|
Re: Update 4 [message #897 is a reply to message #895] |
Tue, 03 July 2007 11:47   |
danpoleary
Messages: 49 Registered: February 2007
|
Member |
|
|
Hi,
Tried a few things, but not sure if my final logic will work.
If I am on the sources table screen, and select (lets say source1), then click "update multiple files". The update multiple screen, will provide a list of all files, from the files table, from that source.
I then select the files I want to set to "publish", then click on "publish selected". At this point, in the publish selected script (inside the custom table class that extends the "files" table class) I then use a call to scriptNext, to call a popup that lets me select the "destination" key from the destination table.
After I call scriptPrevious, and now back inside my publish script, I set the boolean value of publish to "true" and the destination key value to the the return value.
Will this logic work, or am I heading in the wrong direction?
Thanks,
Dan
|
|
|
|
|
|
|
Re: Update 4 [message #908 is a reply to message #901] |
Thu, 05 July 2007 09:56   |
danpoleary
Messages: 49 Registered: February 2007
|
Member |
|
|
Hi Tony,
Before you sent that update, I did get something to work. When I clicked on the multi4 after choosing a source, I get the screen with the source data editable at the top as expected, but the field for the destination_key/desc does not appear.
When I replaced my include.general.inc with the updated one, everything stopped working, blank screen on login. I then reverted the include file, and only incorporated the changed function. Now I can log in, but my call to multi4 brings up a blank screen.
In the popup faq's above, do I need to update the dict file for the source table? If I do, will that not appear on the standard source list1 screen all the time?
and, should I add the field description to the screen.inc file used for my multi4?
Thanks,
Dan
|
|
|
|
Re: Update 4 [message #910 is a reply to message #909] |
Thu, 05 July 2007 11:00   |
danpoleary
Messages: 49 Registered: February 2007
|
Member |
|
|
Hi,
Found my mistake, and fixed the blank screen problem (ftp problem).
Anyway, I did the following:
1. created a new class (sources_destination) derived from the original (sources) class.
2. added the function _cm_changeConfig to this new class:
Quote: | function _cm_changeConfig ($where, $fieldarray)
{
$this->fieldspec['publish_key'] = array('type' => 'string',
'size' => 1024,
'required' => 'y',
'control' => 'popup',
'task_id' => 'destination_list(popup)',
'foreign_field' => 'Collection_destination');
return $fieldarray;
}
|
3. In my filelist(multi4).php, I use (sources_destination) as the outer table. Should this stay as sources?
I did all this first, to ensure that after I pick a source, and select multi4, that I get the screen as described with the extra field displayed in the outer. What I get though, is just the list of files! I think I got myself a little tangled...
Dan
|
|
|
|
|
|
Re: Update 4 [message #914 is a reply to message #913] |
Thu, 05 July 2007 12:48   |
danpoleary
Messages: 49 Registered: February 2007
|
Member |
|
|
I got the first two already, in my sources_destination.class.inc, I have:
Quote: | function _cm_changeConfig ($where, $fieldarray)
{
$this->fieldspec['publish_key'] = array('type' => 'string',
'size' => 1024,
'required' => 'y',
'control' => 'popup',
'task_id' => 'collection_list(popup1)',
'foreign_field' => 'publish_key');
return $fieldarray;
}
|
In the filelist.multi4.screen.inc, I have:
Quote: | $structure['outer']['fields'][] = array('source_key' => 'Source Key');
$structure['outer']['fields'][] = array('source_url' => 'Source Url');
$structure['outer']['fields'][] = array('contact' => 'Contact');
$structure['outer']['fields'][] = array('phone' => 'Phone');
$structure['outer']['fields'][] = array('email' => 'Email');
$structure['outer']['fields'][] = array('region' => 'Region');
$structure['outer']['fields'][] = array('source_root' => 'Source Root');
$structure['outer']['fields'][] = array('parent_source_key' => 'Parent Source Key');
$structure['outer']['fields'][] = array('publish_key' => 'Publish Key');
|
But where does the $fieldarray come into play?
I looked through the code, and the FAQ's, and am not sure where this should be applied.
|
|
|
|
|
|
|
|
|
|
|
Re: Update 4 [message #925 is a reply to message #922] |
Mon, 09 July 2007 15:16   |
danpoleary
Messages: 49 Registered: February 2007
|
Member |
|
|
Hi Tony,
Sorry, I based that call on something on say in the existing code.
I now have the following in the inner entity (filelist_auto.class.inc file) which extends the filelist.class.inc. This extended class is used in both the multi4, and in the update4.
Quote: | function _cm_pre_updateRecord($rowdata)
{
$rowdata['autopublish'] = TRUE;
// what was select in the popup during _cm_initialize
$rowdata['publish_key'] = $rowdata['sel_publish_key'];
return $rowdata;
}
function _cm_changeConfig ($where, $fieldarray)
{
$fieldarray['sel_publish_key'] = '';
$this->fieldspec['sel_publish_key'] = array('type' => 'string',
'size' => 32);
return $fieldarray;
}
function _cm_getInitialData ($fieldarray)
// Perform custom processing for the getInitialData method.
// $fieldarray contains data from the initial $where clause.
{
$fieldarray['sel_publish_key'] = $_POST['sel_publish_key'];
return $fieldarray;
} // _cm_getInitialData
function _cm_getPkeyNames ($pkey, $task_id, $pattern_id)
{
$pkey_array[] = 'sel_publish_key';
return $pkey_array;
}
|
Where else could I try? I can see the post of the sel_publish_key, but I am not sure in which function to set it!
I have looked for many examples, but have yet to find one that works in this multi4, update4 fashion.
Thanks,
dan
|
|
|
|
|
|
|
Re: Update 4 [message #938 is a reply to message #937] |
Tue, 10 July 2007 13:54   |
AJM
Messages: 2378 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
I have just tried modifying a MULTI4 transaction to reproduce the solution I have described, and it works exactly as I expected. I tested it using Radicore version 1.25.0 plus the updated version of 'include.general.inc' which I attached to an earlier post in this thread.
To make sure you are not missing something simple this is what I did:
- the outer entity of the MULTI4 function contains a field called 'sel_publish_key' which appears on the screen and is amendable by the user. This means that when a button is pressed the $_POST array will contain the current value for 'sel_publish_key'.
- when I select entries from the inner entity of the MULTI4 function and press a navigation button, the contents of the $_POST array is then merged with the contents of both the outer and inner entities before the button is processed.
- the inner entity of the MULTI4 function does not contain a field called 'sel_publish_key', so its value will not, by default, be added to $fieldarray within the inner entity. I can change this behaviour by adding the following code to the inner entity:
function _cm_changeConfig ($where, $fieldarray)
{
$this->fieldspec['sel_publish_key'] = array('type' => 'string', 'nondb' => 'y');
return $fieldarray;
} // _cm_changeConfig
- when the navigation button is pressed the following lines in 'std.multi4.inc' will be executed:
116: $inner_post = getPostArray($_POST, $dbinner->getFieldSpec());
117: $inner_data = array_update_indexed($inner_data, $inner_post);
You need to inspect this with your debugger to ensure that $_POST contains a value for 'sel_publish_key', and that $inner_data is updated so that every row now contains the value for 'sel_publish_key'.
- the next line in 'std.multi4.inc' calls the childform() function, which will pass control to the form associated with the navigation button which has been pressed. The processing should go through the code appearing at line 179:
if (isset($post['select'])) {
// convert selection into SQL where format
$pkey_array = $dbobject->getPkeyArray(null, $task_array);
$selection = selection2where($pkey_array, $post['select']);
} else {
The call to getPeyArray() contains the call to _cm_getPkeyNames() which should contain the following:
function _cm_getPkeyNames ($pkey_array, $task_id, $pattern_id)
{
$pkey_array[] = 'sel_publish_key';
return $pkey_array;
} // _cm_getPkeyNames
This ensures that when the $selection string is built it will contain the value for 'sel_publish_key'. This string will then be passed to whatever function was activated by the navigation button.
All I had to do to get this to work was include 'sel_publish_key' in the _cm_changeConfig() and _cm_getPkeyNames() methods of the inner entity, so unless you are doing something really peculiar it should be just as easy for you.
|
|
|
Re: Update 4 [message #939 is a reply to message #938] |
Wed, 11 July 2007 11:15   |
danpoleary
Messages: 49 Registered: February 2007
|
Member |
|
|
Hi Tony,
Thanks,
I rebuilt the whole thing. The following describes what I have right now.
In the multi4 , I access an extended outer class of sources_destination which extends sources, by adding the sel_publish_key field, and allows me to select a value.
for the inner class (filelist), I have exactly what you have above, and that part works well, except my debugger will not allow me to see the contents of $inner_data (komodo problem)
$_POST does contain the value I selected for that key.
When the update4 is processes, I can see the value being passed in, but I get this error:
Quote: | 2007-07-11 11:11:15
Fatal Error: MySQL error: 1054 - Unknown column 'sel_publish_key' in 'where clause' (# 1054).
SQL query: SELECT SQL_CALC_FOUND_ROWS * FROM filelist WHERE ( unique_sequence='1323' AND sel_publish_key='IFC' ) ORDER BY filename asc
Error in line 407 of file 'C:\apache\htdocs\search\includes\dml.mysqli.class.inc'.
Host Info: localhost via TCP/IP
Server Version: 5.0.27-community-nt
Client Info: 5.0.22, Client Encoding: latin1
Script: /search/search/filelist_autopublish(upd4).php
User Id: MGR
Remote Address: 127.0.0.1
Request URI: /search/search/filelist_autopublish(upd4).php?session_name=m enu2
|
So how do I get rid of the sel_publish_key from within the select statement of the filelist for this method?
Thanks, I am much closer, not sure why it did not work before, but it may have been because I was 4 versions behind of Radicore.
Dan
|
|
|
|
Re: Update 4 [message #941 is a reply to message #940] |
Wed, 11 July 2007 12:32   |
danpoleary
Messages: 49 Registered: February 2007
|
Member |
|
|
Yes, success,
Git it, thank you. It appears my root problem in trying to figure it out was that I was to many versions back in Radicore. Once I solved that, things started to fall into place.
One last question, When I select one record from the inner, the update works fine, but when I select multiple records, only the first one gets updated.
I checked the sql, and it only has the first records unique_sequence value in the 'where'. Should the update4, not pass all selections into the POST?
Dan
|
|
|
|
|
|
Goto Forum:
Current Time: Sat Apr 05 18:28:02 EDT 2025
Total time taken to generate the page: 0.07943 seconds
|