-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScriptSample.php
58 lines (50 loc) · 1.39 KB
/
ScriptSample.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
require_once('src/Init.php');
use \Helper\Page;
use \Helper\Functions;
/**
* Example script to work with the helpers
* @author DFelten
*/
class ScriptSample {
/**
* Constructor with examples of the page helper class
* For more see Helper/Page.php
*
* @param MediawikiApi $wiki
*/
public function __construct($wiki) {
//Create the page object
$page = new Page("Article name", "Article content");
//Create or edit the article
if($page->createPage($articleText)) {
echo "Success";
} else {
echo "Error";
}
//Edit the article (only if article already exist)
if($page->editPage("Testderzweite2")) {
echo "Success";
} else {
echo "Error";
}
//Move the article
if($page->movePage("Testderzweite2")) {
echo "Success";
} else {
echo "Error";
}
//Get author of the last revision
$page->getLastRevisionUser("Testderzweite2");
//Check if article exist
if($page->exist()) {
echo "Article exists";
} else {
echo "Article doesn't exist";
}
//Example of other functions (see Functions.php)
$functions = new Functions();
$functions->getPagesWithinCategory();
}
}
$scriptSample = new ScriptSample($wiki);