Skip to content

Instantly share code, notes, and snippets.

@iammerrick
Created April 7, 2011 15:54
Show Gist options
  • Select an option

  • Save iammerrick/908054 to your computer and use it in GitHub Desktop.

Select an option

Save iammerrick/908054 to your computer and use it in GitHub Desktop.
Not tested.
<?php defined('SYSPATH') or die('No direct script access.');
/**
* We Extend Controller_Template to have instant access to a template.
*
* @package default
* @author Merrick Christensen
*/
class Controller_Welcome extends Controller_Template {
public $template = 'home';
private $_fatwallet_min_rating = 5;
private $_fatwallet_expiration = 86400;
public function action_index()
{
if (empty($_GET['auth']))
{
header('HTTP/1.1 301 Moved Permanently');
$this->request->redirect('http://www.kennethdonaldson.net');
}
else
{
/* Header & Footer - This kinda stuff could be handled in a parent controller since it will be common throughout the site.*/
$this->template->header = View::factory('header');
$this->template->footer = View::factory('footer');
/* Page Modules - Take a look at View->set()*/
$this->template->mod_google = View::factory('modules/google');
$this->template->mod_fatwallet = View::factory('modules/fatwallet');
$this->template->mod_fatwallet->rss = $this->fatwallet();
$this->template->mod_fatwallet->max_title_length = 100;
}
}
private function fatwallet($filtervars = null)
{
$rss = new Model_Rss;
$fatwallet_feed = $rss->get_rss('http://feeds.feedburner.com/FatwalletHotDeals');
$fw_array = array();
foreach($fatwallet_feed->channel->item as $item)
{
/* Get Rating */
$rating = trim(substr($item->description,8,2));
$timefrompost = time() - strtotime($item->pubDate);
/* Get High Ratings Only */
if ($rating > $this->_fatwallet_min_rating && $timefrompost < $this->_fatwallet_expiration)
{
$item->rating = $rating;
$fw_array[] = $item;
}
}
return $fw_array;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment