summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.htaccess22
-rw-r--r--application/classes/controller/polls.php59
-rw-r--r--application/classes/model/fairy.php4
-rw-r--r--application/classes/model/flower.php5
-rw-r--r--application/classes/model/option.php12
-rw-r--r--application/classes/model/poll.php13
-rw-r--r--application/classes/model/tree.php5
-rw-r--r--application/config/database.php2
-rw-r--r--application/views/add.php34
-rw-r--r--application/views/index.php16
-rw-r--r--application/views/main.php18
-rw-r--r--application/views/poll.php32
-rw-r--r--application/views/single.php1
-rw-r--r--system/classes/request.php5
-rw-r--r--system/views/error.php94
-rw-r--r--web/.gitignore0
16 files changed, 16 insertions, 306 deletions
diff --git a/.htaccess b/.htaccess
index 90e2456..e7b6e2c 100644
--- a/.htaccess
+++ b/.htaccess
@@ -1,11 +1,11 @@
-RewriteEngine On
-RewriteBase /
-RewriteCond %{DOCUMENT_ROOT}/web/%{REQUEST_URI} -f
-RewriteRule ^(.*)$ /web/$1 [L,QSA]
-RewriteCond %{REQUEST_FILENAME} !-f
-RewriteRule .* index.php?$0 [PT,L,QSA]
-
-
-
-
-
+RewriteEngine On
+RewriteBase /
+RewriteCond %{DOCUMENT_ROOT}/web/%{REQUEST_URI} -f
+RewriteRule ^(.*)$ /web/$1 [L,QSA]
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteRule .* index.php/$0 [PT,L,QSA]
+
+
+
+
+
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">&lt; 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">&lt; 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
diff --git a/system/classes/request.php b/system/classes/request.php
index dfe68f0..106697a 100644
--- a/system/classes/request.php
+++ b/system/classes/request.php
@@ -106,7 +106,10 @@ class Request {
$request = new Request();
$request->_post = $_POST;
$request->_get = $_GET;
- $url_parts = parse_url($_SERVER['REQUEST_URI']);
+ $uri = $_SERVER['REQUEST_URI'];
+ $basepath=Config::get('core.basepath','/');
+ $uri = preg_replace("#^{$basepath}index\.php#i", '', $uri);
+ $url_parts = parse_url($uri);
$request->route = Route::match($url_parts['path']);
$request->method=$_SERVER['REQUEST_METHOD'];
return $request;
diff --git a/system/views/error.php b/system/views/error.php
deleted file mode 100644
index 6204f35..0000000
--- a/system/views/error.php
+++ /dev/null
@@ -1,94 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <title>Error</title>
- <style>
- html{
- width:100%;
- min-height:100%;
- font-family:'Verdana';
- font-size:14px;
- }
- body{
-
- min-height:100%;
- background: #a90329; /* Old browsers */
- background: -moz-radial-gradient(center, ellipse cover, #a90329 0%, #6d0019 100%); /* FF3.6+ */
- background: -webkit-radial-gradient(center, ellipse cover, #a90329 0%,#6d0019 100%); /* Chrome10+,Safari5.1+ */
- }
- #content{
- width:1000px;
- margin:auto;
- padding:10px 0px;
- background:#eee;
- }
- .file{
- font-weight:bold;
- }
- .block{
- border-bottom:1px solid #000;
- margin:10px;
- }
- .code{
-
- padding:10px;
- }
- .highlight{
- background:#efecd0;
- }
- #exception{
- font-size:25px;
- font-weight:bold;
- padding:10px;
- }
-
- </style>
- </head>
- <body>
- <?php
- $rawblocks=array_merge(array(array(
- 'file'=>$exception->getFile(),
- 'line'=>$exception->getLine()
- )), $exception->getTrace());
- $blocks = array();
- foreach($rawblocks as $block){
- if(!isset($block['file']))
- continue;
- //avoid duplicates
- if(count($blocks)>0){
- $last=$blocks[count($blocks)-1];
- if($block['file']==$last['file'] && $block['line']==$last['line'])
- continue;
- }
- $blocks[]=$block;
- }
-
-
- ?>
- <div id="content">
- <div id="exception"><?php echo str_replace("\n",'<br/>',$exception->getMessage()); ?></div>
- <div id="blocks">
- <?php foreach($blocks as $block): ?>
- <div class="block">
- <div class="file"><?php echo $block['file'];?></div>
- <div class="code">
- <?php
- $line=$block['line']-1;
- $code = explode("\n", file_get_contents($block['file']));
- $start = $line - 3;
- if ($start < 0) $start = 0;
- $end = $line + 3;
- if($end>=count($code)) $end=count($code)-1;
- $code=array_slice($code,$start,$end-$start,true);
- ?>
-
- <?php foreach($code as $n=>$text):?>
- <pre class="line <?php echo $n==$line?'highlight':''; ?>"><?php echo ($n+1).' '.htmlspecialchars($text); ?></pre>
- <?php endforeach;?>
- </div>
- </div>
- <?php endforeach;?>
- </div>
- </div>
- </body>
-</html> \ No newline at end of file
diff --git a/web/.gitignore b/web/.gitignore
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/web/.gitignore