コード例 #1
0
ファイル: Authorization.php プロジェクト: Mesoptier/gewisweb
 public function __construct(Translator $translate)
 {
     parent::__construct();
     $this->add(['name' => 'recipient', 'type' => 'hidden']);
     $this->add(['name' => 'agree', 'type' => 'checkbox', 'options' => ['use_hidden_element' => false]]);
     $this->add(['name' => 'submit', 'type' => 'submit', 'attributes' => ['label' => $translate->translate('Authorize')]]);
 }
コード例 #2
0
ファイル: Activate.php プロジェクト: Mesoptier/gewisweb
 public function __construct(Translator $translate)
 {
     parent::__construct();
     $this->add(['name' => 'password', 'type' => 'password', 'options' => ['label' => $translate->translate('Your password')]]);
     $this->add(['name' => 'password_verify', 'type' => 'password', 'options' => ['label' => $translate->translate('Verify your password')]]);
     $this->add(['name' => 'submit', 'type' => 'submit', 'attributes' => ['value' => $translate->translate('Activate')]]);
 }
コード例 #3
0
ファイル: Bulk.php プロジェクト: Mesoptier/gewisweb
 public function __construct(Translator $translator, Fieldset $exam)
 {
     parent::__construct();
     $this->add(['name' => 'exams', 'type' => 'Collection', 'options' => ['count' => 0, 'allow_add' => true, 'allow_remove' => true, 'target_element' => $exam]]);
     $this->add(['name' => 'submit', 'type' => 'submit']);
     $this->get('submit')->setLabel($translator->translate('Finalize uploads'));
 }
コード例 #4
0
ファイル: SearchCourse.php プロジェクト: efueger/gewisweb
 public function __construct(Translator $translate)
 {
     parent::__construct();
     $this->add(array('name' => 'query', 'type' => 'text', 'options' => array('label' => $translate->translate('Search query'))));
     $this->add(array('name' => 'submit', 'type' => 'submit', 'attributes' => array('value' => $translate->translate('Search'))));
     $this->initFilters();
 }
コード例 #5
0
 /**
  * @param array $processLog
  * @param array $processDefinitions
  * @param TranslatorInterface $translator
  */
 private static function addPrcessName(array &$processLog, array &$processDefinitions, TranslatorInterface $translator)
 {
     if (isset($processDefinitions[$processLog['start_message']])) {
         $processLog['process_name'] = $processDefinitions[$processLog['start_message']]['name'];
     } else {
         $processLog['process_name'] = $translator->translate('Unknown');
     }
 }
コード例 #6
0
ファイル: Poll.php プロジェクト: Mesoptier/gewisweb
 public function __construct(Translator $translator)
 {
     parent::__construct();
     $this->add(['name' => 'dutchQuestion', 'type' => 'text', 'options' => ['label' => $translator->translate('Dutch question')]]);
     $this->add(['name' => 'englishQuestion', 'type' => 'text', 'options' => ['label' => $translator->translate('English question')]]);
     $this->add(['name' => 'options', 'type' => 'Zend\\Form\\Element\\Collection', 'options' => ['count' => 2, 'should_create_template' => true, 'allow_add' => true, 'target_element' => ['type' => 'Frontpage\\Form\\PollOption']]]);
     $this->add(['name' => 'submit', 'type' => 'submit', 'attributes' => ['value' => $translator->translate('Submit')]]);
 }
コード例 #7
0
ファイル: PollComment.php プロジェクト: Mesoptier/gewisweb
 public function __construct(Translator $translator)
 {
     parent::__construct();
     $this->add(['name' => 'author', 'type' => 'text', 'options' => ['label' => $translator->translate('Author')]]);
     $this->add(['name' => 'content', 'type' => 'textarea', 'options' => ['label' => $translator->translate('Content')]]);
     $this->add(['name' => 'submit', 'type' => 'submit', 'attributes' => ['value' => $translator->translate('Comment')]]);
     $this->get('submit')->setLabel($translator->translate('Comment'));
 }
