Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

Automatic tagging #5

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8d3edff
Initial hack'n'slash at autotagging new bookmarks.
kenguest Nov 20, 2013
ba55544
missing update
kenguest Nov 20, 2013
b3c9c5c
remove dupes
kenguest Nov 20, 2013
0c7f313
If at a 'help' or 'hilfe' subsite, we can make an educated guess...
kenguest Nov 20, 2013
80729df
Fix package name.
kenguest Nov 20, 2013
a805727
Coding Standards...
kenguest Nov 25, 2013
428418a
some small CS changes.
kenguest Nov 28, 2013
45fe2fa
some CS issues.
kenguest Dec 3, 2013
fe52350
tweaks and fixes.
kenguest Dec 3, 2013
b707390
lazy add of mf2 to the project
kenguest Dec 3, 2013
128fb9f
some additional classes that we will be using
kenguest Dec 3, 2013
4345e9b
remove superfluous file
kenguest Dec 3, 2013
3d85a87
commit changes before I lose them.
kenguest Dec 9, 2013
9447bc8
Remove dead code, add config setting.
kenguest Dec 19, 2013
0836162
www/bookmarks.php adheres to PEAR Coding Standards
kenguest Dec 19, 2013
add35e3
Tweak defineWithDefault to return define's return value.
kenguest Dec 19, 2013
43f66e5
remove var_dump
kenguest Dec 22, 2013
5695303
CS issues.
kenguest Jan 27, 2014
c6115da
CS issues and comment out hardcoded checks.
kenguest Jan 27, 2014
24c22bf
Fix odd class declaration.
kenguest Jan 29, 2014
1db8217
Utilise parsely-page meta tag occasionally present in Wordpress blogs
kenguest Feb 12, 2014
31a2ce5
Display suggested tags as a tag cloud
kenguest Feb 12, 2014
4086425
Some work done on adding Suggested Tags div when ajax is involved.
kenguest Mar 4, 2014
afcb6a5
slight tidy-up
kenguest Mar 5, 2014
74cd7d8
escape tags in getChoiceTags
kenguest Sep 30, 2014
bc83ba8
add status attribute to post in all relevant api functions
pascalfree Jan 16, 2014
fbb1f54
add option to get last modified date instead of creation date
pascalfree Mar 26, 2014
fc49443
add scuttleoid to docs/tools
cweiske Mar 31, 2014
7bfe793
mention scuttle for android
cweiske Mar 31, 2014
3432800
mention scuttle for android
cweiske Mar 31, 2014
f11507b
Add support for phancap website thumbnailer.
cweiske Apr 23, 2014
246aec6
link pear manual ldap options
cweiske Jul 20, 2014
df5bd61
Integrate Firefox Social API for bookmarking
cweiske Jan 21, 2015
6025f32
Merge w upstream
kenguest Jan 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
minimum_version="0.4.0"
/>
<!-- unit tests: -->
<package name="HTML_Request2"
<package name="HTTP_Request2"
channel="pear.php.net"
minimum_version="2.0.0"
/>
Expand Down
9 changes: 7 additions & 2 deletions data/config.default.php
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,12 @@
'menu2', 'tags', 'configurable', 'in', 'data/config.php'
);


/**
* Automatic tag extraction
*
* @var boolean
*/
$tagExtraction = true;

/****************************
* Search
Expand Down Expand Up @@ -655,7 +660,7 @@
* a simple value "xxx" (like "author") automatically associates xxx with
* [xxx][/xxx].
* A complex value "xxx"=>"yyy" (like "address") directly
* associates xxx with yyy.
* associates xxx with yyy.
*
* @var array
*/
Expand Down
19 changes: 12 additions & 7 deletions data/templates/default/dynamictags.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
$allPopularTagsCloud = $b2tservice->tagCloud($allPopularTags, 5, 90, 175);
$allPopularTagsCount = count($allPopularTags);

