コード例 #1
0
ファイル: Thread.php プロジェクト: lazyllama/thread-rotate
 public function actionRotate()
 {
     $threadId = $this->_input->filterSingle('thread_id', XenForo_Input::UINT);
     $newTitle = $this->_input->filterSingle('newTitle', XenForo_Input::STRING);
     $ftpHelper = $this->getHelper('ForumThreadPost');
     list($thread, $forum) = $ftpHelper->assertThreadValidAndViewable($threadId);
     $threadModel = $this->_getThreadModel();
     if (!XenForo_Visitor::getInstance()->hasPermission('forum', 'manageAnyThread')) {
         throw $this->getErrorOrNoPermissionResponseException(false);
     }
     $viewingUser = XenForo_Visitor::getInstance();
     if ($this->isConfirmedPost()) {
         /* Let's create the DataWriter associated on Threads */
         $threadWriter = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread', XenForo_DataWriter::ERROR_SILENT);
         $threadWriter->setExtraData(XenForo_DataWriter_Discussion_Thread::DATA_FORUM, $forum);
         $threadWriter->setOption(XenForo_DataWriter_Discussion::OPTION_TRIM_TITLE, true);
         $threadWriter->bulkSet(array('title' => $newTitle, 'user_id' => $viewingUser['user_id'], 'username' => $viewingUser['username'], 'sticky' => $thread['sticky'], 'discussion_open' => $thread['discussion_open'], 'discussion_state' => $thread['discussion_state'], 'prefix_id' => $thread['prefix_id'], 'node_id' => $thread['node_id']));
         $originalUser = $this->getModelFromCache('XenForo_Model_User')->getUserById($thread['user_id']);
         $params['title'] = $thread['title'];
         $params['username'] = $thread['username'];
         $params['userLink'] = XenForo_Link::buildPublicLink('canonical:members', $originalUser);
         $params['link'] = XenForo_Link::buildPublicLink('full:threads', $thread);
         $message = new XenForo_Phrase('llama_rt_new_rotated_thread_message', $params, false);
         $postWriter = $threadWriter->getFirstMessageDw();
         $postWriter->set('message', $message->render());
         $postWriter->setExtraData(XenForo_DataWriter_DiscussionMessage_Post::DATA_FORUM, $forum);
         /* Save all changes and we are done with new thread! */
         $result = $threadWriter->save();
         $newThreadId = $threadWriter->get('thread_id');
         list($newThread, $newForum) = $ftpHelper->assertThreadValidAndViewable($newThreadId);
         /* Add new post at end of old thread */
         $params['title'] = $newTitle;
         $params['link'] = XenForo_Link::buildPublicLink('full:threads', $newThread);
         $message = new XenForo_Phrase('llama_rt_old_rotated_thread_message', $params, false);
         $postWriter = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post');
         $postWriter->set('user_id', $viewingUser['user_id']);
         $postWriter->set('username', $viewingUser['username']);
         $postWriter->set('message', $message->render());
         $postWriter->set('message_state', $this->_getPostModel()->getPostInsertMessageState($thread, $forum));
         $postWriter->set('thread_id', $threadId);
         $postWriter->setExtraData(XenForo_DataWriter_DiscussionMessage_Post::DATA_FORUM, $forum);
         $postWriter->save();
         /* Close and unstick original thread */
         $dwInput = array('discussion_open' => FALSE, 'sticky' => FALSE);
         $threadWriter = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
         $threadWriter->setExistingData($threadId);
         $threadWriter->bulkSet($dwInput);
         $threadWriter->setExtraData(XenForo_DataWriter_Discussion_Thread::DATA_FORUM, $forum);
         $threadWriter->save();
         XenForo_Model_Log::logModeratorAction('thread', $thread, 'rotate', array('new_title' => $newTitle));
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('full:threads', $newThread));
     } else {
         // Guess the new title
         $newTitleGuess = preg_replace_callback("#(\\d+)\$#", function ($m) {
             return ++$m[1];
         }, $thread['title']);
         $viewParams = array('newTitleGuess' => $newTitleGuess, 'thread' => $thread);
         return $this->responseView('Llama_ViewPublic_Thread_Rotate', 'llama_thread_rotate', $viewParams);
     }
 }
コード例 #2
0
ファイル: Photo.php プロジェクト: Sywooch/forums
 public function actionMeta()
 {
     list($content, $album) = $this->_getPhotoOrError();
     if (empty($content['photo_exif'])) {
         return $this->responseMessage(new XenForo_Phrase('sonnb_xengallery_this_photo_does_not_contain_any_exif_information'));
     }
     if (!empty($content['photo_exif']['ExposureProgram']) && is_int($content['photo_exif']['ExposureProgram']) && $content['photo_exif']['ExposureProgram'] > 0) {
         $phrase = @sonnb_XenGallery_Model_Photo::$exifExposureProgram[$content['photo_exif']['ExposureProgram']];
         if ($phrase) {
             $phrase = new XenForo_Phrase($phrase);
             $content['photo_exif']['ExposureProgram'] = $phrase->render();
         }
     }
     if (!empty($content['photo_exif']['ExposureTime'])) {
         $content['photo_exif']['ExposureTime'] .= ' (' . $content['photo_exif']['ExposureTimeOrigin'] . ')';
     }
     if (isset($content['photo_exif']['Software'])) {
         $content['photo_exif']['Software'] = utf8_bad_replace($content['photo_exif']['Software'], '');
     }
     if (isset($content['photo_exif']['ImageDescription'])) {
         $content['photo_exif']['ImageDescription'] = utf8_bad_replace($content['photo_exif']['ImageDescription'], '');
     }
     if (isset($content['photo_exif']['Artist'])) {
         $content['photo_exif']['Artist'] = utf8_bad_replace($content['photo_exif']['Artist'], '');
     }
     if (isset($content['photo_exif']['Copyright'])) {
         $content['photo_exif']['Copyright'] = utf8_bad_replace($content['photo_exif']['Copyright'], '');
     }
     $viewParams = array('album' => $album, 'content' => $content, 'breadCrumbs' => $this->_getPhotoModel()->getContentBreadCrumbs($content, $album));
     return $this->responseView('sonnb_XenGallery_ViewPublic_Photo_Exif', 'sonnb_xengallery_photo_exif', $viewParams);
 }
