本文整理汇总了PHP中XenForo_Locale::setDefaultTimeZone方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Locale::setDefaultTimeZone方法的具体用法?PHP XenForo_Locale::setDefaultTimeZone怎么用?PHP XenForo_Locale::setDefaultTimeZone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Locale
的用法示例。
在下文中一共展示了XenForo_Locale::setDefaultTimeZone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runDailyCleanUp
public static function runDailyCleanUp()
{
$options = XenForo_Application::get('options');
$model = XenForo_Model::create('Dark_TaigaChat_Model_TaigaChat');
if ($options->dark_taigachat_archivethread > 0) {
// swap timezone to default temporarily
$oldTimeZone = XenForo_Locale::getDefaultTimeZone()->getName();
XenForo_Locale::setDefaultTimeZone($options->guestTimeZone);
$messages = array_reverse($model->getMessagesToday());
if (count($messages) > 0) {
$userModel = XenForo_Model::create('XenForo_Model_User');
$post = "";
foreach ($messages as $message) {
$message['message'] = XenForo_Helper_String::autoLinkBbCode($message['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]";
}
$me = substr($message['message'], 0, 3) == '/me';
if ($me) {
$message['message'] = substr($message['message'], 3);
$post .= "{$date} - [i]{$user} {$message['message']}[/i]\r\n";
} else {
$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();
}
// put timezone back to how it was
XenForo_Locale::setDefaultTimeZone($oldTimeZone);
}
$model->deleteOldMessages();
}
示例2: setup
/**
* Setup the visitor singleton.
*
* @param integer $userId User ID to setup as
* @param array $options
*
* @return XenForo_Visitor
*/
public static function setup($userId, array $options = array())
{
$userId = intval($userId);
$options = array_merge(array('languageId' => 0, 'permissionUserId' => 0), $options);
/* @var $userModel XenForo_Model_User */
$userModel = XenForo_Model::create('XenForo_Model_User');
$class = XenForo_Application::resolveDynamicClass('XenForo_Visitor');
$object = new $class();
if ($userId && ($user = $userModel->getVisitingUserById($userId))) {
if ($user['is_admin']) {
if ($options['permissionUserId']) {
// force permissions for testing
$user = $userModel->setPermissionsFromUserId($user, $options['permissionUserId']);
}
if ($options['languageId']) {
$user['admin_language_id'] = $user['language_id'] = $options['languageId'];
}
}
$object->_user = $user;
} else {
$object->_user = $userModel->getVisitingGuestUser();
if ($options['languageId']) {
$object->_user['language_id'] = $options['languageId'];
}
}
$object->_user = $userModel->prepareUser($object->_user);
$object->_user['referer'] = !empty($options['referer']) ? $options['referer'] : null;
$object->_user['from_search'] = !empty($options['fromSearch']);
if (!empty($object->_user['ignored'])) {
$ignored = XenForo_Helper_Php::safeUnserialize($object->_user['ignored']);
$object->_user['ignoredUsers'] = $ignored;
} else {
$object->_user['ignoredUsers'] = array();
}
if (!$object->_user['global_permission_cache']) {
// force a rebuild if we don't have the perm cache
$perms = XenForo_Model::create('XenForo_Model_Permission')->rebuildPermissionCombinationById($object->_user['permission_combination_id']);
$object->_user['permissions'] = $perms ? $perms : array();
} else {
$object->_user['permissions'] = XenForo_Permission::unserializePermissions($object->_user['global_permission_cache']);
}
$object->setVisitorLanguage($object->_user['language_id']);
XenForo_Locale::setDefaultTimeZone($object->_user['timezone']);
self::$_instance = $object;
self::$_setupOptions = $options;
XenForo_CodeEvent::fire('visitor_setup', array(&self::$_instance));
return self::$_instance;
}
示例3: runDailyCleanUp
public static function runDailyCleanUp()
{
$options = XenForo_Application::get('options');
$model = XenForo_Model::create('Dark_TaigaChat_Model_TaigaChat');
if ($options->dark_taigachat_archivethread > 0) {
// swap timezone to default temporarily
$timeZone = XenForo_Locale::getDefaultTimeZone();
if (!empty($timeZone)) {
$oldTimeZone = XenForo_Locale::getDefaultTimeZone()->getName();
}
XenForo_Locale::setDefaultTimeZone($options->guestTimeZone);
$messages = array_reverse($model->getMessagesToday());
if (count($messages) > 0) {
for ($i = 0; $i < count($messages); $i += $options->dark_taigachat_archive_split) {
$userModel = XenForo_Model::create('XenForo_Model_User');
$post = "";
for ($j = $i; $j < min(count($messages), $i + $options->dark_taigachat_archive_split); $j++) {
//foreach($messages as $message){
$message = $messages[$j];
$message['message'] = XenForo_Helper_String::autoLinkBbCode($message['message']);
$date = XenForo_Locale::dateTime($message['date'], 'absolute');
if ($message['user_id'] > 0) {
$user = "[user={$message['user_id']}]{$message['username']}[/user]";
} else {
$user = "[b]{$message['username']}[/b]";
}
$me = substr($message['message'], 0, 3) == '/me';
if ($me) {
$message['message'] = substr($message['message'], 3);
$post .= "{$date} - [i]{$user} {$message['message']}[/i]\r\n";
} else {
$post .= "{$date} - {$user}: {$message['message']}\r\n";
}
}
if (empty($post)) {
continue;
}
$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);
if (defined('XenForo_DataWriter_DiscussionMessage::OPTION_CHECK_SPAM')) {
$writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_CHECK_SPAM, false);
}
$writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_MAX_MESSAGE_LENGTH, 0);
$writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_MAX_IMAGES, 0);
$writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_MAX_MEDIA, 0);
$writer->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_VERIFY_GUEST_USERNAME, false);
$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();
}
}
// put timezone back to how it was
if (!empty($oldTimeZone)) {
XenForo_Locale::setDefaultTimeZone($oldTimeZone);
}
}
$model->deleteOldMessages();
}
示例4: regeneratePublicHtml
/**
* @param mixed $overrideMotd set motd pre-cache-update
* @param mixed $unsync if not due to new message set true
*/
public function regeneratePublicHtml($overrideMotd = false, $unsync = false)
{
$viewParams = array();
$options = XenForo_Application::get('options');
$visitor = XenForo_Visitor::getInstance();
if ($options->dark_taigachat_speedmode == 'Disabled') {
return;
}
if ($unsync) {
/** @var XenForo_Model_DataRegistry */
$registryModel = $this->getModelFromCache('XenForo_Model_DataRegistry');
$lastUnsync = $registryModel->get('dark_taigachat_unsync');
if (!empty($lastUnsync) && $lastUnsync > time() - 30) {
return;
}
$registryModel->set('dark_taigachat_unsync', time());
}
// swap timezone to default temporarily
$oldTimeZone = XenForo_Locale::getDefaultTimeZone()->getName();
XenForo_Locale::setDefaultTimeZone($options->guestTimeZone);
$messages = $this->getMessages(1, array("page" => 1, "perPage" => $options->dark_taigachat_fullperpage, "lastRefresh" => 0));
$messagesMini = $this->getMessages(1, array("page" => 1, "perPage" => $options->dark_taigachat_sidebarperpage, "lastRefresh" => 0));
$messageIds = $this->getMessageIds(1, array("page" => 1, "perPage" => $options->dark_taigachat_fullperpage, "lastRefresh" => 0));
$bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base'));
$motd = new XenForo_BbCode_TextWrapper($overrideMotd !== false ? $overrideMotd : $options->dark_taigachat_motd, $bbCodeParser);
$onlineUsersTaiga = null;
if ($options->dark_taigachat_sidebar) {
$onlineUsersTaiga = $this->getActivityUserList($visitor->toArray());
}
$viewParams = array('taigachat' => array("messages" => $messages, "sidebar" => false, "messageIds" => $messageIds, "editside" => $options->dark_taigachat_editside, "timedisplay" => $options->dark_taigachat_timedisplay, "miniavatar" => $options->dark_taigachat_miniavatar, "lastrefresh" => 0, "numInChat" => $this->getActivityUserCount(), "motd" => $motd, "online" => $onlineUsersTaiga, "route" => $options->dark_taigachat_route, "publichtml" => true, 'canView' => true, 'enabled' => true));
$dep = new Dark_TaigaChat_Dependencies();
$dep->preLoadData();
$dep->preloadTemplate('dark_taigachat_list');
$viewRenderer = new Dark_TaigaChat_ViewRenderer_JsonInternal($dep, new Zend_Controller_Response_Http(), new Zend_Controller_Request_Http());
if (!file_exists($this->getDataPath() . '/taigachat')) {
XenForo_Helper_File::createDirectory($this->getDataPath() . '/taigachat', true);
}
$innerContent = $viewRenderer->renderView('Dark_TaigaChat_ViewPublic_TaigaChat_List', $viewParams, 'dark_taigachat_list');
$filename = $this->getDataPath() . '/taigachat/messages.html';
$yayForNoLocking = mt_rand(0, 10000000);
if (file_put_contents($filename . ".{$yayForNoLocking}.tmp", $innerContent, LOCK_EX) === false) {
throw new XenForo_Exception("Failed writing TaigaChat messages to {$filename}.{$yayForNoLocking}.tmp");
}
if (!@rename($filename . ".{$yayForNoLocking}.tmp", $filename)) {
@unlink($filename . ".{$yayForNoLocking}.tmp");
}
XenForo_Helper_File::makeWritableByFtpUser($filename);
$viewParams['taigachat']['messages'] = $messagesMini;
$viewParams['taigachat']['sidebar'] = true;
$innerContent = $viewRenderer->renderView('Dark_TaigaChat_ViewPublic_TaigaChat_List', $viewParams, 'dark_taigachat_list');
$filename = $this->getDataPath() . '/taigachat/messagesmini.html';
if (file_put_contents($filename . ".{$yayForNoLocking}.tmp", $innerContent, LOCK_EX) === false) {
throw new XenForo_Exception("Failed writing TaigaChat messages to {$filename}.{$yayForNoLocking}.tmp");
}
// The only reason this could fail is if the file is being hammered, hence no worries ignoring failure
if (!@rename($filename . ".{$yayForNoLocking}.tmp", $filename)) {
@unlink($filename . ".{$yayForNoLocking}.tmp");
}
XenForo_Helper_File::makeWritableByFtpUser($filename);
// put things back to how they was
XenForo_Locale::setDefaultTimeZone($oldTimeZone);
}
示例5: setup
/**
* Setup the visitor singleton.
*
* @param integer $userId User ID to setup as
* @param array $options
*
* @return XenForo_Visitor
*/
public static function setup($userId, array $options = array())
{
$userId = intval($userId);
$options = array_merge(array('languageId' => 0, 'permissionUserId' => 0), $options);
/* @var $userModel XenForo_Model_User */
$userModel = XenForo_Model::create('XenForo_Model_User');
$object = new self();
if ($userId && ($user = $userModel->getVisitingUserById($userId))) {
if ($user['is_admin'] && $options['permissionUserId']) {
// force permissions for testing
$user = $userModel->setPermissionsFromUserId($user, $options['permissionUserId']);
}
$object->_user = $user;
} else {
$object->_user = $userModel->getVisitingGuestUser();
if ($options['languageId']) {
$object->_user['language_id'] = $options['languageId'];
}
}
$object->_user['referer'] = !empty($options['referer']) ? $options['referer'] : null;
$object->_user['from_search'] = !empty($options['fromSearch']);
$object->_user['is_robot'] = !empty($options['isRobot']);
$object->_user['permissions'] = XenForo_Permission::unserializePermissions($object->_user['global_permission_cache']);
$object->setVisitorLanguage($object->_user['language_id']);
XenForo_Locale::setDefaultTimeZone($object->_user['timezone']);
self::$_instance = $object;
XenForo_CodeEvent::fire('visitor_setup', array(&self::$_instance));
return self::$_instance;
}