Voila je voulais partager, pour ceux qui sont interressés
mettre ces fichiers zipper sous smf\Packages\
fichier install.xml : :D
<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>vues_tp_articles</id>
<version>1.0</version>
<file name="$boarddir/index.php">
<operation>
<search position="after"><![CDATA[ 'smstats' => array('Stats.php', 'SMStats'),
]]></search>
<add><![CDATA[ // debut mod vues_tp_articles
'monmod' => array('vues_tp_articles.php', 'Showtparticles'),
// fin mod vues_tp_articles
]]></add>
</operation>
</file>
<file name="$sourcedir/Admin.php">
<operation>
<search position="before"><![CDATA[ // Note the comma!! The setting with automatically appear with the first mod to be added.
]]></search>
<add><![CDATA[ // debut mod vues_tp_articles
'monmod' => array($txt['monmod']),
// fin mod vues_tp_articles
]]></add>
</operation>
</file>
<file name="$languagedir/Modifications.english.php">
<operation>
<search position="after"><![CDATA[?>]]></search>
<add><![CDATA[// debut mod vues_tp_articles
$txt['monmod'] = 'monmod';
// fin mod vues_tp_articles
]]></add>
</operation>
</file>
<file name="$sourcedir/Subs.php">
<operation>
<search position="before"><![CDATA[
'permissions' => array(
'title' => $txt['edit_permissions'],
'href' => $scripturl . '?action=admin;area=permissions',
'show' => allowedTo('manage_permissions'),
'is_last' => true,
),
]]></search>
<add><![CDATA[
// debut mod vues_tp_articles
'monmod' => array(
'title' => 'Vues TP Articles',
'href' => $scripturl, '?action=monmod',
'show' => $context['allow_admin'],
),
// fin mod vues_tp_articles
]]></add>
</operation>
</file>
</modification>
fichier package-info.xml :D:
<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<id>vues_tp_articles</id>
<name>Vues des TP articles pour SMF2.0.2</name>
<version>1.0</version>
<type>modification</type>
<install for="2.0.2">
<modification type="file">install.xml</modification>
<require-file name="vues_tp_articles.php" destination="$sourcedir" />
</install>
<uninstall for="2.0.2">
<modification type="file" reverse="true">install.xml</modification>
<remove-file name="$sourcedir/vues_tp_articles.php" />
</uninstall>
</package-info>
fichier vues_tp_articles.php : :D
<?php
if (!defined('SMF'))
die('Hacking attempt...');
function Showtparticles()
{
global $context, $scripturl, $settings, $txt, $user_info, $modSettings, $smcFunc, $sourcedir, $mbname;
$context['page_title'] = $txt['monmod'];
$context['linktree'][] = array(
'url' => $scripturl . '?action=monmod',
'name' => $txt['monmod'],
);
// boucle sur la base et cree un tableau pour envoyer les donnees a la fonction createlist du fichier Subs-List.php(mise en forme et visualisation)
$listOptions = array(
'items_per_page' => 50, //nombre de ligne visible par page
'no_items_label' => $txt['monmod_articles_none'], //valeur a renvoyer si pas de ligne
'get_items' => array(
'function' => 'list_getarticles', //fonction utilise pour la requete sur la base de donnees
),
'columns' => array(
'subject' => array( //premiere colonne
'header' => array(
'value' => 'Sujet', //titre premiere colonne
),
'data' => array(
'sprintf' => array( // donnees provenant d une chaine de caractere
'format' => '<a href="' . $scripturl . '?page=%s">%s</a>', //format des donnees premiere colonne
'params' => array(
'shortname' => false, //premier parametre du format " ?page=%s " le lien de l article
'subject' => false, //deuxieme parametre du format " >%s</a> " le sujet de l article
),
),
),
),
'category' => array( //deuxieme colonne
'header' => array(
'value' => 'Categorie', //titre deuxieme colonne
),
'data' => array(
'db' => 'value1', // valeur provenant de la base de donnees champ "value1"
),
),
'member_name' => array(
'header' => array(
'value' => 'Autheur',
),
'data' => array(
'db' => 'member_name',
),
),
'views' => array(
'header' => array(
'value' => 'vues',
),
'data' => array(
'db' => 'views',
'style' => 'text-align: center;',
),
),
),
);
//une fois la boucle sur la base terminee on rajoute les elements unique
$listOptions['id'] = 'monmod_list';
$listOptions['title'] = '<a href="' . $scripturl . '">' . $mbname . ' - ' . 'Articles par nombre de fois vues' . '</a>';
$listOptions['base_href'] = $scripturl . '?action=monmod';
// on envoie les donnees
require_once($sourcedir . '/Subs-List.php');
createList($listOptions);
$context['sub_template'] = 'show_list';
$context['default_list'] = 'monmod_list';
}
//fonction de requete sur la table tp-articles et members
function list_getarticles($start, $items_per_page, $sort)
{
global $smcFunc;
$query_limit = !empty($items_per_page) ? 'LIMIT {int:start}, {int:per_page}' : '';
$query_limit_params = !empty($items_per_page) ? array('start' => $start, 'per_page' => $items_per_page) : array();
$request = $smcFunc['db_query']('','
SELECT b.subject , b. views, b.shortname, m.value1, mem.member_name
FROM {db_prefix}tp_articles as b
INNER JOIN {db_prefix}tp_variables as m ON (m.id = b.category)
INNER JOIN {db_prefix}members as mem ON (mem.id_member = b.author_id)
WHERE {query_see_board}
ORDER BY {raw:sort}
' . $query_limit,
array_merge($query_limit_params, array(
'sort' => $sort == '1=1' ? 'b. views DESC' : $sort,
)
));
$articles = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$articles[] = $row;
$smcFunc['db_free_result']($request);
return $articles;
}
?>