Skip to content

Commit

Permalink
Applying the new layout and add some new features
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioricardo committed Apr 26, 2011
1 parent c75e7dc commit 83305f0
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 0 deletions.
68 changes: 68 additions & 0 deletions app/controllers/pages_controller.php
@@ -0,0 +1,68 @@
<?php

class PagesController extends AppController {

public $name = 'Pages';
public $helpers = array('Html', 'Form', 'Javascript', 'TweetsAssist');

public function index() {
if (!empty($this->data['Pages']['event'])) {
$this->Session->write('Option.event', $this->data['Pages']['event']);
$this->redirect(array('controller' => 'tweets', $this->data['Pages']['event']));
}
}

public function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid page', true));
$this->redirect(array('action' => 'index'));
}
$this->set('page', $this->Page->read(null, $id));
}

public function add() {
if (!empty($this->data)) {
$this->Page->create();
if ($this->Page->save($this->data)) {
$this->Session->setFlash(__('The page has been saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The page could not be saved. Please, try again.', true));
}
}
}

public function edit($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid page', true));
$this->redirect(array('action' => 'index'));
}
if (!empty($this->data)) {
if ($this->Page->save($this->data)) {
$this->Session->setFlash(__('The page has been saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The page could not be saved. Please, try again.', true));
}
}
if (empty($this->data)) {
$this->data = $this->Page->read(null, $id);
}
}

public function delete($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for page', true));
$this->redirect(array('action' => 'index'));
}
if ($this->Page->delete($id)) {
$this->Session->setFlash(__('Page deleted', true));
$this->redirect(array('action' => 'index'));
}
$this->Session->setFlash(__('Page was not deleted', true));
$this->redirect(array('action' => 'index'));
}

}

?>
18 changes: 18 additions & 0 deletions app/models/page.php
@@ -0,0 +1,18 @@
<?php
class Page extends AppModel {
var $name = 'Page';
var $displayField = 'title';
var $validate = array(
'title' => array(
'notempty' => array(
'rule' => array('notempty'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
);
}
?>
24 changes: 24 additions & 0 deletions app/views/helpers/tweets_assist.php
@@ -0,0 +1,24 @@
<?php

class TweetsAssistHelper extends AppHelper {

var $helpers = array('Html', 'Form', 'Javascript');

public function formatTweetDate($created) {
date_default_timezone_set('America/Campo_Grande');
return date('d-m-Y', strtotime($created));
}

public function usersTweeting() {
$this->Tweet = new Tweet();
$users_images = $this->Tweet->find('all', array('limit' => 26,
'order' => 'RAND()', 'fields' => array('DISTINCT(user)', 'profile_image')));
echo $this->Html->tag('h2', __('Quem está tuitando?', true));
foreach ($users_images as $user)
echo $this->Html->image($user['Tweet']['profile_image'], array('alt' => $user['Tweet']['user'],
'alt' => $user['Tweet']['user'], 'url' => "http://twitter.com/#!/{$user['Tweet']['user']}", 'id' => 'user_image'));
}

}

?>
3 changes: 3 additions & 0 deletions app/views/pages/index.ctp
@@ -0,0 +1,3 @@
<?php echo $this->Form->create('Pages', array('url' => '/')); ?>
<?php echo $this->Form->input('event', array('label' => false)); ?>
<?php echo $this->Form->end(__('Start', true)); ?>
102 changes: 102 additions & 0 deletions app/webroot/css/bkp.css
@@ -0,0 +1,102 @@
* {
border: 0 none;
margin: 0;
padding: 0;
outline: none;
text-decoration: none;
}

body {
background: #3DABCB;
border-top: 10px solid #121621;
color: #121621;
font-family: 'Philosopher', Arial, serif;
font-size: 17px;
font-weight: normal;
line-height: 24px;
}

a {
color: #459ECB;
text-decoration: none;
}

a#tweet {
background: url(../img/date.png) left center no-repeat;
font-family: Georgia, Times, "Times New Roman", serif;
font-size: 12px;
font-weight: normal;
padding: 0 0 0 15px;
}

#header {
margin: 50px auto 10px;
width: 900px;
}

#header h1 {
background: url(../img/icon.png) left center no-repeat;
color: #121621;
float: left;
font-family: 'Neucha', Arial, serif;
font-size: 56px;
font-weight: bold;
line-height: 56px;
padding: 5px 0 0 50px;
}

#header #users {
display: block;
float: right;
height: 130px;
width: 400px;
}

#header #users h2 {
background: 0 none;
color: #FFF;
font-family: 'Neucha', Arial, serif;
font-style: italic;
}

#content {
background: #459ECB;
border-radius: 5px;
box-shadow: 1px 1px 5px #121621;
margin: 0 auto;
padding: 10px 10px 5px 10px;
width: 900px;
}

#content table {
background: 0 none;
}

#content table tbody tr {
background: 0 none;
}

#content table tbody tr td {
background: #FCFCFC;
padding: 10px 5px;
}

#content table tbody tr td:hover {
background: #F5F5F5;
cursor: pointer;
}

#content table tbody tr:first-child td {
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}

#content table tbody tr:last-child td {
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
}

#content table tbody tr td img {
float: left;
margin: 0 10px;
}

0 comments on commit 83305f0

Please sign in to comment.