1<?php 2/** 3 * Composant Action pour SwitchPanel (Toolbar) 4 * @author J. Ferre 5 */ 6 7if(!defined('DOKU_INC')) die(); 8 9if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 10require_once(DOKU_PLUGIN.'action.php'); 11 12class action_plugin_switchpanel extends DokuWiki_Action_Plugin { 13 14 function getCodePanel($TypePanel){ 15 // Size of the panel 16 $nb_of_rj = '==line:number=24'; 17 // Informations for samples 18 $code_msg = '# '.$this->getLang('panel_info').'\n'; 19 $code_txt = 'text="'.$this->getLang('port_title').'"'; 20 $code_url = $code_txt.',link="'.$this->getLang('port_url').'",target="_blank"'; 21 // Samples for RJ, OF or Gbic ports 22 $rj01to04 = '\n01,01,PC01:color="lime",'.$code_url.'\n02,02,PC02:color="cyan",'.$code_txt.'\n03,03,PC03:color="blue"\n04,04:color="#FF0000"'; 23 $rj05to10 = '\n05,05\n06,06\n07,07\n08,08\n09,09\n10,10'; 24 $cl11se12 = '\n11,11:case=close,text="'.$this->getLang('port_close').'"\n12,12:case=serial,text="'.$this->getLang('port_serial').'"'; 25 $rj13to16 = '\n13,13,PC13:color="teal",'.$code_url.'\n14,14,PC14:color="peru",'.$code_txt.'\n15,15,PC15:color="gold"\n16,16:color="#ABCDEF"'; 26 $rj17to22 = '\n17,17\n18,18\n19,19\n20,20\n21,21\n22,22'; 27 $of23gb24 = '\n23,23:case=of,text="'.$this->getLang('port_of').'"\n24,24:case=gbic,text="'.$this->getLang('port_gbic').'"'; 28 $rj25to28 = '\n01,25,PC25:color="lime",'.$code_url.'\n02,26,PC26:color="cyan",'.$code_txt.'\n03,27,PC27:color="blue"\n04,28:color="#FF0000"'; 29 $rj29to34 = '\n05,29\n06,30\n07,31\n08,32\n09,33\n10,34'; 30 $cl35se36 = '\n11,35:case=close,text="'.$this->getLang('port_close').'"\n12,36:case=serial,text="'.$this->getLang('port_serial').'"'; 31 $rj37to40 = '\n13,37,PC37:color="teal",'.$code_url.'\n14,38,PC38:color="peru",'.$code_txt.'\n15,39,PC39:color="gold"\n16,40:color="#ABCDEF"'; 32 $rj41to46 = '\n17,41\n18,42\n19,43\n20,44\n21,45\n22,46'; 33 $of47gb48 = '\n23,47:case=2of,text="'.$this->getLang('port_2of').'"\n24,48:case=gbic,text="'.$this->getLang('port_gbic').'"'; 34 // Other default port 35 $rj11to16 = '\n11,11\n12,12\n13,13\n14,14\n15,15\n16,16'; 36 $rj35to40 = '\n11,35\n12,36\n13,37\n14,38\n15,39\n16,40'; 37 // Complete panel for 24 ports / 2x12 ports (1U or 2U) 38 $rj01_24a = $nb_of_rj.$rj01to04.$rj05to10.$rj11to16.$rj17to22.$of23gb24; // 1x24 ports 39 $rj01_24b = $nb_of_rj.$rj01to04.$rj05to10.$cl11se12.$rj13to16.$rj17to22.$of23gb24; // 2x12 ports 40 $rj25_48a = $nb_of_rj.$rj25to28.$rj29to34.$rj35to40.$rj41to46.$of47gb48; // 1x24 ports 41 $rj25_48b = $nb_of_rj.$rj25to28.$rj29to34.$cl35se36.$rj37to40.$rj41to46.$of47gb48; // 2x12 ports 42 // Create code for all panels 43 switch($TypePanel) { 44 case '24rj': 45 $code = '\n<switchpanel showEars=false>\n'.$code_msg.$rj01_24a; 46 $code.= '\n</switchpanel>\n'; 47 break; 48 case '1x24': 49 $code = '\n<switchpanel showEars=false>\n'.$code_msg.'==text\n'.$this->getLang('name_1x24a').'\n'.$rj01_24a; 50 $code.= '\n</switchpanel>\n'; 51 break; 52 case '1x48': 53 $code = '\n<switchpanel showEars=false>\n'.$code_msg.'==text\n'.$this->getLang('name_1x48a').'\n'.$rj01_24a; 54 $code.= '\n'.$rj25_48a.'\n</switchpanel>\n'; 55 break; 56 case '2x24': 57 $code = '\n<switchpanel showEars=false>\n'.$code_msg.'==text\n'.$this->getLang('name_2x24a').'\n'.$rj01_24a; 58 $code.= '\n==text\n'.$this->getLang('name_2x24b').'\n'.$rj25_48a.'\n</switchpanel>\n'; 59 break; 60 case '2x12': 61 $code = '\n<switchpanel showEars=false group=12>\n'.$code_msg.'==text\n'.$this->getLang('name_2x12a').'\n'.$rj01_24b; 62 $code.= '\n</switchpanel>\n'; 63 break; 64 case '4x12': 65 $code = '\n<switchpanel showEars=false group=12>\n'.$code_msg.'==text\n'.$this->getLang('name_4x12a').'\n'.$rj01_24b; 66 $code.= '\n==text\n'.$this->getLang('name_4x12b').'\n'.$rj25_48b.'\n</switchpanel>\n'; 67 break; 68 case 'logo': 69 $code = '\n<switchpanel>\n'.$code_msg.'==text\n'.$this->getLang('name_logo').'\n'.$rj01_24a; 70 $code.= '\n</switchpanel>\n'; 71 break; 72 case 'ears': 73 $code = '\n<switchpanel logo=none>\n'.$code_msg.'==text\n'.$this->getLang('name_ears').'\n'.$rj01_24a; 74 $code.= '\n</switchpanel>\n'; 75 break; 76 default : 77 $code = ''; 78 break; 79 } 80 return $code; 81 } 82 83 function register(Doku_Event_Handler $controller){ 84 $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handle_toolbar', array ()); 85 } 86 87 function handle_toolbar(&$event, $param) { 88 $event->data[] = array ( 89 'type' => 'picker', 90 'title' => 'SwitchPanel', 91 'icon' => '../../plugins/switchpanel/pics/logo.png', 92 'list' => array( 93 array( 94 'type' => 'insert', 95 'title' => $this->getLang('panel_24rj'), 96 'icon' => '../../plugins/switchpanel/pics/panel_24rj.png', 97 'insert' => $this->getCodePanel('24rj'), 98 'block' => true 99 ), 100 array( 101 'type' => 'insert', 102 'title' => $this->getLang('panel_1x24'), 103 'icon' => '../../plugins/switchpanel/pics/panel_1x24.png', 104 'insert' => $this->getCodePanel('1x24'), 105 'block' => true 106 ), 107 array( 108 'type' => 'insert', 109 'title' => $this->getLang('panel_1x48'), 110 'icon' => '../../plugins/switchpanel/pics/panel_1x48.png', 111 'insert' => $this->getCodePanel('1x48'), 112 'block' => true 113 ), 114 array( 115 'type' => 'insert', 116 'title' => $this->getLang('panel_2x24'), 117 'icon' => '../../plugins/switchpanel/pics/panel_2x24.png', 118 'insert' => $this->getCodePanel('2x24'), 119 'block' => true 120 ), 121 array( 122 'type' => 'insert', 123 'title' => $this->getLang('panel_2x12'), 124 'icon' => '../../plugins/switchpanel/pics/panel_2x12.png', 125 'insert' => $this->getCodePanel('2x12'), 126 'block' => true 127 ), 128 array( 129 'type' => 'insert', 130 'title' => $this->getLang('panel_4x12'), 131 'icon' => '../../plugins/switchpanel/pics/panel_4x12.png', 132 'insert' => $this->getCodePanel('4x12'), 133 'block' => true 134 ), 135 array( 136 'type' => 'insert', 137 'title' => $this->getLang('panel_logo'), 138 'icon' => '../../plugins/switchpanel/pics/panel_logo.png', 139 'insert' => $this->getCodePanel('logo'), 140 'block' => true 141 ), 142 array( 143 'type' => 'insert', 144 'title' => $this->getLang('panel_ears'), 145 'icon' => '../../plugins/switchpanel/pics/panel_24rj.png', 146 'insert' => $this->getCodePanel('ears'), 147 'block' => true 148 ), 149 array( 150 'type' => 'insert', 151 'title' => $this->getLang('rj'), 152 'icon' => '../../plugins/switchpanel/pics/rj.png', 153 'insert' => 'XX,rj45:case=rj45\n', 154 'block' => false 155 ), 156 array( 157 'type' => 'insert', 158 'title' => $this->getLang('of'), 159 'icon' => '../../plugins/switchpanel/pics/of.png', 160 'insert' => 'XX,of:case=of\n', 161 'block' => false 162 ), 163 array( 164 'type' => 'insert', 165 'title' => $this->getLang('2of'), 166 'icon' => '../../plugins/switchpanel/pics/2of.png', 167 'insert' => 'XX,2of:case=2of\n', 168 'block' => false 169 ), 170 array( 171 'type' => 'insert', 172 'title' => $this->getLang('gbic'), 173 'icon' => '../../plugins/switchpanel/pics/gbic.png', 174 'insert' => 'XX,gbic:case=gbic\n', 175 'block' => false 176 ), 177 array( 178 'type' => 'insert', 179 'title' => $this->getLang('serial'), 180 'icon' => '../../plugins/switchpanel/pics/serial.png', 181 'insert' => 'XX,serial:case=serial\n', 182 'block' => false 183 ), 184 array( 185 'type' => 'insert', 186 'title' => $this->getLang('close'), 187 'icon' => '../../plugins/switchpanel/pics/close.png', 188 'insert' => 'XX,close:case=close\n', 189 'bolck' => false 190 ), 191 array( 192 'type' => 'insert', 193 'title' => $this->getLang('none'), 194 'icon' => '../../plugins/switchpanel/pics/none.png', 195 'insert' => 'XX:case=none\n', 196 'bolck' => false 197 ), 198 array( 199 'type' => 'insert', 200 'title' => $this->getLang('syntax'), 201 'icon' => '../../plugins/switchpanel/pics/syntax.png', 202 'insert' => '<code>\nIndex,Label:color="color|#rgb",case="rj45|of|2of|gbic|none|serial|close",text="Information",link="proto://url",target="page|_new|_blank"\n</code>\n', 203 'bolck' => false 204 ) 205 ) 206 ); 207 } 208} 209 210