Skip to content
This repository
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 204 lines (160 sloc) 7.97 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
<?php
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

/**
* This is the configuration file for mediawiki-bugzilla. It contains important
* settings that should be reviewed and customized for your environment. Please
* see the instructions on each line for details about what should be
* customized and how to properly install the application.
*
* For maximum commpatibility with Mediawiki, settings modifications should be
* made in the mediawiki/LocalSettings.php file. See the README for
* instructions.
*/

/**
* Application metadata and credits. Should not be changed.
*/

$wgExtensionCredits['other'][] = array(
    'name' => 'Bugzilla',
    'author' => 'Christian Legnitto',
    'url' => 'https://github.com/LegNeato/mediawiki-bugzilla',
    'descriptionmsg' => 'bugzilla-desc',
);

$wgResourceModules['ext.Bugzilla'] = array(
    'scripts' => array( 'web/js/jquery.dataTables.js' ),
    'styles' => array( 'web/css/demo_page.css', 'web/css/demo_table.css', 'web/css/bugzilla.css' ),
    'messages' => array( 'bugzilla-hello-world', 'bugzilla-goodbye-world' ),
    'dependencies' => array( 'jquery.ui.core' ),
    'position' => 'top', // jquery.dataTables.js errors otherwise :(
    'localBasePath' => __DIR__,
    'remoteExtPath' => 'Bugzilla'
);

/**
* Classes to be autoloaded by mediawiki. Should you add any cache options, you
* should include them in this list.
*/

$cwd = dirname(__FILE__); // We don't need to do this more than once!

$wgExtensionMessagesFiles['Bugzilla'] = "$cwd/Bugzilla.i18n.php";

$wgAutoloadClasses['Bugzilla'] = $cwd . '/Bugzilla.class.php';
$wgAutoloadClasses['BugzillaQuery'] = $cwd . '/BugzillaQuery.class.php';
$wgAutoloadClasses['BugzillaOutput'] = $cwd . '/BugzillaOutput.class.php';
$wgAutoloadClasses['BugzillaCacheI'] = $cwd . '/cache/BugzillaCacheI.class.php';
$wgAutoloadClasses['BugzillaCacheDummy'] = $cwd . '/cache/BugzillaCacheDummy.class.php';
$wgAutoloadClasses['BugzillaCacheApc'] = $cwd . '/cache/BugzillaCacheApc.class.php';
$wgAutoloadClasses['BugzillaCacheMemcache'] = $cwd . '/cache/BugzillaCacheMemcache.class.php';
$wgAutoloadClasses['BugzillaCacheSql'] = $cwd . '/cache/BugzillaCacheSql.class.php';

/**
* These hooks are used by mediawiki to properly display the plugin information
* and properly interpret the tags used.
*/

$wgHooks['LoadExtensionSchemaUpdates'][] = 'BugzillaCreateCache';
$wgHooks['BeforePageDisplay'][] = 'BugzillaIncludeHTML';
$wgHooks['ParserFirstCallInit'][] = 'BugzillaParserInit';

// Schema updates for the database cache
function BugzillaCreateCache($updater) {

    global $wgBugzillaCacheType;

    $class = Bugzilla::getCacheClass($wgBugzillaCacheType);
    $class::setup($updater);

    // Let the other hooks keep processing
    return true;
}

