@php /** * Shared body of the create and edit screens. They differ only in the * action, the loaded values and the cover already on file, so one partial * keeps the two from drifting apart. * * Expects: $action, $post (null on create), $getCategories, * $selectedCategories, $serverData, $siteData, $pageTitle, * $submitLabel */ $errorTitle = Session::has('error_title'); $errorCat = Session::has('error_cat'); $title = $errorTitle ? '' : old('title', $post ? htmlspecialchars_decode($post->title) : ''); $content = htmlspecialchars_decode(old('content', $post->content ?? '')); $shortText = old('short_text', $post ? htmlspecialchars_decode((string) $post->short_text) : ''); $coverAlt = old('feature_img_alt', $post ? htmlspecialchars_decode((string) $post->feature_img_alt) : ''); $visibility = old('visibility', $post->status ?? '1'); $allowComments = old('allow_comments', $post->allow_comments ?? '1'); $cover = $post->feature_img ?? null; $coverBase = 'https://' . ($serverData->name ?? '') . '/contents/' . ($siteData->id ?? '') . '/posts/'; $coverUrl = $cover ? $coverBase . $cover : ''; $now = now(); $oldSchedule = old('schedule_time'); $scheduleValue = ($oldSchedule && \Carbon\Carbon::parse($oldSchedule)->greaterThan($now)) ? $oldSchedule : ($post->schedule_timestamp ?? $now->format('Y-m-d\TH:i')); $visibilityOptions = [ '1' => __('site.page_post_new_side_grid1_option_1'), '3' => __('site.page_post_new_side_grid1_option_4'), '2' => __('site.page_post_new_side_grid1_option_2'), '0' => __('site.page_post_new_side_grid1_option_3'), ]; @endphp