コード例 #8
0
ファイル: Password.php プロジェクト: Mesoptier/gewisweb
 public function __construct(Translator $translate)
 {
     parent::__construct();
     $this->add(['name' => 'old_password', 'type' => 'password', 'options' => ['label' => $translate->translate('Old password')]]);
     $this->add(['name' => 'password', 'type' => 'password', 'options' => ['label' => $translate->translate('New password')]]);
     $this->add(['name' => 'password_verify', 'type' => 'password', 'options' => ['label' => $translate->translate('Verify new password')]]);
     $this->add(['name' => 'submit', 'type' => 'submit', 'attributes' => ['value' => $translate->translate('Change password')]]);
 }
コード例 #9
0
ファイル: Register.php プロジェクト: Mesoptier/gewisweb
 public function __construct(Translator $translate)
 {
     parent::__construct();
     $this->translate = $translate;
     $this->add(['name' => 'lidnr', 'type' => 'number', 'options' => ['label' => $translate->translate('Membership number')]]);
     $this->add(['name' => 'email', 'type' => 'email', 'options' => ['label' => $translate->translate('E-mail address')]]);
     $this->add(['name' => 'submit', 'type' => 'submit', 'attributes' => ['value' => $translate->translate('Register')]]);
     $this->initFilters();
 }
コード例 #10
0
ファイル: Login.php プロジェクト: efueger/gewisweb
 public function __construct(Translator $translate)
 {
     parent::__construct();
     $this->translate = $translate;
     $this->add(array('name' => 'login', 'type' => 'text', 'options' => array('label' => $translate->translate('Membership number or email address'))));
     $this->add(array('name' => 'password', 'type' => 'password', 'options' => array('label' => $translate->translate('Your password'))));
     $this->add(array('name' => 'submit', 'type' => 'submit', 'attributes' => array('value' => $translate->translate('Login'))));
     $this->initFilters();
 }
コード例 #11
0
 /**
  * Process an incoming request and/or response.
  *
  * Accepts a server-side request and a response instance, and does
  * something with them.
  *
  * If the response is not complete and/or further processing would not
  * interfere with the work done in the middleware, or if the middleware
  * wants to delegate to another process, it can use the `$out` callable
  * if present.
  *
  * If the middleware does not return a value, execution of the current
  * request is considered complete, and the response instance provided will
  * be considered the response to return.
  *
  * Alternately, the middleware may return a response instance.
  *
  * Often, middleware will `return $out();`, with the assumption that a
  * later middleware will return a response.
  *
  * @param Request $request
  * @param Response $response
  * @param null|callable $out
  * @return null|Response
  */
 public function __invoke(Request $request, Response $response, callable $out = null)
 {
     $matchedRoute = $this->router->match($request);
     $params = $matchedRoute->getMatchedParams();
     // Determine the language to use based on the lang parameter
     $lang = isset($params['lang']) ? $params['lang'] : 'en';
     $this->translator->setLocale($lang);
     return $out($request, $response);
 }
コード例 #12
0
ファイル: DisableKeyCommand.php プロジェクト: shlinkio/shlink
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $apiKey = $input->getArgument('apiKey');
     try {
         $this->apiKeyService->disable($apiKey);
         $output->writeln(sprintf($this->translator->translate('API key %s properly disabled'), '<info>' . $apiKey . '</info>'));
     } catch (\InvalidArgumentException $e) {
         $output->writeln(sprintf('<error>' . $this->translator->translate('API key "%s" does not exist.') . '</error>', $apiKey));
     }
 }
コード例 #13
0
ファイル: Login.php プロジェクト: Mesoptier/gewisweb
 public function __construct(Translator $translate)
 {
     parent::__construct();
     $this->translate = $translate;
     $this->add(['name' => 'login', 'type' => 'text', 'options' => ['label' => $translate->translate('Membership number or email address')]]);
     $this->add(['name' => 'password', 'type' => 'password', 'options' => ['label' => $translate->translate('Your password')]]);
     $this->add(['name' => 'submit', 'type' => 'submit', 'attributes' => ['value' => $translate->translate('Login')]]);
     $this->add(['name' => 'remember', 'type' => 'checkbox', 'options' => ['label' => $translate->translate('Remember me'), 'checked_value' => 1, 'unchecked_value' => 0, 'checked' => true]]);
     $this->add(['name' => 'redirect', 'type' => 'hidden']);
     $this->initFilters();
 }
