Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "phpbb-extension",
"description": "Enables tagging of topics",
"homepage": "https://github.com/RobertHeim/phpbb-ext-topictags",
"version": "3.0.0",
"version": "3.0.1",
"time": "2014-05-30",
"keywords": ["phpbb", "extension", "topic tags", "tags", "tag", "tagging", "rh"],
"license": "GPL-2.0",
Expand Down
17 changes: 16 additions & 1 deletion event/main_listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static function getSubscribedEvents()
{
return array(
'core.user_setup' => 'load_language_on_setup',
'core.permissions' => 'permissions',
'core.index_modify_page_title' => 'index_modify_page_title',
'core.modify_posting_parameters' => 'modify_posting_parameters',
'core.posting_modify_template_vars' => 'posting_modify_template_vars',
Expand Down Expand Up @@ -125,6 +126,20 @@ public function load_language_on_setup($event)
$event['lang_set_ext'] = $lang_set_ext;
}

/**
* Loads the permissions.
*
* @param mixed $event The event data
*/
public function permissions($event)
{
$permissions = $event['permissions'];
$permissions[permissions::ADMIN_EDIT_TAGS] = array('lang' => 'ACL_'.utf8_strtoupper(permissions::ADMIN_EDIT_TAGS), 'cat' => 'posting');
$permissions[permissions::MOD_EDIT_TAGS] = array('lang' => 'ACL_'.utf8_strtoupper(permissions::MOD_EDIT_TAGS), 'cat' => 'post_actions');
$permissions[permissions::USE_TAGS] = array('lang' => 'ACL_'.utf8_strtoupper(permissions::USE_TAGS), 'cat' => 'post');
$event['permissions'] = $permissions;
}

/**
* Event: core.index_modify_page_title
*/
Expand Down Expand Up @@ -418,4 +433,4 @@ public function delete_topics_before_query($event)
$topic_ids = $data['topic_ids'];
$this->tags_manager->remove_all_tags_from_topics($topic_ids, true);
}
}
}
6 changes: 5 additions & 1 deletion language/ru/topictags.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
'RH_TOPICTAGS_SEARCH_HEADER_AND' => 'Поиск по темам с любым из этих тегов: %s',
'RH_TOPICTAGS_SEARCH_IGNORED_TAGS' => 'Следующие теги будут проигнорированы, поскольку они неправильные: %s',

'RH_TOPICTAGS_NO_TOPICS_FOR_NO_TAG' => 'Пожалуйста, найдите хотя бы один допустимый тег, чтобы отобразить темы.',
'RH_TOPICTAGS_NO_TOPICS_FOR_TAG_OR' => 'Нет тем ни с одним из этих тегов: %s',
'RH_TOPICTAGS_NO_TOPICS_FOR_TAG_AND' => 'Нет тем с этими тегами: %s',

Expand All @@ -41,5 +42,8 @@
1 => 'Самый популярный тег: %d.',
2 => 'Самые популярные теги: %d.',
),


'RH_TOPICTAGS_TAG_SEARCH' => 'Поиск по тегам',

'RH_TOPICTAGS_TAG_SUGGEST_TAG_ROUTE_ERROR' => 'Маршрут не найден для “%s”',
));
247 changes: 247 additions & 0 deletions styles/all/template/angular.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion styles/all/template/css_includes.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- IF S_ALLOW_CDN -->
<!-- INCLUDECSS //cdnjs.cloudflare.com/ajax/libs/ng-tags-input/2.1.1-1/ng-tags-input.min.css -->
<!-- ELSE -->
<!-- INCLUDECSS @robertheim_topictags/../angular/ng-tags-input.min.css -->
<!-- INCLUDECSS @robertheim_topictags/ng-tags-input.min.css -->
<!-- ENDIF -->
<!-- ENDIF -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<dd>{L_RH_TOPICTAGS_ALLOWED_TAGS}
<!-- IF S_RH_TOPICTAGS_WHITELIST_ENABLED -->
<br/>
<!-- INCLUDEJS @robertheim_topictags/../whitelist.js -->
<!-- INCLUDEJS @robertheim_topictags/whitelist.js -->
<div class="rh_topictags_whitelist">
<!-- BEGIN rh_topictags_whitelist -->
{% include 'simple_tag.html' with {'NAME' : rh_topictags_whitelist.NAME, 'LINK' : rh_topictags_whitelist.LINK} only %}
Expand Down
6 changes: 3 additions & 3 deletions styles/all/template/js_includes.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- IF S_ALLOW_CDN -->
<!-- INCLUDEJS //ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js -->
<!-- ELSE -->
<!-- INCLUDEJS @robertheim_topictags/../angular/angular.min.js -->
<!-- INCLUDEJS @robertheim_topictags/angular.min.js -->
<!-- ENDIF -->

