]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
Minor fix: improve import from Netscape files (taking tags into account)
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>
Thu, 27 Nov 2008 07:27:36 +0000 (07:27 +0000)
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>
Thu, 27 Nov 2008 07:27:36 +0000 (07:27 +0000)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@176 b3834d28-1941-0410-a4f8-b48e95affb8f

importNetscape.php
services/userservice.php
templates/bookmarks.tpl.php
templates/sidebar.block.related.php
templates/top.inc.php

index f4cf6539e240c60c6c46af4ebbdbea6f48539f35..5e70387541e25f0ce27efbd6b8a119e1c06ec8be 100644 (file)
@@ -1,23 +1,23 @@
 <?
 /***************************************************************************
-Copyright (C) 2004 - 2006 Scuttle project
-http://sourceforge.net/projects/scuttle/
-http://scuttle.org/
+ Copyright (C) 2004 - 2006 Scuttle project
+ http://sourceforge.net/projects/scuttle/
+ http://scuttle.org/
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-***************************************************************************/
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ ***************************************************************************/
 
 require_once('header.inc.php');
 
@@ -36,64 +36,78 @@ isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_
 $tplVars = array();
 
 if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['size'] > 0) {
-    $userinfo = $userservice->getCurrentObjectUser();
-
-    if (is_numeric(POST_STATUS)) {
-        $status = intval(POST_STATUS);
-    } else {
-        $status = 2;
-    }
-
-    // File handle
-    $html = file_get_contents($_FILES['userfile']['tmp_name']);
-    
-    // Create link array
-    preg_match_all('/<a\s+(.*?)\s*\/*>([^<]*)/si', $html, $matches);
-    $links = $matches[1];
-    $titles = $matches[2];
-    
-    $size = count($links);
-    for ($i = 0; $i < $size; $i++) {
-        $attributes = preg_split('/\s+/s', $links[$i]);
-        foreach ($attributes as $attribute) {
-            $att = preg_split('/\s*=\s*/s', $attribute, 2);
-            $attrTitle = $att[0];
-            $attrVal = eregi_replace('"', '&quot;', preg_replace('/([\'"]?)(.*)\1/', '$2', $att[1]));
-            switch ($attrTitle) {
-                case "HREF":
-                    $bAddress = $attrVal;
-                    break;
-                case "ADD_DATE":
-                    $bDatetime = gmdate('Y-m-d H:i:s', $attrVal);
-                    break;
-            }
-        }
-        $bTitle = eregi_replace('"', '&quot;', trim($titles[$i]));
-
-        if ($bookmarkservice->bookmarkExists($bAddress, $userservice->getCurrentUserId())) {
-            $tplVars['error'] = T_('You have already submitted this bookmark.');
-        } else {
-           // If bookmark is local (like javascript: or place: in Firefox3), do nothing
-           if(substr($bAddress, 0, 7) == "http://") {
-
-                // If bookmark claims to be from the future, set it to be now instead
-                if (strtotime($bDatetime) > time()) {
-                    $bDatetime = gmdate('Y-m-d H:i:s');
-                }
-
-                if ($bookmarkservice->addBookmark($bAddress, $bTitle, NULL, $status, NULL, $bDatetime, false, true)) {
-                    $tplVars['msg'] = T_('Bookmark imported.');
-                } else {
-                    $tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.');
-                }
-           }
-        }
-    }
-    header('Location: '. createURL('bookmarks', $userinfo->getUsername()));
+       $userinfo = $userservice->getCurrentObjectUser();
+
+       if (is_numeric(POST_STATUS)) {
+               $status = intval(POST_STATUS);
+       } else {
+               $status = 2;
+       }
+
+       // File handle
+       $html = file_get_contents($_FILES['userfile']['tmp_name']);
+
+       // Create link array
+       preg_match_all('/<a\s+(.*?)\s*\/*>([^<]*)/si', $html, $matches);
+       $links = $matches[1];
+       $titles = $matches[2];
+
+       $size = count($links);
+       for ($i = 0; $i < $size; $i++) {
+
+               //      echo "<hr/>";
+               //      echo $links[$i]."<br/>";
+                
+               preg_match_all('/(\w*\s*=\s*"[^"]*")/', $links[$i], $attributes);
+               //$attributes = $attributes[0];  // we keep just one row
+
+               $bDatetime = ""; //bDateTime optional
+               $bCategories = ""; //bCategories optional
+
+               foreach ($attributes[0] as $attribute) {
+                       $att = preg_split('/\s*=\s*/s', $attribute, 2);
+                       $attrTitle = $att[0];
+
+                       $attrVal = eregi_replace('"', '&quot;', preg_replace('/([\'"]?)(.*)\1/', '$2', $att[1]));
+
+                       switch ($attrTitle) {
+                               case "HREF":
+                                       $bAddress = $attrVal;
+                                       break;
+                               case "ADD_DATE":
+                                       $bDatetime = gmdate('Y-m-d H:i:s', $attrVal);
+                                       break;
+                               case "TAGS":
+                                       $bCategories = $attrVal;
+                                       break;
+                       }
+               }
+               $bTitle = eregi_replace('"', '&quot;', trim($titles[$i]));
+
+               if ($bookmarkservice->bookmarkExists($bAddress, $userservice->getCurrentUserId())) {
+                       $tplVars['error'] = T_('You have already submitted this bookmark.');
+               } else {
+                       // If bookmark is local (like javascript: or place: in Firefox3), do nothing
+                       if(substr($bAddress, 0, 7) == "http://") {
+
+                               // If bookmark claims to be from the future, set it to be now instead
+                               if (strtotime($bDatetime) > time()) {
+                                       $bDatetime = gmdate('Y-m-d H:i:s');
+                               }
+
+                               if ($bookmarkservice->addBookmark($bAddress, $bTitle, NULL, $status, $bCategories, $bDatetime, false, true)) {
+                                       $tplVars['msg'] = T_('Bookmark imported.');
+                               } else {
+                                       $tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.');
+                               }
+                       }
+               }
+       }
+       header('Location: '. createURL('bookmarks', $userinfo->getUsername()));
 } else {
-    $templatename = 'importNetscape.tpl';
-    $tplVars['subtitle'] = T_('Import Bookmarks from Browser File');
-    $tplVars['formaction'] = createURL('importNetscape');
-    $templateservice->loadTemplate($templatename, $tplVars);
+       $templatename = 'importNetscape.tpl';
+       $tplVars['subtitle'] = T_('Import Bookmarks from Browser File');
+       $tplVars['formaction'] = createURL('importNetscape');
+       $templateservice->loadTemplate($templatename, $tplVars);
 }
 ?>
