]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - inc/poche/Url.class.php
Revert "Add SHAARLI support to view template"
[github/wallabag/wallabag.git] / inc / poche / Url.class.php
index 00b0b25758236ac03d4c3e6927e167aa7d3b7749..3c74fb434bb1b7f14cd0f0934874893c44cb578c 100644 (file)
@@ -64,8 +64,16 @@ class Url
             if (function_exists('tidy_parse_string')) {
                 $tidy = tidy_parse_string($html, array(), 'UTF8');
                 $tidy->cleanRepair();
-                $html = $tidy->value;
-            }
+
+                //Warning: tidy might fail so, ensure there is still a content
+                $body = $tidy->body();
+
+                //hasChildren does not seem to work, just check the string
+                //returned (and do not forget to clean the white spaces)
+                if (preg_replace('/\s+/', '', $body->value) !== "<body></body>") {
+                    $html = $tidy->value;
+                }
+            } 
 
             $parameters = array();
             if (isset($html) and strlen($html) > 0)
@@ -77,7 +85,7 @@ class Url
                 if($readability->init())
                 {
                     $content = $readability->articleContent->innerHTML;
-                    $parameters['title'] = $readability->articleTitle->innerHTML;
+                    $parameters['title'] = ($readability->articleTitle->innerHTML != '' ? $readability->articleTitle->innerHTML : _('Untitled'));
                     $parameters['content'] = $content;
 
                     return $parameters;