/** * Render user initials or an abbreviated name for a given username. If the account was deleted, use the username as fallback. * * @param string $format Supported are "fullFirstName" and "initials" * @return string */ public function render($format = 'initials') { if (!in_array($format, array('fullFirstName', 'initials', 'fullName'))) { throw new \InvalidArgumentException(sprintf('Format "%s" given to history:userInitials(), only supporting "fullFirstName", "initials" and "fullName".', $format), 1415705861); } $username = $this->renderChildren(); /* @var $requestedUser Person */ $requestedUser = $this->domainUserService->getUser($username); if ($requestedUser === null || $requestedUser->getName() === null) { return $username; } $currentUser = $this->userService->getBackendUser(); if ($currentUser) { if ($currentUser === $requestedUser) { $translationHelper = new TranslationHelper(); $you = $translationHelper->translate('you', null, [], 'Main', 'Neos.Neos'); } } switch ($format) { case 'initials': return mb_substr($requestedUser->getName()->getFirstName(), 0, 1) . mb_substr($requestedUser->getName()->getLastName(), 0, 1); case 'fullFirstName': return isset($you) ? $you : $requestedUser->getName()->getFirstName() . ' ' . mb_substr($requestedUser->getName()->getLastName(), 0, 1) . '.'; case 'fullName': return isset($you) ? $you : $requestedUser->getName()->getFullName(); } }
/** * @return void */ protected function initializeAction() { parent::initializeAction(); $translationHelper = new TranslationHelper(); $this->setTitle($translationHelper->translate($this->moduleConfiguration['label']) . ' :: ' . $translationHelper->translate(str_replace('label', 'action.', $this->moduleConfiguration['label']) . $this->request->getControllerActionName())); if ($this->arguments->hasArgument('user')) { $propertyMappingConfigurationForUser = $this->arguments->getArgument('user')->getPropertyMappingConfiguration(); $propertyMappingConfigurationForUserName = $propertyMappingConfigurationForUser->forProperty('user.name'); $propertyMappingConfigurationForPrimaryAccount = $propertyMappingConfigurationForUser->forProperty('user.primaryAccount'); $propertyMappingConfigurationForPrimaryAccount->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_TARGET_TYPE, Account::class); /** @var PropertyMappingConfiguration $propertyMappingConfiguration */ foreach (array($propertyMappingConfigurationForUser, $propertyMappingConfigurationForUserName, $propertyMappingConfigurationForPrimaryAccount) as $propertyMappingConfiguration) { $propertyMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED, true); } } $this->currentUser = $this->userService->getCurrentUser(); }
/** * Fetch all master plugins that are available in the current * workspace. * * @param string $workspaceName Name of the workspace to use for querying the node * @param array $dimensions Optional list of dimensions and their values which should be used for querying the specified node * @return string JSON encoded array of node path => label */ public function masterPluginsAction($workspaceName = 'live', array $dimensions = array()) { $this->response->setHeader('Content-Type', 'application/json'); $contentContext = $this->createContentContext($workspaceName, $dimensions); $pluginNodes = $this->pluginService->getPluginNodesWithViewDefinitions($contentContext); $masterPlugins = array(); if (is_array($pluginNodes)) { /** @var $pluginNode NodeInterface */ foreach ($pluginNodes as $pluginNode) { if ($pluginNode->isRemoved()) { continue; } $q = new FlowQuery(array($pluginNode)); $page = $q->closest('[instanceof Neos.Neos:Document]')->get(0); if ($page === null) { continue; } $translationHelper = new TranslationHelper(); $masterPlugins[$pluginNode->getIdentifier()] = $translationHelper->translate('masterPlugins.nodeTypeOnPageLabel', null, ['nodeTypeName' => $translationHelper->translate($pluginNode->getNodeType()->getLabel()), 'pageLabel' => $page->getLabel()], 'Main', 'Neos.Neos'); } } return json_encode((object) $masterPlugins); }
/** * Get the human-readable label of this node type * * @return string * @api */ public function getLabel() { $translationHelper = new TranslationHelper(); return isset($this->configuration['label']) ? $translationHelper->translate($this->configuration['label']) : ''; }
/** * @return void */ protected function assignElectronicAddressOptions() { $electronicAddress = new ElectronicAddress(); $electronicAddressTypes = array(); foreach ($electronicAddress->getAvailableElectronicAddressTypes() as $type) { $electronicAddressTypes[$type] = $type; } $electronicAddressUsageTypes = array(); $translationHelper = new TranslationHelper(); foreach ($electronicAddress->getAvailableUsageTypes() as $type) { $electronicAddressUsageTypes[$type] = $translationHelper->translate('users.electronicAddress.usage.type.' . $type, $type, [], 'Modules', 'Neos.Neos'); } array_unshift($electronicAddressUsageTypes, ''); $this->view->assignMultiple(array('electronicAddressTypes' => $electronicAddressTypes, 'electronicAddressUsageTypes' => $electronicAddressUsageTypes)); }