preview.php 617 B

123456789101112131415161718192021222324252627
  1. <?php
  2. include 'common.php';
  3. /** 获取内容 Widget */
  4. \Widget\Archive::alloc('type=single&checkPermalink=0&preview=1')->to($content);
  5. /** 检测是否存在 */
  6. if (!$content->have()) {
  7. $response->redirect($options->adminUrl);
  8. }
  9. /** 检测权限 */
  10. if (!$user->pass('editor', true) && $content->authorId != $user->uid) {
  11. $response->redirect($options->adminUrl);
  12. }
  13. /** 输出内容 */
  14. $content->render();
  15. ?>
  16. <script>
  17. window.onbeforeunload = function () {
  18. if (!!window.parent) {
  19. window.parent.postMessage('cancelPreview', '<?php $options->rootUrl(); ?>');
  20. }
  21. }
  22. </script>