/** * @return Template */ protected function createTemplate($file = null) { $template = new Template($file); $template->baseUrl = \Nette\Environment::getHttpRequest()->url->baseUrl; $template->basePath = rtrim($template->baseUrl, '/'); $template->interface = $this; $template->registerHelperLoader('Nette\\Templating\\Helpers::loader'); return $template; }
/** * Generates control * @return Html */ public function getControl() { $this->setOption('rendered', TRUE); // Create control $control = Html::el('div class=MultipleFileUpload')->id($this->getHtmlId()); // <section token field> $tokenField = Html::el('input type=hidden')->name($this->getHtmlName() . '[token]')->value($this->getToken()); $control->add($tokenField); // </section token field> $fallbacks = array(); $interfaces = self::getUIRegistrator()->getInterfaces(); $num = count($interfaces); $cnt = 1; foreach ($interfaces as $interface) { $html = $interface->render($this); $init = $interface->renderInitJavaScript($this); $desctruct = $interface->renderDestructJavaScript($this); $id = $this->getHtmlId() . "-MFUInterface-" . $interface->reflection->name; $fallback = (object) array("id" => $id, "init" => $init, "destruct" => $desctruct); $fallbacks[] = $fallback; $container = Html::el("div"); $container->setHtml($html); $container->id = $id; if ($cnt == $num) { // Last (will be rendered as JavaScript-disabled capable) $container->style["display"] = "block"; } else { $container->style["display"] = "none"; } $cnt++; $control->add($container); } $template = new UI\Template(); $template->setFile(dirname(__FILE__) . DIRECTORY_SEPARATOR . "RegisterJS.latte"); $template->id = $this->getHtmlId(); $template->fallbacks = $fallbacks; $control->add($template->__toString(TRUE)); /* // <section without JavaScript> $withoutJS = Html::el("div class=withoutJS"); $standardFileInput = Html::el("input type=file") ->name($this->getHtmlName() . '[files][]'); $withoutJS->add($this->createSectionWithoutJS($standardFileInput)); $control->add($withoutJS); // </section without JavaScript> // <section with JavaScript> $withJS = Html::el("div class=withJS"); $uploadifyID = $this->getHtmlId() . "-uploadifyBox"; $withJS->add($this->createSectionWithJS($uploadifyID, $this->getToken())); $control->add($withJS); // </section with JavaScript> */ // Pokud už byla volána metoda handleUploads - /* if(self::$handleUploadsCheck){ $control->add(Html::el('script type=text/javascript')->add( 'jQuery("#' . $uploadifyID . '").uploadify(' . json_encode($this->uploaderOptions) . ');' )); }; */ return $control; }