Template object for key import (upload) form
497634
function tpl_key_import_form($attrib)
    {
        $attrib += array('id' => 'rcmKeyImportForm');

        $upload = new html_inputfield(array('type' => 'file', 'name' => '_file',
            'id' => 'rcmimportfile', 'size' => 30));
        $search = new html_inputfield(array('type' => 'text', 'name' => '_search',
            'id' => 'rcmimportsearch', 'size' => 30));

        $upload_button = new html_inputfield(array(
                'type'    => 'button',
                'value'   => $this->rc->gettext('import'),
                'class'   => 'button',
                'onclick' => "return rcmail.command('plugin.enigma-import','',this,event)",
        ));

        $search_button = new html_inputfield(array(
                'type'    => 'button',
                'value'   => $this->rc->gettext('search'),
                'class'   => 'button',
                'onclick' => "return rcmail.command('plugin.enigma-import-search','',this,event)",
        ));

        $upload_form = html::div(null,
            rcube::Q($this->enigma->gettext('keyimporttext'), 'show')
            . html::br() . html::br() . $upload->show()
            . html::br() . html::br() . $upload_button->show()
        );

        $search_form = html::div(null,
            rcube::Q($this->enigma->gettext('keyimportsearchtext'), 'show')
            . html::br() . html::br() . $search->show()
            . html::br() . html::br() . $search_button->show()
        );

        $form = html::tag('fieldset', '', html::tag('legend', null, $this->enigma->gettext('keyimportlabel')) . $upload_form)
            . html::tag('fieldset', '', html::tag('legend', null, $this->enigma->gettext('keyimportsearchlabel')) . $search_form);

        $this->rc->output->add_label('selectimportfile', 'importwait', 'nopubkeyfor', 'nopubkeyforsender',
            'encryptnoattachments','encryptedsendialog','searchpubkeyservers', 'importpubkeys',
            'encryptpubkeysfound',  'search', 'close', 'import', 'keyid', 'keylength', 'keyexpired',
            'keyrevoked', 'keyimportsuccess', 'keyservererror');
        $this->rc->output->add_gui_object('importform', $attrib['id']);
        $this->rc->output->include_script('publickey.js');

        $out = $this->rc->output->form_tag(array(
            'action'  => $this->rc->url(array('action' => $this->rc->action, 'a' => 'import')),
            'method'  => 'post',
            'enctype' => 'multipart/form-data') + $attrib,
            $form
        );

        return $out;
    }
104767
def get_form(self, key, form_class=None):
        
        if form_class is None:
            form_class = self.get_form_class(key)
        return form_class(**self.get_form_kwargs(key))
565929
function form () {
  form.form = $("#swagger-parser-form");

  form.allow = {
    label: form.form.find("#allow-label"),
    menu: form.form.find("#allow-menu"),
    json: form.form.find("input[name=allow-json]"),
    yaml: form.form.find("input[name=allow-yaml]"),
    text: form.form.find("input[name=allow-text]"),
    empty: form.form.find("input[name=allow-empty]"),
    unknown: form.form.find("input[name=allow-unknown]")
  };

  form.refs = {
    label: form.form.find("#refs-label"),
    menu: form.form.find("#refs-menu"),
    external: form.form.find("input[name=refs-external]"),
    circular: form.form.find("input[name=refs-circular]")
  };

  form.validate = {
    label: form.form.find("#validate-label"),
    menu: form.form.find("#validate-menu"),
    schema: form.form.find("input[name=validate-schema]"),
    spec: form.form.find("input[name=validate-spec]")
  };

  form.tabs = {
    url: form.form.find("#url-tab"),
    text: form.form.find("#text-tab")
  };

  form.method = {
    button: form.form.find("button[name=method]"),
    menu: form.form.find("#method-menu")
  };

  form.samples = {
    url: {
      container: form.form.find("#url-sample"),
      link: form.form.find("#url-sample-link"),
    },
    text: {
      container: form.form.find("#text-sample"),
      link: form.form.find("#text-sample-link"),
    }
  };

  form.url = form.form.find("input[name=url]");
  form.textBox = null; // This is set in editors.js
  form.bookmark = form.form.find("#bookmark");
}
118774
def formfield(self, **kwargs):
        """"""

        defaults = dict(
            form_class=LocalizedFieldForm,
            required=False if self.blank else self.required
        )
        defaults.update(kwargs)
        return super().formfield(**defaults)
776558
def _form_loader(self, _):
        '''
        
        '''
        data = {}
        for key in self.request.arguments:
            val = self.get_arguments(key)
            if len(val) == 1:
                data[key] = val[0]
            else:
                data[key] = val
        return data
509475
def process_form(self, instance, field, form, empty_marker=None,
                     emptyReturnsMarker=False):
        

        # a poor workaround for Plone repeating itself.
        # XXX this is important XXX
        key = field.getName() + '_value'
        if key in instance.REQUEST:
            return instance.REQUEST[key], {}
        value = form.get(field.getName(), empty_marker)
        # When a recordswidget's visibility is defined as hidden
        # '...visible={'view': 'hidden', 'edit': 'hidden'},...' the template
        # displays it as an input field with the attribute 'value' as a string
        # 'value="[{:},{:}]"'. This makes the system save the content of the
        # widget as the string instead of a dictionary inside a list, so we
        # need to check if the variable contains a python object as a string.
        if value and value is not empty_marker and isinstance(value, str):
            import ast
            try:
                value = ast.literal_eval(form.get(field.getName()))
            except:
                # cannot resolve string as a list!
                return empty_marker

        if not value:
            return value, {}
        if value is empty_marker:
            return empty_marker
        if emptyReturnsMarker and value == '':
            return empty_marker

        # we make sure that empty "value" inputs are saved as "" empty string.
        for i in range(len(value)):
            value[i] = dict(value[i])
            if 'value' not in value[i]:
                value[i]['value'] = ''

        instance.REQUEST[key] = value
        return value, {}
