Extension:APF - Advanced Page Functions

Why would you want to use this extension
When you're looking to add functionality to your MediaWiki you'll want to minimize the time you spend adding, checking and updating extensions. If you are looking for an extension that provides the most commonly requested page layout functions in one package then this extension should meet your needs. This extension is built to the latest MediaWiki standards, it already combines the functionality of twenty smaller extensions and new functionality is being added with each monthly release.

What can this extension do?
The current beta 03 code allows you to:


 * 1) Change the heading that appears at the top of an article
 * 2) Change the name of the page that appears at the top of the browser
 * 3) Set the meta description that will be used in a search engine listing.
 * 4) Set the meta keywords that are used by some search engines.
 * 5) Append to the default meta keywords that are used by some search engines
 * 6) Add custom meta information
 * 7) Add per page inline CSS
 * 8) Add per page CSS from an external file
 * 9) Change the robots meta setting so that search engines will not index a page
 * 10) Add raw content from a file directly to a page
 * 11) Embed a flash movie anywhere on a page using two different formats for the source code
 * 12) Add content from an external file to your page

The beta 04 code will also allow you to:


 * 1) Embed a YouTube movie on a page

Adding or changing Page Meta Information
Usage

When in the editor you can add the following page functions anywhere on your page.

"This page function is used to change the heading that appears at the top of the article page. It does this by modifying the text that appears on the article page for the H1 element with id='firstHeading' and class='firstHeading. The article will still be stored in your wiki with the original name and the only thing this function changes is the name that appears on your screen."

"This page function is used to change the name of the page that appears in the top of the browser window and on search engines. It does this by changing the text within the element that appear inside of the element on the browser page. Search engines like Google will use the title as part of their page ranking. Even though google cuts off the display at roughly 63-64 characters (depending on your own word breaks), it will read beyond what is actually shown and use what is after the ellipses (...) as a ranking factor. Some other engines also display more. Yahoo! recommends 67 characters as a limit. To be safe I recommend that you try to keep the lenght of the title to less than 70 characters if you don't want the title to be trucated."

"This page function is used to set the page meta description. It does this my adding the description to the  tag.The meta description tag allows you to influence the description of your page in the search engines that support the tag."

"This page function is used to set the page meta keywords"

"This page function is used to add to the page meta keywords"

"This page function is used to add to add custom meta information"

Example

Adding or changing CSS on your page
Usage

When you're in the editor you can add the following page functions anywhere on your page.

"This page function can be used to add additional inline custom CSS styles to a page. To use the function, replace with the CSS style commands, edit your page and place one or more of these page functions anywhere on the page. The CSS will always be added to the top of your MediaWiki page when the page is generated. If you have more than one call then the CSS styles from each call will be added in the order that the functions appear on the page." "To add CSS styles from a file(s) that you have placed in the /extensions/APF/CSS directory, replace with the name of the file containing your CSS styles, and enter the page function(s) anywhere on your page. If you prefer to store your CSS files in another directory then set the $apfCssDir global variable in your LocalSettings.php file. For example: $apfCssDir = 'C:\wamp\www\wiki5\mw\extensions\APF\CSS_FILES';"

You can add one or more of each of these page functions and if you use both of them on a page then the extension will always add the inline CSS styles from the   function calls after the import commands that are generated by the    function calls. This allows you to fine-tune the CSS on the page and override CSS styles that were added from the imported files.

Example

Code added to a page in the editor window:

Code that this extension will add to your HTML before it is sent to the browser:  @import '/wiki5/mw/extensions/APF/CSS/sample.css'; @import '/wiki5/mw/extensions/APF/CSS/sample1.css'; background-color: red; } background-color: black; }
 * 1) content h1,h2,h3 {color: #fff000;}
 * 2) footer {
 * 1) header {

Notes


 * 1) page.cssd - A sanity check on the CSS is performed. This check stops a user from entering various words such as 'expression', 'http', 'https', 'ftp', 'url' etc.
 * 2) page.cssf - When you click save then an error message will be generated if you attempt to use a file not in the /extensions/APF/CSS directory or the directory that you have specified by adding an entry for the $apfCssDir variable in your LocalSettings.php file.

