Beispiel #1
0
/**
 * Function to show warning message about existing locks for sections or
 * articles.
 *
 * @param <type> $lockobj EditWarningLock object.
 */
function showWarningMsg($msgtype, $lockobj, $cancel_url)
{
    switch ($msgtype) {
        case TYPE_ARTICLE:
            $type = "ArticleWarning";
            break;
        case TYPE_ARTICLE_SECTIONCONFLICT:
            $type = "ArticleSectionWarning";
            break;
        case TYPE_SECTION:
            $type = "SectionWarning";
            break;
    }
    // Calculate time to wait
    $difference = floatval(abs(time() - $lockobj->getTimestamp()));
    $time_to_wait = bcdiv($difference, 60, 0);
    // Parameters for message string
    if ($msgtype == TYPE_ARTICLE || $msgtype == TYPE_SECTION) {
        $msg_params[] = $lockobj->getUserName();
        $msg_params[] = date("Y-m-d", $lockobj->getTimestamp());
        $msg_params[] = date("H:i", $lockobj->getTimestamp());
    }
    $msg_params[] = $time_to_wait;
    // Use minutes or seconds string?
    if ($time_to_wait > 1 || $difference > 60) {
        $msg_params[] = wfMsg('ew-minutes');
    } else {
        $msg_params[] = wfMsg('ew-seconds');
    }
    $msg = EditWarningMsg::getInstance($type, $cancel_url, $msg_params);
    $msg->show();
    unset($msg);
}