コード例 #14
0
ファイル: SummaryUpload.php プロジェクト: wsinnema/gewisweb
 public function __construct(Translator $translator)
 {
     parent::__construct();
     $this->add(['name' => 'course', 'type' => 'text', 'options' => ['label' => $translator->translate('Course code')]]);
     $this->add(['name' => 'date', 'type' => 'date', 'options' => ['label' => $translator->translate('Summary date')]]);
     $this->add(['name' => 'author', 'type' => 'text', 'options' => ['label' => $translator->translate('Author')]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'language', 'options' => ['label' => $translator->translate('Language'), 'value_options' => [ExamModel::EXAM_LANGUAGE_ENGLISH => $translator->translate('English'), ExamModel::EXAM_LANGUAGE_DUTCH => $translator->translate('Dutch')]]]);
     $this->add(['name' => 'upload', 'type' => 'file', 'option' => ['label' => $translator->translate('Summary to upload')]]);
     $this->get('upload')->setLabel($translator->translate('Summary to upload'));
     $this->add(['name' => 'submit', 'type' => 'submit', 'attributes' => ['value' => $translator->translate('Submit')]]);
 }
コード例 #15
0
ファイル: Document.php プロジェクト: Mesoptier/gewisweb
 public function __construct(Translator $translator, MeetingMapper $mapper)
 {
     parent::__construct();
     $this->translator = $translator;
     $this->add(['name' => 'meeting', 'type' => 'hidden', 'options' => ['label' => $translator->translate('Meeting')]]);
     $this->add(['name' => 'name', 'type' => 'text']);
     $this->get('name')->setLabel($translator->translate('Document name'));
     $this->add(['name' => 'upload', 'type' => 'file']);
     $this->get('upload')->setLabel($translator->translate('Document to upload'));
     $this->add(['name' => 'submit', 'type' => 'submit', 'attributes' => ['value' => $translator->translate('Upload document')]]);
 }
コード例 #16
0
 /**
  * @param Request $request
  * @param Response $response
  * @param callable|null $out
  * @return null|Response
  */
 public function dispatch(Request $request, Response $response, callable $out = null)
 {
     try {
         $params = $this->queryToListParams($request->getQueryParams());
         $shortUrls = $this->shortUrlService->listShortUrls(...$params);
         return new JsonResponse(['shortUrls' => $this->serializePaginator($shortUrls)]);
     } catch (\Exception $e) {
         $this->logger->error('Unexpected error while listing short URLs.' . PHP_EOL . $e);
         return new JsonResponse(['error' => RestUtils::UNKNOWN_ERROR, 'message' => $this->translator->translate('Unexpected error occurred')], 500);
     }
 }
コード例 #17
0
 public function __construct(Translator $translator)
 {
     parent::__construct();
     $this->add(['name' => 'email', 'type' => 'email', 'options' => ['label' => $translator->translate('Email')]]);
     $this->add(['name' => 'website', 'type' => 'url', 'options' => ['label' => $translator->translate('Website')]]);
     $this->add(['name' => 'shortDutchDescription', 'type' => 'text', 'options' => ['label' => $translator->translate('Short dutch description')]]);
     $this->add(['name' => 'shortEnglishDescription', 'type' => 'text', 'options' => ['label' => $translator->translate('Short english description')]]);
     $this->add(['name' => 'dutchDescription', 'type' => 'text', 'options' => ['label' => $translator->translate('Long dutch description')]]);
     $this->add(['name' => 'englishDescription', 'type' => 'text', 'options' => ['label' => $translator->translate('Long english description')]]);
     $this->add(['name' => 'upload', 'type' => 'file', 'option' => ['label' => $translator->translate('Cover photo to upload')]]);
     $this->get('upload')->setLabel($translator->translate('Cover photo to upload'));
     $this->add(['name' => 'submit', 'type' => 'submit', 'attributes' => ['value' => $translator->translate('Save')]]);
 }
