Пример #1
0
 /**
  * @param Content $content
  * @return mixed
  */
 public function update(Content $content)
 {
     // Store the content from the configuration form
     $content->params = Input::all();
     $content->save();
     // Redirect to the page where the content is placed on.
     return Redirect::to(Session::get('referer') . '?mode=content');
 }
Пример #2
0
 /**
  * @param Content $content
  * @return View|null
  */
 public function renderContent(Content $content)
 {
     $isContentMode = Session::get('mode') == 'content';
     $isModePublic = $content->section->isPublic();
     $hasConfigForm = $content->hasConfigForm();
     try {
         $controller = $content->getController();
         $response = $this->renderController($controller, $content->params);
         if (!$response) {
             return;
         }
     } catch (\RuntimeException $e) {
         $response = '--- Block not configured properly: missing required fields ---';
     }
     Event::fire('content.dispatch.renderContent', array($response, $content));
     return View::make('content::block', compact('response', 'content', 'isContentMode', 'isModePublic', 'hasConfigForm'));
 }
 /**
  * Register the listeners for the subscriber.
  *
  * @param Events $events
  */
 public function subscribe(Events $events)
 {
     Content::creating(function ($content) {
         $position = DB::table($content->getTable())->whereSectionId($content->section_id)->wherePageId($content->page_id)->count();
         $content->position = $position;
     });
     Content::updated(function ($content) {
         DB::table($content->getTable())->where('position', '>=', $content->position)->where('id', '!=', $content->id)->increment('position', 1);
     });
 }
 /**
  * @param Page $page
  */
 public function onCreateResourcePage(Page $page)
 {
     // Check if there already is content attached to this page.
     // If so, then we don't have to add new content.
     if (Content::wherePageId($page->id)->first()) {
         return;
     }
     $block = Block::whereController($page->controller)->first();
     $section = Section::whereName('content')->first();
     $content = new Content();
     $content->page()->associate($page);
     $content->section()->associate($section);
     if ($block) {
         $content->block()->associate($block);
     } else {
         $content->controller = $page->controller;
     }
     $content->save();
 }
Пример #5
0
 /**
  * @param Page $page
  */
 public function onCreateWithContent(Page $page)
 {
     // If the page doesn't have a controller, then we can do nothing
     if (!$page->controller || !$page->layout) {
         return;
     }
     // Check if there already is content attached to this page.
     // If so, then we don't have to add new content.
     if (Content::wherePageId($page->id)->first()) {
         return;
     }
     // Get the main content section
     $section = Section::whereName('content')->first();
     // Create the new content
     $content = new Content();
     $content->page()->associate($page);
     $content->section()->associate($section);
     $content->controller = $page->controller;
     $content->save();
 }