<!-- IF 0 -->
Expand All @@ -12,7 +12,7 @@
When the PR is merged we should update the whole lib and provide CDN, e.g., for 2.1.1-1:
INCLUDEJS //cdnjs.cloudflare.com/ajax/libs/ng-tags-input/2.1.1-1/ng-tags-input.min.js
<!-- ENDIF -->
<!-- INCLUDEJS @robertheim_topictags/../angular/ng-tags-input.2.1.1-1.workaroundissue278.min.js -->
<!-- INCLUDEJS @robertheim_topictags/ng-tags-input.2.1.1-1.workaroundissue278.min.js -->

<!-- INCLUDEJS @robertheim_topictags/../angular/taginput.app.js -->
<!-- INCLUDEJS @robertheim_topictags/taginput.app.js -->
<!-- ENDIF -->

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions styles/all/template/taginput.app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
$.fn.flash = function(duration, iterations) {
duration = duration || 1000; // Default to 1 second
iterations = iterations || 1; // Default to 1 iteration
var iterationDuration = Math.floor(duration / iterations);

for (var i = 0; i < iterations; i++) {
this.fadeOut(iterationDuration).fadeIn(iterationDuration);
}
return this;
}

/**
* btoa() is not utf8 safe by default
*/
function utf8_to_b64( str ) {
return window.btoa(encodeURIComponent(str));
}

function b64_to_utf8( str ) {
return decodeURIComponent(window.atob(str));
}

angular.module('rhTopicTagsInputApp', ['ngTagsInput'])
.config(function($interpolateProvider, $httpProvider) {
$interpolateProvider.startSymbol('{[{').endSymbol('}]}');
$httpProvider.defaults.headers.common["X-Requested-With"] = 'XMLHttpRequest';
})
.controller('rhTopicTagsInputCtrl', function($scope, $http) {
$scope.tags = [];
$scope.init = function (initTags) {
if ('' != initTags) {
initTags = JSON.parse(b64_to_utf8(initTags));
for (var i = 0; i < initTags.length; i++) {
this.tags.push(initTags[i]);
}
}
}
$scope.loadTags = function(query) {
var data = {
'query': query,
'exclude' : $scope.tags.map(function(tag) {
return tag.text;
})
};
return $http.post('/tags/suggest', data);
};
$scope.addTag = function(tag) {
var found = false;
this.tags.every(function(element, index, array) {
if (element.text == tag) {
found = true;
return false;
}
return true;
});
if (!found) {
this.tags.push({"text": tag});
} else {
$("span:contains('"+tag+"')")
.filter(function() {
return $(this).text() === tag;
})
.parent()
.flash(200, 3);
}
}
$scope.jsonRep = '';
$scope.$watch('tags', function(t) {
$scope.jsonRep = utf8_to_b64(JSON.stringify(t));
}, true);
});
11 changes: 11 additions & 0 deletions styles/all/template/whitelist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$(function(){
$('.rh_topictags_whitelist').find('a').click(function(event){
event.preventDefault();

var $scope = angular.element($("#rhTopicTagsInputAppScope")).scope();
var t = $(this).parent().text();
$scope.$apply(function($scope) {
$scope.addTag(t);
});
});
});
Loading