Voici un petit hack pour ajouter le support des templates a certaines pages qui en sont démunies. Je ne sais pas si ca va interesser qqun, mais puisque c est fait, autant en faire profiter tout le monde...
Je viens de le réaliser pour la page viewpmsg.php, d'autres suivront quand j'aurai le temps.
d'apres les tests rapides que j'ai effectués ca a l air de fonctionner. Si vous faites ces changements il est préférable de faire une copie de sauvegarde avant. La version de xoops utilisée ici est la 2.0.14.
viewpmsg.php
$xoopsOption['pagetype'] = "pmsg";
include_once "mainfile.php";
include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php";
if (!is_object($xoopsUser)) {
$errormessage = _PM_SORRY."<br />"._PM_PLZREG."";
redirect_header("user.php",2,$errormessage);
}
else {
$pm_handler =& xoops_gethandler('privmessage');
if (isset($_POST['delete_messages']) && isset($_POST['msg_id'])) {
if (!$GLOBALS['xoopsSecurity']->check()) {
echo implode('<br />', $GLOBALS['xoopsSecurity']->getErrors());
exit();
}
$size = count($_POST['msg_id']);
$msg =& $_POST['msg_id'];
for ( $i = 0; $i < $size; $i++ ) {
$pm =& $pm_handler->get($msg[$i]);
if ($pm->getVar('to_userid') == $xoopsUser->getVar('uid')) {
$pm_handler->delete($pm);
}
unset($pm);
}
redirect_header("viewpmsg.php",1,_PM_DELETED);
exit();
}
// Set template
$xoopsOption['template_main'] = 'system_userinbox.html';
include XOOPS_ROOT_PATH.'/header.php';
$criteria = new Criteria('to_userid', $xoopsUser->getVar('uid'));
$criteria->setOrder('DESC');
$pm_arr =& $pm_handler->getObjects($criteria);
// Xoops language
$xoopsTpl->assign("lang_PM_PrivateMessage",_PM_PRIVATEMESSAGE);
$xoopsTpl->assign("lang_PM_Profile",_PM_PROFILE);
$xoopsTpl->assign("lang_PM_Inbox",_PM_INBOX);
$xoopsTpl->assign("lang_PM_From",_PM_FROM);
$xoopsTpl->assign("lang_PM_Subject",_PM_SUBJECT);
$xoopsTpl->assign("lang_PM_Date",_PM_DATE);
$xoopsTpl->assign("lang_PM_YouDontHave",_PM_YOUDONTHAVE);
$xoopsTpl->assign("lang_PM_NotRead",_PM_NOTREAD);
$xoopsTpl->assign("lang_PM_Send",_PM_SEND);
$xoopsTpl->assign("lang_PM_Delete",_PM_DELETE);
$total_messages = count($pm_arr);
$xoopsTpl->assign("total_messages",$total_messages);
$pm_msg = array();
for ($i = 0; $i < $total_messages; $i++) {
// Retrieve some special values
$postername = XoopsUser::getUnameFromId($pm_arr[$i]->getVar("from_userid"));
$isAnonymous = 0;
if (!$postername) {
$postername = $xoopsConfig['anonymous'];
$isAnonymous = 1;
}
$pm_msg[] = array ( "msg_id" => $pm_arr[$i]->getVar("msg_id"),
"read_msg" => $pm_arr[$i]->getVar('read_msg'),
"msg_image" => $pm_arr[$i]->getVar("msg_image", "E"),
"from_userid" => $pm_arr[$i]->getVar("from_userid"),
"from_uname" => $postername,
"is_anonymous" => $isAnonymous,
"subject" => $pm_arr[$i]->getVar("subject"),
"msg_time" => formatTimestamp($pm_arr[$i]->getVar("msg_time")),
"start" => ($total_messages-$i-1)
);
}
// Assign the list of messages for display
$xoopsTpl->assign("pm_msg",$pm_msg);
$xoopsTpl->assign("token",$GLOBALS['xoopsSecurity']->getTokenHTML());
include "footer.php";
}
et le code du template : sytem_userinbox.html
<h4 style='text-align:center;'><{$lang_PM_PrivateMessage}></h4>
<br />
<a href='userinfo.php?uid=<{$xoops_userid}>'><{$lang_PM_Profile}></a>
<span style='font-weight:bold;'>»»</span> <{$lang_PM_Inbox}>
<br /><br />
<table border='0' cellspacing='1' cellpadding='4' width='100%' class='outer'>
<form name='prvmsg' method='post' action='viewpmsg.php'>
<tr align='center' valign='middle'>
<th><input name='allbox' id='allbox' onclick='xoopsCheckAll("prvmsg","allbox");' type='checkbox' value='Check All' /></th>
<th><img src='images/download.gif' alt='' border='0' /></th>
<th> </th>
<th><{$lang_PM_From}></th>
<th><{$lang_PM_Subject}></th>
<th align='center'><{$lang_PM_Date}></th>
</tr>
<{if $total_messages == 0}>
<tr>
<td class='even' colspan='6' align='center'><{$lang_PM_YouDontHave}></td>
</tr>
<tr class='bg2' align='left'>
<td colspan='6' align='left'>
<input type='button' class='formButton' onclick='javascript:openWithSelfMain("<{$xoops_url}>/pmlite.php?send=1","pmlite",450,380);' value='<{$lang_PM_Send}>' />
</td>
</tr>
<{else}>
<{foreach item=msg from=$pm_msg}>
<tr align='left' class='<{cycle values="even,odd"}>'>
<td valign='top' width='2%' align='center'>
<input type='checkbox' id='msg_id[]' name='msg_id[]' value='<{$msg.msg_id}>' />
</td>
<td valign='top' width='5%' align='center'>
<{if $msg.read_msg == 1}>
<{else}>
<img src='images/read.gif' alt='<{$lang_PM_NotRead}>' />
<{/if}>
</td>
<td valign='top' width='5%' align='center'>
<img src='images/subject/<{$msg.msg_image}>' alt='' />
</td>
<td valign='middle' width='10%'>
<{if $msg.is_anonymous == 1}>
<{$msg.from_uname}>
<{else}>
<a href='userinfo.php?uid=<{$msg.from_userid}>'><{$msg.from_uname}></a>
<{/if}>
</td>
<td valign='middle'>
<a href='readpmsg.php?start=<{$msg.start}>&total_messages=<{$total_messages}>'><{$msg.subject}></a>
</td>
<td valign='middle' align='center' width='20%'>
<{$msg.msg_time }>
</td>
</tr>
<{/foreach}>
<tr class='foot' align='left'>
<td colspan='6' align='left'>
<input type='button' class='formButton' onclick='javascript:openWithSelfMain("<{$xoops_url}>/pmlite.php?send=1","pmlite",450,380);' value='<{$lang_PM_Send}>' />
<input type='submit' class='formButton' name='delete_messages' value='<{$lang_PM_Delete}>' />
<{$token}>
</td>
</tr>
<{/if}>
</form>
</table>
il faut modifier le fichier xoops_version du module systeme pour que le nouveau template soit pris en compte. Personnellement, j'ai fait mes changement dans un fichier séparé (xoops_version_hacked.php) que j'ai inclus dans le fichier original:
...
$modversion['templates'][15]['file'] = 'system_block_dummy.html';
$modversion['templates'][15]['description'] = 'Dummy template for custom blocks or blocks without templates';
// Hack for template of user forms
include_once dirname(__FILE__)."/xoops_version_hacked.php";
le fichier xoops_version_hacked.php contient alors :
// Set this to the value of the latest index +1
$i = 16;
$modversion['templates'][$i]['file'] = 'system_userinbox.html';
$modversion['templates'][++$i]['description'] = '';
Faire un upgrade du module system pour que les changements soient pris en compte