_update_178_url_fix

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

modules/system/system.install, строка 2797

Версии
5
_update_178_url_fix($text)

▾ 2 функции вызывают _update_178_url_fix()

system_update_178 in modules/system/system.install
Update base paths for relative URLs in node and comment content.
system_update_179 in modules/system/system.install
Update base paths for relative URLs in custom blocks, profiles and various variables.

Код

<?php
function _update_178_url_fix($text) {
  // Key is the attribute to replace.
  $urlpatterns['href'] = "/<a[^>]+href=\"([^\"]+)/i";
  $urlpatterns['src']  = "/<img[^>]+src=\"([^\"]+)/i";

  $old = $text;
  foreach ($urlpatterns as $type => $pattern) {
    if (preg_match_all($pattern, $text, $matches)) {
      foreach ($matches[1] as $url) {
        if ($url != '' && !strstr($url, 'mailto:') && !strstr($url, '://') && !strstr($url, '../') && !strstr($url, './') && $url[0] != '/' && $url[0] != '#') {
          $text = preg_replace('|'. $type .'\s*=\s*"'. preg_quote($url) .'\s*"|', $type. '="'.base_path(). $url  .'"', $text);
        }
      }
    }
  }
  return $text != $old ? $text : FALSE;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему