Author Topic: Is it worth of creating a hook?  (Read 4774 times)

Ginko

  • Newbie
  • *
  • Posts: 6
    • View Profile
Is it worth of creating a hook?
« on: April 16, 2010, 08:06:51 PM »
I've made a small modification to links highlighting in environment/functions/general.php

Just added several strings to the function 'convert_to_links'. I'm interested whether such patch will be upgrade safe or I'll have to create a hook.

ignacio

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
Re: Is it worth of creating a hook?
« Reply #1 on: April 19, 2010, 10:37:10 AM »
Any code in general.php will be overwritten. Can you share the changes you made? If it is useful to everyone we can add it for next release. If not we can add a hook.

Ginko

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Is it worth of creating a hook?
« Reply #2 on: April 23, 2010, 07:47:28 PM »
I doubt that it can be useful for someone, it's rather single-purpose ;-) The basic idea is to search a pattern of a log file name in the text and to add next to the log a link to external log viewer. Here's diff with original general.php file (I've replaced my domain with <my_domain>):

Code: [Select]
diff -aur general_original.php general.php
--- general_original.php        2010-04-11 14:19:50.000000000 +0300
+++ general.php 2010-04-24 01:31:54.000000000 +0300
@@ -573,6 +573,9 @@
        //Convert every word starting with "www." into a hyperlink
        $text = preg_replace('@(>|\s|^)(www.([-\w\.]+)+(:\d+)?(/([%\w/_\-\.\+]*(\?[^\s<]+)?)?)?)@', '$1<a href="http://$2" target="_blank">$2</a>', $text);

+       //log viewer
+       $text = preg_replace('(([0-9A-F]{8}) ([0-9A-F]{8}) ([0-9A-F]{8}) ([0-9A-F]{8}))', '$1 $2 $3 $4 <a style="border: 1px solid; background: #ffffbb;" href="http://<my_domain>/sip-log-viewer/index.html?h323id=$1+$2+$3+$4&master=<my_domain>" target="_blank"><b>(log)</b></a>', $text);
+
        //Convert every email address into an <a href="mailto:... hyperlink
        $text = preg_replace('/([^\:a-zA-Z0-9>"\._\-\+=])([a-zA-Z0-9]+[a-zA-Z0-9\._\-\+]*@[a-zA-Z0-9_\-]+([a-zA-Z0-9\._\-]+)+)/', '$1<a href="mailto:$2" target="_blank">$2</a>', $text);
        return $text;



 

Ginko

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Is it worth of creating a hook?
« Reply #3 on: May 06, 2010, 08:35:11 AM »
As far as I understand I'll need a hook if I want the modification to be upgrade safe. Can someone help with creating a hook? Any help will be appreciated.

 

anything