本文整理汇总了PHP中Gdn_Format::seconds方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Format::seconds方法的具体用法?PHP Gdn_Format::seconds怎么用?PHP Gdn_Format::seconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn_Format
的用法示例。
在下文中一共展示了Gdn_Format::seconds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCommentOptions
/**
* Get comment options.
*
* @since 2.1
* @param DataSet $Comment .
* @return array $Options Each element must include keys 'Label' and 'Url'.
*/
function getCommentOptions($Comment)
{
$Options = array();
if (!is_numeric(val('CommentID', $Comment))) {
return $Options;
}
$Sender = Gdn::controller();
$Session = Gdn::session();
$Discussion = Gdn::controller()->data('Discussion');
$CategoryID = val('CategoryID', $Discussion);
$PermissionCategoryID = val('PermissionCategoryID', $Discussion);
// Determine if we still have time to edit
$EditContentTimeout = c('Garden.EditContentTimeout', -1);
$CanEdit = $EditContentTimeout == -1 || strtotime($Comment->DateInserted) + $EditContentTimeout > time();
$TimeLeft = '';
$canEditDiscussions = $Session->checkPermission('Vanilla.Discussions.Edit', true, 'Category', $PermissionCategoryID);
if ($CanEdit && $EditContentTimeout > 0 && !$canEditDiscussions) {
$TimeLeft = strtotime($Comment->DateInserted) + $EditContentTimeout - time();
$TimeLeft = $TimeLeft > 0 ? ' (' . Gdn_Format::seconds($TimeLeft) . ')' : '';
}
// Can the user edit the comment?
$canEditComments = $Session->checkPermission('Vanilla.Comments.Edit', true, 'Category', $PermissionCategoryID);
if ($CanEdit && $Session->UserID == $Comment->InsertUserID || $canEditComments) {
$Options['EditComment'] = ['Label' => t('Edit') . $TimeLeft, 'Url' => '/post/editcomment/' . $Comment->CommentID, 'EditComment'];
}
// Can the user delete the comment?
$SelfDeleting = $CanEdit && $Session->UserID == $Comment->InsertUserID && c('Vanilla.Comments.AllowSelfDelete');
if ($SelfDeleting || $Session->checkPermission('Vanilla.Comments.Delete', true, 'Category', $PermissionCategoryID)) {
$Options['DeleteComment'] = ['Label' => t('Delete'), 'Url' => '/discussion/deletecomment/' . $Comment->CommentID . '/' . $Session->transientKey() . '/?Target=' . urlencode("/discussion/{$Comment->DiscussionID}/x"), 'Class' => 'DeleteComment'];
}
// DEPRECATED (as of 2.1)
$Sender->EventArguments['Type'] = 'Comment';
// Allow plugins to add options
$Sender->EventArguments['CommentOptions'] =& $Options;
$Sender->EventArguments['Comment'] = $Comment;
$Sender->fireEvent('CommentOptions');
return $Options;
}