The equivalent of <page name>.pdf is what I would need.

On Wed, Mar 25, 2009 at 7:16 PM, Yaron Koren <yaron57@gmail.com> wrote:
Samuel - thanks a lot; this looks good - it'll probably go into the next version of SF.

This code doesn't allow for setting the filename based on the values of other fields in the form, as you first suggested; which isn't that surprising: as you probably discovered while writing the code, getting those values is very difficult, since they haven't been submitted via form yet. You'd probably have to use some strange combination of Javascript and PHP, and I don't know if it's even possible. I certainly don't know if it's desirable, either, since you're basing the name on values that the user may not have even entered yet.

Thinking about it now, I can only think of two variables that it might make sense to add handling for: "<page name>" and "<unique number>". And I'm not sure if that first one is worth supporting either, since the page name might not have been set yet, if you're using the "one-step" form creation. The second one probably makes sense, though, and could probably use similar code to the handling in the "{{{info|page name=" field.

-Yaron


2009/3/25 Brian <Brian.Mingus@colorado.edu>
I *need* this feature as well. Will this be included in semantic forms subversion head soon?

Dear Yaron, please review/commit! ;-)

On Wed, Mar 25, 2009 at 8:28 AM, Samuel Lampa <samuel.lampa.l@rilnet.com> wrote:
Sorry, the section @@ -164,6 +164,13 @@ wasn't mean to be included. New
diff attached below.

(That was my hack for sending variables to the form via URL (using
parameter name 'sfDestFile'), and then using it to replace a placeholder
('destination_filename') in the form definition)

// Samuel


Index: includes/SF_FormInputs.inc
===================================================================
--- includes/SF_FormInputs.inc    (revision 47204)
+++ includes/SF_FormInputs.inc    (working copy)
@@ -34,9 +34,9 @@
    return array_map('addslashes', $names_array);
  }

-  static function uploadLinkHTML($input_id, $delimiter = null) {
+  static function uploadLinkHTML($input_id, $delimiter = null,
$destination_filename) {
    $upload_window_page = SpecialPage::getPage('UploadWindow');
-    $query_string = "sfInputID=$input_id";
+    $query_string = "sfInputID=$input_id" . "&" .
"wpDestFile=$destination_filename";
    if ($delimiter != null)
      $query_string .= "&sfDelimiter=$delimiter";
    $upload_window_url =
$upload_window_page->getTitle()->getFullURL($query_string);
@@ -117,7 +117,12 @@
      } else {
        $delimiter = null;
      }
-      $text .= SFFormInputs::uploadLinkHTML($input_id, $delimiter);
+      if (array_key_exists('destination_filename', $other_args)) {
+        $destination_filename = $other_args['destination_filename'];
+      } else {
+        $destination_filename = "";
+      }
+      $text .= SFFormInputs::uploadLinkHTML($input_id, $delimiter,
$destination_filename);
    }
    return array($text, null);
  }
Index: includes/SF_FormField.inc
===================================================================
--- includes/SF_FormField.inc    (revision 47204)
+++ includes/SF_FormField.inc    (working copy)
@@ -16,6 +16,7 @@
    // the following fields are not set by the form-creation page
    // (though they could be)
    var $is_uploadable;
+    var $destination_filename;
    var $field_args;
    var $autocomplete_source;
    var $autocomplete_field_type;
@@ -38,11 +39,12 @@
        $f->is_hidden = false;
        $f->is_restricted = false;
        $f->is_uploadable = false;
+        $f->destination_filename = "";
        $f->possible_values = null;
        return $f;
    }

-    static function createFromDefinition($field_name, $input_name,
$is_mandatory, $is_hidden, $is_uploadable, $possible_values,
$is_disabled, $is_list, $input_type, $field_args, $all_fields,
$strict_parsing) {
+    static function createFromDefinition($field_name, $input_name,
$is_mandatory, $is_hidden, $is_uploadable, $destination_filename,
$possible_values, $is_disabled, $is_list, $input_type, $field_args,
$all_fields, $strict_parsing) {
        // see if this field matches one of the fields defined for this
        // template - if it is, use all available information about
        // that field; if it's not, either include it in the form or
@@ -73,6 +75,7 @@
        $f->is_mandatory = $is_mandatory;
        $f->is_hidden = $is_hidden;
        $f->is_uploadable = $is_uploadable;
+        $f->destination_filename = $destination_filename;
        $f->possible_values = $possible_values;
        $f->input_type = $input_type;
        $f->field_args = $field_args;
Index: includes/SF_FormPrinter.inc
===================================================================
--- includes/SF_FormPrinter.inc    (revision 47204)
+++ includes/SF_FormPrinter.inc    (working copy)
@@ -435,6 +442,10 @@
              $is_restricted = true;
            } elseif ($component == 'uploadable') {
              $field_args['is_uploadable'] = true;
+            } elseif (substr($component, 0, 20) == 'destination
filename') {
+        // Extract the destination filename from a string of the form
"destination filename=<the actual destination filename>" in the URL // SHL
+              $fDestinationFilename = explode('=',$component);
+              $field_args['destination_filename'] =
$fDestinationFilename[1];
            } elseif ($component == 'list') {
              $is_list = true;
            } elseif ($component == 'autocomplete') {
@@ -710,7 +721,7 @@
            // parameters in the form definition, and any information from
            // the template definition (contained in the $all_fields
parameter)
            $form_field =
SFFormField::createFromDefinition($field_name, $input_name,
-              $is_mandatory, $is_hidden, $is_uploadable,
$possible_values, $is_disabled,
+              $is_mandatory, $is_hidden, $is_uploadable,
$destination_filename, $possible_values, $is_disabled,
              $is_list, $input_type, $field_args, $all_fields,
$strict_parsing);
            // if a property was set in the form definition, overwrite
whatever
            // is set in the template field - this is somewhat of a
hack, since

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com

_______________________________________________
Semediawiki-user mailing list
Semediawiki-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-user


------------------------------------------------------------------------------


_______________________________________________
Semediawiki-user mailing list
Semediawiki-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-user