diff options
author | Nicolas Lœuillet <nicolas.loeuillet@smile.fr> | 2014-10-10 13:33:54 +0200 |
---|---|---|
committer | Nicolas Lœuillet <nicolas.loeuillet@smile.fr> | 2014-10-10 13:33:54 +0200 |
commit | 44d35257e805856b4913c63fcbed3c0acb64bae8 (patch) | |
tree | 11e9d276c34b1b287706cb61182bdc71729661e2 /inc/3rdparty/FlattrItem.class.php | |
parent | af8292c1de1886cd975d79f0f42df40e0bd1c5bd (diff) | |
parent | cf8a5e1eedbed484dbcb1ddc9f7a13fc19b7a27b (diff) | |
download | wallabag-44d35257e805856b4913c63fcbed3c0acb64bae8.tar.gz wallabag-44d35257e805856b4913c63fcbed3c0acb64bae8.tar.zst wallabag-44d35257e805856b4913c63fcbed3c0acb64bae8.zip |
Merge branch 'dev'1.8.0
Diffstat (limited to 'inc/3rdparty/FlattrItem.class.php')
-rw-r--r-- | inc/3rdparty/FlattrItem.class.php | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/inc/3rdparty/FlattrItem.class.php b/inc/3rdparty/FlattrItem.class.php index 711b4ee0..ef8c62f7 100644 --- a/inc/3rdparty/FlattrItem.class.php +++ b/inc/3rdparty/FlattrItem.class.php | |||
@@ -1,28 +1,35 @@ | |||
1 | <?php | 1 | <?php |
2 | /* | 2 | /** |
3 | * Class for Flattr querying | 3 | * wallabag, self hostable application allowing you to not miss any content anymore |
4 | */ | 4 | * |
5 | class FlattrItem { | 5 | * @category wallabag |
6 | * @author Nicolas Lœuillet <nicolas@loeuillet.org> | ||
7 | * @copyright 2013 | ||
8 | * @license http://opensource.org/licenses/MIT see COPYING file | ||
9 | */ | ||
6 | 10 | ||
11 | class FlattrItem | ||
12 | { | ||
7 | public $status; | 13 | public $status; |
8 | public $urltoflattr; | 14 | public $urlToFlattr; |
9 | public $flattrItemURL; | 15 | public $flattrItemURL; |
10 | public $numflattrs; | 16 | public $numFlattrs; |
11 | 17 | ||
12 | public function checkItem($urltoflattr,$id) { | 18 | public function checkItem($urlToFlattr, $id) |
13 | $this->cacheflattrfile($urltoflattr, $id); | 19 | { |
20 | $this->_cacheFlattrFile($urlToFlattr, $id); | ||
14 | $flattrResponse = file_get_contents(CACHE . "/flattr/".$id.".cache"); | 21 | $flattrResponse = file_get_contents(CACHE . "/flattr/".$id.".cache"); |
15 | if($flattrResponse != FALSE) { | 22 | if($flattrResponse != FALSE) { |
16 | $result = json_decode($flattrResponse); | 23 | $result = json_decode($flattrResponse); |
17 | if (isset($result->message)){ | 24 | if (isset($result->message)) { |
18 | if ($result->message == "flattrable") { | 25 | if ($result->message == "flattrable") { |
19 | $this->status = FLATTRABLE; | 26 | $this->status = FLATTRABLE; |
20 | } | 27 | } |
21 | } | 28 | } |
22 | elseif (is_object($result) && $result->link) { | 29 | elseif (is_object($result) && $result->link) { |
23 | $this->status = FLATTRED; | 30 | $this->status = FLATTRED; |
24 | $this->flattrItemURL = $result->link; | 31 | $this->flattrItemURL = $result->link; |
25 | $this->numflattrs = $result->flattrs; | 32 | $this->numFlattrs = $result->flattrs; |
26 | } | 33 | } |
27 | else { | 34 | else { |
28 | $this->status = NOT_FLATTRABLE; | 35 | $this->status = NOT_FLATTRABLE; |
@@ -33,17 +40,18 @@ class FlattrItem { | |||
33 | } | 40 | } |
34 | } | 41 | } |
35 | 42 | ||
36 | private function cacheflattrfile($urltoflattr, $id) { | 43 | private function _cacheFlattrFile($urlToFlattr, $id) |
44 | { | ||
37 | if (!is_dir(CACHE . '/flattr')) { | 45 | if (!is_dir(CACHE . '/flattr')) { |
38 | mkdir(CACHE . '/flattr', 0777); | 46 | mkdir(CACHE . '/flattr', 0777); |
39 | } | 47 | } |
40 | 48 | ||
41 | // if a cache flattr file for this url already exists and it's been less than one day than it have been updated, see in /cache | 49 | // if a cache flattr file for this url already exists and it's been less than one day than it have been updated, see in /cache |
42 | if ((!file_exists(CACHE . "/flattr/".$id.".cache")) || (time() - filemtime(CACHE . "/flattr/".$id.".cache") > 86400)) { | 50 | if ((!file_exists(CACHE . "/flattr/".$id.".cache")) || (time() - filemtime(CACHE . "/flattr/".$id.".cache") > 86400)) { |
43 | $askForFlattr = Tools::getFile(FLATTR_API . $urltoflattr); | 51 | $askForFlattr = Tools::getFile(FLATTR_API . $urlToFlattr); |
44 | $flattrCacheFile = fopen(CACHE . "/flattr/".$id.".cache", 'w+'); | 52 | $flattrCacheFile = fopen(CACHE . "/flattr/".$id.".cache", 'w+'); |
45 | fwrite($flattrCacheFile, $askForFlattr); | 53 | fwrite($flattrCacheFile, $askForFlattr); |
46 | fclose($flattrCacheFile); | 54 | fclose($flattrCacheFile); |
47 | } | 55 | } |
48 | } | 56 | } |
49 | } \ No newline at end of file | 57 | } |