2011-04-29 09:46:29 +02:00
|
|
|
<?php
|
|
|
|
class Application_Controller_Plugin_Pdf extends Zend_Controller_Plugin_Abstract
|
|
|
|
{
|
|
|
|
public function dispatchLoopShutdown()
|
|
|
|
{
|
2017-02-13 14:08:23 +01:00
|
|
|
if (Zend_Registry::isRegistered('logger')) {
|
|
|
|
$logger = Zend_Registry::get('logger');
|
|
|
|
}
|
|
|
|
|
|
|
|
$logger->info('PLUGIN PDF - START');
|
2016-04-07 17:48:55 +02:00
|
|
|
|
|
|
|
$layout = Zend_Layout::getMVCInstance();
|
2012-11-16 15:12:03 +01:00
|
|
|
if ($layout->isEnabled()) {
|
2011-08-18 17:57:14 +02:00
|
|
|
$controller = $this->_request->getControllerName();
|
|
|
|
$action = $this->_request->getActionName();
|
2013-11-18 15:49:04 +01:00
|
|
|
|
2013-11-29 14:54:52 +01:00
|
|
|
$page = new Scores_Export_Print($controller, $action);
|
2011-08-18 17:57:14 +02:00
|
|
|
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);
|
2012-11-16 15:12:03 +01:00
|
|
|
$c = Zend_Registry::get('config');
|
2017-03-07 14:50:28 +01:00
|
|
|
file_put_contents($c->profil->path->shared.'/pages/'.$filename.'.html', $content);
|
2011-08-18 17:57:14 +02:00
|
|
|
}
|
2011-04-29 09:46:29 +02:00
|
|
|
}
|
2016-04-07 17:48:55 +02:00
|
|
|
|
2017-02-13 14:08:23 +01:00
|
|
|
$logger->info('PLUGIN PDF - END');
|
2011-04-29 09:46:29 +02:00
|
|
|
}
|
|
|
|
}
|