aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SemanticScuttle/Service/Bookmark.php10
-rw-r--r--src/SemanticScuttle/Service/Bookmark2Tag.php10
-rw-r--r--src/SemanticScuttle/UrlHelper.php65
-rw-r--r--src/SemanticScuttle/header.php1
4 files changed, 79 insertions, 7 deletions
diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php
index ea8762d..8a8946a 100644
--- a/src/SemanticScuttle/Service/Bookmark.php
+++ b/src/SemanticScuttle/Service/Bookmark.php
@@ -504,7 +504,9 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
'bPrivateNote' => $privateNote,
'bStatus' => intval($status),
'bHash' => $this->getHash($address),
- 'bShort' => $short
+ 'bShort' => $short,
+ 'bVoting' => 0,
+ 'bVotes' => 0,
);
$sql = 'INSERT INTO '. $this->getTableName()
@@ -738,7 +740,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
$tags = [];
}
- $tagcount = count($tags);
+ $tagcount = empty($tags) ? 0 : count($tags);
for ($i = 0; $i < $tagcount; $i ++) {
$tags[$i] = trim($tags[$i]);
}
@@ -861,7 +863,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
}
// Search terms in tags as well when none given
- if (!count($tags)) {
+ if (!empty($tags)) {
$query_2 .= ' LEFT JOIN '. $b2tservice->getTableName() .' AS T'
. ' ON B.bId = T.bId';
$dotags = true;
@@ -1144,7 +1146,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
// Delete final /
if (substr($address, -1) == '/') {
- $address = substr($address, 0, count($address)-2);
+ $address = substr($address, 0, strlen($address)-2);
}
return $address;
diff --git a/src/SemanticScuttle/Service/Bookmark2Tag.php b/src/SemanticScuttle/Service/Bookmark2Tag.php
index a01b5d7..2579022 100644
--- a/src/SemanticScuttle/Service/Bookmark2Tag.php
+++ b/src/SemanticScuttle/Service/Bookmark2Tag.php
@@ -691,14 +691,12 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
}
if ($sortOrder == 'alphabet_asc') {
- usort($output, create_function('$a,$b','return strcasecmp(utf8_deaccent($a["tag"]), utf8_deaccent($b["tag"]));'));
+ usort($output, "cmp");
}
return $output;
}
-
-
/**
* Deletes all tags in bookmarks2tags
*
@@ -711,4 +709,10 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
}
}
+
+function cmp($a,$b)
+{
+ return strcasecmp(utf8_deaccent($a["tag"]), utf8_deaccent($b["tag"]));
+}
+
?>
diff --git a/src/SemanticScuttle/UrlHelper.php b/src/SemanticScuttle/UrlHelper.php
new file mode 100644
index 0000000..5417b9b
--- /dev/null
+++ b/src/SemanticScuttle/UrlHelper.php
@@ -0,0 +1,65 @@
+<?php
+/**
+ * SemanticScuttle - your social bookmark manager.
+ *
+ * PHP version 5.
+ *
+ * @category Bookmarking
+ * @package SemanticScuttle
+ * @author Christian Weiske <cweiske@cweiske.de>
+ * @license GPL http://www.gnu.org/licenses/gpl.html
+ * @link http://sourceforge.net/projects/semanticscuttle
+ */
+
+/**
+ * Work with URLs
+ *
+ * @category Bookmarking
+ * @package SemanticScuttle
+ * @author Christian Weiske <cweiske@cweiske.de>
+ * @license GPL http://www.gnu.org/licenses/gpl.html
+ * @link http://sourceforge.net/projects/semanticscuttle
+ */
+class SemanticScuttle_UrlHelper
+{
+ function getTitle($url)
+ {
+ $fd = @fopen($url, 'r');
+ $title = '';
+ if ($fd) {
+ $html = fread($fd, 1750);
+ fclose($fd);
+
+ // Get title from title tag
+ preg_match_all('/<title[^>]*>(.*)<\/title>/si', $html, $matches);
+ $title = $matches[1][0];
+
+ $encoding = 'utf-8';
+ // Get encoding from charset attribute
+ preg_match_all('/<meta.*charset=([^;"]*)">/i', $html, $matches);
+ if (isset($matches[1][0])) {
+ $encoding = strtoupper($matches[1][0]);
+ }
+
+ // Convert to UTF-8 from the original encoding
+ if (function_exists("mb_convert_encoding")) {
+ $title = @mb_convert_encoding($title, 'UTF-8', $encoding);
+ }
+
+ $title = trim($title);
+ }
+
+ if (utf8_strlen($title) > 0) {
+ $title = html_entity_decode($title, ENT_QUOTES, 'UTF-8');
+ return $title;
+ } else {
+ // No title, so return filename
+ $uriparts = explode('/', $url);
+ $filename = end($uriparts);
+ unset($uriparts);
+
+ return $filename;
+ }
+ }
+}
+?>
diff --git a/src/SemanticScuttle/header.php b/src/SemanticScuttle/header.php
index 1f2f12c..562ae43 100644
--- a/src/SemanticScuttle/header.php
+++ b/src/SemanticScuttle/header.php
@@ -105,6 +105,7 @@ require_once 'SemanticScuttle/functions.php';
require_once 'SemanticScuttle/Model/Bookmark.php';
require_once 'SemanticScuttle/Model/UserArray.php';
require_once 'SemanticScuttle/Model/User/SslClientCert.php';
+require_once 'SemanticScuttle/UrlHelper.php';
if (count($GLOBALS['serviceoverrides']) > 0
&& !defined('UNIT_TEST_MODE')