/home/coolpkct/www/websites/cake3.cool.rocks/admin/classes/previewscreen.php
<?php
/**
 * Part of Showkase web site management package
 *
 * @package Showkase
 * @author Jack Hardie {@link http://www.jhardie.com}
 * @copyright Copyright (c) 2012, SimpleViewer Inc.
 */
defined('SK_ACCESS')||die('<h1>403: Forbidden</h1>');
 
/**
 * Repair screen
 *
 * @package Showkase
 */
class PreviewScreen extends Screen
{
    /**
     * Return complete html for screen
     * overrides parent method
     *
     * @return string
     * @param array context
     */
    public function getHtml($context)
    {
        $content = $this->getContentHtml($context);
        $html = <<<EOD
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Showkase | Preview</title>
  <link href="css/bootstrap.min.css" rel="stylesheet" media="all" />
  <link href="css/all.css" rel="stylesheet" media="all" />
  <!--[if lt IE 9]>
    <script src="scripts/html5shiv.js"></script>
  <![endif]-->
  <link href="css/custom.css" rel="stylesheet" media="all" />
</head>
  <body id="preview" class="preview">
  	<div id="wrapper" style="margin-top: 20px">
      <div id="content" style="width: 916px; padding-right: 24px">
        <p>Publishing&hellip;</p>
        {$content}
      </div>
    </div>
  </body>
</html>    
EOD;
        return $html;
   }

    /**
     * Returns html error message or replace script
     * 
     * @return string html
     * @param array context
     */
    function getContentHtml($context)
    {
        $uncaughtErrorMessages = ob_get_clean();
        $messages = '';
        try {
            $messages = Board::getMessages();
        } catch (Exception $e) {
            $messages = '
      <ul class="messages unstyled">
        <li class="warning">'.$e->getMessage().'</li>
      </ul>';
        }
        if (!empty($uncaughtErrorMessages)) {
            $messages.= '<div class="error">'.$uncaughtErrorMessages.'</div>';
        }
        if ($context['viewUrl'] == '') {
            $messages.= '
              <p>Cannot find web page to display</p>';
        }
        if ($messages == '') {
            return <<<EOD
              <script>
                  window.location.replace("{$context['viewUrl']}");
              </script>
EOD;
        }
        return <<<EOD
            {$messages}
            <script>
                confirmed = confirm("You have warning messages, continue with publishing?");
                if (confirmed) {
                    window.location.replace("{$context['viewUrl']}");
                }
            </script>
EOD;
    }
}