// Add content to page HTML
function BugzillaIncludeHTML( &$out, &$sk ) {

    global $wgScriptPath;
    global $wgVersion;
    global $wgBugzillaJqueryTable;
    global $wgBugzillaTable;

    if( $wgBugzillaJqueryTable ) {
        if( version_compare( $wgVersion, '1.17', '<') ) {
            // Use local jquery
            $out->addScriptFile("$wgScriptPath/extensions/Bugzilla/web/jquery/1.6.2/jquery.min.js");

            // Use local jquery ui
            $out->addScriptFile("$wgScriptPath/extensions/Bugzilla/web/jqueryui/1.8.14/jquery-ui.min.js");

            // Add a local jquery css file
            $out->addStyle("$wgScriptPath/extensions/Bugzilla/web/jqueryui/1.8.14/themes/base/jquery-ui.css");

            // Add a local jquery UI theme css file
            $out->addStyle("$wgScriptPath/extensions/Bugzilla/web/jqueryui/1.8.14/themes/smoothness/jquery-ui.css");

            // Add a local script file for the datatable
            $out->addScriptFile("$wgScriptPath/extensions/Bugzilla/web/js/jquery.dataTables.js");

            // Add local datatable styles
            $out->addStyle("$wgScriptPath/extensions/Bugzilla/web/css/demo_page.css");
            $out->addStyle("$wgScriptPath/extensions/Bugzilla/web/css/demo_table.css");

            // Add local bugzilla extension styles
            $out->addStyle("$wgScriptPath/extensions/Bugzilla/web/css/bugzilla.css");

        }

        // Add the script to do table magic
        $out->addInlineScript('$(document).ready(function() {
$("table.bugzilla").dataTable({
"bJQueryUI": true,
"aLengthMenu": ' . $wgBugzillaTable['lengthMenu'] . ',
"iDisplayLength" : ' . $wgBugzillaTable['pageSize'] . ',
})});'
        );
    }

    // Let the user optionally override bugzilla extension styles
    if( file_exists("$wgScriptPath/extensions/Bugzilla/web/css/custom.css") ) {
        $out->addStyle("$wgScriptPath/extensions/Bugzilla/web/css/custom.css");
    }

    $out->addModules('ext.Bugzilla');

    // Let the other hooks keep processing
    return TRUE;
}

// Hook our callback function into the parser
function BugzillaParserInit( Parser &$parser ) {
    global $wgBugzillaTagName;

    // Register the desired tag
    $parser->setHook( $wgBugzillaTagName, 'BugzillaRender' );

    // Let the other hooks keep processing
    return true;
}

// Function to be called when our tag is found by the parser
function BugzillaRender($input, array $args, Parser $parser, $frame=null ) {
    global $wgBugzillaRESTURL;

    // We don't want the page to be cached
    // TODO: Not sure if we need this
    $parser->disableCache();

    // TODO: Figure out to have the parser not do anything to our output
    // mediawiki docs are wrong :-(
    // error_log(print_r($parser->mStripState, true));
    // $parser->mStripState->addItem( 'nowiki', 'NOWIKI', true);
    // 'noparse' => true, 'isHTML' => true, 'markerType' => 'nowiki' );

    $input = $parser->recursiveTagParse($input, $frame);

    // Create a new bugzilla object
    $bz = Bugzilla::create($args, $input, $parser->getTitle());

    // Show the desired output (or an error if there was one)
    return $bz->render();
}

/**
* This configuration is the default configuration for mediawiki-bugzilla.
* Please feel free to customize it for your environment. Be sure to make
* changes in the mediawiki/LocalSettings.php file, to ensure upgrade
* compatibility.
*/

// Remote API
$wgBugzillaRESTURL = 'https://api-dev.bugzilla.mozilla.org/latest'; // The URL for your Bugzilla API installation
$wgBugzillaURL = 'https://bugzilla.mozilla.org'; // The URL for your Bugzilla installation
$wgBugzillaTagName = 'bugzilla'; // The tag name for your Bugzilla installation (default: 'bugzilla')
$wgBugzillaMethod = 'REST'; // XML-RPC and JSON-RPC may be supported later

// Cache
// NOTE: $wgBugzillaUseCache has been removed. Use $wgBugzillaCacheType below only:
// - any valid value for using it
// - equivalent to previous $wgBugzillaUseCache = false; is $wgBugzillaCacheType = 'dummy';
$wgBugzillaCacheType = 'mysql'; // valid values are: memcache, apc, mysql, postgresql, sqlite, dummy.
$wgBugzillaCacheMins = 5; // Minutes to cache results (default: 5)

$wgBugzillaJqueryTable = true; // Use a jQuery table for display (default: true)

// Charts
$wgBugzillaChartStorage = realpath($cwd . '/charts'); // Location to store generated bug charts
$wgBugzillaFontStorage = $cwd . '/pchart/fonts'; // Path to font directory for font data
$wgBugzillaChartUrl = $wgScriptPath . '/extensions/Bugzilla/charts'; // The URL to use to display charts

// The default fields to display
$wgBugzillaDefaultFields = array(
    'id',
    'summary',
    'priority',
    'status',
);

$wgBugzillaTable = array(
  'pageSize' => 10, //default pagination count
  'lengthMenu' => '[10, 25, 50, 100]', //default length set; example options [[5, 10, 15, 25, 50, 100 , -1], [5, 10, 15, 25, 50, 100, "All"]]]
);
Something went wrong with that request. Please try again.