You are here

function googtube_filter in Googtube 6.2

Same name and namespace in other branches
  1. 5 googtube.module \googtube_filter()
  2. 6 googtube.module \googtube_filter()

File

./googtube.module, line 26

Code

function googtube_filter($op, $delta = 0, $format = -1, $text = '') {
  switch ($op) {
    case 'list':
      return array(
        0 => t('googtube filter'),
      );
    case 'description':
      return t('Youtube and Vimeo video links are automatically converted into embedded videos.');
    case 'settings':
      return _googtube_settings($format);
    case 'process':

      //youtube regex
      if (preg_match_all('#(((http://)?)|(^./))(((www.)?)|(^./))youtube\\.com/watch[?]v=([^\\[\\]()<.,\\s\\n\\t\\r]+)(?![^<]*</a>)#i', $text, $matches)) {
      }
      foreach ($matches[0] as $mi => $match) {
        $replace = googtube_youtube($match, $filter);
        $text = str_replace($match, $replace, $text);
      }

      //vimeo video regex
      if (preg_match_all('#(((http://)?)|(^./))(((www.)?)|(^./))vimeo\\.com/([0-9]+)(?![^<]*</a>)#i', $text, $matches)) {
        foreach ($matches[0] as $mi => $match) {
          $replace = googtube_vimeo($match, $filter);
          $text = str_replace($match, $replace, $text);
        }
      }
      return $text;
    case 'no_cache':
      return false;
    default:
      return $text;
  }
}