index 241934e923f04939758dda0e92d01f6ab48856f9..ad79d34218b75073b6b95d96afcec50d4b158f11 100644 (file)
@@ -462,9 +462,9 @@ class UserService {
                        list($emailUser, $emailDomain) = split("@", $email);
 
                        // Check if the email domain has a DNS record
-                       if ($this->_checkdns($emailDomain)) {
+                       //if ($this->_checkdns($emailDomain)) {
                                return true;
-                       }
+                       //}
                }
                return false;
        }
index 7ab54ab6ee991eeaa96fcb5f8470f8e06f3dfa09..05d3e1b7ee20bbb44d973c74d0f11fdb8988d7e9 100644 (file)
@@ -10,6 +10,7 @@ $cdservice =& ServiceFactory::getServiceInstance('CommonDescriptionService');
 $currentObjectUser = $userservice->getCurrentObjectUser();
 
 $pageName = isset($pageName)?$pageName:"";
+$user = isset($user)?$user:"";
 
 $this->includeTemplate($GLOBALS['top_include']);
 
index 88d42d68b9e289ad3c2f69f36cf709fb288ccef4..81336f9d4f99c145d012844c99bf0d6346e3efe8 100644 (file)
@@ -2,6 +2,9 @@
 $b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
 $userservice =& ServiceFactory::getServiceInstance('UserService');
 
+if(!isset($user)) $user="";
+
+
 $logged_on_userid = $userservice->getCurrentUserId();
 if ($logged_on_userid === false) {
     $logged_on_userid = NULL;
index 2039db2f7d77ff751a6d54d4872296279880c33e..633e3f8496e55cd402429d4a44263e397bcb639e 100644 (file)
@@ -23,12 +23,12 @@ if(isset($rsschannels)) {
        src="<?php echo ROOT ?>jsScuttle.php"></script>
 
 
-<link rel="stylesheet" type="text/css"
+<!-- link rel="stylesheet" type="text/css"
        href="http://ajax.googleapis.com/ajax/libs/dojo/1.2/dijit/themes/nihilo/nihilo.css">
 
 <script type="text/javascript"
        src="http://ajax.googleapis.com/ajax/libs/dojo/1.2/dojo/dojo.xd.js"
-       djConfig="parseOnLoad:true, isDebug:false, usePlainJson:true"></script>
+       djConfig="parseOnLoad:true, isDebug:false, usePlainJson:true"></script> -->
  
 <script type="text/javascript">
 dojo.require("dojo.parser");