コード例 #3
0
ファイル: Thread.php プロジェクト: namgiangle90/tokyobaito
 /**
  * Apply a thread prefix to the specified threads if permissions are sufficient.
  *
  * @param array $threadIds List of thread IDs to change
  * @param integer $prefixId ID of the thread prefix to apply
  * @param array $unchangedThreadIds Array of thread IDs that were not updated by this action
  * @param array $options Options that control the action. Nothing supported at this time.
  * @param string $errorKey Modified by reference. If no permission, may include a key of a phrase that gives more info
  * @param array|null $viewingUser
  *
  * @return boolean True if permissions were ok
  */
 public function applyThreadPrefix(array $threadIds, $prefixId, &$unchangedThreadIds = array(), array $options = array(), &$errorKey = '', array $viewingUser = null)
 {
     $prefixModel = $this->_getPrefixModel();
     $prefixPerms = array();
     if (!$this->canEditThreads($threadIds, $errorKey, $viewingUser)) {
         return false;
     }
     foreach ($threadIds as $threadId) {
         $dw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread', XenForo_DataWriter::ERROR_SILENT);
         if (!$dw->setExistingData($threadId)) {
             continue;
         }
         $thread = $dw->getMergedData();
         $nodeId = $dw->get('node_id');
         if (!isset($prefixPerms[$nodeId])) {
             $prefixPerms[$nodeId] = $prefixModel->verifyPrefixIsUsable($prefixId, $nodeId, $viewingUser);
         }
         if (!$prefixPerms[$nodeId]) {
             $unchangedThreadIds[] = $threadId;
             continue;
         }
         $dw->set('prefix_id', $prefixId);
         $dw->save();
         if ($thread['prefix_id'] != $prefixId) {
             if ($thread['prefix_id']) {
                 $phrase = new XenForo_Phrase('thread_prefix_' . $thread['prefix_id']);
                 $oldValue = $phrase->render();
             } else {
                 $oldValue = '-';
             }
             XenForo_Model_Log::logModeratorAction('thread', $thread, 'prefix', array('old' => $oldValue));
         }
     }
     return true;
 }
コード例 #4
0
ファイル: Verse.php プロジェクト: ThemeHouse-XF/Biblea
 public static function quoteVerse(array $tag, array $rendererStates, XenForo_BbCode_Formatter_Base $formatter)
 {
     $option = explode(',', $tag['option']);
     $xenOptions = XenForo_Application::get('options');
     $verse = '';
     $version = null;
     if (count($option) > 1) {
         $verse = $option[0];
         $version = strtoupper($option[1]);
     } elseif ($option[0]) {
         if (preg_match('#^[A-z]+$#', $tag['option'])) {
             $verse = '';
             $version = strtoupper($tag['option']);
         } else {
             $verse = $tag['option'];
             $version = strtoupper($xenOptions->th_bible_defaultBible);
         }
     }
     if (!$verse && count($tag['children']) == 1 && is_string($tag['children'][0])) {
         $bibleId = $version ? strtolower($version) : null;
         /* @var $verseModel ThemeHouse_Bible_Model_Verse */
         $verseModel = XenForo_Model::create('ThemeHouse_Bible_Model_Verse');
         $verseText = $verseModel->getVerseFromText($tag['children'][0], $bibleId, true);
         if ($verseText) {
             $verse = $tag['children'][0];
             $version = strtoupper($bibleId);
             $tag['children'] = $verseText;
         }
     }
     $link = '';
     $params = array('bible_id' => strtolower($version));
     if (in_array(strtolower($version), $xenOptions->th_bible_bbCodeBibles)) {
         if (preg_match('#^(.*)\\s+([0-9\\-:]+)$#', $verse, $matches)) {
             $urlPortion = strtolower(XenForo_Link::getTitleForUrl($matches[1], true));
             $link = XenForo_Link::buildPublicLink('bible/' . $urlPortion . '/' . $matches[2] . '/', null, $params);
             /* @var $bibleModel ThemeHouse_Bible_Model_Bible */
             $bibleModel = XenForo_Model::create('ThemeHouse_Bible_Model_Bible');
             $titlePhraseName = $bibleModel->getBibleTitlePhraseName(strtolower($version));
             $bibleTitle = new XenForo_Phrase($titlePhraseName);
             $bibleTitle->setPhraseNameOnInvalid(false);
             if ((string) $bibleTitle) {
                 $version = $bibleTitle;
             }
         } else {
             $urlPortion = strtolower(XenForo_Link::getTitleForUrl($verse, true));
             $link = XenForo_Link::buildPublicLink('bible/' . $urlPortion . '/', null, $params);
         }
     } else {
         $link = '';
     }
     $content = $formatter->renderSubTree($tag['children'], $rendererStates);
     $view = $formatter->getView();
     if ($view) {
         $template = $view->createTemplateObject('th_bb_code_verse_bible', array('content' => $content, 'verse' => $verse, 'version' => $version, 'link' => $link));
         $content = $template->render();
         return trim($content);
     }
     return $content;
 }
コード例 #5
0
ファイル: Report.php プロジェクト: ThemeHouse-XF/PostOnReport
 /**
  *
  * @see XenForo_Model_Report::reportContent()
  */
 public function reportContent($contentType, array $content, $message, array $viewingUser = null)
 {
     $reportForumId = XenForo_Application::getOptions()->th_postOnReport_reportIntoForumId;
     if (XenForo_Application::$versionId < 1020000) {
         $this->standardizeViewingUserReference($viewingUser);
         if (!$viewingUser['user_id']) {
             return false;
         }
         $handler = $this->getReportHandler($contentType);
         if (!$handler) {
             return false;
         }
         list($contentId, $contentUserId, $contentInfo) = $handler->getReportDetailsFromContent($content);
         if (!$contentId) {
             return false;
         }
         if ($reportForumId) {
             /**
              * @var $forumModel XenForo_Model_Forum
              */
             $forumModel = $this->getModelFromCache('XenForo_Model_Forum');
             $reportForum = $forumModel->getForumById($reportForumId);
             if ($reportForum) {
                 $report = array('content_type' => $contentType, 'content_id' => $contentId, 'content_user_id' => $contentUserId, 'content_info' => $contentInfo, 'first_report_date' => XenForo_Application::$time, 'report_state' => 'open', 'assigned_user_id' => 0, 'comment_count' => 0, 'report_count' => 0);
                 $params = $this->_getContentForThread($report, $contentInfo, $handler);
                 $user = $this->getModelFromCache('XenForo_Model_User')->getUserById($contentUserId);
                 if ($user) {
                     $params['username'] = $user['username'];
                 }
                 $params['userLink'] = XenForo_Link::buildPublicLink('canonical:members', $user);
                 $params['reporter'] = $viewingUser['username'];
                 $params['reporterLink'] = XenForo_Link::buildPublicLink('canonical:members', $viewingUser);
                 $params['reportReason'] = $message;
                 $threadTitle = new XenForo_Phrase('th_reported_thread_title_postonreport', $params, false);
                 /**
                  * @var $threadDw XenForo_DataWriter_Discussion_Thread
                  */
                 $threadDw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread', XenForo_DataWriter::ERROR_SILENT);
                 $threadDw->setExtraData(XenForo_DataWriter_Discussion_Thread::DATA_FORUM, $reportForum);
                 $threadDw->bulkSet(array('node_id' => $reportForum['node_id'], 'title' => $threadTitle->render(), 'user_id' => $viewingUser['user_id'], 'username' => $viewingUser['username']));
                 $threadDw->set('discussion_state', $this->getModelFromCache('XenForo_Model_Post')->getPostInsertMessageState(array(), $reportForum));
                 $message = new XenForo_Phrase('th_reported_thread_message_postonreport', $params, false);
                 $postWriter = $threadDw->getFirstMessageDw();
                 $postWriter->set('message', $message->render());
                 $postWriter->setExtraData(XenForo_DataWriter_DiscussionMessage_Post::DATA_FORUM, $reportForum);
                 $threadDw->save();
             }
         }
         return parent::reportContent($contentType, $content, $message, $viewingUser);
     }
     XenForo_Application::getOptions()->set('reportIntoForumId', $reportForumId);
     if (parent::reportContent($contentType, $content, $message, $viewingUser)) {
         XenForo_Application::getOptions()->set('reportIntoForumId', 0);
         return parent::reportContent($contentType, $content, $message, $viewingUser);
     }
 }
