本文整理汇总了PHP中Railpage\AppCore::getSmarty方法的典型用法代码示例。如果您正苦于以下问题:PHP AppCore::getSmarty方法的具体用法?PHP AppCore::getSmarty怎么用?PHP AppCore::getSmarty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Railpage\AppCore
的用法示例。
在下文中一共展示了AppCore::getSmarty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: notifyWinner
/**
* Notify the winner
* @since Version 3.9.1
* @return \Railpage\Gallery\Competition
* @param \Railpage\Images\Competition
* @todo Check recipient preferences for email notifications
*/
public static function notifyWinner(Competition $compObject)
{
if (isset($compObject->meta['winnernotified']) && $compObject->meta['winnernotified'] === true) {
return $this;
}
if ($Photo = $compObject->getWinningPhoto()) {
/**
* Create a news article
*/
CompetitionUtility::createNewsArticle_Winner($compObject);
/**
* Create a site message
*/
CompetitionUtility::createSiteNotificationForWinner($compObject);
/**
* Create an email
*/
$Notification = new Notification();
$Notification->AddRecipient($Photo->Author->id, $Photo->Author->username, $Photo->Author->contact_email);
$Notification->subject = sprintf("Photo competition: %s", $compObject->title);
/**
* Set our email body
*/
$body = sprintf("Hi %s,\n\nCongratulations! You won the <a href='%s'>%s</a> photo competition!\n\nAs the winner of this competition, you get to <a href='%s'>select a theme</a> for the next competition. You have seven days to do so, before we automatically select one.\n\nThanks\nThe Railpage team.", $Photo->Author->username, $compObject->url->canonical, $compObject->title, "https://www.railpage.com.au" . $compObject->url->suggestsubject);
if (function_exists("wpautop") && function_exists("format_post")) {
$body = wpautop(format_post($body));
}
/**
* Assemble some template vars for our email
*/
foreach ($Photo->Image->sizes as $size) {
$hero = $size['source'];
if ($size['width'] >= 600) {
break;
}
}
$Smarty = AppCore::getSmarty();
$Smarty->Assign("email", array("subject" => $Notification->subject, "hero" => array("image" => $hero, "title" => sprintf("Winning photo: Yours! <em>%s</em>", $Photo->Image->title), "link" => $compObject->url->url, "author" => $Photo->Author->username), "body" => $body));
$Notification->body = $Smarty->Fetch($Smarty->ResolveTemplate("template.generic"));
$Notification->commit();
/**
* Update the winnernotified flag
*/
$compObject->meta['winnernotified'] = true;
$compObject->commit();
}
return $compObject;
}
示例2: Add
/**
* Add menu entry
* @since Version 3.8.6
* @param string $title The title of the breadcrumb item
* @param string $url An optional URL for this breadcrumb item
*/
public function Add($title = false, $url = false)
{
if (!$title) {
#throw new Exception("Cannot add item to menu - no title given");
return $this;
}
$i = count($this->menu);
$this->menu[$i]['title'] = $title;
if ($url) {
$this->menu[$i]['url'] = strval($url);
$Smarty = AppCore::getSmarty();
/**
* Pre-rendering
*/
if ($Smarty instanceof \Railpage\Template) {
$Smarty->prerender($url);
}
}
return $this;
}
示例3: formatText
/**
* Process the emoticons, BBCode, rich text, embedded content etc in this object and return as HTML
* @since Version 3.10.0
* @param string $string
* @param array $options
* @return string
*/
public static function formatText($string, $options)
{
AppCore::getSmarty()->addStylesheet("/themes/jiffy_simple/style/opt.embedded.css");
$defaultOptions = ["bbcode_uid" => "sausages", "flag_html" => true, "flag_bbcode" => true, "flag_emoticons" => true, "strip_formatting" => false, "editor_version" => 1];
$options = array_merge($defaultOptions, is_array($options) ? $options : []);
if (empty(trim($string))) {
throw new InvalidArgumentException("Cannot execute " . __METHOD__ . " as no text was provided!");
}
$cacheKey = "railpage:formatText=" . sha1((string) $string . json_encode($options)) . ";" . self::$formatTextVer;
$cacheProvider = AppCore::getMemcached();
$processedText = false;
if ($processedText = $cacheProvider->fetch($cacheKey)) {
return $processedText;
}
/**
* @todo
* - make clickable - doesn't seem to do anything? 24/03/2016
* - convert to UTF8 - is this still required? 24/03/2016
*/
$string = EmoticonsUtility::Process($string, $options['flag_emoticons']);
$string = Html::cleanupBadHtml($string, $options['editor_version']);
$string = Html::removeHeaders($string);
$string = BbcodeUtility::Process($string, $options['flag_bbcode']);
$string = MultimediaUtility::Process($string);
$string = MakeClickable::Process($string);
$string = Url::offsiteUrl((string) $string);
if (is_object($string)) {
$string = $string->__toString();
}
if ($options['strip_formatting'] == true) {
$string = strip_tags($string);
}
$rs = $cacheProvider->save($cacheKey, $string, 0);
// 3600 * 24 * 30);
return $string;
}
示例4: send
/**
* Send this message
* @since Version 3.3
* @version 3.3
* @return boolean
*/
public function send()
{
$this->validate();
$data = array("privmsgs_type" => PRIVMSGS_UNREAD_MAIL, "privmsgs_subject" => $this->subject, "privmsgs_from_userid" => $this->from_user_id, "privmsgs_to_userid" => $this->to_user_id, "privmsgs_date" => time(), "privmsgs_ip" => encode_ip($_SERVER['REMOTE_ADDR']), "privmsgs_enable_bbcode" => $this->enable_bbcode, "privmsgs_enable_html" => $this->enable_html, "privmsgs_enable_smilies" => $this->enable_smilies, "privmsgs_attach_sig" => $this->enable_signature, "object_id" => $this->object_id);
$this->db->insert("nuke_bbprivmsgs", $data);
$pm_id = $this->db->lastInsertId();
$this->id = $pm_id;
$data = array("privmsgs_text_id" => $pm_id, "privmsgs_bbcode_uid" => $this->bbcode_uid, "privmsgs_text" => function_exists("prepare_submit") ? prepare_submit($this->body) : $this->body);
$rs = $this->db->insert("nuke_bbprivmsgs_text", $data);
/**
* If the recipient doesn't want to be notified of a new message then return out
*/
if ($this->Recipient->notify_privmsg != 1) {
return;
}
/**
* Send a push notification
*/
$Push = new Notification();
$Push->transport = Notifications::TRANSPORT_PUSH;
$Push->subject = sprintf("[Private Messages] New message from %s", $this->Author->username);
$Push->body = sprintf("%s has sent you a new private message in the conversation titled \"%s\"", $this->Author->username, $this->subject);
$Push->setActionUrl(sprintf("/messages/conversation/%d", $this->id))->addRecipient($this->Recipient->id, $this->Recipient->username, $this->Recipient->username);
$Push->commit()->dispatch();
/**
* Template settings
*/
$Smarty = AppCore::getSmarty();
$Smarty->assign("server_addr", "www.railpage.com.au");
$Smarty->assign("message_id", $this->id);
$Smarty->assign("pm_from_username", $this->Author->username);
$Smarty->assign("userdata_username", $this->Recipient->username);
/**
* Create a user notification
*/
$Notification = new Notification();
$Notification->transport = Notifications::TRANSPORT_EMAIL;
$Notification->status = Notifications::STATUS_QUEUED;
$Notification->subject = sprintf("[Private Messages] New message from %s", $this->Author->username);
$Notification->addRecipient($this->Recipient->id, $this->Recipient->username, $this->Recipient->contact_email);
$tpl = $Smarty->ResolveTemplate("template.generic");
$email = array("subject" => sprintf("New message from %s", $this->Author->username), "subtitle" => "Private Messages", "body" => nl2br(sprintf("Hi %s,\n\n<a href='http://www.railpage.com.au%s?utm_medium&email&utm_source=private-messages&utm_campain=user-%d'>%s</a> has sent you a new <a href='http://www.railpage.com.au/messages/conversation/%d?utm_medium=email&utm_source=private-messages&utm_campaign=user-%d#%d'>private message</a> in the conversation titled <em>%s</em>.", $this->Recipient->username, $this->Author->url->url, $this->Author->id, $this->Author->username, $this->id, $this->Author->id, $this->id, $this->subject)));
$Smarty->Assign("email", $email);
$Notification->body = $Smarty->fetch($tpl);
$Notification->commit();
}
示例5: sendNotification
/**
* Send an email notification for this competition
* @since Version 3.9.1
* @param \Railpage\Images\Competition $photoComp
* @param array $notificationOptions
* @return void
* @todo Finish push notifications
*/
public static function sendNotification(Competition $photoComp, $notificationOptions)
{
if (count((new Competitions())->getPreviousContestants()) == 0) {
return false;
}
$flag = $notificationOptions['flag'];
if (!is_array($notificationOptions)) {
$notificationOptions = [];
}
// If we want to exclude contestants in this competition from this email, set this to true
// This is to remind contestants from previous comps to submit a photo
if (!isset($notificationOptions['excludeCurrentContestants'])) {
$notificationOptions['excludeCurrentContestants'] = false;
}
/**
* Check if the notification sent flag has been set
*/
if (!isset($photoComp->meta[$flag]) || !filter_var($photoComp->meta[$flag]) || $photoComp->meta[$flag] === false) {
/**
* Create the notification
*/
$Notification = new Notification();
$Notification->subject = $notificationOptions['subject'];
$Push = new Notification();
$Push->subject = $Notification->subject;
$Push->transport = Notifications::TRANSPORT_PUSH;
/**
* Add recipients and decoration
*/
$Notification = self::notificationDoRecipients($Notification, $photoComp, $notificationOptions);
$Push = self::notificationDoRecipients($Push, $photoComp, $notificationOptions);
/**
* Set our email body
*/
if (function_exists("wpautop") && function_exists("format_post")) {
$notificationOptions['body'] = wpautop(format_post($notificationOptions['body']));
}
/**
* Assemble some template vars for our email
*/
$Smarty = AppCore::getSmarty();
$Smarty->Assign("email", array("subject" => $notificationOptions['subject'], "body" => $notificationOptions['body']));
/**
* Set the body, submit the notification to the dispatch queue
*/
$Notification->body = $Smarty->Fetch($Smarty->ResolveTemplate("template.generic"));
$Notification->commit();
/**
* Set the notification flag
*/
$photoComp->meta[$flag] = true;
$photoComp->commit();
}
}
示例6: unBanUser
/**
* Unban user
* @since Version 3.2
* @version 3.2
* @param int $banId
* @param int|bool $userId
* @return boolean
*/
public function unBanUser($banId, $userId = null)
{
$success = false;
/**
* Empty the cache
*/
try {
$this->Memcached->delete("railpage:bancontrol.users");
$this->Memcached->delete(self::CACHE_KEY_ALL);
} catch (Exception $e) {
// throw it away
}
try {
$this->Redis->delete("railpage:bancontrol");
} catch (Exception $e) {
// throw it away
}
if ($banId instanceof User) {
$userId = $banId->id;
}
if ($userId == null) {
$query = "SELECT user_id FROM bancontrol WHERE id = ?";
$userId = $this->db->fetchOne($query, $banId);
}
if ($userId > 0) {
$data = array("ban_active" => 0);
$where = array("user_id = " . $userId);
$this->db->update("bancontrol", $data, $where);
$success = true;
$cachekey_user = sprintf(self::CACHE_KEY_USER, $userId);
$this->Memcached->save($cachekey_user, false, strtotime("+5 weeks"));
}
if ($success) {
// Tell the world that they've been unbanned
$ThisUser = UserFactory::CreateUser($userId);
$ThisUser->active = 1;
$ThisUser->location = "";
$ThisUser->signature = "";
$ThisUser->avatar = "";
$ThisUser->interests = "";
$ThisUser->occupation = "";
try {
$ThisUser->commit();
$Smarty = AppCore::getSmarty();
// Send the ban email
$Smarty->Assign("userdata_username", $ThisUser->username);
// Send the confirmation email
$Notification = new Notification();
$Notification->addRecipient($ThisUser->id, $ThisUser->username, $ThisUser->contact_email);
$Notification->body = $Smarty->Fetch($Smarty->ResolveTemplate("email_unban"));
$Notification->subject = "Railpage account re-activation";
$Notification->transport = Notifications::TRANSPORT_EMAIL;
$Notification->commit()->dispatch();
return true;
} catch (Exception $e) {
global $Error;
if (isset($Error)) {
$Error->save($e, $_SESSION['user_id']);
}
Debug::logException($e);
}
}
return false;
}
示例7: send
/**
* Send this reminder
* @since Version 3.8.7
* @return \Railpage\Reminders\Reminder
* @param boolean $markAsSent Flag to indicate if this is a test notification or not
*/
public function send($markAsSent = false)
{
$this->validate();
$Smarty = AppCore::getSmarty();
/**
* Set some vars
*/
$email = array("subject" => $this->title, "body" => wpautop(format_post($this->text)));
/**
* Try and load the object to get some fancy stuff from it
*/
try {
$classname = sprintf("\\%s", $this->object);
$Object = new $classname($this->object_id);
$email['subtitle'] = "Railpage \\ " . $Object->Module->name;
if (isset($Object->meta['coverphoto']) && !empty($Object->meta['coverphoto'])) {
if ($CoverPhoto = (new Images())->getImageFromUrl($Object->meta['coverphoto'])) {
$email['hero'] = array("title" => isset($Object->name) ? $Object->name : $Object->title, "link" => isset($Object->url->canonical) ? $Object->url->canonical : sprintf("http://www.railpage.com.au%s", (string) $Object->url), "author" => isset($CoverPhoto->author->realname) && !empty($CoverPhoto->author->realname) ? $CoverPhoto->author->realname : $CoverPhoto->author->username);
if (strpos($email['hero']['link'], "http://") === false) {
$email['hero']['link'] = "http://www.railpage.com.au" . $email['hero']['link'];
}
if (strpos($email['hero']['link'], "railpage.com.au") === false) {
$email['hero']['link'] = sprintf("http://www.railpage.com.au%s", (string) $Object->url);
}
$utm = ["utm_source=reminder", "utm_medium=email", sprintf("utm_campaign=%s", ContentUtility::generateUrlSlug($this->title))];
$joiner = strpos($email['hero']['link'], "?") === false ? "?" : "&";
$email['hero']['link'] .= $joiner . implode("&", $utm);
foreach ($CoverPhoto->sizes as $size) {
if ($size >= 620) {
$email['hero']['image'] = $size['source'];
}
}
}
}
} catch (Exception $e) {
}
/**
* Process and fetch the email template
*/
$tpl = $Smarty->ResolveTemplate("template.reminder");
$Smarty->Assign("email", $email);
$body = $Smarty->Fetch($tpl);
$Notification = new Notification();
$Notification->subject = $this->title;
$Notification->body = $body;
$Notification->addRecipient($this->User->id, $this->User->username, $this->User->contact_email);
$Notification->commit();
if ($markAsSent) {
$this->sent = true;
$this->Dispatched = new DateTime();
$this->commit();
}
/**
* Start composing and sending the email
*/
/*
$message = Swift_Message::newInstance()
->setSubject($this->title)
->setFrom(array(
$this->Config->SMTP->username => $this->Config->SiteName
))
->setTo(array(
$this->User->contact_email => !empty($this->User->realname) ? $this->User->realname : $this->User->username
))
->setBody($body, 'text/html');
$transport = Swift_SmtpTransport::newInstance($this->Config->SMTP->host, $this->Config->SMTP->port, $this->Config->SMTP->TLS = true ? "tls" : NULL)
->setUsername($this->Config->SMTP->username)
->setPassword($this->Config->SMTP->password);
$mailer = Swift_Mailer::newInstance($transport);
if ($result = $mailer->send($message)) {
if ($markAsSent) {
$this->sent = true;
$this->Dispatched = new DateTime;
$this->commit();
}
}
*/
return $this;
}