/** * Creates an e-mail introduction with the given event's title, date and * time prepended with the given introduction string. * * @param string $introductionBegin * the start of the introduction, must not be empty and contain %s as * place to fill the title of the event in * @param tx_seminars_seminar $event the event the introduction is for * * @return string the introduction with the event's title and if available * date and time, will not be empty */ public function createIntroduction($introductionBegin, tx_seminars_seminar $event) { $result = sprintf($introductionBegin, $event->getTitle()); if (!$event->hasDate()) { return $result; } $result .= ' ' . sprintf($this->translator->translate('email_eventDate'), $event->getDate('-')); if ($event->hasTime() && !$event->hasTimeslots()) { $timeToLabel = $this->translator->translate('email_timeTo'); $time = $event->getTime(' ' . $timeToLabel . ' '); $label = ' ' . (!$event->isOpenEnded() ? $this->translator->translate('email_timeFrom') : $this->translator->translate('email_timeAt')); $result .= sprintf($label, $time); } return $result; }
/** * @test */ public function getTitleForDateReturnsTopicTitle() { $topicRecordUid = $this->testingFramework->createRecord('tx_seminars_seminars', array('object_type' => tx_seminars_Model_Event::TYPE_TOPIC, 'title' => 'a test topic')); $dateRecordUid = $this->testingFramework->createRecord('tx_seminars_seminars', array('object_type' => tx_seminars_Model_Event::TYPE_DATE, 'topic' => $topicRecordUid, 'title' => 'a test date')); $date = new tx_seminars_seminar($dateRecordUid); self::assertSame('a test topic', $date->getTitle()); }
/** * Returns localized e-mail content customized for the provided event and * the provided organizer. * * @param string $locallangKey * locallang key for the text in which to replace key words beginning with "%" by the event's data, must not be empty * @param tx_seminars_seminar $event * event for which to customize the text * @param string $organizerName * name of the organizer, may be empty if no organizer name needs to be inserted in the text * * @return string the localized e-mail content, will not be empty */ private function customizeMessage($locallangKey, tx_seminars_seminar $event, $organizerName = '') { /** @var tx_oelib_Mapper_BackEndUser $mapper */ $mapper = tx_oelib_MapperRegistry::get('tx_oelib_Mapper_BackEndUser'); /** @var Tx_Oelib_Model_BackEndUser $user */ $user = $mapper->findByCliKey(); $GLOBALS['LANG']->lang = $user->getLanguage(); $GLOBALS['LANG']->includeLLFile(t3lib_extMgm::extPath('seminars') . 'locallang.xml'); $result = $GLOBALS['LANG']->getLL($locallangKey); foreach (array('%begin_date' => $this->getDate($event->getBeginDateAsTimeStamp()), '%days' => $this->getDaysBeforeBeginDate(), '%event' => $event->getTitle(), '%organizer' => $organizerName, '%registrations' => $event->getAttendances(), '%uid' => $event->getUid()) as $search => $replace) { $result = str_replace($search, $replace, $result); } return $result; }
/** * Creates an e-mail introduction with the given event's title, date and * time prepended with the given introduction string. * * @param string $introductionBegin * the start of the introduction, must not be empty and contain %s as * place to fill the title of the event in * @param tx_seminars_seminar $event the event the introduction is for * * @return string the introduction with the event's title and if available date and time, will not be empty * * @throws \InvalidArgumentException */ public function createIntroduction($introductionBegin, tx_seminars_seminar $event) { if ($introductionBegin === '') { throw new \InvalidArgumentException('$introductionBegin must not be empty.', 1440109640); } $result = sprintf($introductionBegin, $event->getTitle()); if (!$event->hasDate()) { return $result; } $result .= ' ' . sprintf($this->translator->translate('email_eventDate'), $event->getDate('-')); if ($event->hasTime() && !$event->hasTimeslots()) { $timeToLabelWithPlaceholders = $this->translator->translate('email_timeTo'); $time = $event->getTime(' ' . $timeToLabelWithPlaceholders . ' '); $label = ' ' . (!$event->isOpenEnded() ? $this->translator->translate('email_timeFrom') : $this->translator->translate('email_timeAt')); $result .= sprintf($label, $time); } return $result; }