Changeset 20834 for events

Show
Ignore:
Timestamp:
10/06/08 10:59:08 (2 months ago)
Author:
kenji
Message:

Add auto link to comments

Location:
events/phpframework/codeigniter/trunk/system/application
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • events/phpframework/codeigniter/trunk/system/application/controllers/status.php

    r20833 r20834  
    11<?php 
    2                                  
     2 
    33class Status extends Controller  
    44{ 
     
    6666                        $data->image    = $this->session->userdata('image'); 
    6767                         
    68                         $comment = h($comment); 
     68                        $comment = auto_link(h($comment), 'url'); 
    6969                        if ($reply_username) { 
    7070                                $comment = preg_replace('/^@(\w+)\s/', '@' . anchor(site_url('user/index/' . $reply_username), $reply_username) . ' ', $comment); 
  • events/phpframework/codeigniter/trunk/system/application/helpers/MY_url_helper.php

    r20833 r20834  
    11<?php 
    22 
     3/* 本来は HTML helper かな */ 
    34function h($string) 
    45{ 
    5     return htmlspecialchars($string, ENT_QUOTES); 
     6        return htmlspecialchars($string, ENT_QUOTES); 
    67} 
    78 
     9/* 本来は HTML helper かな */ 
    810function picture($username, $image, $size, $class) 
    911{ 
     
    6769} 
    6870 
     71/* 本来は HTML helper かな */ 
    6972function my_pict($size) 
    7073{ 
     
    7578} 
    7679 
     80/* 本来は HTML helper かな */ 
    7781function js($js = 'default', $timestamp = TRUE) 
    7882{ 
     
    123127        return $str; 
    124128} 
     129 
     130/* auto_link() を一部修正 */ 
     131if ( ! function_exists('auto_link')) 
     132{ 
     133        function auto_link($str, $type = 'both', $popup = FALSE) 
     134        { 
     135                if ($type != 'email') 
     136                {                
     137                        if (preg_match_all("#((http(s?)://)|(www\.))(\w+[^\s\)\<]+)#i", $str, $matches)) 
     138                        { 
     139                                $pop = ($popup == TRUE) ? " target=\"_blank\" " : ""; 
     140 
     141                                for ($i = 0; $i < sizeof($matches['0']); $i++) 
     142                                { 
     143                                        $period = ''; 
     144                                        if (preg_match("|\.$|", $matches['5'][$i])) 
     145                                        { 
     146                                                $period = '.'; 
     147                                                $matches['5'][$i] = substr($matches['5'][$i], 0, -1); 
     148                                        } 
     149 
     150                                        $str = str_replace($matches['0'][$i], 
     151                                                                                '<a href="http'. 
     152                                                                                $matches['3'][$i].'://'. 
     153                                                                                $matches['4'][$i]. 
     154                                                                                $matches['5'][$i].'"'.$pop.'>http'. 
     155                                                                                $matches['3'][$i].'://'. 
     156                                                                                $matches['4'][$i]. 
     157                                                                                $matches['5'][$i].'</a>'. 
     158                                                                                $period, $str); 
     159                                } 
     160                        } 
     161                } 
     162 
     163                if ($type != 'url') 
     164                {        
     165                        if (preg_match_all("/([a-zA-Z0-9_\.\-]+)@([a-zA-Z0-9\-]+)\.([a-zA-Z0-9\-\.]*)/i", $str, $matches)) 
     166                        { 
     167                                for ($i = 0; $i < sizeof($matches['0']); $i++) 
     168                                { 
     169                                        $period = ''; 
     170                                        if (preg_match("|\.$|", $matches['3'][$i])) 
     171                                        { 
     172                                                $period = '.'; 
     173                                                $matches['3'][$i] = substr($matches['3'][$i], 0, -1); 
     174                                        } 
     175 
     176                                        $str = str_replace($matches['0'][$i], safe_mailto($matches['1'][$i].'@'.$matches['2'][$i].'.'.$matches['3'][$i]).$period, $str); 
     177                                } 
     178 
     179                        } 
     180                } 
     181                return $str; 
     182        } 
     183} 
  • events/phpframework/codeigniter/trunk/system/application/views/home/main.php

    r20833 r20834  
    11<?=js()?> 
     2 
    23 
    34<form action="#" name="whatdoing"> 
     
    3435                                <p class="murmur"> 
    3536                                <?=anchor(site_url('user/index/' . $row->username), $row->username)?> 
    36                                 <?php  
    37                                         $row->comment = h($row->comment); 
     37                                <?php 
     38                                        $row->comment = auto_link(h($row->comment), 'url'); 
    3839                                        if ($row->reply_username) { 
    3940                                                $row->comment = preg_replace('/^@(\w+)\s/', '@' . anchor(site_url('user/index/' . $row->reply_username), $row->reply_username) . ' ', $row->comment); 
  • events/phpframework/codeigniter/trunk/system/application/views/home/main_archive.php

    r20833 r20834  
    3434                        <td> 
    3535                                <p class="murmur"> 
    36                                 <?php  
    37                                         $row->comment = h($row->comment); 
     36                                <?php 
     37                                        $row->comment = auto_link(h($row->comment), 'url'); 
    3838                                        if ($row->reply_username) { 
    3939                                                $row->comment = preg_replace('/^@(\w+)\s/', '@' . anchor(site_url('user/index/' . $row->reply_username), $row->reply_username) . ' ', $row->comment); 
  • events/phpframework/codeigniter/trunk/system/application/views/home/main_reply.php

    r20833 r20834  
    3535                                <p class="murmur"> 
    3636                                <?=anchor(site_url('user/index/' . $row->username), $row->username)?> 
    37                                 <?=h($row->comment)?> 
     37                                <?=auto_link(h($row->comment), 'url')?> 
    3838                                <?=anchor(site_url('user/statuses/' . $row->username . '/' . $row->id), posted_time($row->created_at))?> 
    3939                                </p> 
  • events/phpframework/codeigniter/trunk/system/application/views/public_timeline/main.php

    r20833 r20834  
    1212                                <p class="murmur"> 
    1313                                <?=anchor(site_url('user/index/' . $row->username), $row->username)?> 
    14                                 <?php  
    15                                         $row->comment = h($row->comment); 
     14                                <?php 
     15                                        $row->comment = auto_link(h($row->comment), 'url'); 
    1616                                        if ($row->reply_username) { 
    1717                                                $row->comment = preg_replace('/^@(\w+)\s/', '@' . anchor(site_url('user/index/' . $row->reply_username), $row->reply_username) . ' ', $row->comment); 
  • events/phpframework/codeigniter/trunk/system/application/views/public_timeline/main_logged_in.php

    r20833 r20834  
    3434                                <p class="murmur"> 
    3535                                <?=anchor(site_url('user/index/' . $row->username), $row->username)?> 
    36                                 <?php  
    37                                         $row->comment = h($row->comment); 
     36                                <?php 
     37                                        $row->comment = auto_link(h($row->comment), 'url'); 
    3838                                        if ($row->reply_username) { 
    3939                                                $row->comment = preg_replace('/^@(\w+)\s/', '@' . anchor(site_url('user/index/' . $row->reply_username), $row->reply_username) . ' ', $row->comment); 
  • events/phpframework/codeigniter/trunk/system/application/views/user/main.php

    r20833 r20834  
    1919                        alert(data.html); 
    2020                } 
    21     } 
     21        } 
    2222 
    2323        /* フォロー解除する */ 
     
    7171                        <td> 
    7272                                <p class="murmur"> 
    73                                 <?php  
    74                                         $row->comment = h($row->comment); 
     73                                <?php 
     74                                        $row->comment = auto_link(h($row->comment), 'url'); 
    7575                                        if ($row->reply_username) { 
    7676                                                $row->comment = preg_replace('/^@(\w+)\s/', '@' . anchor(site_url('user/index/' . $row->reply_username), $row->reply_username) . ' ', $row->comment); 
  • events/phpframework/codeigniter/trunk/system/application/views/user/main_comment.php

    r20833 r20834  
    55                <?php foreach($list as $row):?> 
    66                                <p> 
    7                                 <?php  
    8                                         $row->comment = h($row->comment); 
     7                                <?php 
     8                                        $row->comment = auto_link(h($row->comment), 'url'); 
    99                                        if ($row->reply_username) { 
    1010                                                $row->comment = preg_replace('/^@(\w+)\s/', '@' . anchor(site_url('user/index/' . $row->reply_username), $row->reply_username) . ' ', $row->comment);