diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/classes/controller/polls.php | 59 | ||||
-rw-r--r-- | application/classes/model/fairy.php | 4 | ||||
-rw-r--r-- | application/classes/model/flower.php | 5 | ||||
-rw-r--r-- | application/classes/model/option.php | 12 | ||||
-rw-r--r-- | application/classes/model/poll.php | 13 | ||||
-rw-r--r-- | application/classes/model/tree.php | 5 | ||||
-rw-r--r-- | application/config/database.php | 2 | ||||
-rw-r--r-- | application/views/add.php | 34 | ||||
-rw-r--r-- | application/views/index.php | 16 | ||||
-rw-r--r-- | application/views/main.php | 18 | ||||
-rw-r--r-- | application/views/poll.php | 32 | ||||
-rw-r--r-- | application/views/single.php | 1 |
12 files changed, 1 insertions, 200 deletions
diff --git a/application/classes/controller/polls.php b/application/classes/controller/polls.php deleted file mode 100644 index c15be88..0000000 --- a/application/classes/controller/polls.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php
-class Polls_Controller extends Controller {
-
- public $view;
- public $template;
-
- public function before() {
- $this->view = View::get('main');
- $this->template=$this->request->param('action');
- }
- public function action_index(){
- $this->view->polls = ORM::factory('poll')->find_all();
- }
-
- public function action_poll() {
-
- if ($this->request->method == 'POST') {
- $option_id = $this->request->post('option');
- $option = ORM::factory('option')->where('id', $option_id)->find();
- $option->votes += 1;
- $option->save();
- $this->response-> redirect('/polls/poll/'.$option->poll->id);
- $this->execute=false;
- return;
- }
-
- $id=$this->request->param('id');
- $this->view->poll = ORM::factory('poll')->where('id', $id)->find();
-
- }
-
- public function action_add(){
- if ($this->request->method == 'POST') {
- $poll = ORM::factory('poll');
- $poll->question = $this->request->post('question');
- $poll->save();
- foreach($this->request->post('options') as $text) {
- if (empty($text))
- continue;
- $option = ORM::factory('option');
- $option->text = $text;
- $option->save();
- $poll->add('options',$option);
- }
- $this->response->redirect('/polls/');
- return;
- }
-
- $this->template='add';
- }
-
- public function after() {
- $this->view->template=Misc::find_file('views',$this->template);
- $this->response->body=$this->view->render();
- }
-
-
-}
-?>
\ No newline at end of file diff --git a/application/classes/model/fairy.php b/application/classes/model/fairy.php deleted file mode 100644 index e5a8678..0000000 --- a/application/classes/model/fairy.php +++ /dev/null @@ -1,4 +0,0 @@ -<?php
-class Fairy_Model extends ORM{
- public $belongs_to=array('tree','flower');
-}
\ No newline at end of file diff --git a/application/classes/model/flower.php b/application/classes/model/flower.php deleted file mode 100644 index b817a7d..0000000 --- a/application/classes/model/flower.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php
-class Flower_Model extends ORM{
- public $has_many=array('fairies');
- public $belongs_to=array('protector'=>array('model'=>'fairy','key'=>'protector_id'));
-}
\ No newline at end of file diff --git a/application/classes/model/option.php b/application/classes/model/option.php deleted file mode 100644 index b143913..0000000 --- a/application/classes/model/option.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php
-class Option_Model extends ORM{
- public $belongs_to = array('poll');
-
- public function get($property) {
- if ($property == 'percent') {
- if($this->poll->total_votes==0)
- return 0;
- return floor($this->votes/$this->poll->total_votes*100);
- }
- }
-}
\ No newline at end of file diff --git a/application/classes/model/poll.php b/application/classes/model/poll.php deleted file mode 100644 index a2cfe08..0000000 --- a/application/classes/model/poll.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php
-class Poll_Model extends ORM{
- public $has_many=array('options');
-
- public function get($property){
- if ($property == 'total_votes') {
- $total=0;
- foreach($this->options->find_all() as $option)
- $total += $option->votes;
- return $total;
- }
- }
-}
\ No newline at end of file diff --git a/application/classes/model/tree.php b/application/classes/model/tree.php deleted file mode 100644 index 721372e..0000000 --- a/application/classes/model/tree.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php
-class Tree_Model extends ORM{
- public $has_many=array('fairies');
- public $belongs_to=array('protector'=>array('model'=>'fairy','key'=>'protector_id'),'flower');
-}
\ No newline at end of file diff --git a/application/config/database.php b/application/config/database.php index 3a04f14..0295f13 100644 --- a/application/config/database.php +++ b/application/config/database.php @@ -4,7 +4,7 @@ return array( 'default' => array(
'user'=>'root',
'password' => '',
- 'driver' => 'mysql',
+ 'driver' => 'pdo',
//'Connection' is required if you use the PDO driver
'connection'=>'mysql:host=localhost;dbname=phpixie',
diff --git a/application/views/add.php b/application/views/add.php deleted file mode 100644 index 3fda246..0000000 --- a/application/views/add.php +++ /dev/null @@ -1,34 +0,0 @@ -<script>
- $(function(){
- $('#addOption').click(function(evt){
- evt.preventDefault();
-
- var newOption=$('.option:eq(0)').clone();
- newOption.find('input').val('').attr('placeholder','Option #'+($('.option').length+1));
- $('#options').append(newOption);
- })
- })
-</script>
-<form method="POST">
-<fieldset>
- <legend>Add a new poll</legend>
- <label>Question</label>
- <input type="text" placeholder="Type your question here..." name="question" />
- <label>Options</label>
- <div id="options">
- <div class="option">
- <input type="text" name="options[]" placeholder="Option #1" />
- </div>
- <div class="option">
- <input type="text" name="options[]" placeholder="Option #2" />
- </div>
- <div class="option">
- <input type="text" name="options[]" placeholder="Option #3" />
- </div>
- </div>
- <button class="btn" id="addOption"><i class="icon-plus"></i> Add option</button>
- <button class="btn btn-primary"><i class="icon-ok icon-white"></i> Save poll </button>
-
-</fieldset>
-</form>
-<a class="btn btn-link" href="/polls">< Back to polls</a>
\ No newline at end of file diff --git a/application/views/index.php b/application/views/index.php deleted file mode 100644 index 5ba6d8d..0000000 --- a/application/views/index.php +++ /dev/null @@ -1,16 +0,0 @@ -<style>
- .muted{
- float:right;
- }
-</style>
-<ul class="nav nav-tabs nav-stacked ">
- <?php foreach($polls as $poll):?>
- <li>
- <a href="<?php echo "/polls/poll/{$poll->id}"; ?>" >
- <?echo $poll->question;?>
- <div class="muted"><?php echo $poll->total_votes; ?> Votes</div>
- </a>
- </li>
- <?php endforeach;?>
-</ul>
-<a class="btn btn-block" href="/polls/add"><i class="icon-plus"></i> Add poll</a>
\ No newline at end of file diff --git a/application/views/main.php b/application/views/main.php deleted file mode 100644 index 96cdbf3..0000000 --- a/application/views/main.php +++ /dev/null @@ -1,18 +0,0 @@ -<!DOCTYPE html>
-<html>
- <head>
- <title>Add a new poll</title>
- <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
- </head>
- <body>
- <div class="container">
- <div class="span4"></div>
- <div class="span4">
- <h2>PHPixie Polls</h2>
- <?php include($template);?>
- </div>
- <div class="span4"></div>
- </div>
- </body>
-</html>
\ No newline at end of file diff --git a/application/views/poll.php b/application/views/poll.php deleted file mode 100644 index 3eaadae..0000000 --- a/application/views/poll.php +++ /dev/null @@ -1,32 +0,0 @@ -<style>
- form{
- margin-bottom:0px;
- }
-
- .filled{
- background:#08C;
- height:20px;
- }
- .bar{
- width:100px;
- }
-</style>
-<h3><?php echo $poll->question; ?></h3>
-<table class="table">
- <?php foreach($poll->options->find_all() as $option):?>
- <tr>
- <td><?php echo $option->text;?></td>
- <td><?php echo $option->votes;?></td>
- <td class="bar">
- <div class="filled" style="width:<?php echo $option->percent;?>%;"></div>
- </td>
- <td>
- <form method="POST">
- <input type="hidden" name="option" value="<?php echo $option->id; ?>" />
- <button class="btn btn-mini">Vote</button>
- </form>
- </td>
- </tr>
- <?php endforeach;?>
-</table>
-<a class="btn btn-link" href="/polls">< Back to polls</a>
\ No newline at end of file diff --git a/application/views/single.php b/application/views/single.php deleted file mode 100644 index d02deaa..0000000 --- a/application/views/single.php +++ /dev/null @@ -1 +0,0 @@ -<h3><?php echo $poll->question; ?></h3>
\ No newline at end of file |