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


PHP Plural函数代码示例

本文整理汇总了PHP中Plural函数的典型用法代码示例。如果您正苦于以下问题:PHP Plural函数的具体用法?PHP Plural怎么用?PHP Plural使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: ProfileController_Quotes_Create

 public function ProfileController_Quotes_Create($Sender)
 {
     $Sender->Permission('Garden.SignIn.Allow');
     $Sender->Title("Quotes Settings");
     $Args = $Sender->RequestArgs;
     if (sizeof($Args) < 2) {
         $Args = array_merge($Args, array(0, 0));
     } elseif (sizeof($Args) > 2) {
         $Args = array_slice($Args, 0, 2);
     }
     list($UserReference, $Username) = $Args;
     $Sender->GetUserInfo($UserReference, $Username);
     $UserPrefs = Gdn_Format::Unserialize($Sender->User->Preferences);
     if (!is_array($UserPrefs)) {
         $UserPrefs = array();
     }
     $UserID = $ViewingUserID = Gdn::Session()->UserID;
     if ($Sender->User->UserID != $ViewingUserID) {
         $Sender->Permission('Garden.Users.Edit');
         $UserID = $Sender->User->UserID;
     }
     $Sender->SetData('ForceEditing', $UserID == Gdn::Session()->UserID ? FALSE : $Sender->User->Name);
     $QuoteFolding = GetValue('Quotes.Folding', $UserPrefs, '1');
     $Sender->Form->SetValue('QuoteFolding', $QuoteFolding);
     $Sender->SetData('QuoteFoldingOptions', array('None' => t("Don't fold quotes"), '1' => Plural(1, '%s level deep', '%s levels deep'), '2' => Plural(2, '%s level deep', '%s levels deep'), '3' => Plural(3, '%s level deep', '%s levels deep'), '4' => Plural(4, '%s level deep', '%s levels deep'), '5' => Plural(5, '%s level deep', '%s levels deep')));
     // If seeing the form for the first time...
     if ($Sender->Form->IsPostBack()) {
         $NewFoldingLevel = $Sender->Form->GetValue('QuoteFolding', '1');
         if ($NewFoldingLevel != $QuoteFolding) {
             Gdn::UserModel()->SavePreference($UserID, 'Quotes.Folding', $NewFoldingLevel);
             $Sender->InformMessage(T("Your changes have been saved."));
         }
     }
     $Sender->Render('quotes', '', 'plugins/Quotes');
 }
开发者ID:Nordic-T,项目名称:vanilla-plugins,代码行数:35,代码来源:class.quotes.plugin.php

示例2: _AttachPostCount

 protected function _AttachPostCount($Sender)
 {
     $User = Gdn::UserModel()->GetID($Sender->EventArguments['Author']->UserID);
     if ($User) {
         $Posts = GetValue('CountComments', $User, 0) + GetValue('CountDiscussions', $User, 0);
         echo '<span class="MItem PostCount">' . Plural(number_format($Posts), '@' . T('Posts.Singular: %s', 'Posts: <b>%s</b>'), '@' . T('Posts.Plural: %s', 'Posts: <b>%s</b>')) . '</span>';
     }
 }
开发者ID:vanilla,项目名称:addons,代码行数:8,代码来源:class.postcount.plugin.php

示例3: OnlineUsers

