mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
scaffolding++
This commit is contained in:
parent
530cb37df0
commit
b429830b34
6
webtools/bouncer/controllers/applications_controller.php
Normal file
6
webtools/bouncer/controllers/applications_controller.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
class ApplicationsController extends AppController {
|
||||
var $name = 'Applications';
|
||||
var $scaffold;
|
||||
}
|
||||
?>
|
78
webtools/bouncer/controllers/downloadables_controller.php
Normal file
78
webtools/bouncer/controllers/downloadables_controller.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
uses('sanitize');
|
||||
|
||||
class DownloadablesController extends AppController {
|
||||
var $name = 'Downloadables';
|
||||
var $scaffold;
|
||||
|
||||
var $helpers = array('Html', 'Pagination');
|
||||
var $show;
|
||||
var $sortBy;
|
||||
var $direction;
|
||||
var $page;
|
||||
var $order;
|
||||
var $sanitize;
|
||||
var $scaffold;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->sanitize = &new Sanitize;
|
||||
$this->show = empty($_GET['show'])? '10': $this->sanitize->sql($_GET['show']);
|
||||
$this->sortBy = empty($_GET['sort'])? 'Downloadable.id': $this->sanitize->sql($_GET['sort']);
|
||||
$this->direction = empty($_GET['direction'])? 'desc': $this->sanitize->sql($_GET['direction']);
|
||||
$this->page = empty($_GET['page'])? '1': $this->sanitize->sql($_GET['page']);
|
||||
$this->order = $this->sortBy.' '.strtoupper($this->direction);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
$data = $this->Downloadable->findAll($criteria=null, $fields=null, $this->order, $this->show, $this->page);
|
||||
|
||||
$paging['style'] = 'html'; //set the style of the links: html or ajax
|
||||
|
||||
foreach ($this->Downloadable->_tableInfo->value as $column) {
|
||||
|
||||
// If the sortBy is the same as the current link, we want to switch it.
|
||||
// By default, we don't -- so that when a user changes columns, the order doesn't also reverse.
|
||||
if ($this->sortBy == $column['name']) {
|
||||
switch ($this->direction) {
|
||||
case 'desc':
|
||||
$link_direction = 'asc';
|
||||
break;
|
||||
case 'asc':
|
||||
default:
|
||||
$link_direction = 'desc';
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$link_direction =& $this->direction;
|
||||
}
|
||||
$paging['headers'][$column['name']] = $this->sanitize->html('/downloadables/?show='.$this->show.'&sort='.$column['name'].'&direction='.$link_direction.'&page='.$this->page);
|
||||
}
|
||||
|
||||
$paging['link'] = $this->sanitize->html('./?show='.$this->show.'&sort='.$this->sortBy.'&direction='.$this->direction.'&page=');
|
||||
$paging['count'] = $this->Downloadable->findCount($criteria=null,'1000');
|
||||
$paging['page'] = $this->page;
|
||||
$paging['limit'] = $this->show;
|
||||
$paging['show'] = array('10','25','50','100');
|
||||
|
||||
$this->set('paging',$paging);
|
||||
$this->set('data',$data);
|
||||
}
|
||||
|
||||
function view($id) {
|
||||
$this->Downloadable->setId($id);
|
||||
$this->set('data', $this->Downloadable->read());
|
||||
}
|
||||
|
||||
function destroy($id) {
|
||||
if (empty($this->params['data'])) {
|
||||
$this->set('data', $this->Downloadable->read());
|
||||
$this->render();
|
||||
} elseif ($this->Downloadable->del($id)) {
|
||||
$this->flash('Downloadable '.$id.' has been deleted.', '/downloadables');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
5
webtools/bouncer/models/application.php
Normal file
5
webtools/bouncer/models/application.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
class Application extends AppModel {
|
||||
var $name = 'Application';
|
||||
}
|
||||
?>
|
7
webtools/bouncer/models/downloadable.php
Normal file
7
webtools/bouncer/models/downloadable.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
class Downloadable extends AppModel {
|
||||
var $name = 'Downloadable';
|
||||
|
||||
var $belongsTo = array('File','Mirror');
|
||||
}
|
||||
?>
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
class File extends AppModel {
|
||||
var $name = 'File';
|
||||
|
||||
var $belongsTo = array('Application', 'Platform', 'Locale', 'Template');
|
||||
}
|
||||
?>
|
||||
|
47
webtools/bouncer/views/downloadables/index.thtml
Normal file
47
webtools/bouncer/views/downloadables/index.thtml
Normal file
@ -0,0 +1,47 @@
|
||||
<h1>Downloadables</h1>
|
||||
|
||||
<?php if($pagination->setPaging($paging)):?>
|
||||
<div class="pagination">
|
||||
<?php echo $pagination->result('Results: '); ?>
|
||||
<?php echo $pagination->prevPage('Prev'); ?>
|
||||
<?php echo $pagination->pageNumbers(); ?>
|
||||
<?php echo $pagination->nextPage('Next'); ?>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
|
||||
<table class="inav">
|
||||
<tr>
|
||||
<th><?php echo $html->link('ID',$paging['headers']['id']); ?></th>
|
||||
<th><?php echo $html->link('Mirror ID',$paging['headers']['mirror_id']); ?></th>
|
||||
<th><?php echo $html->link('File ID',$paging['headers']['file_id']); ?></th>
|
||||
<th><?php echo $html->link('URL',$paging['headers']['url']); ?></th>
|
||||
<th><?php echo $html->link('Active',$paging['headers']['active']); ?></th>
|
||||
<th><?php echo $html->link('Count',$paging['headers']['downloadable_count']); ?></th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
<?php foreach ($data as $downloadable): ?>
|
||||
<tr>
|
||||
<td><?php echo $downloadable['Downloadable']['id']; ?></td>
|
||||
<td><?php echo $downloadable['Downloadable']['mirror_id']; ?></td>
|
||||
<td><?php echo $downloadable['Downloadable']['file_id']; ?></td>
|
||||
<td>
|
||||
<?php echo $html->link( $downloadable['Downloadable']['url'], "/downloadables/view/{$downloadable['Downloadable']['id']}" ); ?>
|
||||
</td>
|
||||
<td><?php echo ($downloadable['Downloadable']['active'])?'On':'Off'; ?></td>
|
||||
<td><?php echo ($downloadable['Downloadable']['downloadable_count']); ?></td>
|
||||
<td>
|
||||
<?=$html->link('Edit',"/downloadables/edit/{$downloadable['Downloadable']['id']}",'class="action"')?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
<?php if($pagination->setPaging($paging)):?>
|
||||
<ul id="page-numbers">
|
||||
<li><?php echo $pagination->show('Show '); ?></li>
|
||||
<li><?php echo $pagination->result('Results: '); ?></li>
|
||||
<li><?php echo $pagination->prevPage('Prev'); ?></li>
|
||||
<li><?php echo $pagination->pageNumbers(); ?></li>
|
||||
<li><?php echo $pagination->nextPage('Next'); ?></li>
|
||||
</ul>
|
||||
<?php endif;?>
|
3
webtools/bouncer/views/downloadables/view.thtml
Normal file
3
webtools/bouncer/views/downloadables/view.thtml
Normal file
@ -0,0 +1,3 @@
|
||||
<h1><?php echo $data['Downloadable']['id']; ?></h1>
|
||||
<p><?php echo $data['Downloadable']['url']; ?></p>
|
||||
<p><?php echo $data['Downloadable']['active']?'Active':'Not Active'; ?></p>
|
Loading…
Reference in New Issue
Block a user