/** * Test the view paths listed in config constant APP_TEST_VIEW_PATH_LIST * by validating the HTML as well-formatted and legal XHTML. */ public function view_paths_test() { foreach ($this->view_paths as $view_path) { $html = uri_get_contents(AppView::uri($view_path)); $errors = $this->app->xhtml_errors($html); $this->should("validate \"{$view_path}\" as XHTML", !$errors, $errors); } }
/** * Redirect to another URI, and possibly exit * * @param String $uri the URI to redirect at * @param Array $options an optional array of options (e.g. "exit") */ public function redirect($uri, $options = array()) { // Set flash messages to be shown on the next view page foreach (array('notice', 'warning', 'alert') as $level) { if ($message = array_key($options, $level)) { $this->controller->flash($level, $message); } } // Remember, type for interface testing is "test" if ($this->content_type !== DEFAULT_CONTENT_TYPE) { $uri .= '.' . $this->content_type; } // Set a location header and optional status $view_uri = AppView::uri($uri); $header = "Location: {$view_uri}"; if ($status = array_key($options, 'status')) { header($header, TRUE, $status); // set user-defined HTTP status code } else { header($header); } // Remain silent, and optionally exit or finish (preferred for logging) $this->is_silent = TRUE; if (array_key($options, 'exit')) { exit; } // careful! it stops our logging! if (array_key($options, 'finish')) { YAWF::finish("Redirected to {$view_uri}"); } }
/** * Get a normalized URI, using the current app's prefix settings * * @param String $uri the URI to normalize (e.g. "user/sign-up") * @param String $prefix an optional URI prefix * @return String the normalized URI */ function uri($uri, $prefix = NULL) { return AppView::uri($uri, $prefix); }
/** * Return an HTML script tag * * @param String $src the location of the script file (required) * @param Array $attrs the script tag's attributes (optional) * @return String the HTML script tag */ public static function script_tag($src, $attrs = array()) { $attrs['src'] = AppView::uri($src, array_key($attrs, 'prefix', FILE_URI_PREFIX)); $attrs['type'] = array_key($attrs, 'type', 'text/javascript'); // by default return '<script ' . self::attrs($attrs) . '></script>' . "\n"; }