Extension:AddScriptCss
From MediaWiki.org
|
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 (experimental) |
|
Contents |
[edit] Purpose
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>.
[edit] Features
- 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
[edit] Examples
<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).
[edit] Syntax
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'
[edit] USAGE NOTES
- 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.
[edit] Dependency
- Depends on Extension:StubManager
[edit] History
- 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
[edit] 1.0.0
- Moved to PEAR repository
[edit] Installation
See the Mediawiki Extension table entry "download" above.[1]
[edit] LocalSettings.php
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" );
[edit] PEARPEAR is a repository of en:PHP software code.
require 'MediaWiki/AddScriptCss/AddScriptCss.php';
[edit] Upgrades through PEARSometimes, it is necessary to clear PEAR's cache in order to perform upgrades.
or use the force method:
[edit] PEAR Web FrontendFor 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. |
[edit] RSS feed
To keep kept up-to-date with this channel, use the following RSS feed__
.
[edit] Notes
[edit] Other Extensions From the same author
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
[edit] TODO
- internationalize
- Support for customization of scripts directory without touching LocalSettings.php
[edit] See also
- Extension:CSS - a similar extension allowing stylesheets residing in other articles to be added to the page
- Extension:PageCSS - on-page CSS styles