コード例 #6
0
ファイル: HtmlEmail.php プロジェクト: namgiangle90/tokyobaito
 public function renderTagMedia(array $tag, array $rendererStates)
 {
     $mediaSiteId = strtolower($tag['option']);
     if (isset($this->_mediaSites[$mediaSiteId])) {
         $phrase = new XenForo_Phrase('embedded_media');
         return '<table cellpadding="0" cellspacing="0" border="0" width="100%"' . ' style="background-color: #F0F7FC; border: 1px solid #A5CAE4; border-radius: 5px; margin: 5px 0; padding: 5px; font-size: 11px; text-align: center">' . '<tr><td>' . $phrase->render() . '</td></tr></table>';
     } else {
         return '';
     }
 }
コード例 #7
0
ファイル: Resource.php プロジェクト: darkearl/projectT122015
 /**
  * Gets the HTML value of the resource field.
  *
  * @param array $field
  * @param mixed $value Value of the field; if null, pulls from field_value
  *        in field
  */
 public static function getResourceFieldValueHtml(XenForo_View $view, array $field, $value = null)
 {
     if ($value === null && isset($field['field_value'])) {
         $value = $field['field_value'];
     }
     if ($value === '' || $value === null) {
         return '';
     }
     $multiChoice = false;
     $choice = '';
     switch ($field['field_type']) {
         case 'radio':
         case 'select':
             $choice = $value;
             $value = new XenForo_Phrase("resource_field_{$field['field_id']}_choice_{$value}");
             $value->setPhraseNameOnInvalid(false);
             break;
         case 'checkbox':
         case 'multiselect':
             $multiChoice = true;
             if (!is_array($value) || count($value) == 0) {
                 return '';
             }
             $newValues = array();
             foreach ($value as $id => $choice) {
                 $phrase = new XenForo_Phrase("resource_field_{$field['field_id']}_choice_{$choice}");
                 $phrase->setPhraseNameOnInvalid(false);
                 $newValues[$choice] = $phrase;
             }
             $value = $newValues;
             break;
         case 'textbox':
         case 'textarea':
         default:
             $value = nl2br(htmlspecialchars(XenForo_Helper_String::censorString($value)));
     }
     if (!empty($field['display_callback_class']) && !empty($field['display_callback_method'])) {
         $value = call_user_func_array(array($field['display_callback_class'], $field['display_callback_method']), array($view, $field, $value));
     } elseif (!empty($field['display_template'])) {
         if ($multiChoice && is_array($value)) {
             foreach ($value as $choice => &$thisValue) {
                 $thisValue = strtr($field['display_template'], array('{$fieldId}' => $field['field_id'], '{$value}' => $thisValue, '{$valueUrl}' => urlencode($thisValue), '{$choice}' => $choice));
             }
         } else {
             $value = strtr($field['display_template'], array('{$fieldId}' => $field['field_id'], '{$value}' => $value, '{$valueUrl}' => urlencode($value), '{$choice}' => $choice));
         }
     }
     return $value;
 }
コード例 #8
0
ファイル: Error.php プロジェクト: hahuunguyen/DTUI_201105
 protected static function _getPhrasedTextIfPossible($fallbackText, $phraseName, array $params = array())
 {
     $output = false;
     ini_set('display_errors', true);
     if (XenForo_Application::isRegistered('db') && XenForo_Application::get('db')->isConnected()) {
         try {
             $phrase = new XenForo_Phrase($phraseName, $params);
             $output = $phrase->render();
         } catch (Exception $e) {
         }
     }
     if ($output === false) {
         $output = $fallbackText;
     }
     return $output;
 }
コード例 #9
0
ファイル: List.php プロジェクト: VoDongMy/xenforo-laravel5.1
 public function renderJson()
 {
     $options = XenForo_Application::get('options');
     $maxid = Dark_TaigaChat_Helper_Global::processMessagesForView($this->_params, $this);
     $template = $this->createTemplateObject($this->_templateName, $this->_params);
     $template->setParams($this->_params);
     if (!empty($this->_params['taigachat']['publichtml'])) {
         $template->setLanguageId(XenForo_Phrase::getLanguageId());
         $template->setStyleId($options->defaultStyleId);
     }
     $rendered = $template->render();
     $rendered = preg_replace('/\\s+<\\/(.*?)>\\s+</si', ' </$1> <', $rendered);
     $rendered = preg_replace('/\\s+<(.*?)([ >])/si', ' <$1$2', $rendered);
     $params = array("templateHtml" => $rendered, "reverse" => $options->dark_taigachat_direction, "lastrefresh" => $maxid, "motd" => $this->_params['taigachat']['motd'], "numInChat" => $this->_params['taigachat']['numInChat']);
     if (!empty($this->_params['taigachat']['publichtml'])) {
         $params += array("_visitor_conversationsUnread" => "IGNORE", "_visitor_alertsUnread" => "IGNORE");
     }
     //$rendered = str_replace(array("\r", "\n", "\t"), "", $rendered);
     $derp = XenForo_ViewRenderer_Json::jsonEncodeForOutput($params, empty($this->_params['taigachat']['publichtml']));
     if (empty($this->_params['taigachat']['publichtml'])) {
         $extraHeaders = XenForo_Application::gzipContentIfSupported($derp);
         foreach ($extraHeaders as $extraHeader) {
             header("{$extraHeader['0']}: {$extraHeader['1']}", $extraHeader[2]);
         }
     }
     return $derp;
 }
コード例 #10
0
ファイル: Attachment.php プロジェクト: Sywooch/forums
 public function actionDeleteAttachment()
 {
     $vals = $this->_input->filter(array('attachmentid' => XenForo_Input::UINT, 'poststarttime' => XenForo_Input::STRING));
     try {
         $attachment = $this->_getAttachmentOrError($vals['attachmentid']);
     } catch (Exception $e) {
         $error = new XenForo_Phrase('do_not_have_permission');
         json_error($error->render());
     }
     if (!$this->_getAttachmentModel()->canDeleteAttachment($attachment, $vals['poststarttime'])) {
         $error = new XenForo_Phrase('do_not_have_permission');
         json_error($error->render());
     }
     $dw = XenForo_DataWriter::create('XenForo_DataWriter_Attachment');
     $dw->setExistingData($attachment, true);
     $dw->delete();
     return array('success' => true);
 }
コード例 #11
0
ファイル: JavaScript.php プロジェクト: Sywooch/forums
 public function renderHtml()
 {
     header('Cache-Control: public, max-age=31536000');
     header('Content-Type: application/javascript');
     $templateObject = XenForo_Application::getFc()->getDependencies()->createTemplateObject($this->_templateName);
     $templateObject->setLanguageId(XenForo_Phrase::getLanguageId());
     $templateObject->setStyleId(XenForo_Application::get('options')->defaultStyleId);
     echo $templateObject->render();
     exit;
 }