コード例 #18
0
ファイル: ResolveUrlCommand.php プロジェクト: shlinkio/shlink
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $shortCode = $input->getArgument('shortCode');
     try {
         $longUrl = $this->urlShortener->shortCodeToUrl($shortCode);
         if (!isset($longUrl)) {
             $output->writeln(sprintf('<error>' . $this->translator->translate('No URL found for short code "%s"') . '</error>', $shortCode));
             return;
         }
         $output->writeln(sprintf('%s <info>%s</info>', $this->translator->translate('Long URL:'), $longUrl));
     } catch (InvalidShortCodeException $e) {
         $output->writeln(sprintf('<error>' . $this->translator->translate('Provided short code "%s" has an invalid format.') . '</error>', $shortCode));
     }
 }
コード例 #19
0
 protected function processUrl($url, OutputInterface $output)
 {
     try {
         $output->write(sprintf($this->translator->translate('Processing URL %s...'), $url));
         $this->previewGenerator->generatePreview($url);
         $output->writeln($this->translator->translate(' <info>Success!</info>'));
     } catch (PreviewGenerationException $e) {
         $messages = [' <error>' . $this->translator->translate('Error') . '</error>'];
         if ($output->isVerbose()) {
             $messages[] = '<error>' . $e->__toString() . '</error>';
         }
         $output->writeln($messages);
     }
 }
コード例 #20
0
 public function renderMenu($class = 'pull-left left-menu') : string
 {
     $pages = isset($this->config['menu']) ? $this->config['menu'] : [];
     $listElements = [];
     $elementPattern = '<li class="%s"><a href="%s" %s>%s</a></li>';
     $currentRoute = $this->routeAssembler->getCurrentRouteResult();
     foreach ($pages as $page) {
         $active = isset($page['route']) && $currentRoute->getMatchedRouteName() === $page['route'] ? 'active' : '';
         $target = isset($page['target']) ? 'target="_blank"' : '';
         $route = $page['uri'] ?? $this->routeAssembler->assembleUrl($page['route'], true);
         $listElements[] = sprintf($elementPattern, $active, $route, $target, $this->translator->translate($page['label']));
     }
     return sprintf('<ul class="%s">%s</ul>', $class, implode('', $listElements));
 }
コード例 #21
0
ファイル: EditTagsAction.php プロジェクト: shlinkio/shlink
 /**
  * @param Request $request
  * @param Response $response
  * @param callable|null $out
  * @return null|Response
  */
 protected function dispatch(Request $request, Response $response, callable $out = null)
 {
     $shortCode = $request->getAttribute('shortCode');
     $bodyParams = $request->getParsedBody();
     if (!isset($bodyParams['tags'])) {
         return new JsonResponse(['error' => RestUtils::INVALID_ARGUMENT_ERROR, 'message' => $this->translator->translate('A list of tags was not provided')], 400);
     }
     $tags = $bodyParams['tags'];
     try {
         $shortUrl = $this->shortUrlService->setTagsByShortCode($shortCode, $tags);
         return new JsonResponse(['tags' => $shortUrl->getTags()->toArray()]);
     } catch (InvalidShortCodeException $e) {
         return new JsonResponse(['error' => RestUtils::getRestErrorCodeFromException($e), 'message' => sprintf($this->translator->translate('No URL found for short code "%s"'), $shortCode)], 404);
     }
 }
コード例 #22
0
 /**
  * @param Request $request
  * @param Response $response
  * @param callable|null $out
  * @return null|Response
  */
 public function dispatch(Request $request, Response $response, callable $out = null)
 {
     $authData = $request->getParsedBody();
     if (!isset($authData['apiKey'])) {
         return new JsonResponse(['error' => RestUtils::INVALID_ARGUMENT_ERROR, 'message' => $this->translator->translate('You have to provide a valid API key under the "apiKey" param name.')], 400);
     }
     // Authenticate using provided API key
     $apiKey = $this->apiKeyService->getByKey($authData['apiKey']);
     if (!isset($apiKey) || !$apiKey->isValid()) {
         return new JsonResponse(['error' => RestUtils::INVALID_API_KEY_ERROR, 'message' => $this->translator->translate('Provided API key does not exist or is invalid.')], 401);
     }
     // Generate a JSON Web Token that will be used for authorization in next requests
     $token = $this->jwtService->create($apiKey);
     return new JsonResponse(['token' => $token]);
 }
