/** * Creates an instance of this class */ public function __construct() { if (GeneralUtility::getTsFe()->tmpl->setup['plugin.']['tx_t3extblog.']['settings.']['blogName']) { $this->sitename = GeneralUtility::getTsFe()->tmpl->setup['plugin.']['tx_t3extblog.']['settings.']['blogName']; } else { $this->sitename = GeneralUtility::getTsFe()->tmpl->setup['sitetitle']; } $this->sitename = htmlspecialchars($this->sitename); }
/** * Enable fields for BE and FE * * @param string $table * * @return string */ public function enableFields($table) { $where = ''; if (TYPO3_MODE === 'FE') { $where .= GeneralUtility::getTsFe()->sys_page->enableFields($table); } else { $where .= BackendUtility::BEenableFields($table); $where .= BackendUtility::deleteClause($table); } return $where; }
/** * Creates an instance of this * * We cant use parent constructor as the wrong class will be initiated */ public function __construct() { $this->rendererClass = 'TYPO3\\T3extblog\\Hooks\\Sitemap\\Renderer'; $this->cObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); $this->cObj->start(array()); $this->offset = max(0, (int) GeneralUtility::_GET('offset')); $this->limit = max(0, (int) GeneralUtility::_GET('limit')); if ($this->limit <= 0) { $this->limit = 100; } $this->createRenderer(); $singlePid = intval(GeneralUtility::_GP('singlePid')); $this->singlePid = $singlePid && $this->isInRootline($singlePid) ? $singlePid : \TYPO3\T3extblog\Utility\GeneralUtility::getTsFe()->id; $this->validateAndcreatePageList(); }
/** * Override the title tag * * @param boolean $prepend * @param string $searchTitle * * @return void */ public function render($prepend = TRUE, $searchTitle = NULL) { if (TYPO3_MODE === 'BE') { return; } $content = $this->renderChildren(); if (empty($content) !== TRUE) { if ($prepend === TRUE) { $content = $content . GeneralUtility::getTsFe()->page['title']; } if ($searchTitle === NULL) { $searchTitle = $content; } GeneralUtility::getTsFe()->indexedDocTitle = $searchTitle; GeneralUtility::getTsFe()->page['title'] = $content; } }
/** * Renders a meta tag * * @param boolean $useCurrentDomain If set, current domain is used * @param boolean $forceAbsoluteUrl If set, absolute url is forced * @return void */ public function render($useCurrentDomain = FALSE, $forceAbsoluteUrl = FALSE) { // set current domain if ($useCurrentDomain) { $this->tag->addAttribute('content', GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')); } // prepend current domain if ($forceAbsoluteUrl) { $path = $this->arguments['content']; if (!GeneralUtility::isFirstPartOfStr($path, GeneralUtility::getIndpEnv('TYPO3_SITE_URL'))) { $this->tag->addAttribute('content', rtrim(GeneralUtility::getIndpEnv('TYPO3_SITE_URL'), '/') . '/' . ltrim($this->arguments['content']), '/'); } } if ($useCurrentDomain || isset($this->arguments['content']) && !empty($this->arguments['content'])) { \TYPO3\T3extblog\Utility\GeneralUtility::getTsFe()->getPageRenderer()->addMetaTag($this->tag->render()); } }
/** * This method decides if the condition is TRUE or FALSE * * @param array $arguments ViewHelper arguments to evaluate the condition * @return bool */ protected static function evaluateCondition($arguments = NULL) { /* @var Post $post */ $post = $arguments['post']; $settings = $arguments['settings']; if (!$settings['blogsystem']['comments']['allowed'] || $post->getAllowComments() === 1) { return FALSE; } if ($post->getAllowComments() === 2 && empty(GeneralUtility::getTsFe()->loginUser)) { return FALSE; } if ($settings['blogsystem']['comments']['allowedUntil']) { if ($post->isExpired(trim($settings['blogsystem']['comments']['allowedUntil']))) { return FALSE; } } return TRUE; }
/** * Redirects permalinks to default show action * * @param int $permalinkPost The post to display * * @return void */ public function permalinkAction($permalinkPost) { $post = $this->postRepository->findByUid((int) $permalinkPost); if ($post === NULL) { GeneralUtility::getTsFe()->pageNotFoundAndExit('Post not found!'); } $this->redirect('show', 'Post', NULL, $post->getLinkParameter(), NULL, 0, 303); }
/** * __construct * */ public function __construct() { $this->frontendUser = GeneralUtility::getTsFe()->fe_user; }
/** * This is the main-function for sending Mails * * @param array $mailTo * @param array $mailFrom * @param string $subject * @param string $emailBody * * @return integer the number of recipients who were accepted for delivery */ public function send($mailTo, $mailFrom, $subject, $emailBody) { if (!($mailTo && is_array($mailTo) && GeneralUtility::validEmail(key($mailTo)))) { $this->log->error('Given mailto email address is invalid.', $mailTo); return FALSE; } if (!($mailFrom && is_array($mailFrom) && GeneralUtility::validEmail(key($mailFrom)))) { $mailFrom = MailUtility::getSystemFrom(); } /* @var $message \TYPO3\CMS\Core\Mail\MailMessage */ $message = $this->objectManager->get('TYPO3\\CMS\\Core\\Mail\\MailMessage'); $message->setTo($mailTo)->setFrom($mailFrom)->setSubject($subject)->setCharset(\TYPO3\T3extblog\Utility\GeneralUtility::getTsFe()->metaCharset); // send text or html emails if (strip_tags($emailBody) === $emailBody) { $message->setBody($emailBody, 'text/plain'); } else { $message->setBody($emailBody, 'text/html'); } if (!$this->settings['debug']['disableEmailTransmission']) { $message->send(); } $logData = array('mailTo' => $mailTo, 'mailFrom' => $mailFrom, 'subject' => $subject, 'emailBody' => $emailBody, 'isSent' => $message->isSent()); $this->log->dev('Email sent.', $logData); return $logData['isSent']; }
/** * @param int $pageUid * * @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController */ protected function buildTSFE($pageUid) { return GeneralUtility::getTsFe($pageUid); }
/** * Get content object renderer * * @return \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer */ protected function getContentObjectRenderer() { return GeneralUtility::getTsFe()->cObj; }
/** * Checks if a new comment could be created * * @param Post $post The post the comment is related to * * @return void */ protected function checkIfCommentIsAllowed(Post $post) { $settings = $this->settings['blogsystem']['comments']; if (!$settings['allowed'] || $post->getAllowComments() === 1) { $this->addFlashMessageByKey('notAllowed', FlashMessage::ERROR); $this->errorAction(); } if ($post->getAllowComments() === 2 && empty(\TYPO3\T3extblog\Utility\GeneralUtility::getTsFe()->loginUser)) { $this->addFlashMessageByKey('notLoggedIn', FlashMessage::ERROR); $this->errorAction(); } if ($settings['allowedUntil']) { if ($post->isExpired(trim($settings['allowedUntil']))) { $this->addFlashMessageByKey('commentsClosed', FlashMessage::ERROR); $this->errorAction(); } } }