Skip to content

Commit

Permalink
Some overall improvements and bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Wouter0100 committed Mar 10, 2016
1 parent f4a3c0b commit 48464d2
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 55 deletions.
26 changes: 11 additions & 15 deletions lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,32 +293,28 @@ function follow_tags_get_all_tags($limit) {
'limit' => $limit,
'threshold' => $threshold,
'tag_name' => 'tags',
);
);

$tags = elgg_get_tags($options);

$json = array();

foreach ($tags as $tag) {
$json[]=$tag->tag;
$json[] = $tag->tag;
}

$deftags = elgg_get_plugin_setting("defaultTags", "follow_tags");

if (!empty($deftags)) {

$deftags = explode(",",$deftags);
$json = array_merge($deftags,$json);

$defaultTags = elgg_get_plugin_setting("defaultTags", "follow_tags");

if (!empty($defaultTags)) {
$defaultTags = explode(',', $defaultTags);
$json = array_merge($defaultTags, $json);
}

if ($json) {
if (is_array($json)) {
$json = json_encode($json);
}else {
$json = "[]";
$json = '[]';
}



return $json;
}

Expand Down
30 changes: 15 additions & 15 deletions start.php
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
<?php

require_once(dirname(__FILE__) . "/lib/functions.php");
require_once(dirname(__FILE__) . '/lib/functions.php');

elgg_register_event_handler('init', 'system', 'follow_tags_init');

function follow_tags_init() {

// Load follow-tags configuration

if(elgg_get_plugin_setting("followTags", "follow_tags") == "true") {
if(elgg_get_plugin_setting('followTags', 'follow_tags') == 'true') {

// Register Cache-Clear hook after change admin settig
elgg_register_plugin_hook_handler("setting", "plugin", "follow_tags_setting");
elgg_register_plugin_hook_handler('setting', 'plugin', 'follow_tags_setting');

//Register Save Action for saving and changing FollowTags
elgg_register_action("follow_tags/save", dirname(__FILE__) . '/action/save_notify.php');
elgg_register_action("follow_tags/activity", dirname(__FILE__) . '/action/save.php');
elgg_register_action('follow_tags/save', dirname(__FILE__) . '/action/save_notify.php');
elgg_register_action('follow_tags/activity', dirname(__FILE__) . '/action/save.php');


//Register a River Tab
if (elgg_is_logged_in()) {
$user = elgg_get_logged_in_user_entity();
elgg_register_menu_item('filter', array(
'name' => 'tags',
'href' => "/activity/tags",
'text' => elgg_echo("follow_tags:tab:title"),
'href' => '/activity/tags',
'text' => elgg_echo('follow_tags:tab:title'),
'priority' => 500,
'contexts' => array('activity'),

));

//Register a Sidebar Item for Usersettings
elgg_register_menu_item('page', array(
'name' => "follow_tags",
'text' => elgg_echo("follow_tags:sidebar:title"),
'href' => "follow_tags/settings/" . $user->username,
'context' => "settings",
'name' => 'follow_tags',
'text' => elgg_echo('follow_tags:sidebar:title'),
'href' => 'follow_tags/settings/' . $user->username,
'context' => 'settings',
));
}

elgg_register_plugin_hook_handler("route", "activity", "follow_tags_route_activity_hook");
elgg_register_plugin_hook_handler('route', 'activity', 'follow_tags_route_activity_hook');

//Register Pagehandlers
elgg_register_page_handler('follow_tags', 'follow_tags_page_handler');
Expand All @@ -58,7 +58,7 @@ function follow_tags_init() {
elgg_register_css('jquery.tagsinput', $css_url);

// extend tags to include js/css just in time
elgg_extend_view("input/tags", "follow_tags/extends/tags");
elgg_extend_view('input/tags', 'follow_tags/extends/tags');

// Add a JavaScript Initialization
elgg_extend_view('js/elgg','js/follow_tags/site');
Expand All @@ -76,8 +76,8 @@ function follow_tags_data_page_handler() {
function follow_tags_route_activity_hook($hook, $type, $return_value, $params) {
$result = $return_value;

if ($page = elgg_extract("segments", $return_value)){
if (elgg_extract(0, $page) == "tags") {
if ($page = elgg_extract('segments', $return_value)){
if (elgg_extract(0, $page) == 'tags') {
include(dirname(__FILE__) . '/pages/activity/follow_tags.php');

$result = false; // block other page handlers
Expand Down
50 changes: 25 additions & 25 deletions views/default/js/follow_tags/site.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,44 @@
/*
* Get autocomplete settings
*/
$minChar = elgg_get_plugin_setting("minChar", "follow_tags");
if(!$minChar) {
$minChar = 2; // Set Default minChar
}
$minChar = elgg_get_plugin_setting('minChar', 'follow_tags');
if(!$minChar) {
$minChar = 2; // Set Default minChar
}

$tagLimit = elgg_get_plugin_setting("tagLimit", "follow_tags");
if(!$tagLimit OR $tagLimit == 0) {
$tagLimit = null; // Set Default minChar
}
$tagLimit = elgg_get_plugin_setting('tagLimit', 'follow_tags');
if(!$tagLimit OR $tagLimit == 0) {
$tagLimit = null; // Set Default minChar
}

$removeConfirmation = elgg_get_plugin_setting("removeConfirmation", "follow_tags");
if(!$removeConfirmation) {
$removeConfirmation = "true"; // Set Default minChar
}
$removeConfirmation = elgg_get_plugin_setting('removeConfirmation', 'follow_tags');
if(!$removeConfirmation) {
$removeConfirmation = 'true'; // Set Default minChar
}

$caseSensitive = elgg_get_plugin_setting("caseSensitive", "follow_tags");
if(!$caseSensitive) {
$caseSensitive = "true"; // Set Default minChar
}
$caseSensitive = elgg_get_plugin_setting('caseSensitive', 'follow_tags');
if(!$caseSensitive) {
$caseSensitive = 'true'; // Set Default minChar
}

$allowSpaces = elgg_get_plugin_setting("allowSpaces", "follow_tags");
if(!$allowSpaces) {
$allowSpaces = "false"; // Set Default minChar
}
$allowSpaces = elgg_get_plugin_setting('allowSpaces', 'follow_tags');
if(!$allowSpaces) {
$allowSpaces = 'false'; // Set Default minChar
}
?>

elgg.provide('elgg.tags_input');

elgg.tags_input.init = function() {
$('div:not(.mandatory) > .elgg-input-tags').each(function(){
var el = $(this);
$.getJSON( '<?php echo elgg_get_site_url(); ?>follow_tags_data', function( tags ) {
$.getJSON( '<?php echo elgg_get_site_url(); ?>follow_tags_data', function( tags ) {
$('div:not(.mandatory) > .elgg-input-tags').each(function(){
var el = $(this);
$(el).tagit({
placeholderText: '<?php echo elgg_echo("follow_tags:tags_input:add"); ?>',
placeholderText: '<?php echo elgg_echo('follow_tags:tags_input:add'); ?>',
availableTags: tags,
autocomplete: {delay: 0, minLength: <?php echo $minChar; ?>},
tagLimit: '<?php echo $tagLimit; ?>',
removeConfirmation: <?php echo $removeConfirmation; ?>,
removeConfirmation: <?php echo $removeConfirmation; ?>,
caseSensitive: <?php echo $caseSensitive; ?>,
allowSpaces: <?php echo $allowSpaces; ?>,

Expand Down

0 comments on commit 48464d2

Please sign in to comment.