original_string: static private function encode_links_helper($content, $name, $path) {
          global $CFG;
          // We want to convert both http and https links.
          $root = $CFG->wwwroot;
          $httpsroot = str_replace('http://', 'https://', $root);
          $httproot = str_replace('https://', 'http://', $root);
  
          $httpsbase = preg_quote($httpsroot . $path, '/');
          $httpbase = preg_quote($httproot . $path, '/');
  
          $return = preg_replace('/(' . $httpsbase . ')([0-9]+)/', '$@' . $name . '*$2@$', $content);
          $return = preg_replace('/(' . $httpbase . ')([0-9]+)/', '$@' . $name . '*$2@$', $return);
  
          return $return;
      }
code: static private function encode_links_helper($content, $name, $path) {
          global $CFG;
          // We want to convert both http and https links.
          $root = $CFG->wwwroot;
          $httpsroot = str_replace('http://', 'https://', $root);
          $httproot = str_replace('https://', 'http://', $root);
  
          $httpsbase = preg_quote($httpsroot . $path, '/');
          $httpbase = preg_quote($httproot . $path, '/');
  
          $return = preg_replace('/(' . $httpsbase . ')([0-9]+)/', '$@' . $name . '*$2@$', $content);
          $return = preg_replace('/(' . $httpbase . ')([0-9]+)/', '$@' . $name . '*$2@$', $return);
  
          return $return;
      }
code_tokens: static private function encode_links_helper ( $ content , $ name , $ path ) { global $ CFG ; // We want to convert both http and https links. $ root = $ CFG -> wwwroot ; $ httpsroot = str_replace ( 'http://' , 'https://' , $ root ) ; $ httproot = str_replace ( 'https://' , 'http://' , $ root ) ; $ httpsbase = preg_quote ( $ httpsroot . $ path , '/' ) ; $ httpbase = preg_quote ( $ httproot . $ path , '/' ) ; $ return = preg_replace ( '/(' . $ httpsbase . ')([0-9]+)/' , '$@' . $ name . '*$2@$' , $ content ) ; $ return = preg_replace ( '/(' . $ httpbase . ')([0-9]+)/' , '$@' . $ name . '*$2@$' , $ return ) ; return $ return ; }
docstring: Helper method, used by encode_content_links.
  @param string $content content in which to encode links.
  @param string $name the name of this type of encoded link.
  @param string $path the path that identifies this type of link, up
  to the ?paramname= bit.
  @return string content with one type of link encoded.
docstring_tokens: Helper method used by encode_content_links .