コード例 #23
0
 /**
  * render
  *
  * @param string $userId
  * @param array  $messages
  * @param bool   $showDefaultMessage
  *
  * @return string
  */
 protected function render($userId, $messages, $showDefaultMessage = false)
 {
     $messageHtml = '';
     $messageHtml .= '<div class="rcmMessage userMessageList" data-ng-controller="rcmMessageList">';
     foreach ($messages as $userMessage) {
         /** @var \RcmMessage\Entity\Message $message */
         $message = $userMessage->getMessage();
         $cssName = $this->getCssName($message->getLevel());
         $messageSubject = $message->getSubject();
         $messageBody = $message->getMessage();
         $messageHtml .= '
         <div class="alert' . $cssName . '" ng-hide="hiddenUserMessageIds[\'' . $userId . ':' . $userMessage->getId() . '\']" role="alert">
           <button type="button" class="close" ng-click="dismissUserMessage(' . $userId . ', ' . $userMessage->getId() . ')" aria-label="Close">
           <span aria-hidden="true">&times;</span>
           </button>
           <span class="subject">
           ' . $this->htmlPurifier->purify($this->translator->translate($messageSubject)) . ':
           </span>
           <span class="body">
           ' . $this->htmlPurifier->purify($this->translator->translate($messageBody)) . '
           </span>
         </div>
         ';
     }
     $messageHtml .= '</div>';
     return $messageHtml;
 }
コード例 #24
0
ファイル: GetVisitsCommand.php プロジェクト: shlinkio/shlink
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $shortCode = $input->getArgument('shortCode');
     $startDate = $this->getDateOption($input, 'startDate');
     $endDate = $this->getDateOption($input, 'endDate');
     $visits = $this->visitsTracker->info($shortCode, new DateRange($startDate, $endDate));
     $table = new Table($output);
     $table->setHeaders([$this->translator->translate('Referer'), $this->translator->translate('Date'), $this->translator->translate('Remote Address'), $this->translator->translate('User agent')]);
     foreach ($visits as $row) {
         $rowData = $row->jsonSerialize();
         // Unset location info
         unset($rowData['visitLocation']);
         $table->addRow(array_values($rowData));
     }
     $table->render();
 }
コード例 #25
0
ファイル: GetVisitsAction.php プロジェクト: shlinkio/shlink
 /**
  * @param Request $request
  * @param Response $response
  * @param callable|null $out
  * @return null|Response
  */
 public function dispatch(Request $request, Response $response, callable $out = null)
 {
     $shortCode = $request->getAttribute('shortCode');
     $startDate = $this->getDateQueryParam($request, 'startDate');
     $endDate = $this->getDateQueryParam($request, 'endDate');
     try {
         $visits = $this->visitsTracker->info($shortCode, new DateRange($startDate, $endDate));
         return new JsonResponse(['visits' => ['data' => $visits]]);
     } catch (InvalidArgumentException $e) {
         $this->logger->warning('Provided nonexistent shortcode' . PHP_EOL . $e);
         return new JsonResponse(['error' => RestUtils::getRestErrorCodeFromException($e), 'message' => sprintf($this->translator->translate('Provided short code %s does not exist'), $shortCode)], 404);
     } catch (\Exception $e) {
         $this->logger->error('Unexpected error while parsing short code' . PHP_EOL . $e);
         return new JsonResponse(['error' => RestUtils::UNKNOWN_ERROR, 'message' => $this->translator->translate('Unexpected error occurred')], 500);
     }
 }
