]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
merge fix 776
authorThomas Citharel <tcit@tcit.fr>
Fri, 15 Aug 2014 22:54:46 +0000 (00:54 +0200)
committerThomas Citharel <tcit@tcit.fr>
Fri, 15 Aug 2014 22:54:46 +0000 (00:54 +0200)
inc/poche/Poche.class.php
themes/baggy/config.twig
themes/default/config.twig

index 098dd7c19c16b6f1891157c32a7639ac0b10e1f1..64a5c4f792e8c3dc8e8d61392795a199fb1c58e5 100755 (executable)
@@ -551,42 +551,39 @@ class Poche
      * import datas into your wallabag
      * @return boolean
      */
-    public function import()
-    {
-        if (isset($_FILES['file'])) {
-            Tools::logm('Import stated: parsing file');
-
-            // assume, that file is in json format
-
-            $str_data = file_get_contents($_FILES['file']['tmp_name']);
-            $data = json_decode($str_data, true);
-            if ($data === null) {
-
-                // not json - assume html
-
-                $html = new simple_html_dom();
-                $html->load_file($_FILES['file']['tmp_name']);
-                $data = array();
-                $read = 0;
-                foreach(array('ol','ul') as $list) {
-                    foreach($html->find($list) as $ul) {
-                        foreach($ul->find('li') as $li) {
-                            $tmpEntry = array();
-                            $a = $li->find('a');
-                            $tmpEntry['url'] = $a[0]->href;
-                            $tmpEntry['tags'] = $a[0]->tags;
-                            $tmpEntry['is_read'] = $read;
-                            if ($tmpEntry['url']) {
-                                $data[] = $tmpEntry;
-                            }
-                        }
-
-                        // the second <ol/ul> is for read links
 
-                        $read = ((sizeof($data) && $read) ? 0 : 1);
-                    }
-                }
+    public function import() {
+
+      if ( isset($_FILES['file']) && $_FILES['file']['tmp_name'] ) {
+        Tools::logm('Import stated: parsing file');
+
+        // assume, that file is in json format
+        $str_data = file_get_contents($_FILES['file']['tmp_name']);
+        $data = json_decode($str_data, true);
+
+        if ( $data === null ) {
+          //not json - assume html
+          $html = new simple_html_dom();
+          $html->load_file($_FILES['file']['tmp_name']);
+          $data = array();
+          $read = 0;
+          foreach (array('ol','ul') as $list) {
+            foreach ($html->find($list) as $ul) {
+              foreach ($ul->find('li') as $li) {
+                $tmpEntry = array();
+                  $a = $li->find('a');
+                  $tmpEntry['url'] = $a[0]->href;
+                  $tmpEntry['tags'] = $a[0]->tags;
+                  $tmpEntry['is_read'] = $read;
+                  if ($tmpEntry['url']) {
+                    $data[] = $tmpEntry;
+                  }
+              }
+              # the second <ol/ul> is for read links
+              $read = ((sizeof($data) && $read)?0:1);
             }
+          }
+       }
 
             // for readability structure
 
@@ -629,9 +626,11 @@ class Poche
                 $this->messages->add('s', _('Articles inserted: ') . $i . _('. Please note, that some may be marked as "read".'));
             }
 
-            Tools::logm('Import of articles finished: ' . $i . ' articles added (w/o content if not provided).');
-        }
-
+        Tools::logm('Import of articles finished: '.$i.' articles added (w/o content if not provided).');
+      }
+      else {
+        $this->messages->add('s', _('Did you forget to select a file?'));
+      }
         // file parsing finished here
         // now download article contents if any
         // check if we need to download any content
index 46735f0744d1e45816df071a4e5a92b9588eb739..e45c3218fa7c4b6638183a39c0baa0dbcdbd736a 100755 (executable)
                 <fieldset class="w500p">
                     <div class="row">
                         <label class="col w150p" for="file">{% trans "File:" %}</label>
-                        <input class="col" type="file" id="file" name="file" tabindex="4">
+                        <input class="col" type="file" id="file" name="file" tabindex="4" required="required">
                     </div>
                     <div class="row mts txtcenter">
                         <button class="bouton" type="submit" tabindex="4">{% trans "Import" %}</button>
index 160f6046a46426f5590603bfd2ddb0d5de1f42d3..8f047ae6ad6162296e0d739a7717ab25eeefa966 100755 (executable)
                 <fieldset class="w500p">
                     <div class="row">
                         <label class="col w150p" for="file">{% trans "File:" %}</label>
-                        <input class="col" type="file" id="file" name="file" tabindex="4">
+                        <input class="col" type="file" id="file" name="file" tabindex="4" required="required">
                     </div>
                     <div class="row mts txtcenter">
                         <button class="bouton" type="submit" tabindex="4">{% trans "Import" %}</button>