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


PHP Gdn_Format::To方法代码示例

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


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

示例1: Page

 public function Page($Reference)
 {
     $PageModel = new PageModel();
     $Page = $PageModel->GetFullID($Reference);
     if (!$Page) {
         throw NotFoundException();
     }
     $this->Page = $Page;
     if ($this->Head) {
         SetMetaTags($Page, $this);
         if ($Page->CustomCss) {
             $CustomCss = "\n" . $Page->CustomCss;
             if (!StringBeginsWith(trim($CustomCss), '<style', True)) {
                 $CustomCss = Wrap($CustomCss, 'style', array('type' => 'text/css'));
             }
             $this->Head->AddString($CustomCss);
         }
         if ($Page->CustomJs) {
             $CustomJs = $Page->CustomJs;
             if (!StringBeginsWith(trim($CustomJs), '<script', True)) {
                 $CustomJs = Wrap($CustomJs, 'script', array('type' => 'text/javascript'));
             }
             $this->Head->AddString($CustomJs);
         }
     }
     if ($Page->SectionID) {
         $this->Section = BuildNode($Page, 'Section');
         $this->SectionID = $Page->SectionID;
         CandyHooks::AddModules($this, $this->Section);
     }
     $this->FireEvent('ContentPage');
     if ($Page->View) {
         $this->View = $this->FetchViewLocation($this->View, False, False, False);
     }
     if (!$this->View) {
         $this->View = $this->FetchViewLocation('view', 'page', '', False);
         if (!$this->View) {
             $this->View = 'default';
         }
     }
     $this->Title($Page->Title);
     $this->SetData('Content', $Page, True);
     $this->EventArguments['Format'] =& $Page->Format;
     $this->EventArguments['Body'] =& $Page->Body;
     $this->FireEvent('BeforeBodyFormat');
     $this->ContentBodyHtml = Gdn_Format::To($Page->Body, $Page->Format);
     $Doc = PqDocument($this->ContentBodyHtml);
     $Header = $Doc->Find('h1');
     $CountH1 = count($Header);
     if ($CountH1 == 0) {
         $this->SetData('Headline', Gdn_Format::Text($Page->Title));
     } elseif ($CountH1 == 1) {
         $this->SetData('Headline', $Header->Text());
         $Header->Remove();
         $this->ContentBodyHtml = $Doc->Html();
     }
     //
     $this->AddModule('PageInfoModule');
     $this->Render();
 }
开发者ID:unlight,项目名称:Candy,代码行数:60,代码来源:class.contentcontroller.php

示例2: FormatBody

 function FormatBody($Object)
 {
     Gdn::Controller()->FireEvent('BeforeCommentBody');
     $Object->FormatBody = Gdn_Format::To($Object->Body, $Object->Format);
     Gdn::Controller()->FireEvent('AfterCommentFormat');
     return $Object->FormatBody;
 }
开发者ID:rnovino,项目名称:Garden,代码行数:7,代码来源:helper_functions.php

示例3: Markdownify

 /**
  * Converts HTML to Markdown
  */
 function Markdownify($Html)
 {
     $Html = Gdn_Format::To($Html, 'xHtml');
     $Snoopy = Gdn::Factory('Snoopy');
     $Vars = array('input' => $Html, 'keepHTML' => 1);
     $Snoopy->Submit('http://milianw.de/projects/markdownify/demo.php', $Vars);
     $Doc = PqDocument($Snoopy->results);
     $Code = Pq('pre > code:eq(0)')->Text();
     $Result = $Code;
     return $Result;
 }
开发者ID:ru4,项目名称:arabbnota,代码行数:14,代码来源:functions.text.php

示例4: Markdownify

 /**
  * Converts HTML to Markdown
  */
 function Markdownify($Html)
 {
     if (function_exists('Debug') && Debug()) {
         trigger_error(sprintf('%s is deprecated, use HtmlToMarkdown() instead.', __FUNCTION__), E_USER_DEPRECATED);
     }
     $Html = Gdn_Format::To($Html, 'xHtml');
     $Snoopy = Gdn::Factory('Snoopy');
     $Vars = array('input' => $Html, 'keepHTML' => 1);
     $Snoopy->Submit('http://milianw.de/projects/markdownify/demo.php', $Vars);
     $Doc = PqDocument($Snoopy->results);
     $Code = Pq('pre > code:eq(0)')->Text();
     $Result = $Code;
     return $Result;
 }
开发者ID:unlight,项目名称:UsefulFunctions,代码行数:17,代码来源:functions.deprecated.php

