当前位置: 首页>>代码示例>>PHP>>正文


PHP Gdn_Format::plainText方法代码示例

本文整理汇总了PHP中Gdn_Format::plainText方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Format::plainText方法的具体用法?PHP Gdn_Format::plainText怎么用?PHP Gdn_Format::plainText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gdn_Format的用法示例。


在下文中一共展示了Gdn_Format::plainText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pluginController_quoteMention_create

 public function pluginController_quoteMention_create($sender, $discussionID, $commentID, $username)
 {
     $sender->deliveryMethod(DELIVERY_METHOD_JSON);
     $user = Gdn::userModel()->getByUsername($username);
     $discussionModel = new DiscussionModel();
     $discussion = $discussionModel->getID($discussionID);
     if (!$user || !$discussion) {
         throw notFoundException();
     }
     // Make sure this endpoint can't be used to snoop around.
     $sender->permission('Vanilla.Discussions.View', true, 'Category', $discussion->PermissionCategoryID);
     // Find the previous comment of the mentioned user in this discussion.
     $item = Gdn::sql()->getWhere('Comment', ['DiscussionID' => $discussion->DiscussionID, 'InsertUserID' => $user->UserID, 'CommentID <' => $commentID], 'CommentID', 'desc', 1)->firstRow();
     // The items ID in the DOM used for highlighting.
     if ($item) {
         $target = '#Comment_' . $item->CommentID;
         // The mentioned user might be the discussion creator.
     } elseif ($discussion->InsertUserID == $user->UserID) {
         $item = $discussion;
         $target = '#Discussion_' . $item->DiscussionID;
     }
     if (!$item) {
         // A success response code always means that a comment was found.
         $sender->statusCode(404);
     }
     $sender->renderData($item ? ['html' => nl2br(sliceString(Gdn_Format::plainText($item->Body, $item->Format), c('QuoteMention.MaxLength', 400))), 'target' => $target] : []);
 }
开发者ID:bleistivt,项目名称:quotemention,代码行数:27,代码来源:class.quotemention.plugin.php

