aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins/wallabag
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2016-01-06 20:40:17 +0100
committerArthurHoaro <arthur@hoa.ro>2016-01-06 20:40:17 +0100
commitc0a50f3663e207d5df007e0fa321219c1b32d6ea (patch)
treed5760caffc5c188670a46b3c06243d1778f974b9 /plugins/wallabag
parent88c15abb2a2b24f05ca926c0ddbdec18a407e47d (diff)
downloadShaarli-c0a50f3663e207d5df007e0fa321219c1b32d6ea.tar.gz
Shaarli-c0a50f3663e207d5df007e0fa321219c1b32d6ea.tar.zst
Shaarli-c0a50f3663e207d5df007e0fa321219c1b32d6ea.zip
Git *wants* to rewrite this file in the exact same way...
Probably a line ending issue...
Diffstat (limited to 'plugins/wallabag')
-rw-r--r--plugins/wallabag/WallabagInstance.php142
1 files changed, 71 insertions, 71 deletions
diff --git a/plugins/wallabag/WallabagInstance.php b/plugins/wallabag/WallabagInstance.php
index 87352e66..72cc2e5e 100644
--- a/plugins/wallabag/WallabagInstance.php
+++ b/plugins/wallabag/WallabagInstance.php
@@ -1,71 +1,71 @@
1<?php 1<?php
2 2
3/** 3/**
4 * Class WallabagInstance. 4 * Class WallabagInstance.
5 */ 5 */
6class WallabagInstance 6class WallabagInstance
7{ 7{
8 /** 8 /**
9 * @var array Static reference to differrent WB API versions. 9 * @var array Static reference to differrent WB API versions.
10 * - key: version ID, must match plugin settings. 10 * - key: version ID, must match plugin settings.
11 * - value: version name. 11 * - value: version name.
12 */ 12 */
13 private static $wallabagVersions = array( 13 private static $wallabagVersions = array(
14 1 => '1.x', 14 1 => '1.x',
15 2 => '2.x', 15 2 => '2.x',
16 ); 16 );
17 17
18 /** 18 /**
19 * @var array Static reference to WB endpoint according to the API version. 19 * @var array Static reference to WB endpoint according to the API version.
20 * - key: version name. 20 * - key: version name.
21 * - value: endpoint. 21 * - value: endpoint.
22 */ 22 */
23 private static $wallabagEndpoints = array( 23 private static $wallabagEndpoints = array(
24 '1.x' => '?plainurl=', 24 '1.x' => '?plainurl=',
25 '2.x' => 'bookmarklet?url=', 25 '2.x' => 'bookmarklet?url=',
26 ); 26 );
27 27
28 /** 28 /**
29 * @var string Wallabag user instance URL. 29 * @var string Wallabag user instance URL.
30 */ 30 */
31 private $instanceUrl; 31 private $instanceUrl;
32 32
33 /** 33 /**
34 * @var string Wallabag user instance API version. 34 * @var string Wallabag user instance API version.
35 */ 35 */
36 private $apiVersion; 36 private $apiVersion;
37 37
38 function __construct($instance, $version) 38 function __construct($instance, $version)
39 { 39 {
40 if ($this->isVersionAllowed($version)) { 40 if ($this->isVersionAllowed($version)) {
41 $this->apiVersion = self::$wallabagVersions[$version]; 41 $this->apiVersion = self::$wallabagVersions[$version];
42 } else { 42 } else {
43 // Default API version: 1.x. 43 // Default API version: 1.x.
44 $this->apiVersion = self::$wallabagVersions[1]; 44 $this->apiVersion = self::$wallabagVersions[1];
45 } 45 }
46 46
47 $this->instanceUrl = add_trailing_slash($instance); 47 $this->instanceUrl = add_trailing_slash($instance);
48 } 48 }
49 49
50 /** 50 /**
51 * Build the Wallabag URL to reach from instance URL and API version endpoint. 51 * Build the Wallabag URL to reach from instance URL and API version endpoint.
52 * 52 *
53 * @return string wallabag url. 53 * @return string wallabag url.
54 */ 54 */
55 public function getWallabagUrl() 55 public function getWallabagUrl()
56 { 56 {
57 return $this->instanceUrl . self::$wallabagEndpoints[$this->apiVersion]; 57 return $this->instanceUrl . self::$wallabagEndpoints[$this->apiVersion];
58 } 58 }
59 59
60 /** 60 /**
61 * Checks version configuration. 61 * Checks version configuration.
62 * 62 *
63 * @param mixed $version given version ID. 63 * @param mixed $version given version ID.
64 * 64 *
65 * @return bool true if it's valid, false otherwise. 65 * @return bool true if it's valid, false otherwise.
66 */ 66 */
67 private function isVersionAllowed($version) 67 private function isVersionAllowed($version)
68 { 68 {
69 return isset(self::$wallabagVersions[$version]); 69 return isset(self::$wallabagVersions[$version]);
70 } 70 }
71} 71}