本文整理汇总了PHP中XenForo_Locale类的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Locale类的具体用法?PHP XenForo_Locale怎么用?PHP XenForo_Locale使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XenForo_Locale类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rebuild
/**
* @see XenForo_CacheRebuilder_DailyStats::rebuild()
*/
public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
{
$options['batch'] = isset($options['batch']) ? $options['batch'] : 28;
$options['batch'] = max(1, $options['batch']);
/* @var $userModel XenForo_Model_Stats */
$statsModel = XenForo_Model::create('XenForo_Model_Stats');
if ($position == 0) {
// delete old stats cache if required
if (!empty($options['delete'])) {
$statsModel->deleteStats();
}
$xenOptions = XenForo_Application::get('options');
// an appropriate date from which to start... first thread, or earliest user reg?
if ($xenOptions->th_noForo_noForum) {
$position = XenForo_Model::create('XenForo_Model_User')->getEarliestRegistrationDate();
} else {
$position = min(XenForo_Model::create('XenForo_Model_Thread')->getEarliestThreadDate(), XenForo_Model::create('XenForo_Model_User')->getEarliestRegistrationDate());
}
// start on a 24 hour increment point
$position = $position - $position % 86400;
} else {
if ($position > XenForo_Application::$time) {
return true;
}
}
XenForo_Db::beginTransaction();
$endPosition = $position + $options['batch'] * 86400;
$data = $statsModel->buildStatsData($position, $endPosition);
XenForo_Db::commit();
$detailedMessage = XenForo_Locale::date($position, 'absolute');
return $endPosition;
}
示例2: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('position' => 0, 'batch' => 100), $data);
$data['batch'] = max(1, $data['batch']);
/* @var $trophyModel XenForo_Model_Trophy */
$trophyModel = XenForo_Model::create('XenForo_Model_Trophy');
$trophies = $trophyModel->getAllTrophies();
if (!$trophies) {
return true;
}
/* @var $userModel XenForo_Model_User */
$userModel = XenForo_Model::create('XenForo_Model_User');
$userIds = $userModel->getUserIdsInRange($data['position'], $data['batch']);
if (sizeof($userIds) == 0) {
return true;
}
$data['position'] = end($userIds);
$users = $userModel->getUsers(array('user_state' => 'valid', 'is_banned' => 0, 'user_id' => $userIds), array('join' => XenForo_Model_User::FETCH_USER_FULL));
$userTrophies = $trophyModel->getUserTrophiesByUserIds(array_keys($users));
foreach ($users as $user) {
$trophyModel->updateTrophiesForUser($user, isset($userTrophies[$user['user_id']]) ? $userTrophies[$user['user_id']] : array(), $trophies);
$trophyModel->updateTrophyPointsForUser($user['user_id']);
}
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('trophies');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
return $data;
}
示例3: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('position' => 0, 'batch' => 100, 'delete' => false), $data);
$data['batch'] = max(1, $data['batch']);
/* @var $statsModel XenForo_Model_Stats */
$statsModel = XenForo_Model::create('XenForo_Model_Stats');
if ($data['position'] == 0) {
// delete old stats cache if required
if (!empty($data['delete'])) {
$statsModel->deleteStats();
}
// an appropriate date from which to start... first thread, or earliest user reg?
$data['position'] = min(XenForo_Model::create('XenForo_Model_Thread')->getEarliestThreadDate(), XenForo_Model::create('XenForo_Model_User')->getEarliestRegistrationDate());
// start on a 24 hour increment point
$data['position'] = $data['position'] - $data['position'] % 86400;
} else {
if ($data['position'] > XenForo_Application::$time) {
return true;
}
}
$endPosition = $data['position'] + $data['batch'] * 86400;
$statsModel->buildStatsData($data['position'], $endPosition);
$data['position'] = $endPosition;
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('daily_statistics');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::date($data['position'], 'absolute'));
return $data;
}
示例4: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('position' => 0, 'batch' => 5), $data);
$data['batch'] = max(1, $data['batch']);
/* @var $albumModel XenGallery_Model_Album */
$albumModel = XenForo_Model::create('XenGallery_Model_Album');
/* @var $mediaModel XenGallery_Model_Media */
$mediaModel = XenForo_Model::create('XenGallery_Model_Media');
$albumIds = $albumModel->getAlbumIdsInRange($data['position'], $data['batch']);
if (sizeof($albumIds) == 0) {
return true;
}
foreach ($albumIds as $albumId) {
$count = $mediaModel->countMedia(array('album_id' => $albumId));
$albumWriter = XenForo_DataWriter::create('XenGallery_DataWriter_Album');
$albumWriter->setExistingData($albumId);
$albumWriter->set('album_media_count', $count);
$albumWriter->save();
$data['position'] = $albumId;
}
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('xengallery_rebuilding_album_media_counts');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
return $data;
}
示例5: runDailyCleanUp
public static function runDailyCleanUp()
{
$options = XenForo_Application::get('options');
$model = XenForo_Model::create('Dark_TaigaChat_Model_TaigaChat');
if ($options->dark_taigachat_archivethread > 0) {
$messages = array_reverse($model->getMessagesToday());
if (count($messages) > 0) {
$userModel = XenForo_Model::create('XenForo_Model_User');
$post = "";
foreach ($messages as $message) {
$date = XenForo_Locale::dateTime($message['date'], 'absolute');
if ($message['user_id'] > 0) {
$url = XenForo_Link::convertUriToAbsoluteUri(XenForo_Link::buildPublicLink("members/" . $message['user_id']), true);
$user = "[url='{$url}']{$message['username']}[/url]";
} else {
$user = "[b]{$message['username']}[/b]";
}
$post .= "{$date} - {$user}: {$message['message']}\r\n";
}
$username = "TaigaChat";
if ($options->dark_taigachat_archiveuser > 0) {
$user = $userModel->getUserById($options->dark_taigachat_archiveuser);
$username = $user['username'];
}
$writer = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post');
$writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_IS_AUTOMATED, true);
$writer->set('user_id', $options->dark_taigachat_archiveuser);
$writer->set('username', $username);
$writer->set('message', $post);
$writer->set('thread_id', $options->dark_taigachat_archivethread);
$writer->save();
}
}
$model->deleteOldMessages();
}
示例6: rebuild
/**
* Rebuilds the data.
*
* @see XenForo_CacheRebuilder_Abstract::rebuild()
*/
public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
{
$options['batch'] = max(1, isset($options['batch']) ? $options['batch'] : 10);
if ($position == 0) {
XenForo_Model::create('XenForo_Model_Node')->updateNestedSetInfo();
}
/* @var $forumModel XenForo_Model_Forum */
$forumModel = XenForo_Model::create('XenForo_Model_Forum');
$forums = $forumModel->getForums(array(), array('limit' => $options['batch'], 'offset' => $position));
XenForo_Db::beginTransaction();
foreach ($forums as $forum) {
$position++;
$forumDw = XenForo_DataWriter::create('XenForo_DataWriter_Forum', XenForo_DataWriter::ERROR_SILENT);
if ($forumDw->setExistingData($forum, true)) {
$forumDw->rebuildCounters();
$forumDw->save();
}
}
XenForo_Db::commit();
$detailedMessage = XenForo_Locale::numberFormat($position);
if (!$forums) {
return true;
} else {
return $position;
}
}
示例7: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
return true;
$data = array_merge(array('position' => 0, 'batch' => 10), $data);
$data['batch'] = max(1, $data['batch']);
/* @var $feedbackModel NixFifty_XenTrader_Model_Feedback */
$feedbackModel = XenForo_Model::create('NixFifty_XenTrader_Model_Feedback');
$feedbackItems = $feedbackModel->getUserIdsInFeedbackRange($data['position'], $data['batch']);
if (sizeof($feedbackItems) == 0) {
return true;
}
$db = XenForo_Application::getDb();
XenForo_Db::beginTransaction($db);
foreach ($feedbackItems as $feedbackItem) {
$data['position'] = $item['media_id'];
$feedbackCount = $db->fetchOne('
SELECT COUNT(*)
FROM xf_nixfifty_xentrader_feedback
WHERE to_user_id = ?
', $feedbackItem);
$db->update('xf_nixfifty_xentrader_user', array('total' => $feedbackCount), 'user_id = ' . $db->quote($feedbackItem));
}
XenForo_Db::commit($db);
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = 'fam i think im broken';
//new XenForo_Phrase('xengallery_rebuild_thumbnails');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
return $data;
}
示例8: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('position' => 0, 'batch' => 10), $data);
$data['batch'] = max(1, $data['batch']);
/* @var $albumModel XenGallery_Model_Album */
$albumModel = XenForo_Model::create('XenGallery_Model_Album');
/* @var $mediaModel XenGallery_Model_Media */
$mediaModel = XenForo_Model::create('XenGallery_Model_Media');
$albumIds = $albumModel->getAlbumIdsInRange($data['position'], $data['batch']);
if (sizeof($albumIds) == 0) {
return true;
}
foreach ($albumIds as $albumId) {
$data['position'] = $albumId;
$writer = XenForo_DataWriter::create('XenGallery_DataWriter_Album');
$writer->setExistingData($albumId);
if (!$writer->get('manual_media_cache') && !$writer->get('album_thumbnail_date')) {
$media = $mediaModel->getMediaForAlbumCache($albumId);
$writer->bulkSet(array('media_cache' => serialize($media)));
$writer->save();
}
}
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('xengallery_rebuild_album_thumbnails');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
return $data;
}
示例9: currencyFormat
/**
* Formats the given number for a currency.
*
* @param float|integer $number Number to format
* @param int|null $currencyId Currency to override default
*
* @return string Formatted number
*/
public static function currencyFormat($number = 0)
{
$currency = array('symbol_left' => '', 'symbol_right' => ' VNĐ', 'value' => 1, 'decimal_place' => 0);
$negative = false;
$formated = '';
if (is_numeric($number)) {
if ($number < 0) {
$negative = true;
$number *= -1;
}
$number *= $currency['value'];
$number = XenForo_Locale::numberFormat($number, $currency['decimal_place']);
} else {
$number = XenForo_Locale::numberFormat(0, $currency['decimal_place']);
}
$formated = $negative ? ' - ' : '';
if ($currency['symbol_left']) {
$formated .= $currency['symbol_left'];
}
$formated .= $number;
if ($currency['symbol_right']) {
$formated .= $currency['symbol_right'];
}
return $formated;
}
示例10: rebuild
/**
* Rebuilds the data.
*
* @see XenForo_CacheRebuilder_Abstract::rebuild()
*/
public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
{
$options['batch'] = max(1, isset($options['batch']) ? $options['batch'] : 10);
$socialForumModel = ThemeHouse_SocialGroups_SocialForum::getSocialForumModel();
if ($position == 0) {
$socialForumModel->unlinkMovedThreads();
}
$socialForums = $socialForumModel->getSocialForums(array(), array('limit' => $options['batch'], 'offset' => $position));
XenForo_Db::beginTransaction();
foreach ($socialForums as $socialForum) {
$position++;
/* @var $socialForumDw ThemeHouse_SocialGroups_DataWriter_SocialForum */
$socialForumDw = XenForo_DataWriter::create('ThemeHouse_SocialGroups_DataWriter_SocialForum', XenForo_DataWriter::ERROR_SILENT);
if ($socialForumDw->setExistingData($socialForum, true)) {
$socialForumDw->rebuildCounters();
$socialForumDw->save();
}
}
XenForo_Db::commit();
$detailedMessage = XenForo_Locale::numberFormat($position);
if (!$socialForums) {
return true;
} else {
return $position;
}
}
示例11: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('position' => 0, 'batch' => 100), $data);
$data['batch'] = max(1, $data['batch']);
if ($data['position'] == 0) {
XenForo_Model::create('XenForo_Model_Node')->updateNestedSetInfo();
}
/* @var $forumModel XenForo_Model_Forum */
$forumModel = XenForo_Model::create('XenForo_Model_Forum');
$forums = $forumModel->getForums(array(), array('limit' => $data['batch'], 'offset' => $data['position']));
if (!$forums) {
return false;
}
foreach ($forums as $forum) {
$data['position']++;
$forumDw = XenForo_DataWriter::create('XenForo_DataWriter_Forum', XenForo_DataWriter::ERROR_SILENT);
if ($forumDw->setExistingData($forum, true)) {
$forumDw->rebuildCounters();
$forumDw->save();
}
}
$rbPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('forums');
$status = sprintf('%s... %s (%s)', $rbPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
return $data;
}
示例12: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$inputHandler = new XenForo_Input($data);
$input = $inputHandler->filter(array('batch' => XenForo_Input::UINT, 'start' => XenForo_Input::UINT, 'extra_data' => XenForo_Input::ARRAY_SIMPLE, 'delay' => XenForo_Input::UNUM, 'content_type' => XenForo_Input::STRING, 'delete_index' => XenForo_Input::UINT));
if ($input['delay'] >= 0.01) {
usleep($input['delay'] * 1000000);
}
/* @var $searchModel XenForo_Model_Search */
$searchModel = XenForo_Model::create('XenForo_Model_Search');
$searchContentTypes = $searchModel->getSearchContentTypes();
$extraData = $input['extra_data'];
if (!isset($extraData['content_types']) || !is_array($extraData['content_types'])) {
if ($input['content_type'] && isset($searchContentTypes[$input['content_type']])) {
$extraData['content_types'] = array($input['content_type']);
} else {
$extraData['content_types'] = array_keys($searchContentTypes);
}
}
if (empty($extraData['current_type'])) {
$extraData['current_type'] = array_shift($extraData['content_types']);
}
if (empty($extraData['type_start'])) {
$extraData['type_start'] = 0;
}
$originalExtraData = $extraData;
while (!isset($searchContentTypes[$extraData['current_type']])) {
if (!$extraData['content_types']) {
return false;
}
$extraData['current_type'] = array_shift($extraData['content_types']);
}
if ($input['delete_index']) {
$source = XenForo_Search_SourceHandler_Abstract::getDefaultSourceHandler();
$source->deleteIndex($input['content_type'] ? $input['content_type'] : null);
}
$dataHandler = false;
$searchHandler = $searchContentTypes[$extraData['current_type']];
if (class_exists($searchHandler)) {
$dataHandler = XenForo_Search_DataHandler_Abstract::create($searchHandler);
$indexer = new XenForo_Search_Indexer();
$indexer->setIsRebuild(true);
$nextStart = $dataHandler->rebuildIndex($indexer, $extraData['type_start'], $input['batch']);
$indexer->finalizeRebuildSet();
} else {
$nextStart = false;
}
if ($nextStart === false) {
// move on to next type
$extraData['current_type'] = '';
$extraData['type_start'] = 0;
} else {
$extraData['type_start'] = $nextStart;
}
$data = array('batch' => $input['batch'], 'start' => $input['start'] + 1, 'extra_data' => $extraData, 'delay' => $input['delay']);
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('search_index');
$text = $dataHandler ? $dataHandler->getSearchContentTypePhrase() : new XenForo_Phrase($originalExtraData['current_type']);
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, "{$text} " . XenForo_Locale::numberFormat($originalExtraData['type_start']));
return $data;
}
示例13: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('position' => 0, 'batch' => 10), $data);
$data['batch'] = max(1, $data['batch']);
/* @var $albumModel XenGallery_Model_Album */
$albumModel = XenForo_Model::create('XenGallery_Model_Album');
$albumIds = $albumModel->getSharedAlbumIdsInRange($data['position'], $data['batch']);
if (sizeof($albumIds) == 0) {
return true;
}
$db = XenForo_Application::getDb();
XenForo_Db::beginTransaction($db);
foreach ($albumIds as $albumId) {
$data['position'] = $albumId;
$album = $albumModel->getAlbumByIdSimple($albumId);
$bind = array($album['album_id'], $album['album_user_id']);
$ownerShared = $db->fetchOne('SELECT shared_user_id FROM xengallery_shared_map WHERE album_id = ? AND shared_user_id = ?', $bind);
if (!$ownerShared) {
$db->query('
INSERT IGNORE INTO xengallery_shared_map
(album_id, shared_user_id)
VALUES
(?, ?)
', $bind);
}
}
XenForo_Db::commit($db);
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('xengallery_album_permissions');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
return $data;
}
示例14: _getPaidContentItemAddEditResponse
/**
* Helper to get the paid content add/edit form controller response.
*
* @param array $paidContentItem
*
* @return XenForo_ControllerResponse_View
*/
protected function _getPaidContentItemAddEditResponse(array $paidContentItem)
{
$paidContentItem = $this->_getPaidContentModel()->preparePaidContent($paidContentItem);
$userGroups = $this->_getUserGroupModel()->getAllUserGroups();
if (!empty($paidContentItem['paid_content_id'])) {
$selUserGroupIds = explode(',', $paidContentItem['user_group_ids']);
if (in_array(-1, $selUserGroupIds)) {
$allUserGroups = true;
$selUserGroupIds = array_keys($userGroups);
} else {
$allUserGroups = false;
}
} else {
$allUserGroups = true;
$selUserGroupIds = array_keys($userGroups);
}
if (empty($paidContentItem['start_date'])) {
$paidContentItem['startDate'] = XenForo_Locale::date(XenForo_Application::$time, 'picker');
}
if (empty($paidContentItem['end_date'])) {
$startTime = !empty($paidContentItem['start_date']) ? $paidContentItem['start_date'] : XenForo_Application::$time;
$paidContentItem['endDate'] = XenForo_Locale::date($startTime + 7 * 24 * 60 * 60, 'picker');
}
$viewParams = array('paidContentItem' => $paidContentItem, 'allUserGroups' => $allUserGroups, 'selUserGroupIds' => $selUserGroupIds, 'userGroups' => $userGroups);
return $this->responseView('ThemeHouse_PayForContent_ViewAdmin_PaidContentItem_Edit', 'th_paid_content_item_edit_payforcontent', $viewParams);
}
示例15: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('userId' => null, 'cutOff' => null, 'count' => 0, 'total' => null), $data);
if (!$data['userId'] || $data['cutOff'] === null) {
return false;
}
$s = microtime(true);
/* @var $editHistoryModel XenForo_Model_EditHistory */
$editHistoryModel = XenForo_Model::create('XenForo_Model_EditHistory');
$edits = $editHistoryModel->getEditHistoryByUserSinceDate($data['userId'], $data['cutOff']);
if (!$edits) {
return false;
}
if ($data['total'] === null) {
$data['total'] = count($edits);
}
$continue = false;
foreach ($edits as $edit) {
$editHistoryModel->revertToHistoryId($edit['edit_history_id']);
$data['count']++;
if ($targetRunTime && microtime(true) - $s > $targetRunTime) {
$continue = true;
break;
}
}
if (!$continue) {
return false;
}
$actionPhrase = new XenForo_Phrase('reverting_edits');
$status = sprintf('%s... %s (%s/$s)', $actionPhrase, XenForo_Locale::numberFormat($data['count']), XenForo_Locale::numberFormat($data['total']));
return $data;
}