当前位置: 首页>>代码示例>>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方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: WriteOptionList

function WriteOptionList($Object, $Sender, $Session)
{
    $EditContentTimeout = C('Garden.EditContentTimeout', -1);
    $CanEdit = $EditContentTimeout == -1 || strtotime($Object->DateInserted) + $EditContentTimeout > time();
    $TimeLeft = '';
    if ($CanEdit && $EditContentTimeout > 0) {
        $TimeLeft = strtotime($Object->DateInserted) + $EditContentTimeout - time();
        $TimeLeft = $TimeLeft > 0 ? ' (' . Gdn_Format::Seconds($TimeLeft) . ')' : '';
    }
    $Sender->Options = '';
    $CategoryID = GetValue('CategoryID', $Object);
    if (!$CategoryID && property_exists($Sender, 'Discussion')) {
        $CategoryID = GetValue('CategoryID', $Sender->Discussion);
    }
    // Show discussion options if this is the discussion / first comment
    if ($Sender->EventArguments['Type'] == 'Discussion') {
        // Can the user edit the discussion?
        if ($CanEdit && $Session->UserID == $Object->InsertUserID || $Session->CheckPermission('Vanilla.Discussions.Edit', TRUE, 'Category', $CategoryID)) {
            $Sender->Options .= '<span>' . Anchor(T('Edit'), '/vanilla/post/editdiscussion/' . $Object->DiscussionID, 'EditDiscussion') . $TimeLeft . '</span>';
        }
        // Can the user announce?
        if ($Session->CheckPermission('Vanilla.Discussions.Announce', TRUE, 'Category', $CategoryID)) {
            $Sender->Options .= '<span>' . Anchor(T($Sender->Discussion->Announce == '1' ? 'Unannounce' : 'Announce'), 'vanilla/discussion/announce/' . $Object->DiscussionID . '/' . $Session->TransientKey(), 'AnnounceDiscussion') . '</span>';
        }
        // Can the user sink?
        if ($Session->CheckPermission('Vanilla.Discussions.Sink', TRUE, 'Category', $CategoryID)) {
            $Sender->Options .= '<span>' . Anchor(T($Sender->Discussion->Sink == '1' ? 'Unsink' : 'Sink'), 'vanilla/discussion/sink/' . $Object->DiscussionID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'SinkDiscussion') . '</span>';
        }
        // Can the user close?
        if ($Session->CheckPermission('Vanilla.Discussions.Close', TRUE, 'Category', $CategoryID)) {
            $Sender->Options .= '<span>' . Anchor(T($Sender->Discussion->Closed == '1' ? 'Reopen' : 'Close'), 'vanilla/discussion/close/' . $Object->DiscussionID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'CloseDiscussion') . '</span>';
        }
        // Can the user delete?
        if ($Session->CheckPermission('Vanilla.Discussions.Delete', TRUE, 'Category', $CategoryID)) {
            $Sender->Options .= '<span>' . Anchor(T('Delete Discussion'), 'vanilla/discussion/delete/' . $Object->DiscussionID . '/' . $Session->TransientKey(), 'DeleteDiscussion') . '</span>';
        }
    } else {
        // And if this is just another comment in the discussion ...
        // Can the user edit the comment?
        if ($CanEdit && $Session->UserID == $Object->InsertUserID || $Session->CheckPermission('Vanilla.Comments.Edit', TRUE, 'Category', $Sender->Discussion->CategoryID)) {
            $Sender->Options .= '<span>' . Anchor(T('Edit'), '/vanilla/post/editcomment/' . $Object->CommentID, 'EditComment') . $TimeLeft . '</span>';
        }
        // Can the user delete the comment?
        if ($Session->CheckPermission('Vanilla.Comments.Delete', TRUE, 'Category', $CategoryID)) {
            $Sender->Options .= '<span>' . Anchor(T('Delete'), 'vanilla/discussion/deletecomment/' . $Object->CommentID . '/' . $Session->TransientKey() . '/?Target=' . urlencode($Sender->SelfUrl), 'DeleteComment') . '</span>';
        }
    }
    // Allow plugins to add options
    $Sender->FireEvent('CommentOptions');
    echo $Sender->Options;
}
开发者ID:kerphi,项目名称:Garden,代码行数:51,代码来源:helper_functions.php

