Changeset 2928

Show
Ignore:
Timestamp:
07/23/08 14:57:52 (1 month ago)
Author:
steevanb
Message:

Ajout d'un template (modifiable via le paramètre template) pour le tag popupinformation, pour que le thème puisse surcharger l'affichage

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/utils/copix/taglib/popupinformation.templatetag.php

    r2920 r2928  
    11<?php 
    22/** 
    3 * @package     copix 
    4 * @subpackage  taglib 
    5 * @author       Gérald Croës 
    6 * @copyright   2000-2006 CopixTeam 
    7 * @link            http://www.copix.org 
    8 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 
    9 */ 
     3 * @package copix 
     4 * @subpackage taglib 
     5 * @author Gérald Croës, Steevan BARBOYON 
     6 * @copyright CopixTeam 
     7 * @link http://www.copix.org 
     8 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 
     9 */ 
    1010 
    1111/** 
    12  * Balise capable d'afficher une liste déroulante 
    13  * @package     copix 
    14  * @subpackage  taglib 
     12 * Balise capable d'afficher une fenêtre contenant du texte 
     13 *  
     14 * @package copix 
     15 * @subpackage taglib 
    1516 */ 
    1617class TemplateTagPopupInformation extends CopixTemplateTag { 
    17     public function process ($pParams, $pContent = null) { 
    18        if (is_null ($pContent) && !isset($pParams['zone'])) { 
    19          return; 
    20        } 
    21         
    22        _tag ('mootools', array('plugin'=>array('overlayfix'))); 
    23        
    24        $alt        = $this->getParam ('alt',''); 
    25        $text       = $this->getParam ('text', ''); 
    26        $displayimg = $this->getParam ('displayimg', true); 
    27        $img        = $this->getParam ('img', _resource ('img/tools/information.png')); 
    28        $divclass   = $this->getParam ('divclass', 'popupInformation'); 
    29        $handler    = $this->getParam ('handler', 'onmouseover'); 
    30        $namespace  = $this->getParam ('namespace', 'default'); 
    31        $wHandle    = $this->getParam ('handlerWindow'); 
    32        $wHandle = ($wHandle != null) ? ( 'handle="'.$wHandle.'" ') : ''; 
    33        $title = $this->getParam ('popuptitle'); 
    34         
    35        $id = uniqid ('popupInformation'); 
    36         
    37        switch ($handler) { 
    38            case 'window': 
    39                $toReturn  = '<a rel="'.$id.'" '.$wHandle.' id="div'.$id.'" class="divwindowpopup" href="javascript:void(null);"'; 
    40                if (isset($pParams['title'])) { 
    41                    $toReturn .= ' title="'.$pParams['title'].'"'; 
    42                } 
    43                $toReturn .= '>'; 
    44                $close = '</a>'; 
    45                CopixHTMLHeader::addJsLink (_resource ('js/taglib/popupinfo_window.js')); 
    46                $js = new CopixJSWidget (); 
    47                CopixHTMLHeader::addJSDOMReadyCode ($js->popupinfo_window (), 'popupinfo_window'); 
    48                break; 
    49            case 'clickdelay': 
    50                $toReturn  = '<a rel="'.$id.'" id="div'.$id.'" class="divclickdelaypopup" href="javascript:void(null);">'; 
    51                $close = '</a>'; 
    52                CopixHTMLHeader::addJsLink (_resource ('js/taglib/popupinfo_clickdelay.js')); 
    53                CopixHTMLHeader::addJSDOMReadyCode ('popupinfo_clickdelay ();', 'popupinfo_clickdelay'); 
    54                break; 
    55            case 'onclick': 
    56                $toReturn  = '<a rel="'.$id.'" id="div'.$id.'" class="divclickpopup" href="javascript:void(null);">'; 
    57                $close = '</a>'; 
    58                CopixHTMLHeader::addJsLink (_resource ('js/taglib/popupinfo_click.js')); 
    59                CopixHTMLHeader::addJSDOMReadyCode ('popupinfo_click ();', 'popupinfo_click'); 
    60                 
    61              break; 
    62           default: 
    63                //prend également en charge onmouseover qui est le handler par défaut. 
    64                $toReturn  = '<div rel="'.$id.'" id="div'.$id.'" class="divpopup" style="display:inline;">'; 
    65                $close = '</div>'; 
    66                CopixHTMLHeader::addJsLink (_resource ('js/taglib/popupinfo.js')); 
    67                CopixHTMLHeader::addJSDOMReadyCode ('popupinfo ();', 'popupinfo'); 
    68              break; 
    69        } 
    70        $toReturn .= $displayimg  === true ? '<img src="'.$img.'" title="'.$alt.'" alt="'.$alt.'" />' : ''; 
    71        $toReturn .= strlen ($text) ? $text : ''; 
    72        $toReturn .= isset($pParams['imgnext']) ? '<img src="'.$pParams['imgnext'].'" />' : ''; 
    73        $toReturn .= $close; 
    74        $toReturn .= '<div class="'.$divclass.'" id="'.$id.'" style="display:none;" rel='.$namespace.' >'; 
    75      
    76         if ($title !== null) { 
    77             $toReturn .= '<div class="' . $divclass . 'Title">' . $title . '</div>'; 
     18    /** 
     19     * Retourne le contenu HTML 
     20     * 
     21     * @param array $pParams Paramètres 
     22     * @param string $pContent Contenu à écrire 
     23     * @return string 
     24     */ 
     25    public function process ($pParams, $pContent = null) { 
     26        if (is_null ($pContent) && !isset ($pParams['zone'])) { 
     27            return; 
    7828        } 
    79         
    80        if (isset($pParams['zone'])) { 
    81            $zone = $pParams['zone']; 
    82            unset($pParams['zone']); 
    83            $toReturn .= _tag('copixzone', array_merge($this->getExtraParams(),array('onComplete'=>'$(\'div'.$id.'\').fireEvent(\'sync\');','process'=>$zone,'ajax'=>true, 'id'=>'zone_'.$id))); 
    84        } else { 
    85            $toReturn .= $pContent; 
    86        } 
    87        $toReturn .= '</div>'; 
    88        return $toReturn; 
    89    } 
     29         
     30        _tag ('mootools', array ('plugin'=>array ('overlayfix'))); 
     31         
     32        $alt = $this->getParam ('alt',''); 
     33        $text = $this->getParam ('text', ''); 
     34        $displayimg = $this->getParam ('displayimg', true); 
     35        $img = $this->getParam ('img', _resource ('img/tools/information.png')); 
     36        $divclass = $this->getParam ('divclass', 'popupInformation'); 
     37        $handler = $this->getParam ('handler', 'onmouseover'); 
     38        $namespace = $this->getParam ('namespace', 'default'); 
     39        $wHandle = $this->getParam ('handlerWindow'); 
     40        $wHandle = ($wHandle != null) ? ( 'handle="'.$wHandle.'" ') : ''; 
     41        $title = $this->getParam ('popuptitle'); 
     42        $width = $this->getParam ('width'); 
     43        $id = uniqid ('popupInformation'); 
     44        $template = $this->getParam ('template', 'generictools|popupinformation.tpl'); 
     45        $templateParams = array ( 
     46            'alt' => $alt, 
     47            'text' => $text, 
     48            'displayimg' => $displayimg, 
     49            'img' => $img, 
     50            'divclass' => $divclass, 
     51            'handler' => $handler, 
     52            'namespace' => $namespace, 
     53            'handlerWindow' => $this->getParam ('handlerWindow'), 
     54            'popuptitle' => $title, 
     55            'id' => $id, 
     56            'width' => $width 
     57        ); 
     58         
     59        switch ($handler) { 
     60            case 'window': 
     61                $toReturn = '<a rel="'.$id.'" '.$wHandle.' id="div'.$id.'" class="divwindowpopup" href="javascript:void(null);"'; 
     62                if (isset($pParams['title'])) { 
     63                    $toReturn .= ' title="'.$pParams['title'].'"'; 
     64                } 
     65                $toReturn .= '>'; 
     66                $close = '</a>'; 
     67                CopixHTMLHeader::addJsLink (_resource ('js/taglib/popupinfo_window.js')); 
     68                $js = new CopixJSWidget (); 
     69                CopixHTMLHeader::addJSDOMReadyCode ($js->popupinfo_window (), 'popupinfo_window'); 
     70                break; 
     71            case 'clickdelay': 
     72                $toReturn = '<a rel="'.$id.'" id="div'.$id.'" class="divclickdelaypopup" href="javascript:void(null);">'; 
     73                $close = '</a>'; 
     74                CopixHTMLHeader::addJsLink (_resource ('js/taglib/popupinfo_clickdelay.js')); 
     75                CopixHTMLHeader::addJSDOMReadyCode ('popupinfo_clickdelay ();', 'popupinfo_clickdelay'); 
     76                break; 
     77            case 'onclick': 
     78                $toReturn = '<a rel="'.$id.'" id="div'.$id.'" class="divclickpopup" href="javascript:void(null);">'; 
     79                $close = '</a>'; 
     80                CopixHTMLHeader::addJsLink (_resource ('js/taglib/popupinfo_click.js')); 
     81                CopixHTMLHeader::addJSDOMReadyCode ('popupinfo_click ();', 'popupinfo_click'); 
     82                 
     83            break; 
     84            default: 
     85                //prend également en charge onmouseover qui est le handler par défaut. 
     86                $toReturn = '<div rel="'.$id.'" id="div'.$id.'" class="divpopup" style="display:inline;">'; 
     87                $close = '</div>'; 
     88                CopixHTMLHeader::addJsLink (_resource ('js/taglib/popupinfo.js')); 
     89                CopixHTMLHeader::addJSDOMReadyCode ('popupinfo ();', 'popupinfo'); 
     90            break; 
     91        } 
     92        $toReturn .= $displayimg === true ? '<img src="'.$img.'" title="'.$alt.'" alt="'.$alt.'" />' : ''; 
     93        $toReturn .= strlen ($text) ? $text : ''; 
     94        $toReturn .= isset($pParams['imgnext']) ? '<img src="'.$pParams['imgnext'].'" />' : ''; 
     95        $toReturn .= $close; 
     96         
     97        if (isset ($pParams['zone'])) { 
     98            $zone = $pParams['zone']; 
     99            unset ($pParams['zone']); 
     100            $content = _tag ('copixzone', array_merge ($this->getExtraParams (), array ('onComplete'=>'$(\'div'.$id.'\').fireEvent(\'sync\');','process'=>$zone,'ajax'=>true, 'id'=>'zone_'.$id))); 
     101        } else { 
     102            $content = $pContent; 
     103        } 
     104         
     105        $tpl = new CopixTPL (); 
     106        $tpl->assign ('MAIN', $content); 
     107        $tpl->assign ('params', $templateParams); 
     108        $toReturn .= $tpl->fetch ($template); 
     109        return $toReturn; 
     110    } 
    90111} 
    91 ?>