noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 169/173: Task #1907: Gestion : événement ajou


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 169/173: Task #1907: Gestion : événement ajout de lien hyperlnk
Date: Mon, 22 Mar 2021 12:59:26 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 5ffb31ea7e8820d58dfeffeb294f5d16775c213a
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Sat Mar 20 15:04:58 2021 +0100

    Task #1907: Gestion : événement ajout de lien hyperlnk
---
 include/lib/ac_common.php           | 12 ++++++++++++
 include/template/detail-action.php  | 17 +++++++++++------
 unit-test/include/lib/ac_common.php | 20 +++++++++++++++++++-
 3 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php
index 6c9a2d3..8f96a81 100644
--- a/include/lib/ac_common.php
+++ b/include/lib/ac_common.php
@@ -1558,4 +1558,16 @@ function rebuild_access_code($pan_code)
         $sep=($s_result != "" )?"/":"";
     }
     return $s_result;
+}
+
+/***
+ * Transform a http link into a clickable link
+ */
+function add_http_link($text)
+{
+    
+    $ret=preg_replace("!http[s]{0,1}://[[:graph:]*]*!",'<a href="\\0" 
target="_blank">\0</a>',$text);
+    
+    return $ret;
+
 }
\ No newline at end of file
diff --git a/include/template/detail-action.php 
b/include/template/detail-action.php
index 99d70b3..f3769b8 100644
--- a/include/template/detail-action.php
+++ b/include/template/detail-action.php
@@ -1,5 +1,6 @@
 <?php
 require_once NOALYSS_INCLUDE."/class/follow_up_other_concerned.class.php";
+
 //This file is part of NOALYSS and is under GPL 
 //see licence.txt
 $uniq=uniqid("tab",TRUE);
@@ -295,9 +296,10 @@ function small(p_id_textarea){
             elseif ($p_view == 'READ' || $editable_description == false)
             {
                 echo h2(_("Description"));
-
                 echo '<pre class="field_follow_up">';
-                echo h($acomment[0]['agc_comment']);
+                $comment_http= h($acomment[0]['agc_comment']);
+                $comment_http=add_http_link($comment_http);
+                echo $comment_http;
                 echo '</pre>';
             }
     } else {
@@ -305,6 +307,7 @@ function small(p_id_textarea){
           echo $description->input();
    }
 
+
         //---------------------------------- Comment 
-----------------------------------------------------------------------
    
    if (    Document_Option::can_add_comment($ag_id)  && 
@@ -364,7 +367,7 @@ function small(p_id_textarea){
                 $comment= h($m_desc.' 
'.$acomment[$c]['agc_id'].'('.$acomment[$c]['tech_user']." ".
                         $acomment[$c]['str_agc_date'].')').$js.
                                 '<pre class="field_follow_up" 
id="com'.$acomment[$c]['agc_id'].'"> '.
-                                " ".h($acomment[$c]['agc_comment']).'</pre>'
+                                " 
".add_http_link(h($acomment[$c]['agc_comment'])).'</pre>'
                                 ;
 
             }
@@ -373,7 +376,7 @@ function small(p_id_textarea){
                     $comment=h($m_desc.' 
'.$acomment[$c]['agc_id'].'('.$acomment[$c]['tech_user']." ".
                             $acomment[$c]['str_agc_date'].')').
                                     '<pre class="field_follow_up" 
id="com'.$acomment[$c]['agc_id'].'"> '.
-                                    " 
".h($acomment[$c]['agc_comment']).'</pre>'
+                                    " 
".add_http_link(h($acomment[$c]['agc_comment'])).'</pre>'
                                     ;
 
 
@@ -394,6 +397,7 @@ function small(p_id_textarea){
 
         }
     }
+   
 
     
 
@@ -488,6 +492,7 @@ for ($i=0;$i<sizeof($aAttachedFile);$i++) :
   </tr>
   <?php
 endfor;
+
   ?>
   </table>
 <?php if ( ! empty ($aAttachedFile)) :
@@ -540,7 +545,7 @@ catch(exception) { alert('<?php echo j(_('Je ne peux pas 
ajouter de fichier'))?>
   </div>
  <?php endif;?>
 </div>
-<?php if  ($p_view != 'NEW') : ?>
+<?php if  ($p_view != 'NEW') :  ?>
 Document créé le <?php echo $this->ag_timestamp ?> par <?php echo 
$this->ag_owner?>
 <?php endif; ?>
 
@@ -571,4 +576,4 @@ Document créé le <?php echo $this->ag_timestamp ?> par 
<?php echo $this->ag_ow
       $('related_action_div<?php echo $uniq?>').hide();
       $('dependant_action_div<?php echo $uniq?>').show();
   }  ;
-</script>
\ No newline at end of file
+</script>
diff --git a/unit-test/include/lib/ac_common.php 
b/unit-test/include/lib/ac_common.php
index b2bc19e..750fe4f 100644
--- a/unit-test/include/lib/ac_common.php
+++ b/unit-test/include/lib/ac_common.php
@@ -167,5 +167,23 @@ class Ac_CommonTest extends TestCase
         $this->assertEquals(
                 $result, trim(sql_filter_per($g_connection, 98, 99, "p_id", 
"j_tech_per")));
     }
-
+    /***
+     * @covers add_http_link
+     */
+    function testAdd_Http_link()
+    {
+        $text="A link on http://demo.noalyss.eu is ok";
+        $result=add_http_link($text);
+        $this->assertEquals('A link on <a href="http://demo.noalyss.eu"; 
target="_blank">http://demo.noalyss.eu</a> is ok',$result);
+        
+        $text="A link on 
https://demo.noalyss.eu/do.php?gDossier=33&ac=COMPTA/MENUFIN is ok";
+        $result=add_http_link($text);
+        $this->assertEquals('A link on <a 
href="https://demo.noalyss.eu/do.php?gDossier=33&ac=COMPTA/MENUFIN"; 
target="_blank">https://demo.noalyss.eu/do.php?gDossier=33&ac=COMPTA/MENUFIN</a>
 is ok',$result);
+        
+        
+        
+        $text = "The chain is not going to change 
htps:/demo.noalyss.eu/do.php?gDossier=33&ac=COMPTA/MENUFIN";
+        $this->assertEquals($text,$text);
+        
+    }
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]