public static function actionButton($name, $options, $context) { if (empty($options)) { $options = array(); } $app = \Slim\Slim::getInstance(); if (is_null(@$options['url'])) { $options['url'] = $app->request->getResourceUri() . '/%s/' . $name; } $url = \Bono\Helper\URL::site(sprintf($options['url'], $context['$id'])); $label = static::get($name, @$options['label'], $context); return '<a href="' . $url . '">' . $label . '</a>'; }
/** * Constructor * * @param [type] $app [description] * @param [type] $baseUri [description] */ public function __construct($app, $baseUri) { $this->app = $app; $this->request = $app->request; $this->response = $app->response; $this->baseUri = $baseUri; $exploded = explode('/', $baseUri); $clazz = $this->clazz = Inflector::classify(end($exploded)); $controller = $this; $response = $this->response; $app->filter('controller', function () use($controller) { return $controller; }); $app->filter('controller.name', function () use($clazz) { return $clazz; }); $app->filter('controller.uri', function ($uri) use($controller, $app) { if (strpos($uri, ':id')) { $params = $app->router->getCurrentRoute()->getParams(); $uri = str_replace(':id', $params['id'] ?: 'null', $uri); } return $controller->getBaseUri() . $uri; }); $app->filter('controller.url', function ($uri) use($controller, $app) { return URL::site(f('controller.uri', $uri)); }); $app->filter('controller.urlWithQuery', function ($uri) use($controller, $app) { return f('controller.url', $uri) . ($app->environment['QUERY_STRING'] ? '?' . $app->environment['QUERY_STRING'] : ''); }); $app->filter('controller.redirectUrl', function ($uri) use($controller) { return $controller->getRedirectUri(); }); $app->hook('bono.controller.before', function ($options) use($app, $controller, $response) { $template = $controller->getTemplate($options['method']); $response->template($template); }); $app->hook('bono.controller.after', function ($options) use($app, $controller, $response) { $response->data($controller->data()); }); $this->mapRoute(); }
<?php use Bono\Helper\URL; ?> <div> <a href="<?php echo URL::site($_controller->getBaseUri() . '/null/create'); ?> " class="button">Add</a> </div> <table class="table table-nowrap table-stripped"> <thead> <tr class="grid-head-row"> <?php foreach ($_schema as $field) { ?> <th><?php echo $field['label']; ?> </th> <?php } ?> <?php if (isset($_actions)) { ?> <th style="width:1px"> </th> <?php
<fieldset> <legend>Container</legend> <?php foreach ($entry as $key => $value) { ?> <div class="row"> <div class="span-12"> <label><?php echo $key; ?> </label> <span class="field"><?php echo $value; ?> </span> </div> </div> <?php } ?> </fieldset> <div class="row"> <a href="<?php echo \Bono\Helper\URL::site($_controller->getBaseUri()); ?> " class="button">Back to List</a> </div>
/** * Get full URL of web service endpoint * * @see MarkdownProvider::getDefaultEndPoint * @return string */ public function getServiceUrl() { return URL::site($this->getDefaultEndPoint()); }
<script type="text/javascript"> // FIXME create custom event using plain javascript only! // (function() { // "use strict"; // var $obj = $('[name=<?php echo $self['name']; ?> ]'); // var criterias = JSON.parse('<?php echo json_encode($criteria); ?> '); // var baseUrl = "<?php echo URL::site('/' . $foreign->name) . '.json'; ?> "; // var foreignKey = "<?php echo $self['foreignKey']; ?> "; // var foreignLabel = "<?php echo $self['foreignLabel']; ?> "; // $(function() { // $obj.trigger('change'); // });
public function renderActionButton($name, $value, $context) { if (empty($value)) { $url = URL::site($this->app->controller->getBaseUri() . '/' . $context['$id'] . '/' . $name); return '<a href="' . $url . '">' . $this->humanize($name) . "</a>\n"; } else { return $value($name, $value, $context); } }
/** * [redirect description] * * @param string $url [description] * @param integer $status [description] * * @return [type] [description] */ public function redirect($url = ':self', $status = 302) { $scheme = parse_url($url, PHP_URL_SCHEME); if (isset($scheme)) { return parent::redirect($url, $status); } if ($url === ':self') { $app = \Slim\Slim::getInstance(); $url = $app->request->getResourceUri(); } $url = \Bono\Helper\URL::site($url); return parent::redirect($url, $status); }