Revision ac4921aa
Von Moritz Bunkus vor etwa 8 Jahren hinzugefügt
SL/DBUpgrade2/Base.pm | ||
---|---|---|
143 | 143 |
$self->db_query(qq|ALTER TABLE $params{schema}."$params{table}" DROP CONSTRAINT "${_}"|) for map { $_->[0] } @{ $constraints }; |
144 | 144 |
} |
145 | 145 |
|
146 |
sub convert_column_to_html { |
|
147 |
my ($self, $table, $column) = @_; |
|
148 |
|
|
149 |
my $sth = $self->dbh->prepare(qq|UPDATE $table SET $column = ? WHERE id = ?|) || $self->dberror; |
|
150 |
|
|
151 |
foreach my $row (selectall_hashref_query($::form, $self->dbh, qq|SELECT id, $column FROM $table WHERE $column IS NOT NULL|)) { |
|
152 |
next if !$row->{$column} || (($row->{$column} =~ m{^<[a-z]+>}) && ($row->{$column} =~ m{</[a-z]+>$})); |
|
153 |
|
|
154 |
my $new_content = "" . $::request->presenter->escape($row->{$column}); |
|
155 |
$new_content =~ s{\r}{}g; |
|
156 |
$new_content =~ s{\n\n+}{</p><p>}g; |
|
157 |
$new_content =~ s{\n}{<br />}g; |
|
158 |
$new_content = "<p>${new_content}</p>" if $new_content; |
|
159 |
|
|
160 |
$sth->execute($new_content, $row->{id}) if $new_content ne $row->{$column}; |
|
161 |
} |
|
162 |
|
|
163 |
$sth->finish; |
|
164 |
} |
|
165 |
|
|
146 | 166 |
1; |
147 | 167 |
__END__ |
148 | 168 |
|
... | ... | |
317 | 337 |
This method is the entry point for the actual upgrade. Each upgrade |
318 | 338 |
script must provide this method. |
319 | 339 |
|
340 |
=item C<convert_column_to_html $table, $column> |
|
341 |
|
|
342 |
Converts the content of a single column from text to HTML suitable for |
|
343 |
use with the ckeditor. |
|
344 |
|
|
320 | 345 |
=back |
321 | 346 |
|
322 | 347 |
=head1 BUGS |
Auch abrufbar als: Unified diff
SL::DBUpgrade2::Base: Spalte-zu-HTML-Funktion ausgelagert
Damit diese Funktion auch aus anderen Datenbankupgradescripten heraus
benutzt werden kann, wurde sie nun in die Basisklasse verschoben.