コード例 #12
0
ファイル: List.php プロジェクト: VoDongMy/xenforo-laravel5.1
 public function renderJson()
 {
     $options = XenForo_Application::get('options');
     $maxUpdate = Dark_TaigaChat_Helper_Global::processMessagesForView($this->_params, $this);
     $messages = $this->_params['taigachat']['messages'];
     if ($options->dark_taigachat_reverse) {
         $messages = array_reverse($messages);
     }
     $twelveHour = false;
     $template = $this->createTemplateObject("dark_taigachat_robots");
     if (!empty($this->_params['taigachat']['publichtml'])) {
         /** @var XenForo_Model_Language */
         $languageModel = XenForo_Model::create('XenForo_Model_Language');
         $language = $languageModel->getLanguageById(XenForo_Phrase::getLanguageId());
         if ($language['time_format'] == 'g:i A') {
             $twelveHour = true;
         }
         $template->setLanguageId(XenForo_Phrase::getLanguageId());
         $template->setStyleId($options->defaultStyleId);
     }
     $robots = $template->render();
     $outputMessages = array();
     $previous = null;
     $template = $this->createTemplateObject("dark_taigachat_message", $this->_params);
     if (!empty($this->_params['taigachat']['publichtml'])) {
         $template->setLanguageId(XenForo_Phrase::getLanguageId());
         $template->setStyleId($options->defaultStyleId);
     }
     foreach ($messages as &$message) {
         $template->setParam("message", $message);
         $rendered = $template->render();
         $rendered = preg_replace('/\\s+<\\/(.*?)>\\s+</si', ' </$1> <', $rendered);
         $rendered = preg_replace('/\\s+<(.*?)([ >])/si', ' <$1$2', $rendered);
         $outputMessages[] = array("id" => $message['id'], "previous" => empty($previous) ? 0 : $previous['id'], "last_update" => $message['last_update'], "html" => $rendered);
         $previous = $message;
     }
     $template = $this->createTemplateObject("dark_taigachat_online_users", $this->_params);
     if (!empty($this->_params['taigachat']['publichtml'])) {
         $template->setLanguageId(XenForo_Phrase::getLanguageId());
         $template->setStyleId($options->defaultStyleId);
     }
     $outputOnlineUsers = $template->render();
     $params = array("robots" => $robots, "messages" => $outputMessages, "messageIds" => $this->_params['taigachat']['messageIds'], "onlineUsers" => $outputOnlineUsers, "reverse" => $options->dark_taigachat_direction, "lastrefresh" => $maxUpdate, "motd" => $this->_params['taigachat']['motd'], "numInChat" => $this->_params['taigachat']['numInChat'], "twelveHour" => $twelveHour);
     if (!empty($this->_params['taigachat']['publichtml'])) {
         $params += array("_visitor_conversationsUnread" => "IGNORE", "_visitor_alertsUnread" => "IGNORE");
     }
     $jsonOutput = XenForo_ViewRenderer_Json::jsonEncodeForOutput($params, empty($this->_params['taigachat']['publichtml']));
     if (empty($this->_params['taigachat']['publichtml'])) {
         $extraHeaders = XenForo_Application::gzipContentIfSupported($jsonOutput);
         foreach ($extraHeaders as $extraHeader) {
             header("{$extraHeader['0']}: {$extraHeader['1']}", $extraHeader[2]);
         }
     }
     return $jsonOutput;
 }
コード例 #13
0
 public function renderRss()
 {
     $options = XenForo_Application::getOptions();
     $title = new XenForo_Phrase('xengallery_media');
     $description = new XenForo_Phrase('xengallery_check_out_all_media_from_x', array('board' => $options->boardTitle));
     $buggyXmlNamespace = defined('LIBXML_DOTTED_VERSION') && LIBXML_DOTTED_VERSION == '2.6.24';
     $feed = new Zend_Feed_Writer_Feed();
     $feed->setEncoding('utf-8');
     $feed->setTitle($title->render());
     $feed->setDescription($description->render());
     $feed->setLink(XenForo_Link::buildPublicLink('canonical:xengallery'));
     if (!$buggyXmlNamespace) {
         $feed->setFeedLink(XenForo_Link::buildPublicLink('canonical:xengallery.rss'), 'rss');
     }
     $feed->setDateModified(XenForo_Application::$time);
     $feed->setLastBuildDate(XenForo_Application::$time);
     $feed->setGenerator($title->render());
     $bbCodeParser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));
     foreach ($this->_params['media'] as $media) {
         $entry = $feed->createEntry();
         $entry->setTitle($media['media_title'] ? $media['media_title'] : $media['media_title'] . ' ');
         $entry->setLink(XenForo_Link::buildPublicLink('canonical:xengallery', $media));
         $entry->setDateCreated(new Zend_Date($media['media_date'], Zend_Date::TIMESTAMP));
         $entry->setDateModified(new Zend_Date($media['last_edit_date'], Zend_Date::TIMESTAMP));
         if (!empty($media['media_description'])) {
             $entry->setDescription($media['media_description']);
         }
         XenGallery_ViewPublic_Helper_VideoHtml::addVideoHtml($media, $bbCodeParser);
         $content = $this->_renderer->createTemplateObject('xengallery_rss_content', array('media' => $media));
         $entry->setContent($content->render());
         if (!$buggyXmlNamespace) {
             $entry->addAuthor(array('name' => $media['username'], 'email' => '*****@*****.**', 'uri' => XenForo_Link::buildPublicLink('canonical:xengallery/users', $media)));
             if ($media['comment_count']) {
                 $entry->setCommentCount($media['comment_count']);
             }
         }
         $feed->addEntry($entry);
     }
     return $feed->export('rss');
 }
コード例 #14
0
ファイル: Content.php プロジェクト: Sywooch/forums
 public function getErrorOrNoPermissionResponse(XenForo_ControllerResponse_View $response, $errorPhraseKey, $stringToPhrase = true)
 {
     $responseCode = 403;
     if (XenForo_Visitor::getUserId() == 0) {
         $viewParams = array('text' => new XenForo_Phrase('login_required'));
         $response2 = $this->_controller->responseView('XenForo_ViewPublic_Error_RegistrationRequired', 'error_with_login', $viewParams);
     } else {
         if (empty($errorPhraseKey)) {
             $error = new XenForo_Phrase('do_not_have_permission');
         } elseif ($errorPhraseKey && (is_string($errorPhraseKey) || is_array($errorPhraseKey)) && $stringToPhrase) {
             $error = new XenForo_Phrase($errorPhraseKey);
             if (preg_match('/^requested_.*_not_found$/i', $error->getPhraseName())) {
                 $responseCode = 404;
             }
         } else {
             $error = $errorPhraseKey;
         }
         if (is_array($error)) {
             $errors = $error;
         } else {
             $errors = array($error);
         }
         $viewParams = array('error' => $errors);
         $response2 = $this->_controller->responseView('', 'error', $viewParams);
     }
     // TODO: improve response code
     // as far as I know, Facebook hates 4xx
     // $response2->responseCode = $responseCode;
     $response2->subView = $response;
     $response2->params['_bdSocialShare_renderSubView'] = true;
     // copy params from $response->params to $response2->params for better
     // compatibility with other add-ons
     foreach ($response->params as $responseParamKey => $responseParamValue) {
         if (!isset($response2->params[$responseParamKey])) {
             $response2->params[$responseParamKey] = $responseParamValue;
         }
     }
     return $response2;
 }
コード例 #15
0
ファイル: Filter.php プロジェクト: Sywooch/forums
    public function renderJson()
    {
        $teams = $this->_params['teams'];
        if (empty($teams)) {
            $content = new XenForo_Phrase('Teams_there_currently_no_teams_to_display');
            $description = '
				<dt><label for="ctrl_team_id">' . new XenForo_Phrase('Teams_team') . ':</label></dt>
					<dd>
						' . $content . '
					</dd>';
        } else {
            $notFound = new XenForo_Phrase('no_results_found');
            $openTag = '
				<script>
					$(document).ready(function()
					{
						$(".choosen").chosen(
						{
							disable_search_threshold: 10,
							no_results_text: "' . $notFound->render() . '",
							width: "100%"
						});
					});
				</script>
				<dt><label for="ctrl_team_id">' . new XenForo_Phrase('Teams_team') . ':</label></dt>
					<dd>
						<select name="team_id" class="textCtrl choosen" id="ctrl_team_id">
			';
            $closeTag = '</select></dd>';
            $content = '';
            foreach ($teams as $team) {
                $content .= '<option value="' . $team['team_id'] . '">' . $team['title'] . '</option>';
            }
            $description = $openTag . $content . $closeTag;
        }
        return array('description' => $description);
    }
コード例 #16
0
ファイル: Update.php プロジェクト: AndroidOS/SocialGroups
 protected function _updateSocialForum($resource)
 {
     if (!$this->_isFirstVisible || !$resource || !$resource['social_forum_id']) {
         return false;
     }
     $socialForum = ThemeHouse_SocialGroups_SocialForum::setup($resource['social_forum_id'])->toArray();
     if (!$socialForum) {
         return false;
     }
     $forum = $this->getModelFromCache('XenForo_Model_Forum')->getForumById($socialForum['node_id']);
     if (!$forum) {
         return false;
     }
     $threadDw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread', XenForo_DataWriter::ERROR_SILENT);
     $threadDw->setExtraData(XenForo_DataWriter_Discussion_Thread::DATA_FORUM, $forum);
     $threadDw->bulkSet(array('node_id' => $socialForum['node_id'], 'title' => $this->get('title'), 'user_id' => $resource['user_id'], 'username' => $resource['username'], 'discussion_type' => 'resource'));
     $threadDw->set('discussion_state', $this->getModelFromCache('XenForo_Model_Post')->getPostInsertMessageState(array(), $forum));
     $threadDw->setOption(XenForo_DataWriter_Discussion::OPTION_PUBLISH_FEED, false);
     $messageText = $this->get('message');
     // note: this doesn't actually strip the BB code - it will fix the BB code in the snippet though
     $parser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_BbCode_AutoLink', false));
     $snippet = $parser->render(XenForo_Helper_String::wholeWordTrim($messageText, 500));
     $message = new XenForo_Phrase('resource_message_create_update', array('title' => $this->get('title'), 'username' => $resource['username'], 'userId' => $resource['user_id'], 'snippet' => $snippet, 'updateLink' => XenForo_Link::buildPublicLink('canonical:resources/update', $resource, array('update' => $this->get('resource_update_id'))), 'resourceTitle' => $resource['title'], 'resourceLink' => XenForo_Link::buildPublicLink('canonical:resources', $resource)), false);
     $postWriter = $threadDw->getFirstMessageDw();
     $postWriter->set('message', $message->render());
     $postWriter->setExtraData(XenForo_DataWriter_DiscussionMessage_Post::DATA_FORUM, $forum);
     $postWriter->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_PUBLISH_FEED, false);
     if (!$threadDw->save()) {
         return false;
     }
     $this->set('discussion_thread_id', $threadDw->get('thread_id'), '', array('setAfterPreSave' => true));
     $postSaveChanges['discussion_thread_id'] = $threadDw->get('thread_id');
     $this->getModelFromCache('XenForo_Model_Thread')->markThreadRead($threadDw->getMergedData(), $forum, XenForo_Application::$time);
     $this->getModelFromCache('XenForo_Model_ThreadWatch')->setThreadWatchStateWithUserDefault($this->get('user_id'), $threadDw->get('thread_id'), $this->getExtraData(XenResource_DataWriter_Resource::DATA_THREAD_WATCH_DEFAULT));
     return $postWriter->get('post_id');
 }
コード例 #17
0
ファイル: Mail.php プロジェクト: hahuunguyen/DTUI_201105
 /**
  * Constructor.
  *
  * @param string $emailTitle Title of the email template
  * @param array $params Key-value params to pass to email template
  * @param integer|null $languageId Language of email; if null, uses language of current user (if setup)
  */
 public function __construct($emailTitle, array $params, $languageId = null)
 {
     if ($languageId === null) {
         $languageId = XenForo_Phrase::getLanguageId();
     } else {
         if (!$languageId) {
             $languageId = XenForo_Application::get('options')->defaultLanguageId;
         }
     }
     $this->_emailTitle = $emailTitle;
     $this->_params = $params;
     $this->_languageId = $languageId;
     if (!isset(self::$_emailCache[$emailTitle][$languageId])) {
         self::$_preCache[$emailTitle] = true;
     }
     if (!XenForo_Application::isRegistered('languages')) {
         XenForo_Application::set('languages', XenForo_Model::create('XenForo_Model_Language')->getAllLanguagesForCache());
     }
 }
コード例 #18
0
ファイル: Visitor.php プロジェクト: darkearl/projectT122015
 public function setVisitorLanguage($languageId)
 {
     $languages = XenForo_Application::isRegistered('languages') ? XenForo_Application::get('languages') : XenForo_Model::create('XenForo_Model_Language')->getAllLanguagesForCache();
     if ($languageId && !empty($languages[$languageId])) {
         $language = $languages[$languageId];
     } else {
         $defaultLanguageId = XenForo_Application::get('options')->defaultLanguageId;
         if (!empty($languages[$defaultLanguageId])) {
             $language = $languages[$defaultLanguageId];
         } else {
             $language = reset($languages);
         }
     }
     if (!$language) {
         return;
         // this probably shouldn't happen
     }
     if (empty($language['phrase_cache'])) {
         $language['phrase_cache'] = array();
     }
     $this->_language = $language;
     XenForo_Phrase::setLanguageId($language['language_id']);
     XenForo_Phrase::setPhrases($language['phrase_cache']);
     XenForo_Locale::setDefaultLanguage($language);
 }
