本文整理汇总了PHP中XenForo_Link::buildPublicLink方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Link::buildPublicLink方法的具体用法?PHP XenForo_Link::buildPublicLink怎么用?PHP XenForo_Link::buildPublicLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Link
的用法示例。
在下文中一共展示了XenForo_Link::buildPublicLink方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: autoTag
/**
* Inserts tag links into an HTML-formatted text.
*
* @param string $html
* @param array $tags
* @param array $options
* @return string
*/
public static function autoTag($html, array $tags, array &$options = array())
{
if (empty($tags)) {
return $html;
}
$html = strval($html);
$htmlNullified = utf8_strtolower($html);
$htmlNullified = preg_replace_callback('#<a[^>]+>.+?</a>#', array(__CLASS__, '_autoTag_nullifyHtmlCallback'), $htmlNullified);
$htmlNullified = preg_replace_callback('#<[^>]+>#', array(__CLASS__, '_autoTag_nullifyHtmlCallback'), $htmlNullified);
// prepare the options
$onceOnly = empty($options['onceOnly']) ? false : true;
$options['autoTagged'] = array();
// reset this
// sort tags with the longest one first
// since 1.0.3
usort($tags, array(__CLASS__, '_autoTag_sortTagsByLength'));
foreach ($tags as $tag) {
$offset = 0;
$tagText = utf8_strtolower($tag['tag']);
$tagLength = utf8_strlen($tagText);
while (true) {
$pos = utf8_strpos($htmlNullified, $tagText, $offset);
if ($pos !== false) {
// the tag has been found
if (self::_autoTag_hasValidCharacterAround($html, $pos, $tagText)) {
// and it has good surrounding characters
// start replacing
$displayText = utf8_substr($html, $pos, $tagLength);
$template = new XenForo_Template_Public('tinhte_xentag_bb_code_tag_tag');
$template->setParam('tag', $tag);
$template->setParam('displayText', $displayText);
$replacement = $template->render();
if (strlen($replacement) === 0) {
// in case template system hasn't been initialized
$replacement = sprintf('<a href="%s">%s</a>', XenForo_Link::buildPublicLink('tags', $tag), $displayText);
}
$html = utf8_substr_replace($html, $replacement, $pos, $tagLength);
$htmlNullified = utf8_substr_replace($htmlNullified, str_repeat('_', utf8_strlen($replacement)), $pos, $tagLength);
// sondh@2012-09-20
// keep track of the auto tagged tags
$options['autoTagged'][$tagText][$pos] = $replacement;
$offset = $pos + utf8_strlen($replacement);
if ($onceOnly) {
// auto link only once per tag
// break the loop now
break;
// while (true)
}
} else {
$offset = $pos + $tagLength;
}
} else {
// no match has been found, stop working with this tag
break;
// while (true)
}
}
}
return $html;
}
示例2: prepareApiDataForProfilePost
public function prepareApiDataForProfilePost(array $profilePost, array $user)
{
$profilePost = $this->prepareProfilePost($profilePost, $user);
$publicKeys = array('profile_post_id' => 'profile_post_id', 'profile_user_id' => 'timeline_user_id', 'user_id' => 'poster_user_id', 'username' => 'poster_username', 'post_date' => 'post_create_date', 'message' => 'post_body', 'likes' => 'post_like_count', 'comment_count' => 'post_comment_count');
$data = bdApi_Data_Helper_Core::filter($profilePost, $publicKeys);
if (isset($profilePost['message_state'])) {
switch ($profilePost['message_state']) {
case 'visible':
$data['post_is_published'] = true;
$data['post_is_deleted'] = false;
break;
case 'moderated':
$data['post_is_published'] = false;
$data['post_is_deleted'] = false;
break;
case 'deleted':
$data['post_is_published'] = false;
$data['post_is_deleted'] = true;
break;
}
}
if (isset($profilePost['like_date'])) {
$data['post_is_liked'] = !empty($profilePost['like_date']);
}
$data['links'] = array('permalink' => XenForo_Link::buildPublicLink('profile-posts', $profilePost), 'detail' => bdApi_Data_Helper_Core::safeBuildApiLink('profile-posts', $profilePost), 'timeline' => bdApi_Data_Helper_Core::safeBuildApiLink('users/timeline', $user), 'timeline_user' => bdApi_Data_Helper_Core::safeBuildApiLink('users', $user), 'poster' => bdApi_Data_Helper_Core::safeBuildApiLink('users', $profilePost), 'likes' => bdApi_Data_Helper_Core::safeBuildApiLink('profile-posts/likes', $profilePost), 'comments' => bdApi_Data_Helper_Core::safeBuildApiLink('profile-posts/comments', $profilePost), 'report' => bdApi_Data_Helper_Core::safeBuildApiLink('profile-posts/report', $profilePost), 'poster_avatar' => XenForo_Template_Helper_Core::callHelper('avatar', array($profilePost, 'm', false, true)));
$data['permissions'] = array('view' => $this->canViewProfilePost($profilePost, $user), 'edit' => $this->canEditProfilePost($profilePost, $user), 'delete' => $this->canDeleteProfilePost($profilePost, $user), 'like' => $this->canLikeProfilePost($profilePost, $user), 'comment' => $this->canCommentOnProfilePost($profilePost, $user), 'report' => $this->canReportProfilePost($profilePost, $user));
return $data;
}
示例3: actionIndex
/**
* Check and apply the association request.
*
* @return XenForo_ControllerResponse_Redirect|XenForo_ControllerResponse_View
*/
public function actionIndex()
{
$mcAssoc = $this->getMcAssoc();
$inputData = $this->_input->filterSingle('data', XenForo_Input::STRING);
$visitor = XenForo_Visitor::getInstance();
$isAdmin = $visitor['is_admin'];
$visitorName = $visitor['username'];
try {
$data = $mcAssoc->unwrapData($inputData);
$username = $mcAssoc->unwrapKey($data->key);
if ($username != $visitorName) {
throw new Exception("Username does not match.");
}
$this->handleData($visitor, $data);
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink("mc-association/view"));
} catch (Exception $e) {
if ($inputData == null) {
$message = "No data provided.";
} else {
$message = $e->getMessage();
}
$opts = XenForo_Application::get('options');
$message .= "<br /><pre>Credentials in use" . json_encode(["site_id" => $opts->mcAssocSiteId, "instance_secret" => $opts->mcAssocInstanceSecret, "shared_secret" => $opts->mcAssocSharedSecret]) . "</pre>";
return $this->responseView('AssociationMc_ViewPublic_Error', 'association_error', array("exceptionMessage" => $isAdmin ? $message : "Please contact an administrator for more information."));
}
}
示例4: generateHtmlRecurrence
public function generateHtmlRecurrence($days, $amount, $currency, $comment, array $data, XenForo_View $view)
{
$data[] = utf8_strtolower($currency);
$data[] = $amount;
$processorModel = $this->_getProcessorModel();
$itemId = $processorModel->generateItemId('bdshop', XenForo_Visitor::getInstance(), $data);
$processorNames = $processorModel->getProcessorNames();
$processors = array();
foreach ($processorNames as $processorId => $processorClass) {
$processors[$processorId] = bdPaygate_Processor_Abstract::create($processorClass);
}
$recurringInterval = false;
$recurringUnit = false;
if ($days > 0) {
if ($days % 360 == 0) {
$recurringInterval = $days / 365;
$recurringUnit = bdPaygate_Processor_Abstract::RECURRING_UNIT_YEAR;
} elseif ($days % 30 == 0) {
$recurringInterval = $days / 30;
$recurringUnit = bdPaygate_Processor_Abstract::RECURRING_UNIT_MONTH;
} else {
$recurringInterval = $days;
$recurringUnit = bdPaygate_Processor_Abstract::RECURRING_UNIT_DAY;
}
}
return implode('', bdPaygate_Processor_Abstract::prepareForms($processors, $amount, $currency, $comment, $itemId, $recurringInterval, $recurringUnit, array(bdPaygate_Processor_Abstract::EXTRA_RETURN_URL => XenForo_Link::buildPublicLink('full:shop/thanks'))));
}
示例5: _getExtraDataLink
protected function _getExtraDataLink(array $widget)
{
if (XenForo_Application::$versionId > 1040000) {
return XenForo_Link::buildPublicLink('find-new/profile-posts');
}
return parent::_getExtraDataLink($widget);
}
示例6: _log
protected function _log(array $logUser, array $content, $action, array $actionParams = array(), $parentContent = null)
{
$dw = XenForo_DataWriter::create('XenForo_DataWriter_ModeratorLog');
$dw->bulkSet(array('user_id' => $logUser['user_id'], 'content_type' => 'resource_category', 'content_id' => $content['resource_category_id'], 'content_user_id' => $logUser['user_id'], 'content_username' => $logUser['username'], 'content_title' => $content['category_title'], 'content_url' => XenForo_Link::buildPublicLink('resources/categories', $content), 'discussion_content_type' => 'resource_category', 'discussion_content_id' => $content['resource_category_id'], 'action' => $action, 'action_params' => $actionParams));
$dw->save();
return $dw->get('moderator_log_id');
}
示例7: navigationTabs
public static function navigationTabs(&$extraTabs, $selectedTabId)
{
$options = XenForo_Application::get('options');
if (XenForo_Visitor::getInstance()->hasPermission('players', 'view') && $options->displayPlayersTab && $options->displayPlayers) {
$extraTabs['players'] = array('title' => new XenForo_Phrase('players'), 'href' => XenForo_Link::buildPublicLink('full:players'), 'position' => 'home', 'linksTemplate' => 'player_tab_links');
}
}
示例8: _render
protected function _render(array $widget, $positionCode, array $params, XenForo_Template_Abstract $renderTemplateObject)
{
$renderTemplateObject->setParams($params);
if (!isset($params['url'])) {
// try to detect the correct url for different templates
$autoDetectedUrl = false;
switch ($positionCode) {
case 'forum_list':
$autoDetectedUrl = XenForo_Link::buildPublicLink('canonical:forums');
break;
case 'forum_view':
$autoDetectedUrl = XenForo_Link::buildPublicLink('canonical:forums', $params['forum']);
break;
case 'member_view':
// this widget on member_view, seriously?
$autoDetectedUrl = XenForo_Link::buildPublicLink('canonical:members', $params['user']);
break;
case 'resource_author_view':
$autoDetectedUrl = XenForo_Link::buildPublicLink('canonical:resources/authors', $params['user']);
break;
case 'resource_view':
$autoDetectedUrl = XenForo_Link::buildPublicLink('canonical:resources', $params['resource']);
break;
case 'thread_view':
$autoDetectedUrl = XenForo_Link::buildPublicLink('canonical:threads', $params['thread']);
break;
}
if ($autoDetectedUrl !== false) {
$renderTemplateObject->setParam('url', $autoDetectedUrl);
}
}
return $renderTemplateObject->render();
}
示例9: actionConfirm
/**
* Confirms a lost password reset request and resets the password.
*
* @return XenForo_ControllerResponse_Abstract
*/
public function actionConfirm()
{
$userId = $this->_input->filterSingle('user_id', XenForo_Input::UINT);
if (!$userId) {
return $this->responseError(new XenForo_Phrase('no_account_specified'));
}
$confirmationModel = $this->_getUserConfirmationModel();
$confirmation = $confirmationModel->getUserConfirmationRecord($userId, 'password');
if (!$confirmation) {
if (XenForo_Visitor::getUserId()) {
// probably already been reset
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL, XenForo_Link::buildPublicLink('index'));
} else {
return $this->responseError(new XenForo_Phrase('your_password_could_not_be_reset'));
}
}
$confirmationKey = $this->_input->filterSingle('c', XenForo_Input::STRING);
if ($confirmationKey) {
$accountConfirmed = $confirmationModel->validateUserConfirmationRecord($confirmationKey, $confirmation);
} else {
$accountConfirmed = false;
}
if ($accountConfirmed) {
$confirmationModel->resetPassword($userId);
$confirmationModel->deleteUserConfirmationRecord($userId, 'password');
XenForo_Visitor::setup(0);
return $this->responseMessage(new XenForo_Phrase('your_password_has_been_reset'));
} else {
return $this->responseError(new XenForo_Phrase('your_password_could_not_be_reset'));
}
}
示例10: actionDiscordLink
public function actionDiscordLink()
{
$this->_assertPostOnly();
$visitor = XenForo_Visitor::getInstance();
if (!$visitor->hasPermission('general', 'linkDiscord')) {
return $this->responseNoPermission();
}
$tokenModel = $this->_getTokenmodel();
$generate = $this->_input->filterSingle('create', XenForo_Input::STRING, array('default' => ''));
if (strlen($generate)) {
$dw = XenForo_DataWriter::create('DiscordAuth_DataWriter_Token');
$existing = $tokenModel->getTokenByUserId($visitor['user_id']);
if ($existing === false || !$existing['valid']) {
if ($existing !== false) {
$dw->setExistingData($existing, true);
}
try {
$dw->set('user_id', $visitor['user_id']);
$dw->set('token', self::generateToken());
$dw->save();
// self::generateToken may throw Exception
} catch (Exception $e) {
XenForo_Error::logException($e, false);
}
}
}
$unlink = $this->_input->filterSingle('unlink', XenForo_Input::STRING, array('default' => ''));
if (strlen($unlink)) {
$dw = XenForo_DataWriter::create('XenForo_DataWriter_User');
$dw->setExistingData($visitor['user_id']);
$dw->set('da_discord_id', null);
$dw->save();
}
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(XenForo_Link::buildPublicLink('account/discord')));
}
示例11: actionSigPicUpload
public function actionSigPicUpload()
{
$this->_assertPostOnly();
if (!XenForo_Visitor::getInstance()->hasPermission('signature', 'sigpic')) {
return $this->responseNoPermission();
}
$sigpic = XenForo_Upload::getUploadedFile('sigpic');
$sigpicModel = $this->getModelFromCache('TPUSigPic_Model_SigPic');
$visitor = XenForo_Visitor::getInstance();
$inputData = $this->_input->filter(array('delete' => XenForo_Input::UINT));
if ($sigpic) {
$sigpicData = $sigpicModel->uploadSigPic($sigpic, $visitor['user_id'], $visitor->getPermissions());
} else {
if ($inputData['delete']) {
$sigpicData = $sigpicModel->deleteSigPic(XenForo_Visitor::getUserId());
}
}
if (isset($sigpicData) && is_array($sigpicData)) {
foreach ($sigpicData as $key => $val) {
$visitor[$key] = $val;
}
}
$message = new XenForo_Phrase('upload_completed_successfully');
if ($this->_noRedirect()) {
// TODO
} else {
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('account/signature'), $message);
}
}
示例12: actionDelete
public function actionDelete()
{
$tag = $this->_getTagOrError();
$tagDw = XenForo_DataWriter::create('sonnb_XenGallery_DataWriter_Tag');
$tagDw->setExistingData($tag, true);
$tagDw->delete();
switch ($tag['content_type']) {
case sonnb_XenGallery_Model_Album::$contentType:
$redirectTarget = XenForo_Link::buildPublicLink('gallery/albums', array('album_id' => $tag['content_id']));
break;
default:
$content = $this->_getContentModel()->getContentById($tag['content_id']);
$redirectTarget = $this->_buildLink('gallery/' . $content['content_type'] . 's', $content);
break;
}
if ($this->_request->isXmlHttpRequest() && $tag['content_type'] !== sonnb_XenGallery_Model_Album::$contentType) {
$this->_routeMatch->setResponseType('json');
$content = $this->_getContentModel()->getContentById($tag['content_id']);
if (!empty($photo['tagUsers'])) {
$content['tagUsers'] = $this->_getTagModel()->getTagsByContentId($content['content_type'], $content['content_id'], array('tag_state' => 'accepted'));
}
return $this->responseView('sonnb_XenGallery_ViewPublic_Tag_Delete', '', array('content' => $content));
} else {
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $redirectTarget);
}
}
示例13: navTabsListener
/**
*
* Adds the "Chat" tab with permission-based links.
*
* @param array $extraTabs
* @param unknown_type $selectedTabId
*/
public static function navTabsListener(array &$extraTabs, $selectedTabId)
{
if (XenForo_Visitor::getInstance()->hasPermission('modm_ajaxchat', 'ajax_chat_view')) {
$perms = array("canModerateChat" => XenForo_Visitor::getInstance()->hasPermission('modm_ajaxchat', 'ajax_chat_mod_access'), "canAccessChat" => XenForo_Visitor::getInstance()->hasPermission('modm_ajaxchat', 'ajax_chat_user_access') || XenForo_Visitor::getInstance()->hasPermission('modm_ajaxchat', 'ajax_chat_guest_access'));
$extraTabs['chat'] = array('title' => new XenForo_Phrase('modm_ajaxchat_tabname'), 'href' => $perms['canAccessChat'] ? XenForo_Link::buildPublicLink('chat/login') : XenForo_Link::buildPublicLink('chat/online'), 'position' => 'middle', 'linksTemplate' => 'modm_ajaxchat_nav_links', 'perms' => $perms);
}
}
示例14: getSessionActivityDetailsForList
public static function getSessionActivityDetailsForList(array $activities)
{
$categoryIds = array();
foreach ($activities as $activity) {
if (!empty($activity['params']['category_id'])) {
$categoryIds[$activity['params']['category_id']] = intval($activity['params']['category_id']);
}
}
$categoryData = array();
if ($categoryIds) {
/* @var $categoryModel SimplePortal_Model_Category */
$categoryModel = XenForo_Model::create('SimplePortal_Model_Category');
$categories = $categoryModel->getCategories(array('category_id' => $categoryIds));
foreach ($categories as $category) {
$categoryData[$category['category_id']] = array('title' => $category['title'], 'url' => XenForo_Link::buildPublicLink('portal/categories', $category));
}
}
$output = array();
foreach ($activities as $key => $activity) {
$category = false;
if (!empty($activity['params']['category_id'])) {
$categoryId = $activity['params']['category_id'];
if (isset($categoryData[$categoryId])) {
$category = $categoryData[$categoryId];
}
}
if ($category) {
$output[$key] = array(new XenForo_Phrase('el_portal_viewing_portal'), $category['title'], $category['url'], false);
} else {
$output[$key] = new XenForo_Phrase('el_portal_viewing_portal');
}
}
return $output;
}
示例15: getVisibleModerationQueueEntriesForUser
/**
* Gets visible moderation queue entries for specified user.
*
* @see XenForo_ModerationQueueHandler_Abstract::getVisibleModerationQueueEntriesForUser()
*/
public function getVisibleModerationQueueEntriesForUser(array $contentIds, array $viewingUser)
{
/** @var XenForo_Model_ProfilePost $profilePostModel */
$profilePostModel = XenForo_Model::create('XenForo_Model_ProfilePost');
$comments = $profilePostModel->getProfilePostCommentsByIds($contentIds);
$profilePostIds = XenForo_Application::arrayColumn($comments, 'profile_post_id');
$profilePosts = $profilePostModel->getProfilePostsByIds($profilePostIds, array('join' => XenForo_Model_ProfilePost::FETCH_USER_RECEIVER | XenForo_Model_ProfilePost::FETCH_USER_RECEIVER_PRIVACY | XenForo_Model_ProfilePost::FETCH_USER_POSTER, 'visitingUser' => $viewingUser));
$output = array();
foreach ($comments as $key => &$comment) {
if (isset($profilePosts[$comment['profile_post_id']])) {
$comment['profilePost'] = $profilePosts[$comment['profile_post_id']];
$comment['profileUser'] = $profilePostModel->getProfileUserFromProfilePost($comment['profilePost'], $viewingUser);
if (!$comment['profilePost'] || !$comment['profileUser']) {
continue;
}
$canManage = true;
if (!$profilePostModel->canViewProfilePostAndContainer($comment['profilePost'], $comment['profileUser'], $null, $viewingUser)) {
$canManage = false;
} else {
if (!$profilePostModel->canViewProfilePostComment($comment, $comment['profilePost'], $comment['profileUser'], $null, $viewingUser)) {
$canManage = false;
} else {
if (!XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'editAny') || !XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'deleteAny')) {
$canManage = false;
}
}
}
if ($canManage) {
$output[$comment['profile_post_comment_id']] = array('message' => $comment['message'], 'user' => array('user_id' => $comment['user_id'], 'username' => $comment['username']), 'title' => new XenForo_Phrase('profile_post_comment_by_x', array('username' => $comment['username'])), 'link' => XenForo_Link::buildPublicLink('profile-posts/comments', $comment), 'contentTypeTitle' => new XenForo_Phrase('profile_post_comment'), 'titleEdit' => false);
}
}
}
return $output;
}