Source for file MapFishPrintGetFileProxy.php

Documentation is available at MapFishPrintGetFileProxy.php

  1. <?php
  2. /**
  3. * Proxy of MapFishPrint type
  4. *
  5. * PHP versions 5
  6. @category  PHP
  7. @package   GeoPrisma
  8. @author    Alexandre Dube
  9. @copyright 2011, Boreal - Information Strategies
  10. @license   http://www.geoprisma.org/license BSD License
  11. @link      http://www.geoprisma.org
  12. */
  13.  
  14. /**
  15. * Proxy of MapFishPrint type
  16. @category   PHP
  17. @package    GeoPrisma
  18. @subpackage Proxy
  19. @author     Alexadnre Dube
  20. */     
  21. {
  22.     /**
  23.     * @var String 
  24.     */
  25.     private $m_strPDFURL null;
  26.  
  27.     /**
  28.     * Get the action this proxy does.
  29.     *                                   
  30.     * @return string 
  31.     */
  32.     public function getAction()
  33.     {
  34.         return self::CRUD_READ;    
  35.     }
  36.  
  37.     /**
  38.     * Forward the call end return the result
  39.     * 
  40.     * @return void 
  41.     */
  42.     public function process()
  43.     {
  44.         $strPDFURL $this->getPDFURL();
  45.         $fileName "map.pdf";
  46.         header("Content-Transfer-Encoding: Binary");
  47.         header('Content-type: application/pdf');
  48.         
  49.         // work around IE6/7/8 bug with download of PDF files over https
  50.         if((strstr($_SERVER["HTTP_USER_AGENT"],"MSIE")==false)) {
  51.             header("Cache-Control: must-revalidate, post-check=0, pre-check=0")
  52.             header("Pragma: public");
  53.         else {
  54.             header('Content-Disposition: attachment; filename="'.$fileName.'"');
  55.         }
  56.  
  57.         readfile($strPDFURL);
  58.     }
  59.     
  60.     /**
  61.     * Not used by this proxy.
  62.     * 
  63.     * @return void 
  64.     */
  65.     public function getLayers()
  66.     {
  67.         return;
  68.     }
  69.  
  70.     /**
  71.     * Get the resources from the 'spec' object.  At the same time, get all
  72.     *     the requested 'layers' as well and the resources according 'services'
  73.     *     that are going to be used to render the images to print.
  74.     *
  75.     * @param org_geoprisma_config_Config &$pobjConfig The config object.
  76.     *
  77.     * @return array of org_geoprisma_resource_Resource objects
  78.     */
  79.     public function getResourcesFromRequest(&$pobjConfig)
  80.     {
  81.         $objArrayResources Array();
  82.  
  83.         if (!session_id()) 
  84.         {
  85.             session_start();
  86.         }
  87.  
  88.         if (!isset($_REQUEST)) 
  89.         {
  90.             throw new com_borealis_foundation_exception_AssertException(
  91.                 "Request is not set"
  92.             );
  93.         }
  94.         else if (!isset($_REQUEST['osmfile'])) 
  95.         {
  96.             throw new com_borealis_foundation_exception_AssertException(
  97.                 "'file' param is not set"
  98.             );
  99.         }
  100.         else if (!isset($_SESSION)) 
  101.         {
  102.             throw new com_borealis_foundation_exception_AssertException(
  103.                 "Session is not set"
  104.             );
  105.         }
  106.         else if (!isset($_SESSION[$_REQUEST['osmfile']])) 
  107.         {
  108.             throw new com_borealis_foundation_exception_AssertException(
  109.                 "Specified file not found in session"
  110.             );
  111.         }
  112.  
  113.         $this->setPDFURL($_SESSION[$_REQUEST['osmfile']]['url']);
  114.         $objArrayResourceNames $_SESSION[$_REQUEST['osmfile']]['resources'];
  115.  
  116.         foreach ($objArrayResourceNames as $strRessourceName
  117.         {
  118.             array_push(
  119.                 $objArrayResources,
  120.                 $pobjConfig->getResource($strRessourceName)
  121.             );
  122.         }
  123.  
  124.         return $objArrayResources;
  125.     }
  126.  
  127.     /**
  128.     * Not used by this proxy.
  129.     *
  130.     * @return void 
  131.     */
  132.     public function validateResourcesFromRequest(
  133.     {
  134.         return;
  135.     }
  136.  
  137.     /**
  138.     * Not used by this proxy.
  139.     *
  140.     * @return void 
  141.     */
  142.     public function validateLayersFromRequest()
  143.     {
  144.         return;
  145.     }
  146.  
  147.     /**
  148.     * Set pdf file url
  149.     *
  150.     * @param string $pstrURL url of the pdf
  151.     *
  152.     * @return void 
  153.     */
  154.     public function setPDFURL($pstrURL)
  155.     {
  156.         $this->m_PDFURL $pstrURL;
  157.     }
  158.  
  159.     /**
  160.     * Get pdf file url
  161.     *
  162.     * @return String 
  163.     */
  164.     public function getPDFURL()
  165.     {
  166.         return $this->m_PDFURL;
  167.     }
  168.  
  169. ?>

Documentation generated on Thu, 19 Jan 2012 00:08:39 +0400 by phpDocumentor 1.4.1