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.         $strFile "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.         {
  52.             header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  53.             header("Pragma: public");
  54.         }
  55.         else
  56.         {
  57.             header('Content-Disposition: attachment; filename="'.$strFile.'"');
  58.         }
  59.  
  60.         readfile($strPDFURL);
  61.     }
  62.     
  63.     /**
  64.     * Not used by this proxy.
  65.     * 
  66.     * @return void 
  67.     */
  68.     public function getLayers()
  69.     {
  70.         return;
  71.     }
  72.  
  73.     /**
  74.     * Get the resources from the 'spec' object.  At the same time, get all
  75.     *     the requested 'layers' as well and the resources according 'services'
  76.     *     that are going to be used to render the images to print.
  77.     *
  78.     * @param org_geoprisma_config_Config &$pobjConfig The config object.
  79.     *
  80.     * @return array of org_geoprisma_resource_Resource objects
  81.     */
  82.     public function getResourcesFromRequest(&$pobjConfig)
  83.     {
  84.         $objArrayResources Array();
  85.  
  86.         if (!session_id()) 
  87.         {
  88.             session_start();
  89.         }
  90.  
  91.         if (!isset($_REQUEST)) 
  92.         {
  93.             throw new com_borealis_foundation_exception_AssertException(
  94.                 "Request is not set"
  95.             );
  96.         }
  97.         else if (!isset($_REQUEST['osmfile'])) 
  98.         {
  99.             throw new com_borealis_foundation_exception_AssertException(
  100.                 "'file' param is not set"
  101.             );
  102.         }
  103.         else if (!isset($_SESSION)) 
  104.         {
  105.             throw new com_borealis_foundation_exception_AssertException(
  106.                 "Session is not set"
  107.             );
  108.         }
  109.         else if (!isset($_SESSION[$_REQUEST['osmfile']])) 
  110.         {
  111.             throw new com_borealis_foundation_exception_AssertException(
  112.                 "Specified file not found in session"
  113.             );
  114.         }
  115.  
  116.         $this->setPDFURL($_SESSION[$_REQUEST['osmfile']]['url']);
  117.         $objArrayResourceNames $_SESSION[$_REQUEST['osmfile']]['resources'];
  118.  
  119.         foreach ($objArrayResourceNames as $strRessourceName
  120.         {
  121.             array_push(
  122.                 $objArrayResources,
  123.                 $pobjConfig->getResource($strRessourceName)
  124.             );
  125.         }
  126.  
  127.         return $objArrayResources;
  128.     }
  129.  
  130.     /**
  131.     * Not used by this proxy.
  132.     *
  133.     * @return void 
  134.     */
  135.     public function validateResourcesFromRequest(
  136.     {
  137.         return;
  138.     }
  139.  
  140.     /**
  141.     * Not used by this proxy.
  142.     *
  143.     * @return void 
  144.     */
  145.     public function validateLayersFromRequest()
  146.     {
  147.         return;
  148.     }
  149.  
  150.     /**
  151.     * Set pdf file url
  152.     *
  153.     * @param string $pstrURL url of the pdf
  154.     *
  155.     * @return void 
  156.     */
  157.     public function setPDFURL($pstrURL)
  158.     {
  159.         $this->m_PDFURL $pstrURL;
  160.     }
  161.  
  162.     /**
  163.     * Get pdf file url
  164.     *
  165.     * @return String 
  166.     */
  167.     public function getPDFURL()
  168.     {
  169.         return $this->m_PDFURL;
  170.     }
  171.  
  172. ?>

Documentation generated on Mon, 20 Feb 2012 13:46:25 -0500 by phpDocumentor 1.4.1