/** * Returns a list of global variables to add to the existing list. * * @return array An array of global variables */ public function getGlobals() { $safeMode = $this->environment->isSafeMode(); $isInstalled = craft()->isInstalled(); $globals = array('user' => null, 'currentUser' => null); if (!$safeMode) { // Keep the 'blx' variable around for now $craftVariable = new CraftVariable(); $globals['craft'] = $craftVariable; $globals['blx'] = $craftVariable; $globals['loginUrl'] = UrlHelper::getUrl(craft()->config->getLoginPath()); $globals['logoutUrl'] = UrlHelper::getUrl(craft()->config->getLogoutPath()); $globals['isInstalled'] = $isInstalled; if ($isInstalled) { $globals['currentUser'] = craft()->userSession->getUser(); } // Keep 'user' around so long as it's not hurting anyone. // Technically deprecated, though. $globals['user'] = $globals['currentUser']; if (craft()->request->isCpRequest()) { $globals['CraftEdition'] = craft()->getEdition(); $globals['CraftPersonal'] = Craft::Personal; $globals['CraftClient'] = Craft::Client; $globals['CraftPro'] = Craft::Pro; } } $globals['now'] = new DateTime(null, new \DateTimeZone(craft()->getTimeZone())); if ($isInstalled && !craft()->updates->isCraftDbMigrationNeeded()) { $globals['siteName'] = craft()->getSiteName(); $globals['siteUrl'] = craft()->getSiteUrl(); if (craft()->request->isSiteRequest()) { foreach (craft()->globals->getAllSets() as $globalSet) { $globals[$globalSet->handle] = $globalSet; } } } else { $globals['siteName'] = null; $globals['siteUrl'] = null; } return $globals; }