function OnlineUsers($forum = 0, $update = true)
{
    global $loguserid;
    $forumClause = "";
    $browseLocation = __("online");
    if ($update) {
        if ($loguserid) {
            Query("UPDATE {users} SET lastforum={0} WHERE id={1}", $forum, $loguserid);
        } else {
            Query("UPDATE {guests} SET lastforum={0} WHERE ip={1}", $forum, $_SERVER['REMOTE_ADDR']);
        }
    }
    if ($forum) {
        $forumClause = " and lastforum={1}";
        $forumName = FetchResult("SELECT title FROM {forums} WHERE id={0}", $forum);
        $browseLocation = format(__("browsing {0}"), $forumName);
    }
    $rOnlineUsers = Query("select u.(_userfields) from {users} u where (lastactivity > {0} or lastposttime > {0}) and loggedin = 1 " . $forumClause . " order by name", time() - 300, $forum);
    $onlineUserCt = 0;
    $onlineUsers = "";
    while ($user = Fetch($rOnlineUsers)) {
        $user = getDataPrefix($user, "u_");
        $userLink = UserLink($user, true);
        $onlineUsers .= ($onlineUserCt ? ", " : "") . $userLink;
        $onlineUserCt++;
    }
    //$onlineUsers = $onlineUserCt." "user".(($onlineUserCt > 1 || $onlineUserCt == 0) ? "s" : "")." ".$browseLocation.($onlineUserCt ? ": " : ".").$onlineUsers;
    $onlineUsers = Plural($onlineUserCt, __("user")) . " " . $browseLocation . ($onlineUserCt ? ": " : ".") . $onlineUsers;
    $data = Fetch(Query("select \n\t\t(select count(*) from {guests} where bot=0 and date > {0} {$forumClause}) as guests,\n\t\t(select count(*) from {guests} where bot=1 and date > {0} {$forumClause}) as bots\n\t\t", time() - 300, $forum));
    $guests = $data["guests"];
    $bots = $data["bots"];
    if ($guests) {
        $onlineUsers .= " | " . Plural($guests, __("guest"));
    }
    if ($bots) {
        $onlineUsers .= " | " . Plural($bots, __("bot"));
    }
    //	$onlineUsers = "<div style=\"display: inline-block; height: 16px; overflow: hidden; padding: 0px; line-height: 16px;\">".$onlineUsers."</div>";
    return $onlineUsers;
}
开发者ID:Servault,项目名称:Blargboard,代码行数:40,代码来源:onlineusers.php

示例4: RenderQuestion

function RenderQuestion($Question)
{
    echo '<li class="DP_ResultQuestion">';
    echo Wrap($Question->Title, 'span');
    echo Wrap(sprintf(Plural($Question->CountResponses, '%s vote', '%s votes'), $Question->CountResponses), 'span', array('class' => 'Number DP_VoteCount'));
    // 'randomize' option bar colors
    $k = $Question->QuestionID % 10;
    echo '<ol class="DP_ResultOptions">';
    foreach ($Question->Options as $Option) {
        $String = Wrap($Option->Title, 'div');
        $Percentage = $Question->CountResponses == 0 ? '0.00' : number_format($Option->CountVotes / $Question->CountResponses * 100, 2);
        // Put text where it makes sense
        if ($Percentage < 10) {
            $String .= '<span class="DP_Bar DP_Bar-' . $k . '" style="width: ' . $Percentage . '%;">&nbsp</span> ' . $Percentage . '%';
        } else {
            $String .= '<span class="DP_Bar DP_Bar-' . $k . '" style="width: ' . $Percentage . '%;">' . $Percentage . '%</span>';
        }
        echo Wrap($String, 'li', array('class' => 'DP_ResultOption'));
        $k = ++$k % 10;
    }
    echo '</ol>';
    echo '</li>';
}
开发者ID:Nordic-T,项目名称:vanilla-plugins,代码行数:23,代码来源:results.php

示例5: Plural

<?php

if (!defined('APPLICATION')) {
    exit;
}
?>
<div class="DataBox DataBox-AcceptedAnswers"><span id="latest"></span>
   <h2 class="CommentHeading"><?php 
echo Plural(count($Sender->Data('Answers')), 'Best Answer', 'Best Answers');
?>
</h2>
   <ul class="MessageList DataList AcceptedAnswers">
      <?php 
foreach ($Sender->Data('Answers') as $Row) {
    $Sender->EventArguments['Comment'] = $Row;
    WriteComment($Row, $Sender, Gdn::Session(), 0);
}
?>
   </ul>
