extranet/library/Application/Controller/Plugin/Pdf.php
2017-03-07 14:50:28 +01:00

30 lines
979 B
PHP

<?php
class Application_Controller_Plugin_Pdf extends Zend_Controller_Plugin_Abstract
{
public function dispatchLoopShutdown()
{
if (Zend_Registry::isRegistered('logger')) {
$logger = Zend_Registry::get('logger');
}
$logger->info('PLUGIN PDF - START');
$layout = Zend_Layout::getMVCInstance();
if ($layout->isEnabled()) {
$controller = $this->_request->getControllerName();
$action = $this->_request->getActionName();
$page = new Scores_Export_Print($controller, $action);
if ($page->exportable('pdf')){
$layout = $this->_response->getBody();
$filename = $page->filename('pdf', $this->_request->getParams());
$content = preg_replace('@<link href="/@si','<link href="./',$layout);
$content = preg_replace('@src="/@si','src="./',$content);
$c = Zend_Registry::get('config');
file_put_contents($c->profil->path->shared.'/pages/'.$filename.'.html', $content);
}
}
$logger->info('PLUGIN PDF - END');
}
}