Permalink
Browse files

Big update and lots of fixes

* Updated to Fuel 1.2-RC1
* New layout using Twitter Bootstrap
* Fixed a bug with the login loop
* Fixed a bug with the publish article
* and some more small fixes.
  • Loading branch information...
1 parent 12bc978 commit eeb5349259a6ec0b507a857660c1948a3aa27600 @abdel committed Jun 2, 2012
Showing 422 changed files with 30,413 additions and 8,119 deletions.
View
@@ -1,7 +1,7 @@
# Stationwagon
-* Version: 1.2
-* Fuel Version: 1.0
+* Version: 1.3
+* Fuel Version: 1.2-RC1
* [Stationwagon on FuelPHP Forums](http://fuelphp.com/forums/topics/view/326)
## Description
@@ -19,7 +19,7 @@ You can download Stationwagon right away from the Downloads area.
## Cloning Stationwagon
git clone git://github.com/abdelm/stationwagon.git
-
+
## Installation
After cloning or downloading Stationwagon using the steps above, you will do a few things to get Stationwagon up and running:
@@ -33,14 +33,14 @@ After cloning or downloading Stationwagon using the steps above, you will do a f
If you want to use mod_rewrite, do the following changes in */fuel/app/config/config.php*:
'index_file' => false,
-
+
h2. Learning
Stationwagon is full of examples and is updated regularly with the latest Fuel changes.
There are a lot of examples on these classes:
- Orm
-- Auth
+- Auth
- Pagination
- Validation
- and more!
View
@@ -1,7 +1,11 @@
<?php
+// Load in the Autoloader
+require COREPATH.'classes'.DIRECTORY_SEPARATOR.'autoloader.php';
+class_alias('Fuel\\Core\\Autoloader', 'Autoloader');
+
// Bootstrap the framework DO NOT edit this
-require_once COREPATH.'bootstrap.php';
+require COREPATH.'bootstrap.php';
Autoloader::add_classes(array(
@@ -12,8 +16,15 @@
// Register the autoloader
Autoloader::register();
-// Initialize the framework with the config file.
-Fuel::init(include(APPPATH.'config/config.php'));
-
+/**
+ * Your environment. Can be set to any of the following:
+ *
+ * Fuel::DEVELOPMENT
+ * Fuel::TEST
+ * Fuel::STAGE
+ * Fuel::PRODUCTION
+ */
+Fuel::$env = (isset($_SERVER['FUEL_ENV']) ? $_SERVER['FUEL_ENV'] : Fuel::DEVELOPMENT);
-/* End of file bootstrap.php */
+// Initialize the framework with the config file.
+Fuel::init('config.php');
@@ -3,15 +3,15 @@
class Controller_Articles extends Controller_Common {
public function action_index($show = 'published')
- {
- $published = (($show === 'published') ? 1 : 0);
-
+ {
+ $published = (($show === 'published') ? 1 : 0);
+
// Get total articles
$total_articles = Model_Article::find()
->where('user_id', $this->user_id)
->where('published', $published)
->count();
-
+
// Setup pagination
Config::set('pagination', array(
'pagination_url' => 'articles/index/'.$show.'/',
@@ -20,7 +20,7 @@ public function action_index($show = 'published')
'num_links' => 3,
'uri_segment' => 4,
));
-
+
// Get articles
$articles = Model_Article::find('all', array(
'offset' => Pagination::$offset,
@@ -31,21 +31,21 @@ public function action_index($show = 'published')
array('published', '=', $published),
),
));
-
+
$this->template->title = 'Articles';
- $this->template->content = View::factory('articles/index')
+ $this->template->content = View::forge('articles/index')
->set('total_articles', $total_articles)
->set('articles', $articles, false)
->set('show', $show);
}
-
+
public function action_add()
- {
- $val = Model_Article::validate('add_article');
-
+ {
+ $val = Model_Article::validate('add_article');
+
if ($val->run())
- {
- $status = (Input::post('save_draft') ? 0 : 1);
+ {
+ $status = (Input::post('save_draft') ? 0 : 1);
if ( ! $val->input('category_id'))
{
@@ -55,40 +55,40 @@ public function action_add()
{
$category_id = $val->validated('category_id');
}
-
+
$article = new Model_Article(array(
'user_id' => $this->user_id,
'category_id' => $category_id,
'title' => $val->validated('title'),
'body' => $val->validated('body'),
'published' => $status,
));
-
+
if ($article->save())
{
Session::set_flash('success', 'Article successfully added.');
}
else
{
- Session::set_flash('error', 'Something went wrong, '.
- 'please try again!');
+ Session::set_flash('error', 'Something went wrong, '.
+ 'please try again!');
}
-
+
Response::redirect('articles/add');
}
-
+
$this->template->title = 'Add Article';
- $this->template->content = View::factory('articles/add')
+ $this->template->content = View::forge('articles/add')
->set('categories', Model_Category::find('all'), false)
->set('val', Validation::instance('add_article'), false);
}
-
+
public function action_edit($id)
{
$article = Model_Article::find_by_id_and_user_id($id, $this->user_id);
-
+
$val = Model_Article::validate('edit_article');
-
+
if ($val->run())
{
if ( ! $val->input('category_id'))
@@ -99,44 +99,44 @@ public function action_edit($id)
{
$category_id = $val->validated('category_id');
}
-
+
$article->category_id = $category_id;
$article->title = $val->validated('title');
$article->body = $val->validated('body');
-
+
if ($article->save())
{
Session::set_flash('success', 'Article successfully updated.');
}
else
{
- Session::set_flash('error', 'Something went wrong, '.
- 'please try again!');
+ Session::set_flash('error', 'Something went wrong, '.
+ 'please try again!');
}
-
+
Response::redirect('articles/edit/'.$article->id);
}
-
+
$this->template->title = 'Edit Article - '.$article->title;
- $this->template->content = View::factory('articles/edit')
+ $this->template->content = View::forge('articles/edit')
->set('categories', Model_Category::find('all'), false)
->set('article', $article, false)
->set('val', Validation::instance('edit_article'), false);
}
-
+
public function action_publish($id)
{
$article = Model_Article::find_by_id_and_user_id($id, $this->user_id);
$article->published = 1;
$article->save();
-
+
Response::redirect('articles');
}
-
+
public function action_delete($id)
{
Model_Article::find_by_id_and_user_id($id, $this->user_id)->delete();
-
+
Response::redirect('articles');
}
}
@@ -1,22 +1,22 @@
<?php
class Controller_Categories extends Controller_Common {
-
+
public function action_index()
{
// Get total categories
- $total_categories = Model_Category::find()
- ->where('user_id', $this->user_id)
- ->count();
-
+ $total_categories = Model_Category::find()
+ ->where('user_id', $this->user_id)
+ ->count();
+
// Setup pagination
Config::set('pagination', array(
'pagination_url' => 'categories/index',
'per_page' => 5,
'total_items' => $total_categories,
'num_links' => 3,
));
-
+
// Get categories
$categories = Model_Category::find('all', array(
'offset' => Pagination::$offset,
@@ -25,20 +25,20 @@ public function action_index()
array('user_id', '=', $this->user_id),
),
));
-
+
$this->template->title = 'Categories';
- $this->template->content = View::factory('categories/index')
+ $this->template->content = View::forge('categories/index')
->set('total_categories', $total_categories)
->set('categories', $categories, false);
}
-
+
public function action_add()
{
// Setup validation
- $val = Validation::factory('add_category');
+ $val = Validation::forge('add_category');
$val->add('name', 'Name')->add_rule('required');
$val->add('description', 'Description');
-
+
if ($val->run())
{
// Set category details
@@ -47,7 +47,7 @@ public function action_add()
'name' => $val->validated('name'),
'description' => $val->validated('description'),
));
-
+
// Save
if ($category->save())
{
@@ -57,28 +57,28 @@ public function action_add()
{
Session::set_flash('error', 'Something went wrong, please try again!');
}
-
+
Response::redirect('categories/add');
}
-
+
$this->template->title = 'Add Category';
- $this->template->content = View::factory('categories/add')
+ $this->template->content = View::forge('categories/add')
->set('val', $val, false);
}
-
+
public function action_edit($id)
{
$category = Model_Category::find_by_id_and_user_id($id, $this->user_id);
-
- $val = Validation::factory('edit_category');
+
+ $val = Validation::forge('edit_category');
$val->add('name', 'Name')->add_rule('required');
$val->add('description', 'Description');
-
+
if ($val->run())
{
$category->name = $val->validated('name');
$category->description = $val->validated('description');
-
+
if ($category->save())
{
Session::set_flash('success', 'Category successfully updated.');
@@ -87,21 +87,21 @@ public function action_edit($id)
{
Session::set_flash('error', 'Something went wrong, please try again!');
}
-
+
Response::redirect('categories/edit/'.$category->id);
}
-
+
$this->template->title = 'Edit Category - '.$category->name;
- $this->template->content = View::factory('categories/edit')
+ $this->template->content = View::forge('categories/edit')
->set('val', $val, false)
->set('category', $category);
}
-
+
public function action_delete($id)
{
// Find and delete category
Model_Category::find_by_id_and_user_id($id, $this->user_id)->delete();
-
+
Response::redirect('categories');
}
}
Oops, something went wrong.

0 comments on commit eeb5349

Please sign in to comment.