Plugin Impression et Export
This commit is contained in:
parent
575fece3e9
commit
2665f8e7eb
93
library/Application/Controller/Plugin/Print.php
Normal file
93
library/Application/Controller/Plugin/Print.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
class Application_Controller_Plugin_Print extends Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
public function postDispatch(Zend_Controller_Request_Abstract $request)
|
||||
{
|
||||
$module = $request->getModuleName();
|
||||
$controller = $request->getControllerName();
|
||||
$action = $request->getActionName();
|
||||
|
||||
if ($request->isXmlHttpRequest()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($module != 'legal') {
|
||||
return;
|
||||
}
|
||||
|
||||
$layout = Zend_Layout::getMVCInstance();
|
||||
if ($layout->isEnabled()) {
|
||||
$view = $layout->getView();
|
||||
|
||||
// Get Print indicator
|
||||
if ($view->Printable) {
|
||||
$view->MenuPrint = true;
|
||||
|
||||
$page = new Scores_Export_Print($controller, $action);
|
||||
|
||||
// @todo : Nom du fichier
|
||||
$view->MenuHtml = $page->filename('print', $request->getParams());
|
||||
|
||||
// @todo : Nom du fichier
|
||||
$view->MenuPdf = $page->filename('pdf', $request->getParams());
|
||||
}
|
||||
|
||||
// Get XML Object
|
||||
if ($view->exportObject) {
|
||||
$view->MenuXml = $page->filename('xml', $request->getParams());
|
||||
// Générer les noms de fichiers avec les paramètres
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function dispatchLoopShutdown()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$module = $request->getModuleName();
|
||||
$controller = $request->getControllerName();
|
||||
$action = $request->getActionName();
|
||||
|
||||
if ($request->isXmlHttpRequest()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($module != 'legal') {
|
||||
return;
|
||||
}
|
||||
|
||||
Zend_Registry::get('firebug')->info('PLUGIN EXPORT - START');
|
||||
|
||||
$layout = Zend_Layout::getMVCInstance();
|
||||
if ($layout->isEnabled()) {
|
||||
$view = $layout->getView();
|
||||
|
||||
// Détecter variable activation export pour pdf
|
||||
if ($view->MenuPrint || $view->MenuPdf) {
|
||||
$html = $this->getResponse()->getBody();
|
||||
|
||||
$page = new Scores_Export_Print($controller, $action);
|
||||
$filename = $page->filename('pdf', $request->getParams());
|
||||
|
||||
$content = preg_replace('@<link href="/@si','<link href="./',$html);
|
||||
$content = preg_replace('@src="/@si','src="./',$content);
|
||||
|
||||
$c = Zend_Registry::get('config');
|
||||
file_put_contents($c->profil->path->shared.'/temp/pages/'.$filename.'.html', $content);
|
||||
}
|
||||
|
||||
// Détecter variable activation export xml
|
||||
$user = new Scores_Utilisateur();
|
||||
if ($view->MenuXml && in_array($user->getIdClient(), array(1,147))) {
|
||||
$page = new Scores_Export_Print($controller, $action);
|
||||
if ($page->exportable('xml') && !empty($view->exportObjet)) {
|
||||
$page->objectToXML($view->exportObjet, $request->getParams());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Zend_Registry::get('firebug')->info('PLUGIN EXPORT - END');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user