/** * This function will generate all meta tags needed for SEO optimisation. * * @param array $content */ public function __invoke(array $content = []) { $description = !empty($content['description']) ? $content['description'] : $this->settings->__invoke('general', 'site_description'); $keywords = !empty($content['keywords']) ? $content['keywords'] : $this->settings->__invoke('general', 'site_keywords'); $text = !empty($content['text']) ? $content['text'] : $this->settings->__invoke('general', 'site_text'); $preview = !empty($content['preview']) ? $content['preview'] : ''; $title = !empty($content['title']) ? $content['title'] : $this->settings->__invoke('general', 'site_name'); $this->placeholder->append("\r\n<meta itemprop='name' content='" . $this->settings->__invoke('general', 'site_name') . "'>\r\n"); // must be set from db $this->placeholder->append("<meta itemprop='description' content='" . substr(strip_tags($text), 0, 150) . "'>\r\n"); $this->placeholder->append("<meta itemprop='title' content='" . $title . "'>\r\n"); $this->placeholder->append("<meta itemprop='image' content='" . $preview . "'>\r\n"); $this->headMeta->appendName('keywords', $keywords); $this->headMeta->appendName('description', $description); $this->headMeta->appendName('viewport', 'width=device-width, initial-scale=1.0'); $this->headMeta->appendName('generator', $this->settings->__invoke('general', 'site_name')); $this->headMeta->appendName('apple-mobile-web-app-capable', 'yes'); $this->headMeta->appendName('application-name', $this->settings->__invoke('general', 'site_name')); $this->headMeta->appendName('mobile-web-app-capable', 'yes'); $this->headMeta->appendName('HandheldFriendly', 'True'); $this->headMeta->appendName('MobileOptimized', '320'); $this->headMeta->appendName('apple-mobile-web-app-status-bar-style', 'black-translucent'); $this->headMeta->appendName('author', 'Stanimir Dimitrov - stanimirdim92@gmail.com'); $this->headMeta->appendName('twitter:card', 'summary'); $this->headMeta->appendName('twitter:site', '@' . $this->settings->__invoke('general', 'site_name')); $this->headMeta->appendName('twitter:title', substr(strip_tags($title), 0, 70)); // max 70 chars $this->headMeta->appendName('twitter:description', substr(strip_tags($text), 0, 200)); $this->headMeta->appendName('twitter:image', $preview); // max 1MB $this->headMeta->appendProperty('og:image', $preview); $this->headMeta->appendProperty('og:title', $title); $this->headMeta->appendProperty('og:description', $description); $this->headMeta->appendProperty('og:type', 'article'); $this->headMeta->appendProperty('og:url', $this->request->getUri()->getHost() . $this->request->getRequestUri()); }
/** * @param string $to * @param string $toName * @param string $subject * @param string $message * @param string $from * @param string $fromName * * @return bool|FlashMessenger */ public function sendMail($to, $toName, $subject, $message, $from, $fromName) { $transport = new SmtpTransport(); $options = new SmtpOptions(['host' => $this->settings->__invoke('mail', 'host'), 'name' => $this->settings->__invoke('mail', 'name'), 'connection_class' => $this->settings->__invoke('mail', 'connection_class'), 'connection_config' => ['username' => $this->settings->__invoke('mail', 'username'), 'password' => $this->settings->__invoke('mail', 'password'), 'ssl' => $this->settings->__invoke('mail', 'ssl')], 'port' => $this->settings->__invoke('mail', 'port')]); $htmlPart = new MimePart($message); $htmlPart->type = 'text/html'; $body = new MimeMessage(); $body->setParts([$htmlPart]); $mail = new Message(); $mail->setFrom($from, $fromName); $mail->addTo($to, $toName); $mail->setSubject($subject); $mail->setEncoding('UTF-8'); $mail->setBody($body); $mail->getHeaders()->addHeaderLine('MIME-Version: 1.0'); $mail->getHeaders()->addHeaderLine('Content-Type', 'text/html; charset=UTF-8'); try { $transport->setOptions($options); $transport->send($mail); return true; } catch (\Exception $e) { return $this->flashMessenger->addMessage('Email not send', 'error'); } }