$suggestedTagsCloud = $b2tservice->tagCloud($row['extractedTags'], 5, 90, 175);
$suggestedTagsCount = count($row['extractedTags']);

// function printing the cloud
function writeTagsProposition($tagsCloud, $title)
Expand All @@ -49,7 +51,7 @@ function writeTagsProposition($tagsCloud, $title)
+ ' <p class="popularTags tags"></p>'
+ '</div>');
JS;

$taglist = '';
foreach (array_keys($tagsCloud) as $key) {
$row = $tagsCloud[$key];
Expand Down Expand Up @@ -101,6 +103,9 @@ function addonload(addition) {

jQuery(function($) {
<?php
if ($suggestedTagsCount > 0) {
writeTagsProposition($suggestedTagsCloud, 'Suggested Tags');
}
if ($userPopularTagsCount > 0) {
writeTagsProposition($userPopularTagsCloud, T_('Popular Tags'));
}
Expand All @@ -110,9 +115,9 @@ function addonload(addition) {
?>
var taglist = $('#tags');
var tags = taglist.val().split(', ');

var populartags = $('.edit-tagclouds span');

for (var i = 0; i < populartags.length; i++) {
if (tags.contains(populartags[i].innerHTML)) {
populartags[i].className = 'selected';
Expand All @@ -124,20 +129,20 @@ function addTag(ele) {
var thisTag = ele.innerHTML;
var taglist = document.getElementById('tags');
var tags = taglist.value.split(', ');

// If tag is already listed, remove it
if (tags.contains(thisTag)) {
tags = tags.remove(thisTag);
ele.className = 'unselected';

// Otherwise add it
} else {
tags.splice(0, 0, thisTag);
ele.className = 'selected';
}

taglist.value = tags.join(', ');

document.getElementById('tags').focus();
}
//]]>
Expand Down
6 changes: 3 additions & 3 deletions data/templates/default/editbookmark.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ function fixOperaButtonName($name) {
</th>
<td><textarea name="description" id="description" rows="5" cols="63" ><?php echo filter($row['bDescription'], 'xml'); ?></textarea></td>
<td>← <?php echo T_('You can use anchors to delimite attributes. for example: [publisher]blah[/publisher] '); ?>
<?php if(count($GLOBALS['descriptionAnchors'])>0): ?>
<?php if (count($GLOBALS['descriptionAnchors'])>0): ?>
<br /><br />
<?php echo T_('Suggested anchors: '); ?>
<?php foreach($GLOBALS['descriptionAnchors'] as $anchorName => $anchorValue): ?>
<?php if(is_numeric($anchorName)) {
<?php if (is_numeric($anchorName)) {
$anchorName = $anchorValue;
$anchorValue = '['.$anchorValue.']'.'[/'.$anchorValue.']';
} ?>
Expand All @@ -72,7 +72,7 @@ function fixOperaButtonName($name) {
<?php endif; ?>
</td>
</tr>
<tr id="privateNoteZone" <?php if(strlen($row['bPrivateNote'])==0):?>style="display:none"<?php endif; ?>>
<tr id="privateNoteZone" <?php if (strlen($row['bPrivateNote'])==0):?>style="display:none"<?php endif; ?>>
<th align="left"><?php echo T_('Private Note'); ?></th>
<td><textarea name="privateNote" id="privateNote" rows="1" cols="63" ><?php echo filter($row['bPrivateNote'], 'xml'); ?></textarea></td>
<td>← <?php echo T_('Just visible by you and your contacts.'); ?>
Expand Down
12 changes: 6 additions & 6 deletions src/SemanticScuttle/Service/AuthUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SemanticScuttle_Service_AuthUser extends SemanticScuttle_Service_User
* @link http://pear.php.net/manual/en/package.authentication.auth.intro-storage.php
*/
var $authtype = null;

/**
* Authentication options
*
Expand Down Expand Up @@ -86,7 +86,7 @@ public static function getInstance($db)
/**
* Create new instance
*
* @var sql_db $db Database object
* @param sql_db $db Database object
*/
protected function __construct($db)
{
Expand All @@ -100,11 +100,11 @@ protected function __construct($db)
if (!$this->authtype) {
return;
}
require_once 'Auth.php';
include_once 'Auth.php';
$this->auth = new Auth($this->authtype, $this->authoptions);
//FIXME: check if it worked (i.e. db connection)
if ($this->authdebug) {
require_once 'Log.php';
include_once 'Log.php';
$this->auth->logger = Log::singleton(
'display', '', '', array(), PEAR_LOG_DEBUG
);
Expand Down Expand Up @@ -208,7 +208,7 @@ public function loginAuth($username, $password)
}

return true;
}
}



Expand All @@ -229,4 +229,4 @@ public function logout()
}

}
?>
?>
49 changes: 47 additions & 2 deletions src/SemanticScuttle/Service/Bookmark2Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function attachTags(
$this->db->sql_transaction('begin');

if ($replace) {
if (!$this->deleteTagsForBookmark($bookmarkid)){
if (!$this->deleteTagsForBookmark($bookmarkid)) {
$this->db->sql_transaction('rollback');
message_die(GENERAL_ERROR, 'Could not attach tags (deleting old ones failed)', '', __LINE__, __FILE__, $sql, $this->db);
return false;
Expand Down Expand Up @@ -379,6 +379,51 @@ function &getTags($userid = NULL) {
return $output;
}

/**
* Given an array of named tags, return an array containing them and the
* count of occurrences of them. Much the same as what getTags returns but
* a subset of it.
*
* @param array $tags
* @param null|id $userid
*
* @return array
*/
function getChoiceTags($tags, $userid = NULL) {
$userservice =SemanticScuttle_Service_Factory::get('User');
$logged_on_user = $userservice->getCurrentUserId();

$ftags = array();
foreach($tags as $tag) {
$ftags[] = $this->db->sql_escape(trim($tag));
}

$imp = implode('\',\'', $ftags);
$imp = '\'' . $imp . '\'';

$query = 'SELECT T.tag, COUNT(B.bId) AS bCount FROM '. $GLOBALS['tableprefix'] .'bookmarks AS B INNER JOIN '. $userservice->getTableName() .' AS U ON B.uId = U.'. $userservice->getFieldName('primary') .' INNER JOIN '. $GLOBALS['tableprefix'] .'bookmarks2tags AS T ON B.bId = T.bId';

$conditions = array();
if (!is_null($userid)) {
$conditions['U.'. $userservice->getFieldName('primary')] = intval($userid);
if ($logged_on_user != $userid)
$conditions['B.bStatus'] = 0;
} else {
$conditions['B.bStatus'] = 0;
}

$query .= ' WHERE '. $this->db->sql_build_array('SELECT', $conditions) .' AND T.tag in ('. $imp .') GROUP BY T.tag ORDER BY bCount DESC, tag';

if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not get tags', '', __LINE__, __FILE__, $query, $this->db);
return false;
}

$output = $this->db->sql_fetchrowset($dbresult);
$this->db->sql_freeresult($dbresult);
return $output;
}


// Returns the tags related to the specified tags; i.e. attached to the same bookmarks
function &getRelatedTags($tags, $for_user = NULL, $logged_on_user = NULL, $limit = 10) {
Expand Down Expand Up @@ -417,7 +462,7 @@ function &getRelatedTags($tags, $for_user = NULL, $logged_on_user = NULL, $limit
$query_5 = ' AND LEFT(T0.tag, 7) <> "system:" GROUP BY T0.tag ORDER BY bCount DESC, T0.tag';
$query = $query_1 . $query_2 . $query_3 . $query_4 . $query_5;

if (! ($dbresult = $this->db->sql_query_limit($query, $limit)) ){
if (! ($dbresult = $this->db->sql_query_limit($query, $limit)) ) {
message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db);
return false;
}
Expand Down
Loading