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 heading, article name and page description
"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 / title of the page that appears in the top of the browser window, in search engines and as the words to describe your page when someone adds it to their 'Favorites' or 'Bookmarks' lists.. The text you use in the page.name tag is one of the most important factors in how a search engine may decide to rank your web page. In use the function changes the title by placing the text you specify inside of the tag. 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 but depending on word breaks it will show up to 72. To be safe I recommend that you try to keep the length 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. Here's some advice from Google about what to include in a description. There are exceptions but the typical maximum character lengths are Bing (185), Yahoo (161)an Google (156). With this in mind I suggest you try to keep the length of your description to less than 150 characters."

Adding or changing keywords and page meta information
"This page function is used to set the page meta keywords. These keywords are officially no longer used by the larger search engines however if you still want to use them then it's generally considered that the length of the keywords should be less than 255 characters and the same keyword should not appear more than three times in the string. By default MediaWiki assigns default meta keywords from the headings and links that it finds on a page. Often these are not appropriate and you can use this function to replace the existing keywords. This function replaces the text in the content area of the  on your source page." "By default MediaWik takes the title, categories, existing and broken links for the page and uses the first 10 of them for META keywords. This function allows you to leave the default choices and add additional keywords. When you use this function you should consider the points made above regarding the way search engines use the keywords. If you want to check the default links that MediaWiki has chosen then check the source code of the page and look for the  string that MediaWiki creates in the header area. After you've added new keywords and saved the page you have edit check the source and you will see new keywords have been added." "This page function is used to add to add custom meta information"

Adding or changing CSS on your page
Use these functions to add new CSS to your page. If you use both of these functions on your page then the CSS generated from the page.cssd will take precedence over that from page.cssf as it will appear later. This allows you to fine-tune the CSS on the page and override CSS styles that were added from the imported files.

"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. When you use this function 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." "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';. 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. 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
"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."

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
"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

Examples of how to use these functions
To use the functions edit a page and then enter the function calls in the source window. With the exception of the functions that are position defendant I would suggest you add the function calls to the top area of the edit window where you can easily see them should you want to go back and make changes.


 * Adding or changing page heading, article name and page description:


 * 1) Page functions added in the editor: ###


 * 1) Results in the following code added to your HTML source: ###

Cebu Hotels in Philippines  Cebu Hotel


 * Adding or changing keywords and page meta information:


 * 1) Page functions added in the editor: ###


 * 1) Results in the following code added to your HTML source: ###

  


 * Adding or changing CSS on your page


 * 1) Code added in the editor: ###


 * 1) Results in the following code added to your HTML source: ###

 @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 {


 * Adding a Flash movie to your page


 * 1) Code added in the editor: ###


 * 1) Results in the following code added to your HTML source: ###

&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;

Download Instructions
Download the extension files from the latest Zip download Snapshot containing the following files:

/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

and place these files in the following MediaWiki directory on your server:

"$IP/extensions/APF/"

$IP is your MediaWiki installation directory and if it doesn't already exist you must create a directory in the $IP/extensions directory named APF. All files and directories must be in this directory as the extension expects you to use this directory naming convention. Each new download snapshot of the software is a complete release and does not depend on any files from a previous release being present.

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