</div>
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:20,代码来源:answers.php

示例6: ksort

        $TitleCell = TRUE;
        ksort($FlaggedList, SORT_STRING);
        $NumComplaintsInThread = sizeof($FlaggedList);
        foreach ($FlaggedList as $FlagIndex => $Flag) {
            if ($TitleCell) {
                $TitleCell = FALSE;
                ?>
                        <div class="FlaggedTitleCell">
                           <div class="FlaggedItemURL"><?php 
                echo Anchor(Url($Flag['ForeignURL'], TRUE), $Flag['ForeignURL']);
                ?>
</div>
                           <div class="FlaggedItemInfo">
                              <?php 
                if ($NumComplaintsInThread > 1) {
                    $OtherString = T(' and') . ' ' . ($NumComplaintsInThread - 1) . ' ' . T(Plural($NumComplaintsInThread - 1, 'other', 'others'));
                } else {
                    $OtherString = '';
                }
                ?>
                              <span><?php 
                echo T('FlaggedBy', "Reported by:");
                ?>
 </span>
                              <span><?php 
                printf(T('<strong>%s</strong>%s on %s'), Anchor($Flag['InsertName'], "profile/{$Flag['InsertUserID']}/{$Flag['InsertName']}"), $OtherString, $Flag['DateInserted']);
                ?>
</span>
                           </div>
                           <div class="FlaggedItemComment">"<?php 
                echo Gdn_Format::Text($Flag['Comment']);
开发者ID:Nordic-T,项目名称:vanilla-plugins,代码行数:31,代码来源:flagging.php

示例7: T

echo T('Manage Applicants');
?>
</h1>
<?php 
echo $this->Form->Open(array('action' => Url('/dashboard/user/applicants')));
echo $this->Form->Errors();
$NumApplicants = $this->UserData->NumRows();
if ($NumApplicants == 0) {
    ?>
      <div class="Info"><?php 
    echo T('There are currently no applicants.');
    ?>
</div>
   <?php 
} else {
    $AppText = Plural($NumApplicants, 'There is currently %s applicant', 'There are currently %s applicants');
    ?>
<div class="Info"><?php 
    echo sprintf($AppText, $NumApplicants);
    ?>
</div>
<table class="CheckColumn">
   <thead>
      <tr>
         <td><?php 
    echo T('Action');
    ?>
</td>
         <th class="Alt"><?php 
    echo T('Applicant');
    ?>
开发者ID:rnovino,项目名称:Garden,代码行数:31,代码来源:applicants.php

示例8: UserPhoto

         <div class="Author Photo"><?php 
        echo UserPhoto($Row, array('Px' => 'First'));
        ?>
</div>
         <div class="ItemContent">
            <b class="Subject"><?php 
        echo Anchor($Row->Name, $Row->Url . '#latest');
        ?>
</b>
            <div class="Meta">
               <?php 
        echo ' <span class="MItem">' . Plural($Row->CountComments, '%s comment', '%s comments') . '</span> ';
        if ($Row->CountUnreadComments === TRUE) {
            echo ' <strong class="HasNew"> ' . T('new') . '</strong> ';
        } elseif ($Row->CountUnreadComments > 0) {
            echo ' <strong class="HasNew"> ' . Plural($Row->CountUnreadComments, '%s new', '%s new plural') . '</strong> ';
        }
        echo ' <span class="MItem">' . Gdn_Format::Date($Row->DateLastComment) . '</span> ';
        ?>
            </div>
         </div>
      </li>
      <?php 
    }
    ?>
      <li class="Item Center">
         <?php 
    echo Anchor(sprintf(T('All %s'), T('Bookmarks')), '/discussions/bookmarked');
    ?>
      </li>
<?php 
开发者ID:rnovino,项目名称:Garden,代码行数:31,代码来源:popin.php

示例9: format

<?php

$footerExtensionsB .= format(__("Page rendered in {0} seconds with {1}") . "<br>", sprintf('%1.3f', usectime() - $timeStart), Plural($queries, __("MySQL query")));
开发者ID:RoadrunnerWMC,项目名称:ABXD-plugins,代码行数:3,代码来源:footer.php

示例10: GetValue

<?php

if (!defined('APPLICATION')) {
    exit;
}
?>
<h1><?php 
echo $this->Data('Title');
?>
</h1>
<?php 
echo $this->Form->Open();
echo $this->Form->Errors();
$CountAllowed = GetValue('CountAllowed', $this->Data, 0);
$CountNotAllowed = GetValue('CountNotAllowed', $this->Data, 0);
$CountCheckedDiscussions = GetValue('CountCheckedDiscussions', $this->Data, 0);
if ($CountNotAllowed > 0) {
    echo Wrap(sprintf('You do not have permission to delete %1$s of the selected discussions.', $CountNotAllowed), 'p');
    echo Wrap(sprintf('You are about to delete %1$s of the %2$s selected discussions.', $CountAllowed, $CountCheckedDiscussions), 'p');
} else {
    echo Wrap(sprintf('You are about to delete %s.', Plural($CountAllowed, '%s discussion', '%s discussions')), 'p');
}
echo '<p><strong>' . T('Are you sure you wish to continue?') . '</strong></p>';
echo '<div class="Buttons Buttons-Confirm">', $this->Form->Button('OK', array('class' => 'Button Primary')), $this->Form->Button('Cancel', array('type' => 'button', 'class' => 'Button Close')), '</div>';
echo $this->Form->Close();
开发者ID:robhazkes,项目名称:Garden,代码行数:25,代码来源:confirmdiscussiondeletes.php

示例11: Validate

 /**
  * @param array $FormPostValues
  * @param bool $Insert
  * @return bool
  */
 public function Validate($FormPostValues, $Insert = FALSE)
 {
     $valid = parent::Validate($FormPostValues, $Insert);
     if (!CheckPermission('Garden.Moderation.Manage') && C('Conversations.MaxRecipients')) {
         $max = C('Conversations.MaxRecipients');
         if (isset($FormPostValues['RecipientUserID']) && count($FormPostValues['RecipientUserID']) > $max) {
             $this->Validation->AddValidationResult('To', Plural($max, "You are limited to %s recipient.", "You are limited to %s recipients."));
             $valid = false;
         }
     }
     return $valid;
 }
开发者ID:3marproof,项目名称:vanilla,代码行数:17,代码来源:class.conversationmessagemodel.php

示例12: if

<?php if (!defined('APPLICATION')) exit(); ?>
<h1><?php echo $this->Data('Title'); ?></h1>
<?php
echo $this->Form->Open();
echo $this->Form->Errors();

$CountCheckedComments = GetValue('CountCheckedComments', $this->Data, 0);

echo Wrap(sprintf(
   'You have chosen to split %s into a new discussion.',
   Plural($CountCheckedComments, '%s comment', '%s comments')
   ), 'p');
?>
<ul>
   <li>
      <?php
         echo $this->Form->Label('New Discussion Topic', 'Name');
         echo $this->Form->TextBox('Name');
      ?>
   </li>
   <?php if ($this->ShowCategorySelector === TRUE) { ?>
   <li>
      <?php
         echo '<p><div class="Category">';
         echo $this->Form->Label('Category', 'CategoryID'), ' ';
         echo $this->Form->DropDown('CategoryID', $this->CategoryData, array('TextField' => 'Name', 'ValueField' => 'CategoryID'));
         echo '</div></p>';
      ?>
   </li>
   <?php } ?>
</ul>
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:31,代码来源:splitcomments.php

示例13: UserPhoto

   <div class="Photo"><?php echo UserPhoto($PhotoUser); ?></div>
   <?php } ?>
   <div class="ItemContent Conversation">
      <?php
      $Url = '/messages/'.$Conversation->ConversationID.'/#Item_'.$JumpToItem;

      if ($Names) {
         echo '<h3 class="Users">', Anchor(htmlspecialchars($Names), $Url), '</h3>';
      }
      if ($SubjectsVisible && $Subject = GetValue('Subject', $Conversation)) {
         echo '<div class="Subject"><b>'.Anchor(htmlspecialchars($Subject), $Url).'</b></div>';
      }
      ?>
      <div class="Excerpt"><?php echo Anchor($Message, $Url, 'Message'); ?></div>
      <div class="Meta">
         <?php 
         $this->FireEvent('BeforeConversationMeta');

         echo '<span class="MetaItem">'.sprintf(Plural($Conversation->CountMessages, '%s message', '%s messages'), $Conversation->CountMessages).'</span>';

         if ($Conversation->CountNewMessages > 0) {
            echo '<strong class="MetaItem">'.Plural($Conversation->CountNewMessages, '%s new', '%s new').'</strong>';
         }
         
         echo '<span class="MetaItem">'.Gdn_Format::Date($Conversation->DateLastMessage).'</span>';
         ?>
      </div>
   </div>
</li>
<?php
}
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:31,代码来源:conversations.php

