Changeset 17351


Ignore:
Timestamp:
08/03/12 19:02:24 (5 years ago)
Author:
mistic100
Message:

feature 2380: add URL for user comment

Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/comments.php

    r15924 r17351  
    383383       com.author_id, 
    384384       com.date, 
     385       com.website_url, 
    385386       com.content, 
    386387       com.validated 
     
    478479      'ALT' => $name, 
    479480      'AUTHOR' => trigger_event('render_comment_author', $comment['author']), 
     481      'WEBSITE_URL' => $comment['website_url'], 
    480482      'DATE'=>format_date($comment['date'], true), 
    481483      'CONTENT'=>trigger_event('render_comment_content',$comment['content']), 
  • trunk/include/functions.inc.php

    r15598 r17351  
    16931693  return $is_mobile_theme; 
    16941694} 
     1695 
     1696/** 
     1697 * check url format 
     1698 */ 
     1699function url_check_format($url) 
     1700{ 
     1701  if (version_compare(PHP_VERSION, '5.2.0') >= 0) 
     1702  { 
     1703    return filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED)!==false; 
     1704  } 
     1705  else 
     1706  { 
     1707    // http://mathiasbynens.be/demo/url-regex @imme_emosol 
     1708    return (bool)preg_match('@^https?://(-\.)?([^\s/?\.#-]+\.?)+(/[^\s]*)?$@iS', $url); 
     1709  } 
     1710} 
    16951711?> 
  • trunk/include/functions_comment.inc.php

    r15983 r17351  
    128128  } 
    129129   
     130  // website 
     131  if ( !empty($comm['website_url']) and !preg_match('/^https?/i', $comm['website_url']) ) 
     132  { 
     133    $comm['website_url'] = 'http://'.$comm['website_url']; 
     134  } 
     135  if ( !empty($comm['website_url']) and !url_check_format($comm['website_url']) ) 
     136  { 
     137    array_push($infos, l10n('Your website URL is invalid')); 
     138    $comment_action='reject'; 
     139  } 
     140   
    130141  // anonymous id = ip address 
    131142  $ip_components = explode('.', $comm['ip']); 
     
    169180    $query = ' 
    170181INSERT INTO '.COMMENTS_TABLE.' 
    171   (author, author_id, anonymous_id, content, date, validated, validation_date, image_id) 
     182  (author, author_id, anonymous_id, content, date, validated, validation_date, image_id, website_url) 
    172183  VALUES ( 
    173184    \''.$comm['author'].'\', 
     
    178189    \''.($comment_action=='validate' ? 'true':'false').'\', 
    179190    '.($comment_action=='validate' ? 'NOW()':'NULL').', 
    180     '.$comm['image_id'].' 
     191    '.$comm['image_id'].', 
     192    '.(!empty($comm['website_url']) ? '\''.$comm['website_url'].'\'' : 'NULL').' 
    181193  ) 
    182194'; 
  • trunk/include/picture_comment.inc.php

    r15924 r17351  
    4949    'author' => trim( @$_POST['author'] ), 
    5050    'content' => trim( $_POST['content'] ), 
     51    'website_url' => trim( $_POST['website_url'] ), 
    5152    'image_id' => $page['image_id'], 
    5253   ); 
     
    146147    date, 
    147148    image_id, 
     149    website_url, 
    148150    content, 
    149151    validated 
     
    179181          'DATE' => format_date($row['date'], true), 
    180182          'CONTENT' => trigger_event('render_comment_content',$row['content']), 
     183          'WEBSITE_URL' => $row['website_url'], 
    181184        ); 
    182185 
     
    242245  { 
    243246    $key = get_ephemeral_key(3, $page['image_id']); 
    244     $content = $author = ''; 
     247    $content = $author = $website_url = ''; 
    245248    if ('reject'===@$comment_action) 
    246249    { 
    247250      $content = htmlspecialchars( stripslashes($comm['content']) ); 
    248251      $author = htmlspecialchars( stripslashes($comm['author']) ); 
     252      $website_url = htmlspecialchars( stripslashes($comm['website_url']) ); 
    249253    } 
    250254    $template->assign('comment_add', 
     
    255259          'SHOW_AUTHOR' => !is_classic_user(), 
    256260          'AUTHOR' => $author , 
     261          'WEBSITE_URL' => $website_url,  
    257262        )); 
    258263  } 
  • trunk/install/piwigo_structure-mysql.sql

    r15983 r17351  
    5454  `author_id` smallint(5) DEFAULT NULL, 
    5555  `anonymous_id` varchar(45) NOT NULL, 
     56  `website_url` varchar(255) DEFAULT NULL, 
    5657  `content` longtext, 
    5758  `validated` enum('true','false') NOT NULL default 'false', 
  • trunk/themes/default/template/comment_list.tpl

    r16522 r17351  
    5555                {/if} 
    5656 
    57                 <span class="commentAuthor">{$comment.AUTHOR}</span> - <span class="commentDate">{$comment.DATE}</span> 
     57                <span class="commentAuthor">{if $comment.WEBSITE_URL}<a href="{$comment.WEBSITE_URL}" class="external" target="_blank">{$comment.AUTHOR}</a>{else}{$comment.AUTHOR}{/if}</span>  
     58      - <span class="commentDate">{$comment.DATE}</span> 
    5859                {if isset($comment.IN_EDIT)} 
    5960                <a name="edit_comment"></a> 
  • trunk/themes/default/template/picture.tpl

    r17302 r17351  
    350350                                        <p><label for="author">{'Author'|@translate} :</label></p> 
    351351                                        <p><input type="text" name="author" id="author" value="{$comment_add.AUTHOR}"></p> 
    352                                         <p><label for="contentid">{'Comment'|@translate} :</label></p> 
    353352                                {/if} 
     353        <p><label for="website_url">{'Website'|@translate} :</label></p> 
     354                          <p><input type="text" name="website_url" id="website_url" value="{$comment_add.WEBSITE_URL}"></p> 
     355                          <p><label for="contentid">{'Comment'|@translate} :</label></p> 
    354356                                <p><textarea name="content" id="contentid" rows="5" cols="50">{$comment_add.CONTENT}</textarea></p> 
    355357                                <p><input type="hidden" name="key" value="{$comment_add.KEY}"> 
Note: See TracChangeset for help on using the changeset viewer.