ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 10429


Ignore:
Timestamp:
Jan 26, 2009, 8:35:51 PM (14 years ago)
Author:
ogawa
Message:

#3301:added url cmd

Location:
OpenPNE3/trunk
Files:
36 added
1 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/lib/helper/opUtilHelper.php

    r10078 r10429  
    153153  return $script_name;
    154154}
     155
     156function op_url_cmd($text)
     157{
     158  $url_pattern = '/https?:\/\/([a-zA-Z0-9\-.]+)\/?(?:[a-zA-Z0-9_\-\/.,:;~?@=+$%#!()]|&)*/';
     159
     160  return preg_replace_callback($url_pattern, '_op_url_cmd', $text);
     161}
     162
     163function _op_url_cmd($matches)
     164{
     165  $url = $matches[0];
     166  $cmd = $matches[1];
     167
     168  $file = $cmd . '.js';
     169  $path = './cmd/' . $file;
     170
     171  if (!is_readable($path)) {
     172    return str_replace('&', '&', op_auto_link_text(str_replace('&', '&', $url)));
     173  }
     174
     175  $public_path = _compute_public_path($cmd, 'cmd', 'js');
     176  $result = <<<EOD
     177<script type="text/javascript" src="{$public_path}"></script>
     178<script type="text/javascript">
     179<!--
     180url2cmd('{$url}');
     181//-->
     182</script>
     183EOD;
     184  return $result;
     185}
     186
     187/**
     188 * @see auto_link_text
     189 */
     190function op_auto_link_text($text, $link = 'urls', $href_options = array('target' => '_blank'), $truncate = true, $truncate_len = 57, $pad = '...')
     191{
     192  use_helper('Text');
     193  return auto_link_text($text, $link, $href_options, $truncate, $truncate_len, $pad);
     194}
     195
     196?>
Note: See TracChangeset for help on using the changeset viewer.