text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_suffix|>ceof ZipExportPage) { $pageExportModel = $exportModel; } // Add the image to the export if it's accessible or just return the existing reference if already added if (isset($this->images[$model->id]) || ($pageExportModel && $this->imageService->imageAcce...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Exports\ZipExports; use BookStack\Exceptions\ZipExportException; use BookStack\Exports\ZipExports\Models\ZipExportBook; use BookStack\Exports\ZipExports\Models\ZipExportChapter; use BookStack\Exports\ZipExports\Models\ZipExportPage; class ZipExportValidator { public functi...
fim
BookStackApp/BookStack
php
<|fim_suffix|> $fail('validation.zip_file_size')->translate([ 'attribute' => $value, 'size' => config('app.upload_limit'), ]); } if (!empty($this->acceptedMimes)) { $fileMime = $this->context->zipReader->sniffFileMime($value); i...
fim
BookStackApp/BookStack
php
<|fim_suffix|>]; }, $content); return $result ?: $content; } public function replaceReferences(): void { foreach ($this->books as $book) { $exportBook = $this->zipExportBookMap[$book->id]; $content = $exportBook->description_html ?? ''; $parsed =...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Exports\ZipExports; use BookStack\Entities\Models\Book; use BookStack\Entities\Models\Chapter; use BookStack\Entities\Models\Entity; use BookStack\Entities\Models\Page; use BookStack\Entities\Repos\BookRepo; use BookStack\Entities\Repos\ChapterRepo; use BookStack\Entities\Repos...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Exports\ZipExports; use BookStack\App\Model; use BookStack\Entities\Queries\EntityQueries; use BookStack\References\ModelResolvers\AttachmentModelResolver; use BookStack\References\ModelResolvers\BookLinkModelResolver; use BookStack\References\ModelResolvers\ChapterLinkModelRes...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Exports\ZipExports; use Closure; use Illuminate\Contracts\Validation\ValidationRule; class ZipUniqueIdRule implements ValidationRule { public function __construct( protected ZipValidationHelper $context, protected string $modelType, ) { } /<|f...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Exports\ZipExports; use BookStack\Exports\ZipExports\Models\ZipExportModel; use Illuminate\Validation\Factory; class ZipValidationHelper { protected Factory $validationFactory; /** * Local store of validated IDs (in format "<type>:<id>". Example: "book:2") *...
fim
BookStackApp/BookStack
php
<|fim_suffix|>@mixin \BookStack\Activity\Tools\ActivityLogger */ class Activity extends Facade { /** * Get the registered name of the component. * * @return string */ protected static function getFacadeAccessor() { return 'activity'; } } <|fim_prefix|><?php n<|fim_middle|>a...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Facades; use BookStack\Theming\ThemeService; use Illuminate\Support\Facades\Facade; class Th<|fim_suffix|> * * @return string */ protected static function getFacadeAccessor() { return ThemeService::class; } } <|fim_middle|>eme extends Facade { ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>property but can be a rules() method. */ public function getValidationRules(): array { return $this->rules(); } /** * Get the validation rules for the actions in this controller. * Defaults to a $rules property but can be a rules() method. */ protected func...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Http; use BookStack\Activity\Models\Loggable; use BookStack\App\Model; use BookStack\Exceptions\NotifyException; use BookStack\Facades\Activity; use BookStack\Permissions\Permission; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Validation\ValidatesReq...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Http; use Illuminate\Http\Request; use Illuminate\Http\Response; use Symfony\Component\HttpFoundation\StreamedResponse; class DownloadResponseFactory { public function __construct( protected Request $request, ) { } /** * Create a response that dir...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Http; use GuzzleHttp\Psr7\Request as GuzzleRequest; class HttpClientHistory { public function __construct( protected &$container ) { } public fu<|fim_suffix|>ic function all(): array { return $this->container; } } <|fim_middle|>nction r...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Http; use GuzzleHttp\Client; use GuzzleHttp\Handler\MockHandler; use GuzzleHttp\HandlerStack; use GuzzleHttp\Middleware; use GuzzleHttp\Psr7\Request as GuzzleRequest; use GuzzleHttp\Psr7\Response; use Psr\Http\Client\ClientInterface; class HttpRequestService { protected ?H...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Http; use Illuminate\Foundation\Http\Kernel as HttpKernel; class Kernel extends HttpKernel { /** * The application's global HTTP middleware stack. * These middleware are run during every request to your application. * * @var list<class-string> */ ...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Http\Middleware; use BookStack\Exceptions\ApiAuthException; use BookStack\Permissions\Permission; use Closure; use Illuminate\Http\Request; class ApiAuthenticate { /** * Handle an incoming request. *<|fim_suffix|> } // Only allow GET request...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Http\Middleware; use BookStack\Util\CspService; use Closure; use Illuminate\Http\Request; class ApplyCspRules { protected CspService $cspService; public function __constr<|fim_suffix|>spHeader = $this->cspService->getCspHeader(); $response->headers->set('Conte...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Http\Middleware; use Closure; use Illuminate\Http\Request; class Authenticate { /** * Handle an incoming requ<|fim_suffix|>ction handle(Request $request, Closure $next) { if (!user()->hasAppAccess()) { if ($request->ajax()) { re...
fim
BookStackApp/BookStack
php
<|fim_suffix|> protected $mfaSession; public function __construct(LoginService $loginService, MfaSession $mfaSession) { $this->loginService = $loginService; $this->mfaSession = $mfaSession; } /** * Handle an incoming request. * * @param \Illuminate\Http\Request $requ...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Http\Middleware; use BookStack\Access\EmailConfirmationService; use BookStack\Users\Models\User; use Closure; /** * Check that the user's email address is confirmed. * * As of v21.08 this is technically not required but kept as a prevention * to log out any users that may be logged in b...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Http\Middleware; use Closure; class CheckGuard { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string <|fim_suffix|>ethod'); if (!in_array($activeG...
fim
BookStackApp/BookStack
php
<|fim_suffix|> <|fim_prefix|><?php namespace BookStack\Http\Middleware; use BookStack\Permissions\Permission; use Closure; use Illuminate\Http\Request; class CheckUserHasPermission { /** * Handle an incoming request. * * @return mixed */ public function handle(Request $request, Closure $n...
fim
BookStackApp/BookStack
php
<|fim_suffix|>f the cookies that should not be encrypted. * * @var array<int, string> */ protected $except = [ // ]; } <|fim_prefix|><?php nam<|fim_middle|>espace BookStack\Http\Middleware; use Illuminate\Cookie\Middleware\EncryptCookies as Middleware; class EncryptCookies extends Midd...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Http\Middleware; use BookStack\Translation\LocaleManager; use Closure; class Localization { public function __construct( protected LocaleManager $localeManager ) { } /** * Handle an incomin<|fim_suffix|> app()->setLocale($userLocale->appLo...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Http\Middleware; use Illuminate\Foundation\Http\Middleware\PreventReq<|fim_suffix|> array<int, string> */ protected $except = [ // ]; } <|fim_middle|>uestsDuringMaintenance as Middleware; class PreventRequestsDuringMaintenance extends Middleware { /** ...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Http\Middleware; use Closure; use Symfony\Component\HttpFoundation\Response; class PreventResponseCaching { /** * Paths to ignore when preventing response caching. */ protected array $ignoredPathPrefixes = [ 'theme/', ]; /** * Handle an ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>* @param Closure(Request): (Response) $next */ public function handle(Request $request, Closure $next, string ...$guards): Response { $guards = empty($guards) ? [null] : $guards; foreach ($guards as $guard) { if (Auth::guard($guard)->check()) { ret...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Http\Middleware; use BookStack\Facades\Theme; use BookStack\Theming\ThemeEvents; use Closure; class RunThemeActions { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @r...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Http\Middle<|fim_suffix|>/images/', 'dist/', 'manifest.json', 'opensearch.xml', ]; /** * @inheritdoc */ protected function storeCurrentUrl(Request $request, $session): void { $requestPath = strtolower($request->path()); ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>dleware\StartSession as Middleware; class StartSessionIfCookieExists extends Middleware { /** * Handle an incoming request. */ public function handle($request, Closure $next) { $sessionCookieName = config('session.cookie'); if ($request->cookies->has($sessionCookieNa...
fim
BookStackApp/BookStack
php
<|fim_suffix|> { return (int) config('api.requests_per_minute'); } } <|fim_prefix|><?php namespace Book<|fim_middle|>Stack\Http\Middleware; use Illuminate\Routing\Middleware\ThrottleRequests as Middleware; class ThrottleApiRequests extends Middleware { /** * Resolve the number of attempts if...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace Boo<|fim_suffix|>ack\Http\Middleware; use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware; class TrimStrings extends Middleware { /** * The names of the attributes that should not be trimmed. * * @var array<int, string> */ protected $except = ...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Http\Middleware; use Illuminate\Http\Middleware\<|fim_suffix|> } } <|fim_middle|>TrustHosts as Middleware; class TrustHosts extends Middleware { /** * Get the host patterns that should be trusted. * * @return array<int, string|null> */ public functi...
fim
BookStackApp/BookStack
php
<|fim_suffix|>etect proxies. * * @var int */ protected $headers = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO | Request::HEADER_X_FORWARDED_AWS_ELB; /** * Handle the request, Set the correct user-c...
fim
BookStackApp/BookStack
php
<|fim_suffix|> @var bool */ protected $addHttpCookie = true; /** * The URIs that should be excluded from CSRF verification. * * @var array<int, string> */ protected $except = [ 'saml2/*', ]; } <|fim_prefix|><?php namespace BookStack\Http\Middleware; use Illuminate\Fou...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Http; use BookStack\Util\WebSafeMimeSniffer; use Illuminate\Http\Request; /** * Helper wrapper for range-based stream response handling. * Much of this used symfony/http-foundation as a reference during build. * URL: https://github.co<|fim_suffix|> !str_starts_with($range, ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>lic function getBaseUrl(): string { $appUrl = config('app.url', null); if ($appUrl) { $parsedBaseUrl = rtrim(implode('/', array_slice(explode('/', $appUrl), 3)), '/'); return empty($parsedBaseUrl) ? '' : ('/' . $parsedBaseUrl); } return parent...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Permissions; use BookStack\Entities\EntityProvider; use BookStack\Entities\Models\Entity; use BookStack\Entities\Tools\PermissionsUpdater; use BookStack\Http\ApiController; use Illuminate\Http\Request; class ContentPermissionApiController extends ApiController { public fun...
fim
BookStackApp/BookStack
php
<|fim_suffix|>) use ($filterRoleIds) { $query->whereIn('role_id', [...$filterRoleIds, 0]); }); } return $query->get(['entity_id', 'entity_type', 'role_id', $this->action])->all(); } /** * @return string[] */ protected function gatherEntityChainTypeIds(...
fim
BookStackApp/BookStack
php
<|fim_suffix|>$books) use ($roles) { $this->buildJointPermissionsForBooks($books, $roles); }); // Chunk through all bookshelves $this->queries->shelves->start()->withTrashed()->select(['id', 'owned_by']) ->chunk(50, function (EloquentCollection $shelves) use ($roles) { ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>Cache; } } <|fim_prefix|><?php namespace BookStack\Permissions; use BookStack\Permissions\Models\EntityPermission; class MassEntityPermissionEvaluator extends EntityPermissionEvaluator { /** * @var SimpleEntityData[] */ protected array $entitiesInvolved; protected array $permi...
fim
BookStackApp/BookStack
php
<|fim_suffix|> 'create', 'update', 'delete']; public $timestamps = false; protected $hidden = ['entity_id', 'entity_type', 'id']; protected $casts = [ 'view' => 'boolean', 'create' => 'boolean', 'read' => 'boolean', 'update' => 'boolean', 'delete' => 'boolean', ];...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Permissions\Models; use BookStack\App\Model; use BookStack\Entities\Models\Entity; use BookStack\Users\Models\Role; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\MorphOne; class JointPermission extends Model { protected $primaryKey = nu...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Permissions\Models; use BookStack\App\Model; use BookStac<|fim_suffix|>Many(Role::class, 'permission_role', 'permission_id', 'role_id'); } /** * Get the permission object by name. */ public static function getByName(string $name): ?RolePermission { ...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Permissions; /** * Enum to represent the permissions which may be used in checks. * The<|fim_suffix|>se BookshelfUpdateOwn = 'bookshelf-update-own'; case BookshelfView = 'bookshelf-view'; case BookshelfViewAll = 'bookshelf-view-all'; case BookshelfViewOwn = 'books...
fim
BookStackApp/BookStack
php
<|fim_suffix|>.type'); })->whereNull('deletions.deleted_at'); } /** * Add conditions to a query for a model that's a relation of a page, so only the model results * on visible pages are returned by the query. * Is effectively the same as "restrictEntityRelationQuery" but takes into accou...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Permissions; use BookStack\Entities\Models\Entity; use BookStack\Permissions\Models\EntityPermission; use BookStack\Users\Models\Role; class PermissionFormData { protected Entity $entity; public function __construct(Entity $entity) { $this->entity = $entity; } ...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Permissions; clas<|fim_suffix|>const IMPLICIT_DENY = 0; const IMPLICIT_ALLOW = 1; const EXPLICIT_DENY = 2; const EXPLICIT_ALLOW = 3; } <|fim_middle|>s PermissionStatus { <|endoftext|>
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Permissions; use BookStack\Entities\Queries\EntityQueries; use BookStack\Entities\Tools\PermissionsUpdater; use BookStack\Http\Controller; use BookStack\Permissions\Models\EntityPermission; use BookStack\Users\Models\Role; use BookStack\Util\DatabaseTransaction; use Illuminate\...
fim
BookStackApp/BookStack
php
<|fim_suffix|> throw new PermissionsException(trans('errors.role_registration_default_cannot_delete')); } (new DatabaseTransaction(function () use ($migrateRoleId, $role) { if ($migrateRoleId !== 0) { $newRole = Role::query()->find($migrateRoleId); if (...
fim
BookStackApp/BookStack
php
<|fim_suffix|>simple->book_id = $attrs['book_id'] ?? null; $simple->chapter_id = $attrs['chapter_id'] ?? null; return $simple; } } <|fim_prefix|><?php namespace BookStack\Permissions; use BookStack\Entities\Models\Entity; class SimpleEntityData { public int $id; public string $type; ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>s), new PageLinkModelResolver($queries->pages), new ChapterLinkModelResolver($queries->chapters), new BookLinkModelResolver($queries->books), new BookshelfLinkModelResolver($queries->shelves), ]); } } <|fim_prefix|><?php namespace BookStack\Refe...
fim
BookStackApp/BookStack
php
<|fim_suffix|>ntval($matches[1]); return Attachment::query()->find($id); } } <|fim_prefix|><?php namespace BookStack\References\ModelResolvers; use<|fim_middle|> BookStack\Uploads\Attachment; class AttachmentModelResolver implements CrossLinkModelResolver { public function resolve(string $link): ?At...
fim
BookStackApp/BookStack
php
<|fim_suffix|>, '/') . '\/([\w-]+)' . '([#?\/]|$)/'; $matches = []; $match = preg_match($pattern, $link, $matches); if (!$match) { return null; } $bookSlug = $matches[1]; /** @var ?Book $model */ $model = $this->queries->start()->where('slug', '=', $...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\References\ModelResolvers; use BookStack\App\Model; use BookStack\Entities\Models\Bookshelf; use BookStack\En<|fim_suffix|>ver implements CrossLinkModelResolver { public function __construct( protected BookshelfQueries $queries ) { } public function reso...
fim
BookStackApp/BookStack
php
<|fim_suffix|>= []; $match = preg_match($pattern, $link, $matches); if (!$match) { return null; } $bookSlug = $matches[1]; $chapterSlug = $matches[2]; /** @var ?Chapter $model */ $model = $this->queries->usingSlugs($bookSlug, $chapterSlug)->first(['i...
fim
BookStackApp/BookStack
php
<|fim_suffix|>given href link value to a model. */ public function resolve(string $link): ?Model; } <|fim_prefix|><?php namespace BookStack\References\ModelResolver<|fim_middle|>s; use BookStack\App\Model; interface CrossLinkModelResolver { /** * Resolve the <|endoftext|>
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\References\ModelResolvers; use BookStack\Uploads\Image; use BookStack\Uploads\ImageStorage; class ImageModelResolver implements CrossLinkModelResolver { protected ?string $pattern = null; public function resolve(string $link): ?Image { $pattern = $this->ge...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\References\ModelResolvers; use BookStack\App\Model; use BookStack\Entities\Models\Page; use BookStack\Entities\Queries\PageQueries; class PageLinkModelResolver implements CrossLinkModelResolver { public function __construct( protected PageQueries $queries ) { ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>->find($id, ['id']); return $model; } } <|fim_prefix|><?php namespace BookStack\References\ModelResolvers; use BookStack\App\Model; use BookStack\Entities\Models\Page; use BookStack\Entities\Queries\PageQueries; class PagePermalinkModelResolver implements CrossLinkModelResolver { publi...
fim
BookStackApp/BookStack
php
<|fim_suffix|> to(): MorphTo { return $this->morphTo('to'); } public function jointPermissions(): HasMany { return $this->hasMany(JointPermission::class, 'entity_id', 'from_id') ->whereColumn('references.from_type', '=', 'joint_permissions.entity_type'); } } <|fim_prefix...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\References; use BookStack\Entities\Models\Entity; class ReferenceChangeCo<|fim_suffix|>on add(Entity $oldEntity, Entity $newEntity): void { $this->changes[] = [$oldEntity, $newEntity]; } /** * Get all the new entities from the changes. */ pub...
fim
BookStackApp/BookStack
php
<|fim_suffix|>rences, ]); } } <|fim_prefix|><?php namespace BookStack\References; use BookStack\Entities\Queries\EntityQueries; use BookStack\Http\Controller; class ReferenceController extends Controller { public function __construct( protected ReferenceFetcher $referenceFetcher, prot...
fim
BookStackApp/BookStack
php
<|fim_suffix|>e::query() ->where('to_type', '=', $entity->getMorphClass()) ->where('to_id', '=', $entity->id) ->whereHas('from'); return $this->permissions->restrictEntityRelationQuery( $baseQuery, 'references', 'from_id', 'fro...
fim
BookStackApp/BookStack
php
<|fim_suffix|> foreach ($entities as $entity) { $models = $parser->extractLinkedModels($entity->getAttribute($entity->htmlField)); foreach ($models as $model) { $references[] = [ 'from_id' => $entity->id, 'from_type' => $entity->getMo...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\References; use BookStack\Entities\Models\Book; use BookStack\Entities\Models\HasDescriptionInterface; use BookStack\Entities\Models\Entity; use BookStack\Entities\Models\Page; use BookStack\Entities\Repos\RevisionRepo; use BookStack\Util\HtmlDocument; class ReferenceUpdater { public fu...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Search\Options; class ExactSearchOption extends SearchOption { public function toString(): string { $escaped = str_replace('\\', '\\\\', $this->value); $escaped =<|fim_suffix|>egated ? '-' : '') . '"' . $escaped . '"'; } } <|fim_middle|> str_replace(...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Search\Options; class FilterSearchOption extends SearchOption { protected string $name; public function __construct( string $value, string $name, bool $negat<|fim_suffix|>g { $valueText = ($this->value ? ':' . $this->value : ''); ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>arch string representation for this search option. */ abstract public function toString(): string; } <|fim_prefix|><?php namespace BookStack\Search\Options; abstract class SearchOption { public function __construct( public string $value, public bool $negated = false, ) {...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Search\Options; class TagSearchOption extends SearchOption { /** * Acceptable operators to be used within a tag search option. * * @var string[] */ protected array $queryOperators = ['<=', '>=', '=', '<', '>', 'like', '!=']; public function toSt...
fim
BookStackApp/BookStack
php
<|fim_suffix|>on { public function toString(): string { return $this->value; } } <|fim_prefix|><?php namespace Boo<|fim_middle|>kStack\Search\Options; class TermSearchOption extends SearchOpti<|endoftext|>
fim
BookStackApp/BookStack
php
<|fim_suffix|> 'data' => $data, 'total' => $results['total'], ]); } } <|fim_prefix|><?php declare(strict_types=1); namespace BookStack\Search; use BookStack\Api\ApiEntityListFormatter; use BookStack\Entities\Models\Entity; use BookStack\Http\ApiController; use Illuminate\Http\JsonRespons...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Search; use BookStack\Entities\Queries\PageQueries; use BookStack\Entities\Queries\QueryPopular; use BookStack\Entities\Tools\SiblingFetcher; use BookStack\Http\Controller; use Illuminate\Http\Request; use Illuminate\Pagination\LengthAwarePaginator; class SearchController exte...
fim
BookStackApp/BookStack
php
<|fim_suffix|>elims = static::$softDelimiters; $tokenizer = new SearchTextTokenizer($text, static::$delimiters); $extendedToken = ''; $extendedLen = 0; $token = $tokenizer->next(); while ($token !== false) { $delim = $tokenizer->previousDelimiter(); if ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>@return self<T> */ public function nonNegated(): self { $values = array_values(array_filter($this->options, fn (SearchOption $option) => !$option->negated)); return new self($values); } /** * @return self<T> */ public function limit(int $limit): self ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>ss)) ->filterEmpty(); // Add tags & filters $this->tags = $this->tags->merge(new SearchOptionSet($terms['tags'])); $this->filters = $this->filters->merge(new SearchOptionSet($terms['filters'])); } /** * Limit the amount of search options to reasonable lev...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Search; use BookStack\Activity\Models\Tag; use BookStack\Entities\Models\Entity; use Illuminate\Support\HtmlString; class SearchResultsFormatter { /** * For the given array of entities, Prepare the models to be shown in search result * output. This sets a series ...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Search; use BookStack\Entities\EntityProvider; use BookStack\Entities\Models\Entity; use BookStack\Entities\Queries\EntityQueries; use BookStack\Entities\Tools\EntityHydrator; use BookStack\Permissions\PermissionApplicator; use BookStack\Search\Options\TagSearchOption; use BookStack\Users\Mo...
fim
BookStackApp/BookStack
php
<|fim_suffix|>his->morphTo('entity'); } } <|fim_prefix|><?php namespace BookStack\Search; use Boo<|fim_middle|>kStack\App\Model; class SearchTerm extends Model { protected $fillable = ['term', 'entity_id', 'entity_type', 'score']; public $timestamps = false; /** * Get the entity that this term ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>protected string $currentDelimiter = ''; protected string $previousDelimiter = ''; public function __construct( protected string $text, protected string $delimiters = ' ' ) { $this->length = strlen($this->text); } /** * Get the current delimiter to be fou...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Settings; use BookStack\Uploads\FaviconHandler; use BookStack\Uploads\ImageRepo; use Illuminate\Http\Request; class AppSettingsStore { public function __construct( protected ImageRepo $imageRepo, protected FaviconHandler $faviconHandler, ) { } ...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Settings; use BookStack\Activity\ActivityType; use BookStack\App\AppVersion; use BookStack\Entities\Tools\TrashCan; use BookStack\Http\Controller; use BookStack\Permissions\Permission; use BookStack\References\ReferenceStore; use BookStack\Uploads\ImageService; use Illuminate\H...
fim
BookStackApp/BookStack
php
<|fim_suffix|>tends Model { protected $fillable = ['setting_key', 'value']; protected $primaryKey = 'setting_key'; } <|fim_prefix|><?php namespace BookStack\<|fim_middle|>Settings; use BookStack\App\Model; class Setting ex<|endoftext|>
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Settings; use BookStack\Activity\ActivityType; use BookStack\App\AppVersion; use BookStack\Http\Controller; use BookStack\Permissions\Permission; use BookStack\Users\Models\User; use Illuminate\Http\Request; class SettingController extends Controller { /** * Handle re...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Settings; use BookStack\Users\Models\User; /** * Class SettingService * The settings are a simple key-value database store. * For non-authenticated users, user settings are stored via the session instead. * A local array-based cache is used to for setting accesses across a request. */ ...
fim
BookStackApp/BookStack
php
<|fim_suffix|> return DB::table('migrations')->count() > 0; }), 'cache' => $this->trueWithoutError(function () { $rand = Str::random(12); $key = "status_test_{$rand}"; Cache::add($key, $rand); return Cache::pull($ke...
fim
BookStackApp/BookStack
php
<|fim_suffix|>t_email_mail_subject')) ->greeting(trans('settings.maint_send_test_email_mail_greeting')) ->line(trans('settings.maint_send_test_email_mail_text')); } } <|fim_prefix|><?php namespace BookStack\Settings; use BookStack\App\MailNotification; use BookStack\Users\Models\Us...
fim
BookStackApp/BookStack
php
<|fim_suffix|>=== 'true' ? 'true' : 'false'; setting()->putUser($this->user, 'notifications#' . $setting, $value); } } protected function getNotificationSetting(string $key): bool { return setting()->getUser($this->user, 'notifications#' . $key); } } <|fim_prefix|><?php nam...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Settings; class UserShortcutMap { protected const DEFAULTS = [ // Header actions "home_view" => "1", "shelves_view" => "2", "books_view" => "3", "settings_view" => "4", "favourites_view" => "5", "profile_view" => "6", ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>ublic function update(Request $request, BookSorter $sorter, string $bookSlug) { $book = $this->queries->findVisibleBySlugOrFail($bookSlug); $this->checkOwnablePermission(Permission::BookUpdate, $book); $loggedActivityForBook = false; // Sort via map if ($reques...
fim
BookStackApp/BookStack
php
<|fim_suffix|> } /** * @return BookSortMapItem[] */ public function all(): array { return $this->mapData; } public static function fromJson(string $json): self { $map = new BookSortMap(); $mapData = json_decode($json); foreach ($mapData as $mapDataIt...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Sorting; class BookSortMapItem { public function __construct( public int $id, public int $sort, public int|null $parentChapterId, public string $type, public int $parentBookId, ) { } } <|endoftext|>
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Sorting; use BookStack\Entities\Models\Book; use BookStack\Entities\Models\BookChild; use BookStack\Entities\Models\Chapter; use BookStack\Entities\Models\Entity; use BookStack\Entities\Models\Page; use BookStack\Entities\Queries\EntityQueries; use BookStack\Entities\Tools\Pare...
fim
BookStackApp/BookStack
php
<|fim_suffix|>tatic::query() ->withCount('books') ->orderBy('name', 'asc') ->get(); } } <|fim_prefix|><?php namespace BookStack\Sorting; use BookStack\Activity\Models\Loggable; use BookStack\Entities\Models\Book; use Carbon\Carbon; use Illuminate\Database\Eloquent\Collection; u...
fim
BookStackApp/BookStack
php
<?php namespace BookStack\Sorting; use BookStack\Activity\ActivityType; use BookStack\Entities\Models\EntityContainerData; use BookStack\Http\Controller; use BookStack\Permissions\Permission; use Illuminate\Http\Request; class SortRuleController extends Controller { public function __construct() { $t...
fim
BookStackApp/BookStack
php
<|fim_suffix|> return !in_array($operation, $operations); }); return array_values($filtered); } /** * Create a set of operations from a string sequence representation. * (values seperated by commas). * @return SortRuleOperation[] */ public static function fromSeque...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Sorting; use voku\helper\ASCII; use BookStack\Entities\Models\Chapter; use BookStack\Entities\Models\Entity; /** * Sort comparison function for each of the possible SortSetOperation values. * Method names should be camelCase names for the SortSetOperation enum value. */ cla...
fim
BookStackApp/BookStack
php
<|fim_prefix|><?php namespace BookStack\Sorting; /** * Generate a URL with multiple parameters for sorting purposes. * Works out the logic to set the correct sorting direction * Discards empty parameters and allows overriding. */ class SortUrl { public function __construct( protected string $path, ...
fim
BookStackApp/BookStack
php
<|fim_suffix|>n" . $this->getModuleHeadContent(); return HtmlNonceApplicator::prepare($content); }); return HtmlNonceApplicator::apply($html, $this->cspService->getNonce()); } /** * Fetch our custom HTML head content prepared for use in export formats. * Scripts are strip...
fim
BookStackApp/BookStack
php