src/wcmf/lib/model/NodeUtil.php
private static function makeValueUrlsRelative(PersistentObject $object, $valueName, $baseUrl) {
    $value = $object->getValue($valueName);

    // find urls in texts
    $urls = StringUtil::getUrls($value);
    // find direct attribute urls
    if (strpos($value, 'http://') === 0 || strpos($value, 'https://') === 0) {
      $urls[] = $value;
    }
    // process urls
    foreach ($urls as $url) {
      // convert absolute urls matching baseUrl
      $urlConv = $url;
      if (strpos($url, $baseUrl) === 0) {
        $urlConv = str_replace($baseUrl, '', $url);
      }
      // replace url
      $value = str_replace($url, $urlConv, $value);
    }
    $object->setValue($valueName, $value);
  }
private static function makeValueUrlsRelative(PersistentObject $object, $valueName, $baseUrl) {
    $value = $object->getValue($valueName);

    // find urls in texts
    $urls = StringUtil::getUrls($value);
    // find direct attribute urls
    if (strpos($value, 'http://') === 0 || strpos($value, 'https://') === 0) {
      $urls[] = $value;
    }
    // process urls
    foreach ($urls as $url) {
      // convert absolute urls matching baseUrl
      $urlConv = $url;
      if (strpos($url, $baseUrl) === 0) {
        $urlConv = str_replace($baseUrl, '', $url);
      }
      // replace url
      $value = str_replace($url, $urlConv, $value);
    }
    $object->setValue($valueName, $value);
  }
private static function makeValueUrlsRelative ( PersistentObject $ object , $ valueName , $ baseUrl ) { $ value = $ object -> getValue ( $ valueName ) ; // find urls in texts $ urls = StringUtil :: getUrls ( $ value ) ; // find direct attribute urls if ( strpos ( $ value , 'http://' ) === 0 || strpos ( $ value , 'https://' ) === 0 ) { $ urls [ ] = $ value ; } // process urls foreach ( $ urls as $ url ) { // convert absolute urls matching baseUrl $ urlConv = $ url ; if ( strpos ( $ url , $ baseUrl ) === 0 ) { $ urlConv = str_replace ( $ baseUrl , '' , $ url ) ; } // replace url $ value = str_replace ( $ url , $ urlConv , $ value ) ; } $ object -> setValue ( $ valueName , $ value ) ; }
Make the urls matching a given base url in a PersistentObject value relative.
@param $node Node instance that holds the value
@param $valueName The name of the value
@param $baseUrl The baseUrl to which matching urls will be made relative
Make the urls matching a given base url in a PersistentObject value relative .