Changeset 899

Show
Ignore:
Timestamp:
09/07/08 19:41:49 (3 months ago)
Author:
mikelietz
Message:

plugin: Twitter added an option to linkify URLs (and it works better than twitter's method, thanks ringmaster).
Didn't bump the version - still doesn't seem to be 1.0 quality yet.

Location:
plugins/twitter/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • plugins/twitter/trunk/tweets.php

    r45 r899  
    33<div id="twitterbox"> 
    44 <img src="<?php echo htmlspecialchars( $tweet_image_url ); ?>" alt="<?php echo urlencode( Options::get( 'twitter:username' )); ?>"> 
    5  <p><?php echo htmlspecialchars( $tweet_text ) . ' @ ' . htmlspecialchars( $tweet_time ); ?></p> 
     5 <p><?php /* remove the following htmlspecialchars if you are linkifying links */ echo htmlspecialchars( $tweet_text ) . ' @ ' . htmlspecialchars( $tweet_time );  
     6?></p> 
    67<p><small>via <a href="http://twitter.com/<?php echo urlencode( Options::get( 'twitter:username' )); ?>">Twitter</a></small></p> 
    78 </div> 
  • plugins/twitter/trunk/twitter.plugin.php

    r708 r899  
    6767                Options::set( 'twitter__hide_replies', 0 ); 
    6868            } 
     69            if ( Options::get( 'twitter__linkify_urls' ) == null ) { 
     70                Options::set( 'twitter__linkify_urls', 0 ); 
     71            } 
    6972        } 
    7073    } 
     
    8285                case 'Configure' : 
    8386                    $ui= new FormUI( strtolower( get_class( $this ) ) ); 
    84                     $twitter_username= $ui->append( 'text', 'username', 'twitter__username', 'Twitter Username:' ); 
    85                     $twitter_password= $ui->append( 'password', 'password', 'twitter__password', 'Twitter Password:' ); 
    86                     $twitter_post= $ui->append( 'select', 'post_status', 'twitter__post_status', 'Autopost to Twitter:' ); 
    87                     $twitter_post->options= array( '0' => 'Disabled', '1' => 'Enabled' ); 
    88                     $twitter_show= $ui->append( 'select', 'show', 'twitter__show', 'Make Tweets available to Habari' ); 
    89                     $twitter_show->options= array( '0' => 'No', '1' => 'Yes' ); 
    90                     $twitter_show= $ui->append( 'select', 'hide_replies', 'twitter__hide_replies', 'Hide @replies' ); 
    91                     $twitter_show->options= array( '1' => 'Yes' , '0' => 'No' ); 
    92                     $twitter_cache_time= $ui->append( 'text', 'cache', 'twitter__cache', 'Cache expiry in seconds:' ); 
     87                    $twitter_username= $ui->append( 'text', 'username', 'twitter__username',  
     88                        _t('Twitter Username:') ); 
     89                    $twitter_password= $ui->append( 'password', 'password', 'twitter__password',  
     90                        _t('Twitter Password:') ); 
     91                    $twitter_post= $ui->append( 'select', 'post_status', 'twitter__post_status',  
     92                        _t('Autopost to Twitter:') ); 
     93                    $twitter_post->options= array( '0' => _t('Disabled'), '1' => _t('Enabled') ); 
     94                    $twitter_show= $ui->append( 'select', 'show', 'twitter__show',  
     95                        _t('Make Tweets available to Habari') ); 
     96                    $twitter_show->options= array( '0' => _t('No'), '1' => _t('Yes') ); 
     97                    $twitter_show= $ui->append( 'select', 'hide_replies',  
     98                        'twitter__hide_replies', _t('Hide @replies') ); 
     99                    $twitter_show->options= array( '1' => _t('Yes') , '0' => _t('No') ); 
     100                    $twitter_show= $ui->append( 'select', 'linkify_urls',  
     101                        'twitter__linkify_urls', _t('Linkify URLs') ); 
     102                    $twitter_show->options= array( '1' => _t('Yes') , '0' => _t('No') ); 
     103                    $twitter_cache_time= $ui->append( 'text', 'cache', 'twitter__cache',  
     104                        _t('Cache expiry in seconds:') ); 
    93105                    // $ui->on_success( array( $this, 'updated_config' ) ); 
    94106                    $ui->append( 'submit', 'save', _t('Save') ); 
     
    253265            $theme->tweet_image_url= ''; 
    254266        } 
     267        if ( Options::get( 'twitter__linkify_urls' ) != FALSE ) { 
     268            $theme->tweet_text = preg_replace("%https?://(\S*)%i", 
     269            ' <a href="$0">$0</a> ', $theme->tweet_text); 
     270} 
    255271        return $theme->fetch( 'tweets' ); 
    256272    }