public function render() { $this->initializeUrl(); $this->getCurrentOffset(); $pageLinks = array(); if (empty($this->range)) { for ($i = 1; $i <= $this->numberOfPages; ++$i) { $pageLinks[] = $i != $this->currentOffset ? \vxPHP\Template\SimpleTemplate::a($this->urlFragment . $i, $i) : "<span class='currentPage'>{$i}</span>"; } if (is_string($separator)) { return implode($separator, $pageLinks); } if (is_array($separator) && count($separator) == 5) { return implode($separator[2], $pageLinks); } return implode(' | ', $pageLinks); } else { } }
/** * create response * with a HttpException status code and headers are considered * other exceptions default to status code 500 * a error_docs/error_{status_code}.php template is parsed, when found * otherwise the exception data is decorated and dumped * * @param \Exception $e * @return \vxPHP\Http\Response */ protected function createResponse(\Exception $e) { if ($e instanceof HttpException) { $status = $e->getStatusCode(); $headers = $e->getHeaders(); } else { $status = Response::HTTP_INTERNAL_SERVER_ERROR; $headers = array(); } $config = Application::getInstance()->getConfig(); if (isset($config->paths['tpl_path'])) { $path = ($config->paths['tpl_path']['absolute'] ? '' : rtrim(Application::getInstance()->getRootPath(), DIRECTORY_SEPARATOR)) . $config->paths['tpl_path']['subdir']; if (file_exists($path . 'error_docs' . DIRECTORY_SEPARATOR . 'error_' . $status . '.php')) { $tpl = SimpleTemplate::create('error_docs' . DIRECTORY_SEPARATOR . 'error_' . $status . '.php'); $content = $tpl->assign('exception', $e)->assign('status', $status)->display(); } else { $content = $this->decorateException($e, $status); } } else { $content = $this->decorateException($e, $status); } return new Response($content, $status, $headers); }
/** * explicitly insert template at $blockName position * * @param SimpleTemplate $childTemplate * @param string $blockName * @return SimpleTemplate */ public function insertTemplateAt(SimpleTemplate $childTemplate, $blockName) { $blockRegExp = '~<!--\\s*\\{\\s*block\\s*:\\s*' . $blockName . '\\s*\\}\\s*-->~'; if (preg_match($blockRegExp, $this->rawContents)) { $this->rawContents = preg_replace($blockRegExp, $childTemplate->getRawContents(), $this->rawContents); } else { throw new SimpleTemplateException("Could not insert child template at '{$blockName}'.", SimpleTemplateException::TEMPLATE_INVALID_NESTING); } return $this; }