Skip to content

Commit

Permalink
Issue #1
Browse files Browse the repository at this point in the history
Randomized banner images to display photos from /media/images/banners/

Signed-off-by:  <adarshakb@gmail.com>
  • Loading branch information
Adarsha authored and Adarsha committed Nov 20, 2012
1 parent 1df87ed commit 9be4e05
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
database.php
google.php
application/cache/*
application/logs/*
application/bootstrap.php
application/config/*
modules/database/config/*

!.gitignore
18 changes: 18 additions & 0 deletions application/classes/controller/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

class Controller_Calendar extends Controller {

//Default banner image full path
private $_defaultBanner = "calendar-6.jpg";

// Helper function for clearing out local caches
private function _delete_all($model)
{
Expand Down Expand Up @@ -41,8 +44,23 @@ public function action_index()
}
}

$handle = opendir('media/images/banners');
$banners = array($this->_defaultBanner);


if ($handle !== false) {

while (false !== ($entry = readdir($handle))) {
if(preg_match('/\.jpg$/i', $entry) != 0) {
$banners[] = $entry;
}
}
closedir($handle);
}

$view = View::factory('template')
->set('show_datepicker', true)
->set('banner_img_url',$banners[array_rand($banners)])
->bind('events', $events)
->bind('calendars', $calendars)
->bind('display_dates', $display_dates);
Expand Down
4 changes: 2 additions & 2 deletions application/views/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
<?php echo View::factory('header'); ?>
<div class="contentWidth bodyContent">
<div id="calendar_container">
<div id="banner" style="background-image: url('/media/images/banners/calendar-6.jpg');">
<div id="banner" style="background-image: url('<?=url::base()?>media/images/banners/<?=$banner_img_url?>');">
<h1><a href="<?php echo URL::base(); ?>">Events Calendar</a></h1>
</div>
<div id="main_column">
<?php include Kohana::find_file('views', $subview); ?>
</div>
<div id="secondary_column">
<?php if (isset($show_datepicker)): ?>
<?php if (isset($show_datepicker) && $show_datepicker): ?>
<div id="datepicker" class="secondary_block"></div>
<?php endif; ?>

Expand Down

0 comments on commit 9be4e05

Please sign in to comment.