Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trunk' of git://github.com/integry/integry-framework in…
…to trunk
- Loading branch information
Showing
6 changed files
with
153 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/** | ||
* Integry framework bootstrap | ||
* | ||
* @package framework | ||
* @author Integry Systems | ||
* | ||
*/ | ||
|
||
require_once(dirname(__file__) . DIRECTORY_SEPARATOR . 'ClassLoader.php'); | ||
|
||
// we're assuming that application root is one level above the framework directory | ||
// if it's not the case, call ClassLoader::mountPath('.', '/path/to/the/root/directory'); | ||
ClassLoader::mountPath('.', dirname(dirname(__file__)) . DIRECTORY_SEPARATOR); | ||
|
||
ClassLoader::mountPath('framework', dirname(__file__) . DIRECTORY_SEPARATOR); | ||
|
||
ClassLoader::import('framework.request.*'); | ||
ClassLoader::import('framework.renderer.*'); | ||
ClassLoader::import('framework.response.*'); | ||
ClassLoader::import('framework.controller.*'); | ||
|
||
ClassLoader::import('framework.Application'); | ||
|
||
$app = new Application(); | ||
|
||
// initialize default routing rules | ||
$router = $app->getRouter(); | ||
|
||
$rules = array( | ||
array(":controller", array("action" => "index"), array()), | ||
array(":controller/:id", array("action" => "index"), array("id" => "-?[0-9]+")), | ||
array(":controller/:action", array(), array()), | ||
array(":controller/:action/:id", array(), array("id" => "-?[0-9]+")), | ||
); | ||
|
||
foreach ($rules as $route) | ||
{ | ||
$router->connect($route[0], $route[1], $route[2]); | ||
} | ||
|
||
return $app; | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
ClassLoader::import('framework.renderer.Renderer'); | ||
|
||
/** | ||
* Renderer implementation based on raw PHP files ("PHP itself is a templating engine") | ||
* | ||
* @package framework.renderer | ||
* @author Integry Systems | ||
*/ | ||
class PHPRenderer extends Renderer | ||
{ | ||
protected $values = array(); | ||
|
||
public function __construct(Application $application) | ||
{ | ||
$this->application = $application; | ||
} | ||
|
||
/** | ||
* Gets application instance | ||
* | ||
* @return Smarty | ||
*/ | ||
public function getApplication() | ||
{ | ||
return $this->application; | ||
} | ||
|
||
public function set($name, $value) | ||
{ | ||
$this->values[$name] = $value; | ||
} | ||
|
||
public function appendValue($name, $value) | ||
{ | ||
$this->values[$name] = $value; | ||
} | ||
|
||
public function setValueArray($array) | ||
{ | ||
$this->values[$name] = $array; | ||
} | ||
|
||
public function setObject($name, $object) | ||
{ | ||
$this->values[$name] = $object; | ||
} | ||
|
||
public function unsetValue($name) | ||
{ | ||
unset($this->values[$name]); | ||
} | ||
|
||
public function unsetAll() | ||
{ | ||
$this->values = array(); | ||
} | ||
|
||
public function render($view) | ||
{ | ||
if (file_exists($view)) | ||
{ | ||
ob_start(); | ||
extract($this->values); | ||
include $view; | ||
$contents = ob_get_contents(); | ||
ob_end_clean(); | ||
return $contents; | ||
} | ||
else | ||
{ | ||
throw new ViewNotFoundException($view); | ||
} | ||
} | ||
|
||
public function getViewExtension() | ||
{ | ||
return 'php'; | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters