本文整理汇总了PHP中wfTimestampNow函数的典型用法代码示例。如果您正苦于以下问题:PHP wfTimestampNow函数的具体用法?PHP wfTimestampNow怎么用?PHP wfTimestampNow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfTimestampNow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: adminPostTalkMessage
public static function adminPostTalkMessage($to_user, $from_user, $comment)
{
global $wgLang;
$existing_talk = '';
//make sure we have everything we need...
if (empty($to_user) || empty($from_user) || empty($comment)) {
return false;
}
$from = $from_user->getName();
if (!$from) {
return false;
}
//whoops
$from_realname = $from_user->getRealName();
$dateStr = $wgLang->date(wfTimestampNow());
$formattedComment = wfMsg('postcomment_formatted_comment', $dateStr, $from, $from_realname, $comment);
$talkPage = $to_user->getUserPage()->getTalkPage();
if ($talkPage->getArticleId() > 0) {
$r = Revision::newFromTitle($talkPage);
$existing_talk = $r->getText() . "\n\n";
}
$text = $existing_talk . $formattedComment . "\n\n";
$flags = EDIT_FORCE_BOT | EDIT_SUPPRESS_RC;
$article = new Article($talkPage);
$result = $article->doEdit($text, "", $flags);
return $result;
}
示例2: execute
public function execute()
{
global $wgUser;
if (!$wgUser->isAllowed('surveysubmit') || $wgUser->isBlocked()) {
$this->dieUsageMsg(array('badaccess-groups'));
}
$params = $this->extractRequestParams();
if (!(isset($params['id']) xor isset($params['name']))) {
$this->dieUsage(wfMsg('survey-err-id-xor-name'), 'id-xor-name');
}
if (isset($params['name'])) {
$survey = Survey::newFromName($params['name'], null, false);
if ($survey === false) {
$this->dieUsage(wfMsgExt('survey-err-survey-name-unknown', 'parsemag', $params['name']), 'survey-name-unknown');
}
} else {
$survey = Survey::newFromId($params['id'], null, false);
if ($survey === false) {
$this->dieUsage(wfMsgExt('survey-err-survey-id-unknown', 'parsemag', $params['id']), 'survey-id-unknown');
}
}
$submission = new SurveySubmission(array('survey_id' => $survey->getId(), 'page_id' => 0, 'user_name' => $GLOBALS['wgUser']->getName(), 'time' => wfTimestampNow()));
foreach (FormatJson::decode($params['answers']) as $answer) {
$submission->addAnswer(SurveyAnswer::newFromArray((array) $answer));
}
$submission->writeToDB();
}
示例3: handleAFAction
public static function handleAFAction( $action, $parameters, $title, $vars, $rule_desc ) {
global $wgUser;
$dbw = wfGetDB( DB_MASTER );
$dbQuery = array(
'pmq_id' => '',
'pmq_page_last_id' => $title->getLatestRevID(),
'pmq_page_ns' => $title->getNamespace(),
'pmq_page_title' => $title->getDBkey(),
'pmq_user' => $wgUser->getID(),
'pmq_user_text' => $wgUser->getName(),
'pmq_timestamp' => $dbw->timestamp( wfTimestampNow() ),
'pmq_minor' => $vars->getVar( 'minor_edit' )->toInt(),
'pmq_summary' => $vars->getVar( 'summary' )->toString(),
'pmq_len' => $title->getLength(),
'pmq_text' => $vars->getVar( 'new_wikitext' )->toString(),
'pmq_flags' => false,
'pmq_ip' => wfGetIP(),
'pmq_status' => 'new'
);
$dbw->insert( 'pm_queue', $dbQuery, __METHOD__ );
$dbw->commit();
return true;
}
示例4: loadSummaryFields
/**
* (non-PHPdoc)
* @see EPDBObject::loadSummaryFields()
*/
public function loadSummaryFields($summaryFields = null)
{
if (is_null($summaryFields)) {
$summaryFields = array('courses', 'terms', 'students', 'active');
} else {
$summaryFields = (array) $summaryFields;
}
$fields = array();
if (in_array('courses', $summaryFields)) {
$fields['courses'] = EPCourse::count(array('org_id' => $this->getId()));
}
if (in_array('terms', $summaryFields)) {
$fields['terms'] = EPTerm::count(array('org_id' => $this->getId()));
}
$dbr = wfGetDB(DB_SLAVE);
if (in_array('students', $summaryFields)) {
$termIds = EPTerm::selectFields('id', array('org_id' => $this->getId()));
if (count($termIds) > 0) {
$fields['students'] = $dbr->select('ep_students_per_term', 'COUNT(*) AS rowcount', array('spt_term_id' => $termIds));
$fields['students'] = $fields['students']->fetchObject()->rowcount;
} else {
$fields['students'] = 0;
}
}
if (in_array('active', $summaryFields)) {
$now = wfGetDB(DB_SLAVE)->addQuotes(wfTimestampNow());
$fields['active'] = EPTerm::has(array('org_id' => $this->getId(), 'end >= ' . $now, 'start <= ' . $now));
}
$this->setFields($fields);
}
示例5: calcRecommendations
public static function calcRecommendations($filename, $limit = false)
{
$f = fopen($filename, "w");
$stubs = Recommendations::findStubs($limit);
$r = new Recommendations();
$r->excludeWorstRelated(250);
$userScore = array();
foreach ($stubs as $stub) {
if ($stub) {
$userScore = $r->getSuggestedUsers($stub);
arsort($userScore);
foreach ($userScore as $username => $score) {
if (Recommendations::isAvailableUser($username)) {
print wfTimestampNow() . " Adding recommendation to edit " . $stub->getText() . " for user " . $username . "\n";
$u = User::newFromId($username);
if ($u && $u->getId()) {
fwrite($f, $u->getId() . "\t" . $stub->getArticleId() . "\t" . $score);
$reasons = $r->getSuggestionReason($username, $stub->getArticleId());
foreach ($reasons as $reason) {
fwrite($f, "\t" . $reason);
}
fwrite($f, "\n");
}
}
}
}
}
}
示例6: execute
public function execute($subpage)
{
global $wgOut, $wgRequest, $wgUser, $wgCacheEpoch, $wgCityId;
wfProfileIn(__METHOD__);
$this->setHeaders();
$this->mTitle = SpecialPage::getTitleFor('cacheepoch');
if ($this->isRestricted() && !$this->userCanExecute($wgUser)) {
$this->displayRestrictionError();
wfProfileOut(__METHOD__);
return;
}
//no WikiFactory (internal wikis)
if (empty($wgCityId)) {
$wgOut->addHTML(wfMsg('cacheepoch-no-wf'));
wfProfileOut(__METHOD__);
return;
}
if ($wgRequest->wasPosted()) {
$wgCacheEpoch = wfTimestampNow();
$status = WikiFactory::setVarByName('wgCacheEpoch', $wgCityId, $wgCacheEpoch, wfMsg('cacheepoch-wf-reason'));
if ($status) {
$wgOut->addHTML('<h2>' . wfMsg('cacheepoch-updated', $wgCacheEpoch) . '</h2>');
} else {
$wgOut->addHTML('<h2>' . wfMsg('cacheepoch-not-updated') . '</h2>');
}
} else {
$wgOut->addHTML('<h2>' . wfMsg('cacheepoch-header') . '</h2>');
}
$wgOut->addHTML(Xml::openElement('form', array('action' => $this->mTitle->getFullURL(), 'method' => 'post')));
$wgOut->addHTML(wfMsg('cacheepoch-value', $wgCacheEpoch) . '<br>');
$wgOut->addHTML(Xml::submitButton(wfMsg('cacheepoch-submit')));
$wgOut->addHTML(Xml::closeElement('form'));
wfProfileOut(__METHOD__);
}
示例7: execute
public function execute()
{
$posFile = $this->getOption('p', 'searchUpdate.' . wfWikiId() . '.pos');
$end = $this->getOption('e', wfTimestampNow());
if ($this->hasOption('s')) {
$start = $this->getOption('s');
} elseif (is_readable('searchUpdate.pos')) {
# B/c to the old position file name which was hardcoded
# We can safely delete the file when we're done though.
$start = file_get_contents('searchUpdate.pos');
unlink('searchUpdate.pos');
} elseif (is_readable($posFile)) {
$start = file_get_contents($posFile);
} else {
$start = wfTimestamp(TS_MW, time() - 86400);
}
$lockTime = $this->getOption('l', 20);
$this->doUpdateSearchIndex($start, $end, $lockTime);
if (is_writable(dirname(realpath($posFile)))) {
$file = fopen($posFile, 'w');
if ($file !== false) {
fwrite($file, $end);
fclose($file);
} else {
$this->error("*** Couldn't write to the {$posFile}!\n");
}
} else {
$this->error("*** Couldn't write to the {$posFile}!\n");
}
}
示例8: insert
/**
* Adds this new notification object to the backend storage.
*/
protected function insert()
{
global $wgEchoBackend, $wgEchoNotifications;
$row = array('notification_event' => $this->event->getId(), 'notification_user' => $this->user->getId(), 'notification_anon_ip' => $this->user->isAnon() ? $this->user->getName() : $this->user->getId(), 'notification_timestamp' => $this->timestamp, 'notification_read_timestamp' => $this->readTimestamp, 'notification_bundle_hash' => '', 'notification_bundle_display_hash' => '');
// Get the bundle key for this event if web bundling is enabled
$bundleKey = '';
if (!empty($wgEchoNotifications[$this->event->getType()]['bundle']['web'])) {
wfRunHooks('EchoGetBundleRules', array($this->event, &$bundleKey));
}
if ($bundleKey) {
$hash = md5($bundleKey);
$row['notification_bundle_hash'] = $hash;
$lastStat = $wgEchoBackend->getLastBundleStat($this->user, $hash);
// Use a new display hash if:
// 1. there was no last bundle notification
// 2. last bundle notification with the same hash was read
if ($lastStat && !$lastStat->notification_read_timestamp) {
$row['notification_bundle_display_hash'] = $lastStat->notification_bundle_display_hash;
} else {
$row['notification_bundle_display_hash'] = md5($bundleKey . '-display-hash-' . wfTimestampNow());
}
}
$wgEchoBackend->createNotification($row);
wfRunHooks('EchoCreateNotificationComplete', array($this));
}
示例9: getVisibilitySettingsFromRow
/**
* Get page configuration settings from a DB row
*/
public static function getVisibilitySettingsFromRow($row)
{
if ($row) {
# This code should be refactored, now that it's being used more generally.
$expiry = Block::decodeExpiry($row->fpc_expiry);
# Only apply the settings if they haven't expired
if (!$expiry || $expiry < wfTimestampNow()) {
$row = null;
// expired
self::purgeExpiredConfigurations();
}
}
// Is there a non-expired row?
if ($row) {
$level = $row->fpc_level;
if (!self::isValidRestriction($row->fpc_level)) {
$level = '';
// site default; ignore fpc_level
}
$config = array('override' => $row->fpc_override ? 1 : 0, 'autoreview' => $level, 'expiry' => Block::decodeExpiry($row->fpc_expiry));
# If there are protection levels defined check if this is valid...
if (FlaggedRevs::useProtectionLevels()) {
$level = self::getProtectionLevel($config);
if ($level == 'invalid' || $level == 'none') {
// If 'none', make sure expiry is 'infinity'
$config = self::getDefaultVisibilitySettings();
// revert to default (none)
}
}
} else {
# Return the default config if this page doesn't have its own
$config = self::getDefaultVisibilitySettings();
}
return $config;
}
示例10: csvOutput
function csvOutput($res)
{
global $wgOut, $wgRequest;
$ts = wfTimestampNow();
$filename = "community_applications_{$ts}.csv";
$wgOut->disable();
wfResetOutputBuffers();
$wgRequest->response()->header("Content-disposition: attachment;filename={$filename}");
$wgRequest->response()->header("Content-type: text/csv; charset=utf-8");
$fh = fopen('php://output', 'w');
$fields = null;
foreach ($res as $row) {
$data = FormatJson::decode($row->ch_data, true);
$data = array('id' => $row->ch_id) + $data;
if (!is_array($fields)) {
$fields = array_keys($data);
fputcsv($fh, $fields);
}
$outData = array();
foreach ($fields as $k) {
$outData[] = isset($data[$k]) ? $data[$k] : null;
unset($data[$k]);
}
foreach ($data as $k => $v) {
$outData[] = "{$k}: {$v}";
}
fputcsv($fh, $outData);
}
fclose($fh);
}
示例11: ActivityFeedTag_render
function ActivityFeedTag_render($content, $attributes, $parser, $frame)
{
global $wgExtensionsPath, $wgEnableAchievementsInActivityFeed, $wgEnableAchievementsExt;
if (!class_exists('ActivityFeedHelper')) {
return '';
}
wfProfileIn(__METHOD__);
$parameters = ActivityFeedHelper::parseParameters($attributes);
$tagid = str_replace('.', '_', uniqid('activitytag_', true));
//jQuery might have a problem with . in ID
$jsParams = "size={$parameters['maxElements']}";
if (!empty($parameters['includeNamespaces'])) {
$jsParams .= "&ns={$parameters['includeNamespaces']}";
}
if (!empty($parameters['flags'])) {
$jsParams .= '&flags=' . implode('|', $parameters['flags']);
}
$parameters['tagid'] = $tagid;
$feedHTML = ActivityFeedHelper::getList($parameters);
$style = empty($parameters['style']) ? '' : ' style="' . $parameters['style'] . '"';
$timestamp = wfTimestampNow();
$snippetsDependencies = array('/extensions/wikia/MyHome/ActivityFeedTag.js', '/extensions/wikia/MyHome/ActivityFeedTag.css');
if (!empty($wgEnableAchievementsInActivityFeed) && !empty($wgEnableAchievementsExt)) {
array_push($snippetsDependencies, '/extensions/wikia/AchievementsII/css/achievements_sidebar.css');
}
$snippets = F::build('JSSnippets')->addToStack($snippetsDependencies, null, 'ActivityFeedTag.initActivityTag', array('tagid' => $tagid, 'jsParams' => $jsParams, 'timestamp' => $timestamp));
wfProfileOut(__METHOD__);
return "<div{$style}>{$feedHTML}</div>{$snippets}";
}
示例12: getDateCond
function getDateCond()
{
if ($this->year || $this->month) {
// Assume this year if only a month is given
if ($this->year) {
$year_start = $this->year;
} else {
$year_start = substr(wfTimestampNow(), 0, 4);
$thisMonth = gmdate('n');
if ($this->month > $thisMonth) {
// Future contributions aren't supposed to happen. :)
$year_start--;
}
}
if ($this->month) {
$month_end = str_pad($this->month + 1, 2, '0', STR_PAD_LEFT);
$year_end = $year_start;
} else {
$month_end = 0;
$year_end = $year_start + 1;
}
$ts_end = str_pad($year_end . $month_end, 14, '0');
$this->mOffset = $ts_end;
}
}
示例13: onGroupNotify
/**
* Handles group notification.
*
* @since 0.1
*
* @param SWLGroup $group
* @param array $userIDs
* @param SMWChangeSet $changes
*
* @return true
*/
public static function onGroupNotify(SWLGroup $group, array $userIDs, SWLChangeSet $changes)
{
global $egSWLMailPerChange, $egSWLMaxMails;
foreach ($userIDs as $userID) {
$user = User::newFromId($userID);
if ($user->getOption('swl_email', false)) {
if ($user->getName() != $changes->getEdit()->getUser()->getName() || $GLOBALS['egSWLEnableSelfNotify']) {
if (!method_exists('Sanitizer', 'validateEmail') || Sanitizer::validateEmail($user->getEmail())) {
$lastNotify = $user->getOption('swl_last_notify');
$lastWatch = $user->getOption('swl_last_watch');
if (is_null($lastNotify) || is_null($lastWatch) || $lastNotify < $lastWatch) {
$mailCount = $user->getOption('swl_mail_count', 0);
if ($egSWLMailPerChange || $mailCount < $egSWLMaxMails) {
SWLEmailer::notifyUser($group, $user, $changes, $egSWLMailPerChange);
$user->setOption('swl_last_notify', wfTimestampNow());
$user->setOption('swl_mail_count', $mailCount + 1);
$user->saveSettings();
}
}
}
}
}
}
return true;
}
示例14: insertLogRecord
/**
* Insert to the logging table
* @param array $values Values to be entered to the DB
* @return bool True/False on query success/fail
*/
public static function insertLogRecord($values)
{
$logValues = array('pa_page_id' => $values['pa_page_id'], 'pa_user_id' => $values['pa_user'], 'pa_page_revision' => $values['pa_page_revision'], 'pa_project' => $values['pa_project'], 'pa_class' => $values['pa_class'], 'pa_importance' => $values['pa_importance'], 'pa_timestamp' => wfTimestampNow());
$dbw = wfGetDB(DB_MASTER);
$dbw->insert('page_assessments_log', $logValues, __METHOD__);
return true;
}
示例15: run
/**
* Run a refreshLinks job
* @return boolean success
*/
function run()
{
global $wgTitle, $wgUser, $wgLang, $wrGedcomExportDirectory;
$wgTitle = $this->title;
// FakeTitle (the default) generates errors when accessed, and sometimes I log wgTitle, so set it to something else
$wgUser = User::newFromName('WeRelate agent');
// set the user
$treeId = $this->params['tree_id'];
$treeName = $this->params['name'];
$treeUser = $this->params['user'];
$filename = "{$wrGedcomExportDirectory}/{$treeId}.ged";
$ge = new GedcomExporter();
$error = $ge->exportGedcom($treeId, $filename);
if ($error) {
$this->error = $error;
return false;
}
// leave a message for the tree requester
$userTalkTitle = Title::newFromText($treeUser, NS_USER_TALK);
$article = new Article($userTalkTitle, 0);
if ($article->getID() != 0) {
$text = $article->getContent();
} else {
$text = '';
}
$title = Title::makeTitle(NS_SPECIAL, 'Trees');
$msg = wfMsg('GedcomExportReady', $wgLang->date(wfTimestampNow(), true, false), $treeName, $title->getFullURL(wfArrayToCGI(array('action' => 'downloadExport', 'user' => $treeUser, 'name' => $treeName))));
$text .= "\n\n" . $msg;
$success = $article->doEdit($text, 'GEDCOM export ready');
if (!$success) {
$this->error = 'Unable to edit user talk page: ' . $treeUser;
return false;
}
return true;
}