Extension:AddScriptCss
|
AddScriptCss Release status: stable |
|
|---|---|
| Implementation | Tag, Parser function |
| Description | |
| Author(s) | Jean-Lou Dupont |
| Last version | 1.0.0 |
| MediaWiki | 1.10, 1.11 |
| License | No license specified |
| Download | SVN See SVN ($Id: AddScriptCss.php 822 2007-09-30 13:28:36Z jeanlou.dupont $) |
| Check usage and version matrix | |
Contents |
Purpose [edit]
Inserts <script> (i.e. Javascript) or <link> (i.e. CSS) code at the bottom of the page's head or within the page's body. Securely inserts arbitrary code to the page's head using <addtohead>.
Features [edit]
- Security: local files (URI) only
- Files must be located in wiki installation home directory/scripts
<addtohead>some html code here</addtohead>- Security:
- Only pages with restricted editing can access 'addtohead' functionality (i.e. manually protect the page).
- Use global variable '$bwScriptsDirectory' to customize scripts directory
Examples [edit]
<addscript src='local URL' />
- (R1) e.g. <addscript src=/sarissa/sarissa type=js />
- (R2) e.g. {{#addscript: src=/styleinfo|pos=head|type=css}}
- R1) Results in
/home/scripts/sarissa/sarissa.jsbeing added to the page's body section provided the said file exists.
- R2) The CSS file
/home/scripts/styleinfo.csswill be added to the page's HEAD section (provided it exists).
Syntax [edit]
Form 1: <addscript src=filename [type={js|css}] [pos={head|body}] />
Form 2: {{#addscript:src=filename [|type={js|css} [|pos={head|body}] }}
If no 'type' field is present, then the extension assumes 'js'.
If no 'pos' field is present, then the extension assumes 'body'
USAGE NOTES [edit]
- When using 'pos=body', it is recommended to use the extension 'ParserCacheControl' in order to better integrate this extension with the standard MW parser cache.
- Use the global variable
$bwScriptsDirectoryto set a new directory for the scripts- e.g.
$bwScriptsDirectory = 'scripts';will result in$IP.'/'.$scriptsto be used.
- e.g.
Dependency [edit]
- Depends on Extension:StubManager
History [edit]
- Adjusted for new ExtensionClass version (no automatic registering of hooks of ExtensionClass)
- Adjusted singleton invocation to end of file (PHP limitation)
- Imported required functionality from ExtensionClass
- Imported 'addtohead' tag functionality from SecureHTML extension
- Removed dependency on ExtensionClass
- Added support for a global setting '$bwScriptsDirectory'
- Fixed issue when $IP !== $wgScriptPath
1.0.0 [edit]
- Moved to PEAR repository
Installation [edit]
See the Mediawiki Extension table entry "download" above.[1]
LocalSettings.php [edit]
Extension:ExtensionManager: See footnote[2]
- Add the following to LocalSettings.php, if the extension was downloaded from Jean-Lou Dupont's MediaWiki SVN directory (link in the download entry of the table above)[2]:
require_once( "$IP/extensions/AddScriptCss/AddScriptCss.php" );
- Since this Extensions is depending on StubManager, add the line after the StubManager include, or else your Wiki won't work.
PEAR [edit]PEAR is a repository of PHP software code.
require 'MediaWiki/AddScriptCss/AddScriptCss.php';
Upgrades through PEAR [edit]Sometimes, it is necessary to clear PEAR's cache in order to perform upgrades.
or use the force method:
PEAR Web Frontend [edit]For easier remote package management, PEAR Frontend WEB can be installed. Installation notes can be found here. An example of the WEB frontend is available here. |
RSS feed [edit]
To keep up-to-date with this channel, use the following RSS feed__
.
Notes [edit]
Other Extensions From the same author [edit]
Consult User Jldupont's page.
- ↑ The most recent release is always available through the extension's PEAR and SVN repositories. This page is not necessarily up-to-date.
- ↑ 2.0 2.1 2.2 Extension:ExtensionManager does not require any modification to LocalSettings.php because ExtensionManager includes the extension.
Note that if PHP code caching is in place (e.g. APC, eAccelerator), then to successfully complete the installation a cache flush might be needed. - ↑ Modifications to
LocalSettings.phpis only necessary if not using Extension:ExtensionManager
TODO [edit]
- internationalize
- Support for customization of scripts directory without touching LocalSettings.php
See also [edit]
- Extension:CSS - a similar extension allowing stylesheets residing in other articles to be added to the page
- Extension:PageCSS - on-page CSS styles