News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

Tagging System SMFSIMPLE

Started by vbgamer45, December 11, 2012, 01:24:35 AM

Previous topic - Next topic

nikan

#120
Your solution is working perfectly. Thanks for sharing.

I have changed the unicode regex to letters only, i hope.

Romanj

Also few improvements)

1. As said before, I got encoding problem in autocomplete with russian characters. I fixed it with this:

In Sources/TaggingSystem.php
Find
if (!empty($context['tags_suggests']))
{
$list = '';
foreach ($context['tags_suggests'] as $id => $tagname)
$list .= '<li class="opcion" id="' . $id . '">'.$tagname.'</li>';
}

Replace with
if (!empty($context['tags_suggests']))
{
$list = '';
foreach ($context['tags_suggests'] as $id => $tagname) {
$tagname = iconv("UTF-8", "WINDOWS-1251", $tagname);
$list .= '<li class="opcion" id="' . $id . '">'.$tagname.'</li>'; }
}


For other languages, change WINDOWS-1251 to your type of the encoding.


2. Little bugfix in the Themes\default\css\tags.css

Find
.tag_selectable.tag_suggest ul li:hover{
    background: yellow;
}

Replace with
.tag_selectable .tag_suggest ul li:hover{
    background: yellow;
}


After that hover for autocomplete list starts to work.

3. I think it's right idea to turn off browser's autocomplete for input field. Because two autocomplete at same time obviously could bother users. So, in the Themes\default\Post.template.php (or in the modifications.xml)
Find:
<input id="consulta" type="text" value="', !empty($context['editTags']) ? $context['editTags'] : '','" />
Replace with
<input id="consulta" type="text" autocomplete="off" value="', !empty($context['editTags']) ? $context['editTags'] : '','" />

4. By default, when you click on certain tags, topics sorted by subject. If you think more proper way to sort topics by last answer, there it is:

Sources/TaggingSystem.php
Find
$request = $smcFunc['db_query']('', '
SELECT tt.id, tt.id_tag, tt.id_topic, ta.tag, b.name as board_name, m.id_msg, m.subject, mem.id_member, mem.real_name, mem.avatar,
top.id_topic, top.id_board, top.id_first_msg, top.id_member_started,
IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type
FROM {db_prefix}tags_topic as tt
INNER JOIN {db_prefix}topics AS top ON tt.id_topic = top.id_topic
INNER JOIN {db_prefix}tags AS ta ON tt.id_tag = ta.id_tag
INNER JOIN {db_prefix}messages AS m ON top.id_first_msg = m.id_msg
INNER JOIN {db_prefix}boards AS b ON (b.id_board = top.id_board)
INNER JOIN {db_prefix}members AS mem ON (mem.id_member = top.id_member_started)
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = top.id_member_started)
WHERE tt.id_tag = {int:id_tag} AND {query_see_board}
ORDER BY m.subject ASC
'.(($perpage < 0)  ? '' : 'LIMIT '.$start.','.$perpage.'').'',
array(
'id_tag' => $id_tag,
)
);

Replace with
$request = $smcFunc['db_query']('', '
SELECT tt.id, tt.id_tag, tt.id_topic, ta.tag, b.name as board_name, m.id_msg, m.subject, mem.id_member, mem.real_name, mem.avatar,
top.id_topic, top.id_board, top.id_first_msg, top.id_member_started, top.id_last_msg,
IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type
FROM {db_prefix}tags_topic as tt
INNER JOIN {db_prefix}topics AS top ON tt.id_topic = top.id_topic
INNER JOIN {db_prefix}tags AS ta ON tt.id_tag = ta.id_tag
INNER JOIN {db_prefix}messages AS m ON top.id_first_msg = m.id_msg
INNER JOIN {db_prefix}boards AS b ON (b.id_board = top.id_board)
INNER JOIN {db_prefix}members AS mem ON (mem.id_member = top.id_member_started)
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = top.id_member_started)
WHERE tt.id_tag = {int:id_tag} AND {query_see_board}
ORDER BY top.id_last_msg DESC
'.(($perpage < 0)  ? '' : 'LIMIT '.$start.','.$perpage.'').'',
array(
'id_tag' => $id_tag,
)
);

Romanj

In some cases, when I tried to edit message which reached maximum amount of tags, I've got javascript error, with text "Uncaught TypeError: Cannot call method 'attr' of undefined"

Finally, I fixed it, but again, I don't know is this proper way or not. But it workd for me. There is the way:

In the Themes/default/scripts/tags.js:
Find
function tagSendRequest(campo)
{
    var texto = '';

    if (campo.val() != '')
        texto = prepararTexto(campo.val());
   
    if (texto.length >= conf.filtro)
    {
        if (request != null) request.abort();
       
        request = tg.ajax({

Replace with
function tagSendRequest(campo)
{
    var texto = '';
var checkmax = tg(".tag_selection input").length;
    if (campo.val() != '')
        texto = prepararTexto(campo.val());
   
    if ((texto.length >= conf.filtro)&&(checkmax <= conf.limite))
    {
        if (request != null) request.abort();
       
        request = tg.ajax({


Find
        if (texto.length <= conf.max && conf.min <= texto.length)
        {
            var label = tg('<span>').attr({id: 'opcion' + opcion.attr('id') }).text(texto);
            var accion = tg('<a>').text(" ").attr({href: '#'}).click(function(e){e.preventDefault(); tagRemove(tg(this)); });
            var check = tg('<input>').attr({name: 'tags[]', value: opcion.attr('id'), type: "hidden", alt: texto});
            label.append(check);
            label.append(accion);
            tg('.tag_selection').append(label);
            tg('.tag_suggest').empty();
            tg('#consulta').val('');
           
            if (etiquetas >= conf.limite)
            {
                q.attr('readonly', 'readonly');

Replace with
        if ((texto.length <= conf.max && conf.min <= texto.length)&&(etiquetas <= conf.limite))
        {
            var label = tg('<span>').attr({id: 'opcion' + opcion.attr('id') }).text(texto);
            var accion = tg('<a>').text(" ").attr({href: '#'}).click(function(e){e.preventDefault(); tagRemove(tg(this)); });
            var check = tg('<input>').attr({name: 'tags[]', value: opcion.attr('id'), type: "hidden", alt: texto});
            label.append(check);
            label.append(accion);
            tg('.tag_selection').append(label);
            tg('.tag_suggest').empty();
            tg('#consulta').val('');
           
            if ((etiquetas >= conf.limite)&&(q != null))
            {
                q.attr('readonly', 'readonly');

Find
        if (texto.length <= conf.max && conf.min <= texto.length)
        {
            var label = tg('<span>').attr({name: texto, "class": "tag_new" }).text(texto);
            var accion = tg('<a>').text(" ").attr({href: '#'}).click(function(e){e.preventDefault(); tagRemove(tg(this)); });
            var check = tg('<input>').attr({name: 'tags_news[]', value: texto, type: "hidden", alt: texto });
           
            label.append(check);
            label.append(accion);
            tg('.tag_selection').append(label);
            tg('.tag_suggest').empty();
            tg('#consulta').val('');
           
            if (etiquetas >= conf.limite)
            {
                q.attr('readonly', 'readonly');

Replace with
        if ((texto.length <= conf.max && conf.min <= texto.length)&&(etiquetas <= conf.limite))
        {
            var label = tg('<span>').attr({name: texto, "class": "tag_new" }).text(texto);
            var accion = tg('<a>').text(" ").attr({href: '#'}).click(function(e){e.preventDefault(); tagRemove(tg(this)); });
            var check = tg('<input>').attr({name: 'tags_news[]', value: texto, type: "hidden", alt: texto });
           
            label.append(check);
            label.append(accion);
            tg('.tag_selection').append(label);
            tg('.tag_suggest').empty();
            tg('#consulta').val('');
           
            if ((etiquetas >= conf.limite)&&(q != null))
            {
                q.attr('readonly', 'readonly');

nikan

#123
Change the 1 in Sources/TaggingSystem.php to this:
if (!empty($context['tags_suggests']))
{
$list = '';
foreach ($context['tags_suggests'] as $id => $tagname)
{
if (!$context['utf8'] && function_exists('iconv'))
{
$tag_name = @iconv('UTF-8', $context['character_set'], $tagname);
if ($tag_name)
$tagname = $tag_name;
}
$list .= '<li class="opcion" id="' . $id . '">'.$tagname.'</li>';
}
}



MechSpecs

#124
Ok I have done some extensive testing on this mod today.

FRESH INSTALL OF SMF 2.0.4 (with backed up database from my live site)
FRESH INSTALL OF THEME

Installed the mod and I got an error when attempting to modify the CORE theme but since I don't use the CORE it doesn't matter. Everything was fine on DEFAULT theme modifications.

MOD IS ENABLED: CHECK
TAGS ARE REQUIRED: UNCHECKED
DISABLE TAGS FOR THIS BOARD: 7
SHOW TAG CLOUD: UNCHECKED
SHOW LIST OF TAGS: CHECK
SHOW AMOUNT BY EACH TAG: CHECK
# OF TOPICS PER PAGE ON SEARCH: 25

So here are the bugs and errors I experienced.

ISSUE #1:
When I attempt to edit an existing post, and add tags to that post, it does not save them when I click SAVE post. In order to get around this I have to go and create a NEW dummy/test post and add a bunch of tags to it; that seems to populate the tags section of the database and then everything works. When editing existing posts, to add tags to them, it adds the following errors into my ADMIN ERROR LOG.

Quote
http://www.sitename.org/forum/index.php?action=post2;start=0;msg=10152;fb5f6af4dfb1=cc975f2dc1a0f21c8653636f9ff2482a;board=37
2: Invalid argument supplied for foreach()
File: /home/blahblah/www/www/forum/Sources/TaggingSystem.php
Line: 585

http://www.sitename.org/forum/index.php?action=post2;start=0;msg=10152;fb5f6af4dfb1=cc975f2dc1a0f21c8653636f9ff2482a;board=37
8: Undefined index: tags_news
File: /home/blahblah/www/www/forum/Sources/TaggingSystem.php
Line: 435

http://www.sitename.org/forum/index.php?action=post;msg=10152;topic=1700.0
2: implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed
File: /home/blahblah/www/www/forum/Themes/default/languages/Tagging.english.php (main sub template - eval?)
Line: 409

http://www.sitename.org/forum/index.php?action=post;msg=10152;topic=1700.0
8: Undefined index: tags_news
File: /home/blahblah/www/www/forum/Themes/default/languages/Tagging.english.php (main sub template - eval?)
Line: 409

ISSUE #2:
When making a post in the board where tags are disabled it allows me to do it (since I have require tags unchecked) however I get the following errors in my ADMIN ERROR LOG

Quote
http://www.sitename.org/forum/index.php?action=post2;start=0;board=7
2: Invalid argument supplied for foreach()
File: /home/blahblah/www/www/forum/Sources/TaggingSystem.php
Line: 585

http://www.sitename.org/forum/index.php?action=post2;start=0;board=7
8: Undefined index: tags_news
File: /home/blahblah/www/www/forum/Sources/TaggingSystem.php
Line: 435

http://www.sitename.org/forum/index.php?action=post;board=7.0
2: implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed
File: /home/blahblah/www/www/forum/Themes/default/languages/Tagging.english.php (main sub template - eval?)
Line: 407

http://www.sitename.org/forum/index.php?action=post;board=7.0
8: Undefined index: tags_news
File: /home/blahblah/www/www/forum/Themes/default/languages/Tagging.english.php (main sub template - eval?)
Line: 407

Now my Tagging.english.php file only has 55 lines and not 407 that is for sure. I have no idea what would be causing the other errors.

ISSUE #3:
When I attempt to edit an existing post and REMOVE the tags they won't stay removed after clicking SAVE. I also get the following two errors in my ADMIN LOG FILE

Quote
http://www.sitename.org/forum/index.php?action=post;msg=10152;topic=1700.0
2: implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed
File: /home/blahblah/www/www/forum/Themes/default/languages/Tagging.english.php (main sub template - eval?)
Line: 409

http://www.sitename.org/forum/index.php?action=post;msg=10152;topic=1700.0
8: Undefined index: tags_news
File: /home/blahblah/www/www/forum/Themes/default/languages/Tagging.english.php (main sub template - eval?)
Line: 409

ISSUE #4:
When attempting to add a NEW post with tags (in a board that allows them) I get the following errors

Quote
http://www.sitename.org/forum/index.php?action=post;board=37.0
2: implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed
File: /home/blahblah/www/www/forum/Themes/default/languages/Tagging.english.php (main sub template - eval?)
Line: 407
   
http://www.sitename.org/forum/index.php?action=post;board=37.0
8: Undefined index: tags_news
File: /home/blahblah/www/www/forum/Themes/default/languages/Tagging.english.php (main sub template - eval?)
Line: 407

Anyone have any thoughts and ideas on this?

MechSpecs

Wow so nobody has had these issues with their ADMIN ERROR LOG?

Hrmmmmmmmmmmm, wonder what is causing it on my end then :(

4Kstore

thank you all, please give me a little time to get back to work on this mod, check your contributions and fix all ... I will try to do my best

¡¡NEW MOD: Sparkles User Names!!!

FragaCampos

I want to thank you all for these contributions to a great mod. I hope 4Kstore can use them and make it even better.  :)

MechSpecs

Quote from: 4Kstore on July 24, 2013, 03:45:19 AM
thank you all, please give me a little time to get back to work on this mod, check your contributions and fix all ... I will try to do my best

Hey man, thanks for looking into this again. I realize these older mods sometimes get forgotten about and left by the way side but its nice to see you digging back into this one as it has some pretty cool functionality.

I updated my testing post (http://www.simplemachines.org/community/index.php?topic=492347.msg3581542#msg3581542) with the 4th and final issue I encountered while attempting to get this mod to work. In fact the mod DOES work (sort of) but even while it is working it is logging errors left right and center so hopefully they help debug it. 

I have a testing server that I use  as a sandbox so anything I can do to help out please let me know.

manixless

Thanks to everyone for all the fixes and bugs reported. We are working in the next update since today. It will be completed as soon as possible. Thank you again!

Advertisement: