Ejemplo n.º 1
0
 /**
  * Plant a new bonsai collection!
  *
  * @param  string  $namespace
  * @param  string  $path
  * @return null
  */
 public function plant($callback = null)
 {
     $assets = new Assets();
     if (is_callable($callback)) {
         call_user_func($callback, $assets);
     }
     $this->collection->put('bonsai', $assets);
     $this->view->share('bonsai', $assets);
     return $assets;
 }
Ejemplo n.º 2
0
Archivo: Menu.php Proyecto: tok3/menus
 /**
  * Create a new menu instance.
  *
  * @param  string    $name
  * @param  callable  $callback
  * @return \Caffeinated\Menus\Builder
  */
 public function make($name, $callback)
 {
     if (is_callable($callback)) {
         $menu = new Builder($name, $this->loadConfig($name), $this->html, $this->url);
         call_user_func($callback, $menu);
         $this->collection->put($name, $menu);
         $this->view->share('menu_' . $name, $menu);
         return $menu;
     }
 }
Ejemplo n.º 3
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $this->app->setLocale($this->settings->get('user.language', 'en'));
     $langDir = ['left' => 'left', 'right' => 'right'];
     if (trans('general.direction') == 'rtl') {
         $langDir['left'] = 'right';
         $langDir['right'] = 'left';
     }
     $this->viewFactory->share('langDir', $langDir);
     return $next($request);
 }
Ejemplo n.º 4
0
 /**
  * Create a new menu instance.
  *
  * @param string   $name
  * @param callable $callback
  *
  * @return \Kiwina\Menu\Menu
  */
 public function make($name, $callback)
 {
     if (is_callable($callback)) {
         $menu = new Builder($name, $this->loadConf($name), $this->html, $this->url);
         // Registering the items
         call_user_func($callback, $menu);
         // Storing each menu instance in the collection
         $this->collection->put($name, $menu);
         // Make the instance available in all views
         $this->view->share($name, $menu);
         return $menu;
     }
 }
Ejemplo n.º 5
0
 /**
  * Bootstrap the application services
  *
  * @param ViewFactory $viewFactory
  */
 public function boot(ViewFactory $viewFactory)
 {
     if (is_dir(base_path() . '/resources/views/viktorv/lpanel')) {
         $this->loadViewsFrom(base_path() . '/resources/views/viktorv/lpanel', 'lpanel');
     } else {
         $path = realpath(__DIR__ . '/../resources/views');
         /** @var \League\Plates\Engine $platesEngine */
         $platesEngine = $this->app->make('League\\Plates\\Engine');
         $platesEngine->setDirectory($path);
         $platesEngine->addFolder('layout', $path . '/admin/layout');
         $platesEngine->addFolder('noscript', $path . '/noscript');
         $this->loadViewsFrom($path, 'lpanel');
     }
     /** @var \Illuminate\Validation\Factory $validator */
     $validator = $this->app->validator;
     $validator->resolver(function ($translator, $data, $rules, $messages) {
         return new Validator($translator, $data, $rules, $messages);
     });
     $viewFactory->share('block', new BaseBlock($this->app));
     if (is_dir(base_path() . '/resources/lang/viktorv/lpanel')) {
         $this->loadTranslationsFrom(base_path() . '/resources/lang/viktorv/lpanel', 'lpanel');
     } else {
         $this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'lpanel');
     }
 }
Ejemplo n.º 6
0
 private function shareTitle()
 {
     $langKey = "titles.{$this->router->currentRouteName()}";
     if ($this->lang->has($langKey)) {
         $this->view->share('title', $this->lang->get($langKey));
     }
 }
Ejemplo n.º 7
0
 /**
  * Add a piece of shared data to the factory.
  *
  * @param  string  $key
  * @param  mixed   $value
  * @return void
  */
 public function share($key, $value = null)
 {
     if (!is_array($key)) {
         return parent::share($key, $this->decorate($value));
     }
     return parent::share($this->decorate($key));
 }
Ejemplo n.º 8
0
 public function register(Container $pimple)
 {
     $pimple['files'] = function () {
         return new Filesystem();
     };
     $pimple['view.engine.resolver'] = function () use($pimple) {
         $resolver = new EngineResolver();
         foreach (['php', 'blade'] as $engine) {
             $this->{'register' . ucfirst($engine) . 'Engine'}($resolver, $pimple);
         }
         return $resolver;
     };
     $pimple['view.finder'] = function () use($pimple) {
         $paths = $pimple['config']['view.paths'];
         return new FileViewFinder($pimple['files'], $paths);
     };
     $pimple['view'] = function () use($pimple) {
         // Next we need to grab the engine resolver instance that will be used by the
         // environment. The resolver will be used by an environment to get each of
         // the various engine implementations such as plain PHP or Blade engine.
         $resolver = $pimple['view.engine.resolver'];
         $finder = $pimple['view.finder'];
         $env = new Factory($resolver, $finder, $pimple['events']);
         // We will also set the container instance on this view environment since the
         // view composers may be classes registered in the container, which allows
         // for great testable, flexible composers for the application developer.
         $env->setContainer($pimple['container']);
         $env->share('app', $pimple);
         return $env;
     };
 }
Ejemplo n.º 9
0
 public function __construct(Store $session, Factory $view)
 {
     $this->session = $session;
     $view->share('flash', $this);
     if ($this->session->has($this->namespace)) {
         $flashed = $this->session->get($this->namespace);
         $this->message = $flashed['message'];
         $this->title = $flashed['title'];
         $this->type = $flashed['type'];
         $this->exists = true;
     }
 }
Ejemplo n.º 10
0
 private function loadMocks(View $view)
 {
     $events = [1 => ['/img/event-sample1.jpg', 'iMasters Developer Week RJ', 'Rio de Janeiro, Brazil'], 2 => ['/img/event-sample2.jpg', 'PHP\'n Rio 2011', 'Rio de Janeiro, Brazil'], 3 => ['/img/event-sample3.jpg', 'PHPConf 2015', 'Osasco, Brazil'], 4 => ['/img/event-sample4.jpg', 'TDCOnline 2015 POA', 'Porto Alegre, Brazil'], 5 => ['/img/event-sample5.jpg', 'O\'Reilly\'s Fluent', 'San Francisco, USA'], 6 => ['/img/event-sample6.gif', 'UERJ Sem Muros', 'Rio de Janeiro, Brazil'], 7 => ['/img/event-sample7.jpg', '53º Congresso HUPE', 'Rio de Janeiro, Brazil'], 8 => ['/img/event-sample8.png', 'XXVI Congresso Brasileiro de Virologia', 'Florianópolis, Brazil']];
     foreach ($events as $i => &$event) {
         $event[] = time();
         $event[] = $i % 2 ? time() + 60 * 60 * 24 * 3 : null;
         $event[] = 'Fusce pellentesque velvitae tincidunt egestas. Pellentesque habitant morbi. Proin gravida nibh vel velit auctor aliquet. Aenean sollicitudin, lorem quis.
         Bibendum auctor, nisi elit consequat ipsum, nec sagittis sem nibh id elit. Duis sed odio sit amet nibh vulputate cursus a sit amet mauris.';
         $event[] = (bool) rand(0, 1);
         $event[] = 'http://www.google.com.br';
         $event[] = 'konato';
         $event[] = 'konato2015';
     }
     $types = [_('Congresses'), _('Meetings'), _('Talks & discussions'), _('University meetings'), _('Cultural')];
     $selected_types = array_rand($types, 2);
     $themes = explode(' ', 'PHP Databases MySQL Webdesign APIs');
     $selected_themes = array_rand($themes, 2);
     $speakers = [['/img/speaker-sample1.jpg', 'Fabio Akita', 'São Paulo, Brazil', ['Ruby', 'Agile', 'Speaking']], ['/img/speaker-sample2.jpg', 'Raphael de Almeida', 'Rio de Janeiro, Brazil', ['PHP', 'Microsserviços', 'Ruby']], ['/img/speaker-sample3.jpg', 'Valéria Parajara', 'Rio de Janeiro, Brazil', ['Ruby', 'Gastronomia']], ['/img/speaker-sample4.jpg', 'Pedro Couteiro', 'Tsukuba, Japan', ['CG', 'Java', 'Japanese']], ['/img/speaker-sample5.jpg', 'Luan Rodrigues', 'Rio de Janeiro, Brazil', ['Computação médica', 'Cirurgia plástica']], ['/img/speaker-sample6.jpg', 'Igor Santos', 'Halifax, Canada', ['Web Services', 'PHP']]];
     foreach ($speakers as $i => &$speaker) {
         $speaker[] = rand(5, 15);
         $speaker[] = rand(15, 50);
         $speaker[] = 'Fusce pellentesque velvitae tincidunt egestas. Pellentesque habitant morbi.';
         $speaker[] = ['M', 'M', 'F', 'M', 'M', 'M'][$i];
     }
     $materials = [['http://www.google.com', 'How to be Agile in Project Management', 'doc', $speakers[1]], ['http://pt.slideshare.net/igorsantos07/rest-fuuuu-54458320', 'The RESTful Police', 'slide', $speakers[5]], ['http://www.google.com', 'Immobilized lipase reutilization on biodiesel syntesis from soy oil', 'doc', $speakers[3]], ['http://www.google.com', 'How to launch a culinary business having an IT background', 'video', $speakers[2]]];
     shuffle($events);
     shuffle($speakers);
     $view->share('events', $events);
     //        $view->share('types', $types);
     $view->share('selected_types', $selected_types);
     $view->share('themes', $themes);
     $view->share('selected_themes', $selected_themes);
     $view->share('speakers', $speakers);
     $view->share('materials', $materials);
 }
 protected function makeView()
 {
     $app = new Container();
     $resolver = new EngineResolver();
     $resolver->register('php', function () {
         return new PhpEngine();
     });
     $finder = new FileViewFinder(new Filesystem(), [realpath(__DIR__)]);
     $dispatcher = (new Dispatcher($app))->setQueueResolver(function () use($app) {
         return $app->make('Illuminate\\Contracts\\Queue\\Factory');
     });
     $env = new Factory($resolver, $finder, $dispatcher);
     $env->setContainer($app);
     $env->share('app', $app);
     return new Illuminate($env);
 }
 /**
  * Register the view environment.
  *
  * @return void
  */
 public function registerFactory()
 {
     $this->app->singleton('view', function ($app) {
         // Next we need to grab the engine resolver instance that will be used by the
         // environment. The resolver will be used by an environment to get each of
         // the various engine implementations such as plain PHP or Blade engine.
         $resolver = $app['view.engine.resolver'];
         $finder = $app['view.finder'];
         $env = new Factory($resolver, $finder, $app['events']);
         // We will also set the container instance on this view environment since the
         // view composers may be classes registered in the container, which allows
         // for great testable, flexible composers for the application developer.
         $env->setContainer($app);
         $env->share('app', $app);
         return $env;
     });
 }
