-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kevin Carter
committed
Oct 1, 2009
0 parents
commit f6b2532
Showing
18 changed files
with
425 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
class AdsAppController extends AppController { | ||
|
||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
class AdsAppModel extends AppModel { | ||
|
||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
class AdPositionsController extends AdsAppController { | ||
var $name = 'AdPositions'; | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
class AdRulesController extends AdsAppController { | ||
var $name = 'AdRules'; | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
class AdsController extends AdsAppController { | ||
var $name = 'Ads'; | ||
|
||
function beforeFilter() { | ||
parent::beforeFilter(); | ||
$this->Auth->allow('get'); | ||
} | ||
|
||
function get($id) { | ||
$this->data = $this->Ad->pullAd($id); | ||
|
||
if (isset($this->params['requested'])) { | ||
return $this->data; | ||
} | ||
} | ||
|
||
function admin_add( ) { | ||
parent::admin_add( ); | ||
$this->_setAdSizes( ); | ||
} | ||
|
||
function admin_edit($id) { | ||
parent::admin_edit($id); | ||
$this->_setAdSizes($this->data['Ad']['ad_position_id']); | ||
} | ||
|
||
function _setAdSizes($position_id = null) { | ||
$options['contain'] = 'AdRule'; | ||
if ($position_id) { | ||
$position = $this->Ad->AdPosition->read(null, $position_id); | ||
$options['conditions'] = array('AdRule.id' => $position['AdPosition']['ad_rule_id']); | ||
} | ||
$options['order'] = 'AdPosition.name'; | ||
$adPositions = $this->Ad->AdPosition->find('all', $options); | ||
$sizes = Set::combine($adPositions, '/AdPosition/id', array('%s × %s', '/AdRule/width', '/AdRule/height')); | ||
$adPositions = Set::combine($adPositions, '/AdPosition/id', array('%s (%sx%s)', '/AdPosition/name', '/AdRule/width', '/AdRule/height')); | ||
$this->set(compact('sizes', 'adPositions')); | ||
} | ||
|
||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
class Ad extends AdsAppModel { | ||
|
||
var $name = 'Ad'; | ||
var $validate = array( | ||
'name' => array('notempty'), | ||
'ad_position_id' => array('numeric'), | ||
'active' => array('numeric') | ||
); | ||
|
||
var $actsAs = array( | ||
'Image' => array( | ||
'fields' => array( | ||
'src' => array( | ||
'resize' => false, | ||
), | ||
), | ||
), | ||
); | ||
|
||
var $belongsTo = array( | ||
'Ads.AdPosition', | ||
); | ||
|
||
function pullAd($position_id) { | ||
$ad = $this->find('first', array( | ||
'conditions' => array( | ||
'ad_position_id' => $position_id, | ||
'active' => 1, | ||
'NOW() BETWEEN Ad.start_date AND Ad.end_date', | ||
), | ||
'order' => 'created' | ||
)); | ||
return $ad; | ||
} | ||
|
||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
class AdPosition extends AdsAppModel { | ||
|
||
var $name = 'AdPosition'; | ||
var $validate = array( | ||
'name' => array('notempty'), | ||
'ad_rule_id' => array('numeric') | ||
); | ||
|
||
var $belongsTo = array( | ||
'Ads.AdRule' | ||
); | ||
|
||
var $hasMany = array( | ||
'Ads.Ad' | ||
); | ||
|
||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
class AdRule extends AdsAppModel { | ||
|
||
var $name = 'AdRule'; | ||
var $validate = array( | ||
'name' => array('notempty'), | ||
'width' => array('numeric'), | ||
'height' => array('numeric') | ||
); | ||
|
||
var $hasMany = array( | ||
'Ads.AdPosition', | ||
); | ||
|
||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php /* SVN FILE: $Id$ */ | ||
if ($data) { | ||
extract($data); | ||
} | ||
$action = in_array($this->action, array('add', 'admin_add'))?'Add':'Edit'; | ||
$action = Inflector::humanize($action); | ||
$name = isset($this->data[$modelClass]['name'])?$this->data[$modelClass]['name']:' new'; | ||
?> | ||
<h1><?php echo $this->name . ' - ' . $action . ' ' . $name ?></h1> | ||
<div class="form-container"> | ||
<?php | ||
echo $form->create(null, array('type' => 'file')); | ||
echo $form->inputs(array( | ||
'legend' => false, | ||
'id', | ||
'name', | ||
'ad_rule_id' => array('empty' => true), | ||
)); | ||
echo $form->end('Submit'); | ||
?></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php /* SVN FILE: $Id$ */ ?> | ||
<h1>Ad Positions</h1> | ||
<div class="container"> | ||
<?php | ||
$pass = $this->passedArgs; | ||
$pass['action'] = str_replace(Configure::read('Routing.admin') . '_', '', $this->action); // temp | ||
$paginator->options(array('url' => $pass)); | ||
?> | ||
<table> | ||
<?php | ||
$th = array( | ||
$paginator->sort('Id', 'id'), | ||
$paginator->sort('Name', 'name'), | ||
$paginator->sort('Ad Rule', 'AdRule.name'), | ||
); | ||
echo $html->tableHeaders($th); | ||
foreach ($data as $row) { | ||
extract($row); | ||
$tr = array( | ||
$html->link($AdPosition['id'], array('action' => 'view', $AdPosition['id'])), | ||
$AdPosition['name'], | ||
$AdRule?$AdRule['name']:'', | ||
); | ||
echo $html->tableCells($tr, array('class' => 'odd'), array('class' => 'even')); | ||
} | ||
?> | ||
</table> | ||
<?php echo $this->element('paging'); ?></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php /* SVN FILE: $Id$ */ | ||
extract($data); ?> | ||
<h1><?php echo $AdPosition['name'] ?></h1> | ||
<div class="container"> | ||
<table> | ||
<?php | ||
extract($data); | ||
echo $html->tableCells(array('id',$AdPosition['id'])); | ||
echo $html->tableCells(array('name',$AdPosition['name'])); | ||
echo $html->tableCells(array('Ad Rule', $AdRule?$AdRule['name']:'')); | ||
?> | ||
</table> | ||
</div> | ||
<?php | ||
$menu->addm('View', array( | ||
array('title' => $AdRule['name'], 'url' => array('controller' => 'ad_rules', 'action' => 'view', $AdPosition['ad_rule_id'])), | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php /* SVN FILE: $Id$ */ | ||
if ($data) { | ||
extract($data); | ||
} | ||
$action = in_array($this->action, array('add', 'admin_add'))?'Add':'Edit'; | ||
$action = Inflector::humanize($action); | ||
$name = isset($this->data[$modelClass]['name'])?$this->data[$modelClass]['name']:' new'; | ||
?> | ||
<h1><?php echo $this->name . ' - ' . $action . ' ' . $name ?></h1> | ||
<div class="form-container"> | ||
<?php | ||
echo $form->create(null, array('type' => 'file')); | ||
echo $form->inputs(array( | ||
'legend' => false, | ||
'id', | ||
'name', | ||
'width', | ||
'height', | ||
)); | ||
echo $form->end('Submit'); | ||
?></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php /* SVN FILE: $Id$ */ ?> | ||
<h1>Ad Rules</h1> | ||
<div class="container"> | ||
<?php | ||
$pass = $this->passedArgs; | ||
$pass['action'] = str_replace(Configure::read('Routing.admin') . '_', '', $this->action); // temp | ||
$paginator->options(array('url' => $pass)); | ||
?> | ||
<table> | ||
<?php | ||
$th = array( | ||
$paginator->sort('Id', 'id'), | ||
$paginator->sort('Name', 'name'), | ||
$paginator->sort('Width', 'width'), | ||
$paginator->sort('Height', 'height'), | ||
); | ||
echo $html->tableHeaders($th); | ||
foreach ($data as $row) { | ||
extract($row); | ||
$tr = array( | ||
$html->link($AdRule['id'], array('action' => 'view', $AdRule['id'])), | ||
$AdRule['name'], | ||
$AdRule['width'], | ||
$AdRule['height'], | ||
); | ||
echo $html->tableCells($tr, array('class' => 'odd'), array('class' => 'even')); | ||
} | ||
?> | ||
</table> | ||
<?php echo $this->element('paging'); ?></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php /* SVN FILE: $Id$ */ | ||
extract($data); ?> | ||
<h1><?php echo $AdRule['name'] ?></h1> | ||
<div class="container"> | ||
<table> | ||
<?php | ||
extract($data); | ||
echo $html->tableCells(array('id',$AdRule['id'])); | ||
echo $html->tableCells(array('name',$AdRule['name'])); | ||
echo $html->tableCells(array('width',$AdRule['width'])); | ||
echo $html->tableCells(array('height',$AdRule['height'])); | ||
?> | ||
</table> | ||
</div> | ||
<?php | ||
$menu->addm('View', array( | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php /* SVN FILE: $Id$ */ | ||
if ($data) { | ||
extract($data); | ||
} | ||
$image = null; | ||
if ( !empty($this->data['Ad']['src']['path']) ) { | ||
$image = $html->image($this->data['Ad']['src']['path']); | ||
|
||
$pathBase = WWW_ROOT.'img'.DS; | ||
if (file_exists($pathBase.$this->data['Ad']['src']['path'])) { | ||
list($width, $height) = @getimagesize($pathBase.$this->data['Ad']['src']['path']); | ||
$image .= "<br /><br /><b>Image Size:</b> ({$width}px × {$height}px)"; | ||
} | ||
} | ||
$action = in_array($this->action, array('add', 'admin_add'))?'Add':'Edit'; | ||
$action = Inflector::humanize($action); | ||
$name = isset($this->data[$modelClass]['name'])?$this->data[$modelClass]['name']:' new'; | ||
?> | ||
<h1><?php echo $this->name . ' - ' . $action . ' ' . $name ?></h1> | ||
<div class="form-container"> | ||
<?php | ||
echo $form->create(null, array('type' => 'file')); | ||
echo $form->inputs(array( | ||
'legend' => false, | ||
'id', | ||
'ad_position_id' => array('empty' => true), | ||
'name', | ||
'src' => array('type' => 'file', 'label' => 'Src<br /> ', 'after' => '<br/>'. $image), | ||
'active', | ||
'url', | ||
'start_date', | ||
'end_date', | ||
)); | ||
echo $form->end('Submit'); | ||
?></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php /* SVN FILE: $Id$ */ ?> | ||
<h1>Ads</h1> | ||
<div class="container"> | ||
<?php | ||
$pass = $this->passedArgs; | ||
$pass['action'] = str_replace(Configure::read('Routing.admin') . '_', '', $this->action); // temp | ||
$paginator->options(array('url' => $pass)); | ||
?> | ||
<table> | ||
<?php | ||
$th = array( | ||
$paginator->sort('Id', 'id'), | ||
$paginator->sort('Ad Position', 'AdPosition.name'), | ||
$paginator->sort('Name', 'name'), | ||
$paginator->sort('Active', 'active'), | ||
$paginator->sort('Url', 'url'), | ||
$paginator->sort('Start Date', 'start_date'), | ||
$paginator->sort('End Date', 'end_date'), | ||
); | ||
echo $html->tableHeaders($th); | ||
foreach ($data as $row) { | ||
extract($row); | ||
$tr = array( | ||
$html->link($Ad['id'], array('action' => 'view', $Ad['id'])), | ||
$AdPosition?$AdPosition['name']:'', | ||
$Ad['name'], | ||
$Ad['active'], | ||
$Ad['url'], | ||
$Ad['start_date'], | ||
$Ad['end_date'], | ||
); | ||
echo $html->tableCells($tr, array('class' => 'odd'), array('class' => 'even')); | ||
} | ||
?> | ||
</table> | ||
<?php echo $this->element('paging'); ?></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php /* SVN FILE: $Id$ */ | ||
extract($data); ?> | ||
<h1><?php echo $Ad['name'] ?></h1> | ||
<div class="container"> | ||
<table> | ||
<?php | ||
extract($data); | ||
|
||
$size = ''; | ||
if (!empty($Ad['src']['path'])) { | ||
$pathBase = WWW_ROOT.'img'.DS; | ||
|
||
if (file_exists($pathBase.$Ad['src']['path'])) { | ||
list($width, $height) = @getimagesize($pathBase.$Ad['src']['path']); | ||
$size = "<br /><br /><b>Image Size:</b> ({$width}px × {$height}px)"; | ||
} | ||
} | ||
echo $html->tableCells(array('id',$Ad['id'])); | ||
echo $html->tableCells(array('Ad Position', $AdPosition?$AdPosition['name']:'')); | ||
echo $html->tableCells(array('name',$Ad['name'])); | ||
echo $html->tableCells(array('src', $html->image($Ad['src']['path']).$size)); | ||
echo $html->tableCells(array('created',$Ad['created'])); | ||
echo $html->tableCells(array('modified',$Ad['modified'])); | ||
echo $html->tableCells(array('active',$Ad['active'])); | ||
echo $html->tableCells(array('url',$Ad['url'])); | ||
echo $html->tableCells(array('start_date',$Ad['start_date'])); | ||
echo $html->tableCells(array('end_date',$Ad['end_date'])); | ||
?> | ||
</table> | ||
</div> | ||
<?php | ||
$menu->addm('View', array( | ||
array('title' => $AdPosition['name'], 'url' => array('controller' => 'ad_positions', 'action' => 'view', $Ad['ad_position_id'])), | ||
)); |
Oops, something went wrong.