本文整理汇总了PHP中XenForo_Link类的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Link类的具体用法?PHP XenForo_Link怎么用?PHP XenForo_Link使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XenForo_Link类的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: actionPromote
public function actionPromote()
{
if (!$this->perms['promote']) {
return $this->responseNoPermission();
}
$input = $this->_input->filter(array('thread_id' => XenForo_Input::UINT, 'promote_date' => XenForo_Input::UINT, 'promote_icon' => XenForo_Input::STRING, 'attach_data' => XenForo_Input::UINT, 'image_data' => XenForo_Input::STRING, 'medio_data' => XenForo_Input::UINT, 'date' => XenForo_Input::STRING, 'hour' => XenForo_Input::UINT, 'mins' => XenForo_Input::UINT, 'ampm' => XenForo_Input::STRING, 'zone' => XenForo_Input::STRING, 'delete' => XenForo_Input::STRING));
$ftpHelper = $this->getHelper('ForumThreadPost');
list($thread, $forum) = $ftpHelper->assertThreadValidAndViewable($input['thread_id']);
if ($this->_request->isPost()) {
$this->getModelFromCache('EWRporta_Model_Promotes')->updatePromotion($input);
$this->getModelFromCache('EWRporta_Model_Caches')->emptyBlockCache(array('block_id' => 'RecentFeatures'));
$this->getModelFromCache('EWRporta_Model_Caches')->emptyBlockCache(array('block_id' => 'RecentNews'));
} else {
$threadPromote = $this->getModelFromCache('EWRporta_Model_Promotes')->getPromoteByThreadId($thread['thread_id']);
$visitor = XenForo_Visitor::getInstance();
$datetime = $threadPromote ? $threadPromote['promote_date'] : $thread['post_date'];
$datetime = new DateTime(date('r', $datetime));
$datetime->setTimezone(new DateTimeZone($visitor['timezone']));
$datetime = explode('.', $datetime->format('Y-m-d.h.i.A.T'));
$datetime = array('date' => $datetime[0], 'hour' => $datetime[1], 'mins' => $datetime[2], 'meri' => $datetime[3], 'zone' => $datetime[4]);
$icons = $this->getModelFromCache('EWRporta_Model_Promotes')->getPromoteIcons($thread);
$viewParams = array('thread' => $thread, 'icons' => $icons, 'threadPromote' => $threadPromote, 'datetime' => $datetime, 'nodeBreadCrumbs' => $ftpHelper->getNodeBreadCrumbs($forum));
return $this->responseView('EWRporta_ViewPublic_Promote', 'EWRporta_Promote', $viewParams);
}
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('threads', $thread));
}
示例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: buildLink
/**
*
* @see XenForo_Route_Prefix_Forums::buildLink()
*/
public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
{
if (isset($data['social_forum_id'])) {
if (ThemeHouse_SocialGroups_SocialForum::hasInstance()) {
$socialForum = ThemeHouse_SocialGroups_SocialForum::getInstance()->toArray();
} else {
$socialForum = $data;
}
$class = XenForo_Application::resolveDynamicClass('ThemeHouse_SocialGroups_Route_Prefix_SocialForums', 'route_prefix');
$router = new $class();
$link = $router->buildLink('social-forums', 'social-forums', $action, $extension, $socialForum, $extraParams);
if (XenForo_Application::isRegistered('routeFiltersOut')) {
$routeFilters = XenForo_Application::get('routeFiltersOut');
if (isset($routeFilters['social-forums'])) {
foreach ($routeFilters['social-forums'] as $filter) {
if (array_key_exists('find_route', $filter) && array_key_exists('replace_route', $filter)) {
list($from, $to) = XenForo_Link::translateRouteFilterToRegex($filter['find_route'], $filter['replace_route']);
$newLink = preg_replace($from, $to, $link);
} else {
$newLink = $link;
}
if ($newLink != $link) {
$link = $newLink;
break;
}
}
}
}
return $link;
}
return parent::buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, $extraParams);
}
示例6: actionTogglePrivate
public function actionTogglePrivate()
{
$this->_assertPostOnly();
$idExists = $this->_input->filterSingle('exists', array(XenForo_Input::UINT, 'array' => true));
$ids = $this->_input->filterSingle('id', array(XenForo_Input::UINT, 'array' => true));
$nodeModel = $this->_getNodeModel();
$nodes = $nodeModel->getAllNodes();
$permissionEntries = $this->_getPermissionModel()->getAllContentPermissionEntriesByTypeGrouped('node');
$privateNodes = array();
foreach ($permissionEntries['system'] as $nodeId => $nodePermissions) {
if (!empty($nodePermissions['general']['viewNode']) && $nodePermissions['general']['viewNode'] == 'reset') {
$privateNodes[$nodeId] = true;
}
}
foreach ($nodes as $nodeId => $node) {
if (isset($idExists[$nodeId])) {
$itemActive = !empty($ids[$nodeId]) ? 1 : 0;
if (!empty($privateNodes[$nodeId]) != $itemActive) {
// TODO: better approach that doesn't rely on every
// permission having "revoke" value
$this->_setPermissionRevokeStatus($node['node_id'], 0, 0, $itemActive);
}
}
}
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('nodes/private', $node));
}
示例7: _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');
}
示例8: _log
/**
* @param array $logUser
* @param array $content
* @param $action
* @param array $actionParams
* @param null $parentContent
* @return mixed
*/
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' => sonnb_XenGallery_Model_Photo::$xfContentType, 'content_id' => $content['content_id'], 'content_user_id' => $content['user_id'], 'content_username' => $content['username'], 'content_title' => XenForo_Helper_String::wordWrapString($content['title'], 140), 'content_url' => XenForo_Link::buildPublicLink('gallery/photos', $content), 'discussion_content_type' => sonnb_XenGallery_Model_Photo::$xfContentType, 'discussion_content_id' => $content['content_id'], 'action' => $action, 'action_params' => $actionParams));
$dw->save();
return $dw->get('moderator_log_id');
}
示例9: buildLink
/**
* Method to build a link to the specified page/action with the provided
* data and params.
*
* @see XenForo_Route_BuilderInterface
*/
public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
{
if (!empty($data['ip_id'])) {
$extraParams['ip_id'] = $data['ip_id'];
}
return XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix, $action, $extension, $data, 'user_id', 'username');
}
示例10: actionSave
/**
* Saves changes to the messages/discussions in the mdoeration queue.
*
* @return XenForo_ControllerResponse_Abstract
*/
public function actionSave()
{
$this->_assertPostOnly();
$queue = $this->_input->filterSingle('queue', XenForo_Input::ARRAY_SIMPLE);
$this->_getModerationQueueModel()->saveModerationQueueChanges($queue);
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('moderation-queue'));
}
示例11: buildLink
public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
{
if ($action == 'categories' && isset($data['categorytitle'])) {
$data['title'] = $data['categorytitle'];
}
return XenForo_Link::buildSubComponentLink($this->_getSubcomponents(), $outputPrefix, $action, $extension, $data);
}
示例12: match
/**
* Attempts to match the routing path. See {@link XenForo_Route_Interface} for further details.
*
* @param string $routePath Routing path
* @param Zend_Controller_Request_Http $request Request object
* @param XenForo_Router $router Routing object
*
* @return XenForo_RouteMatch|bool
*/
public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
{
if (!XenForo_Application::isRegistered('routeFiltersIn')) {
return false;
}
$filters = XenForo_Application::get('routeFiltersIn');
if (!$filters) {
return false;
}
foreach ($filters as $filter) {
if (isset($filter['match_regex'])) {
$from = $filter['match_regex'];
$to = $filter['match_replace'];
} else {
list($from, $to) = XenForo_Link::translateRouteFilterToRegex(urldecode($filter['replace_route']), urldecode($filter['find_route']));
}
$newRoutePath = preg_replace($from, $to, $routePath);
if ($newRoutePath != $routePath) {
$match = $router->getRouteMatch();
$match->setModifiedRoutePath($newRoutePath);
return $match;
}
}
return false;
}
示例13: _pageContainer
protected function _pageContainer()
{
$threadLinkString = 'threadLinkString';
$threadLink = XenForo_Link::buildPublicLink($threadLinkString);
$prefix = rtrim(str_replace($threadLinkString, '', $threadLink), '/');
//TODO Global Variable
if (!isset($GLOBALS['ThreadInOverlay_overlayLinks'])) {
return;
}
foreach ($GLOBALS['ThreadInOverlay_overlayLinks'] as $link => $action) {
$linkPrefixed = $prefix . $link;
$regEx = '/<a href="' . preg_quote($linkPrefixed, '/') . '"[^>]*>/i';
$offset = 0;
$matches = array();
do {
$matched = preg_match($regEx, $this->_contents, $matches, PREG_OFFSET_CAPTURE, $offset + 1);
if ($matched) {
$offset = $matches[0][1];
$found = $matches[0][0];
if (strpos($found, 'class="') !== false) {
// there is a class attribute already
if (strpos($found, 'OverlayTrigger') === false) {
$replacement = str_replace('class="', 'class="OverlayTrigger ', $found);
}
} else {
// no class yet
$replacement = str_replace('<a', '<a class="OverlayTrigger"', $found);
}
// all seems find, update content now
$this->_contents = substr_replace($this->_contents, $replacement, $offset, strlen($found));
}
} while ($matched);
}
}
示例14: getBreadcrumbsForContent
public function getBreadcrumbsForContent(array $content)
{
$breadCrumbs = $this->_getCategoryModel()->getCategoryBreadcrumb($content);
$breadCrumbs = array_values($breadCrumbs);
$breadCrumbs[] = array('href' => XenForo_Link::buildPublicLink('full:resources', $content), 'value' => $content['title']);
return $breadCrumbs;
}
示例15: getVisibleModerationQueueEntriesForUser
/**
* Gets visible moderation queue entries for specified user.
*
* @see XenForo_ModerationQueueHandler_Abstract::getVisibleModerationQueueEntriesForUser()
*/
public function getVisibleModerationQueueEntriesForUser(array $contentIds, array $viewingUser)
{
/* @var $profilePostModel XenForo_Model_ProfilePost */
$profilePostModel = XenForo_Model::create('XenForo_Model_ProfilePost');
$profilePosts = $profilePostModel->getProfilePostsByIds($contentIds);
$profileUserIds = array();
foreach ($profilePosts as $profilePost) {
$profileUserIds[] = $profilePost['profile_user_id'];
}
$users = XenForo_Model::create('XenForo_Model_User')->getUsersByIds($profileUserIds, array('join' => XenForo_Model_User::FETCH_USER_PRIVACY, 'followingUserId' => $viewingUser['user_id']));
$output = array();
foreach ($profilePosts as $profilePost) {
if (!isset($users[$profilePost['profile_user_id']])) {
continue;
}
$user = $users[$profilePost['profile_user_id']];
$canManage = true;
if (!$profilePostModel->canViewProfilePostAndContainer($profilePost, $user, $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[$profilePost['profile_post_id']] = array('message' => $profilePost['message'], 'user' => array('user_id' => $profilePost['user_id'], 'username' => $profilePost['username']), 'title' => new XenForo_Phrase('profile_post_for_x', array('username' => $user['username'])), 'link' => XenForo_Link::buildPublicLink('profile-posts', $profilePost), 'contentTypeTitle' => new XenForo_Phrase('profile_post'), 'titleEdit' => false);
}
}
return $output;
}