示例14: WriteDiscussion

function WriteDiscussion($Discussion, &$Sender, &$Session, $Alt2)
{
    static $Alt = FALSE;
    $CssClass = 'Item';
    $CssClass .= $Discussion->Bookmarked == '1' ? ' Bookmarked' : '';
    $CssClass .= $Alt ? ' Alt ' : '';
    $Alt = !$Alt;
    $CssClass .= $Discussion->Announce == '1' ? ' Announcement' : '';
    $CssClass .= $Discussion->Dismissed == '1' ? ' Dismissed' : '';
    $CssClass .= $Discussion->InsertUserID == $Session->UserID ? ' Mine' : '';
    $CssClass .= $Discussion->CountUnreadComments > 0 && $Session->IsValid() ? ' New' : '';
    $DiscussionUrl = '/discussion/' . $Discussion->DiscussionID . '/' . Gdn_Format::Url($Discussion->Name) . ($Discussion->CountCommentWatch > 0 && C('Vanilla.Comments.AutoOffset') && $Session->UserID > 0 ? '/#Item_' . $Discussion->CountCommentWatch : '');
    //   $DiscussionUrl = $Discussion->Url;
    $Sender->EventArguments['DiscussionUrl'] =& $DiscussionUrl;
    $Sender->EventArguments['Discussion'] =& $Discussion;
    $Sender->EventArguments['CssClass'] =& $CssClass;
    $First = UserBuilder($Discussion, 'First');
    $Last = UserBuilder($Discussion, 'Last');
    $Sender->FireEvent('BeforeDiscussionName');
    $DiscussionName = $Discussion->Name;
    if ($DiscussionName == '') {
        $DiscussionName = T('Blank Discussion Topic');
    }
    $Sender->EventArguments['DiscussionName'] =& $DiscussionName;
    static $FirstDiscussion = TRUE;
    if (!$FirstDiscussion) {
        $Sender->FireEvent('BetweenDiscussion');
    } else {
        $FirstDiscussion = FALSE;
    }
    ?>
<li class="<?php 
    echo $CssClass;
    ?>
">
   <?php 
    if (!property_exists($Sender, 'CanEditDiscussions')) {
        $Sender->CanEditDiscussions = GetValue('PermsDiscussionsEdit', CategoryModel::Categories($Discussion->CategoryID)) && C('Vanilla.AdminCheckboxes.Use');
    }
    $Sender->FireEvent('BeforeDiscussionContent');
    WriteOptions($Discussion, $Sender, $Session);
    ?>
   <div class="ItemContent Discussion">
      <?php 
    echo Anchor($DiscussionName, $DiscussionUrl, 'Title');
    ?>
      <?php 
    $Sender->FireEvent('AfterDiscussionTitle');
    ?>
      <div class="Meta">
         <?php 
    $Sender->FireEvent('BeforeDiscussionMeta');
    ?>
         <?php 
    if ($Discussion->Announce == '1') {
        ?>
         <span class="Tag Announcement"><?php 
        echo T('Announcement');
        ?>
</span>
         <?php 
    }
    ?>
         <?php 
    if ($Discussion->Closed == '1') {
        ?>
         <span class="Tag Closed"><?php 
        echo T('Closed');
        ?>
</span>
         <?php 
    }
    ?>
         <span class="MItem CommentCount"><?php 
    printf(Plural($Discussion->CountComments, '%s comment', '%s comments'), $Discussion->CountComments);
    if ($Session->IsValid() && $Discussion->CountUnreadComments > 0) {
        echo ' <strong class="HasNew">' . Plural($Discussion->CountUnreadComments, '%s new', '%s new plural') . '</strong>';
    }
    ?>
</span>
         <?php 
    $Sender->FireEvent('AfterCountMeta');
    if ($Discussion->LastCommentID != '') {
        echo ' <span class="MItem LastCommentBy">' . sprintf(T('Most recent by %1$s'), UserAnchor($Last)) . '</span> ';
        echo ' <span class="MItem LastCommentDate">' . Gdn_Format::Date($Discussion->LastDate) . '</span>';
    } else {
        echo ' <span class="MItem LastCommentBy">' . sprintf(T('Started by %1$s'), UserAnchor($First)) . '</span> ';
        echo ' <span class="MItem LastCommentDate">' . Gdn_Format::Date($Discussion->FirstDate);
        if ($Source = GetValue('Source', $Discussion)) {
            echo ' ' . sprintf(T('via %s'), T($Source . ' Source', $Source));
        }
        echo '</span> ';
    }
    if (C('Vanilla.Categories.Use') && $Discussion->CategoryUrlCode != '') {
        echo ' ' . Wrap(Anchor($Discussion->Category, '/categories/' . rawurlencode($Discussion->CategoryUrlCode)), 'span', array('class' => 'Tag Category'));
    }
    $Sender->FireEvent('DiscussionMeta');
    ?>
      </div>
   </div>
//.........这里部分代码省略.........
开发者ID:Raz0r,项目名称:Garden,代码行数:101,代码来源:helper_functions.php

示例15: UserBuilder

    $Name = $Session->UserID == $Conversation->LastMessageUserID ? 'You' : $Conversation->LastMessageName;
    $JumpToItem = $Conversation->CountMessages - $Conversation->CountNewMessages;
    ?>
<li<?php 
    echo $Class == '' ? '' : ' class="' . $Class . '"';
    ?>
>
   <?php 
    $LastAuthor = UserBuilder($Conversation, 'LastMessage');
    echo UserPhoto($LastAuthor, 'Photo');
    ?>
   <div>
      <?php 
    echo UserAnchor($LastAuthor, 'Name');
    echo Anchor(SliceString(Format::Text($Conversation->LastMessage), 100), '/messages/' . $Conversation->ConversationID . '/#Item_' . $JumpToItem, 'Message');
    echo '<div class="Meta">';
    echo Format::Date($Conversation->DateLastMessage);
    echo '<span>&bull;</span>';
    printf(Gdn::Translate(Plural($Conversation->CountMessages, '%s message', '%s messages')), $Conversation->CountMessages);
    if ($Conversation->CountNewMessages > 0) {
        echo '<span>&bull;</span>';
        echo '<em>';
        printf(Gdn::Translate('%s new'), $Conversation->CountNewMessages);
        echo '</em>';
    }
    echo '</div>';
    ?>
   </div>
</li>
<?php 
}
开发者ID:robi-bobi,项目名称:Garden,代码行数:31,代码来源:conversations.php


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