@@ -16,91 +16,91 @@ |
||
| 16 | 16 | |
| 17 | 17 | trait TemplateOutput |
| 18 | 18 | { |
| 19 | - /** @var Smarty */ |
|
| 20 | - private $smarty; |
|
| 19 | + /** @var Smarty */ |
|
| 20 | + private $smarty; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @return SiteConfiguration |
|
| 24 | - */ |
|
| 25 | - protected abstract function getSiteConfiguration(); |
|
| 22 | + /** |
|
| 23 | + * @return SiteConfiguration |
|
| 24 | + */ |
|
| 25 | + protected abstract function getSiteConfiguration(); |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Assigns a Smarty variable |
|
| 29 | - * |
|
| 30 | - * @param array|string $name the template variable name(s) |
|
| 31 | - * @param mixed $value the value to assign |
|
| 32 | - */ |
|
| 33 | - final protected function assign($name, $value) |
|
| 34 | - { |
|
| 35 | - $this->smarty->assign($name, $value); |
|
| 36 | - } |
|
| 27 | + /** |
|
| 28 | + * Assigns a Smarty variable |
|
| 29 | + * |
|
| 30 | + * @param array|string $name the template variable name(s) |
|
| 31 | + * @param mixed $value the value to assign |
|
| 32 | + */ |
|
| 33 | + final protected function assign($name, $value) |
|
| 34 | + { |
|
| 35 | + $this->smarty->assign($name, $value); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Sets up the variables used by the main Smarty base template. |
|
| 40 | - * |
|
| 41 | - * This list is getting kinda long. |
|
| 42 | - */ |
|
| 43 | - final protected function setUpSmarty() |
|
| 44 | - { |
|
| 45 | - $this->smarty = new Smarty\Smarty(); |
|
| 46 | - $this->smarty->addPluginsDir($this->getSiteConfiguration()->getFilePath() . '/smarty-plugins'); |
|
| 38 | + /** |
|
| 39 | + * Sets up the variables used by the main Smarty base template. |
|
| 40 | + * |
|
| 41 | + * This list is getting kinda long. |
|
| 42 | + */ |
|
| 43 | + final protected function setUpSmarty() |
|
| 44 | + { |
|
| 45 | + $this->smarty = new Smarty\Smarty(); |
|
| 46 | + $this->smarty->addPluginsDir($this->getSiteConfiguration()->getFilePath() . '/smarty-plugins'); |
|
| 47 | 47 | |
| 48 | - $this->assign('currentUser', User::getCommunity()); |
|
| 49 | - $this->assign('skin', 'auto'); |
|
| 50 | - $this->assign('currentDomain', null); |
|
| 51 | - $this->assign('loggedIn', false); |
|
| 52 | - $this->assign('baseurl', $this->getSiteConfiguration()->getBaseUrl()); |
|
| 53 | - $this->assign('resourceCacheEpoch', $this->getSiteConfiguration()->getResourceCacheEpoch()); |
|
| 48 | + $this->assign('currentUser', User::getCommunity()); |
|
| 49 | + $this->assign('skin', 'auto'); |
|
| 50 | + $this->assign('currentDomain', null); |
|
| 51 | + $this->assign('loggedIn', false); |
|
| 52 | + $this->assign('baseurl', $this->getSiteConfiguration()->getBaseUrl()); |
|
| 53 | + $this->assign('resourceCacheEpoch', $this->getSiteConfiguration()->getResourceCacheEpoch()); |
|
| 54 | 54 | |
| 55 | - $this->assign('siteNoticeText', ''); |
|
| 56 | - $this->assign('siteNoticeVersion', 0); |
|
| 57 | - $this->assign('siteNoticeState', 'd-none'); |
|
| 58 | - $this->assign('toolversion', Environment::getToolVersion()); |
|
| 55 | + $this->assign('siteNoticeText', ''); |
|
| 56 | + $this->assign('siteNoticeVersion', 0); |
|
| 57 | + $this->assign('siteNoticeState', 'd-none'); |
|
| 58 | + $this->assign('toolversion', Environment::getToolVersion()); |
|
| 59 | 59 | |
| 60 | - // default these |
|
| 61 | - $this->assign('onlineusers', array()); |
|
| 62 | - $this->assign('typeAheadBlock', ''); |
|
| 63 | - $this->assign('extraJs', array()); |
|
| 60 | + // default these |
|
| 61 | + $this->assign('onlineusers', array()); |
|
| 62 | + $this->assign('typeAheadBlock', ''); |
|
| 63 | + $this->assign('extraJs', array()); |
|
| 64 | 64 | |
| 65 | - // nav menu access control |
|
| 66 | - $this->assign('nav__canRequests', false); |
|
| 67 | - $this->assign('nav__canLogs', false); |
|
| 68 | - $this->assign('nav__canUsers', false); |
|
| 69 | - $this->assign('nav__canSearch', false); |
|
| 70 | - $this->assign('nav__canStats', false); |
|
| 71 | - $this->assign('nav__canBan', false); |
|
| 72 | - $this->assign('nav__canEmailMgmt', false); |
|
| 73 | - $this->assign('nav__canWelcomeMgmt', false); |
|
| 74 | - $this->assign('nav__canSiteNoticeMgmt', false); |
|
| 75 | - $this->assign('nav__canUserMgmt', false); |
|
| 76 | - $this->assign('nav__canViewRequest', false); |
|
| 77 | - $this->assign('nav__canJobQueue', false); |
|
| 78 | - $this->assign('nav__canFlaggedComments', false); |
|
| 79 | - $this->assign('nav__canDomainMgmt', false); |
|
| 80 | - $this->assign('nav__canQueueMgmt', false); |
|
| 81 | - $this->assign('nav__canFormMgmt', false); |
|
| 82 | - $this->assign('nav__canErrorLog', false); |
|
| 65 | + // nav menu access control |
|
| 66 | + $this->assign('nav__canRequests', false); |
|
| 67 | + $this->assign('nav__canLogs', false); |
|
| 68 | + $this->assign('nav__canUsers', false); |
|
| 69 | + $this->assign('nav__canSearch', false); |
|
| 70 | + $this->assign('nav__canStats', false); |
|
| 71 | + $this->assign('nav__canBan', false); |
|
| 72 | + $this->assign('nav__canEmailMgmt', false); |
|
| 73 | + $this->assign('nav__canWelcomeMgmt', false); |
|
| 74 | + $this->assign('nav__canSiteNoticeMgmt', false); |
|
| 75 | + $this->assign('nav__canUserMgmt', false); |
|
| 76 | + $this->assign('nav__canViewRequest', false); |
|
| 77 | + $this->assign('nav__canJobQueue', false); |
|
| 78 | + $this->assign('nav__canFlaggedComments', false); |
|
| 79 | + $this->assign('nav__canDomainMgmt', false); |
|
| 80 | + $this->assign('nav__canQueueMgmt', false); |
|
| 81 | + $this->assign('nav__canFormMgmt', false); |
|
| 82 | + $this->assign('nav__canErrorLog', false); |
|
| 83 | 83 | |
| 84 | - // Navigation badges for concern areas. |
|
| 85 | - $this->assign("nav__numAdmin", 0); |
|
| 86 | - $this->assign("nav__numFlaggedComments", 0); |
|
| 87 | - $this->assign("nav__numJobQueueFailed", 0); |
|
| 84 | + // Navigation badges for concern areas. |
|
| 85 | + $this->assign("nav__numAdmin", 0); |
|
| 86 | + $this->assign("nav__numFlaggedComments", 0); |
|
| 87 | + $this->assign("nav__numJobQueueFailed", 0); |
|
| 88 | 88 | |
| 89 | - // debug helpers |
|
| 90 | - $this->assign('showDebugCssBreakpoints', $this->getSiteConfiguration()->getDebuggingCssBreakpointsEnabled()); |
|
| 89 | + // debug helpers |
|
| 90 | + $this->assign('showDebugCssBreakpoints', $this->getSiteConfiguration()->getDebuggingCssBreakpointsEnabled()); |
|
| 91 | 91 | |
| 92 | - $this->assign('page', $this); |
|
| 93 | - } |
|
| 92 | + $this->assign('page', $this); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Fetches a rendered Smarty template |
|
| 97 | - * |
|
| 98 | - * @param $template string Template file path, relative to /templates/ |
|
| 99 | - * |
|
| 100 | - * @return string Templated HTML |
|
| 101 | - */ |
|
| 102 | - final protected function fetchTemplate($template) |
|
| 103 | - { |
|
| 104 | - return $this->smarty->fetch($template); |
|
| 105 | - } |
|
| 95 | + /** |
|
| 96 | + * Fetches a rendered Smarty template |
|
| 97 | + * |
|
| 98 | + * @param $template string Template file path, relative to /templates/ |
|
| 99 | + * |
|
| 100 | + * @return string Templated HTML |
|
| 101 | + */ |
|
| 102 | + final protected function fetchTemplate($template) |
|
| 103 | + { |
|
| 104 | + return $this->smarty->fetch($template); |
|
| 105 | + } |
|
| 106 | 106 | } |
@@ -17,57 +17,57 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class Offline |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Determines if the tool is offline |
|
| 22 | - * @return bool |
|
| 23 | - */ |
|
| 24 | - public static function isOffline(SiteConfiguration $configuration): bool |
|
| 25 | - { |
|
| 26 | - return (bool)$configuration->getOffline()['offline']; |
|
| 27 | - } |
|
| 20 | + /** |
|
| 21 | + * Determines if the tool is offline |
|
| 22 | + * @return bool |
|
| 23 | + */ |
|
| 24 | + public static function isOffline(SiteConfiguration $configuration): bool |
|
| 25 | + { |
|
| 26 | + return (bool)$configuration->getOffline()['offline']; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Gets the offline message |
|
| 31 | - * |
|
| 32 | - * @throws Smarty\Exception |
|
| 33 | - */ |
|
| 34 | - public static function getOfflineMessage(bool $external, SiteConfiguration $configuration, ?string $message = null): string |
|
| 35 | - { |
|
| 36 | - $baseurl = $configuration->getBaseUrl(); |
|
| 37 | - $culprit = $configuration->getOffline()['culprit']; |
|
| 38 | - $reason = $configuration->getOffline()['reason']; |
|
| 29 | + /** |
|
| 30 | + * Gets the offline message |
|
| 31 | + * |
|
| 32 | + * @throws Smarty\Exception |
|
| 33 | + */ |
|
| 34 | + public static function getOfflineMessage(bool $external, SiteConfiguration $configuration, ?string $message = null): string |
|
| 35 | + { |
|
| 36 | + $baseurl = $configuration->getBaseUrl(); |
|
| 37 | + $culprit = $configuration->getOffline()['culprit']; |
|
| 38 | + $reason = $configuration->getOffline()['reason']; |
|
| 39 | 39 | |
| 40 | - $smarty = new Smarty\Smarty(); |
|
| 41 | - $smarty->assign("baseurl", $baseurl); |
|
| 42 | - $smarty->assign("resourceCacheEpoch", 0); |
|
| 43 | - $smarty->assign("alerts", []); |
|
| 44 | - $smarty->assign("toolversion", Environment::getToolVersion()); |
|
| 40 | + $smarty = new Smarty\Smarty(); |
|
| 41 | + $smarty->assign("baseurl", $baseurl); |
|
| 42 | + $smarty->assign("resourceCacheEpoch", 0); |
|
| 43 | + $smarty->assign("alerts", []); |
|
| 44 | + $smarty->assign("toolversion", Environment::getToolVersion()); |
|
| 45 | 45 | |
| 46 | - if (!headers_sent()) { |
|
| 47 | - header("HTTP/1.1 503 Service Unavailable"); |
|
| 48 | - } |
|
| 46 | + if (!headers_sent()) { |
|
| 47 | + header("HTTP/1.1 503 Service Unavailable"); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - if ($external) { |
|
| 51 | - return $smarty->fetch("offline/external.tpl"); |
|
| 52 | - } |
|
| 53 | - else { |
|
| 54 | - $hideCulprit = true; |
|
| 50 | + if ($external) { |
|
| 51 | + return $smarty->fetch("offline/external.tpl"); |
|
| 52 | + } |
|
| 53 | + else { |
|
| 54 | + $hideCulprit = true; |
|
| 55 | 55 | |
| 56 | - // Use the provided message if possible |
|
| 57 | - if ($message === null) { |
|
| 58 | - $hideCulprit = false; |
|
| 59 | - $message = $reason; |
|
| 60 | - } |
|
| 56 | + // Use the provided message if possible |
|
| 57 | + if ($message === null) { |
|
| 58 | + $hideCulprit = false; |
|
| 59 | + $message = $reason; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - $smarty->assign("hideCulprit", $hideCulprit); |
|
| 63 | - $smarty->assign("dontUseDbCulprit", $culprit); |
|
| 64 | - $smarty->assign("dontUseDbReason", $message); |
|
| 65 | - $smarty->assign("alerts", []); |
|
| 66 | - $smarty->assign('currentUser', User::getCommunity()); |
|
| 67 | - $smarty->assign('skin', 'main'); |
|
| 68 | - $smarty->assign('currentDomain', null); |
|
| 62 | + $smarty->assign("hideCulprit", $hideCulprit); |
|
| 63 | + $smarty->assign("dontUseDbCulprit", $culprit); |
|
| 64 | + $smarty->assign("dontUseDbReason", $message); |
|
| 65 | + $smarty->assign("alerts", []); |
|
| 66 | + $smarty->assign('currentUser', User::getCommunity()); |
|
| 67 | + $smarty->assign('skin', 'main'); |
|
| 68 | + $smarty->assign('currentDomain', null); |
|
| 69 | 69 | |
| 70 | - return $smarty->fetch("offline/internal.tpl"); |
|
| 71 | - } |
|
| 72 | - } |
|
| 70 | + return $smarty->fetch("offline/internal.tpl"); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | 73 | } |