Overview

Namespaces

  • Mapbender
    • Component
      • HTTP
    • CoreBundle
      • Command
      • Component
        • Exception
      • Controller
      • DataFixtures
        • ORM
      • DependencyInjection
      • Element
        • Type
      • Entity
      • EventListener
      • Extension
      • Form
        • DataTransformer
        • EventListener
        • Type
      • Security
      • Template
    • DrupalIntegrationBundle
      • DependencyInjection
      • Security
        • Authentication
          • Provider
          • Token
        • Authorization
          • Voter
        • Factory
        • Firewall
        • User
      • Session
    • KmlBundle
      • Element
    • ManagerBundle
      • Controller
      • Form
        • DataTransformer
        • Type
    • MonitoringBundle
      • Command
      • Component
      • Controller
      • DependencyInjection
      • Entity
      • EventListener
      • Form
    • PrintBundle
      • Component
      • Controller
    • WmcBundle
      • Component
        • Exception
      • Element
        • Type
      • Entity
      • Form
        • EventListener
        • Type
    • WmsBundle
      • Component
        • Exception
      • Controller
      • DependencyInjection
      • Element
        • Type
      • Entity
      • Event
      • Form
        • EventListener
        • Type
    • WmtsBundle
      • Component
        • Exception
      • Controller
      • Entity
      • Form
        • Type
  • None
  • PHP

