From 8c679b32b69e248125b8da5becef80275e1ec745 Mon Sep 17 00:00:00 2001
From: Earl Miles <merlin@logrus.com>
Date: Fri, 17 Oct 2008 18:55:38 +0000
Subject: [PATCH] #298934 by redndahead: Allow &path& as a more robust token
 replacement. Also for topic and base_url

---
 advanced_help.module          |  4 ++++
 help/using-advanced-help.html | 13 ++++++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/advanced_help.module b/advanced_help.module
index 5a1bdf5..157fed9 100644
--- a/advanced_help.module
+++ b/advanced_help.module
@@ -509,10 +509,12 @@ function advanced_help_view_topic($module, $topic, $popup = FALSE) {
     if ($popup) {
       $output = preg_replace('/href="topic:([^"]+)"/', 'href="' . strtr(url('help/$1', array('query' => 'popup=true')), array('%24' => '$')) . '"', $output);
       $output = preg_replace('/src="topic:([^"]+)"/', 'src="' . strtr(url('help/$1', array('query' => 'popup=true')), array('%24' => '$')) . '"', $output);
+      $output = preg_replace('/&topic:([^"]+)&/', strtr(url('help/$1', array('query' => 'popup=true')), array('%24' => '$')), $output);
     }
     else {
       $output = preg_replace('/href="topic:([^"]+)"/', 'href="' . strtr(url('help/$1'), array('%24' => '$')) . '"', $output);
       $output = preg_replace('/src="topic:([^"]+)"/', 'src="' . strtr(url('help/$1'), array('%24' => '$')) . '"', $output);
+      $output = preg_replace('/&topic:([^"]+)&/', strtr(url('help/$1'), array('%24' => '$')), $output);
     }
 
     global $base_path;
@@ -520,10 +522,12 @@ function advanced_help_view_topic($module, $topic, $popup = FALSE) {
     // Change 'path:' to the URL to the base help directory.
     $output = preg_replace('/href="path:([^"]+)"/', 'href="' . $base_path . $info['path'] . '/$1"', $output);
     $output = preg_replace('/src="path:([^"]+)"/', 'src="' . $base_path . $info['path'] . '/$1"', $output);
+    $output = str_replace('&path&', $base_path . $info['path'] .'/', $output);
 
     // Change 'base_url:' to the URL to the site.
     $output = preg_replace('/href="base_url:([^"]+)"/', 'href="' . strtr(url('$1'), array('%24' => '$')) . '"', $output);
     $output = preg_replace('/src="base_url:([^"]+)"/', 'src="' . strtr(url('$1'), array('%24' => '$')) . '"', $output);
+    $output = str_replace('&base_url&', $base_path, $output);
 
     if (!empty($info['navigation'])) {
       $topics = advanced_help_get_topics();
diff --git a/help/using-advanced-help.html b/help/using-advanced-help.html
index 4ea1070..6a32808 100644
--- a/help/using-advanced-help.html
+++ b/help/using-advanced-help.html
@@ -28,16 +28,19 @@ id. To embed links, use the following format:
 $output .= theme('advanced_help_topic', $module, $topic);
 </code>
 
-<p>Inside your help file, link to other topics using the format <strong>&lt;a href=&quot;topic:module/topic"&gt;</strong>. This
+<p>Inside your help file, link to other topics using the format <strong>&lt;a href="&amp;topic:module/topic&amp;"&gt;</strong>. This
 format will ensure the popup status remains consistent when switching between links.</p>
 
-<p>Use <strong>&lt;a href=&quot;path:example.jpg"&gt;</strong> to reference items 
+<p>Use <strong>&lt;a href="&amp;path&amp;example.jpg"&gt;</strong> to reference items
 within the help directory, such as images you wish to embed within the help text.</p>
 
-<p>Use <strong>&lt;a href=&quot;base_url:admin/settings/site-configuration"&gt;</strong> to reference any normal path in the site.</p>
+<p>Use <strong>&lt;a href="&amp;base_url&amp;admin/settings/site-configuration"&gt;</strong> to reference any normal path in the site.</p>
 
 <p>If the search module is enabled, the contents of help system will be indexed on cron. If you enable new modules and wish to immediately index its help text, visit the "Administration -> Reports -> Status report" and click the "Run cron manually" link.</p>
 
-<p>Example: <a href="path:nowhere.jpg">Don't click this!</a></p>
+<p>Example: <a href="&path&nowhere.jpg">Don't click this!</a></p>
 
-<p>See: <a href="topic:advanced_help/ini-file">ini file format</a></p>
+<p>See: <a href="&topic:advanced_help/ini-file&">ini file format</a></p>
+
+<p><strong>NOTE: </strong> In previous versions Advanced Help did not require the &amp;'s wrapped around the topic:, path:, and base_url: links.  This
+is currently still supported, but may be removed in a future version.  By adding the &'s these tokens are now not limited to href="" and src="" paramaters.</p>
-- 
GitLab