本文整理汇总了PHP中WrapIf函数的典型用法代码示例。如果您正苦于以下问题:PHP WrapIf函数的具体用法?PHP WrapIf怎么用?PHP WrapIf使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了WrapIf函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writePromotedContent
/**
* Generates html output of $Content array
*
* @param array|object $Content
* @param PromotedContentModule $Sender
*/
function writePromotedContent($Content, $Sender)
{
static $UserPhotoFirst = NULL;
if ($UserPhotoFirst === null) {
$UserPhotoFirst = c('Vanilla.Comment.UserPhotoFirst', true);
}
$ContentType = val('RecordType', $Content);
$ContentID = val("{$ContentType}ID", $Content);
$Author = val('Author', $Content);
$ContentURL = val('Url', $Content);
$Sender->EventArguments['Content'] =& $Content;
$Sender->EventArguments['ContentUrl'] =& $ContentURL;
?>
<div id="<?php
echo "Promoted_{$ContentType}_{$ContentID}";
?>
" class="<?php
echo CssClass($Content);
?>
">
<div class="AuthorWrap">
<span class="Author">
<?php
if ($UserPhotoFirst) {
echo userPhoto($Author);
echo userAnchor($Author, 'Username');
} else {
echo userAnchor($Author, 'Username');
echo userPhoto($Author);
}
$Sender->fireEvent('AuthorPhoto');
?>
</span>
<span class="AuthorInfo">
<?php
echo ' ' . WrapIf(htmlspecialchars(val('Title', $Author)), 'span', array('class' => 'MItem AuthorTitle'));
echo ' ' . WrapIf(htmlspecialchars(val('Location', $Author)), 'span', array('class' => 'MItem AuthorLocation'));
$Sender->fireEvent('AuthorInfo');
?>
</span>
</div>
<div class="Meta CommentMeta CommentInfo">
<span class="MItem DateCreated">
<?php
echo anchor(Gdn_Format::date($Content['DateInserted'], 'html'), $ContentURL, 'Permalink', array('rel' => 'nofollow'));
?>
</span>
<?php
// Include source if one was set
if ($Source = val('Source', $Content)) {
echo wrap(sprintf(t('via %s'), t($Source . ' Source', $Source)), 'span', array('class' => 'MItem Source'));
}
$Sender->fireEvent('ContentInfo');
?>
</div>
<div
class="Title"><?php
echo anchor(Gdn_Format::text(sliceString($Content['Name'], $Sender->TitleLimit), false), $ContentURL, 'DiscussionLink');
?>
</div>
<div class="Body">
<?php
echo anchor(htmlspecialchars(sliceString(Gdn_Format::plainText($Content['Body'], $Content['Format']), $Sender->BodyLimit)), $ContentURL, 'BodyLink');
$Sender->fireEvent('AfterPromotedBody');
// separate event to account for less space.
?>
</div>
</div>
<?php
}
示例2: UserPhoto
<span class="Author">
<?php
if ($UserPhotoFirst) {
echo UserPhoto($Author);
echo UserAnchor($Author, 'Username');
} else {
echo UserAnchor($Author, 'Username');
echo UserPhoto($Author);
}
echo FormatMeAction($Discussion);
?>
</span>
<span class="AuthorInfo">
<?php
echo WrapIf(htmlspecialchars(GetValue('Title', $Author)), 'span', array('class' => 'MItem AuthorTitle'));
echo WrapIf(htmlspecialchars(GetValue('Location', $Author)), 'span', array('class' => 'MItem AuthorLocation'));
$this->FireEvent('AuthorInfo');
?>
</span>
</div>
<div class="Meta DiscussionMeta">
<span class="MItem DateCreated">
<?php
echo Anchor(Gdn_Format::Date($Discussion->DateInserted, 'html'), $Discussion->Url, 'Permalink', array('rel' => 'nofollow'));
?>
</span>
<?php
echo DateUpdated($Discussion, array('<span class="MItem">', '</span>'));
?>
<?php
// Include source if one was set
示例3: _PollInsertion
/**
* Determines what part of the poll (if any) needs to be rendered
* Checks permissions and displays any tools available to user
* @param VanillaController $Sender
* @return type
*/
protected function _PollInsertion($Sender)
{
$Discussion = $Sender->Discussion;
$Session = Gdn::Session();
$DPModel = new DiscussionPollsModel();
// Does an attached poll exist?
if ($DPModel->Exists($Discussion->DiscussionID)) {
$Results = FALSE;
$Closed = FALSE;
$Poll = $DPModel->GetByDiscussionID($Discussion->DiscussionID);
// Can the current user view polls?
if (!$Session->CheckPermission('Plugins.DiscussionPolls.View')) {
// make this configurable?
echo Wrap(T('Plugins.DiscussionPolls.NoView', 'You do not have permission to view polls.'), 'div', array('class' => 'DP_AnswerForm'));
return;
}
// Check to see if the discussion is closed
if ($Discussion->Closed) {
// Close the Poll if the discussion is closed (workaround)
$DPModel->Close($Discussion->DiscussionID);
// TODO: Get rid of workaround by finding _some way_ to hook into the discussion model
// and close/open the poll **only** when the attached discussion is [un]closed.
$Closed = TRUE;
}
// Has the user voted?
if ($DPModel->HasAnswered($Poll->PollID, $Session->UserID) || !$Session->IsValid() || $Closed) {
$Results = TRUE;
// Render results
$this->_RenderResults($Poll);
} else {
$PartialAnswers = $DPModel->PartialAnswer($Poll->PollID, $Session->UserID);
//if some saved partial answers inform
if (!empty($PartialAnswers)) {
// TODO: Remove?
Gdn::Controller()->InformMessage(T('Plugins.DiscussionPolls.LoadedPartial', 'Your answered questions have been loaded.'));
}
// Render the submission form
$this->_RenderVotingForm($Sender, $Poll, $PartialAnswers);
}
// Render poll tools
// Owner and Plugins.DiscussionPolls.Manage gets delete if exists and attach if it doesn't
// Plugins.DiscussionPolls.View gets show results if the results aren't shown
$Tools = '';
if ($Discussion->InsertUserID == $Session->UserID || $Session->CheckPermission('Plugins.DiscussionPolls.Manage')) {
$Tools .= Wrap(Anchor(T('Delete Poll'), '/discussion/poll/delete/' . $Poll->PollID), 'li', array('id' => 'DP_Remove'));
}
if (!$Results && C('Plugins.DiscussionPolls.EnableShowResults', TRUE)) {
$Tools .= Wrap(Anchor(T('Show Results'), '/discussion/poll/results/' . $Poll->PollID), 'li', array('id' => 'DP_Results'));
}
echo WrapIf($Tools, 'ul', array('id' => 'DP_Tools'));
} else {
// Poll does not exist
if ($Discussion->InsertUserID == $Session->UserID || $Session->CheckPermission('Plugins.DiscussionPolls.Manage')) {
echo Wrap(Wrap(Anchor(T('Attach Poll'), '/vanilla/post/editdiscussion/' . $Discussion->DiscussionID), 'li'), 'ul', array('id' => 'DP_Tools'));
}
}
}
示例4: WriteActivity
function WriteActivity($Activity, &$Sender, &$Session)
{
$Activity = (object) $Activity;
// If this was a status update or a wall comment, don't bother with activity strings
$ActivityType = explode(' ', $Activity->ActivityType);
// Make sure you strip out any extra css classes munged in here
$ActivityType = $ActivityType[0];
$Author = UserBuilder($Activity, 'Activity');
$PhotoAnchor = '';
if ($Activity->Photo) {
$PhotoAnchor = Anchor(Img($Activity->Photo, array('class' => 'ProfilePhoto ProfilePhotoMedium')), $Activity->PhotoUrl, 'PhotoWrap');
}
$CssClass = 'Item Activity Activity-' . $ActivityType;
if ($PhotoAnchor != '') {
$CssClass .= ' HasPhoto';
}
$Format = GetValue('Format', $Activity);
$Title = '';
$Excerpt = $Activity->Story;
if ($Format) {
$Excerpt = Gdn_Format::To($Excerpt, $Format);
}
if (!in_array($ActivityType, array('WallComment', 'WallPost', 'AboutUpdate'))) {
$Title = '<div class="Title">' . GetValue('Headline', $Activity) . '</div>';
} else {
if ($ActivityType == 'WallPost') {
$RegardingUser = UserBuilder($Activity, 'Regarding');
$PhotoAnchor = UserPhoto($RegardingUser);
$Title = '<div class="Title">' . UserAnchor($RegardingUser, 'Name') . ' <span>→</span> ' . UserAnchor($Author, 'Name') . '</div>';
if (!$Format) {
$Excerpt = Gdn_Format::Display($Excerpt);
}
} else {
$Title = UserAnchor($Author, 'Name');
if (!$Format) {
$Excerpt = Gdn_Format::Display($Excerpt);
}
}
}
$Sender->EventArguments['Activity'] =& $Activity;
$Sender->EventArguments['CssClass'] =& $CssClass;
$Sender->FireEvent('BeforeActivity');
?>
<li id="Activity_<?php
echo $Activity->ActivityID;
?>
" class="<?php
echo $CssClass;
?>
">
<?php
if ($Session->IsValid() && ($Session->UserID == $Activity->InsertUserID || $Session->CheckPermission('Garden.Activity.Delete'))) {
echo '<div class="Options">' . Anchor('×', 'dashboard/activity/delete/' . $Activity->ActivityID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'Delete') . '</div>';
}
if ($PhotoAnchor != '') {
?>
<div class="Author Photo"><?php
echo $PhotoAnchor;
?>
</div>
<?php
}
?>
<div class="ItemContent Activity">
<?php
echo $Title;
?>
<?php
echo WrapIf($Excerpt, 'div', array('class' => 'Excerpt'));
?>
<?php
$Sender->EventArguments['Activity'] = $Activity;
$Sender->FireAs('ActivityController')->FireEvent('AfterActivityBody');
?>
<div class="Meta">
<span class="MItem DateCreated"><?php
echo Gdn_Format::Date($Activity->DateUpdated);
?>
</span>
<?php
$SharedString = FALSE;
$ID = GetValue('SharedNotifyUserID', $Activity->Data);
if (!$ID) {
$ID = GetValue('CommentNotifyUserID', $Activity->Data);
}
if ($ID) {
$SharedString = FormatString(T('Comments are between {UserID,you}.'), array('UserID' => array($Activity->NotifyUserID, $ID)));
}
$AllowComments = $Activity->NotifyUserID < 0 || $SharedString;
if ($AllowComments && $Session->CheckPermission('Garden.Profiles.Edit')) {
echo '<span class="MItem AddComment">' . Anchor(T('Activity.Comment', 'Comment'), '#CommentForm_' . $Activity->ActivityID, 'CommentOption');
}
if ($SharedString) {
echo ' <span class="MItem"><i>' . $SharedString . '</i></span>';
}
echo '</span>';
$Sender->FireEvent('AfterMeta');
?>
</div>
</div>
//.........这里部分代码省略.........
示例5: WriteComment
function WriteComment($Comment, $Sender, $Session, $CurrentOffset)
{
static $UserPhotoFirst = NULL;
if ($UserPhotoFirst === NULL) {
$UserPhotoFirst = C('Vanilla.Comment.UserPhotoFirst', TRUE);
}
$Author = Gdn::UserModel()->GetID($Comment->InsertUserID);
//UserBuilder($Comment, 'Insert');
$Permalink = GetValue('Url', $Comment, '/discussion/comment/' . $Comment->CommentID . '/#Comment_' . $Comment->CommentID);
// Set CanEditComments (whether to show checkboxes)
if (!property_exists($Sender, 'CanEditComments')) {
$Sender->CanEditComments = $Session->CheckPermission('Vanilla.Comments.Edit', TRUE, 'Category', 'any') && C('Vanilla.AdminCheckboxes.Use');
}
// Prep event args
$CssClass = CssClass($Comment, $CurrentOffset);
$Sender->EventArguments['Comment'] =& $Comment;
$Sender->EventArguments['Author'] =& $Author;
$Sender->EventArguments['CssClass'] =& $CssClass;
// DEPRECATED ARGUMENTS (as of 2.1)
$Sender->EventArguments['Object'] =& $Comment;
$Sender->EventArguments['Type'] = 'Comment';
// First comment template event
$Sender->FireEvent('BeforeCommentDisplay');
?>
<li class="<?php
echo $CssClass;
?>
" id="<?php
echo 'Comment_' . $Comment->CommentID;
?>
">
<div class="Comment">
<?php
// Write a stub for the latest comment so it's easy to link to it from outside.
if ($CurrentOffset == Gdn::Controller()->Data('_LatestItem')) {
echo '<span id="latest"></span>';
}
?>
<div class="Options">
<?php
WriteCommentOptions($Comment);
?>
</div>
<?php
$Sender->FireEvent('BeforeCommentMeta');
?>
<div class="Item-Header CommentHeader">
<div class="AuthorWrap">
<span class="Author">
<?php
if ($UserPhotoFirst) {
echo UserPhoto($Author);
echo UserAnchor($Author, 'Username');
} else {
echo UserAnchor($Author, 'Username');
echo UserPhoto($Author);
}
echo FormatMeAction($Comment);
?>
</span>
<span class="AuthorInfo">
<?php
echo ' ' . WrapIf(htmlspecialchars(GetValue('Title', $Author)), 'span', array('class' => 'MItem AuthorTitle'));
$Sender->FireEvent('AuthorInfo');
?>
</span>
</div>
<div class="Meta CommentMeta CommentInfo">
<span class="MItem DateCreated">
<?php
echo Anchor(Gdn_Format::Date($Comment->DateInserted, 'html'), $Permalink, 'Permalink', array('name' => 'Item_' . $CurrentOffset, 'rel' => 'nofollow'));
?>
</span>
<?php
// Include source if one was set
if ($Source = GetValue('Source', $Comment)) {
echo Wrap(sprintf(T('via %s'), T($Source . ' Source', $Source)), 'span', array('class' => 'MItem Source'));
}
$Sender->FireEvent('CommentInfo');
$Sender->FireEvent('InsideCommentMeta');
// DEPRECATED
$Sender->FireEvent('AfterCommentMeta');
// DEPRECATED
// Include IP Address if we have permission
if ($Session->CheckPermission('Garden.Moderation.Manage')) {
echo Wrap(IPAnchor($Comment->InsertIPAddress), 'span', array('class' => 'MItem IPAddress'));
}
?>
</div>
</div>
<div class="Item-BodyWrap">
<div class="Item-Body">
<div class="Message">
<?php
echo FormatBody($Comment);
?>
</div>
<?php
$Sender->FireEvent('AfterCommentBody');
WriteReactions($Comment);
//.........这里部分代码省略.........
示例6: WritePromotedContent
function WritePromotedContent($Content, $Sender)
{
static $UserPhotoFirst = NULL;
if ($UserPhotoFirst === NULL) {
$UserPhotoFirst = C('Vanilla.Comment.UserPhotoFirst', TRUE);
}
$ContentType = GetValue('ItemType', $Content);
$ContentID = GetValue("{$ContentType}ID", $Content);
$Author = GetValue('Author', $Content);
switch (strtolower($ContentType)) {
case 'comment':
$ContentURL = CommentUrl($Content);
break;
case 'discussion':
$ContentURL = DiscussionUrl($Content);
break;
}
?>
<div id="<?php
echo "Promoted_{$ContentType}_{$ContentID}";
?>
" class="<?php
echo CssClass($Content);
?>
">
<div class="AuthorWrap">
<span class="Author">
<?php
if ($UserPhotoFirst) {
echo UserPhoto($Author);
echo UserAnchor($Author, 'Username');
} else {
echo UserAnchor($Author, 'Username');
echo UserPhoto($Author);
}
$Sender->FireEvent('AuthorPhoto');
?>
</span>
<span class="AuthorInfo">
<?php
echo ' ' . WrapIf(htmlspecialchars(GetValue('Title', $Author)), 'span', array('class' => 'MItem AuthorTitle'));
echo ' ' . WrapIf(htmlspecialchars(GetValue('Location', $Author)), 'span', array('class' => 'MItem AuthorLocation'));
$Sender->FireEvent('AuthorInfo');
?>
</span>
</div>
<div class="Meta CommentMeta CommentInfo">
<span class="MItem DateCreated">
<?php
echo Anchor(Gdn_Format::Date($Content['DateInserted'], 'html'), $Permalink, 'Permalink', array('rel' => 'nofollow'));
?>
</span>
<?php
// Include source if one was set
if ($Source = GetValue('Source', $Content)) {
echo Wrap(sprintf(T('via %s'), T($Source . ' Source', $Source)), 'span', array('class' => 'MItem Source'));
}
$Sender->FireEvent('ContentInfo');
?>
</div>
<div class="Title"><?php
echo Anchor(Gdn_Format::Text($Content['Name'], FALSE), $ContentURL, 'DiscussionLink');
?>
</div>
<div class="Body"><?php
echo Anchor(strip_tags(Gdn_Format::To($Content['Body'], $Content['Format'])), $ContentURL, 'BodyLink');
?>
</div>
</div>
<?php
}
示例7: UserPhoto
<div class="Item-Header DiscussionHeader">
<div class="AuthorWrap">
<span class="Author">
<?php
if ($UserPhotoFirst) {
echo UserPhoto($Author);
echo UserAnchor($Author);
} else {
echo UserAnchor($Author);
echo UserPhoto($Author);
}
?>
</span>
<span class="AuthorInfo">
<?php
echo WrapIf(htmlspecialchars(GetValue('Title', $Author)), 'span', array('class' => 'MItem AuthorTitle'));
$this->FireEvent('AuthorInfo');
?>
</span>
</div>
<div class="Meta DiscussionMeta">
<span class="MItem DateCreated">
<?php
echo Anchor(Gdn_Format::Date($Discussion->DateInserted, 'html'), $Discussion->Url, 'Permalink', array('rel' => 'nofollow'));
?>
</span>
<?php
// Category
if (C('Vanilla.Categories.Use')) {
echo ' <span class="MItem Category">';
echo ' ' . T('in') . ' ';
示例8: Wrap
<?php
if (!defined('APPLICATION')) {
exit;
}
/* Copyright 2014 Zachary Doll */
$TransportType = $this->Data('TransportType');
$Filename = $this->Data('TransportPath');
$ActionCount = $this->Data('ActionCount', NULL);
$BadgeCount = $this->Data('BadgeCount', NULL);
$RankCount = $this->Data('RankCount', NULL);
$ImageCount = $this->Data('ImageCount', NULL);
echo Wrap($this->Title(), 'h1');
echo Wrap(Wrap(sprintf(T("Yaga.{$TransportType}.Success"), $Filename), 'div'), 'div', array('class' => 'Wrap'));
$String = '';
if ($ActionCount) {
$String .= Wrap(T('Yaga.Reactions') . ': ' . $ActionCount, 'li');
}
if ($BadgeCount) {
$String .= Wrap(T('Yaga.Badges') . ': ' . $BadgeCount, 'li');
}
if ($RankCount) {
$String .= Wrap(T('Yaga.Ranks') . ': ' . $RankCount, 'li');
}
if ($ImageCount) {
$String .= Wrap(T('Image Files') . ': ' . $ImageCount, 'li');
}
echo WrapIf($String, 'ul', array('class' => 'Wrap'));
echo Wrap(Anchor(T('Yaga.Transport.Return'), 'yaga/settings'), 'div', array('class' => 'Wrap'));
示例9: Wrap
if (!defined('APPLICATION')) {
exit;
}
/* Copyright 2013 Zachary Doll */
echo Wrap($this->Title(), 'h1');
echo '<ul class="DataList Badges">';
foreach ($this->Data('Badges') as $Badge) {
// Don't show disabled badges
//if(!$Badge->Enabled) {
// continue;
//}
$Row = '';
$AwardDescription = '';
$ReadClass = ' Read';
if ($Badge->UserID) {
$ReadClass = '';
$AwardDescription = sprintf(T('Yaga.Badge.Earned.Format'), Gdn_Format::Date($Badge->DateInserted, 'html'), $Badge->InsertUserName);
if ($Badge->Reason) {
$AwardDescription .= ': "' . $Badge->Reason . '"';
}
}
if ($Badge->Photo) {
$Row .= Img($Badge->Photo, array('class' => 'BadgePhoto'));
} else {
$Row .= Img('applications/yaga/design/images/default_badge.png', array('class' => 'BadgePhoto'));
}
$Row .= Wrap(Wrap(Anchor($Badge->Name, 'badges/detail/' . $Badge->BadgeID . '/' . Gdn_Format::Url($Badge->Name), array('class' => 'Title')), 'div', array('class' => 'Title')) . Wrap(Wrap($Badge->Description, 'span', array('class' => 'MItem BadgeDescription')) . Wrap($Badge->AwardValue . ' points.', 'span', array('class' => 'MItem BadgePoints')) . WrapIf($AwardDescription, 'p'), 'div', array('class' => 'Meta')), 'div', array('class' => 'ItemContent Badge'));
echo Wrap($Row, 'li', array('class' => 'Item ItemBadge' . $ReadClass));
}
echo '</ul>';
示例10: ActionRow
/**
* Renders an action row used to construct the action admin screen
*
* @param stdClass $Action
* @return string
*/
function ActionRow($Action)
{
return Wrap(Wrap(Anchor(T('Edit'), 'action/edit/' . $Action->ActionID, array('class' => 'Popup SmallButton')) . Anchor(T('Delete'), 'action/delete/' . $Action->ActionID, array('class' => 'Popup SmallButton')), 'div', array('class' => 'Tools')) . Wrap(Wrap($Action->Name, 'h4') . Wrap(Wrap($Action->Description, 'span') . ' ' . Wrap(Plural($Action->AwardValue, '%s Point', '%s Points'), 'span'), 'div', array('class' => 'Meta')) . Wrap(Wrap(' ', 'span', array('class' => 'ReactSprite React-' . $Action->ActionID . ' ' . $Action->CssClass)) . WrapIf(rand(0, 18), 'span', array('class' => 'Count')) . Wrap($Action->Name, 'span', array('class' => 'ReactLabel')), 'div', array('class' => 'Preview Reactions')), 'div', array('class' => 'Action')), 'li', array('id' => 'ActionID_' . $Action->ActionID));
}