Skip to content

Commit

Permalink
Recess Tools links up
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisJordan committed Apr 13, 2009
1 parent ea49729 commit 76c352c
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 19 deletions.
Expand Up @@ -3,7 +3,7 @@
Library::import('recess.database.pdo.RecessType');

/**
* !View Native, Prefix: apps/
* !View Recess, Prefix: apps/
* !RoutesPrefix apps/
*/
class RecessToolsAppsController extends Controller {
Expand Down
Expand Up @@ -10,7 +10,7 @@
Library::import('recess.apps.tools.models.RecessReflectorMethod');

/**
* !View Native, Prefix: code/
* !View Recess, Prefix: code/
* !RoutesPrefix code/
*/
class RecessToolsCodeController extends Controller {
Expand Down
Expand Up @@ -4,7 +4,7 @@
Library::import('recess.database.pdo.PdoDataSource');

/**
* !View Native, Prefix: database/
* !View Recess, Prefix: database/
* !RoutesPrefix database/
*/
class RecessToolsDatabaseController extends Controller {
Expand Down
Expand Up @@ -2,7 +2,7 @@
Library::import('recess.framework.controllers.Controller');

/**
* !View Native, Prefix: home/
* !View Recess, Prefix: home/
*/
class RecessToolsHomeController extends Controller {

Expand Down
Expand Up @@ -2,7 +2,7 @@
Library::import('recess.framework.controllers.Controller');

/**
* !View Native, Prefix: routes/
* !View Recess, Prefix: routes/
* !RoutesPrefix routes/
*/
class RecessToolsRoutesController extends Controller {
Expand Down
Expand Up @@ -2,7 +2,7 @@
Library::import('recess.framework.controllers.Controller');

/**
* !View Native, Prefix: tests/
* !View Recess, Prefix: tests/
* !RoutesPrefix tests/
*/
class RecessToolsTestsController extends Controller {
Expand Down
20 changes: 11 additions & 9 deletions recess/recess/apps/tools/views/common/header.php
@@ -1,17 +1,19 @@
<html>
<head>
<!-- Blue Print -->
<link rel="stylesheet" href="<?php echo $_ENV['url.content']; ?>css/blueprint/screen.css" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="<?php echo $_ENV['url.content']; ?>css/blueprint/print.css" type="text/css" media="print" />
<?php echo html::css('blueprint/screen', 'screen'); ?>
<?php echo html::css('blueprint/print', 'print'); ?>
<!--[if IE]>
<link rel="stylesheet" href="/css/blueprint/ie.css" type="text/css" media="screen, projection" />
<?php echo html::css('blueprint/ie', 'screen'); ?>
<![endif]-->
<link rel="stylesheet" href="<?php echo $_ENV['url.content']; ?>css/recess.css" />
<!-- Syntax Highlighter -->
<link type="text/css" rel="stylesheet" href="<?php echo $_ENV['url.content']; ?>css/SyntaxHighlighter.css"></link>
<script language="javascript" src="<?php echo $_ENV['url.content']; ?>js/shCore.js"></script>
<script language="javascript" src="<?php echo $_ENV['url.content']; ?>js/shBrushPhp.js"></script>
<script language="javascript" src="<?php echo $_ENV['url.content']; ?>js/shBrushSql.js"></script>
<?php echo html::css('recess'); ?>

<?php
echo html::css('SyntaxHighlighter');
echo html::js('shCore');
echo html::js('shBrushPhp');
echo html::js('shBrushSql');
?>
<script language="javascript">
window.onload = function() {
dp.SyntaxHighlighter.ClipboardSwf = '<?php echo $_ENV['url.content']; ?>flash/clipboard.swf';
Expand Down
3 changes: 1 addition & 2 deletions recess/recess/framework/helpers/Html.class.php
@@ -1,5 +1,5 @@
<?php
Library::import('recess.framework.helpers.AbstractHelper');
Library::import('recess.framework.AbstractHelper');
Library::import('recess.framework.helpers.Url');

/**
Expand Down Expand Up @@ -75,7 +75,6 @@ public static function anchor($uri, $title = NULL, $attributes = NULL) {
*
* @param string|array filename, or array of filenames to match to array of medias
* @param string|array media type of stylesheet, or array to match filenames
* @param boolean include the index_page in the link
* @return string
*/
public static function css($style, $media = FALSE) {
Expand Down
97 changes: 97 additions & 0 deletions recess/recess/framework/helpers/Layout.class.php
@@ -0,0 +1,97 @@
<?php
Library::import('recess.framework.AbstractHelper');

class Layout extends AbstractHelper {

const DEFAULT_BLOCK = 'body';

protected static $extendStack = array();

protected static $blockStack = array();
protected static $blockMap = array();

protected static $slotStack = array();

protected static $app;

public static function init($view) {
$response = $view->getResponse();
self::$app = $response->meta->app;
}

public static function extend($layout) {
if(!empty(self::$extendStack)) {
die('error: can\'t nest extends');
}

array_push(self::$extendStack, $layout);
ob_start();
}

public static function block($title) {
if(empty(self::$extendStack)) {
die('error: not extending');
}

if(!empty(self::$blockStack)) {
die('error: cant nest blocks');
}

array_push(self::$blockStack, $title);
ob_start();
}

public static function blockEnd() {
if(empty(self::$blockStack)) {
die('not in a block!');
}

$blockName = array_pop(self::$blockStack);
if(!isset(self::$blockMap[$blockName])) {
self::$blockMap[$blockName] = ob_get_clean();
} else {
ob_end_clean();
}
}

public static function slot($title) {
if(!empty(self::$slotStack)) {
die('can\'t nest slots');
}

array_push(self::$slotStack, $title);
ob_start();
}

public static function slotEnd() {
if(empty(self::$slotStack)) {
die('not in a slot');
}

$slotName = array_pop(self::$slotStack);
if(isset(self::$blockMap[$slotName])) {
ob_end_clean();
echo self::$blockMap[$slotName];
unset(self::$blockMap[$slotName]);
} else {
ob_end_flush();
}
}

public static function extendEnd() {
if(!empty(self::$extendStack)) {
if(!isset(self::$blockMap[Layout::DEFAULT_BLOCK])) {
self::$blockMap[Layout::DEFAULT_BLOCK] = ob_get_clean();
} else {
ob_end_clean();
}

$parent = array_pop(self::$extendStack);
include(self::$app->getViewsDir() . $parent . '.php');
self::extendEnd();
}
}

}

?>
4 changes: 2 additions & 2 deletions recess/recess/framework/helpers/Url.class.php
@@ -1,5 +1,5 @@
<?php
Library::import('recess.framework.helpers.AbstractHelper');
Library::import('recess.framework.AbstractHelper');

/**
* The URL helper is used in views to generate URLs to many aspects
Expand Down Expand Up @@ -58,7 +58,7 @@ public static function base($suffix = ''){
* @return string URL to an asset.
*/
public static function asset($file = ''){
return self::$publicPath . $file;
return self::$assetUrl . $file;
}

/**
Expand Down
26 changes: 26 additions & 0 deletions recess/recess/framework/views/RecessView.class.php
@@ -0,0 +1,26 @@
<?php
Library::import('recess.framework.views.NativeView');
Library::import('recess.framework.helpers.Layout');
Library::import('recess.framework.helpers.Url');
Library::import('recess.framework.helpers.Html');

class RecessView extends NativeView {
/**
* Realizes HTTP's body content based on the Response parameter. Responsible
* for returning content in the format desired. The render method likely uses
* inversion of control which delegates to another method within the view to
* realize the Response.
*
* @param Response $response
* @abstract
*/
protected function render(Response $response) {
$this->loadHelper(
'recess.framework.helpers.Layout',
'recess.framework.helpers.Url',
'recess.framework.helpers.Html');
parent::render($response);
Layout::extendEnd();
}
}
?>

0 comments on commit 76c352c

Please sign in to comment.