Artikelstammdaten: HTML in Langtexten nutzen
authorMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 14 Jan 2014 15:04:43 +0000 (16:04 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 1 Apr 2014 11:12:25 +0000 (13:12 +0200)
SL/DB/Part.pm
SL/DB/Translation.pm
SL/IC.pm
bin/mozilla/ic.pl
templates/webpages/ic/form_header.html
templates/webpages/ic/parts_language_selection.html [new file with mode: 0644]
templates/webpages/ic/tabs/_edit_translations.html

index ecdaeaa..89630ec 100644 (file)
@@ -9,6 +9,7 @@ use SL::DBUtils;
 use SL::DB::MetaSetup::Part;
 use SL::DB::Manager::Part;
 use SL::DB::Chart;
+use SL::DB::Helper::AttrHTML;
 use SL::DB::Helper::TransNumberGenerator;
 use SL::DB::Helper::CustomVariables (
   module      => 'IC',
@@ -40,6 +41,8 @@ __PACKAGE__->meta->add_relationships(
 
 __PACKAGE__->meta->initialize;
 
+__PACKAGE__->attr_html('notes');
+
 __PACKAGE__->before_save('_before_save_set_partnumber');
 
 sub _before_save_set_partnumber {
index 82362d4..5087ccc 100644 (file)
@@ -1,15 +1,14 @@
-# This file has been auto-generated only because it didn't exist.
-# Feel free to modify it at will; it will not be overwritten automatically.
-
 package SL::DB::Translation;
 
 use strict;
 
 use SL::DB::MetaSetup::Translation;
+use SL::DB::Helper::AttrHTML;
 
 __PACKAGE__->meta->initialize;
 
-# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
 __PACKAGE__->meta->make_manager_class;
 
+__PACKAGE__->attr_html('longdescription');
+
 1;
index 649ad2f..191a2d3 100644 (file)
--- a/SL/IC.pm
+++ b/SL/IC.pm
@@ -40,6 +40,7 @@ use YAML;
 
 use SL::CVar;
 use SL::DBUtils;
+use SL::HTML::Restrict;
 use SL::TransNumber;
 
 use strict;
@@ -227,6 +228,7 @@ sub save {
   my @values;
   # connect to database, turn off AutoCommit
   my $dbh = $form->get_standard_dbh;
+  my $restricter = SL::HTML::Restrict->create;
 
   # save the part
   # make up a unique handle and store in partnumber field
@@ -371,7 +373,7 @@ sub save {
              $form->{lastcost},
              $form->{weight},
              $form->{unit},
-             $form->{notes},
+             $restricter->process($form->{notes}),
              $form->{formel},
              $form->{rop},
              conv_i($form->{warehouse_id}),
@@ -405,7 +407,7 @@ sub save {
     $sth   = $dbh->prepare($query);
 
     foreach my $translation (@translations) {
-      do_statement($form, $sth, $query, conv_i($form->{id}), conv_i($translation->{language_id}), $translation->{translation}, $translation->{longdescription});
+      do_statement($form, $sth, $query, conv_i($form->{id}), conv_i($translation->{language_id}), $translation->{translation}, $restricter->process($translation->{longdescription}));
     }
 
     $sth->finish();
index 473467b..3a97c8e 100644 (file)
@@ -39,6 +39,7 @@ use SL::AM;
 use SL::CVar;
 use SL::IC;
 use SL::Helper::Flash;
+use SL::HTML::Util;
 use SL::ReportGenerator;
 
 #use SL::PE;
@@ -1382,6 +1383,8 @@ sub generate_report {
     }
     map { $row->{$_}{link} = $ref->{$_} } qw(drawing microfiche);
 
+    $row->{notes}{data} = SL::HTML::Util->strip($ref->{notes});
+
     $report->add_data($row);
 
     my $next_ref = $form->{parts}[$idx + 1];
@@ -1628,6 +1631,7 @@ sub form_header {
   CVar->render_inputs('variables' => $form->{CUSTOM_VARIABLES}, show_disabled_message => 1)
     if (scalar @{ $form->{CUSTOM_VARIABLES} });
 
+  $::request->layout->use_javascript("${_}.js") for qw(ckeditor/ckeditor ckeditor/adapters/jquery);
   $form->header;
   #print $form->parse_html_template('ic/form_header', { ALL_PRICE_FACTORS => $form->{ALL_PRICE_FACTORS},
   #                                                     ALL_UNITS         => $form->{ALL_UNITS},
index 296cd16..20ff5a9 100644 (file)
@@ -1,6 +1,6 @@
 [%- USE T8 %]
 [%- USE HTML %]
-[%- USE LxERP %][%- USE L -%]
+[%- USE LxERP %][%- USE L -%][%- USE P -%]
 [% PROCESS 'common/select_warehouse_bin.html' %]
  <p><div class="listtop">[% title %]  [% HTML.escape(partnumber) %]  [% HTML.escape(description) %]</div></p>
 
               <th align="left">[% 'Part Notes' | $T8 %]</th>
               <th align="left">[% 'Formula' | $T8 %]</th>
              </tr>
-             <tr>
+             <tr valign="top">
               <td>
-               <textarea name="notes" rows="[% HTML.escape(notes_rows) %]" cols="45" wrap="soft">[% HTML.escape(notes) %]</textarea>
+               [% L.textarea_tag("notes", P.restricted_html(notes), class="texteditor", style="width: 600px; height: 200px") %]
               </td>
               <td>
                <ilayer>
diff --git a/templates/webpages/ic/parts_language_selection.html b/templates/webpages/ic/parts_language_selection.html
new file mode 100644 (file)
index 0000000..58e1832
--- /dev/null
@@ -0,0 +1,69 @@
+[%- USE T8 %]
+[%- USE HTML %][%- USE L -%][%- USE P -%]
+ <form name="Form">
+
+  <input type="hidden" name="input_name" value="[% HTML.escape(input_name) %]">
+
+  <div class="listtop">[% title %]</div>
+
+  <p>[% 'Please insert your language values below' | $T8 %]</p>
+
+  <p>
+   <table>
+    <tr class="listheading">
+     <th class="listheading">&nbsp;</th>
+     [%- FOREACH col = HEADER %]
+     <th nowrap class="listheading">[% col.column_title %]</th>
+     [%- END %]
+    </tr>
+
+    [%- FOREACH row = LANGUAGES %]
+    <tr class="listrow[% loop.count % 2 %]">
+     <td>[% L.hidden_tag("id_" _ loop.count, row.id) %][% HTML.escape(row.description) %]</td>
+     <td>
+       [%- IF row.translation_area %]
+         [% L.textarea_tag("translation_" _ loop.count, row.translation, rows=row.translation_rows, cols="40", wrap="soft") %]
+       [%- ELSE %]
+         [% L.input_tag("translation_" _ loop.count, row.translation) %]
+       [%- END %]
+     </td>
+     <td>
+      [% L.textarea_tag("longdescription_" _ loop.count, P.restricted_html(row.longdescription), class="texteditor", style="width: 500px; height: 100px") %]
+     </td>
+    </tr>
+
+    [%- IF loop.last %]
+    <input type="hidden" id="rowcount" name="rowcount" value="[% loop.count %]">
+    [%- END %]
+    [%- END %]
+   </table>
+  </p>
+
+  <p>
+   <button type="button" onclick="languages_updated()">[% 'Close' | $T8 %]</button>
+  </p>
+
+ </form>
+
+ <script type="text/javascript">
+  <!--
+      function languages_updated() {
+        var languages = "";
+        for (var i = 1; i <= (document.getElementsByName("rowcount")[0].value); i++) {
+          var id              = "id_" + i ;
+          var translation     = "translation_" + i ;
+          var longdescription = "longdescription_" + i;
+
+          languages = languages +
+            "---+++---" + $('#id_' + i).val() +
+            "--++--" + $('#translation_' + i).val() +
+            "--++--"  + $('#longdescription_' + i).val();
+        }
+        console.info(languages);
+
+        window.opener.document.getElementsByName(document.Form.input_name.value)[0].value = languages;
+
+        self.close();
+      }
+      //-->
+ </script>
index 61884bf..1d0d6c1 100644 (file)
@@ -15,7 +15,7 @@
    <tr class="listrow" valign="top">
     <td>[% HTML.escape(language.description) %]</td>
     <td>[% L.input_tag("translations[].translation", translation.translation) %]</td>
-    <td>[% L.textarea_tag("translations[].longdescription", translation.longdescription, id="translations_longdescription_" _ language_id, style="width: 500px; height: 100px") %]</td>
+    <td>[% L.textarea_tag("translations[].longdescription", P.restricted_html(translation.longdescription), id="translations_longdescription_" _ language_id, class="texteditor", style="width: 500px; height: 100px") %]</td>
    </tr>
   [%- END %]
  </table>