public function deletePage($id) { $page = HandbookPage::find($id); if ($page) { $url = HandbookPage::getURLReadyLink($page->title); $page->delete(); return Redirect::to("/handbook/{$url}"); } else { return 'No page found.'; } }
public function body() { $body = $this->body; $body = preg_replace_callback("/\\[\\[([\\w\\W]+?)\\]\\]/", function ($match) { $parts = explode("/", $match[1]); if (sizeof($parts) > 1) { //This is a command switch (strtolower($parts[0])) { case "redirect": $source_page = HandbookPage::where('title', $parts[1])->first(); if ($source_page) { if (Input::get('redirect') == "no") { return 'This page redirects to <a href="/handbook/' . HandbookPage::getURLReadyLink($parts[1]) . '">' . $source_page->title . '</a>.'; } else { return 'Redirecting...'; } } else { return 'This page has an invalid redirect.'; } } } //Look for the relevant page $name = $match[1]; if (strrpos($name, '{')) { $parts = explode('{', $name); $name = $parts[0]; $link = str_replace('}', '', $parts[1]); } else { $link = $name; } $page = HandbookPage::where('title', $link)->exists(); $rawLink = HandbookPage::getURLReadyLink($link); return "<a class='page-link " . (!$page ? 'invalid' : '') . "' href='/handbook/" . $rawLink . "'>{$name}</a>"; }, $body); return $body; }
<?php $user = Auth::user(); $st = $user->isStoryteller(); $query = $st ? HandbookPage::orderBy('created_at', 'DESC') : HandbookPage::where('created_by', $user->id); $pagination = $query->paginate(15); ?> @extends('layout') @section('title', 'Handbook Directory') @section('includes') <style type="text/css"> .handbook-pagination { float: right; margin-top: -40px; } .handbook-page { padding: 10px 10px; border: 1px solid #c0c0c0; border-radius: 3px; margin-bottom: 10px; } .handbook-title { font-size: 1.3em; } .handbook-preview { overflow: hidden; font-size: 0.9em;
<?php $page = HandbookPage::getByTitle($title); $user = Auth::user(); ?> <div class="row"> <div class="small-12 columns"> @if($page && !$page->userCanRead($user)) <h1>This Handbook Page is Hidden</h1> <p>You do not have permission to view this page.</p> @else <h1 class="handbook-title">@if($page && $page->read_permission && $page->readPermission->hasRestrictions()) <i class="handbook-lock icon-lock" data-tooltip title="Restricted to {{$page->readPermissionList()}}"></i> @endif {{$page ? $page->title : "Page not found"}}</h1> @if(Session::get('redirect')) <div class="redirect">(Redirected from <a href="/handbook/{{HandbookPage::getURLReadyLink(Session::get('redirect'))}}?redirect=no">{{Session::get('redirect')}}</a>)</div> @endif @if($user) <ul class="button-group handbook-edit-options"> @if(isset($showNewPage)) <li><a class="button small new-page" href="/handbook/directory">{{Auth::user()->isStoryteller() ? "Directory" : "My Pages"}}</a></li> <li><a class="button small new-page" href="/handbook/create">New Page</a></li> @endif @if($page && $page->userCanWrite($user))<li><a class="button small edit-page" href="/handbook/{{$title}}/edit">Edit Page</a></li>@endif </ul> @endif @if($page) {{$page->body()}} <div class="handbook-stats">
<?php if (!isset($name)) { $name = 'Home'; } $name = str_replace("_", " ", $name); $page = HandbookPage::where('title', 'LIKE', $name)->first(); ?> @extends('layout') @section('title', $page ? $page->title : 'New Page') @section('content') <div class="handbook-content theme-wrapper"> {{View::make('partials/handbookPage', ['title' => $name, 'showNewPage' => true])->render()}} </div> @stop