コード例 #26
0
ファイル: Holdings.php プロジェクト: htw-pk15/vufind
 /**
  * Get holdings structure for holdings
  *
  * @param    Integer $fieldName
  * @return    Array[]
  */
 protected function getStructuredHoldingsStructure($fieldName, $data = array())
 {
     //$data    = array();
     $fields = $this->holdings ? $this->holdings->getFields($fieldName) : false;
     $mapping = array('B' => 'network', 'F' => 'institution_chb');
     if (is_array($fields)) {
         foreach ($fields as $index => $field) {
             $item = $this->extractFieldData($field, $mapping);
             $networkCode = $item['network'];
             $institution = $item['institution_chb'];
             $groupCode = $this->getGroup($institution);
             // Prevent display of untranslated and ungrouped institutions
             $institutionLabel = $this->translator->translate($institution, 'institution');
             if ($groupCode == 'unknown' || $institutionLabel === $institution) {
                 if ($groupCode === 'unknown') {
                     $this->swissbibLogger->logUngroupedInstitution($institution);
                 }
                 continue;
             }
             // Make sure group is present
             if (!isset($data[$groupCode])) {
                 $data[$groupCode] = array('label' => $groupCode, 'networkCode' => $networkCode, 'institutions' => array());
             }
             // Make sure institution is present
             if (!isset($data[$groupCode]['institutions'][$institution])) {
                 $data[$groupCode]['institutions'][$institution] = array('label' => $institution, 'bibinfolink' => $this->getBibInfoLink($institution));
             }
         }
     }
     return $data;
 }
コード例 #27
0
ファイル: Status.php プロジェクト: cross-solution/yawik
 /**
  * @param Translator $translator
  * @return array
  */
 public function getOptions(Translator $translator)
 {
     $options = [];
     foreach ($this->getStates() as $state) {
         $options[$state] = $translator->translate($state);
     }
     return $options;
 }
コード例 #28
0
ファイル: ResolveUrlAction.php プロジェクト: shlinkio/shlink
 /**
  * @param Request $request
  * @param Response $response
  * @param callable|null $out
  * @return null|Response
  */
 public function dispatch(Request $request, Response $response, callable $out = null)
 {
     $shortCode = $request->getAttribute('shortCode');
     try {
         $longUrl = $this->urlShortener->shortCodeToUrl($shortCode);
         if (!isset($longUrl)) {
             return new JsonResponse(['error' => RestUtils::INVALID_ARGUMENT_ERROR, 'message' => sprintf($this->translator->translate('No URL found for short code "%s"'), $shortCode)], 404);
         }
         return new JsonResponse(['longUrl' => $longUrl]);
     } catch (InvalidShortCodeException $e) {
         $this->logger->warning('Provided short code with invalid format.' . PHP_EOL . $e);
         return new JsonResponse(['error' => RestUtils::getRestErrorCodeFromException($e), 'message' => sprintf($this->translator->translate('Provided short code "%s" has an invalid format'), $shortCode)], 400);
     } catch (\Exception $e) {
         $this->logger->error('Unexpected error while resolving the URL behind a short code.' . PHP_EOL . $e);
         return new JsonResponse(['error' => RestUtils::UNKNOWN_ERROR, 'message' => $this->translator->translate('Unexpected error occurred')], 500);
     }
 }
コード例 #29
0
 public function indexAction()
 {
     /** @var string|null $id */
     $id = $this->params('id');
     $resume = $this->repository->find($id);
     if (!$resume) {
         $this->getResponse()->setStatusCode(Response::STATUS_CODE_404);
         return ['message' => sprintf($this->translator->translate('Resume with id "%s" not found'), $id)];
     }
     /* @todo REMOVE THIS
      * @codeCoverageIgnoreStart */
     if (!$resume->getDateCreated()) {
         $resume->setDateCreated();
     }
     /* @codeCoverageIgnoreEnd */
     $this->acl($resume, 'view');
     return ['resume' => $resume];
 }
コード例 #30
0
 /**
  * Format a facet field according to the settings
  *
  * @param string $facet Facet field
  * @param string $value Facet value
  *
  * @return string Formatted field
  */
 protected function formatFacetField($facet, $value)
 {
     if (in_array($facet, $this->translatedFacets)) {
         $value = $this->translator->translate($value);
     }
     $allLevels = isset($this->displayStyles[$facet]) ? $this->displayStyles[$facet] == 'full' : false;
     $separator = isset($this->separators[$facet]) ? $this->separators[$facet] : '/';
     $value = $this->facetHelper->formatDisplayText($value, $allLevels, $separator);
     return $value;
 }