/**
  * Given a block of HTML text, replace any local-system urls with tokenized
  * placeholders. These placeholders can the be translated back at display time
  * in order to match the current system base-url 
  * 
  * @param string $htmlString
  * @return string The HTML text with URLs translated into tokens.
  * @access public
  * @since 1/24/08
  */
 public function tokenizeLocalUrls($htmlString)
 {
     $patterns = array();
     $harmoni = Harmoni::instance();
     $pattern = '#(' . str_replace('.', '\\.', MYURL) . '[^\'"\\s\\]<>}]*)#i';
     $urls = preg_match_all($pattern, $htmlString, $matches);
     foreach ($matches[1] as $url) {
         $paramString = $harmoni->request->getParameterListFromUrl($url);
         if ($paramString !== false) {
             // File urls
             if ($harmoni->request->getModuleFromUrl($url) == 'repository' && $harmoni->request->getActionFromUrl($url) == 'viewfile') {
                 $htmlString = $this->str_replace_once($url, '[[fileurl:' . MediaFile::getIdStringFromUrl($url) . ']]', $htmlString);
             } else {
                 if ($harmoni->request->getModuleFromUrl($url) == 'sites') {
                     $htmlString = $this->str_replace_once($url, '[[localurl:module=view&amp;action=html&amp;site=' . $harmoni->request->getActionFromUrl($url) . ']]', $htmlString);
                 } else {
                     $htmlString = $this->str_replace_once($url, '[[localurl:' . $paramString . ']]', $htmlString);
                 }
             }
         }
     }
     return $htmlString;
 }