Fork me on GitHub






[Hack] ajout du support des templates
Aspirant
Inscrit: 17/04/2006 14:36
Messages: 21
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>&nbsp;
<
span style='font-weight:bold;'>&raquo;&raquo;</span>&nbsp;<{$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>&nbsp;</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}>
                            &
nbsp;
                        <{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}>' />
                    &
nbsp;
                    <
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

Posté le : 17/08/2006 01:08
Partager Twitter Partagez cette article sur GG+
Re: [Hack] ajout du support des templates
Xoops accro
Inscrit: 04/02/2003 01:54
De Le Mans
Messages: 12273
Merci pour cette contribution

Posté le : 17/08/2006 01:57
Partager Twitter Partagez cette article sur GG+
Re: [Hack] ajout du support des templates
Admin Frxoops
Inscrit: 04/02/2003 07:37
De Belgique
Messages: 3376
Tu n'en ferais pas une archive téléchargeable ?


Posté le : 17/08/2006 08:01
Partager Twitter Partagez cette article sur GG+
Re: [Hack] ajout du support des templates
Aspirant
Inscrit: 17/04/2006 14:36
Messages: 21
Citation :

Solo71 a écrit:
Tu n'en ferais pas une archive téléchargeable ?



si mais il y a d autres pages qui sont dans le meme cas, quand j'aurai fini de les modifier je ferai l'archive

Posté le : 17/08/2006 09:20
Partager Twitter Partagez cette article sur GG+
Re: [Hack] ajout du support des templates
Aspirant
Inscrit: 13/07/2003 14:14
De Brasil - SíƒÂ£o Paulo - Guarulhos
Messages: 72
Merci.

I waiting too

Test in 2.0.15 not work, blank page in inbox.

Posté le : 11/10/2006 12:22

Edité par gibaphp sur 11/10/2006 12:39:23
Partager Twitter Partagez cette article sur GG+

 Haut   Précédent   Suivant



Vous pouvez voir les sujets.
Vous ne pouvez pas débuter de nouveaux sujets.
Vous ne pouvez pas répondre aux contributions.
Vous ne pouvez pas éditer vos contributions.
Vous ne pouvez pas effacez vos contributions.
Vous ne pouvez pas ajouter de nouveaux sondages.
Vous ne pouvez pas voter en sondage.
Vous ne pouvez pas attacher des fichiers à vos contributions.
Vous ne pouvez pas poster sans approbation.

Propulsé avec XOOPS | Graphisme adapté par Tatane, Grosdunord, Montuy337513

114 Personne(s) en ligne (94 Personne(s) connectée(s) sur Forum) | Utilisateur(s): 0 | Invité(s): 114 | Plus ...