本文整理汇总了PHP中XenForo_Locale::numberFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Locale::numberFormat方法的具体用法?PHP XenForo_Locale::numberFormat怎么用?PHP XenForo_Locale::numberFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Locale
的用法示例。
在下文中一共展示了XenForo_Locale::numberFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: applyCover
public function applyCover($teamId, $fileName, $imageType = false, $width = false, $height = false, $existingCoverDate = 0)
{
if (!$imageType || !$width || !$height) {
$imageInfo = @getimagesize($fileName);
if (!$imageInfo) {
throw new Nobita_Teams_Exception_Abstract('Non-image passed in to applyCover');
}
$width = $imageInfo[0];
$height = $imageInfo[1];
$imageType = $imageInfo[2];
}
if (!in_array($imageType, array(IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
throw new Nobita_Teams_Exception_Abstract('Invalid image type passed in to applyCover');
}
if (!XenForo_Image_Abstract::canResize($width, $height)) {
throw new Nobita_Teams_Exception_Abstract(new XenForo_Phrase('uploaded_image_is_too_big'), true);
}
$maxFileSize = XenForo_Application::getOptions()->Teams_coverFileSize;
if ($maxFileSize && filesize($fileName) > $maxFileSize) {
@unlink($fileName);
throw new XenForo_Exception(new XenForo_Phrase('Teams_your_cover_file_size_large_smaller_x', array('size' => XenForo_Locale::numberFormat($maxFileSize, 'size'))), true);
}
if ($existingCoverDate) {
$existedFile = $this->getCoverCropFilePath($teamId, $existingCoverDate);
@unlink($existedFile);
}
$this->_witerCoverPhoto($teamId, $fileName);
@unlink($fileName);
$dwData = array('cover_date' => XenForo_Application::$time, 'cover_crop_details' => array('height' => $height, 'width' => $width));
$dw = XenForo_DataWriter::create('Nobita_Teams_DataWriter_Team');
$dw->setExistingData($teamId);
$dw->bulkSet($dwData);
$dw->save();
return $dwData;
}
示例2: rebuild
/**
* @param int $position
* @param array $options
* @param string $detailedMessage
* @return bool|int|string|true
*/
public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
{
$options['batch'] = max(1, isset($options['batch']) ? $options['batch'] : 10);
/* @var sonnb_XenGallery_Model_Location $locationModel */
$locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
$locations = $locationModel->getLocationsWithoutCoordinate($position, $options['batch']);
if (count($locations) < 1) {
return true;
}
XenForo_Db::beginTransaction();
$db = XenForo_Application::getDb();
/** @var sonnb_XenGallery_Model_Location $locationModel */
$locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
foreach ($locations as $locationId => $location) {
$position = $location['location_id'];
try {
$client = XenForo_Helper_Http::getClient($locationModel->getGeocodeUrlForAddress($location['location_name']));
$response = $client->request('GET');
$response = @json_decode($response->getBody(), true);
if (empty($response['results'][0])) {
continue;
}
$address = $response['results'][0]['formatted_address'];
$lat = $response['results'][0]['geometry']['location']['lat'];
$lng = $response['results'][0]['geometry']['location']['lng'];
$db->update('sonnb_xengallery_location', array('location_name' => $address, 'location_lat' => $lat, 'location_lng' => $lng), array('location_id = ?' => $location['location_id']));
} catch (Exception $e) {
continue;
}
}
XenForo_Db::commit();
$detailedMessage = XenForo_Locale::numberFormat($position);
return $position;
}
示例3: 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;
}
示例4: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('position' => 0, 'batch' => 70), $data);
$data['batch'] = max(1, $data['batch']);
/* @var $postModel XenForo_Model_Post */
$postModel = XenForo_Model::create('XenForo_Model_Post');
$postIds = $postModel->getPostIdsInRange($data['position'], $data['batch']);
if (sizeof($postIds) == 0) {
return true;
}
foreach ($postIds as $postId) {
$data['position'] = $postId;
/* @var $postDw XenForo_DataWriter_DiscussionMessage_Post */
$postDw = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post', XenForo_DataWriter::ERROR_SILENT);
if ($postDw->setExistingData($postId)) {
XenForo_Db::beginTransaction();
$postDw->rebuildPostVerseCache();
XenForo_Db::commit();
}
}
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('posts');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
return $data;
}
示例5: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('position' => 0, 'batch' => 5, 'positionRebuild' => false), $data);
$data['batch'] = max(1, $data['batch']);
/* @var $mediaModel XenGallery_Model_Media */
$mediaModel = XenForo_Model::create('XenGallery_Model_Media');
/* @var $commentModel XenGallery_Model_Comment */
$commentModel = XenForo_Model::create('XenGallery_Model_Comment');
$mediaIds = $mediaModel->getMediaIdsInRange($data['position'], $data['batch'], 'all');
if (sizeof($mediaIds) == 0) {
return true;
}
foreach ($mediaIds as $mediaId) {
$conditions = array('media_id' => $mediaId);
$count = $commentModel->countComments($conditions);
$mediaWriter = XenForo_DataWriter::create('XenGallery_DataWriter_Media');
$mediaWriter->setExistingData($mediaId);
$mediaWriter->set('comment_count', $count);
$mediaWriter->save();
if ($data['positionRebuild']) {
// $mediaWriter->rebuildCommentPositions();
}
$data['position'] = $mediaId;
}
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('xengallery_rebuilding_media_comment_counts');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
return $data;
}
示例6: 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;
}
示例7: rebuild
/**
* Rebuilds the data.
*
* @see XenForo_CacheRebuilder_Abstract::rebuild()
*/
public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
{
$options['batch'] = isset($options['batch']) ? $options['batch'] : 75;
$options['batch'] = max(1, $options['batch']);
/* @var $userModel XenForo_Model_User */
$userModel = XenForo_Model::create('XenForo_Model_User');
/* @var $conversationModel XenForo_Model_Conversation */
$conversationModel = XenForo_Model::create('XenForo_Model_Conversation');
$userIds = $userModel->getUserIdsInRange($position, $options['batch']);
if (sizeof($userIds) == 0) {
return true;
}
XenForo_Db::beginTransaction();
foreach ($userIds as $userId) {
$position = $userId;
/* @var $userDw XenForo_DataWriter_User */
$userDw = XenForo_DataWriter::create('XenForo_DataWriter_User', XenForo_DataWriter::ERROR_SILENT);
if ($userDw->setExistingData($userId)) {
$userDw->set('alerts_unread', $userModel->getUnreadAlertsCount($userId));
$userDw->set('conversations_unread', $conversationModel->countUnreadConversationsForUser($userId));
$userDw->save();
$userDw->rebuildUserGroupRelations();
$userDw->rebuildPermissionCombinationId();
$userDw->rebuildDisplayStyleGroupId();
$userDw->rebuildIdentities();
}
}
XenForo_Db::commit();
$detailedMessage = XenForo_Locale::numberFormat($position);
return $position;
}
示例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');
$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;
}
示例9: 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;
}
}
示例10: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('userGroupId' => 0, 'displayPriority' => 0, 'count' => 0), $data);
if (!$data['userGroupId']) {
return false;
}
$s = microtime(true);
/* @var $groupModel XenForo_Model_UserGroup */
$groupModel = XenForo_Model::create('XenForo_Model_UserGroup');
$limit = 100;
do {
$results = $groupModel->removeUserGroupFromUsers($data['userGroupId'], XenForo_Model_User::$defaultRegisteredGroupId, $limit);
if (!$results[0] && !$results[1]) {
$groupModel->recalculateUserGroupDisplayStylePriority($data['userGroupId'], $data['displayPriority'], -1);
$groupModel->rebuildDisplayStyleCache();
$groupModel->rebuildUserBannerCache();
return false;
}
$data['count'] += $limit;
} while ($targetRunTime && microtime(true) - $s < $targetRunTime);
$actionPhrase = new XenForo_Phrase('deleting');
$typePhrase = new XenForo_Phrase('user_group');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['count']));
return $data;
}
示例11: rebuild
/**
* Rebuilds the data.
*
* @see XenForo_CacheRebuilder_Abstract::rebuild()
*/
public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
{
$options = array_merge(array('batch' => 100, 'positionRebuild' => false), $options);
/* @var $threadModel XenForo_Model_Thread */
$threadModel = XenForo_Model::create('XenForo_Model_Thread');
$threadIds = $threadModel->getThreadIdsInRange($position, $options['batch']);
if (sizeof($threadIds) == 0) {
return true;
}
XenForo_Db::beginTransaction();
foreach ($threadIds as $threadId) {
$position = $threadId;
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread', XenForo_DataWriter::ERROR_SILENT);
if ($dw->setExistingData($threadId)) {
$dw->setOption(XenForo_DataWriter_Discussion::OPTION_UPDATE_CONTAINER, false);
if ($options['positionRebuild']) {
$dw->rebuildDiscussion();
} else {
$dw->rebuildDiscussionCounters();
}
$dw->save();
}
}
XenForo_Db::commit();
$detailedMessage = XenForo_Locale::numberFormat($position);
return $position;
}
示例12: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('batch' => 100, 'position' => 0, 'positionRebuild' => false), $data);
/* @var $threadModel XenForo_Model_Thread */
$threadModel = XenForo_Model::create('XenForo_Model_Thread');
$threadIds = $threadModel->getThreadIdsInRange($data['position'], $data['batch']);
if (sizeof($threadIds) == 0) {
return false;
}
$forums = XenForo_Model::create('XenForo_Model_Forum')->getForumsByThreadIds($threadIds);
foreach ($threadIds as $threadId) {
$data['position'] = $threadId;
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread', XenForo_DataWriter::ERROR_SILENT);
if ($dw->setExistingData($threadId)) {
$dw->setOption(XenForo_DataWriter_Discussion::OPTION_UPDATE_CONTAINER, false);
if (isset($forums[$dw->get('node_id')])) {
$dw->setExtraData(XenForo_DataWriter_Discussion_Thread::DATA_FORUM, $forums[$dw->get('node_id')]);
}
if ($data['positionRebuild']) {
$dw->rebuildDiscussion();
} else {
$dw->rebuildDiscussionCounters();
}
$dw->save();
}
}
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('threads');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
return $data;
}
示例13: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('batch' => 10, 'position' => 0, 'positionRebuild' => false), $data);
/* @var sonnb_XenGallery_Model_Location $locationModel */
$locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
$locations = $locationModel->getLocationsWithoutCoordinate($data['position'], $data['batch']);
if (count($locations) < 1) {
return false;
}
$db = XenForo_Application::getDb();
/** @var sonnb_XenGallery_Model_Location $locationModel */
$locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
foreach ($locations as $locationId => $location) {
$data['position'] = $location['location_id'];
try {
$client = XenForo_Helper_Http::getClient($locationModel->getGeocodeUrlForAddress($location['location_name']));
$response = $client->request('GET');
$response = @json_decode($response->getBody(), true);
if (empty($response['results'][0])) {
continue;
}
$address = $response['results'][0]['formatted_address'];
$lat = $response['results'][0]['geometry']['location']['lat'];
$lng = $response['results'][0]['geometry']['location']['lng'];
$db->update('sonnb_xengallery_location', array('location_name' => $address, 'location_lat' => $lat, 'location_lng' => $lng), array('location_id = ?' => $location['location_id']));
} catch (Exception $e) {
continue;
}
}
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('sonnb_xengallery_location');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
return $data;
}
示例14: 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;
}
示例15: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('position' => 0, 'batch' => 70), $data);
$data['batch'] = max(1, $data['batch']);
/* @var $userModel XenForo_Model_User */
$userModel = XenForo_Model::create('XenForo_Model_User');
/* @var $conversationModel XenForo_Model_Conversation */
$conversationModel = XenForo_Model::create('XenForo_Model_Conversation');
$userIds = $userModel->getUserIdsInRange($data['position'], $data['batch']);
if (sizeof($userIds) == 0) {
return true;
}
foreach ($userIds as $userId) {
$data['position'] = $userId;
/* @var $userDw XenForo_DataWriter_User */
$userDw = XenForo_DataWriter::create('XenForo_DataWriter_User', XenForo_DataWriter::ERROR_SILENT);
if ($userDw->setExistingData($userId)) {
XenForo_Db::beginTransaction();
$userDw->set('alerts_unread', $userModel->getUnreadAlertsCount($userId));
$userDw->set('conversations_unread', $conversationModel->countUnreadConversationsForUser($userId));
$userDw->save();
$userDw->rebuildUserGroupRelations();
$userDw->rebuildPermissionCombinationId();
$userDw->rebuildDisplayStyleGroupId();
$userDw->rebuildCustomFields();
$userDw->rebuildIgnoreCache();
XenForo_Db::commit();
}
}
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('users');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
return $data;
}