當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Gdn_Format::seconds方法代碼示例

本文整理匯總了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;
 }
開發者ID:vanilla,項目名稱:vanilla,代碼行數:45,代碼來源:helper_functions.php


注:本文中的Gdn_Format::seconds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。