Move pdf.css into different directory to prevent it from being loaded during
regular requests. refs #5644
This commit is contained in:
parent
f6692ba436
commit
342a9375de
|
@ -1,103 +0,0 @@
|
|||
<?php
|
||||
// @codingStandardsIgnoreStart
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
/**
|
||||
* This file is part of Icinga Web 2.
|
||||
*
|
||||
* Icinga Web 2 - Head for multiple monitoring backends.
|
||||
* Copyright (C) 2013 Icinga Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||
* @author Icinga Development Team <info@icinga.org>
|
||||
*
|
||||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
class Zend_Controller_Action_Helper_DataFormatSwitch extends Zend_Controller_Action_Helper_ContextSwitch {
|
||||
|
||||
protected $autoSerialization = true;
|
||||
|
||||
public function setAutoJsonSerialization($value)
|
||||
{
|
||||
$this->autoSerialization = $value;
|
||||
$this->setAutoJsonSerialization($value);
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContexts(
|
||||
array(
|
||||
'pdf' => array(
|
||||
'suffix' => 'pdf',
|
||||
'headers' => array('Content-Type' => 'application/pdf'),
|
||||
'callbacks' => array(
|
||||
'init' => 'removeStyles',
|
||||
'post' => 'postPdfContext'
|
||||
)
|
||||
),
|
||||
'json' => array(
|
||||
'suffix' => 'json',
|
||||
'headers' => array('Content-Type' => 'application/json'),
|
||||
'callbacks' => array(
|
||||
'init' => 'removeStyles',
|
||||
'post' => 'postJsonContext'
|
||||
)
|
||||
),
|
||||
'xml' => array(
|
||||
'suffix' => 'xml',
|
||||
'headers' => array('Content-Type' => 'application/xml'),
|
||||
'callbacks' => array(
|
||||
'init' => 'removeStyles',
|
||||
'post' => 'postXmlContext'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function postXmlContext()
|
||||
{
|
||||
if (!$this->autoSerialization) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private function postPdfContext()
|
||||
{
|
||||
if (!$this->autoSerialization) {
|
||||
return;
|
||||
}
|
||||
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
|
||||
$helper = new Zend_View_Helper_Pdf();
|
||||
$this->getResponse()->setBody(
|
||||
$helper->pdf($viewRenderer->render())
|
||||
);
|
||||
}
|
||||
|
||||
private function removeStyles()
|
||||
{
|
||||
if (!$this->getAutoJsonSerialization()) {
|
||||
return;
|
||||
}
|
||||
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
|
||||
$view = $viewRenderer->view;
|
||||
if ($view instanceof Zend_View_Interface) {
|
||||
$viewRenderer->setNoRender(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -254,11 +254,9 @@ class ActionController extends Zend_Controller_Action
|
|||
if (!headers_sent()) {
|
||||
$css = $this->view->getHelper('action')->action('stylesheet', 'static', 'application');
|
||||
|
||||
// fix css for pdf
|
||||
require_once 'vendor/lessphp/lessc.inc.php';
|
||||
$lessc = new \lessc();
|
||||
// load css fixes for pdf formatting mode
|
||||
$publicDir = realpath(dirname($_SERVER['SCRIPT_FILENAME']));
|
||||
$css .= $lessc->compile($publicDir . '/css/icinga/pdf.less');
|
||||
$css .= file_get_contents($publicDir . '/css/pdf/pdf.css');
|
||||
|
||||
$pdf = new PDF();
|
||||
if ($this->_request->getControllerName() === 'list') {
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
* @author Icinga Development Team <info@icinga.org>
|
||||
*
|
||||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
/* {{{ICINGA_LICENSE_HEADER}}} */
|
||||
|
||||
|
||||
*, html {
|
||||
font-size: 100%;
|
||||
|
@ -34,7 +35,6 @@ form {
|
|||
display: none;
|
||||
}
|
||||
|
||||
// Insert page breaks
|
||||
div.pdf-page {
|
||||
page-break-before: always;
|
||||
}
|
||||
|
@ -46,24 +46,20 @@ div.selection-toolbar > a {
|
|||
display: none;
|
||||
}
|
||||
|
||||
// Dont show any link outline
|
||||
a {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
// Fix badge positioning
|
||||
span.badge {
|
||||
float: right;
|
||||
max-width: 5px;
|
||||
}
|
||||
|
||||
// prevent table rows from growing too big on page breaks
|
||||
tr {
|
||||
max-height: 30px;
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
// Hide buttons
|
||||
*.button {
|
||||
display: none;
|
||||
}
|
||||
|
@ -74,7 +70,6 @@ button > i {
|
|||
display: none;
|
||||
}
|
||||
|
||||
// Hide navigation
|
||||
*.nav {
|
||||
display: none;
|
||||
}
|
||||
|
@ -85,7 +80,6 @@ button > i {
|
|||
display: none;
|
||||
}
|
||||
|
||||
// Hide pagination
|
||||
*.pagination {
|
||||
display: none;
|
||||
}
|
||||
|
@ -97,4 +91,4 @@ button > i {
|
|||
}
|
||||
*.pagination > li > span {
|
||||
display: none;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue