Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton committed Jul 23, 2013
1 parent d81bdb4 commit f35dcd5
Show file tree
Hide file tree
Showing 104 changed files with 2,769 additions and 3 deletions.
60 changes: 60 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# License Agreement

This license is a legal agreement between you and the Modular Gaming Team for the use of Modular Gaming (the "Software").
By obtaining the Software you agree to comply with the terms and conditions of this license.

Copyright 2008-2013 Modular Gaming
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the author nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


# Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or

(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or

(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.

(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
core
====
# [Modular Gaming Core](http://www.modulargaming.com)

Modular Gaming core module.
A modular [persistent browser based game](http://www.pbbg.org) framework using [Kohana 3.3](https://github.com/kohana/core) with [ORM](https://github.com/kohana/orm) and [KOstache](https://github.com/zombor/KOstache).
3 changes: 3 additions & 0 deletions classes/Abstract/Controller/Ajax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

abstract class Abstract_Controller_Ajax extends MG_Abstract_Controller_Ajax {}
3 changes: 3 additions & 0 deletions classes/Abstract/Controller/Frontend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

abstract class Abstract_Controller_Frontend extends MG_Abstract_Controller_Frontend {}
3 changes: 3 additions & 0 deletions classes/Abstract/Tab.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

abstract class Abstract_Tab extends MG_Abstract_Tab {}
11 changes: 11 additions & 0 deletions classes/Abstract/View.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* Abstract base view for normal purposes.
*
* @package Modular Gaming
* @category View
* @author Modular Gaming Team
* @copyright (c) 2012-2013 Modular Gaming Team
* @license BSD http://modulargaming.com/license
*/
abstract class Abstract_View extends MG_Abstract_View {}
11 changes: 11 additions & 0 deletions classes/Abstract/View/Email.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* Abstract base view for email purposes.
*
* @package Modular Gaming
* @category View
* @author Modular Gaming Team
* @copyright (c) 2012-2013 Modular Gaming Team
* @license BSD http://modulargaming.com/license
*/
abstract class Abstract_View_Email extends MG_Abstract_View_Email {}
3 changes: 3 additions & 0 deletions classes/Abstract/View/Tab.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

abstract class Abstract_View_Tab extends MG_Abstract_View_Tab {}
3 changes: 3 additions & 0 deletions classes/Controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

class Controller extends MG_Controller {}
3 changes: 3 additions & 0 deletions classes/Controller/Assets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

class Controller_Assets extends MG_Controller_Assets {}
3 changes: 3 additions & 0 deletions classes/Controller/Error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

class Controller_Error extends MG_Controller_Error { }
3 changes: 3 additions & 0 deletions classes/Controller/Search.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

class Controller_Search extends MG_Controller_Search {}
3 changes: 3 additions & 0 deletions classes/Controller/Welcome.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

class Controller_Welcome extends MG_Controller_Welcome {}
3 changes: 3 additions & 0 deletions classes/Date.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

class Date extends MG_Date {}
3 changes: 3 additions & 0 deletions classes/Email.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

class Email extends MG_Email { }
3 changes: 3 additions & 0 deletions classes/Event.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

class Event extends MG_Event {}
3 changes: 3 additions & 0 deletions classes/HTTP/Exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

class HTTP_Exception extends MG_HTTP_Exception {}
3 changes: 3 additions & 0 deletions classes/HTTP/Exception/401.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

class HTTP_Exception_401 extends MG_HTTP_Exception_401 {}
3 changes: 3 additions & 0 deletions classes/HTTP/Exception/404.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

class HTTP_Exception_404 extends MG_HTTP_Exception_404 {}
3 changes: 3 additions & 0 deletions classes/Hint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

class Hint extends MG_Hint {}
3 changes: 3 additions & 0 deletions classes/Interface/Property.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

interface Interface_Property extends MG_Interface_Property {}
3 changes: 3 additions & 0 deletions classes/Journal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

class Journal extends MG_Journal {}
3 changes: 3 additions & 0 deletions classes/Kostache/Email.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

class Kostache_Email extends MG_Kostache_Email {}
3 changes: 3 additions & 0 deletions classes/Kostache/Layout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php defined('SYSPATH') OR die('No direct script access.');

class Kostache_Layout extends MG_Kostache_Layout {}
20 changes: 20 additions & 0 deletions classes/MG/Abstract/Controller/Ajax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* Abstract base controller for ajax.
*
* @package MG/Core
* @category Controller
* @author Modular Gaming Team
* @copyright (c) 2012-2013 Modular Gaming Team
* @license BSD http://modulargaming.com/license
*/
abstract class MG_Abstract_Controller_Ajax extends Controller {

public function before()
{
parent::before();

$this->response->headers('Content-Type', 'application/json');
}

}
65 changes: 65 additions & 0 deletions classes/MG/Abstract/Controller/Frontend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* Abstract base controller for frontend controllers.
*
* @package MG/Core
* @category Controller
* @author Modular Gaming Team
* @copyright (c) 2012-2013 Modular Gaming Team
* @license BSD http://modulargaming.com/license
*/
abstract class MG_Abstract_Controller_Frontend extends Controller {

/**
* @var Abstract_View view to render
*/
protected $view = NULL; // View to render.

/**
* @var string layout file.
*/
protected $layout = 'layout';

/**
* Run CSRF check and load frontend assets.
*/
public function before()
{
parent::before();

$this->_validate_csrf();
}

/**
* Set the response body to $this->view if $this->view is defined..
*/
public function after()
{
if ($this->view != NULL)
{
$renderer = Kostache_Layout::factory();
$renderer->set_layout($this->layout);
$this->response->body($renderer->render($this->view));
}
}

/**
* Check to ensure POST requests contains CSRF.
* @throws HTTP_Exception
*/
private function _validate_csrf()
{
if ($this->request->method() == HTTP_Request::POST)
{
$validation = Validation::factory($this->request->post())
->rule('csrf', 'not_empty')
->rule('csrf', 'Security::check');

if ( ! $validation->check())
{
throw HTTP_Exception::Factory(403, 'CSRF check failed!');
}
}
}

} // End Frontend
24 changes: 24 additions & 0 deletions classes/MG/Abstract/Tab.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php defined('SYSPATH') OR die('No direct script access.');
/**
*
*
* @package MG/Core
* @category View
* @author Modular Gaming Team
* @copyright (c) 2012-2013 Modular Gaming Team
* @license BSD http://modulargaming.com/license
*/
abstract class MG_Abstract_Tab {

/**
* @var Abstract_View_Tab $view
*/
protected $view;

public function render()
{
$renderer = Kostache::factory();
return $renderer->render($this->view);
}

}
Loading

0 comments on commit f35dcd5

Please sign in to comment.