Autor Tópico: Tagging System For Topics  (Lida 3748 vezes)

0 Membros e 2 Visitantes estão a ver este tópico.

Offline candidosa2

  • Suporte Tecnico
  • Fundador
  • *
  • Mensagens: 5072
  • Rank: 1658
  • Sexo: Masculino
  • Suporte
    • Hosting Moçambique
Tagging System For Topics
« em: 10 de Novembro de 2008, 17:25 »
$boarddir/index.php

Pesquisar por
Código: [Seleccione]
'sticky' => array('LockTopic.php', 'Sticky'),
Adicionar
Código: [Seleccione]
'tags' => array('Tags.php', 'TagsMain'),
$teutema/index.template.php

Pesquisar por
Código: [Seleccione]
$current_action = 'admin';
if (in_array($context['current_action'], array(

Adicionar
Código: [Seleccione]
'tags',
Pesquisar por

Código: [Seleccione]
// the [member] list button
if ($context['allow_memberlist'])
echo ($current_action == 'mlist' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'mlist' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=mlist">' , $txt[331] , '</a>
</td>' , $current_action == 'mlist' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

Adicionar
Código: [Seleccione]
// the [tags] button
echo ($current_action == 'tags' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'tags' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=tags">' , $txt['smftags_menu']  , '</a>
</td>' , $current_action == 'tags' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


/Post.template.php

Pesquisar por
Código: [Seleccione]
<input type="text" name="subject"', $context['subject'] == '' ? '' : ' value="' . $context['subject'] . '"', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" />
</td>
</tr>

Adicionar
Código: [Seleccione]
';
//Tagging system Mod
if(!isset($context['num_replies']))
{
echo '
<tr>
<td align="right">
<b>', $txt['smftags_topic'], '</b></td>
<td>
<input type="text" name="tags"', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" />
<br /><span class="smalltext">', $txt['smftags_seperate'], '</span>
</td>
</tr>';

}


//End Tagging system mod
echo '

sourcedir/ManagePermissions.php

Pesquisar
Código: [Seleccione]
'pm' => array(
'pm_read' => false,
'pm_send' => false,
),
Adicionar
Código: [Seleccione]
'smftags' => array(
'smftags_manage' => false,
),

$sourcedir/Subs.php
Pesquisar
Código: [Seleccione]
'edit_settings' => '<a href="' . $scripturl . '?action=serversettings;sesc=' . $sc . '">' . $txt[222] . '</a>',
Adicionar
Código: [Seleccione]
'tags_settings' => '<a href="' . $scripturl . '?action=tags;sa=admin;sesc=' . $sc . '">' . $txt['smftags_admin'] . '</a>',
$sourcedir/Post.php
Pesquisar
Código: [Seleccione]
createPost($msgOptions, $topicOptions, $posterOptions);
 
if (isset($topicOptions['id']))
$topic = $topicOptions['id'];
}

Adicionar
Código: [Seleccione]
//Tagging System

if(isset($_REQUEST['tags']) && !isset($_REQUEST['num_replies']))
{
//Get how many tags there have been for the topic
$dbresult = db_query("SELECT COUNT(*) as total FROM {$db_prefix}tags_log WHERE ID_TOPIC = " . $topic, __FILE__, __LINE__);
$row = mysql_fetch_assoc($dbresult);
$totaltags = $row['total'];
mysql_free_result($dbresult);
 
//Check Tag restrictions
$tags = explode(',',htmlspecialchars($_REQUEST['tags'],ENT_QUOTES));
 
if($totaltags < $modSettings['smftags_set_maxtags'])
{
$tagcount = 0;
foreach($tags as $tag)
{
if($tagcount >= $modSettings['smftags_set_maxtags'])
continue;
 
 
if(empty($tag))
continue;
 
//Check min tag length
if(strlen($tag) < $modSettings['smftags_set_mintaglength'])
continue;
//Check max tag length
if(strlen($tag) > $modSettings['smftags_set_maxtaglength'])
continue;
 
//Insert The tag
$dbresult = db_query("SELECT ID_TAG FROM {$db_prefix}tags WHERE tag = '$tag'", __FILE__, __LINE__);
if(db_affected_rows() == 0)
{
//Insert into Tags table
db_query("INSERT INTO {$db_prefix}tags
(tag, approved)
VALUES ('$tag',1)", __FILE__, __LINE__);
$ID_TAG = db_insert_id();
//Insert into Tags log
db_query("INSERT INTO {$db_prefix}tags_log
(ID_TAG,ID_TOPIC, ID_MEMBER)
VALUES ($ID_TAG,$topic,$ID_MEMBER)", __FILE__, __LINE__);
 
$tagcount++;
}
else
{
$row = mysql_fetch_assoc($dbresult);
$ID_TAG = $row['ID_TAG'];
$dbresult2= db_query("SELECT ID FROM {$db_prefix}tags_log WHERE ID_TAG  =  $ID_TAG  AND ID_TOPIC = $topic", __FILE__, __LINE__);
if(db_affected_rows() != 0)
{
continue;
 
}
mysql_free_result($dbresult2);
//Insert into Tags log
 
db_query("INSERT INTO {$db_prefix}tags_log
(ID_TAG,ID_TOPIC, ID_MEMBER)
VALUES ($ID_TAG,$topic,$ID_MEMBER)", __FILE__, __LINE__);
$tagcount++;
 
}
mysql_free_result($dbresult);
}
}
}

//End Tagging System

$sourcedir/Display.php
[logged]
Código: [Seleccione]
if (empty($_SESSION['last_read_topic']) || $_SESSION['last_read_topic'] != $topic)
{
db_query("
UPDATE {$db_prefix}topics
SET numViews = numViews + 1
WHERE ID_TOPIC = $topic
LIMIT 1", __FILE__, __LINE__);
 
$_SESSION['last_read_topic'] = $topic;
}
Adicionar
Código: [Seleccione]
//Tagging System
$dbresult= db_query("SELECT t.tag,l.ID,t.ID_TAG FROM {$db_prefix}tags_log as l, {$db_prefix}tags as t WHERE t.ID_TAG = l.ID_TAG && l.ID_TOPIC = $topic", __FILE__, __LINE__);
$context['topic_tags'] = array();
while($row = mysql_fetch_assoc($dbresult))
{
$context['topic_tags'][] = array(
'ID' => $row['ID'],
'ID_TAG' => $row['ID_TAG'],
'tag' => $row['tag'],
);
}
mysql_free_result($dbresult);
//End Tagging System

teutema/Display.template.php

Pesquisar
Código: [Seleccione]
<a name="lastPost"></a>';
Adicionar
Código: [Seleccione]
//Tagging System
echo '<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="windowbg">
<b>', $txt['smftags_topic'], '</b>';



foreach ($context['topic_tags'] as $i => $tag)
{
echo '<a href="' . $scripturl . '?action=tags;id=' . $tag['ID_TAG']  . '">' . $tag['tag'] . '</a>&nbsp;';
if(!$context['user']['is_guest'])
echo '<a href="' . $scripturl . '?action=tags;sa=deletetag;id=' . $tag['ID']  . '"><font color="#FF0000">[X]</font></a>&nbsp;';

}

if(!$context['user']['is_guest'])
echo '
&nbsp;<a href="' . $scripturl . '?action=tags;sa=addtag;topic=',$context['current_topic'], '">' . $txt['smftags_addtag'] . '</a>

</td>
</tr>
</table>';

//End Tagging System
[/logged]


Modifications.portuguese.php

Antes
Código: [Seleccione]
?>
Server também para Brazilian

[hide]
Código: [Seleccione]
$txt['smftags_menu'] = 'Tags';
$txt['smftags_admin'] = 'Tags Configurações';

$txt['smftags_addtag'] = '[Add Tag]';
$txt['smftags_seperate'] = 'Separe cada tag por uma vírgula';

$txt['smftags_topic'] = 'Tags: ';
$txt['permissiongroup_smftags'] = 'SMF Tags';
$txt['permissionname_smftags_suggest'] = 'Tags Sugerir';
$txt['permissionhelp_smftags_suggest'] = 'Os usuários podem sugerir para adicionar tags';
$txt['cannot_smftags_suggest'] = 'Você não está autorizado a sugerir tags.';

$txt['permissionname_smftags_manage'] = 'Gerenciar Tags';
$txt['permissionhelp_smftags_manage'] = 'Os membros podem modificar as definições de tag e adicionar e remover tags';
$txt['cannot_smftags_manage'] = 'Você não está autorizado a gerir tags.';
[/hide]

Colocar os ficheiro no anexo mais antes correr o ficheiro tagsql.php

Tags.php  /Sources
Tags.template.php Themes/default
Tags.portuguese_pt.php na pasta  languages
« Última modificação: 28 de Dezembro de 2008, 10:44 por candidosa2 »

Offline AlaStar

  • Iniciar SmfPt
  • *
  • Mensagens: 43
  • Rank: 2
Re: Tagging System For Topics
« Responder #1 em: 30 de Novembro de 2008, 22:10 »
para quem quiser saber e ver exemplos, aqui fica o link do mod original
http://custom.simplemachines.org/mods/index.php?mod=579