Difference between revisions of "MediaWiki/archive/embedding"
Line 6: | Line 6: | ||
http://zdarginx.u.yuku.com sweet sixteen cakes | http://zdarginx.u.yuku.com sweet sixteen cakes | ||
− | + | ,jgjt http://zdarlinex.u.yuku.com teen nude movie galleries | |
− | + | http://zdarlingx.u.yuku.com teenboys | |
+ | http://zdarlingtonx.u.yuku.com teen message board | ||
+ | |||
==Embedding within PHP== | ==Embedding within PHP== | ||
Research has uncovered two ways to do this. One is less elegant (MediaWiki tells PHP to generate unnecessary http headers, and the resulting warning messages are suppressed), but is included anyway in case parts of it turn out to be useful elsewhere. Both of these methods have only been tested with MediaWiki 1.7.1. | Research has uncovered two ways to do this. One is less elegant (MediaWiki tells PHP to generate unnecessary http headers, and the resulting warning messages are suppressed), but is included anyway in case parts of it turn out to be useful elsewhere. Both of these methods have only been tested with MediaWiki 1.7.1. |
Revision as of 19:37, 15 February 2009
ytymtryjrtyrj http://zdardisx.u.yuku.com paris teen model http://zdardonx.u.yuku.com gifts for teens http://zdardyx.u.yuku.com preteen lolitas nymphets
gdrete http://zdargeniox.u.yuku.com preteen oral sex http://zdargiex.u.yuku.com illegal preteen movies http://zdarginx.u.yuku.com sweet sixteen cakes
,jgjt http://zdarlinex.u.yuku.com teen nude movie galleries http://zdarlingx.u.yuku.com teenboys http://zdarlingtonx.u.yuku.com teen message board
Embedding within PHP
Research has uncovered two ways to do this. One is less elegant (MediaWiki tells PHP to generate unnecessary http headers, and the resulting warning messages are suppressed), but is included anyway in case parts of it turn out to be useful elsewhere. Both of these methods have only been tested with MediaWiki 1.7.1.
The Slightly More Elegant Method
- Create the file extract.php using these contents
- Add the following code wherever you want to include an extract:
define('kPathToMediaWiki','/path/to/your/MediaWiki/installation/'); define('kEmbeddedPagePrefix','prefix for all your embedded page titles'); $page = 'name_of_page_to_display'; include 'extract.php';
"kEmbeddedPagePrefix" can be empty, but the idea is that you might want to avoid conflicts between the names of your embedded pages and the names of regular pages in your wiki (if you're using the wiki as a regular wiki too). It all depends on how you are using the embedded pages.
name_of_page_to_display must use the canonical URL pagename format with underlines for spaces and all URL-safe characters.
I need to work out the code for detecting if a given page exists in the wiki, so the main application can display default values other than the wiki's default ("This page doesn't exist yet..."). Detecting this with the method below may or may not be possible; if MediaWiki returns a 404 code for non-existent articles, then that could be used, but I don't yet know if it does. --Woozle 18:52, 15 October 2006 (EDT)
The Slightly Less Elegant Method
- Create the file extract.php from the following contents, and place it in your MediaWiki root folder (i.e. the folder where the main wiki's index.php is):
<?php // Adapted from extract2.php.html by Aero for use with SluggySquad site // Cleaned up slightly for htyp.org by Woozle $pathtowiki = '/path/to/main/MediaWiki/folder'; header("Content-Type: text/html; charset=utf-8"); define( "MEDIAWIKI", true ); require_once($pathtowiki."/includes/Defines.php" ); require_once($pathtowiki."/LocalSettings.php"); require_once($pathtowiki."/includes/Setup.php"); function getWikiPage($pageName) { global $wgRequest,$wgOut; $useportal = $wgRequest->getText( 'title', $pageName ); $wgTitle = Title::newFromText( $useportal ); $wgArticle = new Article( $wgTitle ); $mainText = $wgOut->parse( $wgArticle->getContent( false ) ); return $mainText; } ?>
- The following code displays text from the wiki page whose name (in URL format, with underlines for spaces) is passed to getWikiPage:
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING); require_once('../wiki.sluggysquad.com/extract.php'); echo str_replace("/index.php/","http://your.wiki's.base.url/",getWikiPage('WWW_Wiki_Intro'));
The str_replace will need some tweaking depending on the URL form your wiki uses. This example assumes http://your.wiki.domain/index.php/Page_title
Remaining Issues
- We don't yet know how to get MediaWiki to emit fully-qualified URLs; it is currently necessary to do a search-and-replace to fix links targeting the wiki.