Pastoid

Full FlickrFill

The page you are looking at now is at this URL: http://pastoid.com/azf

This paste was last updated on June 3, 2009 at 1:34 pm.

Full home.phpraw

<?php include 'header.php'; ?>
<? $post2date = ''; ?>
<div id="content">
	<?php foreach ( $posts as $post ) { ?>
		<?php 
			$postid= $post->id;
			 $pullquote = reset($post->comments->comments->moderated);
 
		?>
 
		<?php 
			$post1date = ((empty($post2date)) ? time() : $post2date);
			$post2date = $post->pubdate;
			echo "Dates: $post1date, $post2date";
			$theme->flickrfill( $post1date, $post2date );
		?>
		<div class="flickrfill">
			<?php  ?>
		</div>
 
		<div id="post-<?php echo $post->id; ?>" class="mainpost <?php echo $post->statusname; ?>">
			<div class="entry-body">
				<div class="entry-head">
					<h3 class="entry-title">
						<a href="<?php echo $post->permalink; ?>" title="<?php echo $post->title; ?>">
							<?php echo $post->title_out; ?>
						</a>
					</h3>
 
					<div class="entry-data">
						<?php $theme->comments_link($post); ?>
 
						<?php if ( $loggedin ) { ?>
							<span class="entry-edit"><a href="<?php echo $post->editlink; ?>" title="<?php _e('Edit post'); ?>"><?php _e('Edit'); ?></a></span>
						<?php } ?>
 
						was published in <?php echo $post->pubdate_out->text_format('{Y}, on {M} {j} at {g}:{i} {A}'); ?> and tagged with:
						<?php if ( is_array( $post->tags ) ) { ?>
								<span class="entry-tags">
									<?php echo $post->tags_out; ?>
								</span>
						<?php } ?>
 
					</div>
				</div>
				<?php if ($pullquote) { ?>
					<div class="pull-comment">
						<?php echo $pullquote->content_out;?>
						<br><i><?php echo $pullquote->author; ?></i>
					</div>
				<?php } ?>
				<div class="entry-content">
					<?php echo $post->content_out; ?>
				</div>
 
				<div class="entry-data">
					<a href="<?php echo $post->permalink; ?>" title="<?php _e('Comments on this post'); ?>">
						<?php echo $post->comments->approved->count; ?> <?php echo _n( 'Comment', 'Comments', $post->comments->approved->count ); ?>
					</a>
				</div>
 
				<div class="clear"></div>
			</div>
		</div>
	<?php } ?>
 
	<div id="page-selector">
		Page: <?php $theme->prev_page_link('Previous Page'); ?> <?php $theme->page_selector( null, array( 'leftSide' => 2, 'rightSide' => 2 ) ); ?> <?php $theme->next_page_link('Next Page'); ?>
	</div>
</div>
 
<?php $theme->display ('footer'); ?>
 
 

Toggle wordwrap

Full flickrfill.plugin.phpraw

<?php
class FlickrFill extends Plugin
{
	private $flickr= null;
	private $api_key= null;
	private $person_id= null;
	private $photo= null;
 
	public function setup()
	{
		$this->api_key= Options::get( 'skippyflickr__api_key' );
		$this->person_id= Options::get( 'skippyflickr__person' );
	}
 
	function info()
	{
		return array(
			'name' => 'FlickrFill',
			'url' => 'http://642Design.com/',
			'author' => 'Sean T Evans',
			'authorurl' => 'http://morydd.net/',
			'version' => '0.1',
			'license' => 'Apache License 2.0',
			'description' => 'Displays flickr images before each post based on date'
		);
	}
 
	public function filter_plugin_config( $actions, $plugin_id )
	{
		if ( $plugin_id == $this->plugin_id() ) {
			$actions[]= _t('Configure');
			$actions[]= _t('Refresh');
		}
		return $actions;
	}
 
	public function action_plugin_ui( $plugin_id, $action )
	{
		if ( $plugin_id == $this->plugin_id() ) {
			switch ( $action ) {
				case _t('Configure') :
					$ui = new FormUI( strtolower( get_class( $this ) ) );
					$person= $ui->append( 'text', 'person', 'flickrfill__person',  _t('Person ID: ' ) );
					// $ui->on_success( array( $this, 'updated_config' ) );
					$ui->append( 'submit', 'save', _t('Save') );
					$ui->out();
					break;
				case _t('Refresh') :
					$this->theme_flickrfill();
					Utils::redirect( URL::get('admin', 'page=plugins') );
					break;
				}
			}
	}
 
	public function updated_config( $ui )
	{
		return true;
	}
 
	// the workhouse method, which gets invoked hourly by cron
	public function theme_flickrfill( $post1date, $post2date )
	{
		$this->person_id= Options::get( 'flickrfill__person' );
 
		echo "Dates in function: $post1date,$post2date";
		$request= new RemoteRequest( 'http://api.flickr.com/services/rest/?method=flickr.photos.search&format=rest&api_key=39b1bcf1b0c84a24435677252085d436&user_id=' . $this->person_id . '&min_date_taken=' . $post2date . '&max_date_taken=' . $post1date . '&sort=interestingness-desc&media=photos&per_page=5' );
		$request->set_timeout( 5 );
		$result= $request->execute();
		if ( Error::is_error( $result ) ) {
			// this is a cronjob, so no sense displaying an error
			EventLog::log( 'Error getting photo from Flickr', 'err', 'default', 'habari' );
			return;
		}
		$response= $request->get_response_body();
		$xml= new SimpleXMLElement( $response );
		if ( ! $xml ) { return; }
		$photo=$xml->photos->photo;
		if ( ! $photo ) { return; }
		if ( ! $photo['id'] ) { return; }
		echo '<a href="http://www.flickr.com/photos/' . $this->person_id . '/' . $photo['id'] . '"><img src="http://farm' . $photo['farm'] . '.static.flickr.com/' . $photo['server'] . '/' . $photo['id'] . '_' . $photo['secret'] . '_t.jpg"></a>';
		/*Options::set( 'skippyflickr__photo', $newphoto );*/
		EventLog::log( 'Updated photo: ' . $photo['title'], 'info', 'default', 'habari' );
	}
 
	public function theme_recent_photo()
	{
		$photo= Options::get( 'skippyflickr__photo' );
		if ( '' != $photo ) {
			echo $photo;
		}
	}
}
?>

Toggle wordwrap

Referring DomainHits
Unknown Referer 190
pastoid.com 25
search.live.com 1
mibbit.com 1
Is this paste spam?
<Hide