@@ -440,6 +440,34 @@ public function prepareInputForAdd($input) {
440
440
}
441
441
}
442
442
443
+ // handle description field and its inline pictures
444
+ if (isset ($ input ['_description ' ])) {
445
+ foreach ($ input ['_description ' ] as $ id => $ filename ) {
446
+ // TODO :replace PluginFormcreatorCommon::getDuplicateOf by Document::getDuplicateOf
447
+ // when is merged https://github.com/glpi-project/glpi/pull/9335
448
+ if ($ document = PluginFormcreatorCommon::getDuplicateOf (Session::getActiveEntity (), GLPI_TMP_DIR . '/ ' . $ filename )) {
449
+ $ this ->value = str_replace ('id=" ' . $ input ['_tag_description ' ] . '" ' , $ document ->fields ['tag ' ], $ this ->value );
450
+ $ input ['_tag_description ' ][$ id ] = $ document ->fields ['tag ' ];
451
+ }
452
+ }
453
+
454
+ $ input = $ this ->addFiles (
455
+ $ input ,
456
+ [
457
+ 'force_update ' => true ,
458
+ 'content_field ' => null ,
459
+ 'name ' => 'description ' ,
460
+ ]
461
+ );
462
+
463
+ $ input ['description ' ] = Html::entity_decode_deep ($ input ['description ' ]);
464
+ foreach ($ input ['_tag_description ' ] as $ tag ) {
465
+ $ regex = '/<img[^>]+ ' . preg_quote ($ tag , '/ ' ) . '[^<]+>/im ' ;
466
+ $ input ['description ' ] = preg_replace ($ regex , "# $ tag# " , $ input ['description ' ]);
467
+ }
468
+ $ input ['description ' ] = Html::entities_deep ($ input ['description ' ]);
469
+ }
470
+
443
471
// generate a unique id
444
472
if (!isset ($ input ['uuid ' ])
445
473
|| empty ($ input ['uuid ' ])) {
@@ -469,6 +497,34 @@ public function prepareInputForUpdate($input) {
469
497
return false ;
470
498
}
471
499
500
+ // handle description field and its inline pictures
501
+ if (isset ($ input ['_description ' ])) {
502
+ foreach ($ input ['_description ' ] as $ id => $ filename ) {
503
+ // TODO :replace PluginFormcreatorCommon::getDuplicateOf by Document::getDuplicateOf
504
+ // when is merged https://github.com/glpi-project/glpi/pull/9335
505
+ if ($ document = PluginFormcreatorCommon::getDuplicateOf (Session::getActiveEntity (), GLPI_TMP_DIR . '/ ' . $ filename )) {
506
+ $ this ->value = str_replace ('id=" ' . $ input ['_tag_description ' ] . '" ' , $ document ->fields ['tag ' ], $ this ->value );
507
+ $ input ['_tag_description ' ][$ id ] = $ document ->fields ['tag ' ];
508
+ }
509
+ }
510
+
511
+ $ input = $ this ->addFiles (
512
+ $ input ,
513
+ [
514
+ 'force_update ' => true ,
515
+ 'content_field ' => null ,
516
+ 'name ' => 'description ' ,
517
+ ]
518
+ );
519
+
520
+ $ input ['description ' ] = Html::entity_decode_deep ($ input ['description ' ]);
521
+ foreach ($ input ['_tag_description ' ] as $ tag ) {
522
+ $ regex = '/<img[^>]+ ' . preg_quote ($ tag , '/ ' ) . '[^<]+>/im ' ;
523
+ $ input ['description ' ] = preg_replace ($ regex , "# $ tag# " , $ input ['description ' ]);
524
+ }
525
+ $ input ['description ' ] = Html::entities_deep ($ input ['description ' ]);
526
+ }
527
+
472
528
// generate a unique id
473
529
if (!isset ($ input ['uuid ' ])
474
530
|| empty ($ input ['uuid ' ])) {
@@ -831,7 +887,7 @@ public function showForm($ID, $options = []) {
831
887
echo Html::textarea ([
832
888
'name ' => 'description ' ,
833
889
'id ' => 'description ' ,
834
- 'value ' => $ this ->fields ['description ' ],
890
+ 'value ' => Toolbox:: convertTagToImage ( $ this ->fields ['description ' ], $ this ) ,
835
891
'enable_richtext ' => true ,
836
892
'filecontainer ' => 'description_info ' ,
837
893
'display ' => false ,
0 commit comments