User:DavidMcCabe/LiquidThreads/FictitousAPI

This is a draft.

This is an overview of what you need to know if you want to extend or embed LiquidThreads.

Classes and Overall Arrangement
LQT follows the model-view-controller pattern as closely as is reasonable within MediaWiki. Here are the classes:

Model:

Handles thread metadata; static method to find an article's threads.
 * Thread

Database-munging related to Posts. A Post is an Article that knows about its position in a thread.
 * Post extends Article

View:

Methods for rendering posts and threads into HTML, as well as editing forms, history, etc. The following three subclasses selectively invoke methods of this classe in order to render the appropriate information and retrieve threads from the right sources.
 * LqtView

Renders entire talk pages.
 * ChannelView extends LqtView

Renders a specific post and its children.
 * PermalinkView extends LqtView

Renders an entire talk page's archive with a permalink to each thread.
 * ArchiveView extends LqtView

Controller:

Handles actions such as move, delete, etc., and redirects to the appropriate view page.
 * LqtController

In general, LQT's accessor methods do not have any ' ' prefix. Thus:

$post = $thread->firstPost; $user = $post->originalAuthor;

If You Want To Look At Threads Programmatically
For bots and so on, you can look at the model directly. If you want to present information about threads in a new way in HTML, it's probably easiest to extend the LqtView class -- see the next section.

The first thing you probably want to do is get a list of threads. The method returns the list of Thread objects that belong to the given Article and that were touched between the two given days (in MediaWiki string format):

$threads = Thread::threadsOfArticle($article, $first_day, $last_day);

Then, you can inspect each thread's metadata and get a pointer to its first Post:

$thread->article; $thread->summary; $thread->touched; $thread->firstPost;

To access the individual Post objects inside a thread, you can use a ThreadIterator object, which implemenst the standard SPL RecursiveIterator interface. For example, this function sets the subject line of each post to "Foo":

function fooifyThread($thread_iterator) { foreach( $thread_iterator as $post ) { $post->setSubject("Foo"); if( $post->hasChildren ) { fooifyThread( $post->getChildren ); }       }    }    fooifyThread( $thread->iterator );

If You Want To Write An Alternate HTML View
The LqtView class provides methods for viewing specific aspects of Liquid Threads which can be used à la carte from a subclass's method. The included classes such as ChannelView and PermalinkView simply invoke different combinations of their parent class's methods, for the most part. And you can do the same.