MediawikiのExtension:AccessLog

閲覧数: 22(0)

旅日記ネタが続いたので久しぶりにITネタを。本来アクセス数を稼ぐブログでは統一したテーマで一貫して書くことが最良とされているそうです。特にアクセス数を狙っていないので書きたいことを書いています。実のところITネタの方がヒットは多いですW

今回は、タイトルにある通りMediawiki(Wikipediaのもとになっているオープンソース)の機能を拡張するExtensionについてです。ここでも何度か紹介したTsubopediaはベースにMediawikiを使用しています。途中でダウングレードした時期もありましたが、現在は常に最新バージョンを適用するようにしています。現在は、2017年4月30日リリースの1.28.2です。Extensionで様々な拡張を行っていますが、まずは特別ページから、最初に紹介するのはAccessLogです。誰がどのページにアクセスしてきているのかユーザー名またはIPアドレスで判るようになります。タイトル画像がその例です。

作りは若干古く、そのままでは1.25以降ぐらいから使えなくなっています。最低限使えるようにハードコーディングで修正しています。ついでに多少の日本語化のため言語ファイルに記述を追加しました。その他にもイメージファイルフォルダの場所変更なども行っていますがこれは必須ではないので省きます。

ではまずAccessLog.phpから、特別ページでのアクセス権を’sysop'(管理者)に限定する設定です。$wgGroupPermissions[‘sysop’][‘accesslog’] = true;を冒頭に追加します。

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

$wgGroupPermissions['sysop']['accesslog'] = true;

次に、AccessLog.body.phpを修正します。Extensionを入れただけではエラーが出てしまい、画面が表示されませんので、ログからエラーを辿って、結局AccessLog.body.phpの以下の記述が原因であると思ったので、185行目付近のgetLang()をgetLanguage()に修正しています。コメント行は元の記述です。

                $out .= ' ';
//              $out .= $this->getLang()->pipeList( $links );
                $out .= $this->getLanguage()->pipeList( $links );

多言語対応していないので、メッセージ等がすべて英語ですが、AccessLog.i18n.phpに以下の行を追加すると、メッセージ等が日本語で表示されるようになります。必須ではありません。$messages[‘en’] = array()の後に以下の行を追加します。最後の?>は含まれていないので忘れないようにしましょう。

        $messages['qqq'] = array(
                'accesslog' => 'Access log',
                'accesslog-badaccess' => 'You do not have access right to this page.',
                'accesslog-disclaimer' => 'This special page lists the access log. For any questions or troubleshooting, please <a href="mailto:$1">contact</a> the administrator.',
                'accesslog-filter-fieldset' => 'Log filtering options',
                'accesslog-filter-access' => 'Access:',
                'accesslog-filter-access-all' => 'all',
                'accesslog-filter-access-view' => 'view',
                'accesslog-filter-access-edit' => 'edit',
                'accesslog-filter-or' => 'or ',
                'accesslog-filter-title' => 'Title:',
                'accesslog-filter-user' => 'User:',
                'accesslog-filter-user-anons' => '$1 anonymous users',
                'accesslog-filter-user-loggedin' => '$1 logged-in users',
                'accesslog-filter-user-mine' => '$1 my actions',
                'accesslog-filter-daysinput' => 'in last $1 day(s)',
                'accesslog-purge-fieldset' => 'Purge old logs',
                'accesslog-purge-daysinput' => 'Purge log older than $1 day(s) ',
                'accesslog-purge-button' => 'Purge',
                'accesslog-purge-all' => 'Are you sure you want to purge the entire log?',
                'accesslog-purge-days' => 'Are you sure you want to purge entries older than {{PLURAL:$1|one day|$1 days}}?',
                'accesslog-access-view' => 'has viewed',
                'accesslog-access-edit' => 'has edited'
        );

        $messages['ja'] = array(
                'accesslog' => 'アクセス ログ',
                'accesslog-badaccess' => 'このページへのアクセス権がありません。
',
                'accesslog-disclaimer' => 'この特別ページはアクセスログです。 For any questions or troubleshooting, please <a href="mailto:$1">contact</a> the administrator.',
                'accesslog-filter-fieldset' => 'ログフィルタオプション',
                'accesslog-filter-access' => 'アクセス:',
                'accesslog-filter-access-all' => '全て',
                'accesslog-filter-access-view' => '閲覧',
                'accesslog-filter-access-edit' => '編集',
                'accesslog-filter-or' => 'or ',
                'accesslog-filter-title' => 'タイトル:',
                'accesslog-filter-user' => 'ユーザ:',
                'accesslog-filter-user-anons' => '$1 anonymous users',
                'accesslog-filter-user-loggedin' => '$1 logged-in users',
                'accesslog-filter-user-mine' => '$1 自分のアクション',
                'accesslog-filter-daysinput' => '過去 $1 日',
                'accesslog-purge-fieldset' => '古いログの消去',
                'accesslog-purge-daysinput' => '過去 $1 日より古いログの消去',
                'accesslog-purge-button' => '消去',
                'accesslog-purge-all' => 'Are you sure you want to purge the entire log?',
                'accesslog-purge-days' => 'Are you sure you want to purge entries older than {{PLURAL:$1|one day|$1 days}}?',
                'accesslog-access-view' => '閲覧',
                'accesslog-access-edit' => '編集'
        );
カテゴリー公開, 閑話(IT)タグ,
dockerとiptables

クラウドサーバーを利用する場合、ファイアウォール(Firewalld/iptables)の設定に失敗  続きを読む

SWIPERでSLIDER
blank

無料テーマを独自に改善する活動の一環として、前回は「おすすめ記事」を表示する部分について書きました。  続きを読む

テスト系その2
blank

このサイトは個人用ブログだけど、ローカルにテスト系を持っている。個人ブログ運営者なら、記事のバックア  続きを読む

Mediawikiプレビュー機能
blank

Wikipediaで実装されていいなぁと思っていた「プレビュー機能」記事中でリンクされた文字列にマウ  続きを読む

dotProject
blank

オープンソースのプロジェクト管理ツールである「dotProject」便利なツールで使い込んでいますが  続きを読む

ElasticPress日本語設定202...
blank

ElasticsearchをWordpressで利用するためのプラグインであるElasticPres  続きを読む

スポンサーリンク

コメントを残す

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください