public function __construct($view, $data = array()) { parent::__construct($view, $data); // If a session driver has been specified, we will bind an instance of the // message container to every view. If a container instance // exists in the session, we will use that instance. $key = 'messages'; if (!isset($this->data[$key])) { if (Session::started() and Session::has($key)) { $this->data[$key] = Session::get($key); } else { $this->data[$key] = new TypedMessages(); } } }
/** * Resolve a controller name to a controller instance. * * @param string $container * @param string $controller * @return Controller */ public static function resolve($controller) { if (!static::load($controller)) { return; } // If the controller is registered in the IoC container, we will resolve // it out of the container. Using constructor injection on controllers // via the container allows more flexible and testable applications. if (IoC::registered('controllers.' . $controller)) { return IoC::resolve('controllers.' . $controller); } $controller = str_replace(' ', '_', ucwords(str_replace('.', ' ', $controller))) . '_Controller'; $controller = new $controller(); // If the controller has specified a layout to be used when rendering // views, we will instantiate the layout instance and set it to the // layout property, replacing the string layout name. if (!is_null($controller->layout)) { $controller->layout = View::make($controller->layout); } return $controller; }
/** * Create a new error response instance. * * The response status code will be set using the specified code. * * The specified error should match a view in your views/error directory. * * <code> * // Create a 404 response * return Response::error('404'); * * // Create a 404 response with data * return Response::error('404', array('message' => 'Not Found')); * </code> * * @param int $code * @param array $data * @return Response */ public static function error($code, $data = array()) { return new static(View::make('error.' . $code, $data), $code); }
/** * Create the layout that is assigned to the controller. * * @return View */ public function layout() { if (starts_with($this->layout, 'name: ')) { return View::of(substr($this->layout, 6)); } return View::make($this->layout); }
/** * Method for displaying all notifications that have been added on the previous request. * * <code> * // Add a info notification that will show for 3 seconds with a close button * echo Notification::show(); * </code> * * @author Nick <*****@*****.**> */ public static function show() { $notifications = Session::get('notifications'); if (count($notifications) > 0) { return View::make('admin::layouts.notifications')->with('notifications', $notifications); } }
/** * Verifies if view file exists * @param string $view_path String containing the view path * @return mixed The full view path if view was found, null otherwise */ private function view_exists($view_path) { $result = null; // Look for a custom path if (file_exists($path = $view_path . BLADE_EXT)) { $result = 'path: ' . $path; } if (file_exists($path = $view_path . EXT)) { $result = 'path: ' . $path; } // We still can't find this view // lets look for a bundle view // or application folder view if ($result == null) { $view_path = View::exists($view_path, true); if ($view_path) { $result = 'path: ' . $view_path; } } return $result; }
/** * Set the body of the email. * * @param string $message * @return Driver */ public function body($body) { if (strpos($body, 'view: ') === 0) { $body = substr($body, 6); $body = View::make($body, (array) $this->body); } $this->body = $body; return $this; }
public function render_admin_sub_menu_items($menuArray, $class = '', $path = null) { // the path will be used if passed in the method call // for a specific path in the themes folder if (is_array($menuArray) and !empty($menuArray)) { $theme_name = $this->_theme_name; $theme_path_relative = $this->_theme_path . DS . $theme_name; $theme_path_absolute = $this->_theme_base_path . $theme_path_relative; $theme_partials_absolute = $theme_path_absolute . DS . 'partials' . DS; // LOOK IN THE THEME FOLDERS FIRST if (file_exists($tpath = $theme_partials_absolute . 'admin_nav_sub_items' . EXT)) { return View::make("path: " . $tpath)->with('items', $menuArray)->with('class', $class)->with('theme', $this); } elseif (file_exists($tpath = $theme_partials_absolute . 'admin_nav_sub_items' . BLADE_EXT)) { return View::make("path: " . $tpath)->with('items', $menuArray)->with('class', $class)->with('theme', $this); } // IF NOT FOUND IN THE THEMES FOLDER RETURN FROM THEMES if (file_exists($tpath = \Bundle::path('themes') . 'views' . DS . 'backend' . DS . 'partials' . DS . 'admin_nav_sub_items' . EXT)) { return View::make('themes::backend.partials.admin_nav_sub_items')->with('items', $menuArray)->with('class', $class)->with('theme', $this); } elseif (file_exists($tpath = \Bundle::path('themes') . 'views' . DS . 'backend' . DS . 'partials' . DS . 'admin_nav_sub_items' . BLADE_EXT)) { return View::make('themes::backend.partials.admin_nav_sub_items')->with('items', $menuArray)->with('class', $class)->with('theme', $this); } } }
/** * Returns a string containing * all required module names * * @return string comma separated module names */ public function requirements_to_string() { $result = array(); if (!empty($this->required)) { foreach ($this->required as $key => $value) { if (!empty($value)) { foreach ($value as $k => $v) { $version = $value['version']; if ($k == 'name') { $m = static::make($v); if ($m->is_valid()) { if ($m->installed) { if ($m->enabled) { if ($this->installer->check_version($m->version, $version, '>=')) { $result[] = View::make('modules::backend.partials.module_requirements_popup')->with('module_rq', $this)->with('module', $m)->with('class', 'green')->with('message', $this->name . ' module requires ' . $m->name . ' module, and it passes all requirements.')->render(); } else { $result[] = View::make('modules::backend.partials.module_requirements_popup')->with('module_rq', $this)->with('module', $m)->with('class', 'orange')->with('message', $this->name . ' module requires ' . $m->name . ' module version ' . $version . ', and currently you have installed version ' . $m->version . '.')->render(); } } else { $result[] = View::make('modules::backend.partials.module_requirements_popup')->with('module_rq', $this)->with('module', $m)->with('class', 'orange')->with('message', $this->name . ' module requires ' . $m->name . ' module, and it must be enabled.')->render(); } } else { $result[] = View::make('modules::backend.partials.module_requirements_popup')->with('module_rq', $this)->with('module', $m)->with('class', 'orange')->with('message', $this->name . ' module requires ' . $m->name . ' module, and it must be installed.')->render(); } } else { $result[] = View::make('modules::backend.partials.module_requirements_popup')->with('module_rq', $this)->with('module_slug', $v)->with('class', 'red')->with('message', $this->name . ' module requires ' . $v . ' module, and it was not found in the modules folder.')->render(); } } } } } return '<small>Requirements: (' . implode(', ', $result) . ')</small>'; } else { return ''; } }
/** * Render the given view. * * @param string $view * @param array $data * @return Laravel\View */ protected function getView($view, $data) { return View::make($view, $data)->render(); }