示例5: Gdn_Form_BeforeBodyBox_Handler

 /**
  *
  * @param Gdn_Form $Sender 
  */
 public function Gdn_Form_BeforeBodyBox_Handler($Sender, $Args)
 {
     $this->_AddCLEditor(Gdn::Controller());
     $Format = $Sender->GetValue('Format');
     if ($Format) {
         $Formatter = Gdn::Factory($Format . 'Formatter');
         if ($Formatter && method_exists($Formatter, 'FormatForWysiwyg')) {
             $Body = $Formatter->FormatForWysiwyg($Sender->GetValue('Body'));
             $Sender->SetValue('Body', $Body);
         } elseif (!in_array($Format, array('Html', 'Wysiwyg'))) {
             $Sender->SetValue('Body', Gdn_Format::To($Sender->GetValue('Body'), $Format));
         }
     }
     $Sender->SetValue('Format', 'Wysiwyg');
 }
开发者ID:robhazkes,项目名称:Garden,代码行数:19,代码来源:default.php

示例6: AttachFormattingBar

 /**
  * Adds the formatting bar to the form used by the Controller.
  *
  * @param Gdn_Controller $Sender Sending Controller instance.
  */
 private function AttachFormattingBar(Gdn_Controller $Sender)
 {
     $this->_AddWysihtml5($Sender);
     $Form = $Sender->Form;
     $Format = $Form->GetValue('Format');
     if ($Format) {
         $Formatter = Gdn::Factory($Format . 'Formatter');
         if ($Formatter && method_exists($Formatter, 'FormatForWysiwyg')) {
             $Body = $Formatter->FormatForWysiwyg($Form->GetValue('Body'));
             $Form->SetValue('Body', $Body);
         } elseif (!in_array($Format, array('Html', 'Wysiwyg'))) {
             $Form->SetValue('Body', Gdn_Format::To($Form->GetValue('Body'), $Format));
         }
     }
     $Form->SetValue('Format', 'Wysiwyg');
     echo $Sender->FetchView($this->GetView('toolbar_view.php'));
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:22,代码来源:class.wysihtml5.plugin.php

示例7: Update

 public function Update($Reference = '', $PostBackKey = '')
 {
     $this->Permission('Candy.Chunks.Edit');
     $Content = False;
     $Session = Gdn::Session();
     $this->AddJsFile('jquery.textpandable.js');
     $this->AddJsFile('editform.js');
     $this->Form->SetModel($this->ChunkModel);
     if ($Reference != '') {
         $Content = $this->ChunkModel->GetID($Reference);
         if ($Content) {
             $this->Form->AddHidden('ChunkID', $Content->ChunkID);
             $this->Editing = True;
             $this->Form->SetData($Content);
         }
     }
     $IsFormPostBack = $this->Form->AuthenticatedPostBack();
     $PostAuthenticatedByKey = $Session->ValidateTransientKey($PostBackKey) && $this->Form->IsPostBack();
     if ($IsFormPostBack || $PostAuthenticatedByKey) {
         if ($PostAuthenticatedByKey) {
             // AJAX, set form values.
             $this->Form->SetFormValue('ChunkID', $Content->ChunkID);
             $this->Form->SetFormValue('Body', GetPostValue('Body'));
         }
         $SavedID = $this->Form->Save($Content);
         if ($SavedID) {
             $Message = T('Saved');
             $this->InformMessage($Message, array('Sprite' => 'Check', 'CssClass' => 'Dismissable AutoDismiss'));
             if ($this->DeliveryType() == DELIVERY_TYPE_BOOL) {
                 //$this->SetData('Content', $Content);
                 //$this->SetData('NewBody', Gdn_Format::To($this->Form->GetFormValue('Body'), $Content->Format));
                 $this->SetJson('NewBody', Gdn_Format::To($this->Form->GetFormValue('Body'), $Content->Format));
             }
         }
     } else {
         $this->SetData('Content', $Content);
         $this->Form->SetData($Content);
     }
     $this->Title(ConcatSep(' - ', T('Chunk'), GetValue('Name', $Content)));
     $this->Render();
 }
开发者ID:unlight,项目名称:Candy,代码行数:41,代码来源:class.chunkcontroller.php

示例8: FormatMentions

 /**
  *  replaces /library/core/class.format.php function Mention
  *  code is as close to original function (taken from 2.0.18.9) as possible 
  */
 public function FormatMentions($Mixed)
 {
     if (!is_string($Mixed)) {
         return Gdn_Format::To($Mixed, 'Mentions');
     }
     // Handle @mentions.
     if (C('Garden.Format.Mentions')) {
         // without spaces
         $StrippedValidationRegex = '[' . str_replace(' ', '', str_replace('\\s', '', C('Garden.User.ValidationRegex'))) . ']' . C('Garden.User.ValidationLength', '{3,20}');
         $Mixed = preg_replace('/(^|[\\s,\\.>])@(' . $StrippedValidationRegex . ')\\b/iu', '\\1' . Anchor('@\\2', '/profile/\\2'), $Mixed);
         // with spaces
         $Mixed = preg_replace('/(^|[\\s,\\.>])@' . C('Plugins.MentionsPlus.MentionStart', '"') . '(' . ValidateUsernameRegex() . ')' . C('Plugins.MentionsPlus.MentionStop', '"') . '/iu', '\\1' . Anchor('@' . C('Plugins.MentionsPlus.MentionStart', '"') . '\\2' . C('Plugins.MentionsPlus.MentionStop', '"'), '/profile/\\2'), $Mixed);
     }
     // Handle #hashtag searches
     if (C('Garden.Format.Hashtags')) {
         $Mixed = preg_replace('/(^|[\\s,\\.>])\\#([\\w\\-]+)(?=[\\s,\\.!?]|$)/iu', '\\1' . Anchor('#\\2', '/search?Search=%23\\2&Mode=like') . '\\3', $Mixed);
     }
     // Handle "/me does x" action statements
     if (C('Garden.Format.MeActions')) {
         $Mixed = preg_replace('/(^|[\\n])(\\' . C('Plugins.MentionsPlus.MeActionCode', '/me') . ')(\\s[^(\\n)]+)/iu', '\\1' . Wrap(Wrap('\\2', 'span', array('class' => 'MeActionName')) . '\\3', 'span', array('class' => 'AuthorAction')), $Mixed);
     }
     return $Mixed;
 }
开发者ID:Nordic-T,项目名称:vanilla-plugins,代码行数:27,代码来源:class.umlautmentionsformatter.php

示例9: WriteReply

    public static function WriteReply(&$Sender, &$Session)
    {
        ?>
         <li class="Reply" id="Comment_<?php 
        echo $Sender->CurrentReply->CommentID;
        ?>
">
            <?php 
        // Delete comment
        if ($Session->CheckPermission('Vanilla.Comments.Delete', $Sender->Discussion->CategoryID)) {
            echo Anchor(T('Delete'), 'vanilla/discussion/deletecomment/' . $Sender->CurrentReply->CommentID . '/' . $Session->TransientKey(), 'DeleteReply');
        }
        ?>
            <ul class="Info<?php 
        echo $Sender->CurrentReply->InsertUserID == $Session->UserID ? ' Author' : '';
        ?>
">
               <li class="Author"><?php 
        $Author = UserBuilder($Sender->CurrentReply, 'Insert');
        echo UserPhoto($Author);
        echo UserAnchor($Author);
        ?>
</li>
               <li class="Created"><?php 
        echo Gdn_Format::Date($Sender->CurrentReply->DateInserted);
        ?>
</li>
               <li class="Permalink"><?php 
        echo Anchor(T('Permalink'), '/discussion/comment/' . (isset($Sender->CurrentComment) ? $Sender->CurrentComment->CommentID : $Sender->ReplyCommentID) . '/#Comment_' . $Sender->CurrentReply->CommentID, T('Permalink'));
        ?>
</li>
            </ul>
            <div class="Body"><?php 
        echo Gdn_Format::To($Sender->CurrentReply->Body, $Sender->CurrentReply->Format);
        ?>
</div>
         </li>
      <?php 
    }
开发者ID:SatiricMan,项目名称:addons,代码行数:39,代码来源:default.php

示例10: foreach

      <?php 
    foreach ($this->Data('Conversations') as $Row) {
        ?>
      <li id="Conversation_<?php 
        echo $Row['ConversationID'];
        ?>
" class="Item">
         <?php 
        $JumpToItem = $Row['CountMessages'] - $Row['CountNewMessages'];
        $Url = "/messages/{$Row['ConversationID']}/#Item_{$JumpToItem}";
        if ($SubjectsVisible && $Row['Subject']) {
            $Message = htmlspecialchars($Row['Title']);
        } elseif ($Row['Format'] == 'Text') {
            $Message = SliceString(Gdn_Format::To($Row['LastMessage'], $Conversation['Format']), 100);
        } else {
            $Message = SliceString(Gdn_Format::Text(Gdn_Format::To($Row['LastMessage'], $Row['Format']), FALSE), 100);
        }
        if (StringIsNullOrEmpty(trim($Message))) {
            $Message = T('Blank Message');
        }
        echo Anchor($Message, $Url, 'ConversationLink');
        ?>
         <div class="Meta">
            <span class="MItem Participants">
               <?php 
        $First = TRUE;
        foreach ($Row['Participants'] as $User) {
            if ($First) {
                $First = FALSE;
            } else {
                echo ', ';
开发者ID:bishopb,项目名称:vanilla,代码行数:31,代码来源:inbox.php

示例11: drawSignature

 protected function drawSignature($Sender)
 {
     if ($this->hide()) {
         return;
     }
     if (isset($Sender->EventArguments['Discussion'])) {
         $Data = $Sender->EventArguments['Discussion'];
     }
     if (isset($Sender->EventArguments['Comment'])) {
         $Data = $Sender->EventArguments['Comment'];
     }
     $SourceUserID = GetValue('InsertUserID', $Data);
     $User = Gdn::UserModel()->GetID($SourceUserID, DATASET_TYPE_ARRAY);
     if (GetValue('HideSignature', $User, FALSE)) {
         return;
     }
     $Signature = $this->Signatures($Sender, $SourceUserID);
     if (is_array($Signature)) {
         list($Signature, $SigFormat) = $Signature;
     } else {
         $SigFormat = C('Garden.InputFormatter');
     }
     if (!$SigFormat) {
         $SigFormat = C('Garden.InputFormatter');
     }
     $this->EventArguments = array('UserID' => $SourceUserID, 'Signature' => &$Signature);
     $this->FireEvent('BeforeDrawSignature');
     $SigClasses = '';
     if (!is_null($Signature)) {
         $HideImages = $this->UserPreferences('Plugin.Signatures.HideImages', FALSE);
         if ($HideImages) {
             $SigClasses .= 'HideImages ';
         }
         // Don't show empty sigs
         if ($Signature == '') {
             return;
         }
         // If embeds were disabled from the dashboard, temporarily set the
         // universal config to make sure no URLs are turned into embeds.
         if (!C('Plugins.Signatures.AllowEmbeds', true)) {
             $originalEnableUrlEmbeds = C('Garden.Format.DisableUrlEmbeds', false);
             SaveToConfig(array('Garden.Format.DisableUrlEmbeds' => true), null, array('Save' => false));
         }
         $UserSignature = Gdn_Format::To($Signature, $SigFormat) . "<!-- {$SigFormat} -->";
         // Restore original config.
         if (!C('Plugins.Signatures.AllowEmbeds', true)) {
             SaveToConfig(array('Garden.Format.DisableUrlEmbeds' => $originalEnableUrlEmbeds), null, array('Save' => false));
         }
         $this->EventArguments = array('UserID' => $SourceUserID, 'String' => &$UserSignature);
         $this->FireEvent('FilterContent');
         if ($UserSignature) {
             echo "<div class=\"Signature UserSignature {$SigClasses}\">{$UserSignature}</div>";
         }
     }
 }
开发者ID:jamesinc,项目名称:addons,代码行数:55,代码来源:class.signatures.plugin.php

示例12: WriteComment

/**
 * $Object is either a Comment or the original Discussion.
 */
function WriteComment($Object, $Sender, $Session, $CurrentOffset)
{
    $Author = UserBuilder($Object, 'Insert');
    $Type = property_exists($Object, 'CommentID') ? 'Comment' : 'Discussion';
    $Sender->EventArguments['Object'] = $Object;
    $Sender->EventArguments['Type'] = $Type;
    $Sender->EventArguments['Author'] = $Author;
    $CssClass = 'Item Comment';
    if ($Type == 'Comment') {
        $Sender->EventArguments['Comment'] = $Object;
        $Id = 'Comment_' . $Object->CommentID;
        $Permalink = '/discussion/comment/' . $Object->CommentID . '/#Comment_' . $Object->CommentID;
    } else {
        $Sender->EventArguments['Discussion'] = $Object;
        $CssClass .= ' FirstComment';
        $Id = 'Discussion_' . $Object->DiscussionID;
        $Permalink = '/discussion/' . $Object->DiscussionID . '/' . Gdn_Format::Url($Object->Name) . '/p1';
    }
    $Sender->Options = '';
    $CssClass .= $Object->InsertUserID == $Session->UserID ? ' Mine' : '';
    $Sender->FireEvent('BeforeCommentDisplay');
    ?>
<li class="<?php 
    echo $CssClass;
    ?>
" id="<?php 
    echo $Id;
    ?>
">
   <div class="Comment">
      <div class="Meta">
         <?php 
    $Sender->FireEvent('BeforeCommentMeta');
    ?>
         <span class="Author">
            <?php 
    echo UserPhoto($Author);
    echo UserAnchor($Author);
    ?>
         </span>
         <span class="DateCreated">
            <?php 
    echo Gdn_Format::Date($Object->DateInserted);
    ?>
         </span>
         <span class="Permalink">
            <?php 
    echo Anchor(T('Permalink'), $Permalink, 'Permalink', array('name' => 'Item_' . ($CurrentOffset + 1), 'rel' => 'nofollow'));
    ?>
         </span>
         <?php 
    WriteOptionList($Object, $Sender, $Session);
    ?>
         <?php 
    $Sender->FireEvent('AfterCommentMeta');
    ?>
      </div>
      <div class="Message">
			<?php 
    $Sender->FireEvent('BeforeCommentBody');
    ?>
			<p><?php 
    echo Gdn_Format::To($Object->Body, $Object->Format);
    ?>
</p>
		</div>
      <?php 
    $Sender->FireEvent('AfterCommentBody');
    ?>
   </div>
</li>
<?php 
    $Sender->FireEvent('AfterComment');
}
开发者ID:kerphi,项目名称:Garden,代码行数:77,代码来源:helper_functions.php

示例13: RefetchPageInfo

 /**
  * Re-fetch a discussion's content based on its foreign url.
  * @param type $DiscussionID
  */
 public function RefetchPageInfo($DiscussionID)
 {
     // Make sure we are posting back.
     if (!$this->Request->IsPostBack()) {
         throw PermissionException('Javascript');
     }
     // Grab the discussion.
     $Discussion = $this->DiscussionModel->GetID($DiscussionID);
     if (!$Discussion) {
         throw NotFoundException('Discussion');
     }
     // Make sure the user has permission to edit this discussion.
     $this->Permission('Vanilla.Discussions.Edit', TRUE, 'Category', $Discussion->PermissionCategoryID);
     $ForeignUrl = GetValueR('Attributes.ForeignUrl', $Discussion);
     if (!$ForeignUrl) {
         throw new Gdn_UserException(T("This discussion isn't associated with a url."));
     }
     $Stub = $this->DiscussionModel->FetchPageInfo($ForeignUrl, TRUE);
     // Save the stub.
     $this->DiscussionModel->SetField($DiscussionID, (array) $Stub);
     // Send some of the stuff back.
     if (isset($Stub['Name'])) {
         $this->JsonTarget('.PageTitle h1', Gdn_Format::Text($Stub['Name']));
     }
     if (isset($Stub['Body'])) {
         $this->JsonTarget("#Discussion_{$DiscussionID} .Message", Gdn_Format::To($Stub['Body'], $Stub['Format']));
     }
     $this->InformMessage('The page was successfully fetched.');
     $this->Render('Blank', 'Utility', 'Dashboard');
 }
开发者ID:srikarrohit,项目名称:Vanillaforums-SSO,代码行数:34,代码来源:class.discussioncontroller.php

示例14: defined

<?php

defined('APPLICATION') or exit;
$Session = Gdn::Session();
// Format page body.
$PageBody = $this->Page->Body;
if ($this->Page->Format === 'RawHtmlLineBreaks') {
    $PageBody = preg_replace("/(\r\n)|(\r)|(\n)/", "<br />", $PageBody);
    $PageBody = FixNl2Br($PageBody);
} else {
    if ($this->Page->Format !== 'RawHtml') {
        $PageBody = Gdn_Format::To($PageBody, $this->Page->Format);
    }
}
?>
<div id="Page_<?php 
echo $this->Page->PageID;
?>
" class="PageContent Page-<?php 
echo $this->Page->UrlCode;
?>
">
    <?php 
$this->FireEvent('BeforePageOptions');
?>
    <?php 
if ($Session->CheckPermission('Garden.Settings.Manage')) {
    ?>
        <div class="Options">
         <span class="ToggleFlyout OptionsMenu">
            <span class="OptionsTitle" title="<?php 
开发者ID:oMadMartigaNo,项目名称:readjust-forum,代码行数:31,代码来源:index.php

示例15: RssHtml

 /**
  * Format some text in a way suitable for passing into an rss/atom feed.
  * @since 2.1
  * @param string $Text The text to format.
  * @param string $Format The current format of the text.
  * @return string
  */
 public static function RssHtml($Text, $Format = 'Html')
 {
     if (!in_array($Text, array('Html', 'Raw'))) {
         $Text = Gdn_Format::To($Text, $Format);
     }
     if (function_exists('FormatRssHtmlCustom')) {
         return FormatRssHtmlCustom($Text);
     } else {
         return Gdn_Format::Html($Text);
     }
 }
开发者ID:3marproof,项目名称:vanilla,代码行数:18,代码来源:class.format.php


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