Gebruiker:Jos1950/vector.css: verschil tussen versies

Uit LinuxMintNL WiKi
Ga naar: navigatie, zoeken
(Nieuw)
 
(Proef)
Regel 1: Regel 1:
  
 +
<?php
 
/**
 
/**
* Constants for use with the mode,
+
* CategoryGallery MediaWiki extension.
* defining what should be shown in the tree
+
*
*/
+
* This extension implements a <categorygallery> tag creating a gallery of all images in
define( 'CT_MODE_CATEGORIES',  0 );
+
* a category.
define( 'CT_MODE_PAGES',       10 );
+
*
define( 'CT_MODE_ALL',        20 );
+
* Written by Leucosticte
define( 'CT_MODE_PARENTS',   100 );
+
* https://www.mediawiki.org/wiki/User:Leucosticte
   
+
*
/**
+
* This program is free software; you can redistribute it and/or modify
  * Options:
+
* it under the terms of the GNU General Public License as published by
 +
* the Free Software Foundation; either version 3 of the License, or
 +
* (at your option) any later version.
 +
*
 +
* This program is distributed in the hope that it will be useful,
 +
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 +
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 +
  * GNU General Public License for more details.
 +
*
 +
* You should have received a copy of the GNU General Public License along
 +
* with this program; if not, write to the Free Software Foundation, Inc.,
 +
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 +
  * http://www.gnu.org/copyleft/gpl.html
 
  *
 
  *
  * $wgCategoryTreeMaxChildren
+
  * @file
  *           - maximum number of children shown in a tree
+
  * @ingroup Extensions
*       node. Default is 200
 
* $wgCategoryTreeAllowTag
 
*          - enable <categorytree> tag. Default is true.
 
* $wgCategoryTreeDynamicTag
 
*          - loads the first level of the tree in a <categorytag>
 
*            dynamically.  This way, the cache does not need to be
 
*            disabled.  Default is false.
 
* $wgCategoryTreeDisableCache
 
*          - disabled the parser cache for pages with a
 
*            <categorytree> tag. Default is true.
 
* $wgCategoryTreeMaxDepth
 
*          - maximum value for depth argument; An array that maps
 
*            mode ; values to the maximum depth acceptable for the
 
*            depth option.  Per default, the "categories" mode has a
 
*            max depth of 2, all other modes have a max depth of 1.
 
* $wgCategoryTreeDefaultOptions
 
*          - default options for the <categorytree> tag.
 
* $wgCategoryTreeCategoryPageOptions
 
*          - options to apply on category pages.
 
* $wgCategoryTreeSpecialPageOptions
 
*          - options to apply on Special:CategoryTree.
 
 
  */
 
  */
+
 
$wgCategoryTreeMaxChildren =  200;
+
if( !defined( 'MEDIAWIKI' ) ) {
$wgCategoryTreeAllowTag    = true;
+
        echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
$wgCategoryTreeDynamicTag  = false;
+
        die( 1 );
$wgCategoryTreeDisableCache = true;
+
}
$wgCategoryTreeMaxDepth    = array(
+
 
  CT_MODE_PAGES => 1,
+
$wgExtensionCredits['parserhook'][] = array(
  CT_MODE_ALL => 1,
+
        'path' => __FILE__,
  CT_MODE_CATEGORIES => 2
+
        'name' => 'CategoryGallery',
 +
        'author' => 'Nathan Larson',
 +
        'url' => 'https://mediawiki.org/wiki/Extension:CategoryGallery',
 +
        'description' => 'Adds <nowiki><categorygallery></nowiki> tag',
 +
        'version' => '1.0.1'
 
);
 
);
+
 
# Default values for most options
+
$wgExtensionFunctions[] = "CategoryGallery::categoryGallerySetHook";
$wgCategoryTreeDefaultOptions      = array();
+
 
