Giter VIP home page Giter VIP logo

Comments (5)

Eisteed avatar Eisteed commented on August 18, 2024 1

Okay easier than I thought, but I don't know if this is a proper way to do it. I added another function to threadpreview

function threadpreview_getPreview($thread)
{
	global $mybb, $db, $tids, $threadcache, $thread, $firstpostcache;
	$query = $db->query("SELECT t.tid, t.firstpost, p.message
			FROM " . TABLE_PREFIX . "threads t
			LEFT JOIN " . TABLE_PREFIX . "posts p
			ON(t.firstpost=p.pid)
			WHERE t.tid IN(" . $thread['tid'] . ")");
	while($data = $db->fetch_array($query))
	{
		$firstpostcache[$data['tid']] = replaceMedia($data['message']);
		//$firstpostcache[$data['tid']] = substr($data['message'], 0, (int)$mybb->settings['threadpreview_maxlength']);
		//$threadcache[$data['tid']]['preview'] = $data['message'];
	}

	// MangaD - parse mycode, smilies...
	global $parser;
	if(!$parser)
	{
		require_once MYBB_ROOT."inc/class_parser.php";
		$parser = new postParser;
	}

	$parser_options = array(
		"allow_html" => (int)$mybb->settings['pmsallowhtml'],
		"allow_mycode" => (int)$mybb->settings['pmsallowmycode'],
		"allow_smilies" => (int)$mybb->settings['pmsallowsmilies'],
		"allow_imgcode" => (int)$mybb->settings['pmsallowimgcode'],
		"allow_videocode" => (int)$mybb->settings['pmsallowvideocode'],
		"nofollow_on" => 1,
		"filter_badwords" => 1
	);

	$thread['preview'] = $parser->parse_message($firstpostcache[$thread['tid']], $parser_options);
	$thread['preview'] = truncateHTML((int)$mybb->settings['threadpreview_maxlength'], $thread['preview']);
}

then inside endless I can call threadpreview_getPreview with the current $thread being created as argument.

from mybb-thread-preview.

MangaD avatar MangaD commented on August 18, 2024

Hello, I am not familiar with the endless plugin and have no intention to support it. But as this project is open source, anyone is welcome to contribute.

from mybb-thread-preview.

Eisteed avatar Eisteed commented on August 18, 2024

Alright ;( I don't know much about mybb plugins dev but I will try to find a fix.

from mybb-thread-preview.

MangaD avatar MangaD commented on August 18, 2024

The only problem I see is that there's a reference to the $thread global variable inside the function, that possibly conflicts with the argument.

from mybb-thread-preview.

Eisteed avatar Eisteed commented on August 18, 2024

Yea I wasn't sure about how to use those but it's working like that ^^
Removing $thread returns an empty $thread['preview']

from mybb-thread-preview.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.