~xibo-maintainers/xibo/tempel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/*
 * Xibo - Digital Signage - http://www.xibo.org.uk
 * Copyright (C) 2014 Alex Harrington
 *
 * This file is part of Xibo.
 *
 * Xibo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version. 
 *
 * Xibo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
 */
namespace Xibo\Controller;

use baseDAO;
use database;
use Xibo\Entity\User;
use Xibo\Helper\Theme;

defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");

class Preview extends Base
{
    /* @var \Xibo\Entity\Layout $layout */
    private $layout;

    function __construct(database $db, user $user)
    {
        $this->db =& $db;
        $this->user =& $user;

        $layoutId = \Xibo\Helper\Sanitize::getInt('layoutid');

        //if we have modify selected then we need to get some info
        if ($layoutId != 0) {
            // get the permissions
            $layout = $this->user->LayoutList(NULL, array('layoutId' => $layoutId));

            if (count($layout) <= 0)
                trigger_error(__('You do not have permissions to view this layout'), E_USER_ERROR);

            $this->layout = $layout[0];
        }
    }

    function render()
    {
        $favicon = Theme::ImageUrl('favicon.ico');

        // Render a specific layout in the previewer
        // layoutid must be provided
        $pfl = __('Preview for Layout');

        $previewCss = Theme::ItemPath('css/html-preview.css');

        $output = <<<EOT
            <!DOCTYPE html>
            <html>
                <head>
                    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
                    <title>$pfl {$this->layout->layoutId}</title>
                    <link rel="stylesheet" type="text/css" href="$previewCss" />
                    <script type="text/JavaScript" src="theme/default/libraries/jquery/jquery-1.9.1.js"></script>
                    <script type="text/JavaScript" src="modules/preview/html5Preloader.js"></script>
                    <script type="text/JavaScript" src="modules/preview/html-preview.js"></script>
                    <link rel="shortcut icon" href="$favicon" />
                </head>
                <body onload="dsInit({$this->layout->layoutId})">
                    <div id="player">
                        <div id="info"></div>
                        <div id="log"></div>
                        <div id="screen">
                            <div id="splash">
                                <div id="loader"></div>
                                <div id="loaderCaption"><p>
EOT;

        $output .= __("Loading layout...");
        $output .= "</p></div>";
        $output .= "</div>";
        $output .= '<div id="end"><a href="javascript:history.go(0)" style="text-decoration: none; color: #ffffff">';
        $output .= __("Play again?");
        $output .= "</a></div></div></div></body></html>";

        print $output;
    }

    function getXlf()
    {
        print $this->layout->toXlf();
    }
}