extranet/library/Scores/PagePrint.php
2011-04-29 07:49:05 +00:00

67 lines
1.3 KiB
PHP

<?php
class PagePrint
{
protected $controller = null;
protected $action = null;
protected $pagePRINT = array(
'identite-fiche' => 'siret,id',
);
protected $pagePDF = array(
'identite-fiche' => 'siret,id',
);
protected $pageXML = array(
'identite-fiche' => 'siret,id',
);
public function __construct($controller, $action)
{
$this->controller = $controller;
$this->action = $action;
}
protected function getTypeElement($type)
{
$element = array();
switch($type){
case 'print':
$element = $this->pagePRINT;
break;
case 'pdf':
$element = $this->pagePDF;
break;
case 'xml':
$element = $this->pageXML;
break;
}
return $element;
}
public function exportable($type)
{
$element = $this->getTypeElement($type);
if (array_key_exists($this->controller.'-'.$this->action, $element)){
return true;
}
return false;
}
public function filename($type, $params)
{
$element = $this->getTypeElement($type);
$filename = $this->controller.'-'.$this->action;
$key = $this->controller.'-'.$this->action;
if (array_key_exists($key, $element)){
$part = explode(',', $element[$key]);
foreach( $part as $item ){
if (!empty($params[$item])){
$filename.= '-'.$params[$item];
}
}
}
return $filename;
}
}