write-page.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. include 'common.php';
  3. include 'header.php';
  4. include 'menu.php';
  5. \Widget\Contents\Page\Edit::alloc()->to($page);
  6. ?>
  7. <div class="main">
  8. <div class="body container">
  9. <?php include 'page-title.php'; ?>
  10. <div class="row typecho-page-main typecho-post-area" role="form">
  11. <form action="<?php $security->index('/action/contents-page-edit'); ?>" method="post" name="write_page">
  12. <div class="col-mb-12 col-tb-9" role="main">
  13. <?php if ($page->draft): ?>
  14. <?php if ($page->draft['cid'] != $page->cid): ?>
  15. <?php $pageModifyDate = new \Typecho\Date($page->draft['modified']); ?>
  16. <cite
  17. class="edit-draft-notice"><?php _e('当前正在编辑的是保存于%s的草稿, 你可以<a href="%s">删除它</a>', $pageModifyDate->word(),
  18. $security->getIndex('/action/contents-page-edit?do=deleteDraft&cid=' . $page->cid)); ?></cite>
  19. <?php else: ?>
  20. <cite class="edit-draft-notice"><?php _e('当前正在编辑的是未发布的草稿'); ?></cite>
  21. <?php endif; ?>
  22. <input name="draft" type="hidden" value="<?php echo $page->draft['cid'] ?>"/>
  23. <?php endif; ?>
  24. <p class="title">
  25. <label for="title" class="sr-only"><?php _e('标题'); ?></label>
  26. <input type="text" id="title" name="title" autocomplete="off" value="<?php $page->title(); ?>"
  27. placeholder="<?php _e('标题'); ?>" class="w-100 text title"/>
  28. </p>
  29. <?php $permalink = \Typecho\Common::url($options->routingTable['page']['url'], $options->index);
  30. [$scheme, $permalink] = explode(':', $permalink, 2);
  31. $permalink = ltrim($permalink, '/');
  32. $permalink = preg_replace("/\[([_a-z0-9-]+)[^\]]*\]/i", "{\\1}", $permalink);
  33. if ($page->have()) {
  34. $permalink = str_replace('{cid}', $page->cid, $permalink);
  35. }
  36. $input = '<input type="text" id="slug" name="slug" autocomplete="off" value="' . htmlspecialchars($page->slug ?? '') . '" class="mono" />';
  37. ?>
  38. <p class="mono url-slug">
  39. <label for="slug" class="sr-only"><?php _e('网址缩略名'); ?></label>
  40. <?php echo preg_replace("/\{slug\}/i", $input, $permalink); ?>
  41. </p>
  42. <p>
  43. <label for="text" class="sr-only"><?php _e('页面内容'); ?></label>
  44. <textarea style="height: <?php $options->editorSize(); ?>px" autocomplete="off" id="text"
  45. name="text" class="w-100 mono"><?php echo htmlspecialchars($page->text ?? ''); ?></textarea>
  46. </p>
  47. <?php include 'custom-fields.php'; ?>
  48. <p class="submit clearfix">
  49. <span class="left">
  50. <button type="button" id="btn-cancel-preview" class="btn"><i
  51. class="i-caret-left"></i> <?php _e('取消预览'); ?></button>
  52. </span>
  53. <span class="right">
  54. <input type="hidden" name="cid" value="<?php $page->cid(); ?>"/>
  55. <button type="button" id="btn-preview" class="btn"><i
  56. class="i-exlink"></i> <?php _e('预览页面'); ?></button>
  57. <button type="submit" name="do" value="save" id="btn-save"
  58. class="btn"><?php _e('保存草稿'); ?></button>
  59. <button type="submit" name="do" value="publish" class="btn primary"
  60. id="btn-submit"><?php _e('发布页面'); ?></button>
  61. <?php if ($options->markdown && (!$page->have() || $page->isMarkdown)): ?>
  62. <input type="hidden" name="markdown" value="1"/>
  63. <?php endif; ?>
  64. </span>
  65. </p>
  66. <?php \Typecho\Plugin::factory('admin/write-page.php')->content($page); ?>
  67. </div>
  68. <div id="edit-secondary" class="col-mb-12 col-tb-3" role="complementary">
  69. <ul class="typecho-option-tabs clearfix">
  70. <li class="active w-50"><a href="#tab-advance"><?php _e('选项'); ?></a></li>
  71. <li class="w-50"><a href="#tab-files" id="tab-files-btn"><?php _e('附件'); ?></a></li>
  72. </ul>
  73. <div id="tab-advance" class="tab-content">
  74. <section class="typecho-post-option" role="application">
  75. <label for="date" class="typecho-label"><?php _e('发布日期'); ?></label>
  76. <p><input class="typecho-date w-100" type="text" name="date" id="date" autocomplete="off"
  77. value="<?php $page->have() && $page->created > 0 ? $page->date('Y-m-d H:i') : ''; ?>"/>
  78. </p>
  79. </section>
  80. <section class="typecho-post-option">
  81. <label for="order" class="typecho-label"><?php _e('页面顺序'); ?></label>
  82. <p><input type="text" id="order" name="order" value="<?php $page->order(); ?>"
  83. class="w-100"/></p>
  84. <p class="description"><?php _e('为你的自定义页面设定一个序列值以后, 能够使得它们按此值从小到大排列'); ?></p>
  85. </section>
  86. <section class="typecho-post-option">
  87. <label for="template" class="typecho-label"><?php _e('自定义模板'); ?></label>
  88. <p>
  89. <select name="template" id="template">
  90. <option value=""><?php _e('不选择'); ?></option>
  91. <?php $templates = $page->getTemplates();
  92. foreach ($templates as $template => $name): ?>
  93. <option
  94. value="<?php echo $template; ?>"<?php if ($template == $page->template): ?> selected="true"<?php endif; ?>><?php echo $name; ?></option>
  95. <?php endforeach; ?>
  96. </select>
  97. </p>
  98. <p class="description"><?php _e('如果你为此页面选择了一个自定义模板, 系统将按照你选择的模板文件展现它'); ?></p>
  99. </section>
  100. <?php \Typecho\Plugin::factory('admin/write-page.php')->option($page); ?>
  101. <button type="button" id="advance-panel-btn" class="btn btn-xs"><?php _e('高级选项'); ?> <i
  102. class="i-caret-down"></i></button>
  103. <div id="advance-panel">
  104. <section class="typecho-post-option visibility-option">
  105. <label for="visibility" class="typecho-label"><?php _e('公开度'); ?></label>
  106. <p>
  107. <select id="visibility" name="visibility">
  108. <option
  109. value="publish"<?php if ($page->status == 'publish' || !$page->status): ?> selected<?php endif; ?>><?php _e('公开'); ?></option>
  110. <option
  111. value="hidden"<?php if ($page->status == 'hidden'): ?> selected<?php endif; ?>><?php _e('隐藏'); ?></option>
  112. </select>
  113. </p>
  114. </section>
  115. <section class="typecho-post-option allow-option">
  116. <label class="typecho-label"><?php _e('权限控制'); ?></label>
  117. <ul>
  118. <li><input id="allowComment" name="allowComment" type="checkbox" value="1"
  119. <?php if ($page->allow('comment')): ?>checked="true"<?php endif; ?> />
  120. <label for="allowComment"><?php _e('允许评论'); ?></label></li>
  121. <li><input id="allowPing" name="allowPing" type="checkbox" value="1"
  122. <?php if ($page->allow('ping')): ?>checked="true"<?php endif; ?> />
  123. <label for="allowPing"><?php _e('允许被引用'); ?></label></li>
  124. <li><input id="allowFeed" name="allowFeed" type="checkbox" value="1"
  125. <?php if ($page->allow('feed')): ?>checked="true"<?php endif; ?> />
  126. <label for="allowFeed"><?php _e('允许在聚合中出现'); ?></label></li>
  127. </ul>
  128. </section>
  129. <?php \Typecho\Plugin::factory('admin/write-page.php')->advanceOption($page); ?>
  130. </div>
  131. <?php if ($page->have()): ?>
  132. <?php $modified = new \Typecho\Date($page->modified); ?>
  133. <section class="typecho-post-option">
  134. <p class="description">
  135. <br>&mdash;<br>
  136. <?php _e('本页面由 <a href="%s">%s</a> 创建',
  137. \Typecho\Common::url('manage-pages.php?uid=' . $page->author->uid, $options->adminUrl), $page->author->screenName); ?>
  138. <br>
  139. <?php _e('最后更新于 %s', $modified->word()); ?>
  140. </p>
  141. </section>
  142. <?php endif; ?>
  143. </div><!-- end #tab-advance -->
  144. <div id="tab-files" class="tab-content hidden">
  145. <?php include 'file-upload.php'; ?>
  146. </div><!-- end #tab-files -->
  147. </div>
  148. </form>
  149. </div>
  150. </div>
  151. </div>
  152. <?php
  153. include 'copyright.php';
  154. include 'common-js.php';
  155. include 'form-js.php';
  156. include 'write-js.php';
  157. \Typecho\Plugin::factory('admin/write-page.php')->trigger($plugged)->richEditor($page);
  158. if (!$plugged) {
  159. include 'editor-js.php';
  160. }
  161. include 'file-upload-js.php';
  162. include 'custom-fields-js.php';
  163. \Typecho\Plugin::factory('admin/write-page.php')->bottom($page);
  164. include 'footer.php';
  165. ?>