当前位置: 首页>>代码示例>>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;未经允许,请勿转载。