diff options
Diffstat (limited to 'application/classes')
-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 |
6 files changed, 0 insertions, 98 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 |