Classes

  • AboutDialog
  • ActivityIndicator
  • Button
  • CoordinatesDisplay
  • Copyright
  • FeatureInfo
  • GpsPosition
  • Layertree
  • Legend
  • Map
  • Overview
  • PrintClient
  • Ruler
  • ScaleBar
  • ScaleDisplay
  • ScaleSelector
  • SearchRouter
  • SrsSelector
  • ZoomBar
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download
  1: <?php
  2: 
  3: namespace Mapbender\CoreBundle\Element;
  4: 
  5: use Mapbender\CoreBundle\Component\Element;
  6: use Symfony\Component\HttpFoundation\Response;
  7: use Mapbender\PrintBundle\Component\OdgParser;
  8: 
  9: /**
 10:  * 
 11:  */
 12: class PrintClient extends Element
 13: {
 14: 
 15:     /**
 16:      * @inheritdoc
 17:      */
 18:     static public function getClassTitle()
 19:     {
 20:         return "Print Client";
 21:     }
 22: 
 23:     /**
 24:      * @inheritdoc
 25:      */
 26:     static public function getClassDescription()
 27:     {
 28:         return "Renders a Print dialog";
 29:     }
 30: 
 31:     /**
 32:      * @inheritdoc
 33:      */
 34:     static public function getClassTags()
 35:     {
 36:         return array('Print');
 37:     }
 38: 
 39:     /**
 40:      * @inheritdoc
 41:      */
 42:     public function getAssets()
 43:     {
 44:         return array('js' => array('mapbender.element.printClient.js'),'css' => array());
 45:     }
 46: 
 47: //    /**
 48: //     * @inheritdoc
 49: //     */
 50: //    public static function getDefaultConfiguration()
 51: //    {
 52: //        return array(
 53: //            "target" => null,
 54: //            "autoOpen" => false,
 55: //            "print_directly" => true,
 56: //            "templates" => array(
 57: //                "a4portrait" => array(
 58: //                    "label" => "A4 Portrait",
 59: //                    "format" => "a4"),
 60: //                "a4landscape" => array(
 61: //                    "label" => "A4 Landscape",
 62: //                    "format" => "a4"),
 63: //                "a3portrait" => array(
 64: //                    "label" => "A3 Portrait",
 65: //                    "format" => "a3"),
 66: //                "a3landscape" => array(
 67: //                    "label" => "A3 Landscape",
 68: //                    "format" => "a3")),
 69: //            "scales" => array(500, 1000, 5000, 10000, 25000),
 70: //            "quality_levels" => array("72" => "Entwurf", "288" => "Document"),
 71: //            "rotatable" => true,
 72: //            "optional_fields" => null
 73: //        );
 74: //    }
 75: 
 76:     /**
 77:      * @inheritdoc
 78:      */
 79:     public static function getDefaultConfiguration()
 80:     {
 81:         return array(
 82:             "target" => null,
 83:             "autoOpen" => false,
 84:             "print_directly" => true,
 85:             "templates" => array(
 86:                 array(
 87:                     'template' => "a4portrait",
 88:                     "label" => "A4 Portrait",
 89:                     "format" => "a4")
 90:                 ,
 91:                 array(
 92:                     'template' => "a4landscape",
 93:                     "label" => "A4 Landscape",
 94:                     "format" => "a4")
 95:                 ,
 96:                 array(
 97:                     'template' => "a3portrait",
 98:                     "label" => "A3 Portrait",
 99:                     "format" => "a3")
100:                 ,
101:                 array(
102:                     'template' => "a3landscape",
103:                     "label" => "A3 Landscape",
104:                     "format" => "a3")
105:             ),
106:             "scales" => array(500, 1000, 5000, 10000, 25000),
107:             "quality_levels" => array(array('dpi' => "72", 'label' => "Draft (72dpi)"),
108:                 array('dpi' => "288", 'label' => "Draft (288dpi)")),
109:             "rotatable" => true,
110:             "optional_fields" => null
111:         );
112:     }
113:     
114:     /**
115:      * @inheritdoc
116:      */
117:     public function getConfiguration()
118:     {
119:         $config = parent::getConfiguration();
120:         if(isset($config["templates"])){
121:             $templates = array();
122:             foreach ($config["templates"] as $template) {
123:                 $templates[$template['template']] = $template;
124:             }
125:             $config["templates"] = $templates;
126:         }
127:         if(isset($config["quality_levels"])){
128:             $levels = array();
129:             foreach ($config["quality_levels"] as $level) {
130:                 $levels[$level['dpi']] = $level['label'];
131:             }
132:             $config["quality_levels"] = $levels;
133:         }
134:         return $config;
135:     }
136:     
137:     /**
138:      * @inheritdoc
139:      */
140:     public static function getType()
141:     {
142:         return 'Mapbender\CoreBundle\Element\Type\PrintClientAdminType';
143:     }    
144:     
145:     /**
146:      * @inheritdoc
147:      */
148:     public static function getFormTemplate()
149:     {
150:         return 'MapbenderCoreBundle:ElementAdmin:printclient.html.twig';
151:     }
152:     
153:     /**
154:      * @inheritdoc
155:      */
156:     public function getWidgetName()
157:     {
158:         return 'mapbender.mbPrintClient';
159:     }
160: 
161:     /**
162:      * @inheritdoc
163:      */
164:     public function render()
165:     {
166:         return $this->container->get('templating')
167:                         ->render('MapbenderCoreBundle:Element:printclient.html.twig', 
168:                         array(
169:                             'id' => $this->getId(),
170:                             'title' => $this->getTitle(),
171:                             'configuration' => $this->getConfiguration()
172:                         ));
173:     }
174: 
175:     /**
176:      * @inheritdoc
177:      */
178:     public function httpAction($action) {
179:         switch ($action) {
180:             case 'direct':
181: 
182:                 $request = $this->container->get('request');
183:                 $data = $request->request->all();
184: 
185:                 foreach ($request->request->keys() as $key) {
186:                     $request->request->remove($key);
187:                 }
188:                 // keys, remove
189:                 foreach ($data['layers'] as $idx => $layer) {
190:                     $data['layers'][$idx] = json_decode($layer, true);
191:                 }
192:                 $content = json_encode($data);
193: 
194:                 // Forward to Printer Service URL using OWSProxy
195:                 $configuration = $this->getConfiguration();
196:                 $url = $this->container->get('router')->generate('mapbender_print_print_service', array(), true);
197: 
198:                 return $this->container->get('http_kernel')->forward(
199:                                 'OwsProxy3CoreBundle:OwsProxy:genericProxy', array(
200:                             'url' => $url,
201:                             'content' => $content
202:                                 )
203:                 );
204: 
205:             case 'queued':
206:                 // NYI
207:                 
208: //                $content = $this->container->get('request')->getContent();
209: //                if (empty($content)) {
210: //                    throw new \RuntimeException('No Request Data received');
211: //                }
212: //
213: //                // Forward to Printer Service URL using OWSProxy
214: //                $configuration = $this->getConfiguration();
215: //                $url = (null !== $configuration['printer']['service'] ?
216: //                                $configuration['printer']['service'] :
217: //                                $this->container->get('router')->generate('mapbender_print_print_service', array(), true));
218: //                return $this->container->get('http_kernel')->forward(
219: //                                'OwsProxy3CoreBundle:OwsProxy:genericProxy', array(
220: //                            'url' => $url,
221: //                            'content' => $content
222: //                                )
223: //                );
224:             case 'template':
225:                 $response = new Response();
226:                 $response->headers->set('Content-Type', 'application/json');
227:                 $request = $this->container->get('request');
228:                 $data = json_decode($request->getContent(), true);
229:                 $container = $this->container;
230:                 $odgParser = new OdgParser($container);
231:                 $size = $odgParser->getMapSize($data['template']);
232:                 $response->setContent($size->getContent());
233:                 return $response;
234:         }
235:     }
236: }
237: 
Mapbender3 API documenation API documentation generated by ApiGen 2.8.0