示例2: addLabel

 /**
  *
  *
  * @param $Name
  * @param string $Code
  * @param string $Url
  */
 public function addLabel($Name, $Code = '', $Url = '')
 {
     if ($Code == '') {
         $Code = Gdn_Format::url(ucwords(trim(Gdn_Format::plainText($Name))));
     }
     $this->_Labels[] = array('Name' => $Name, 'Code' => $Code, 'Url' => $Url);
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:14,代码来源:class.togglemenumodule.php

示例3: informNotifications

 /**
  * Grabs all new notifications and adds them to the sender's inform queue.
  *
  * This method gets called by dashboard's hooks file to display new
  * notifications on every pageload.
  *
  * @since 2.0.18
  * @access public
  *
  * @param Gdn_Controller $Sender The object calling this method.
  */
 public static function informNotifications($Sender)
 {
     $Session = Gdn::session();
     if (!$Session->isValid()) {
         return;
     }
     $ActivityModel = new ActivityModel();
     // Get five pending notifications.
     $Where = array('NotifyUserID' => Gdn::session()->UserID, 'Notified' => ActivityModel::SENT_PENDING);
     // If we're in the middle of a visit only get very recent notifications.
     $Where['DateUpdated >'] = Gdn_Format::toDateTime(strtotime('-5 minutes'));
     $Activities = $ActivityModel->getWhere($Where, 0, 5)->resultArray();
     $ActivityIDs = array_column($Activities, 'ActivityID');
     $ActivityModel->setNotified($ActivityIDs);
     $Sender->EventArguments['Activities'] =& $Activities;
     $Sender->fireEvent('InformNotifications');
     foreach ($Activities as $Activity) {
         if ($Activity['Photo']) {
             $UserPhoto = anchor(img($Activity['Photo'], array('class' => 'ProfilePhotoMedium')), $Activity['Url'], 'Icon');
         } else {
             $UserPhoto = '';
         }
         $Excerpt = Gdn_Format::plainText($Activity['Story']);
         $ActivityClass = ' Activity-' . $Activity['ActivityType'];
         $Sender->informMessage($UserPhoto . Wrap($Activity['Headline'], 'div', array('class' => 'Title')) . Wrap($Excerpt, 'div', array('class' => 'Excerpt')), 'Dismissable AutoDismiss' . $ActivityClass . ($UserPhoto == '' ? '' : ' HasIcon'));
     }
 }
开发者ID:austins,项目名称:vanilla,代码行数:38,代码来源:class.notificationscontroller.php

示例4: index

 /**
  * Homepage & single addon view.
  *
  * @param string $ID The addon to view.
  * @throws Exception Addon not found.
  */
 public function index($ID = '')
 {
     if ($ID != '') {
         $Addon = $this->AddonModel->getSlug($ID, true);
         if (!is_array($Addon)) {
             throw notFoundException('Addon');
         } else {
             $this->addCssFile('confidence.css');
             $AddonID = $Addon['AddonID'];
             $this->setData($Addon);
             $Description = val('Description', $Addon);
             if ($Description) {
                 $this->Head->addTag('meta', array('name' => 'description', 'content' => Gdn_Format::plainText($Description, false)));
             }
             $this->addCssFile('fancyzoom.css');
             $this->addJsFile('fancyzoom.js');
             $this->addJsFile('addon.js');
             $PictureModel = new Gdn_Model('AddonPicture');
             $this->PictureData = $PictureModel->getWhere(array('AddonID' => $AddonID));
             $DiscussionModel = new DiscussionModel();
             $this->DiscussionData = $DiscussionModel->get(0, 50, array('AddonID' => $AddonID));
             $this->View = 'addon';
             $this->title($this->data('Name') . ' ' . $this->data('Version'));
             // Set the canonical url.
             $this->canonicalUrl(url('/addon/' . AddonModel::slug($Addon, false), true));
             $this->loadConfidenceRecord($Addon);
         }
     } else {
         $this->View = 'browse';
         $this->browse();
         return;
     }
     $this->addModule('AddonHelpModule');
     $this->setData('_Types', AddonModel::$Types);
     $this->setData('_TypesPlural', AddonModel::$TypesPlural);
     $this->render();
 }
开发者ID:vanilla,项目名称:community,代码行数:43,代码来源:class.addoncontroller.php

示例5: postController_twitter_create

 /**
  *
  *
  * @param PostController $Sender
  * @param type $RecordType
  * @param type $ID
  * @throws type
  */
 public function postController_twitter_create($Sender, $RecordType, $ID)
 {
     if (!$this->socialReactions()) {
         throw permissionException();
     }
     //      if (!Gdn::request()->isPostBack())
     //         throw permissionException('Javascript');
     $Row = GetRecord($RecordType, $ID, true);
     if ($Row) {
         // Grab the tweet message.
         switch (strtolower($RecordType)) {
             case 'discussion':
                 $Message = Gdn_Format::plainText($Row['Name'], 'Text');
                 break;
             case 'comment':
             default:
                 $Message = Gdn_Format::plainText($Row['Body'], $Row['Format']);
         }
         $Elips = '...';
         $Message = preg_replace('`\\s+`', ' ', $Message);
         //         if (function_exists('normalizer_is_normalized')) {
         //            // Slice the string to 119 characters (21 reservered for the url.
         //            if (!normalizer_is_normalized($Message))
         //               $Message = Normalizer::normalize($Message, Normalizer::FORM_D);
         //            $Elips = Normalizer::normalize($Elips, Normalizer::FORM_D);
         //         }
         $Max = 140;
         $LinkLen = 22;
         $Max -= $LinkLen;
         $Message = SliceParagraph($Message, $Max);
         if (strlen($Message) > $Max) {
             $Message = substr($Message, 0, $Max - strlen($Elips)) . $Elips;
         }
         //         echo $Message.strlen($Message);
         if ($this->accessToken()) {
             Gdn::controller()->setData('Message', $Message);
             $Message .= ' ' . $Row['ShareUrl'];
             $R = $this->api('/statuses/update.json', array('status' => $Message), 'POST');
             $Sender->setJson('R', $R);
             $Sender->informMessage(t('Thanks for sharing!'));
         } else {
             $Get = array('text' => $Message, 'url' => $Row['ShareUrl']);
             $Url = "https://twitter.com/share?" . http_build_query($Get);
             redirect($Url);
         }
     }
     $Sender->render('Blank', 'Utility', 'Dashboard');
 }
开发者ID:korelstar,项目名称:vanilla,代码行数:56,代码来源:class.twitter.plugin.php

示例6: index

 /**
  * Default single discussion display.
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $DiscussionID Unique discussion ID
  * @param string $DiscussionStub URL-safe title slug
  * @param int $Page The current page of comments
  */
 public function index($DiscussionID = '', $DiscussionStub = '', $Page = '')
 {
     // Setup head
     $Session = Gdn::session();
     $this->addJsFile('jquery.autosize.min.js');
     $this->addJsFile('autosave.js');
     $this->addJsFile('discussion.js');
     Gdn_Theme::section('Discussion');
     // Load the discussion record
     $DiscussionID = is_numeric($DiscussionID) && $DiscussionID > 0 ? $DiscussionID : 0;
     if (!array_key_exists('Discussion', $this->Data)) {
         $this->setData('Discussion', $this->DiscussionModel->getID($DiscussionID), true);
     }
     if (!is_object($this->Discussion)) {
         $this->EventArguments['DiscussionID'] = $DiscussionID;
         $this->fireEvent('DiscussionNotFound');
         throw notFoundException('Discussion');
     }
     // Define the query offset & limit.
     $Limit = c('Vanilla.Comments.PerPage', 30);
     $OffsetProvided = $Page != '';
     list($Offset, $Limit) = offsetLimit($Page, $Limit);
     // Check permissions
     $this->permission('Vanilla.Discussions.View', true, 'Category', $this->Discussion->PermissionCategoryID);
     $this->setData('CategoryID', $this->CategoryID = $this->Discussion->CategoryID, true);
     if (strcasecmp(val('Type', $this->Discussion), 'redirect') === 0) {
         $this->redirectDiscussion($this->Discussion);
     }
     $Category = CategoryModel::categories($this->Discussion->CategoryID);
     $this->setData('Category', $Category);
     if ($CategoryCssClass = val('CssClass', $Category)) {
         Gdn_Theme::section($CategoryCssClass);
     }
     $this->setData('Breadcrumbs', CategoryModel::getAncestors($this->CategoryID));
     // Setup
     $this->title($this->Discussion->Name);
     // Actual number of comments, excluding the discussion itself.
     $ActualResponses = $this->Discussion->CountComments;
     $this->Offset = $Offset;
     if (c('Vanilla.Comments.AutoOffset')) {
         //         if ($this->Discussion->CountCommentWatch > 1 && $OffsetProvided == '')
         //            $this->addDefinition('ScrollTo', 'a[name=Item_'.$this->Discussion->CountCommentWatch.']');
         if (!is_numeric($this->Offset) || $this->Offset < 0 || !$OffsetProvided) {
             // Round down to the appropriate offset based on the user's read comments & comments per page
             $CountCommentWatch = $this->Discussion->CountCommentWatch > 0 ? $this->Discussion->CountCommentWatch : 0;
             if ($CountCommentWatch > $ActualResponses) {
                 $CountCommentWatch = $ActualResponses;
             }
             // (((67 comments / 10 perpage) = 6.7) rounded down = 6) * 10 perpage = offset 60;
             $this->Offset = floor($CountCommentWatch / $Limit) * $Limit;
         }
         if ($ActualResponses <= $Limit) {
             $this->Offset = 0;
         }
         if ($this->Offset == $ActualResponses) {
             $this->Offset -= $Limit;
         }
     } else {
         if ($this->Offset == '') {
             $this->Offset = 0;
         }
     }
     if ($this->Offset < 0) {
         $this->Offset = 0;
     }
     $LatestItem = $this->Discussion->CountCommentWatch;
     if ($LatestItem === null) {
         $LatestItem = 0;
     } elseif ($LatestItem < $this->Discussion->CountComments) {
         $LatestItem += 1;
     }
     $this->setData('_LatestItem', $LatestItem);
     // Set the canonical url to have the proper page title.
     $this->canonicalUrl(discussionUrl($this->Discussion, pageNumber($this->Offset, $Limit, 0, false)));
     //      url(ConcatSep('/', 'discussion/'.$this->Discussion->DiscussionID.'/'. Gdn_Format::url($this->Discussion->Name), PageNumber($this->Offset, $Limit, TRUE, Gdn::session()->UserID != 0)), true), Gdn::session()->UserID == 0);
     // Load the comments
     $this->setData('Comments', $this->CommentModel->get($DiscussionID, $Limit, $this->Offset));
     $PageNumber = PageNumber($this->Offset, $Limit);
     $this->setData('Page', $PageNumber);
     $this->_SetOpenGraph();
     include_once PATH_LIBRARY . '/vendors/simplehtmldom/simple_html_dom.php';
     if ($PageNumber == 1) {
         $this->description(sliceParagraph(Gdn_Format::plainText($this->Discussion->Body, $this->Discussion->Format), 160));
         // Add images to head for open graph
         $Dom = str_get_html(Gdn_Format::to($this->Discussion->Body, $this->Discussion->Format));
     } else {
         $this->Data['Title'] .= sprintf(t(' - Page %s'), PageNumber($this->Offset, $Limit));
         $FirstComment = $this->data('Comments')->firstRow();
         $FirstBody = val('Body', $FirstComment);
         $FirstFormat = val('Format', $FirstComment);
//.........这里部分代码省略.........
开发者ID:caidongyun,项目名称:vanilla,代码行数:101,代码来源:class.discussioncontroller.php

示例7: plainTextEmail

 /**
  * Renders a plaintext email.
  *
  * @return string A plaintext email.
  */
 protected function plainTextEmail()
 {
     $email = ['banner' => val('alt', $this->image) . ' ' . val('link', $this->image), 'title' => $this->getTitle(), 'lead' => $this->getLead(), 'message' => $this->getMessage(), 'button' => sprintf(t('%s: %s'), val('text', $this->button), val('url', $this->button)), 'footer' => $this->getFooter()];
     foreach ($email as $key => $val) {
         if (!$val) {
             unset($email[$key]);
         } else {
             if ($key == 'message') {
                 $email[$key] = "<br>{$val}<br>";
             }
         }
     }
     return Gdn_Format::plainText(Gdn_Format::text(implode('<br>', $email), false));
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:19,代码来源:class.emailtemplate.php

示例8: index

 /**
  * Default search functionality.
  *
  * @since 2.0.0
  * @access public
  * @param int $Page Page number.
  */
 public function index($Page = '')
 {
     $this->addJsFile('search.js');
     $this->title(t('Search'));
     saveToConfig('Garden.Format.EmbedSize', '160x90', false);
     Gdn_Theme::section('SearchResults');
     list($Offset, $Limit) = offsetLimit($Page, c('Garden.Search.PerPage', 20));
     $this->setData('_Limit', $Limit);
     $Search = $this->Form->getFormValue('Search');
     $Mode = $this->Form->getFormValue('Mode');
     if ($Mode) {
         $this->SearchModel->ForceSearchMode = $Mode;
     }
     try {
         $ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit);
     } catch (Gdn_UserException $Ex) {
         $this->Form->addError($Ex);
         $ResultSet = array();
     } catch (Exception $Ex) {
         LogException($Ex);
         $this->Form->addError($Ex);
         $ResultSet = array();
     }
     Gdn::userModel()->joinUsers($ResultSet, array('UserID'));
     // Fix up the summaries.
     $SearchTerms = explode(' ', Gdn_Format::text($Search));
     foreach ($ResultSet as &$Row) {
         $Row['Summary'] = SearchExcerpt(Gdn_Format::plainText($Row['Summary'], $Row['Format']), $SearchTerms);
         $Row['Summary'] = Emoji::instance()->translateToHtml($Row['Summary']);
         $Row['Format'] = 'Html';
     }
     $this->setData('SearchResults', $ResultSet, true);
     $this->setData('SearchTerm', Gdn_Format::text($Search), true);
     if ($ResultSet) {
         $NumResults = count($ResultSet);
     } else {
         $NumResults = 0;
     }
     if ($NumResults == $Offset + $Limit) {
         $NumResults++;
     }
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $this->Pager = $PagerFactory->GetPager('MorePager', $this);
     $this->Pager->MoreCode = 'More Results';
     $this->Pager->LessCode = 'Previous Results';
     $this->Pager->ClientID = 'Pager';
     $this->Pager->configure($Offset, $Limit, $NumResults, 'dashboard/search/%1$s/%2$s/?Search=' . Gdn_Format::url($Search));
     //		if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
     //         $this->setJson('LessRow', $this->Pager->toString('less'));
     //         $this->setJson('MoreRow', $this->Pager->toString('more'));
     //         $this->View = 'results';
     //      }
     $this->canonicalUrl(url('search', true));
     $this->render();
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:63,代码来源:class.searchcontroller.php

示例9: url

        ?>
            <li class="Item" rel="<?php 
        echo url("/messages/{$Row['ConversationID']}#Message_{$Row['LastMessageID']}");
        ?>
">
                <div class="Author Photo"><?php 
        echo userPhoto($PhotoUser);
        ?>
</div>
                <div class="ItemContent">
                    <b class="Subject"><?php 
        echo anchor($Subject, "/messages/{$Row['ConversationID']}#Message_{$Row['LastMessageID']}");
        ?>
</b>
                    <?php 
        $Excerpt = sliceString(Gdn_Format::plainText($Row['LastBody'], $Row['LastFormat']), 80);
        echo wrap(nl2br(htmlspecialchars($Excerpt)), 'div', array('class' => 'Excerpt'));
        ?>
                    <div class="Meta">
                        <?php 
        echo ' <span class="MItem">' . plural($Row['CountMessages'], '%s message', '%s messages') . '</span> ';
        if ($Row['CountNewMessages'] > 0) {
            echo ' <strong class="HasNew"> ' . plural($Row['CountNewMessages'], '%s new', '%s new') . '</strong> ';
        }
        echo ' <span class="MItem">' . Gdn_Format::date($Row['LastDateInserted']) . '</span> ';
        ?>
                    </div>
                </div>
            </li>
        <?php 
    }
开发者ID:dimassrio,项目名称:vanilla,代码行数:31,代码来源:popin.php

示例10: formatQuote

    /**
     *
     *
     * @param $Type
     * @param $ID
     * @param $QuoteData
     * @param bool $Format
     */
    protected function formatQuote($Type, $ID, &$QuoteData, $Format = false)
    {
        // Temporarily disable Emoji parsing (prevent double-parsing to HTML)
        $emojiEnabled = Emoji::instance()->enabled;
        Emoji::instance()->enabled = false;
        if (!$Format) {
            $Format = c('Garden.InputFormatter');
        }
        $Type = strtolower($Type);
        $Model = false;
        switch ($Type) {
            case 'comment':
                $Model = new CommentModel();
                break;
            case 'discussion':
                $Model = new DiscussionModel();
                break;
            default:
                break;
        }
        //$QuoteData = array();
        if ($Model) {
            $Data = $Model->getID($ID);
            $NewFormat = $Format;
            if ($NewFormat == 'Wysiwyg') {
                $NewFormat = 'Html';
            }
            $QuoteFormat = $Data->Format;
            if ($QuoteFormat == 'Wysiwyg') {
                $QuoteFormat = 'Html';
            }
            // Perform transcoding if possible
            $NewBody = $Data->Body;
            if ($QuoteFormat != $NewFormat) {
                if (in_array($NewFormat, array('Html', 'Wysiwyg'))) {
                    $NewBody = Gdn_Format::to($NewBody, $QuoteFormat);
                } elseif ($QuoteFormat == 'Html' && $NewFormat == 'BBCode') {
                    $NewBody = Gdn_Format::text($NewBody, false);
                } elseif ($QuoteFormat == 'Text' && $NewFormat == 'BBCode') {
                    $NewBody = Gdn_Format::text($NewBody, false);
                } else {
                    $NewBody = Gdn_Format::plainText($NewBody, $QuoteFormat);
                }
                if (!in_array($NewFormat, array('Html', 'Wysiwyg'))) {
                    Gdn::controller()->informMessage(sprintf(t('The quote had to be converted from %s to %s.', 'The quote had to be converted from %s to %s. Some formatting may have been lost.'), htmlspecialchars($QuoteFormat), htmlspecialchars($NewFormat)));
                }
            }
            $Data->Body = $NewBody;
            // Format the quote according to the format.
            switch ($Format) {
                case 'Html':
                    // HTML
                    $Quote = '<blockquote class="Quote" rel="' . htmlspecialchars($Data->InsertName) . '">' . $Data->Body . '</blockquote>' . "\n";
                    break;
                case 'BBCode':
                    $Author = htmlspecialchars($Data->InsertName);
                    if ($ID) {
                        $IDString = ';' . htmlspecialchars($ID);
                    }
                    $QuoteBody = $Data->Body;
                    // TODO: Strip inner quotes...
                    //                  $QuoteBody = trim(preg_replace('`(\[quote.*/quote\])`si', '', $QuoteBody));
                    $Quote = <<<BQ
[quote="{$Author}{$IDString}"]{$QuoteBody}[/quote]

BQ;
                    break;
                case 'Markdown':
                case 'Display':
                case 'Text':
                    $QuoteBody = $Data->Body;
                    // Strip inner quotes and mentions...
                    $QuoteBody = self::_stripMarkdownQuotes($QuoteBody);
                    $QuoteBody = self::_stripMentions($QuoteBody);
                    $Quote = '> ' . sprintf(t('%s said:'), '@' . $Data->InsertName) . "\n" . '> ' . str_replace("\n", "\n> ", $QuoteBody) . "\n";
                    break;
                case 'Wysiwyg':
                    $Attribution = sprintf(t('%s said:'), userAnchor($Data, null, array('Px' => 'Insert')));
                    $QuoteBody = $Data->Body;
                    // TODO: Strip inner quotes...
                    //                  $QuoteBody = trim(preg_replace('`(<blockquote.*/blockquote>)`si', '', $QuoteBody));
                    $Quote = <<<BLOCKQUOTE
<blockquote class="Quote">
  <div class="QuoteAuthor">{$Attribution}</div>
  <div class="QuoteText">{$QuoteBody}</div>
</blockquote>

BLOCKQUOTE;
                    break;
            }
            $QuoteData = array_merge($QuoteData, array('status' => 'success', 'body' => $Quote, 'format' => $Format, 'authorid' => $Data->InsertUserID, 'authorname' => $Data->InsertName, 'type' => $Type, 'typeid' => $ID));
        }
//.........这里部分代码省略.........
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:101,代码来源:class.quotes.plugin.php

示例11: postController_facebook_create

 /**
  *
  * @param PostController $Sender
  * @param type $RecordType
  * @param type $ID
  * @throws type
  */
 public function postController_facebook_create($Sender, $RecordType, $ID)
 {
     if (!$this->socialReactions()) {
         throw permissionException();
     }
     $Row = getRecord($RecordType, $ID, true);
     if ($Row) {
         $Message = sliceParagraph(Gdn_Format::plainText($Row['Body'], $Row['Format']), 160);
         if ($this->accessToken() && $Sender->Request->isPostBack()) {
             $R = $this->api('/me/feed', array('link' => $Row['ShareUrl'], 'message' => $Message));
             $Sender->setJson('R', $R);
             $Sender->informMessage(t('Thanks for sharing!'));
         } else {
             $Get = array('app_id' => c('Plugins.Facebook.ApplicationID'), 'link' => $Row['ShareUrl'], 'name' => Gdn_Format::plainText($Row['Name'], 'Text'), 'description' => $Message, 'redirect_uri' => url('/post/shared/facebook', true));
             $Url = 'http://www.facebook.com/dialog/feed?' . http_build_query($Get);
             redirect($Url);
         }
     }
     $Sender->render('Blank', 'Utility', 'Dashboard');
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:27,代码来源:class.facebook.plugin.php

示例12: plainTextEmail

 /**
  * Renders a plaintext email.
  *
  * @return string A plaintext email.
  */
 protected function plainTextEmail()
 {
     return Gdn_Format::plainText(Gdn_Format::text($this->getMessage()));
 }
开发者ID:R-J,项目名称:vanilla,代码行数:9,代码来源:class.rawemailtemplate.php

示例13: userPhoto

                $LastPhoto = userPhoto($User);
                if ($LastPhoto) {
                    break;
                }
            } elseif (!$LastPhoto) {
                $LastPhoto = userPhoto($User);
            }
        }
    }
    $CssClass = 'Item';
    $CssClass .= $Alt ? ' Alt' : '';
    $CssClass .= $Conversation->CountNewMessages > 0 ? ' New' : '';
    $CssClass .= $LastPhoto != '' ? ' HasPhoto' : '';
    $CssClass .= ' ' . ($Conversation->CountNewMessages <= 0 ? 'Read' : 'Unread');
    $JumpToItem = $Conversation->CountMessages - $Conversation->CountNewMessages;
    $Message = sliceString(Gdn_Format::plainText($Conversation->LastBody, $Conversation->LastFormat), 100);
    if (stringIsNullOrEmpty(trim($Message))) {
        $Message = t('Blank Message');
    }
    $this->EventArguments['Conversation'] = $Conversation;
    ?>
    <li class="<?php 
    echo $CssClass;
    ?>
">
        <?php 
    $Names = ConversationModel::participantTitle($Conversation, false);
    ?>
        <div class="ItemContent Conversation">
            <?php 
    $Url = '/messages/' . $Conversation->ConversationID . '/#Item_' . $JumpToItem;
开发者ID:vanilla,项目名称:vanilla,代码行数:31,代码来源:conversations.php

示例14: queueNotification

 /**
  * Queue a notification for sending.
  *
  * @since 2.0.17
  * @access public
  * @param int $ActivityID
  * @param string $Story
  * @param string $Position
  * @param bool $Force
  */
 public function queueNotification($ActivityID, $Story = '', $Position = 'last', $Force = false)
 {
     $Activity = $this->getID($ActivityID);
     if (!is_object($Activity)) {
         return;
     }
     $Story = Gdn_Format::text($Story == '' ? $Activity->Story : $Story, false);
     // If this is a comment on another activity, fudge the activity a bit so that everything appears properly.
     if (is_null($Activity->RegardingUserID) && $Activity->CommentActivityID > 0) {
         $CommentActivity = $this->getID($Activity->CommentActivityID);
         $Activity->RegardingUserID = $CommentActivity->RegardingUserID;
         $Activity->Route = '/activity/item/' . $Activity->CommentActivityID;
     }
     $User = Gdn::userModel()->getID($Activity->RegardingUserID, DATASET_TYPE_OBJECT);
     //$this->SQL->select('UserID, Name, Email, Preferences')->from('User')->where('UserID', $Activity->RegardingUserID)->get()->firstRow();
     if ($User) {
         if ($Force) {
             $Preference = $Force;
         } else {
             //            $Preferences = Gdn_Format::Unserialize($User->Preferences);
             $ConfigPreference = c('Preferences.Email.' . $Activity->ActivityType, '0');
             if ($ConfigPreference !== false) {
                 $Preference = val('Email.' . $Activity->ActivityType, $User->Preferences, $ConfigPreference);
             } else {
                 $Preference = false;
             }
         }
         if ($Preference) {
             $ActivityHeadline = Gdn_Format::text(Gdn_Format::activityHeadline($Activity, $Activity->ActivityUserID, $Activity->RegardingUserID), false);
             $Email = new Gdn_Email();
             $Email->subject(sprintf(t('[%1$s] %2$s'), Gdn::config('Garden.Title'), $ActivityHeadline));
             $Email->to($User);
             $url = externalUrl(val('Route', $Activity) == '' ? '/' : val('Route', $Activity));
             $emailTemplate = $Email->getEmailTemplate()->setButton($url, t('Check it out'))->setTitle(Gdn_Format::plainText(val('Headline', $Activity)));
             if ($message = val('Story', $Activity)) {
                 $emailTemplate->setMessage($message, true);
             }
             $Email->setEmailTemplate($emailTemplate);
             if (!array_key_exists($User->UserID, $this->_NotificationQueue)) {
                 $this->_NotificationQueue[$User->UserID] = array();
             }
             $Notification = array('ActivityID' => $ActivityID, 'User' => $User, 'Email' => $Email, 'Route' => $Activity->Route, 'Story' => $Story, 'Headline' => $ActivityHeadline, 'Activity' => $Activity);
             if ($Position == 'first') {
                 $this->_NotificationQueue[$User->UserID] = array_merge(array($Notification), $this->_NotificationQueue[$User->UserID]);
             } else {
                 $this->_NotificationQueue[$User->UserID][] = $Notification;
             }
         }
     }
 }
开发者ID:bahill,项目名称:vanilla,代码行数:60,代码来源:class.activitymodel.php

示例15: email

 /**
  *
  *
  * @param $Activity
  * @param bool $NoDelete
  * @return bool
  * @throws Exception
  */
 public function email(&$Activity, $NoDelete = false)
 {
     if (is_numeric($Activity)) {
         $ActivityID = $Activity;
         $Activity = $this->getID($ActivityID);
     } else {
         $ActivityID = val('ActivityID', $Activity);
     }
     if (!$Activity) {
         return false;
     }
     $Activity = (array) $Activity;
     $User = Gdn::userModel()->getID($Activity['NotifyUserID'], DATASET_TYPE_ARRAY);
     if (!$User) {
         return false;
     }
     // Format the activity headline based on the user being emailed.
     if (val('HeadlineFormat', $Activity)) {
         $SessionUserID = Gdn::session()->UserID;
         Gdn::session()->UserID = $User['UserID'];
         $Activity['Headline'] = formatString($Activity['HeadlineFormat'], $Activity);
         Gdn::session()->UserID = $SessionUserID;
     } else {
         if (!isset($Activity['ActivityGender'])) {
             $AT = self::getActivityType($Activity['ActivityType']);
             $Data = array($Activity);
             self::joinUsers($Data);
             $Activity = $Data[0];
             $Activity['RouteCode'] = val('RouteCode', $AT);
             $Activity['FullHeadline'] = val('FullHeadline', $AT);
             $Activity['ProfileHeadline'] = val('ProfileHeadline', $AT);
         }
         $Activity['Headline'] = Gdn_Format::activityHeadline($Activity, '', $User['UserID']);
     }
     // Build the email to send.
     $Email = new Gdn_Email();
     $Email->subject(sprintf(t('[%1$s] %2$s'), c('Garden.Title'), Gdn_Format::plainText($Activity['Headline'])));
     $Email->to($User);
     $Url = ExternalUrl($Activity['Route'] == '' ? '/' : $Activity['Route']);
     if ($Activity['Story']) {
         $Message = sprintf(t('EmailStoryNotification', "%3\$s\n\n%2\$s"), Gdn_Format::plainText($Activity['Headline']), $Url, Gdn_Format::plainText($Activity['Story']));
     } else {
         $Message = sprintf(t('EmailNotification', "%1\$s\n\n%2\$s"), Gdn_Format::plainText($Activity['Headline']), $Url);
     }
     $Email->message($Message);
     // Fire an event for the notification.
     $Notification = array('ActivityID' => $ActivityID, 'User' => $User, 'Email' => $Email, 'Route' => $Activity['Route'], 'Story' => $Activity['Story'], 'Headline' => $Activity['Headline'], 'Activity' => $Activity);
     $this->EventArguments = $Notification;
     $this->fireEvent('BeforeSendNotification');
     // Send the email.
     try {
         // Only send if the user is not banned
         if (!val('Banned', $User)) {
             $Email->send();
         }
         $Emailed = self::SENT_OK;
         // Delete the activity now that it has been emailed.
         if (!$NoDelete && !$Activity['Notified']) {
             if (val('ActivityID', $Activity)) {
                 $this->delete($Activity['ActivityID']);
             } else {
                 $Activity['_Delete'] = true;
             }
         }
     } catch (phpmailerException $pex) {
         if ($pex->getCode() == PHPMailer::STOP_CRITICAL) {
             $Emailed = self::SENT_FAIL;
         } else {
             $Emailed = self::SENT_ERROR;
         }
     } catch (Exception $ex) {
         $Emailed = self::SENT_FAIL;
         // similar to http 5xx
     }
     $Activity['Emailed'] = $Emailed;
     if ($ActivityID) {
         // Save the emailed flag back to the activity.
         $this->SQL->put('Activity', array('Emailed' => $Emailed), array('ActivityID' => $ActivityID));
     }
 }
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:88,代码来源:class.activitymodel.php


注:本文中的Gdn_Format::plainText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。