/** * Obtains the cached HTML of a form and generates it if missing * * @param Form $form * * @return string */ public function getContent(Form $form) { $cachedHtml = $form->getCachedHtml(); if (empty($cachedHtml)) { $cachedHtml = $this->generateHtml($form); } return $cachedHtml; }
/** * {@inheritDoc} */ public function getCachedHtml() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCachedHtml', array()); return parent::getCachedHtml(); }
/** * Obtains the cached HTML of a form and generates it if missing * * @param Form $form * @param bool|true $withScript * @param bool|true $useCache * * @return string */ public function getContent(Form $form, $withScript = true, $useCache = true) { if ($useCache) { $cachedHtml = $form->getCachedHtml(); } if (empty($cachedHtml)) { $cachedHtml = $this->generateHtml($form, $useCache); } if ($withScript) { $cachedHtml = $this->getFormScript($form) . "\n\n" . $cachedHtml; } return $cachedHtml; }
/** * Get the document write javascript for the form * * @param Form $form * @return string */ public function getAutomaticJavascript(Form $form) { $html = $form->getCachedHtml(); //replace line breaks with literal symbol and escape quotations $search = array("\n", '"'); $replace = array('\\n', '\\"'); $html = str_replace($search, $replace, $html); return "document.write(\"" . $html . "\");"; }