]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - inc/poche/Poche.class.php
Merge branch 'Flattr' of git://github.com/tcitworld/poche into tcitworld-Flattr
[github/wallabag/wallabag.git] / inc / poche / Poche.class.php
index b0efe69a673f9e8f4f241a7964a0bb5e78fbdb5e..9db4a0346eb539b12dc75b887e0dbdb5efb5508e 100644 (file)
@@ -182,7 +182,7 @@ class Poche
                 }
 
                 if (!$import) {
-                    Tools::redirect();
+                    Tools::redirect('?view=home');
                 }
                 break;
             case 'delete':
@@ -248,9 +248,9 @@ class Poche
                         $tidy->cleanRepair();
                         $content = $tidy->value;
 
-                        // flattr checking
+                        # flattr checking
                         $flattr = new FlattrItem();
-                        $flattr->checkitem($entry['url']);
+                        $flattr->checkItem($entry['url']);
 
                         $tpl_vars = array(
                         'entry' => $entry,
@@ -263,11 +263,12 @@ class Poche
                     Tools::logm('error in view call : entry is null');
                 }
                 break;
-            default : // home, favorites and archive views
+            default: # home, favorites and archive views 
                 $entries = $this->store->getEntriesByView($view, $this->user->getId());
                 $tpl_vars = array(
                     'entries' => '',
                     'page_links' => '',
+                    'nb_results' => '',
                 );
                 if (count($entries) > 0) {
                     $this->pagination->set_total(count($entries));
@@ -275,6 +276,7 @@ class Poche
                     $datas = $this->store->getEntriesByView($view, $this->user->getId(), $this->pagination->get_limit());
                     $tpl_vars['entries'] = $datas;
                     $tpl_vars['page_links'] = $page_links;
+                    $tpl_vars['nb_results'] = count($entries);
                 }
                 Tools::logm('display ' . $view . ' view');
                 break;
@@ -564,53 +566,4 @@ class Poche
         }
         return $version;
     }
-}
-
-/* class for Flattr querying. Should be put in a separate file
-*   Or maybe just create an array instead of a complete class... My mistake. :-°
-*/
-class FlattrItem{
-    public $status;
-    public $urltoflattr;
-    public $flattrItemURL;
-    public $numflattrs;
-
-    public function checkitem($urltoflattr){
-        $this->cacheflattrfile($urltoflattr);
-        $flattrResponse = file_get_contents("cache/flattr/".base64_encode($urltoflattr).".cache");
-        if($flattrResponse != FALSE){
-            $result = json_decode($flattrResponse);
-            if (isset($result->message)){
-                if ($result->message == "flattrable"){
-                $this->status = "flattrable";
-                        }
-                    } 
-            elseif ($result->link) {
-                            $this->status = "flattred";
-                            $this->flattrItemURL = $result->link;
-                            $this->numflattrs = $result->flattrs;
-                        }
-            else{
-                $this->status = "not flattrable";
-            }
-        }
-        else
-        {
-            $this->status = "FLATTR_ERR_CONNECTION";
-        }
-    }
-
-    private function cacheflattrfile($urltoflattr){
-        if (!is_dir('cache/flattr')){
-            mkdir('./cache/flattr', 0777);
-        }
-        // 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
-        if ((!file_exists("cache/flattr/".base64_encode($urltoflattr).".cache")) || (time() - filemtime("cache/flattr/".base64_encode($urltoflattr).".cache") > 86400))
-        {
-            $askForFlattr = Tools::getFile("https://api.flattr.com/rest/v2/things/lookup/?url=".$urltoflattr);
-             $flattrCacheFile = fopen("cache/flattr/".base64_encode($urltoflattr).".cache", 'w+');
-             fwrite($flattrCacheFile, $askForFlattr);
-             fclose($flattrCacheFile);
-        }
-    }
-}
+}
\ No newline at end of file