Exemple #1
0
 public function __construct()
 {
     $appFolder = Config::getInstance()->getFolderPath('app');
     $this->setRootFolder($appFolder . 'cache/');
     // also include all custom caches that extend BaseCache
     $this->modelCache = ModelCache::getInstance()->setRootFolder($appFolder . 'cache/');
     $this->templateCache = TemplateCache::getInstance()->setRootFolder($appFolder . 'cache/');
 }
Exemple #2
0
 public static function getDefaultLanguage()
 {
     $config = Config::getInstance();
     // first, take a look at env-specific value
     $languageCode = Config::getInstance()->getEnvSetting('defaultLanguage');
     // if not found, use non-env-specific value
     if ($languageCode == '') {
         $languageCode = $config->get('defaultLanguage');
     }
     // if still not found, go with English
     if ($languageCode == '') {
         $languageCode = 'en';
     }
     return $languageCode;
 }
Exemple #3
0
 public function addCommonAssets()
 {
     $config = Config::getInstance();
     $env = $config->get('ENV');
     // Add jQuery and bootstrap, serve local version only on MAMP, use CDN on TEST/PROD
     if ($env == 'MAMP') {
         $this->addStylesheetFile('/css/bootstrap.min.css');
         $this->addJavascriptFile('/js/jquery-1.10.2.min.js', true);
         $this->addJavascriptFile('/js/bootstrap.min.js', true);
     } else {
         $this->addStylesheetFile('https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css');
         $this->addJavascriptFile('https://code.jquery.com/jquery-1.10.2.min.js', true);
         $this->addJavascriptFile('https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js', true);
     }
     // Add more common assets in your own implementation of Page class
 }
Exemple #4
0
 /**
  * Send accumulated warnings to site administrator by email (if allowed in the config)
  *
  * @param string $channel
  */
 protected function sendWarnings($channel = '')
 {
     if ($this->muted) {
         $channel = 'none';
     } elseif ($channel == '') {
         $channel = Config::getInstance()->getEnvSetting('sendWarnings');
     }
     if ($channel != 'none') {
         $this->getReporter()->send($this, $channel);
     }
 }
Exemple #5
0
 /**
  * Transport mail message with PhpMailer library
  *
  * @param $to
  * @param $subj
  * @param $body
  * @param $hash
  * @param $intro
  * @param $options
  *
  * @return bool
  */
 public static function transportMailPhpMailer($to, $subj, $body, $hash, $intro, $options)
 {
     if (!is_array($to)) {
         $to = explode(',', $to);
     }
     $signature = Util::lavnn('signature', $options, 'team');
     $language = Util::lavnn('language', $options, 'en');
     $sender = Util::lavnn('sender', $options, 0);
     $config = Config::getInstance();
     $envConfig = $config->getEnvConfig();
     $mail = new \PHPMailer();
     $mail->isSMTP();
     // Set mailer to use SMTP
     $mail->Host = $config->get('SMTP_HOST');
     // Specify main and backup SMTP servers
     $mail->SMTPAuth = true;
     // Enable SMTP authentication
     $mail->Username = $config->get('SMTP_USER');
     // SMTP username
     $mail->Password = $config->get('SMTP_PASSWORD');
     // SMTP password
     $mail->SMTPSecure = 'tls';
     // Enable encryption, 'ssl' also accepted
     $mail->From = Util::lavnn('mailFrom', $envConfig, '*****@*****.**');
     $mail->FromName = Util::lavnn('mailFromName', $envConfig, 'Info@Tilpy');
     foreach ($to as $email) {
         $mail->addAddress($email);
     }
     $mail->addReplyTo($mail->From, $mail->FromName);
     /*
     $mail->addBCC('*****@*****.**');
     $mail->WordWrap = 50;                                 // Set word wrap to 50 characters
     $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
     $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
     */
     $mail->isHTML(true);
     // Set email format to HTML
     $mail->Subject = $subj;
     $mail->Body = self::prepareHtmlMail($subj, $body, $hash, $intro, $signature, $language, $sender);
     $mail->AltBody = $body = self::prepareTextMail($subj, $body, $hash, $intro, $signature, $language, $sender);
     $result = $mail->send();
     if (!$result) {
         // @TODO decide what to do with mail sending errors
         echo 'Message could not be sent.';
         echo 'Mailer Error: ' . $mail->ErrorInfo;
     }
     return $result;
 }