当前位置: 首页>>代码示例>>PHP>>正文


PHP XenForo_Locale::dateTime方法代码示例

本文整理汇总了PHP中XenForo_Locale::dateTime方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Locale::dateTime方法的具体用法?PHP XenForo_Locale::dateTime怎么用?PHP XenForo_Locale::dateTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XenForo_Locale的用法示例。


在下文中一共展示了XenForo_Locale::dateTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) {
         $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();
 }
开发者ID:Sywooch,项目名称:forums,代码行数:35,代码来源:CleanUp.php

示例2: actionBanned

 public function actionBanned()
 {
     $userId = XenForo_Visitor::getUserId();
     $bannedUser = $this->getModelFromCache('XenForo_Model_Banning')->getBannedUserById($userId);
     if (!$bannedUser) {
         return $this->responseNoPermission();
     } else {
         if ($bannedUser['triggered'] && !$bannedUser['end_date']) {
             /** @var XenForo_Model_Warning $warningModel */
             $warningModel = $this->getModelFromCache('XenForo_Model_Warning');
             $minUnbanDate = $warningModel->getMinimumWarningUnbanDate($userId);
             if ($minUnbanDate) {
                 $bannedUser['end_date'] = $minUnbanDate;
             }
         }
         if ($bannedUser['user_reason']) {
             $message = new XenForo_Phrase('you_have_been_banned_for_following_reason_x', array('reason' => $bannedUser['user_reason']));
         } else {
             $message = new XenForo_Phrase('you_have_been_banned');
         }
         if ($bannedUser['end_date'] > XenForo_Application::$time) {
             $message .= ' ' . new XenForo_Phrase('your_ban_will_be_lifted_on_x', array('date' => XenForo_Locale::dateTime($bannedUser['end_date'])));
         }
         return $this->responseError($message, 403);
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:26,代码来源:Error.php

示例3: actionGetSubscriptions

 public function actionGetSubscriptions()
 {
     $page = max($this->_input->filterSingle('page', XenForo_Input::UINT), 1);
     $perpage = $this->_input->filterSingle('perpage', XenForo_Input::UINT);
     if (!$perpage) {
         $perpage = XenForo_Application::get('options')->discussionsPerPage;
     }
     $previewtype = $this->_input->filterSingle('previewtype', XenForo_Input::UINT);
     if (!$previewtype) {
         $previewtype = 2;
     }
     $visitor = XenForo_Visitor::getInstance();
     $watch_model = $this->_getThreadWatchModel();
     $threads = $watch_model->getThreadsWatchedByUser($visitor['user_id'], false, array('join' => XenForo_Model_Thread::FETCH_FORUM | XenForo_Model_Thread::FETCH_USER, 'readUserId' => $visitor['user_id'], 'page' => $page, 'perPage' => $perpage, 'postCountUserId' => $visitor['user_id'], 'permissionCombinationId' => $visitor['permission_combination_id']));
     $threads = $watch_model->unserializePermissionsInList($threads, 'node_permission_cache');
     $threads = $watch_model->getViewableThreadsFromList($threads);
     $threads = $this->_prepareWatchedThreads($threads);
     $total = $watch_model->countThreadsWatchedByUser($visitor['user_id']);
     $this->canonicalizePageNumber($page, $perpage, $total, 'watched/threads/all');
     $thread_data = array();
     $thread_model = $this->_getThreadModel();
     $post_model = $this->getModelFromCache('XenForo_Model_Post');
     $preview_length = XenForo_Application::get('options')->discussionPreviewLength;
     $formatter = XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_Text');
     $parser = new XenForo_BbCode_Parser($formatter);
     foreach ($threads as &$thread) {
         $out = array('thread_id' => $thread['thread_id'], 'forum_title' => prepare_utf8_string($thread['node_title']), 'new_posts' => $thread['isNew'], 'forum_id' => $thread['node_id'], 'total_posts' => $thread['reply_count'] + 1, 'thread_title' => prepare_utf8_string(strip_tags($thread['title'])), 'post_lastposttime' => prepare_utf8_string(XenForo_Locale::dateTime($thread['last_post_date'], 'absolute')));
         if ($previewtype == 1) {
             $out += array('post_username' => prepare_utf8_string(strip_tags($thread['username'])), 'post_userid' => $thread['user_id']);
         } else {
             $out += array('post_username' => prepare_utf8_string(strip_tags($thread['last_post_username'])), 'post_userid' => $thread['last_post_user_id']);
         }
         $post = $post_model->getPostById($thread[$previewtype == 1 ? 'first_post_id' : 'last_post_id'], array('join' => XenForo_Model_Post::FETCH_USER));
         $avatarurl = process_avatarurl(XenForo_Template_Helper_Core::getAvatarUrl($post, 'm'));
         if (strpos($avatarurl, '/xenforo/avatars/avatar_') !== false) {
             $avatarurl = '';
         }
         if ($avatarurl != '') {
             $out['avatarurl'] = $avatarurl;
         }
         $preview = '';
         if ($preview_length) {
             $preview = $parser->render($post['message']);
         }
         if ($preview != '') {
             $out['thread_preview'] = prepare_utf8_string(html_entity_decode($preview));
         }
         if ($thread['discussion_type'] == 'poll') {
             $out['poll'] = true;
         }
         $thread_data[] = $out;
     }
     $out = array('threads' => $thread_data, 'total_threads' => $total);
     return $out;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:55,代码来源:Subscriptions.php

示例4: 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();
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:47,代码来源:CleanUp.php

示例5: actionBanned

 public function actionBanned()
 {
     $bannedUser = $this->getModelFromCache('XenForo_Model_Banning')->getBannedUserById(XenForo_Visitor::getUserId());
     if (!$bannedUser) {
         return $this->responseNoPermission();
     } else {
         // TODO: better display/message for banned user
         if ($bannedUser['user_reason']) {
             $message = new XenForo_Phrase('you_have_been_banned_for_following_reason_x', array('reason' => $bannedUser['user_reason']));
         } else {
             $message = new XenForo_Phrase('you_have_been_banned');
         }
         if ($bannedUser['end_date'] > XenForo_Application::$time) {
             $message .= ' ' . new XenForo_Phrase('your_ban_will_be_lifted_on_x', array('date' => XenForo_Locale::dateTime($bannedUser['end_date'])));
         }
         return $this->responseError($message, 403);
     }
 }
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:18,代码来源:Error.php

示例6: actionGetPost

    public function actionGetPost()
    {
        // Whole function is an ugly hack.  Revisit later.
        global $dependencies, $zresponse;
        $postid = $this->_input->filterSingle('postid', XenForo_Input::UINT);
        $type = $this->_input->filterSingle('type', XenForo_Input::STRING);
        $signature = $this->_input->filterSingle('signature', XenForo_Input::UINT);
        if (!$type || $type == '') {
            $type = 'html';
        }
        $user_model = $this->getModelFromCache('XenForo_Model_User');
        $session_model = $this->getModelFromCache('XenForo_Model_Session');
        $thread_model = $this->getModelFromCache('XenForo_Model_Thread');
        $forum_model = $this->getModelFromCache('XenForo_Model_Forum');
        $attachment_model = $this->getModelFromCache('XenForo_Model_Attachment');
        $helper = $this->getHelper('ForumThreadPost');
        try {
            list($post, $thread, $forum) = $helper->assertPostValidAndViewable($postid);
        } catch (Exception $e) {
            json_error($e->getControllerResponse()->errorText->render());
        }
        $post_model = $this->_getPostModel();
        $post = $post_model->getPostById($postid, array('join' => XenForo_Model_Post::FETCH_THREAD | XenForo_Model_Post::FETCH_FORUM | XenForo_Model_Post::FETCH_USER | XenForo_Model_Post::FETCH_USER_PROFILE));
        $user = $user_model->getUserById($post['user_id']);
        $online_info = $session_model->getSessionActivityRecords(array('user_id' => $post['user_id'], 'cutOff' => array('>', $session_model->getOnlineStatusTimeout())));
        $is_online = false;
        if (count($online_info) == 1) {
            $is_online = true;
        }
        $avatarurl = '';
        if ($user !== false) {
            $avatarurl = process_avatarurl(XenForo_Template_Helper_Core::getAvatarUrl($user, 'm'));
            if (strpos($avatarurl, '/xenforo/avatars/avatar_') !== false) {
                $avatarurl = '';
            }
        }
        $attachments = $attachment_model->getAttachmentsByContentId('post', $postid);
        $message = fr_strip_smilies($this, $post['message']);
        list($text, $nuked_quotes, $images) = parse_post($message, true, array());
        $image = '';
        if ($type == 'html') {
            $css = <<<EOF
<style type="text/css">
body {
  margin: 0;
  padding: 3;
  font: 13px Arial, Helvetica, sans-serif;
}
.alt2 {
  background-color: #e6edf5;
  font: 13px Arial, Helvetica, sans-serif;
}
html {
    -webkit-text-size-adjust: none;
}
</style>
EOF;
            $formatter = XenForo_BbCode_Formatter_Base::create('ForumRunner_BbCode_Formatter_BbCode_Post', array('smilies' => XenForo_Application::get('smilies')));
            $parser = new XenForo_BbCode_Parser($formatter);
            $html = $css . $parser->render($message);
            if ($signature && $post['signature']) {
                $html .= '<div style="border-top: 1px dashed grey; font-size: 9pt; margin-top: 5px; padding: 5px 0 0;">' . $parser->render(fr_strip_smilies($this, $post['signature'])) . '</div>';
            }
        } else {
            if ($type == 'facebook') {
                $html = XenForo_Helper_String::censorString(XenForo_Helper_String::bbCodeStrip($message, true));
                if (count($attachments)) {
                    $attachments = array_values($attachments);
                    $link = XenForo_Link::buildPublicLink('attachments', $attachments[0]);
                    $image = fr_get_xenforo_bburl() . '/' . $link;
                }
            }
        }
        $post_page = floor($post['position'] / XenForo_Application::get('options')->messagesPerPage) + 1;
        $out = array('post_id' => $post['post_id'], 'thread_id' => $post['thread_id'], 'forum_id' => $post['node_id'], 'forum_title' => prepare_utf8_string(strip_tags($post['node_title'])), 'username' => prepare_utf8_string(strip_tags($post['username'])), 'joindate' => prepare_utf8_string(XenForo_Locale::date($post['register_date'], 'absolute')), 'usertitle' => XenForo_Template_Helper_Core::helperUserTitle($user), 'numposts' => $user ? $user['message_count'] : 0, 'userid' => $post['user_id'], 'title' => prepare_utf8_string($post['title']), 'online' => $is_online, 'post_timestamp' => prepare_utf8_string(XenForo_Locale::dateTime($post['post_date'], 'absolute')), 'html' => prepare_utf8_string($html), 'quotable' => $nuked_quotes, 'canpost' => $thread_model->canReplyToThread($thread, $forum), 'canattach' => $forum_model->canUploadAndManageAttachment($forum), 'post_link' => fr_get_xenforo_bburl() . '/' . XenForo_Link::buildPublicLink('threads', $thread, array('page' => $post_page)) . '#post-' . $post['post_id']);
        if ($image != '') {
            $out['image'] = $image;
        }
        if ($avatarurl != '') {
            $out['avatarurl'] = $avatarurl;
        }
        return $out;
    }
开发者ID:Sywooch,项目名称:forums,代码行数:83,代码来源:Post.php

示例7: getFeedData

 /**
  * Fetch the latest data for a feed from its specified URL.
  * Individual entries are returned in the 'entries' key of the return array.
  *
  * @param string $url
  * @param Exception|null $e Exception that occurs when reading feed
  *
  * @return array
  */
 public function getFeedData($url, Exception &$e = null)
 {
     try {
         $feed = Zend_Feed_Reader::import($url);
     } catch (Exception $feedEx) {
         $e = $feedEx;
         return array();
     }
     $data = array('id' => $feed->getId(), 'title' => $feed->getTitle(), 'link' => $feed->getLink(), 'date_modified' => $feed->getDateModified(), 'description' => $feed->getDescription(), 'language' => $feed->getLanguage(), 'image' => $feed->getImage(), 'generator' => $feed->getGenerator(), 'entries' => array());
     foreach ($feed as $entry) {
         /** @var $entry Zend_Feed_Reader_EntryInterface */
         $entryData = array('id' => $entry->getId(), 'title' => html_entity_decode($entry->getTitle(), ENT_COMPAT, 'utf-8'), 'description' => html_entity_decode($entry->getDescription(), ENT_COMPAT, 'utf-8'), 'date_modified' => null, 'authors' => $entry->getAuthors(), 'link' => $entry->getLink(), 'content_html' => $entry->getContent());
         $enclosure = $entry->getEnclosure();
         if ($enclosure) {
             $entryData['enclosure_url'] = $enclosure->url;
             $entryData['enclosure_length'] = $enclosure->length;
             $entryData['enclosure_type'] = $enclosure->type;
         }
         if (utf8_strlen($entryData['id']) > 250) {
             $entryData['id'] = md5($entryData['id']);
         }
         try {
             $entryData['date_modified'] = $entry->getDateModified();
         } catch (Zend_Exception $e) {
         }
         // triggered with invalid date format
         if (!empty($entryData['date_modified']) && $entryData['date_modified'] instanceof Zend_Date) {
             $entryData['date_modified'] = $entryData['date_modified']->getTimeStamp();
         } else {
             $entryData['date_modified'] = XenForo_Application::$time;
         }
         $entryData['date_modified'] = XenForo_Locale::dateTime($entryData['date_modified'], 'absolute');
         $data['entries'][] = $entryData;
     }
     $data = XenForo_Input::cleanStringArray($data);
     return $data;
 }
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:46,代码来源:Feed.php

示例8: 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();
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:65,代码来源:CleanUp.php

示例9: dateTimeHtml

 /**
  * Returns an <abbr> tag with a date suitable for Javascript refreshing
  *
  * @param integer $timestamp
  * @param array $attributes
  *
  * @return string <abbr class="DateTime" data-unixtime="$timestamp"...
  */
 public static function dateTimeHtml($timestamp, $attributes = array())
 {
     $class = empty($attributes['class']) ? '' : ' ' . htmlspecialchars($attributes['class']);
     unset($attributes['time'], $attributes['class']);
     $attribs = self::getAttributes($attributes);
     $time = XenForo_Locale::dateTime($timestamp, 'separate', self::$_language);
     if ($time['relative']) {
         $tag = 'abbr';
         $data = ' data-time="' . $timestamp . '" data-diff="' . (XenForo_Application::$time - $timestamp) . '" data-datestring="' . $time['date'] . '" data-timestring="' . $time['time'] . '"';
         $value = $time['string'];
     } else {
         $tag = 'span';
         $data = ' title="' . $time['string'] . '"';
         // empty this to remove tooltip from non-relative dates
         $value = $time['date'];
     }
     return "<{$tag} class=\"DateTime{$class}\"{$attribs}{$data}>{$value}</{$tag}>";
 }
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:26,代码来源:Core.php

示例10: actionFindNew

 public function actionFindNew()
 {
     $do = $this->_input->filterSingle('do', XenForo_Input::STRING);
     $days = $this->_input->filterSingle('days', XenForo_Input::UINT);
     $page = max($this->_input->filterSingle('page', XenForo_Input::UINT), 1);
     $perpage = $this->_input->filterSingle('perpage', XenForo_Input::UINT);
     if (!$perpage) {
         $perpage = XenForo_Application::get('options')->discussionsPerPage;
     }
     $previewtype = $this->_input->filterSingle('previewtype', XenForo_Input::UINT);
     if (!$previewtype) {
         $previewtype = 2;
     }
     $thread_model = $this->_getThreadModel();
     $search_model = $this->_getSearchModel();
     $post_model = $this->getModelFromCache('XenForo_Model_Post');
     $user_model = $this->getModelFromCache('XenForo_Model_User');
     $node_model = $this->getModelFromCache('XenForo_Model_Node');
     $userid = XenForo_Visitor::getUserId();
     $options = array('limit' => XenForo_Application::get('options')->maximumSearchResults);
     if ($do == 'getdaily') {
         if ($days < 0 || $days > 30) {
             $days = 3;
         }
         $search_options = $options + array('order' => 'last_post_date', 'orderDirection' => 'desc');
         $threadids = array_keys($thread_model->getThreads(array('last_post_date' => array('>', XenForo_Application::$time - 86400 * $days), 'deleted' => false, 'moderated' => false), $search_options));
         $search_type = 'recent-threads';
     } else {
         $threadids = $thread_model->getUnreadThreadIds($userid, $options);
         $search_type = 'new-threads';
     }
     $exclude = XenForo_Application::get('options')->forumrunnerExcludeForums;
     if (!$exclude) {
         $exclude = array();
     }
     $forums = $node_model->getViewableNodeList(null, true);
     foreach ($exclude as $remove) {
         fr_remove_node_and_children($forums, $remove);
     }
     $forums = array_keys($forums);
     $results = array();
     foreach ($threadids as $threadid) {
         $thread = $thread_model->getThreadById($threadid);
         if (!in_array($thread['node_id'], $forums)) {
             continue;
         }
         $results[] = array(XenForo_Model_Search::CONTENT_TYPE => 'thread', XenForo_Model_Search::CONTENT_ID => $threadid);
     }
     $results = $search_model->getViewableSearchResults($results);
     if (!$results) {
         return $this->noResults();
     }
     $search = $search_model->insertSearch($results, $search_type, '', array(), 'date', false);
     $search_id = $search['search_id'];
     $resultids = $search_model->sliceSearchResultsToPage($search, $page, $perpage);
     $results = $search_model->getSearchResultsForDisplay($resultids);
     if (!$results) {
         return $this->noResults();
     }
     $thread_data = array();
     $preview_length = XenForo_Application::get('options')->discussionPreviewLength;
     foreach ($results['results'] as $result) {
         $thread = $result['content'];
         $post = $post_model->getPostById($thread[$previewtype == 1 ? 'first_post_id' : 'last_post_id'], array('join' => XenForo_Model_Post::FETCH_USER));
         $preview = '';
         if ($preview_length) {
             $preview = preview_chop(XenForo_Helper_String::bbCodeStrip(XenForo_Helper_String::censorString($post['message']), true), $preview_length);
         }
         $out = array('thread_id' => $thread['thread_id'], 'new_posts' => $thread['isNew'], 'forum_id' => $thread['node_id'], 'total_posts' => $thread['reply_count'] + 1, 'forum_title' => prepare_utf8_string(strip_tags($thread['node_title'])), 'thread_title' => prepare_utf8_string(XenForo_Helper_String::censorString($thread['title'])), 'post_lastposttime' => prepare_utf8_string(XenForo_Locale::dateTime($thread['last_post_date'], 'absolute')));
         if ($previewtype == 1) {
             $out['post_username'] = prepare_utf8_string(strip_tags($thread['username']));
             $out['post_userid'] = $thread['user_id'];
         } else {
             $out['post_username'] = prepare_utf8_string(strip_tags($thread['last_post_username']));
             $out['post_userid'] = $thread['last_post_user_id'];
         }
         $user = $user_model->getUserById($out['post_userid']);
         if ($user !== false) {
             $avatarurl = process_avatarurl(XenForo_Template_Helper_Core::getAvatarUrl($user, 'm'));
             if (strpos($avatarurl, '/xenforo/avatars/avatar_') !== false) {
                 $avatarurl = '';
             }
             if ($avatarurl != '') {
                 $out['avatarurl'] = $avatarurl;
             }
         }
         if ($preview != '') {
             $out['thread_preview'] = prepare_utf8_string(html_entity_decode($preview));
         }
         if ($thread['discussion_type'] == 'poll') {
             $out['poll'] = true;
         }
         if ($thread['prefix_id']) {
             $phrase = new XenForo_Phrase('thread_prefix_' . $thread['prefix_id']);
             $out['prefix'] = prepare_utf8_string(strip_tags($phrase->render(false)));
         }
         $thread_data[] = $out;
     }
     $out = array('threads' => $thread_data, 'total_threads' => $search['result_count'], 'searchid' => $search_id);
     return $out;
//.........这里部分代码省略.........
开发者ID:Sywooch,项目名称:forums,代码行数:101,代码来源:FindNew.php

示例11: actionGetConversation

 public function actionGetConversation()
 {
     $conversationid = $this->_input->filterSingle('conversationid', XenForo_Input::UINT);
     $signature = $this->_input->filterSingle('signature', XenForo_Input::UINT);
     $page = max($this->_input->filterSingle('page', XenForo_Input::UINT), 1);
     $perpage = $this->_input->filterSingle('perpage', XenForo_Input::UINT);
     if (!$perpage) {
         $perpage = XenForo_Application::get('options')->messagesPerPage;
     }
     $conversation_model = $this->_getConversationModel();
     $session_model = $this->getModelFromCache('XenForo_Model_Session');
     try {
         $conversation_info = $this->_getConversationOrError($conversationid);
     } catch (Exception $e) {
         json_error($e->getControllerResponse()->errorText->render());
     }
     $gotomessageid = 0;
     if ($page == FR_LAST_POST) {
         if (!$conversation_info['last_read_date']) {
             $page = 1;
         } else {
             if ($conversation_info['last_read_date'] >= $conversation_info['last_message_date']) {
                 $first_unread = false;
             } else {
                 $first_unread = $conversation_model->getNextMessageInConversation($conversationid, $conversation_info['last_read_date']);
             }
             if (!$first_unread || $first_unread['message_id'] == $conversation_info['last_message_id']) {
                 $page = floor($conversation_info['reply_count'] / $perpage) + 1;
                 $gotomessageid = $conversation_info['last_message_id'];
             } else {
                 $before = $conversation_model->countMessagesBeforeDateInConversation($conversationid, $first_unread['message_date']);
                 $page = floor($before / $perpage) + 1;
                 $gotomessageid = $first_unread['message_id'];
             }
         }
     }
     $recipients = $conversation_model->getConversationRecipients($conversationid);
     $messages = $conversation_model->getConversationMessages($conversationid, array('page' => $page, 'perPage' => $perpage));
     $max = $conversation_model->getMaximumMessageDate($messages);
     if ($max > $conversation_info['last_read_date']) {
         $conversation_model->markConversationAsRead($conversationid, XenForo_Visitor::getUserId(), $max, $conversation_info['last_message_date']);
     }
     $messages = $conversation_model->prepareMessages($messages, $conversation_info);
     $user_model = $this->getModelFromCache('XenForo_Model_User');
     foreach ($messages as &$message) {
         $user = $user_model->getUserById($message['user_id']);
         $online_info = $session_model->getSessionActivityRecords(array('user_id' => $message['user_id'], 'cutOff' => array('>', $session_model->getOnlineStatusTimeout())));
         $is_online = false;
         if (count($online_info) == 1) {
             $is_online = true;
         }
         list($text, $nuked_quotes, $images) = parse_post(fr_strip_smilies($this, XenForo_Helper_String::censorString($message['message'])), true);
         $fr_images = array();
         foreach ($images as $image) {
             $fr_images[] = array('img' => $image);
         }
         $avatarurl = '';
         if ($user !== false) {
             $avatarurl = process_avatarurl(XenForo_Template_Helper_Core::getAvatarUrl($user, 'm'));
             if (strpos($avatarurl, '/xenforo/avatars/avatar_') !== false) {
                 $avatarurl = '';
             }
         }
         $out = array('post_id' => $message['message_id'], 'thread_id' => $message['conversation_id'], 'username' => prepare_utf8_string(strip_tags($message['username'])), 'joindate' => prepare_utf8_string(XenForo_Locale::date($message['register_date'], 'absolute')), 'usertitle' => XenForo_Template_Helper_Core::helperUserTitle($user), 'numposts' => $user ? $user['message_count'] : 0, 'userid' => $message['user_id'], 'online' => $is_online, 'post_timestamp' => prepare_utf8_string(XenForo_Locale::dateTime($message['message_date'], 'absolute')), 'fr_images' => $fr_images, 'text' => $text, 'quotable' => $nuked_quotes);
         if ($avatarurl != '') {
             $out['avatarurl'] = $avatarurl;
         }
         if ($signature) {
             $sig = trim(strip_tags(remove_bbcode($message['signature'], true, true), '<a>'));
             $sig = str_replace(array("\t", "\r"), array('', ''), $sig);
             $sig = str_replace("\n\n", "\n", $sig);
             $out['sig'] = prepare_utf8_string($sig);
         }
         $message_data[] = $out;
     }
     $out = array('posts' => $message_data, 'total_posts' => $conversation_info['reply_count'] + 1, 'page' => $page, 'canattach' => false, 'canpost' => true, 'title' => prepare_utf8_string(XenForo_Helper_String::censorString($conversation_info['title'])), 'thread_link' => process_avatarurl(XenForo_Link::buildPublicLink('conversations', $conversation_info)));
     if ($gotomessageid) {
         $out['gotopostid'] = $gotomessageid;
     }
     $r = array_values($conversation_model->getConversationRecipients($conversationid));
     $recipients = '';
     for ($i = 0; $i < count($r); $i++) {
         if ($i != 0) {
             $recipients .= ', ';
         }
         $recipients .= prepare_utf8_string(strip_tags($r[$i]['username']));
     }
     $out['recipients'] = $recipients;
     return $out;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:90,代码来源:Conversation.php

示例12: processSearch

 private function processSearch(&$search)
 {
     $vals = $this->_input->filter(array('page' => XenForo_Input::UINT, 'perpage' => XenForo_Input::UINT, 'previewtype' => XenForo_Input::UINT, 'starteronly' => XenForo_Input::UINT));
     $vals['page'] = max($vals['page'], 1);
     $vals['perpage'] = min(XenForo_Application::get('options')->discussionsPerPage, $vals['perpage']);
     if (!$vals['perpage']) {
         $vals['perpage'] = XenForo_Application::get('options')->discussionsPerPage;
     }
     if (!$vals['previewtype']) {
         $vals['previewtype'] = 2;
     }
     if ($vals['starteronly']) {
         $vals['previewtype'] = 1;
     }
     $search_model = $this->_getSearchModel();
     $search_id = $search['search_id'];
     $resultids = $search_model->sliceSearchResultsToPage($search, $vals['page'], $vals['perpage']);
     $results = $search_model->getSearchResultsForDisplay($resultids);
     if (!$results) {
         return $this->sendError(new XenForo_Phrase('no_results_found'));
     }
     $post_model = $this->getModelFromCache('XenForo_Model_Post');
     $user_model = $this->getModelFromCache('XenForo_Model_User');
     $thread_data = array();
     $preview_length = XenForo_Application::get('options')->discussionPreviewLength;
     foreach ($results['results'] as $result) {
         $thread = $result['content'];
         $is_post = $result['content_type'] == 'post';
         if ($is_post) {
             $post = $post_model->getPostById($thread['post_id'], array('join' => XenForo_Model_Post::FETCH_USER));
         } else {
             $post = $post_model->getPostById($thread[$vals['previewtype'] == 1 ? 'first_post_id' : 'last_post_id'], array('join' => XenForo_Model_Post::FETCH_USER));
         }
         $preview = '';
         if ($preview_length) {
             $preview = preview_chop(XenForo_Helper_String::bbCodeStrip(XenForo_Helper_String::censorString($thread['message']), true), $preview_length);
         }
         $out = array('thread_id' => $thread['thread_id'], 'new_posts' => $thread['isNew'], 'forum_id' => $thread['node_id'], 'total_posts' => $thread['reply_count'] + 1, 'forum_title' => prepare_utf8_string(strip_tags($thread['node_title'])), 'thread_title' => prepare_utf8_string(XenForo_Helper_String::censorString($thread['title'])));
         if ($is_post) {
             $out += array('post_id' => $thread['post_id'], 'jump_to_post' => 1, 'post_username' => prepare_utf8_string(strip_tags($thread['username'])), 'post_userid' => $thread['user_id'], 'post_lastposttime' => prepare_utf8_string(XenForo_Locale::dateTime($thread['post_date'], 'absolute')));
         } else {
             if ($vals['previewtype'] == 1) {
                 $out += array('post_username' => prepare_utf8_string(strip_tags($thread['username'])), 'post_userid' => $thread['user_id']);
             } else {
                 $out += array('post_username' => prepare_utf8_string(strip_tags($thread['last_post_username'])), 'post_userid' => $thread['last_post_user_id']);
             }
             $out['post_lastposttime'] = prepare_utf8_string(XenForo_Locale::dateTime($thread['last_post_date'], 'absolute'));
         }
         $user = $user_model->getUserById($out['post_userid']);
         if ($user !== false) {
             $avatarurl = process_avatarurl(XenForo_Template_Helper_Core::getAvatarUrl($user, 'm'));
             if (strpos($avatarurl, '/xenforo/avatars/avatar_') !== false) {
                 $avatarurl = '';
             }
             if ($avatarurl != '') {
                 $out['avatarurl'] = $avatarurl;
             }
         }
         if ($preview != '') {
             $out['thread_preview'] = prepare_utf8_string(html_entity_decode($preview));
         }
         if ($thread['discussion_type'] == 'poll') {
             $out['poll'] = true;
         }
         if ($thread['prefix_id']) {
             $phrase = new XenForo_Phrase('thread_prefix_' . $thread['prefix_id']);
             $out['prefix'] = prepare_utf8_string(strip_tags($phrase->render(false)));
         }
         $thread_data[] = $out;
     }
     $out = array('threads' => $thread_data, 'total_threads' => $search['result_count'], 'searchid' => $search_id);
     return $out;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:73,代码来源:Search.php

示例13: _prepareFieldsForTemplate

 protected function _prepareFieldsForTemplate($fields)
 {
     $templateFields = array();
     foreach ($fields as $fieldId => $field) {
         if ($field['active']) {
             if ($field['field_type'] == 'checkbox' || $field['field_type'] == 'select' || $field['field_type'] == 'multiselect' || $field['field_type'] == 'radio' || $field['field_type'] == 'rating') {
                 if (!is_array($field['field_choices'])) {
                     $choices = unserialize($field['field_choices']);
                 }
                 if (is_array($field['field_value'])) {
                     $text = '';
                     foreach ($field['field_value'] as $choiceId) {
                         $text .= ', ' . $choices[$choiceId];
                     }
                     $templateFields[$field['field_name']]['value'] = substr($text, 2);
                 } else {
                     if ($field['field_type'] == 'rating' && $field['field_value'] != '') {
                         $templateFields[$field['field_name']]['value'] = $field['field_value'] . new XenForo_Phrase('lpsf_rating_separator') . XenForo_Application::getOptions()->lpsfRatingMax;
                     } else {
                         if (isset($choices[$field['field_value']])) {
                             $templateFields[$field['field_name']]['value'] = $choices[$field['field_value']];
                         } else {
                             $templateFields[$field['field_name']]['value'] = '';
                         }
                     }
                 }
             } else {
                 $templateFields[$field['field_name']]['value'] = htmlspecialchars_decode($field['field_value']);
                 if (($field['field_type'] == 'date' || $field['field_type'] == 'datetime') && $field['field_value'] != '') {
                     $dateTime = new DateTime($field['field_value'], XenForo_Locale::getDefaultTimeZone());
                 }
                 if ($field['field_type'] == 'date' && isset($dateTime)) {
                     $templateFields[$field['field_name']]['value'] = XenForo_Locale::date($dateTime, 'absolute');
                 }
                 if ($field['field_type'] == 'datetime' && isset($dateTime)) {
                     $templateFields[$field['field_name']]['value'] = XenForo_Locale::dateTime($dateTime, 'absolute');
                 }
             }
             $templateFields[$field['field_name']]['field_type'] = $field['field_type'];
             $templateFields[$field['field_name']]['title'] = $field['title']->render();
         }
     }
     return $templateFields;
 }
开发者ID:Mirovinger,项目名称:xenforo-simple-forms,代码行数:44,代码来源:Abstract.php

示例14: processThreads

 private function processThreads(&$threads, $previewtype)
 {
     $thread_data = array();
     $thread_model = $this->_getThreadModel();
     $post_model = $this->getModelFromCache('XenForo_Model_Post');
     $preview_length = XenForo_Application::get('options')->discussionPreviewLength;
     foreach ($threads as &$thread) {
         // For each thread, get the first post/last post information as requested by user
         if ($thread_model->isRedirect($thread)) {
             // Redirect thread XXX RKJ
             continue;
         }
         $out = array('thread_id' => $thread['thread_id'], 'new_posts' => $thread['isNew'], 'forum_id' => $thread['node_id'], 'total_posts' => $thread['reply_count'] + 1, 'thread_title' => prepare_utf8_string(strip_tags($thread['title'])), 'post_lastposttime' => prepare_utf8_string(XenForo_Locale::dateTime($thread['last_post_date'])));
         if ($previewtype == 1) {
             $out += array('post_username' => prepare_utf8_string(strip_tags($thread['username'])), 'post_userid' => $thread['user_id']);
         } else {
             $out += array('post_username' => prepare_utf8_string(strip_tags($thread['last_post_username'])), 'post_userid' => $thread['last_post_user_id']);
         }
         $post = $post_model->getPostById($thread[$previewtype == 1 ? 'first_post_id' : 'last_post_id'], array('join' => XenForo_Model_Post::FETCH_USER));
         $avatarurl = process_avatarurl(XenForo_Template_Helper_Core::getAvatarUrl($post, 'm'));
         if (strpos($avatarurl, '/xenforo/avatars/avatar_') !== false) {
             $avatarurl = '';
         }
         if ($avatarurl != '') {
             $out['avatarurl'] = $avatarurl;
         }
         $preview = '';
         if ($preview_length) {
             $preview = preview_chop(XenForo_Helper_String::bbCodeStrip($post['message'], true), $preview_length);
         }
         if ($preview != '') {
             $out['thread_preview'] = prepare_utf8_string(html_entity_decode($preview));
         }
         if ($thread['discussion_type'] == 'poll') {
             $out['poll'] = true;
         }
         if ($thread['prefix_id'] && isset($this->_prefixes[$thread['prefix_id']])) {
             $out['prefix'] = prepare_utf8_string(strip_tags($this->_prefixes[$thread['prefix_id']]));
         }
         $thread_data[] = $out;
     }
     return $thread_data;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:43,代码来源:Forum.php

示例15: actionGetThread


//.........这里部分代码省略.........
                 $ext = strtolower($attachment['extension']);
                 $link = XenForo_Link::buildPublicLink('attachments', $attachment);
                 if ($ext == 'jpe' || $ext == 'jpeg' || $ext == 'png' || $ext == 'gif' || $ext == 'jpg') {
                     $data = array('img' => fr_get_xenforo_bburl() . '/' . $link);
                     if ($attachment['thumbnailUrl']) {
                         $data['tmb'] = fr_get_xenforo_bburl() . '/' . $attachment['thumbnailUrl'];
                     }
                     $fr_images[] = $data;
                 } else {
                     if ($ext == 'pdf') {
                         $docattach[] = fr_get_xenforo_bburl() . '/' . $link;
                     }
                 }
             }
         }
         list($text, $nuked_quotes, $images) = parse_post(fr_strip_smilies($this, XenForo_Helper_String::censorString($post['message'])), true);
         if (count($fr_images) > 0) {
             $text .= "<br/>";
             foreach ($fr_images as $attachment) {
                 $text .= "<img src=\"{$attachment['img']}\"/>";
             }
         }
         foreach ($images as $image) {
             $fr_images[] = array('img' => $image);
         }
         $avatarurl = '';
         if ($user !== false) {
             $avatarurl = process_avatarurl(XenForo_Template_Helper_Core::getAvatarUrl($user, 'm'));
             if (strpos($avatarurl, '/xenforo/avatars/avatar_') !== false) {
                 $avatarurl = '';
             }
         }
         $post_page = floor($post['position'] / XenForo_Application::get('options')->messagesPerPage) + 1;
         $out = array('post_id' => $post['post_id'], 'thread_id' => $post['thread_id'], 'forum_id' => $post['node_id'], 'forum_title' => prepare_utf8_string(strip_tags($post['node_title'])), 'username' => prepare_utf8_string(strip_tags($post['username'])), 'joindate' => prepare_utf8_string(XenForo_Locale::date($post['register_date'], 'absolute')), 'usertitle' => strip_tags(XenForo_Template_Helper_Core::helperUserTitle($user)), 'numposts' => $user ? $user['message_count'] : 0, 'userid' => $post['user_id'], 'canlike' => $post['canLike'] ? true : false, 'likes' => $post['like_date'] > 0 ? true : false, 'title' => prepare_utf8_string(XenForo_Helper_String::censorString($post['title'])), 'online' => $is_online, 'post_timestamp' => prepare_utf8_string(XenForo_Locale::dateTime($post['post_date'], 'absolute')), 'post_link' => fr_get_xenforo_bburl() . '/' . XenForo_Link::buildPublicLink('threads', $thread_info, array('page' => $post_page)) . '#post-' . $post['post_id'], 'fr_images' => $fr_images);
         if ($post['canDelete']) {
             $out['candelete'] = true;
         }
         if ($post['likes']) {
             $out['likestext'] = prepare_utf8_string($post_helper->likesHtml($post['post_id'], $post['likes'], $post['like_date'], $post['likeUsers']));
             $like_users = '';
             for ($i = 0; $i < count($post['likeUsers']); $i++) {
                 if ($i != 0) {
                     $like_users .= ', ';
                 }
                 $like_users .= $post['likeUsers'][$i]['username'];
             }
             $out['likesusers'] = prepare_utf8_string($like_users);
         }
         if ($avatarurl != '') {
             $out['avatarurl'] = $avatarurl;
         }
         if ($post['message_state'] == 'deleted') {
             $out += array('deleted' => true, 'del_username' => prepare_utf8_string(strip_tags($post['delete_username'])));
             if ($post['delete_reason']) {
                 $out['del_reason'] = prepare_utf8_string($post['delete_reason']);
             }
         } else {
             if ($post['canEdit']) {
                 $out += array('canedit' => $post['canEdit']);
             }
             $out += array('text' => $text, 'quotable' => $nuked_quotes, 'edittext' => prepare_utf8_string($post['message']));
         }
         if (count($docattach)) {
             $out['docattach'] = $docattach;
         }
         if ($signature) {
开发者ID:Sywooch,项目名称:forums,代码行数:67,代码来源:Thread.php


注:本文中的XenForo_Locale::dateTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。