1 | <?php |
---|
2 | # ACS |
---|
3 | # (Plugin Spip) |
---|
4 | # http://acs.geomaticien.org |
---|
5 | # |
---|
6 | # Copyright Daniel FAIVRE, 2007-2011 |
---|
7 | # Copyleft: licence GPL - Cf. LICENCES.txt |
---|
8 | |
---|
9 | /** |
---|
10 | * Affiche une liste contextuelle des composants - Onglet composants |
---|
11 | * Show a contextual widget list - Used by pages AND composants |
---|
12 | */ |
---|
13 | function liste_widgets($visible = true) { |
---|
14 | $composants = composants_liste(); |
---|
15 | // On renvoie directement une liste vide si aucun composant n'est trouvé |
---|
16 | if (!is_array($composants)) |
---|
17 | return acs_box('0 '.strtolower(_T('composants')), ' ', _DIR_PLUGIN_ACS."/images/composant-24.gif", 'acs_box_composants'); |
---|
18 | |
---|
19 | $elts = ''; |
---|
20 | $cadres = ''; |
---|
21 | foreach($composants as $class=>$cp) { |
---|
22 | $vp = 'acs'.ucfirst($class); |
---|
23 | foreach($cp['instances'] as $nic=>$c) { |
---|
24 | $vpi = $vp.($nic ? $nic : ''); |
---|
25 | // Si le composant possede une variable Nom on l'affiche en nom et le nom du composant en info-bulle |
---|
26 | $v = $vpi.'Nom'; |
---|
27 | if ($GLOBALS['meta'][$v]) { |
---|
28 | $nom = couper($GLOBALS['meta'][$v], 50); |
---|
29 | $title = ucfirst(str_replace('_', ' ', $class)).($nic ? ' '.$nic : ''); |
---|
30 | } |
---|
31 | else { |
---|
32 | $nom = ucfirst(str_replace('_', ' ', $class)).($nic ? ' '.$nic : ''); |
---|
33 | $title = _T('composant'); |
---|
34 | } |
---|
35 | $html = '<div id="widget_'.$class.($nic ? '-'.$nic : '').'" class="'.get_widget_class($cp['over'], $c['on'], 'widget').'">'. |
---|
36 | '<table><tr><td><a href="'._DIR_RESTREINT.'?exec=acs&onglet=composants&composant='.$class.($nic ? '&nic='.$nic : '').'" title="'._T('composant').'">'.widget_icon($class, $nic).'</a>'. |
---|
37 | '</td><td title="'.$title.'" style="width: 95%;"><div><a href="'._DIR_RESTREINT.'?exec=acs&onglet=composants&composant='.$class.($nic ? '&nic='.$nic : '').'" title="'.$title.'">'.$nom.'</a></div></td></tr></table>'. |
---|
38 | '</div>'; |
---|
39 | if ($class == 'cadre') |
---|
40 | $cadres .= $html; |
---|
41 | else |
---|
42 | $elts .= $html; |
---|
43 | $nbci++; |
---|
44 | } |
---|
45 | $nbc++; |
---|
46 | } |
---|
47 | $r = '<div id="widgets" class="widgets">'.$elts.'<hr />'.$cadres.'</div>'; |
---|
48 | return acs_box($nbci.' '.(($nbci==1) ? strtolower(_T('composant')) : strtolower(_T('composants'))).' ('.$nbc.')', $r, _DIR_PLUGIN_ACS."/images/composant-24.gif", 'acs_box_composants'.($visible ? '' : '_hidden').''); |
---|
49 | } |
---|
50 | |
---|
51 | function get_widget_class($over, $on, $style) { |
---|
52 | $ov .= $style; |
---|
53 | if ($over) |
---|
54 | $ov .= ' '.$style.'_overriden'; |
---|
55 | if (!($on == 'oui')) |
---|
56 | $ov .= ' '.$style.'_unused'; |
---|
57 | return $ov; |
---|
58 | } |
---|
59 | |
---|
60 | function widget_icon($class, $nic, $size=24) { |
---|
61 | $o = 'acs'.ucfirst($class).($nic ? $nic : '').'Orientation'; |
---|
62 | // Si le composant possède une propriete orientation ET une icone correspondante on oriente l'icone |
---|
63 | $wicon = (isset($GLOBALS['meta'][$o]) && $GLOBALS['meta'][$o] == 'horizontal') ? 'horizontal' : 'icon'; |
---|
64 | $wicon = find_in_path('composants/'.$class.'/images/'.$class.'_'.$wicon.'.gif'); |
---|
65 | if (!file_exists($wicon)) |
---|
66 | $wicon = _DIR_PLUGIN_ACS.'images/composant-24.gif'; |
---|
67 | return '<img src="'.$wicon.'" height="'.$size.'px" width="'.$size.'px" />'; |
---|
68 | } |
---|
69 | ?> |
---|