コード例 #19
0
ファイル: Register.php プロジェクト: Sywooch/forums
 public function actionRegister()
 {
     $this->_assertRegistrationActive();
     $vals = $this->_input->filter(array('username' => XenForo_Input::STRING, 'email' => XenForo_Input::STRING, 'password' => XenForo_Input::STRING, 'password_md5' => XenForo_Input::STRING, 'birthday' => XenForo_Input::STRING, 'timezone_name' => XenForo_Input::STRING));
     $options = XenForo_Application::get('options');
     if (!$options->forumrunnerRegistration) {
         $p = new XenForo_Phrase('do_not_have_permission');
         json_error($p->render());
     }
     $out = array();
     if ($vals['username']) {
         $writer = XenForo_DataWriter::create('XenForo_DataWriter_User');
         if ($options->registrationDefaults) {
             $writer->bulkSet($options->registrationDefaults, array('ignoreInvalidFields' => true));
         }
         $day = $month = $year = '';
         if ($vals['birthday']) {
             $parts = preg_split('#/#', $vals['birthday']);
             if ($parts[0]) {
                 $month = intval($parts[0]);
             }
             if ($parts[1]) {
                 $day = intval($parts[1]);
             }
             if ($parts[2]) {
                 $year = intval($parts[2]);
             }
         }
         // Figure out Time Zone
         $data = array('username' => $vals['username'], 'email' => $vals['email'], 'gender' => '', 'dob_day' => $day, 'dob_month' => $month, 'dob_year' => $year, 'timezone' => $vals['timezone_name']);
         $writer->bulkSet($data);
         $writer->setPassword($vals['password'], $vals['password']);
         // verified by client
         // if the email corresponds to an existing Gravatar, use it
         if ($options->gravatarEnable && XenForo_Model_Avatar::gravatarExists($data['email'])) {
             $writer->set('gravatar', $data['email']);
         }
         $writer->set('user_group_id', XenForo_Model_User::$defaultRegisteredGroupId);
         $writer->set('language_id', XenForo_Visitor::getInstance()->get('language_id'));
         $writer->advanceRegistrationUserState();
         $writer->preSave();
         if ($options->get('registrationSetup', 'requireDob')) {
             // dob required
             if (!$data['dob_day'] || !$data['dob_month'] || !$data['dob_year']) {
                 $p = new XenForo_Phrase('please_enter_valid_date_of_birth');
                 json_error($p->render());
             }
             $userAge = $this->_getUserProfileModel()->getUserAge($writer->getMergedData(), true);
             if ($userAge < 1) {
                 $p = new XenForo_Phrase('please_enter_valid_date_of_birth');
                 json_error($p->render());
             }
             if ($userAge < intval($options->get('registrationSetup', 'minimumAge'))) {
                 $p = new XenForo_Phrase('sorry_you_too_young_to_create_an_account');
                 json_error($p->render());
             }
         }
         $errors = $writer->getErrors();
         if (count($errors)) {
             // only show first
             $errors = array_values($errors);
             json_error($errors[0]->render());
         }
         $writer->save();
         $user = $writer->getMergedData();
         // log the ip of the user registering
         XenForo_Model_Ip::log($user['user_id'], 'user', $user['user_id'], 'register');
         if ($user['user_state'] == 'email_confirm') {
             $this->_getUserConfirmationModel()->sendEmailConfirmation($user);
             $out['emailverify'] = true;
         } else {
             $out['emailverify'] = false;
         }
         XenForo_Visitor::setup(0);
     } else {
         $p = new XenForo_Phrase('fr_register_forum_rules');
         $out += array('rules' => preg_replace('/<a href=\\"(.*?)\\">(.*?)<\\/a>/', "\\2", $p->render()), 'birthday' => $options->get('registrationSetup', 'requireDob') ? true : false);
     }
     return $out;
 }
コード例 #20
0
ファイル: Admin.php プロジェクト: hahuunguyen/DTUI_201105
 /**
  * Performs any pre-view rendering setup, such as getting style information and
  * ensuring the correct data is registered.
  *
  * @param XenForo_ControllerResponse_Abstract|null $controllerResponse
  */
 public function preRenderView(XenForo_ControllerResponse_Abstract $controllerResponse = null)
 {
     parent::preRenderView($controllerResponse);
     XenForo_Template_Abstract::setLanguageId(XenForo_Phrase::getLanguageId());
     $properties = XenForo_Application::get('adminStyleProperties');
     XenForo_Template_Helper_Core::setStyleProperties($properties);
     $this->_defaultTemplateParams['_styleModifiedDate'] = XenForo_Application::get('adminStyleModifiedDate');
 }
コード例 #21
0
ファイル: Report.php プロジェクト: Sywooch/forums
 /**
  * Reports a piece of content.
  *
  * @param string $contentType
  * @param array $content Information about content
  * @param string $message
  * @param array|null $viewingUser User reporting; null means visitor
  *
  * @return bool|integer Report ID or false if no report was made, true if reported into a forum
  */
 public function reportContent($contentType, array $content, $message, array $viewingUser = null)
 {
     $this->standardizeViewingUserReference($viewingUser);
     if (!$viewingUser['user_id']) {
         return false;
     }
     $handler = $this->getReportHandler($contentType);
     if (!$handler) {
         return false;
     }
     list($contentId, $contentUserId, $contentInfo) = $handler->getReportDetailsFromContent($content);
     if (!$contentId) {
         return false;
     }
     $reportForumId = XenForo_Application::getOptions()->reportIntoForumId;
     if ($reportForumId) {
         /** @var $forumModel XenForo_Model_Forum */
         $forumModel = $this->getModelFromCache('XenForo_Model_Forum');
         $reportForum = $forumModel->getForumById($reportForumId);
         if ($reportForum) {
             $report = array('content_type' => $contentType, 'content_id' => $contentId, 'content_user_id' => $contentUserId, 'content_info' => $contentInfo, 'first_report_date' => XenForo_Application::$time, 'report_state' => 'open', 'assigned_user_id' => 0, 'comment_count' => 0, 'report_count' => 0);
             $params = $handler->getContentForThread($report, $contentInfo);
             $user = $this->getModelFromCache('XenForo_Model_User')->getUserById($contentUserId);
             if ($user) {
                 $params['username'] = $user['username'];
             }
             $params['userLink'] = XenForo_Link::buildPublicLink('canonical:members', $user);
             $params['reporter'] = $viewingUser['username'];
             $params['reporterLink'] = XenForo_Link::buildPublicLink('canonical:members', $viewingUser);
             $params['reportReason'] = $message;
             foreach ($params as &$param) {
                 if ($param instanceof XenForo_Phrase) {
                     // make sure that params in phrases don't get escaped
                     $newParam = clone $param;
                     $newParam->setEscapeCallback(false);
                     $param = $newParam;
                 }
             }
             $threadTitle = new XenForo_Phrase('reported_thread_title', $params, false);
             /** @var $threadDw XenForo_DataWriter_Discussion_Thread */
             $threadDw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread', XenForo_DataWriter::ERROR_SILENT);
             $threadDw->setExtraData(XenForo_DataWriter_Discussion_Thread::DATA_FORUM, $reportForum);
             $threadDw->setOption(XenForo_DataWriter_Discussion::OPTION_TRIM_TITLE, true);
             $threadDw->bulkSet(array('node_id' => $reportForum['node_id'], 'title' => $threadTitle->render(), 'user_id' => $viewingUser['user_id'], 'username' => $viewingUser['username']));
             $threadDw->set('discussion_state', $this->getModelFromCache('XenForo_Model_Post')->getPostInsertMessageState(array(), $reportForum));
             $message = new XenForo_Phrase('reported_thread_message', $params, false);
             $postWriter = $threadDw->getFirstMessageDw();
             $postWriter->set('message', $message->render());
             $postWriter->setExtraData(XenForo_DataWriter_DiscussionMessage_Post::DATA_FORUM, $reportForum);
             return $threadDw->save();
         }
         return false;
     }
     $newReportState = '';
     $report = $this->getReportByContent($contentType, $contentId);
     if ($report) {
         $reportId = $report['report_id'];
         if ($report['report_state'] == 'resolved' || $report['report_state'] == 'rejected') {
             // re-open an existing report
             $reportDw = XenForo_DataWriter::create('XenForo_DataWriter_Report');
             $reportDw->setExistingData($report, true);
             $reportDw->set('report_state', 'open');
             $reportDw->save();
             $newReportState = 'open';
         }
     } else {
         $reportDw = XenForo_DataWriter::create('XenForo_DataWriter_Report');
         $reportDw->bulkSet(array('content_type' => $contentType, 'content_id' => $contentId, 'content_user_id' => $contentUserId, 'content_info' => $contentInfo));
         $reportDw->save();
         $reportId = $reportDw->get('report_id');
     }
     $reasonDw = XenForo_DataWriter::create('XenForo_DataWriter_ReportComment');
     $reasonDw->bulkSet(array('report_id' => $reportId, 'user_id' => $viewingUser['user_id'], 'username' => $viewingUser['username'], 'message' => $message, 'state_change' => $newReportState, 'is_report' => 1));
     $reasonDw->save();
     return $reportId;
 }
コード例 #22
0
function get_xf_lang($lang_key, $params = array())
{
    $phrase = new XenForo_Phrase($lang_key, $params);
    return $phrase->render();
}
コード例 #23
0
 function getContentTypeKeyPhrase()
 {
     $phrase = new XenForo_Phrase('thread');
     return $phrase->render();
 }
コード例 #24
0
ファイル: Thread.php プロジェクト: namgiangle90/tokyobaito
 /**
  * Logs the moderator actions for thread edits.
  *
  * @param array $thread
  * @param XenForo_DataWriter_Discussion_Thread $dw
  * @param array $skip Array of keys to skip logging for
  */
 protected function _updateModeratorLogThreadEdit(array $thread, XenForo_DataWriter_Discussion_Thread $dw, array $skip = array())
 {
     $newData = $dw->getMergedNewData();
     if ($newData) {
         $oldData = $dw->getMergedExistingData();
         $basicLog = array();
         foreach ($newData as $key => $value) {
             $oldValue = isset($oldData[$key]) ? $oldData[$key] : '-';
             switch ($key) {
                 case 'sticky':
                     XenForo_Model_Log::logModeratorAction('thread', $thread, $value ? 'stick' : 'unstick');
                     break;
                 case 'discussion_open':
                     XenForo_Model_Log::logModeratorAction('thread', $thread, $value ? 'unlock' : 'lock');
                     break;
                 case 'discussion_state':
                     if ($value == 'visible' && $oldValue == 'moderated') {
                         XenForo_Model_Log::logModeratorAction('thread', $thread, 'approve');
                     } else {
                         if ($value == 'visible' && $oldValue == 'deleted') {
                             XenForo_Model_Log::logModeratorAction('thread', $thread, 'undelete');
                         } else {
                             if ($value == 'deleted') {
                                 XenForo_Model_Log::logModeratorAction('thread', $thread, 'delete_soft', array('reason' => ''));
                             } else {
                                 if ($value == 'moderated') {
                                     XenForo_Model_Log::logModeratorAction('thread', $thread, 'unapprove');
                                 }
                             }
                         }
                     }
                     break;
                 case 'title':
                     XenForo_Model_Log::logModeratorAction('thread', $thread, 'title', array('old' => $oldValue));
                     break;
                 case 'prefix_id':
                     if ($oldValue) {
                         $phrase = new XenForo_Phrase('thread_prefix_' . $oldValue);
                         $oldValue = $phrase->render();
                     } else {
                         $oldValue = '-';
                     }
                     XenForo_Model_Log::logModeratorAction('thread', $thread, 'prefix', array('old' => $oldValue));
                     break;
                 default:
                     if (!in_array($key, $skip)) {
                         $basicLog[$key] = $oldValue;
                     }
             }
         }
         if ($basicLog) {
             XenForo_Model_Log::logModeratorAction('thread', $thread, 'edit', $basicLog);
         }
     }
 }
コード例 #25
0
ファイル: Team.php プロジェクト: Sywooch/forums
 protected function _insertDiscussionThread($nodeId, $prefixId = 0)
 {
     if (!$nodeId) {
         return false;
     }
     $forum = $this->getModelFromCache('XenForo_Model_Forum')->getForumById($nodeId);
     if (!$forum) {
         return false;
     }
     $threadDw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread', XenForo_DataWriter::ERROR_SILENT);
     $threadDw->setExtraData(XenForo_DataWriter_Discussion_Thread::DATA_FORUM, $forum);
     $threadDw->bulkSet(array('node_id' => $nodeId, 'title' => $this->_getThreadTitle(), 'user_id' => $this->get('user_id'), 'username' => $this->get('username'), 'discussion_type' => 'team', 'prefix_id' => $prefixId));
     $threadDw->set('discussion_state', $this->getModelFromCache('XenForo_Model_Post')->getPostInsertMessageState(array(), $forum));
     $threadDw->setOption(XenForo_DataWriter_Discussion::OPTION_PUBLISH_FEED, false);
     $messageText = $this->get('about');
     // note: this doesn't actually strip the BB code - it will fix the BB code in the snippet though
     $parser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_BbCode_AutoLink', false));
     $snippet = $parser->render(XenForo_Helper_String::wholeWordTrim($messageText, 500));
     $message = new XenForo_Phrase('Teams_message_create_team', array('title' => $this->get('title'), 'tagLine' => $this->get('tag_line'), 'username' => $this->get('username'), 'userId' => $this->get('user_id'), 'snippet' => $snippet, 'teamLink' => XenForo_Link::buildPublicLink('canonical:' . Nobita_Teams_Model_Team::routePrefix(), $this->getMergedData())), false);
     $postWriter = $threadDw->getFirstMessageDw();
     $postWriter->set('message', $message->render());
     $postWriter->setExtraData(XenForo_DataWriter_DiscussionMessage_Post::DATA_FORUM, $forum);
     $postWriter->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_PUBLISH_FEED, false);
     if (!$threadDw->save()) {
         return false;
     }
     $this->set('discussion_thread_id', $threadDw->get('thread_id'), '', array('setAfterPreSave' => true));
     $postSaveChanges['discussion_thread_id'] = $threadDw->get('thread_id');
     $this->getModelFromCache('XenForo_Model_Thread')->markThreadRead($threadDw->getMergedData(), $forum, \XenForo_Application::$time);
     $this->getModelFromCache('XenForo_Model_ThreadWatch')->setThreadWatchStateWithUserDefault($this->get('user_id'), $threadDw->get('thread_id'), $this->getExtraData(self::DATA_THREAD_WATCH_DEFAULT));
     return $threadDw->get('thread_id');
 }
コード例 #26
0
ファイル: Resource.php プロジェクト: Sywooch/forums
 /**
  * Gets the HTML value of the resource field.
  *
  * @param array $resource
  * @param array|string $field If string, field ID
  * @param mixed $value Value of the field; if null, pulls from field_value in field
  *
  * @return string
  */
 public static function getResourceFieldValueHtml(array $resource, $field, $value = null)
 {
     if (!is_array($field)) {
         $fields = XenForo_Model::create('XenResource_Model_ResourceField')->getResourceFieldCache();
         if (!isset($fields[$field])) {
             return '';
         }
         $field = $fields[$field];
     }
     if (!XenForo_Application::isRegistered('view')) {
         return 'No view registered';
     }
     if ($value === null && isset($field['field_value'])) {
         $value = $field['field_value'];
     }
     if ($value === '' || $value === null) {
         return '';
     }
     $multiChoice = false;
     $choice = '';
     $view = XenForo_Application::get('view');
     switch ($field['field_type']) {
         case 'radio':
         case 'select':
             $choice = $value;
             $value = new XenForo_Phrase("resource_field_{$field['field_id']}_choice_{$value}");
             $value->setPhraseNameOnInvalid(false);
             $valueRaw = $value;
             break;
         case 'checkbox':
         case 'multiselect':
             $multiChoice = true;
             if (!is_array($value) || count($value) == 0) {
                 return '';
             }
             $newValues = array();
             foreach ($value as $id => $choice) {
                 $phrase = new XenForo_Phrase("resource_field_{$field['field_id']}_choice_{$choice}");
                 $phrase->setPhraseNameOnInvalid(false);
                 $newValues[$choice] = $phrase;
             }
             $value = $newValues;
             $valueRaw = $value;
             break;
         case 'bbcode':
             $valueRaw = htmlspecialchars(XenForo_Helper_String::censorString($value));
             $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $view)));
             $value = $bbCodeParser->render($value, array('noFollowDefault' => empty($resource['isTrusted'])));
             break;
         case 'textbox':
         case 'textarea':
         default:
             $valueRaw = htmlspecialchars(XenForo_Helper_String::censorString($value));
             $value = XenForo_Template_Helper_Core::callHelper('bodytext', array($value));
     }
     if (!empty($field['display_template'])) {
         if ($multiChoice && is_array($value)) {
             foreach ($value as $choice => &$thisValue) {
                 $thisValue = strtr($field['display_template'], array('{$fieldId}' => $field['field_id'], '{$value}' => $thisValue, '{$valueRaw}' => $thisValue, '{$valueUrl}' => urlencode($thisValue), '{$choice}' => $choice));
             }
         } else {
             $value = strtr($field['display_template'], array('{$fieldId}' => $field['field_id'], '{$value}' => $value, '{$valueRaw}' => $valueRaw, '{$valueUrl}' => urlencode($value), '{$choice}' => $choice));
         }
     }
     if (is_array($value)) {
         if (empty($value)) {
             return '';
         }
         return '<ul class="plainList"><li>' . implode('</li><li>', $value) . '</li></ul>';
     }
     return $value;
 }
コード例 #27
0
ファイル: Post.php プロジェクト: Sywooch/forums
 public function actionLike()
 {
     $postid = $this->_input->filterSingle('postid', XenForo_Input::UINT);
     $helper = $this->getHelper('ForumThreadPost');
     try {
         list($post_info, $thread_info, $forum_info) = $helper->assertPostValidAndViewable($postid);
     } catch (Exception $e) {
         json_error($e->getControllerResponse()->errorText->render());
     }
     if (!$this->_getPostModel()->canLikePost($post_info, $thread_info, $forum_info, $error)) {
         $phrase = new XenForo_Phrase($error);
         json_error($phrase->render());
     }
     $like_model = $this->_getLikeModel();
     $existing_like = $like_model->getContentLikeByLikeUser('post', $postid, XenForo_Visitor::getUserId());
     if ($existing_like) {
         $like_model->unlikeContent($existing_like);
     } else {
         $like_model->likeContent('post', $postid, $post_info['user_id']);
     }
     return array('success' => true);
 }
コード例 #28
0
ファイル: Controller.php プロジェクト: Sywooch/forums
 /**
  * Gets a specific error or a general no permission response exception.
  * If the first param is a string and $stringToPhrase is true, it will be treated
  * as a phrase key and turned into a phrase.
  *
  * If a specific phrase is requested, a general error will be thrown. Otherwise,
  * a generic no permission error will be shown.
  *
  * @param string|XenForo_Phrase|mixed $errorPhraseKey A phrase key, a phrase object, or hard coded text. Or, may be empty.
  * @param boolean $stringToPhrase If true and the $errorPhraseKey is a string, $errorPhraseKey is treated as the name of a phrase.
  *
  * @return XenForo_ControllerResponse_Exception
  */
 public function getErrorOrNoPermissionResponseException($errorPhraseKey, $stringToPhrase = true)
 {
     $responseCode = 403;
     if ($errorPhraseKey && (is_string($errorPhraseKey) || is_array($errorPhraseKey)) && $stringToPhrase) {
         $error = new XenForo_Phrase($errorPhraseKey);
         if (preg_match('/^requested_.*_not_found$/i', $error->getPhraseName())) {
             $responseCode = 404;
         }
     } else {
         $error = $errorPhraseKey;
     }
     if ($errorPhraseKey) {
         return $this->responseException($this->responseError($error, $responseCode));
     } else {
         return $this->getNoPermissionResponseException();
     }
 }
コード例 #29
0
ファイル: index.php プロジェクト: VoDongMy/xenforo-laravel5.1
<?php

$startTime = microtime(true);
$fileDir = dirname(__FILE__);
$rootPath = realpath($fileDir . '/..');
chdir($rootPath);
require $rootPath . '/library/XenForo/Autoloader.php';
XenForo_Autoloader::getInstance()->setupAutoloader($rootPath . '/library');
XenForo_Application::initialize($rootPath . '/library', $rootPath, false);
XenForo_Application::set('page_start_time', $startTime);
XenForo_Phrase::setPhrases(require $fileDir . '/language_en.php');
XenForo_Template_Install::setFilePath($fileDir . '/templates');
$fc = new XenForo_FrontController(new XenForo_Dependencies_Install());
$fc->run();
コード例 #30
0
ファイル: FindNew.php プロジェクト: Sywooch/forums
 private function noResults()
 {
     $no_results = new XenForo_Phrase('no_results_found');
     return array('threads' => array(array('error' => $no_results->render())), 'total_threads' => 1);
 }