WebOrbiton
v1.0.0.9

Publisium

87 lines · 4.2 KB
  1. <?php
  2. ​
  3. declare(strict_types=1);
  4. ​
  5. if (!AuthorProfile::isEnabled()) {
  6. echo '<h1 class="dash-title">' . Icons::icon('user', 'icon icon-lg') . 'Artist</h1>';
  7. echo Auth::hasRoleAtLeast(Auth::ROLE_EDITOR_IN_CHIEF)
  8. ? '<p>Author pages are turned off. Turn them on in <a href="settings.php?tab=layout">Settings → Layout</a> (tick "Turn on author pages").</p>'
  9. : '<p>Author pages are turned off. An administrator can enable them in Settings → Layout.</p>';
  10. return;
  11. }
  12. ​
  13. if (!AuthorProfile::canHaveProfile()) {
  14. echo '<p>Author pages aren’t available for your role.</p>';
  15. return;
  16. }
  17. ​
  18. $profile = AuthorProfile::forAccount((int) $currentUser['id']);
  19. $wasPosted = $_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['action'] ?? '') === 'save_profile';
  20. $form = $wasPosted
  21. ? [
  22. 'headline' => (string) ($_POST['headline'] ?? ''),
  23. 'bio' => (string) ($_POST['bio'] ?? ''),
  24. 'website_url' => (string) ($_POST['website_url'] ?? ''),
  25. ]
  26. : AuthorProfile::formValues($profile);
  27. $publishDirectly = Auth::canPublishDirectly();
  28. $status = $profile['status'] ?? 'draft';
  29. $showSchemaType = SiteFront::settings()['seo_article_schema_enabled'] === '1';
  30. $schemaType = $wasPosted ? (string) ($_POST['schema_type'] ?? '') : (string) ($profile['schema_type'] ?? '');
  31. $schemaType = in_array($schemaType, AuthorProfile::SCHEMA_TYPES, true) ? $schemaType : 'Person';
  32. ​
  33. ?>
  34. <div class="dash-header-row">
  35. <h1 class="dash-title"><?= Icons::icon('user', 'icon icon-lg') ?>Artist</h1>
  36. <?php if ($profile && (int) $profile['is_public'] === 1): ?>
  37. <a href="<?= htmlspecialchars(SiteFront::authorUrl((string) $profile['slug']), ENT_QUOTES) ?>" class="dash-btn-small" target="_blank" rel="noopener noreferrer"><?= Icons::icon('eye', 'icon icon-sm') ?>View page</a>
  38. <?php endif; ?>
  39. </div>
  40. ​
  41. <div class="sidebar-box" style="max-width:720px;">
  42. <p style="margin-bottom:12px;">
  43. <?php if ($profile === null): ?>
  44. You have not created your author page yet. Fill in the form below to start.
  45. <?php else: ?>
  46. Status: <span class="status-pill status-<?= htmlspecialchars(AuthorProfile::statusClass($status)) ?>"><?= htmlspecialchars(AuthorProfile::statusLabel($status)) ?></span>
  47. <?php if ((int) $profile['is_public'] === 1 && $status !== 'approved'): ?>
  48. &middot; the public page keeps showing the last approved version until your changes are approved.
  49. <?php endif; ?>
  50. <?php endif; ?>
  51. </p>
  52. ​
  53. <?php if ($status === 'rejected' && !empty($profile['rejection_reason'])): ?>
  54. <div class="dash-flash dash-flash-error">Sent back with a note: <?= htmlspecialchars($profile['rejection_reason']) ?></div>
  55. <?php endif; ?>
  56. ​
  57. <form method="post">
  58. <?= Csrf::field() ?>
  59. <input type="hidden" name="action" value="save_profile">
  60. ​
  61. <label>Headline (e.g. "Technology reporter")</label>
  62. <input type="text" name="headline" maxlength="<?= AuthorProfile::HEADLINE_MAX ?>" value="<?= htmlspecialchars($form['headline']) ?>">
  63. ​
  64. <label>Bio (up to <?= AuthorProfile::BIO_MAX ?> characters)</label>
  65. <textarea name="bio" rows="8" maxlength="<?= AuthorProfile::BIO_MAX ?>"><?= htmlspecialchars($form['bio']) ?></textarea>
  66. ​
  67. <label>Website (optional)</label>
  68. <input type="url" name="website_url" maxlength="<?= AuthorProfile::URL_MAX ?>" value="<?= htmlspecialchars($form['website_url']) ?>" placeholder="https://">
  69. ​
  70. <?php if ($showSchemaType): ?>
  71. <label>For search engines, this author is</label>
  72. <select name="schema_type">
  73. <option value="Person" <?= $schemaType === 'Person' ? 'selected' : '' ?>>A person (Person)</option>
  74. <option value="Organization" <?= $schemaType === 'Organization' ? 'selected' : '' ?>>An organization, e.g. an editorial team or agency (Organization)</option>
  75. </select>
  76. <p style="font-size:12px;color:var(--muted);margin-top:6px;">Shown to search engines with your articles. It changes right away, without review.</p>
  77. <?php endif; ?>
  78. ​
  79. <p style="font-size:12px;color:var(--muted);margin-top:10px;">Your profile photo is set by an administrator in Team.</p>
  80. ​
  81. <div class="publish-actions">
  82. <button type="submit" name="intent" value="draft" class="dash-btn"><?= Icons::icon('pages', 'icon icon-sm') ?>Save draft</button>
  83. <button type="submit" name="intent" value="submit" class="dash-btn dash-btn-primary"><?= Icons::icon('check', 'icon icon-sm') ?><?= $publishDirectly ? 'Publish' : 'Send for review' ?></button>
  84. </div>
  85. </form>
  86. </div>
  87. ​