M src/Web/Tpl.php => src/Web/Tpl.php +13 -70
@@ 140,7 140,7 @@ class Tpl
*
* @return string
*/
- private function getAssetUrl($requestRoot, $assetPath)
+ public function getAssetUrl($requestRoot, $assetPath)
{
if (false === $mTime = @\filemtime($this->assetDir.'/'.$assetPath)) {
// can't find file or determine last modified time, do not include
@@ 156,7 156,7 @@ class Tpl
*
* @return string
*/
- private static function languageCodeToHuman($languageCode)
+ public static function languageCodeToHuman($languageCode)
{
$implementedLocales = self::getImplementedLocales();
if (!\array_key_exists($languageCode, $implementedLocales)) {
@@ 169,7 169,7 @@ class Tpl
/**
* @return array<string,string>
*/
- private static function getImplementedLocales()
+ public static function getImplementedLocales()
{
return [
'en-US' => 'English',
@@ 178,22 178,11 @@ class Tpl
}
/**
- * @param string $templateName
- * @param array<string,mixed> $templateVariables
- *
- * @return string
- */
- private function insert($templateName, array $templateVariables = [])
- {
- return $this->render($templateName, $templateVariables);
- }
-
- /**
* @param string $sectionName
*
* @return void
*/
- private function start($sectionName)
+ public function start($sectionName)
{
if (null !== $this->activeSectionName) {
throw new TplException(\sprintf('section "%s" already started', $this->activeSectionName));
@@ 208,7 197,7 @@ class Tpl
*
* @return void
*/
- private function stop($sectionName)
+ public function stop($sectionName)
{
if (null === $this->activeSectionName) {
throw new TplException('no section started');
@@ 231,7 220,7 @@ class Tpl
*
* @return void
*/
- private function layout($layoutName, array $templateVariables = [])
+ public function layout($layoutName, array $templateVariables = [])
{
$this->layoutList[$layoutName] = $templateVariables;
}
@@ 241,7 230,7 @@ class Tpl
*
* @return string
*/
- private function section($sectionName)
+ public function section($sectionName)
{
if (!\array_key_exists($sectionName, $this->sectionList)) {
throw new TplException(\sprintf('section "%s" does not exist', $sectionName));
@@ 251,54 240,25 @@ class Tpl
}
/**
- * @param string $v
- * @param string|null $cb
+ * @param mixed $v
*
* @return string
*/
- private function e($v, $cb = null)
+ public function e($v)
{
- if (null !== $cb) {
- $v = $this->batch($v, $cb);
+ if (is_scalar($v) || (is_object($v) && method_exists($v, '__toString'))) {
+ return \htmlentities((string) $v, \ENT_QUOTES | \ENT_SUBSTITUTE, 'UTF-8');
}
- return \htmlentities($v, \ENT_QUOTES | \ENT_SUBSTITUTE, 'UTF-8');
+ throw new TplException(sprintf('unable to cast "%s" to string', gettype($v)));
}
/**
* @param string $v
- * @param string $cb
*
* @return string
*/
- private function batch($v, $cb)
- {
- $functionList = \explode('|', $cb);
- foreach ($functionList as $f) {
- if ('escape' === $f) {
- $v = $this->e($v);
-
- continue;
- }
- if (\array_key_exists($f, $this->callbackList)) {
- $f = $this->callbackList[$f];
- } else {
- if (!\function_exists($f)) {
- throw new TplException(\sprintf('function "%s" does not exist', $f));
- }
- }
- $v = \call_user_func($f, $v);
- }
-
- return $v;
- }
-
- /**
- * @param string $v
- *
- * @return string
- */
- private function t($v)
+ public function t($v)
{
// use original, unless it is found in any of the translation files...
$translatedText = $v;
@@ 334,23 294,6 @@ class Tpl
/**
* @param string $templateName
*
- * @return bool
- */
- private function exists($templateName)
- {
- foreach ($this->templateFolderList as $templateFolder) {
- $templatePath = \sprintf('%s/%s.php', $templateFolder, $templateName);
- if (\file_exists($templatePath)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * @param string $templateName
- *
* @return string
*/
private function templatePath($templateName)
M views/base.php => views/base.php +6 -1
@@ 1,3 1,8 @@
+<?php declare(strict_types=1); ?>
+<?php /** @var \fkooman\SAML\SP\Web\Tpl $this */ ?>
+<?php /** @var string $requestRoot */ ?>
+<?php /** @var string $serviceName */ ?>
+<?php /** @var array<string> $enabledLanguages */ ?>
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
@@ 13,7 18,7 @@
<?php if (1 < \count($enabledLanguages)): ?>
<form method="post" action="setLanguage">
<?php foreach ($enabledLanguages as $uiLanguage): ?>
- <button type="submit" name="uiLanguage" value="<?=$this->e($uiLanguage); ?>"><?=$this->e($uiLanguage, 'language_code_to_human'); ?></button>
+ <button type="submit" name="uiLanguage" value="<?=$this->e($uiLanguage); ?>"><?=$this->languageCodeToHuman($uiLanguage); ?></button>
<?php endforeach; ?>
</form>
<?php endif; ?>
M views/error.php => views/error.php +3 -0
@@ 1,3 1,6 @@
+<?php declare(strict_types=1); ?>
+<?php /** @var \fkooman\SAML\SP\Web\Tpl $this */ ?>
+<?php /** @var \fkooman\SAML\SP\Web\Exception\HttpException $e */ ?>
<?php $this->layout('base'); ?>
<?php $this->start('content'); ?>
<h2><?=$this->t('Error'); ?></h2>
M views/index.php => views/index.php +6 -0
@@ 1,3 1,9 @@
+<?php declare(strict_types=1); ?>
+<?php /** @var \fkooman\SAML\SP\Web\Tpl $this */ ?>
+<?php /** @var string $metadataUrl */ ?>
+<?php /** @var string $samlMetadata */ ?>
+<?php /** @var bool $decryptionSupport */ ?>
+<?php /** @var bool $mbFuncOverload */ ?>
<?php $this->layout('base'); ?>
<?php $this->start('content'); ?>
<h2><?=$this->t('Welcome'); ?></h2>
M views/info.php => views/info.php +4 -0
@@ 1,3 1,7 @@
+<?php declare(strict_types=1); ?>
+<?php /** @var \fkooman\SAML\SP\Web\Tpl $this */ ?>
+<?php /** @var string $logoutReturnTo */ ?>
+<?php /** @var \fkooman\SAML\SP\Assertion $samlAssertion */ ?>
<?php $this->layout('base'); ?>
<?php $this->start('content'); ?>
<h2><?=$this->t('Assertion'); ?></h2>
M views/wayf.php => views/wayf.php +4 -0
@@ 1,3 1,7 @@
+<?php declare(strict_types=1); ?>
+<?php /** @var \fkooman\SAML\SP\Web\Tpl $this */ ?>
+<?php /** @var ?\fkooman\SAML\SP\IdpInfo $lastChosenIdpInfo */ ?>
+<?php /** @var array<string,\fkooman\SAML\SP\IdpInfo> $idpInfoList */ ?>
<?php $this->layout('base'); ?>
<?php $this->start('content'); ?>
<p>