This is a TNG mod directive file %name:FindAGrave Links% %version:12.0.0.5% %description: For users who flag FindAGrave references by typing GRid=nnnnnn in the note associated with a Burial event. Adds code to function insertLink in genblib.php to change a GRid reference into an URL. The subsequent normal action of the function will turn that URL into a hyperlink.
(No longer installs fagwidget.php, because changes to the FindAGrave website broke it.) % %wikipage:FindAGrave_Links% %author:Robin Richmond:https://tng.lythgoes.net/wiki/index.php?title=User:Robinrichm% ********************************** *** Revision History *** v12.0.0.5 - 16 Nov 2018 - Removed the admin options, since the old version of FindAGrave that uses GRid and CRid is gone. - No longer installs the FindAGrave widget, since the widget depended on the old version of FindAGrave. - Includes the correct filename from Show Mod Names - Removed case sensitivity of GRid and CRid. v12.0.0.4 - 23 Mar 2018 - No functional changes. - Changed the search text of location 1 of genlib.php - The top-of-file comment - Changed the search text of Location 2 of admin_genconfig.php, where the last field in the Miscellaneous section changed - Updated the cust_text.php search strings. - Updated the author tag. - Renamed the widget and its css file to use the base filename rrfindagravewidget v3b - 11 Dec 2017 - The Widget uses old.findagrave.com - The Admin>>General Settings>Miscellaneous option installed by this mod now specifies www.findagrave.com for the new site design and old.findagrave.com for the old site design - Uses the new FindAGrave URL format if note has been selected in the Admin screen v3a - 28 Aug 2017 - Uses the original FindAGrave URLs if none have been selected in the Admin screen v3 - 12 Aug 2017 - The FindAGrave Grave and Cemetery URLs are defined by admin_setup.php - at Admin >> Setup >> General Settings >> Miscellaneous - Also installs the FindAGrave Widget, and includes SQL files in the mod subfolder. v2 - 5 Jul 2017 - Handles FindAGrave Cemetery pages (which I link to from Cemetery descriptions) as well as links to FindAGrave Memorial pages (which I link to from burial event descriptions and FindAGrave citation notes). ************************************************************************* %target:genlib.php% *************** genlib.php Location 1 - Top-of-file comments %location:% if(isset($_GET['cms']) || isset($_POST['cms'])) die("Sorry!"); %end:% %insert:before% # genlib.php has been modified by Robin Richmond's FindAGrave Links mod: # - function insertLinks() now calls function rrFindAGraveLinks(), which is in # globallib.php. It converts FindAGrave page references in the form GRid=nnnn and # CRid=nnnn into full hyperlinks. %end:% *************** genlib.php Location 2 - new code in function insertLinks %location:% $posidx--; } %end:% %insert:after% ###FindAGrave Links mod Location 2: Change FindAGrave references to hyperlinks using the #function rrFindAGraveLinks in globallib.php, where it is available to Admin programs, #which do not Include genlib.php. #Register this mod $GLOBALS['tngModNames']['FindAGrave Links']['genlib.php(insertLinks)'] = '5'; $notes = rrFindAGraveLinks($notes); ###FindAGrave Links mod Location 2: End of Insertion %end:% ************************************************************************* %target:globallib.php% *************** globallib.php Location 1 - Top-of-file comments %location:% @ini_set( "session.bug_compat_warn", "0" ); %end:% %insert:before% # globallib.php has been modified by Robin Richmond's FindAGrave Links mod # to add function rrFindAGraveLinks(), which finds occurrences of GRid=nnnn # and CRid=nnnn in the function argument, and changes them into full URLs %end:% *************** globallib.php Location 2 - new function rrFindAGraveLinks %location:% return $truncated; } %end:% %insert:after% ############################ ###FindAGrave Links mod Location 2: New Function to resolve abbreviated FindAGrave references. # rrFindAGraveLinks finds occurrences of GRid=nnnn and CRid=nnnn in the # function argument, and changes them into hyperlinks, using hard-coded URLs since # FindAGrave no longer supports two versions of their website. # variables $tngconfig['rrfaggraveurl'] and $tngconfig['rrfagcemeteryurl']. # The hyperinks created here all specify target='_blank', thus opening the FindAGrave page in a new window. function rrFindAGraveLinks($notes) { global $tngconfig, $text; #Register this mod $GLOBALS['tngModNames']['FindAGrave Links']['globallib.php(rrFindAGraveLinks)'] = '5'; #First, GRid=nnnn for burial memorial pages #The GRid number will be added at the end of this URL, as though it were a folder name. $rrfagurl = 'https://www.findagrave.com/memorial/'; #Use preg_replace to find a GRid=nnnn reference that is not already embedded #in a hyperlink. That is, make sure that GRid is NOT preceded by the ampersand #or semicolon that could precede it in an old-style FindAGrave reference. $rrfagreplace = '$1' . $text['rrfag-memorial'] . ' $2$3'; $notes = preg_replace('/([^&;]|^)GRid=(\d+)(\D|$)/i', $rrfagreplace, $notes); #Next, CRid=nnn for cemetery pages. This replacement works just like the one above; #we're just looking for CRid instead of GRid, and replacing it with a different URL. #The CRid number will be added at the end of this URL, as though it were a folder name. $rrfagurl = 'https://www.findagrave.com/cemetery/'; $rrfagreplace = '$1' . $text['rrfag-cemetery'] . ' $2$3'; $notes = preg_replace('/([^&;]|^)CRid=(\d+)(\D|$)/i', $rrfagreplace, $notes); return $notes; } #end of function rrFindAGraveLinks ###FindAGrave Links mod Location 2: End of insertion %end:% ************************************************************************** %target:languages/English/cust_text.php% %location:% //Mods should put their changes before this line, local changes should come after it. %end:% %insert:before% ################ FindAGrave Links Mod: New Strings ## Strings for the new function in globallib.php $text['rrfag-memorial'] = 'FindAGrave Memorial'; $text['rrfag-cemetery'] = 'FindAGrave Cemetery'; ################ FindAGrave Links Mod: End of New Strings %end:% ************************************************************************* %target:languages/English-UTF8/cust_text.php% %location:% //Mods should put their changes before this line, local changes should come after it. %end:% %insert:before% ################ FindAGrave Links Mod: New Strings ## Strings for admin_genconfig.php ## Strings for the new function in globallib.php $text['rrfag-memorial'] = 'FindAGrave Memorial'; $text['rrfag-cemetery'] = 'FindAGrave Cemetery'; ################ FindAGrave Links Mod: End of New Strings %end:%