Ejemplo n.º 1
0
 /**
  * @param $theme
  * @param $data
  * @return mixed
  */
 protected function renderTheme($theme, $data)
 {
     $customTemplate = 'blade-pagination/' . $theme;
     if (View::exists($customTemplate)) {
         return View::make($customTemplate, $data)->render();
     }
     return View::make('blade-pagination::' . $theme, $data)->render();
 }
Ejemplo n.º 2
0
 /**
  * Show default page.
  *
  * @param  string  $slug
  *
  * @return mixed
  */
 protected function page($slug)
 {
     $page = Content::page()->publish()->where('slug', '=', $slug)->firstOrFail();
     $slug = preg_replace('/^_page_\\//', '', $slug);
     if (!View::exists($view = "orchestra/story::pages.{$slug}")) {
         $view = 'orchestra/story::page';
     }
     return Facile::view($view)->with(['page' => $page])->render();
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 protected function getResponse($page, $id, $slug)
 {
     $slug = preg_replace('/^_post_\\//', '', $slug);
     if (!View::exists($view = "orchestra/story::posts.{$slug}")) {
         $view = 'orchestra/story::post';
     }
     $data = ['id' => $id, 'page' => $page, 'slug' => $slug];
     return Facile::view($view)->with($data)->render();
 }
Ejemplo n.º 4
0
Archivo: Feed.php Proyecto: kamyh/KBlog
 public function getView($format)
 {
     // if a custom view is set, we don't have to account for the format and assume
     // that the developer knows what he's doing
     if ($this->customView !== null && View::exists($this->customView)) {
         return $this->customView;
     }
     return $format;
 }
Ejemplo n.º 5
0
 public function page($slug = 'index')
 {
     $view = implode('/', ['pages', $slug]);
     if (!View::exists($view)) {
         abort(404);
     }
     $locale = App::getLocale();
     $pageInMarkdown = base_path("resources/pages/{$locale}/{$slug}.md");
     $pageInHtml = file_exists($pageInMarkdown) ? (new ParsedownExtra())->text(File::get($pageInMarkdown)) : '';
     return view($view, ['slug' => $slug, 'html' => $pageInHtml]);
 }
Ejemplo n.º 6
0
 /**
  * Translate view name
  *
  * @param $name
  * @param string $delimiter
  * @return string
  */
 protected function translateView($name, $delimiter = '.')
 {
     $locale = App::getLocale();
     $explodedName = (array) explode($delimiter, $name);
     $replaceable = end($explodedName);
     $replaced = preg_replace("~{$replaceable}(?!.*{$replaceable})~", "{$locale}{$delimiter}{$replaceable}", $name);
     if (View::exists($replaced)) {
         return $replaced;
     }
     return $name;
 }
 public static function getEmailBugLink(\Exception $exception, $message)
 {
     $lang = App::getLocale();
     $fallbackLang = Config::get('app.fallback_locale');
     $emergencyLang = 'en';
     $translatedMail = "pretty-error-page::mail.{$lang}";
     $fallbackMail = "pretty-error-page::mail.{$fallbackLang}";
     $emergencyMail = "pretty-error-page::mail.{$emergencyLang}";
     $mailView = View::exists($translatedMail) ? $translatedMail : (View::exists($fallbackMail) ? $fallbackMail : $emergencyMail);
     View::share('exception', $exception);
     View::share('message', $message);
     $mailBody = rawurlencode(View::make($mailView)->render());
     $mailRecipient = Config::get('pretty-error-page::recipient');
     return "mailto:{$mailRecipient}?body={$mailBody}";
 }
Ejemplo n.º 8
0
 public function render($view = '', array $data = array())
 {
     if (count($data) === 0) {
         foreach ($data as $k => $v) {
             $this->data($k, $v);
         }
     }
     if (empty($view) || !View::exists($view)) {
         $view = $this->_view;
     }
     if (View::exists($view)) {
         return View::make($view, $this->viewData)->with('messages', $this->getMessageBag());
     }
     return View::make('noexist', array('message' => 'View <strong>' . $view . '</strong> doesn\'t exist'));
 }
Ejemplo n.º 9
0
 /**
  * Global method to send an email using the provided data
  *
  * @param array $data
  * @param array $mailingList
  * @param string $baseUrl
  * @param string $htmlTemplate
  * @param string $textTemplate
  * @return bool
  */
 protected function sendMail(array $data, array $mailingList, $baseUrl, $htmlTemplate, $textTemplate)
 {
     if (View::exists($htmlTemplate) && View::exists($textTemplate)) {
         $mailFrom = $this->mailFrom;
         Mail::send(array('html' => $htmlTemplate, 'text' => $textTemplate), $data, function ($message) use($mailingList, $baseUrl, $mailFrom) {
             $message->from($mailFrom);
             $message->subject('Error while using ' . $baseUrl);
             foreach ($mailingList as $emailAddress) {
                 $message->to($emailAddress);
             }
         });
         return true;
     }
     return false;
 }
 /**
  * Returns the matching static view for the request (if the file
  * exists), otherwise returns the 404 response.
  *
  * TODO: Review the security of matchStaticView() function. Does
  * the Laravel framework already filter the "Request::path()" or
  * "View::make()" methods, or do we need to filter out possible
  * directory traversal attacks from the "requestPath" variable?
  *
  * @param  array $parameters Optional parameters for the View
  * @param  string $view Render the content with the specific view template
  * @return View
  */
 private function matchStaticView($parameters = array(), $view = null)
 {
     $basePath = rtrim(base_path(), "/");
     $requestPath = rtrim(mb_strtolower(Request::path()), "/");
     $fullStaticViewPath = "{$basePath}/resources/views/pages/{$requestPath}";
     $staticViewFilename = "pages/{$requestPath}";
     if (is_dir($fullStaticViewPath)) {
         $staticViewFilename .= "/index";
     }
     if (View::exists($staticViewFilename)) {
         return View::make($staticViewFilename, $parameters);
     }
     if (isset($view) && View::exists($view)) {
         return View::make($view, $parameters);
     }
     # Otherwise return the 404 response
     return App::abort(404);
 }
Ejemplo n.º 11
0
 public function preview($entity, $id)
 {
     $modelString = 'Yab\\Quarx\\Models\\' . ucfirst($entity);
     if (!class_exists($modelString)) {
         $modelString = 'Yab\\Quarx\\Models\\' . ucfirst($entity) . 's';
     }
     $model = new $modelString();
     $modelInstance = $model->find($id);
     $data = [$entity => $modelInstance];
     $view = 'quarx-frontend::' . $entity . '.show';
     if (!View::exists($view)) {
         $view = 'quarx-frontend::' . $entity . 's.show';
     }
     if ($entity === 'page') {
         $view = 'quarx-frontend::pages.' . $modelInstance->template;
     }
     return view($view, $data);
 }
Ejemplo n.º 12
0
 /**
  * Get view name
  * Defaults to the package views unless a custom view is set
  *
  * @param string $format
  *
  * @return void
  */
 public function getView($format)
 {
     // if a custom view is set, we don't have to account for the format and assume
     // that the developer knows what he's doing
     if ($this->customView !== null && View::exists($this->customView)) {
         return $this->customView;
     }
     $packagePrefix = 'feed::';
     // for package's default views, we send the view name with appropriate format
     return $packagePrefix . $format;
 }
Ejemplo n.º 13
0
 /**
  * Get view name
  *
  * @param string $format
  *
  * @return void
  */
 public function getView($format)
 {
     // if a custom view is set
     if ($this->customView !== null && View::exists($this->customView)) {
         return $this->customView;
     }
     // else return default view
     return 'feed::' . $format;
 }
Ejemplo n.º 14
0
 public function getEmbedHtml($height = null, $width = null)
 {
     $viewPrefix = 'boomcms::assets.embed.';
     $assetType = strtolower(class_basename($this->getType()));
     $viewName = View::exists($viewPrefix . $assetType) ? $viewPrefix . $assetType : $viewPrefix . 'default';
     return View::make($viewName, ['asset' => $this, 'height' => $height, 'width' => $width]);
 }
Ejemplo n.º 15
0
 /**
  * @return bool
  */
 public function fileExists()
 {
     return View::exists($this->getFullFilename());
 }
 /**
  * Get the correct error view.
  *
  * @description
  * If a specific view (eg. 404) exists it will be used. If not it will look
  * for a generic error view (eg. 4xx). If both are not available a fallback
  * will be used.
  *
  * @param int|string $code
  * @param string     $fallbackView
  *
  * @return string
  */
 private function getErrorView($code, $fallbackView = 'pretty-error-page::pages.any')
 {
     $fallbackCode = substr("{$code}", 0, 1) . "xx";
     if (View::exists("pretty-error-page::pages.{$code}")) {
         return "pretty-error-page::pages.{$code}";
     } else {
         if (View::exists("pretty-error-page::pages.{$fallbackCode}")) {
             return "pretty-error-page::pages.{$fallbackCode}";
         }
     }
     return $fallbackView;
 }
 private function viewOrRedirect($view)
 {
     return View::exists($view) ? view($view) : Redirect::to($view);
 }
Ejemplo n.º 18
0
 public function getView()
 {
     if (!($URI = Input::get('URI'))) {
         return Redirect::back()->with('flashError', 'No URI given');
     }
     if ($entity = $this->repository->find($URI)) {
         $documentType_view = 'media.view.' . $entity->format . '.pages.' . $entity->documentType;
         if (View::exists($documentType_view)) {
             return View::make($documentType_view, compact('entity'));
         }
         return View::make('media/view/text/pages/entity', compact('entity'));
     }
     return Redirect::to('media/browse')->with('flashError', "No document found at given URI: {$URI}");
 }
Ejemplo n.º 19
0
 public function hasHttpExceptionView($statusCode)
 {
     return View::exists($this->httpExceptionViewName($statusCode));
 }