-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmwcat.php
36 lines (30 loc) · 814 Bytes
/
mwcat.php
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
<?php
use Alfred\Workflows\Workflow;
require 'vendor/autoload.php';
$workflow = new Workflow;
// add variables
$root_url = getenv('wiki_url');
$url = $root_url . "/api.php?action=query&list=allcategories&format=json&aclimit=500";
$json = file_get_contents( $url );
$obj = json_decode( $json, TRUE );
$cats = [];
foreach ( $obj['query']['allcategories'] as $item ) {
$cats[] = $item['*'];
}
$query = $argv[1];
foreach ( $cats as $cat ) {
$cat_url = $root_url . "?title=Category:" . $cat . "&action=edit&redlink=1";
$workflow->result()
->uid( $cat )
->title( $cat )
->subtitle( '' )
->quicklookurl( $cat_url )
->type( 'default' )
->arg( $cat_url )
->valid( TRUE );
}
if ( !empty( $query ) ) {
// Default is searching in title:
$workflow->filterResults( $query );
}
echo $workflow->output();