public function redirect($handler, $page = null) { # Convenient wrapper for NeechyResponse::redirect. Also allows mocking for # testing, which is difficult with static methods. (See # http://stackoverflow.com/q/2357001/1093087). $url = NeechyPath::url($page, $handler); return NeechyResponse::redirect($url); }
/** * Tests */ public function testUrl() { $cases = array(array(array('MyPage', NULL, NULL), '?page=MyPage'), array(array('MyPage', 'handler', NULL), '?page=MyPage&handler=handler'), array(array('MyPage', NULL, 'action'), '?page=MyPage&action=action'), array(array('MyPage', 'handler', 'action'), '?page=MyPage&handler=handler&action=action')); foreach ($cases as $case) { list($args, $expected) = $case; list($page, $handler, $action) = $args; $url = NeechyPath::url($page, $handler, $action); $this->assertEquals($expected, $url); } }
public function build_page_tab_menu($page_title) { $page_tabs = array('page' => $page_title, 'editor' => 'Edit', 'history' => 'History'); $tabs_by_user_status = array('default' => array('page', 'history'), 'logged-in' => array_keys($page_tabs)); $user_status = AppUser::is_logged_in() ? 'logged-in' : 'default'; $user_tabs = $tabs_by_user_status[$user_status]; $tab_links = array(); foreach ($user_tabs as $handler) { $label = $page_tabs[$handler]; $href = NeechyPath::url($this->request->page, $handler); $classes = array($handler); if ($handler == 'page') { $classes[] = 'title'; } if ($handler == $this->request->handler) { $classes[] = 'active'; } if ($this->request->handler == 'editor' && $handler == $this->request->handler && $this->request->action == 'preview') { $label = 'Preview'; } $tab_links[] = $this->build_page_tab_link($label, $href, $classes); } return implode("\n", $tab_links); }
public function neechy_link($label, $page = null, $handler = null, $action = null, $options = array()) { $page = is_null($page) ? $label : $page; $href = NeechyPath::url($page, $handler, $action); return $this->link($href, $label, $options); }
<?php # # Neechy Signup/Login Form # Source: http://getbootstrap.com/examples/signin/ # $t = $this; # templater object $t->append_to_head($t->css_link($t->css_href('form.css'))); # General vars $alert = $t->data('alert'); $post_url = NeechyPath::url('login', 'auth'); $validation_errors = $t->data('validation-errors'); # # Helper function # function auth_field($field, $attrs, $t) { $type = $attrs[0]; $placeholder = $attrs[1]; $autofocus = isset($attrs[2]) ? $attrs[2] : false; $value = $type == 'password' ? NULL : $t->data($field); $options = array('class' => 'form-control', 'placeholder' => $placeholder, 'required' => NULL); if ($autofocus) { $options['autofocus'] = NULL; } $html = $t->input_field($type, $field, $value, $options); # Apply error styling if appropriate if (isset($validation_errors[$field])) { $html = apply_field_state('error', $html); }
<?php $t = $this; # templater object $page_url = NeechyPath::url($t->request->page, 'page'); ?> <table class="table table-condensed"> <tr> <th>id</th> <th>editor</th> <th>size</th> <th>datetime</th> </tr> <?php foreach ($t->data('edits') as $row) { ?> <tr> <td class="id"><?php echo $row['id']; ?> </td> <td class="editor"><?php echo $row['editor']; ?> </td> <td class="body"><?php echo strlen($row['body']); ?> </td> <td class="created_at"><?php echo $row['created_at'];
public function url($handler = NULL, $action = NULL, $params = array()) { return NeechyPath::url($this->field('name'), $handler, $action, $params); }
<?php # # Neechy Password View # require_once '../core/handlers/password/php/helper.php'; $t = $this; # templater object $t->append_to_head($t->css_link($t->css_href('form.css'))); $validator = $t->data('form-validator'); $helper = new PasswordHelper(); # General vars $post_url = NeechyPath::url('change', 'password'); ?> <div class="password handler"> <h2>Password</h2> <div id="neechy-pass" class="row"> <div id="neechy-login" class="well-sm col-xs-offset-1 col-xs-5"> <?php echo $helper->open_form($post_url); ?> <h3>Change Password</h2> <?php echo $helper->password_group('old-password', 'Old Password', true, $validator); ?> <?php echo $helper->password_group('new-password', 'New Password (8 chars min)', false, $validator); ?> <?php echo $helper->password_group('new-password-confirm', 'New Password (confirm)', false, $validator);