Adding a Flash movie to your page
Usage

When you're in the editor you can add the following page functions anywhere on your page.

"Adds a flash movie from the /images directory to your page. When using this function you can specify any of the following parameters for the flash movie: align, base, bgcolor, classid, codebase, devicefont, file, height, loop, movie, menu, play, quality, salign, scale, src, swliveconnect, width, wmode. Use of any other parameter will result in an error message."

"Adds a flash movie in the same way as page.swf1 however the generated HTML code is more suitable for older browsers."

Example

Code added to a page in the editor window:

Code that this extension will add to your HTML before it is sent to the browser: &lt;object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='400' height='250' id='/wiki5/mw/images/filename.swf' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0'&gt; &lt;param name='movie' value='/wiki5/mw/images/filename.swf'&gt; &lt;embed src='/wiki5/mw/images/filename.swf' width='400' height='250' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'&gt; &lt;/embed&gt;&lt;/object&gt;

&lt;object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='400' height='250'&gt; &lt;param name='movie' value='/wiki5/mw/images/filename.swf' /&gt; &lt;!--[if !IE]&gt;--&gt; &lt;object type='application/x-shockwave-flash' data='/wiki5/mw/images/filename.swf' width='400' height='250'&gt; &lt;!--&lt;![endif]--&gt; &lt;p&gt;Alternative content&lt;/p&gt; &lt;!--[if !IE]&gt;--&gt; &lt;/object&gt; &lt;!--&lt;![endif]--&gt; &lt;/object&gt;

Notes


 * You must use the 'file=' parameter to specify the flash movie filename.
 * If you do not specify them then the following defaults apply:
 * height=500px
 * width=500px
 * The default directory searched for swf files is /images. You can specify an alternate directory by setting the $apfSwfDir global variable in your LocalSettings.php file. For example: $apfSwfDir = "C:\wamp\www\wiki5\mw\extensions\APF\SWF_FILES";
 * An error message will be generated if you attempt to use a file not in the /images or user specified directory.

Adding content from a file to your page
Usage

"To add content from a file(s) that you have placed in the /extensions/APF/FILE directory, replace with the name of the file, and enter the page function(s) anywhere on your page. If you prefer to store the files in another directory then you change the source directory by setting $apfFileDir global variable in your LocalSettings.php file. For example: $apfFileDir = 'C:\wamp\www\wiki5\mw\extensions\APF\DATA_FILES';"

Example

Download Instructions
Please download the zip release containing code files and place the files in the following directory:

/APF.i18n.magic.php /APF.i18n.php /APF_setup.php /CSS/sample.css /FILE/filename.txt /includes/APF.php /includes/APF_HTML.php /includes/APF_Tag.php

Internationalization Instructions
If you need to internationalize this extension make changes to the following files:


 * 1) /APF.i18n.magic.php
 * 2) /APF.i18n.php

Check the contents of the files for more information on what you will need to change to internationalize the functions for your language.

Installation

 * 1) In the directory in $IP/extensions create a new directory APF - where $IP is your MediaWiki installation directory.
 * 2) Copy the extension directories and files into the APF directory you just created
 * 3) Add the following line to the bottom of the LocalSettings.php in your MediaWiki installation directory: require_once('extensions/APF/APF.php');
 * 4) Modify the files: APF.i18n.magic.php and APF.i18n.php if you need to internationalize this extension for another language.
 * 5) If you use the page.cssf function then store your files in the  /extensions/APF/CSS directory
 * 6) If you use the page.swf1 function and if you want to allow users to upload their own swf files then add $wgFileExtensions[] = 'swf'; to LocalSettings.php. Files uploaded by users will be uploaded to the /images directory

Code
You can download zip files containing the extension code and sample files from this page: Download Snapshot.

Bugs, Comments and Feature Requests
At this stage in the development process my focus is on providing additional functionality with each new beta release. If you have a chance to try out this extension then I would very much appreciate your feed back if you are find any bugs. Please use the comment area on this page to notify me about bugs that you find and also tell if you have any feature requests: Bugs, Comments and Feature Requests

Dependency

 * No dependencies when used with MediaWiki 1.14 and above