Ejemplo n.º 13
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // Share the authenticated user to make sure we have a decorated version of it
     $this->viewFactory->share('auth_user', $this->guard->user());
     return $next($request);
 }
Ejemplo n.º 14
0
 /**
  * Get the string contents of the view.
  *
  * @param Request $request
  * @return string
  */
 public function render(Request $request)
 {
     $forum = $this->getForumDocument($request);
     $this->view->share('translator', $this->locales->getTranslator());
     $this->view->share('allowJs', !array_get($request->getQueryParams(), 'nojs'));
     $this->view->share('forum', array_get($forum, 'data'));
     $this->view->share('debug', array_get($forum, 'data.attributes.debug'));
     $view = $this->view->file(__DIR__ . '/../../../views/app.blade.php');
     $view->title = $this->buildTitle(array_get($forum, 'data.attributes.title'));
     $view->description = $this->description;
     $view->modules = $this->modules;
     $view->payload = $this->buildPayload($request, $forum);
     $view->layout = $this->buildLayout();
     $baseUrl = array_get($forum, 'data.attributes.baseUrl');
     $view->cssUrls = $this->buildCssUrls($baseUrl);
     $view->jsUrls = $this->buildJsUrls($baseUrl);
     $view->head = implode("\n", $this->head);
     $view->foot = implode("\n", $this->foot);
     return $view->render();
 }
Ejemplo n.º 15
0
 /**
  * Shares the required data for the reCAPTCHA
  *
  * @return void
  */
 public function shareDataToViews()
 {
     $this->view->share('captcha_validation_url', $this->mockably->route('larapress.api.captcha.validate.post'));
 }
Ejemplo n.º 16
0
 /**
  * Assign data across all views.
  *
  * @param  mixed $key
  * @param  mixed $value
  * @return mixed
  */
 public function share($key, $value)
 {
     return $this->view->share($key, $value);
 }
Ejemplo n.º 17
0
 /**
  * Sets the page title (Shares the title variable for the view)
  *
  * @param string $page_name The page name
  * @return void
  */
 public function setPageTitle($page_name)
 {
     $title = $this->config->get('larapress.names.cms') . ' | ' . $this->lang->get('larapress::general.' . $page_name);
     $this->view->share('title', $title);
 }
Ejemplo n.º 18
0
 /**
  * Add a piece of shared data to the environment.
  *
  * @param array|string $key
  * @param mixed $value
  * @return mixed 
  * @static 
  */
 public static function share($key, $value = null)
 {
     return \Illuminate\View\Factory::share($key, $value);
 }
Ejemplo n.º 19
0
 /**
  * Register the view factory. The factory is
  * available in all views.
  */
 protected function registerViewFactory()
 {
     // Register the View Finder first.
     $this->app->singleton('view.finder', function ($container) {
         return new ViewFinder($container['filesystem'], [], ['blade.php', 'scout.php', 'twig', 'php']);
     });
     $this->app->singleton('view', function ($container) {
         $factory = new Factory($container['view.engine.resolver'], $container['view.finder'], $container['events']);
         // Set the container.
         $factory->setContainer($container);
         // Tell the factory to also handle the scout template for backwards compatibility.
         $factory->addExtension('scout.php', 'blade');
         // Tell the factory to handle twig extension files and assign them to the twig engine.
         $factory->addExtension('twig', 'twig');
         // We will also set the container instance on this view environment since the
         // view composers may be classes registered in the container, which allows
         // for great testable, flexible composers for the application developer.
         $factory->setContainer($container);
         $factory->share('app', $container);
         return $factory;
     });
 }