1047883
def clean_form_template(self):
        
        form_template = self.cleaned_data.get('form_template', '')
        if form_template:
            try:
                get_template(form_template)
            except TemplateDoesNotExist:
                msg = _('Selected Form Template does not exist.')
                raise forms.ValidationError(msg)
        return form_template
1140477
function template(str, params){
  return str.replace(/%(\w*)%/g, function(m, key){
    return params[key];
  });
}
1013978
def xform_key(self, key):
        ''''''

        newkey = hashlib.sha1(key.encode('utf-8'))
        return newkey.hexdigest()
400982
def render_export_form(self, request, context, form_url=''):
        
        context.update({
            'has_change_permission': self.has_change_permission(request),
            'form_url': mark_safe(form_url),
            'opts': self.opts,
            'add': True,
            'save_on_top': self.save_on_top,
        })

        return TemplateResponse(request, self.export_form_template, context)
711850
def template(self, key):
        
        try:
            return self._templates[key]
        except KeyError:
            return Template.Plugins[key]
19487
@POST
    @Consumes("multipart/form-data")
    @RequiresPermissions(I18nPermissions.KEY_WRITE)
    public Response importTranslations(FormDataMultiPart multiPart) {
        WebAssertions.assertNotNull(multiPart, "Missing input file");

        int importedKeys = 0;
        for (BodyPart bodyPart : multiPart.getBodyParts()) {
            importedKeys += importFile(bodyPart);
        }

        String importedKeysMessage = String.format(LOADED_KEYS_MESSAGE, importedKeys);
        LOGGER.debug(importedKeysMessage);
        return Response.ok(importedKeysMessage, MediaType.TEXT_PLAIN_TYPE).build();
    }
915028
def upload_file(request):
    ''''''
    if request.method == 'POST':
        form = MediaForm(request.POST, request.FILES)
        if form.is_valid():
            context_dict = {}
            try:
                context_dict['copied_files'] = update_media_file(
                    request.FILES['zip_file'])
            except Exception as e:
                context_dict['error_message'] = e.message
            return render(request,
                          'django_admin/transfer_media_message.html',
                          context_dict)
    else:
        form = MediaForm()
    return render(request, 'django_admin/upload_media.html', {'form': form})
846301
def process_import(self, request, *args, **kwargs):
        
        if not self.has_import_permission(request):
            raise PermissionDenied

        form_type = self.get_confirm_import_form()
        confirm_form = form_type(request.POST)
        if confirm_form.is_valid():
            import_formats = self.get_import_formats()
            input_format = import_formats[
                int(confirm_form.cleaned_data['input_format'])
            ]()
            tmp_storage = self.get_tmp_storage_class()(name=confirm_form.cleaned_data['import_file_name'])
            data = tmp_storage.read(input_format.get_read_mode())
            if not input_format.is_binary() and self.from_encoding:
                data = force_text(data, self.from_encoding)
            dataset = input_format.create_dataset(data)

            result = self.process_dataset(dataset, confirm_form, request, *args, **kwargs)

            tmp_storage.remove()

            return self.process_result(result, request)
20698
def get_import_data_kwargs(self, request, *args, **kwargs):
        
        form = kwargs.get('form')
        if form:
            kwargs.pop('form')
            return kwargs
        return {}
244952
def key_file(self, value):
        """"""
        import os
        if os.path.isfile(value):
            self._keyfile = value
1317663
public function editTemplate()
    {
        $this->defaultData();

        $clazz = $this->getCurrentClass();
        $delivery = $this->getCurrentInstance();

        $formContainer = new DeliveryForm($clazz, $delivery);
        $myForm = $formContainer->getForm();

        $myForm->evaluate();

        if ($myForm->isSubmited()) {
            if ($myForm->isValid()) {
                $propertyValues = $myForm->getValues();

                // then save the property values as usual
                $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($delivery);
                $delivery = $binder->bind($propertyValues);

                // edit process label:
                $this->getClassService()->onChangeLabel($delivery);

                $this->setData("selectNode", tao_helpers_Uri::encode($delivery->getUri()));
                $this->setData('message', __('Delivery saved'));
                $this->setData('reload', true);
            }
        }

        $this->setData('contentForm', $this->getContentForm());

        $this->setData('uri', tao_helpers_Uri::encode($delivery->getUri()));
        $this->setData('classUri', tao_helpers_Uri::encode($clazz->getUri()));

        $this->setData('hasContent', !is_null($this->getClassService()->getContent($delivery)));

        $this->setData('formTitle', __('Delivery properties'));
        $this->setData('myForm', $myForm->render());

        if ($this->getServiceLocator()->get(\common_ext_ExtensionsManager::SERVICE_ID)->isEnabled('taoCampaign')) {
            $this->setData('campaign', \taoCampaign_helpers_Campaign::renderCampaignTree($delivery));
        }
        $this->setView('DeliveryTemplate/editDelivery.tpl');
    }