Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9f3c46ff

Von Moritz Bunkus vor etwa 3 Jahren hinzugefügt

  • ID 9f3c46ffb16c200246c545faa7f17686aa461483
  • Vorgänger c1551e49
  • Nachfolger 2644d2a9

Benutzerdef. Var. als HTML-Feld: Breite & Höhe in Pixeln angeben

Unterschiede anzeigen:

SL/DB/CustomVariableConfig.pm
37 37
use constant OPTION_DEFAULTS =>
38 38
  {
39 39
    MAXLENGTH => 75,
40
    WIDTH => 30,
41
    HEIGHT => 5,
40
    WIDTH     => 225,
41
    HEIGHT    => 90,
42 42
  };
43 43

  
44 44
sub processed_options {
locale/de/all
3364 3364
  'Text blocks back'            => 'Textblöcke hinten',
3365 3365
  'Text blocks front'           => 'Textblöcke vorne',
3366 3366
  'Text field'                  => 'Textfeld',
3367
  'Text field and HTML field variables: \'WIDTH=w HEIGHT=h\' sets the width and height of the text field. They default to 30 and 5 respectively.' => 'Textfelder und HTML-Felder: \'WIDTH=w HEIGHT=h\' setzen die Breite und die Höhe des Textfeldes. Wenn nicht anders angegeben, so werden sie 30 Zeichen breit und fünf Zeichen hoch dargestellt.',
3367
  'Text field and HTML field variables: \'WIDTH=w HEIGHT=h\' sets the width and height of the field in pixels. They default to 225 and 90 respectively.' => 'Textfelder und HTML-Felder: \'WIDTH=w HEIGHT=h\' setzen die Breite und die Höhe des Feldes in Pixeln. Wenn nicht anders angegeben, so werden sie 225 Pixel breit und 90 Pixel hoch dargestellt.',
3368 3368
  'Text in CSV File'            => 'Spalte in der CSV Datei',
3369 3369
  'Text variables: \'MAXLENGTH=n\' sets the maximum entry length to \'n\'.' => 'Textzeilen: \'MAXLENGTH=n\' setzt eine Maximallänge von n Zeichen.',
3370 3370
  'Text, text field, HTML field and number variables: The default value will be used as-is.' => 'Textzeilen, Textfelder, HTML-Felder und Zahlenvariablen: Der Standardwert wird so wie er ist übernommen.',
locale/en/all
3363 3363
  'Text blocks back'            => '',
3364 3364
  'Text blocks front'           => '',
3365 3365
  'Text field'                  => '',
3366
  'Text field and HTML field variables: \'WIDTH=w HEIGHT=h\' sets the width and height of the text field. They default to 30 and 5 respectively.' => '',
3366
  'Text field and HTML field variables: \'WIDTH=w HEIGHT=h\' sets the width and height of the field in pixels. They default to 225 and 90 respectively.' => '',
3367 3367
  'Text in CSV File'            => '',
3368 3368
  'Text variables: \'MAXLENGTH=n\' sets the maximum entry length to \'n\'.' => '',
3369 3369
  'Text, text field, HTML field and number variables: The default value will be used as-is.' => '',
sql/Pg-upgrade2/custom_variables_convert_width_height_to_pixels.pl
1
# @tag: custom_variables_convert_width_height_to_pixels
2
# @description: Benutzerdefinierte Variablen: Optionen »WIDTH« & »HEIGHT« nach Pixel konvertieren
3
# @depends: release_3_5_8
4
package SL::DBUpgrade2::custom_variables_convert_width_height_to_pixels;
5

  
6
use strict;
7
use utf8;
8

  
9
use parent qw(SL::DBUpgrade2::Base);
10

  
11
use SL::DBUtils;
12

  
13
sub find_configs {
14
  my ($self) = @_;
15

  
16
  my $sql = <<SQL;
17
    SELECT id, options
18
    FROM custom_variable_configs
19
    WHERE (COALESCE(options, '') ~ 'WIDTH=|HEIGHT=')
20
      AND (type = 'textfield')
21
SQL
22

  
23
  return selectall_hashref_query($::form, $self->dbh, $sql);
24
}
25

  
26
sub fix_configs {
27
  my ($self, $configs) = @_;
28

  
29
  my $sql = <<SQL;
30
    UPDATE custom_variable_configs
31
    SET options = ?
32
    WHERE id = ?
33
SQL
34

  
35
  my $update_h = prepare_query($::form, $self->dbh, $sql);
36

  
37
  # Old defaults: 30 columns, 5 rows
38
  # New defaults: 225px width, 90px height
39

  
40
  foreach my $config (@{ $configs }) {
41
    $config->{options} =~ s{WIDTH=(\d+)}{  int($1 * (225 / 30.0)) }eg;
42
    $config->{options} =~ s{HEIGHT=(\d+)}{ int($1 * ( 90 /  5.0)) }eg;
43

  
44
    $update_h->execute(@{$config}{qw(options id)}) || $self->db_error($sql);
45
  }
46

  
47
  $update_h->finish;
48
}
49

  
50
sub run {
51
  my ($self) = @_;
52

  
53
  my $configs = $self->find_configs;
54
  $self->fix_configs($configs) if @{ $configs };
55

  
56
  return 1;
57
}
58

  
59
1;
templates/webpages/common/render_cvar_input.html
5 5
[%- USE LxERP %]
6 6

  
7 7
[%- DEFAULT var_name = HTML.escape(cvar_name_prefix) _ HTML.escape(var.config.name) _ HTML.escape(cvar_name_postfix) %]
8
[%- SET style_ = "width: " _ var.config.processed_options.WIDTH _ "px; height: " _ var.config.processed_options.HEIGHT _ "px" %]
8 9

  
9 10
[%- IF ( hide_non_editable && !var.config.is_flag('editable') ) %]
10 11
  [% L.hidden_tag(var_name, var.value) %]
......
15 16
[%- ELSIF ( var.config .type == 'bool' ) %]
16 17
  [% L.checkbox_tag(var_name, checked = var.value, for_submit = 1) %]
17 18
[%- ELSIF ( var.config .type == 'textfield' ) %]
18
  [% L.textarea_tag(var_name, var.value, cols = var.config.processed_options.WIDTH, rows = var.config.processed_options.HEIGHT) %]
19
  [% L.textarea_tag(var_name, var.value, style=style_) %]
19 20
[%- ELSIF ( var.config .type == 'htmlfield' ) %]
20
  [% L.textarea_tag(var_name, L.restricted_html(var.value), cols = var.config.processed_options.WIDTH, rows = var.config.processed_options.HEIGHT, class='texteditor') %]
21
  [% L.textarea_tag(var_name, L.restricted_html(var.value), class='texteditor', style=style_) %]
21 22
[%- ELSIF ( var.config.type == 'date' ) %]
22 23
  [% L.date_tag(var_name, var.value) %]
23 24
[%- ELSIF ( var.config.type == 'timestamp' ) %]
templates/webpages/custom_variable_config/form.html
138 138
  <br>
139 139
  <ul>
140 140
   <li>[%- 'Text variables: \'MAXLENGTH=n\' sets the maximum entry length to \'n\'.' | $T8 %]</li>
141
   <li>[%- 'Text field and HTML field variables: \'WIDTH=w HEIGHT=h\' sets the width and height of the text field. They default to 30 and 5 respectively.' | $T8 %]</li>
141
   <li>[%- 'Text field and HTML field variables: \'WIDTH=w HEIGHT=h\' sets the width and height of the field in pixels. They default to 225 and 90 respectively.' | $T8 %]</li>
142 142
   <li>[%- 'Number variables: \'PRECISION=n\' forces numbers to be shown with exactly n decimal places.' | $T8 %]</li>
143 143
   <li>[%- 'Selection fields: The option field must contain the available options for the selection. Options are separated by \'##\', for example \'Early##Normal##Late\'.' | $T8 %]</li>
144 144
  </ul>

Auch abrufbar als: Unified diff