Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hobby committed Feb 6, 2016
1 parent 07f4231 commit 5755d01
Show file tree
Hide file tree
Showing 145 changed files with 34,061 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
/vendor/
composer.lock
16 changes: 16 additions & 0 deletions composer.json
@@ -0,0 +1,16 @@
{
"name": "hiveclick/mojavi",
"description": "Lightweight MVC Framework that works with MySQL, Postgres, and Mongo databases",
"require": {
"zendframework/zend-http": "^2.5",
"zendframework/zend-json": "^2.6",
"oyejorge/less.php": "v1.7.0.10"
},
"authors": [
{
"name": "hobby",
"email": "mark@hiveclick.com"
}
],
"minimum-stability": "dev"
}
Binary file added src/Mojavi/.DS_Store
Binary file not shown.
Binary file added src/Mojavi/._.DS_Store
Binary file not shown.
191 changes: 191 additions & 0 deletions src/Mojavi/Action/Action.php
@@ -0,0 +1,191 @@
<?php
/**
* Action allows you to separate application and business logic from your
* presentation. By providing a core set of methods used by the framework,
* automation in the form of security and validation can occur.
*
* @package Mojavi
* @subpackage Action
*/
namespace Mojavi\Action;

use Mojavi\Core\MojaviObject;
use Mojavi\Controller\Controller;
use Mojavi\View\View;
use Mojavi\Request\Request;

abstract class Action extends MojaviObject
{

// +-----------------------------------------------------------------------+
// | PRIVATE VARIABLES |
// +-----------------------------------------------------------------------+

// +-----------------------------------------------------------------------+
// | METHODS |
// +-----------------------------------------------------------------------+

/**
* Execute any application/business logic for this action.
*
* @return mixed A string containing the view name associated with this
* action.
*
* Or an array with the following indices:
*
* - The parent module of the view that will be executed.
* - The view that will be executed.
*/
abstract function execute ();

// -------------------------------------------------------------------------

/**
* Retrieve the current application context.
* @return \Mojavi\Core\Context
*/
public function getContext ()
{
return Controller::getInstance()->getContext();
}

// -------------------------------------------------------------------------

/**
* Retrieve the credential required to access this action.
*
* @return mixed Data that indicates the level of security for this action.
*/
public function getCredential ()
{

return null;

}

// -------------------------------------------------------------------------

/**
* Retrieve the default view to be executed when a given request is not
* served by this action.
*
* @return mixed A string containing the view name associated with this
* action.
*
* Or an array with the following indices:
*
* - The parent module of the view that will be executed.
* - The view that will be executed.
*/
public function getDefaultView ()
{

return View::INPUT;

}

// -------------------------------------------------------------------------

/**
* Retrieve the request methods on which this action will process
* validation and execution.
*
* @return int One of the following values:
*
* - Request::GET
* - Request::POST
* - Request::NONE
*/
public function getRequestMethods ()
{

return Request::GET | Request::POST;

}

// -------------------------------------------------------------------------

/**
* Execute any post-validation error application logic.
*
* @return mixed A string containing the view name associated with this
* action.
*
* Or an array with the following indices:
*
* - The parent module of the view that will be executed.
* - The view that will be executed.
*/
public function handleError ()
{

return View::ERROR;

}

// -------------------------------------------------------------------------

/**
* Initialize this action.
*
* @param Context The current application context.
*
* @return bool true, if initialization completes successfully, otherwise
* false.
*/
public function initialize ($context)
{
return true;

}

// -------------------------------------------------------------------------

/**
* Indicates that this action requires security.
*
* @return bool true, if this action requires security, otherwise false.
*/
public function isSecure ()
{

return false;

}

// -------------------------------------------------------------------------

/**
* Manually register validators for this action.
* @param ValidatorManager A ValidatorManager instance.
* @return void
*/
public function registerValidators ($validatorManager)
{

}

// -------------------------------------------------------------------------

/**
* Manually validate files and parameters.
*
* @return bool true, if validation completes successfully, otherwise false.
*/
public function validate ()
{

return true;

}

/**
* returns the errors
* @return \Mojavi\Error\Errors
*/
function getErrors() {
return $this->getContext()->getErrors();
}

}

135 changes: 135 additions & 0 deletions src/Mojavi/Action/ActionStack.php
@@ -0,0 +1,135 @@
<?php
/**
* ActionStack keeps a list of all requested actions and provides accessor
* methods for retrieving individual entries.
*
* @package Mojavi
* @subpackage Action
*/
namespace Mojavi\Action;

use Mojavi\Core\MojaviObject;

class ActionStack extends MojaviObject
{

// +-----------------------------------------------------------------------+
// | PRIVATE VARIABLES |
// +-----------------------------------------------------------------------+

private
$stack = array();

// +-----------------------------------------------------------------------+
// | METHODS |
// +-----------------------------------------------------------------------+

/**
* Add an entry.
*
* @param string A module name.
* @param string An action name.
* @param Action An action implementation instance.
*
* @return void
*/
public function addEntry ($moduleName, $actionName, $actionInstance)
{

// create our action stack entry and add it to our stack
$actionEntry = new ActionStackEntry($moduleName, $actionName,
$actionInstance);

$this->stack[] = $actionEntry;

}

// -------------------------------------------------------------------------

/**
* Retrieve the entry at a specific index.
*
* @param int An entry index.
*
* @return ActionStackEntry An action stack entry implementation.
*/
public function getEntry ($index)
{

$retval = null;

if ($index > -1 && $index < count($this->stack))
{

$retval = $this->stack[$index];

}

return $retval;

}

// -------------------------------------------------------------------------

/**
* Retrieve the first entry.
*
* @return ActionStackEntry An action stack entry implementation.
*/
public function getFirstEntry ()
{

$count = count($this->stack);
$retval = null;

if ($count > 0)
{

$retval = $this->stack[0];

}

return $retval;

}

// -------------------------------------------------------------------------

/**
* Retrieve the last entry.
*
* @return ActionStackEntry An action stack entry implementation.
*/
public function getLastEntry ()
{

$count = count($this->stack);
$retval = null;

if ($count > 0)
{

$retval = $this->stack[$count - 1];

}

return $retval;

}

// -------------------------------------------------------------------------

/**
* Retrieve the size of this stack.
*
* @return int The size of this stack.
*/
public function getSize ()
{

return count($this->stack);

}

}

0 comments on commit 5755d01

Please sign in to comment.