Hello, I have allready programmed mediawiki extensions but no skins.
I have 2 issues:
1) In the extension I can made a file ext.i18n.php and then use: $wgExtensionMessagesFiles['ext'] = dirname( __FILE__ ) . 'ext.i18n.php'; wfMsg('something');
With skins it doesn't work. Can you help me?
2) How to get the full url of a skin image?
thanks all! regards, ADM
On Mon, 23 Jul 2012 15:02:16 -0700, Adm linuxloverstaff@gmail.com wrote:
Hello, I have allready programmed mediawiki extensions but no skins.
Read over the tutorials I have on skinning MediaWiki 1.18+
http://blog.redwerks.org/2012/02/08/mediawiki-skinning-tutorial/ http://blog.redwerks.org/2012/02/28/mediawiki-subskin-tutorial/
I have 2 issues:
- In the extension I can made a file ext.i18n.php and then use:
$wgExtensionMessagesFiles['ext'] = dirname( __FILE__ ) . 'ext.i18n.php'; wfMsg('something');
With skins it doesn't work. Can you help me?
The tutorial covers this.
You should consider the skins/SkinName.php pattern deprecated, and only use it for built-in skins now.
Construct your skins using the pattern: skins/myskinname/myskinname.php skins/myskinname/myskinname.i18n.php skins/myskinname/MySkinName.skin.php
The naming of MySkinName.skin.php doesn't really matter, but that file will be the equivalent of what you used to put in skins/MySkinName.php. With this pattern you'll have a skins/myskinname/myskinname.php file which you can add the i18n file to and setup the autoloading and resource loader modules. Just like an extension you'll install your skin by using `require_once( "$IP/skins/myskinname/myskinname.php" );`... for now.
- How to get the full url of a skin image?
Put as many images as possible inside of your css files instead of in the output. ResourceLoader handles your images extremely well if you put them in the module css.
If you absolutely must use a path inside your source you can use `$tpl->getSkin()->getSkinStylePath( 'myimage.png' )` to get the absolute path to 'skins/myskinname/myimage.png' (ie: the name is relative to the base of your skin folder) and echo that into your markup (PLEASE do use the Html:: class or escape it with htmlspecialcharacters if you echo it directly).
thanks all! regards, ADM
Il giorno lun, 23/07/2012 alle 15.39 -0700, Daniel Friesen ha scritto:
Read over the tutorials I have on skinning MediaWiki 1.18+
http://blog.redwerks.org/2012/02/08/mediawiki-skinning-tutorial/ http://blog.redwerks.org/2012/02/28/mediawiki-subskin-tutorial/
I have 2 issues:
- In the extension I can made a file ext.i18n.php and then use:
$wgExtensionMessagesFiles['ext'] = dirname( __FILE__ ) . 'ext.i18n.php'; wfMsg('something');
With skins it doesn't work. Can you help me?
The tutorial covers this.
You should consider the skins/SkinName.php pattern deprecated, and only use it for built-in skins now.
Construct your skins using the pattern: skins/myskinname/myskinname.php skins/myskinname/myskinname.i18n.php skins/myskinname/MySkinName.skin.php
The naming of MySkinName.skin.php doesn't really matter, but that file will be the equivalent of what you used to put in skins/MySkinName.php. With this pattern you'll have a skins/myskinname/myskinname.php file which you can add the i18n file to and setup the autoloading and resource loader modules. Just like an extension you'll install your skin by using `require_once( "$IP/skins/myskinname/myskinname.php" );`... for now.
oh! ok! I'm sorry, I have read the mediawiki.org documentation for both my module and my skin but it seems not very updated.
thanks! ADM
Il giorno lun, 23/07/2012 alle 15.39 -0700, Daniel Friesen ha scritto:
http://blog.redwerks.org/2012/02/08/mediawiki-skinning-tutorial/ http://blog.redwerks.org/2012/02/28/mediawiki-subskin-tutorial/
Following the first tutorial:
PHP Fatal error: Class 'MySkin' not found in /var/www/mediawiki-1.19.1/includes/SkinTemplate.php on line 126
Why? ADM
On Mon, 23 Jul 2012 17:29:40 -0700, linuxlover linuxloverstaff@gmail.com wrote:
Il giorno lun, 23/07/2012 alle 15.39 -0700, Daniel Friesen ha scritto:
http://blog.redwerks.org/2012/02/08/mediawiki-skinning-tutorial/ http://blog.redwerks.org/2012/02/28/mediawiki-subskin-tutorial/
Following the first tutorial:
PHP Fatal error: Class 'MySkin' not found in /var/www/mediawiki-1.19.1/includes/SkinTemplate.php on line 126
Why? ADM
You don't appear to have actually followed the tutorial. "For our tutorial let’s ignore the existence of a skin called ‘MySkin’ in MediaWiki and call ours “My Skin” for tutorial purposes. You should come up with a name of your own for your skin." You shouldn't end up with anything called MySkin.
Given that is wrong from the start I'll need to see your actual skin code to help you fix whatever's wrong.
Il giorno lun, 23/07/2012 alle 15.39 -0700, Daniel Friesen ha scritto:
On Mon, 23 Jul 2012 15:02:16 -0700, Adm linuxloverstaff@gmail.com wrote:
http://blog.redwerks.org/2012/02/08/mediawiki-skinning-tutorial/
I think there is an error in the tutorial: class MySkinTemplate extends BaseTemplate {
Replace with:
class MySkin extends BaseTemplate {
ADM
On Mon, 23 Jul 2012 17:43:07 -0700, linuxlover linuxloverstaff@gmail.com wrote:
Il giorno lun, 23/07/2012 alle 15.39 -0700, Daniel Friesen ha scritto:
On Mon, 23 Jul 2012 15:02:16 -0700, Adm linuxloverstaff@gmail.com wrote:
http://blog.redwerks.org/2012/02/08/mediawiki-skinning-tutorial/
I think there is an error in the tutorial: class MySkinTemplate extends BaseTemplate {
Replace with:
class MySkin extends BaseTemplate {
ADM
No, you should have two classes in your skin. The one inheriting from BaseTemplate is your skins template, that one should be {MySkin}Template, not {MySkin}. You need a different class called {MySkin} that inherits from SkinTemplate (which while confusingly named is a Skin class rather than a template). This class is what defines what template and css to use.
Il giorno lun, 23/07/2012 alle 17.54 -0700, Daniel Friesen ha scritto:
No, you should have two classes in your skin. The one inheriting from BaseTemplate is your skins template, that one should be {MySkin}Template, not {MySkin}. You need a different class called {MySkin} that inherits from SkinTemplate (which while confusingly named is a Skin class rather than a template). This class is what defines what template and css to use.
Bokoor.skin.php --------------------------------- class SkinBokoor extends SkinTemplate { var $skinname = 'bokoor', $stylename = 'bokoor', $template = 'Bokoor', $useHeadElement = true;
/** * @param $out OutputPage object */ function setupSkinUserCss( OutputPage $out ){ parent::setupSkinUserCss( $out ); $out->addModuleStyles( "skins.bokoor" ); } }
/** * @todo document * @ingroup Skins */ class BokoorTemplate extends BaseTemplate { -----------------------------------------------------------------------
bokoor.php ------------------------------------ $wgExtensionCredits['skin'][] = array( 'path' => __FILE__, 'name' => 'Bokoor', 'url' => "http://www.alfredodimaria.it", 'author' => '[http://mediawiki.org/wiki/User:Admdebian]', 'descriptionmsg' => 'Bokoor skin - mediawiki 1.19.1', ); $wgValidSkinNames['bokoor'] = 'Bokoor'; $wgAutoloadClasses['SkinBokoor'] = dirname(__FILE__).'/Bokoor.skin.php'; $wgExtensionMessagesFiles['Bokoor'] = dirname(__FILE__).'/Bokoor.i18n.php';
$wgResourceModules['skins.bokoor'] = array( 'styles' => array( 'bokoor/css/screen.css' => array( 'media' => 'screen' ), ), 'remoteBasePath' => &$GLOBALS['wgStylePath'], 'localBasePath' => &$GLOBALS['wgStyleDirectory'], ); ------------------------------------------------------------
Error: ------------------------------------------------------------------------- PHP Fatal error: require_once(): Failed opening required '/var/www/mediawiki-1.19.1/skins/Bokoor.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/mediawiki-1.19.1/includes/Skin.php on line 155
ADM
On 12-07-23 6:17 PM, linuxlover wrote:
Il giorno lun, 23/07/2012 alle 17.54 -0700, Daniel Friesen ha scritto:
No, you should have two classes in your skin. The one inheriting from BaseTemplate is your skins template, that one should be {MySkin}Template, not {MySkin}. You need a different class called {MySkin} that inherits from SkinTemplate (which while confusingly named is a Skin class rather than a template). This class is what defines what template and css to use.
Bokoor.skin.php
class SkinBokoor extends SkinTemplate { var $skinname = 'bokoor', $stylename = 'bokoor', $template = 'Bokoor', $useHeadElement = true;
You want $template = 'BokoorTemplate'
/** * @param $out OutputPage object */ function setupSkinUserCss( OutputPage $out ){ parent::setupSkinUserCss( $out ); $out->addModuleStyles( "skins.bokoor" ); } }
/**
- @todo document
- @ingroup Skins
*/ class BokoorTemplate extends BaseTemplate {
bokoor.php
$wgExtensionCredits['skin'][] = array( 'path' => __FILE__, 'name' => 'Bokoor', 'url' => "http://www.alfredodimaria.it", 'author' => '[http://mediawiki.org/wiki/User:Admdebian]', 'descriptionmsg' => 'Bokoor skin - mediawiki 1.19.1', ); $wgValidSkinNames['bokoor'] = 'Bokoor'; $wgAutoloadClasses['SkinBokoor'] = dirname(__FILE__).'/Bokoor.skin.php'; $wgExtensionMessagesFiles['Bokoor'] = dirname(__FILE__).'/Bokoor.i18n.php';
$wgResourceModules['skins.bokoor'] = array( 'styles' => array( 'bokoor/css/screen.css' => array( 'media' => 'screen' ), ), 'remoteBasePath' => &$GLOBALS['wgStylePath'], 'localBasePath' => &$GLOBALS['wgStyleDirectory'], );
Error:
PHP Fatal error: require_once(): Failed opening required '/var/www/mediawiki-1.19.1/skins/Bokoor.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/mediawiki-1.19.1/includes/Skin.php on line 155
ADM
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
- In the extension I can made a file ext.i18n.php and then use:
$wgExtensionMessagesFiles['ext'] = dirname( __FILE__ ) . 'ext.i18n.php'; wfMsg('something');
In the interest of keeping up with the times, I'll leave this here:
http://www.mediawiki.org/wiki/WfMessage#Comparison_with_the_deprecated_wfMsg...
Not to say that you should necessarily rush to "fix" your extensions, but be aware that it's preferable to use the wfMessage function now.
Credit to Krenair, by the way, who managed to merge a fix for my bug report about this in less than three hours (the patch is also a good example of how to update your extensions):
https://bugzilla.wikimedia.org/show_bug.cgi?id=38501
Cheers,
wikitech-l@lists.wikimedia.org