$wgCategoryTreeDefaultOptions['mode']           = null;
+
class CategoryGallery {
$wgCategoryTreeDefaultOptions['hideprefix']     = null;
+
        public static function categoryGallerySetHook() {
$wgCategoryTreeDefaultOptions['showcount']     = false;
+
                global $wgParser;
# false means "no filter"
+
                $wgParser->setHook( "categorygallery",
$wgCategoryTreeDefaultOptions['namespaces']     = false;
+
                        "CategoryGallery::renderCategoryGallery" );
+
                $wgParser->setHook( "catgallery",
# Options to be used for category pages
+
                        "CategoryGallery::renderCategoryGallery" );
$wgCategoryTreeCategoryPageOptions = array();
+
        }
$wgCategoryTreeCategoryPageOptions['mode']      = null;
+
 
$wgCategoryTreeCategoryPageOptions['showcount'] = true;
+
        public static function renderCategoryGallery( $input, $params, $parser ) {
   
+
                global $wgBedellPenDragonResident;
# Options to be used for Special:CategoryTree
+
                $parser->disableCache();
$wgCategoryTreeSpecialPageOptions  = array();
+
                if ( !isset( $params['cat'] ) ) { // No category selected
$wgCategoryTreeSpecialPageOptions['showcount']  = true;
+
                        return '';
 +
                }
 +
                // Capitalize the first letter in the category argument, convert spaces to _
 +
                $params['cat'] = str_replace ( ' ', '_', ucfirst( $params['cat'] ) );
 +
                // Retrieve category members from database
 +
                $dbr = wfGetDB( DB_SLAVE );
 +
                $res = $dbr->select( 'categorylinks', 'cl_from',
 +
                        array (
 +
                              'cl_to' => $params['cat'],
 +
                              'cl_type' => 'file'
 +
                        )
 +
                );
 +
                $ids = array();
 +
                foreach ( $res as $row ) {
 +
                        $ids[] = $row->cl_from;
 +
                }
 +
                // Create the gallery
 +
                $titles = Title::newFromIDs ( $ids );
 +
                $text = '';
 +
                foreach ( $titles as $title ) {
 +
                        $titlePrefixedDBKey = $title->getPrefixedDBKey();
 +
                        $text .= $titlePrefixedDBKey;
 +
                        if ( isset ( $params['bpdcaption'] ) && $wgBedellPenDragonResident ) {
 +
                                $caption = BedellPenDragon::renderGetBpdProp( $parser,
 +
                                        $titlePrefixedDBKey, $params['bpdcaption'], true, true );
 +
                                if ( $caption !== BPD_NOPROPSET ) {
 +
                                        $text .= "|" . $caption;
 +
                                }
 +
                        }
 +
                        $text .= "\n";
 +
                }
 +
                $output = $parser->renderImageGallery( $text, $params );
 +
                return $output;
 +
        }
 +
}

Versie van 13 aug 2014 om 20:06

<?php
/**
 * CategoryGallery MediaWiki extension.
 *
 * This extension implements a <categorygallery> tag creating a gallery of all images in
 * a category.
 *
 * Written by Leucosticte
 * https://www.mediawiki.org/wiki/User:Leucosticte
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 * http://www.gnu.org/copyleft/gpl.html
 *
 * @file
 * @ingroup Extensions
 */

if( !defined( 'MEDIAWIKI' ) ) {
        echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
        die( 1 );
}

$wgExtensionCredits['parserhook'][] = array(
        'path' => __FILE__,
        'name' => 'CategoryGallery',
        'author' => 'Nathan Larson',
        'url' => 'https://mediawiki.org/wiki/Extension:CategoryGallery',
        'description' => 'Adds <nowiki><categorygallery></nowiki> tag',
        'version' => '1.0.1'
);

$wgExtensionFunctions[] = "CategoryGallery::categoryGallerySetHook";

class CategoryGallery {
        public static function categoryGallerySetHook() {
                global $wgParser;
                $wgParser->setHook( "categorygallery",
                        "CategoryGallery::renderCategoryGallery" );
                $wgParser->setHook( "catgallery",
                        "CategoryGallery::renderCategoryGallery" );
        }

        public static function renderCategoryGallery( $input, $params, $parser ) {
                global $wgBedellPenDragonResident;
                $parser->disableCache();
                if ( !isset( $params['cat'] ) ) { // No category selected
                        return '';
                }
                // Capitalize the first letter in the category argument, convert spaces to _
                $params['cat'] = str_replace ( ' ', '_', ucfirst( $params['cat'] ) );
                // Retrieve category members from database
                $dbr = wfGetDB( DB_SLAVE );
                $res = $dbr->select( 'categorylinks', 'cl_from',
                        array (
                               'cl_to' => $params['cat'],
                               'cl_type' => 'file'
                        )
                );
                $ids = array();
                foreach ( $res as $row ) {
                        $ids[] = $row->cl_from;
                }
                // Create the gallery
                $titles = Title::newFromIDs ( $ids );
                $text = '';
                foreach ( $titles as $title ) {
                        $titlePrefixedDBKey = $title->getPrefixedDBKey();
                        $text .= $titlePrefixedDBKey;
                        if ( isset ( $params['bpdcaption'] ) && $wgBedellPenDragonResident ) {
                                $caption = BedellPenDragon::renderGetBpdProp( $parser,
                                        $titlePrefixedDBKey, $params['bpdcaption'], true, true );
                                if ( $caption !== BPD_NOPROPSET ) {
                                        $text .= "|" .  $caption;
                                }
                        }
                        $text .= "\n";
                }
                $output = $parser->renderImageGallery( $text, $params );
                return $output;
        }
}