示例#1
0
 protected function render($opts, PluggableViewInterface $view)
 {
     $templater = $view->getPluginTemplater();
     $base_content = array('options' => $opts);
     $content = $this->provideContent($view);
     $content['js_templates'] = $view->getJSTemplates($this->config['view'], $templater->getLoader(), "{$this->name}/partial");
     $content = isset($content) ? array_merge($base_content, $content) : $base_content;
     return $templater->render("{$this->name}/main", $content);
 }
示例#2
0
 protected function provideContent(PluggableViewInterface $view)
 {
     $formats = array();
     $orders = array();
     $units = array();
     foreach ($this->services as $name => $s) {
         $formats[$name] = isset($s['format']) ? $s['format'] : 'json';
         $orders[$name] = isset($s['order']) ? $s['order'] : null;
         $units[$name] = isset($s['unit']) ? $s['unit'] : 'item';
     }
     $formats = json_encode($formats);
     $orders = json_encode($orders);
     $units = json_encode($units);
     $options = array();
     foreach ($this->config['options'] as $key => $value) {
         $options[Inflector::camelize($key)] = $value;
     }
     $options = json_encode($options);
     $view->addPluginSnippet("Silexhibit.ExternalData.FEED_FORMATS = {$formats};\n" . "Silexhibit.ExternalData.FEED_ORDERS = {$orders};\n" . "Silexhibit.ExternalData.FEED_UNITS = {$units};\n" . "jQuery.extend(Silexhibit.ExternalData.options, {$options});");
     return array();
 }