/** * Prepares JS for inclusion in the template. * * @param string $js The Javascript code. * @param bool $first Whether the Javascript code should be included before any other Javascript code that was * already included with this method. * * @return null */ public function includeJs($js, $first = false) { // Trim any whitespace and ensure it ends with a semicolon. $js = trim($js, " \t\n\r\v;") . ';'; $latestBuffer =& $this->_jsBuffers[count($this->_jsBuffers) - 1]; ArrayHelper::prependOrAppend($latestBuffer, $js, $first); }
/** * Prepares JS for inclusion in the template. * * @param string $js The Javascript code. * @param bool $first Whether the Javascript code should be included before any other Javascript code that was * already included with this method. * * @return null */ public function includeJs($js, $first = false) { $latestBuffer =& $this->_jsBuffers[count($this->_jsBuffers) - 1]; ArrayHelper::prependOrAppend($latestBuffer, trim($js), $first); }
/** * Prepares JS for inclusion in the template. * * @param $js * @param bool|null $first * @return void */ public function includeJs($js, $first = false) { ArrayHelper::prependOrAppend($this->_js, trim($js), $first); }
/** * Send Email Notification * */ public function sendEmailNotification($form, $files, $postData, $customEmail, $customSubject, $message, $html = true, $email = null) { $errors = false; $attributes = $form->getAttributes(); $notificationSettings = $attributes['notificationSettings']; $toEmails = ArrayHelper::stringToArray($notificationSettings['emailSettings']['notifyEmail']); $emailSettings = craft()->email->getSettings(); if (isset($notificationSettings['replyTo']) && $notificationSettings['replyTo'] != '') { $replyTo = $postData[$notificationSettings['replyTo']]; } else { $replyTo = $emailSettings['emailAddress']; } // Process Subject Line if ($customSubject) { $subject = $customSubject; } else { $subject = $notificationSettings['emailSettings']['emailSubject']; } if ($customEmail != '') { $theEmailAddress = explode('|', $customEmail); ArrayHelper::prependOrAppend($toEmails, $theEmailAddress[0], true); } foreach ($toEmails as $toEmail) { $email = new EmailModel(); $email->fromEmail = $emailSettings['emailAddress']; $email->replyTo = $replyTo; $email->sender = $emailSettings['emailAddress']; $email->fromName = $form->name; $email->toEmail = $toEmail; $email->subject = $subject; $email->htmlBody = $message; // Attach files to email if (!empty($files)) { foreach ($files as $attachment) { $email->addAttachment($attachment['tempPath'], $attachment['filename'], 'base64', $attachment['type']); } } if (!craft()->email->sendEmail($email)) { $errors = true; } } return $errors ? false : true; }