示例2: GetCommentOptions

 function GetCommentOptions($Comment)
 {
     $Options = array();
     if (!is_numeric(GetValue('CommentID', $Comment))) {
         return $Options;
     }
     $Sender = Gdn::Controller();
     $Session = Gdn::Session();
     $Discussion = Gdn::Controller()->Data('Discussion');
     $CategoryID = GetValue('CategoryID', $Discussion);
     $PermissionCategoryID = GetValue('PermissionCategoryID', $Discussion);
     // Determine if we still have time to edit
     $EditContentTimeout = C('Garden.EditContentTimeout', -1);
     $CanEdit = $EditContentTimeout == -1 || strtotime($Comment->DateInserted) + $EditContentTimeout > time();
     $TimeLeft = '';
     if ($CanEdit && $EditContentTimeout > 0 && !$Session->CheckPermission('Vanilla.Discussions.Edit', TRUE, 'Category', $PermissionCategoryID)) {
         $TimeLeft = strtotime($Comment->DateInserted) + $EditContentTimeout - time();
         $TimeLeft = $TimeLeft > 0 ? ' (' . Gdn_Format::Seconds($TimeLeft) . ')' : '';
     }
     // Can the user edit the comment?
     if ($CanEdit && $Session->UserID == $Comment->InsertUserID || $Session->CheckPermission('Vanilla.Comments.Edit', TRUE, 'Category', $PermissionCategoryID)) {
         $Options['EditComment'] = array('Label' => T('Edit') . ' ' . $TimeLeft, 'Url' => '/vanilla/post/editcomment/' . $Comment->CommentID, 'EditComment');
     }
     // Can the user delete the comment?
     // if (($CanEdit && $Session->UserID == $Comment->InsertUserID) || $Session->CheckPermission('Vanilla.Comments.Delete', TRUE, 'Category', $PermissionCategoryID))
     if ($Session->CheckPermission('Vanilla.Comments.Delete', TRUE, 'Category', $PermissionCategoryID)) {
         $Options['DeleteComment'] = array('Label' => T('Delete'), 'Url' => 'vanilla/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:rnovino,项目名称:Garden,代码行数:36,代码来源:helper_functions.php

示例3: WriteOptionList

function WriteOptionList($Object, $Sender, $Session)
{
    $EditContentTimeout = C('Garden.EditContentTimeout', -1);
    $CategoryID = GetValue('CategoryID', $Object);
    if (!$CategoryID && property_exists($Sender, 'Discussion')) {
        $CategoryID = GetValue('CategoryID', $Sender->Discussion);
    }
    $PermissionCategoryID = GetValue('PermissionCategoryID', $Object, GetValue('PermissionCategoryID', $Sender->Discussion));
    $CanEdit = $EditContentTimeout == -1 || strtotime($Object->DateInserted) + $EditContentTimeout > time();
    $TimeLeft = '';
    if ($CanEdit && $EditContentTimeout > 0 && !$Session->CheckPermission('Vanilla.Discussions.Edit', TRUE, 'Category', $PermissionCategoryID)) {
        $TimeLeft = strtotime($Object->DateInserted) + $EditContentTimeout - time();
        $TimeLeft = $TimeLeft > 0 ? ' (' . Gdn_Format::Seconds($TimeLeft) . ')' : '';
    }
    $Sender->Options = '';
    // Show discussion options if this is the discussion / first comment
    if ($Sender->EventArguments['Type'] == 'Discussion') {
        // Can the user edit the discussion?
        if ($CanEdit && $Session->UserID == $Object->InsertUserID || $Session->CheckPermission('Vanilla.Discussions.Edit', TRUE, 'Category', $PermissionCategoryID)) {
            $Sender->Options .= '<span>' . Anchor(T('Edit'), '/post/editdiscussion/' . $Object->DiscussionID, 'EditDiscussion') . $TimeLeft . '</span>';
        }
        // Can the user announce?
        if ($Session->CheckPermission('Vanilla.Discussions.Announce', TRUE, 'Category', $PermissionCategoryID)) {
            $Sender->Options .= '<span>' . Anchor(T($Sender->Discussion->Announce == '1' ? 'Unannounce' : 'Announce'), 'discussion/announce/' . $Object->DiscussionID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'AnnounceDiscussion') . '</span>';
        }
        // Can the user sink?
        if ($Session->CheckPermission('Vanilla.Discussions.Sink', TRUE, 'Category', $PermissionCategoryID)) {
            $Sender->Options .= '<span>' . Anchor(T($Sender->Discussion->Sink == '1' ? 'Unsink' : 'Sink'), 'discussion/sink/' . $Object->DiscussionID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'SinkDiscussion') . '</span>';
        }
        // Can the user close?
        if ($Session->CheckPermission('Vanilla.Discussions.Close', TRUE, 'Category', $PermissionCategoryID)) {
            $Sender->Options .= '<span>' . Anchor(T($Sender->Discussion->Closed == '1' ? 'Reopen' : 'Close'), 'discussion/close/' . $Object->DiscussionID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'CloseDiscussion') . '</span>';
        }
        // Can the user delete?
        if ($Session->CheckPermission('Vanilla.Discussions.Delete', TRUE, 'Category', $PermissionCategoryID)) {
            $Sender->Options .= '<span>' . Anchor(T('Delete Discussion'), 'discussion/delete/' . $Object->DiscussionID . '/' . $Session->TransientKey(), 'DeleteDiscussion') . '</span>';
        }
    } else {
        // And if this is just another comment in the discussion ...
        // Can the user edit the comment?
        if ($CanEdit && $Session->UserID == $Object->InsertUserID || $Session->CheckPermission('Vanilla.Comments.Edit', TRUE, 'Category', $PermissionCategoryID)) {
            $Sender->Options .= '<span>' . Anchor(T('Edit'), '/post/editcomment/' . $Object->CommentID, 'EditComment') . $TimeLeft . '</span>';
        }
        // Can the user delete the comment?
        if ($Session->CheckPermission('Vanilla.Comments.Delete', TRUE, 'Category', $PermissionCategoryID)) {
            $Sender->Options .= '<span>' . Anchor(T('Delete'), 'discussion/deletecomment/' . $Object->CommentID . '/' . $Session->TransientKey() . '/?Target=' . urlencode("/discussion/{$Object->DiscussionID}/x"), 'DeleteComment') . '</span>';
        }
    }
    // Allow plugins to add options
    $Sender->FireEvent('CommentOptions');
    echo $Sender->Options;
    if ($Sender->CanEditComments) {
        if ($Sender->EventArguments['Type'] == 'Comment') {
            $Id = $Object->CommentID;
            echo '<div class="Options">';
            if (!property_exists($Sender, 'CheckedComments')) {
                $Sender->CheckedComments = $Session->GetAttribute('CheckedComments', array());
            }
            $ItemSelected = InSubArray($Id, $Sender->CheckedComments);
            echo '<span class="AdminCheck"><input type="checkbox" name="' . 'Comment' . 'ID[]" value="' . $Id . '"' . ($ItemSelected ? ' checked="checked"' : '') . ' /></span>';
            echo '</div>';
        } else {
            echo '<div class="Options">';
            echo '<div class="AdminCheck"><input type="checkbox" name="Toggle"></div>';
            echo '</div>';
        }
    }
}
开发者ID:ru4,项目名称:arabbnota,代码行数:68,代码来源:helper_functions.php


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