[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 // $Id: html.php 20988 2006-04-06 11:09:19Z ralfbecker $ 3 4 // These functions take wiki entities like 'bold_begin' or 'ref' and return 5 // HTML representing these entities. They are used throught this script 6 // to generate appropriate HTML. Together with the template scripts, they 7 // constitue the sole generators of HTML in this script, and are thus the 8 // sole means of customizing appearance. 9 function html_bold_start() 10 { return '<strong>'; } 11 function html_bold_end() 12 { return '</strong>'; } 13 function html_italic_start() 14 { return '<em>'; } 15 function html_italic_end() 16 { return '</em>'; } 17 function html_tt_start() 18 { return '<tt>'; } 19 function html_tt_end() 20 { return '</tt>'; } 21 function html_ul_start() 22 { return '<ul>'; } 23 function html_ul_end() 24 { return "</ul>\n"; } 25 function html_ol_start() 26 { return '<ol>'; } 27 function html_ol_end() 28 { return "</ol>\n"; } 29 function html_li_start() 30 { return '<li>'; } 31 function html_li_end() 32 { return "</li>\n"; } 33 function html_dl_start() 34 { return '<dl>'; } 35 function html_dl_end() 36 { return "</dl>\n"; } 37 function html_dd_start() 38 { return '<dd>'; } 39 function html_dd_end() 40 { return "</dd>\n"; } 41 function html_dt_start() 42 { return '<dt>'; } 43 function html_dt_end() 44 { return '</dt>'; } 45 function html_hr() 46 { return "<hr align=left width=99% />\n"; } 47 function html_newline() 48 { return "<br />\n"; } 49 function html_head_start($level) 50 { return "<h$level>"; } 51 function html_head_end($level) 52 { return "</h$level>"; } 53 function html_nowiki($text) 54 { return $text; } 55 function html_code($text) 56 { return '<pre>' . $text . '</pre>'; } 57 function html_raw($text) 58 { return $text; } 59 function html_anchor($name) 60 { return '<a name="' . $name . '"></a>'; } 61 function html_diff_old_start() 62 { return "<table class=\"diff\"><tr><td class=\"diff-removed\">\n"; } 63 function html_diff_new_start() 64 { return "<table class=\"diff\"><tr><td class=\"diff-added\">\n"; } 65 function html_diff_end() 66 { return '</td></tr></table>'; } 67 function html_diff_add() 68 { return html_bold_start() . lang('Added').':' . html_bold_end(); } 69 function html_diff_change() 70 { return html_bold_start() . lang('Changed').':' . html_bold_end(); } 71 function html_diff_delete() 72 { return html_bold_start() . lang('Deleted').':' . html_bold_end(); } 73 function html_table_start() 74 { return '<table class="wiki" style="border: 1px solid black; border-collapse: collapse;">'; } 75 function html_table_end() 76 { return '</table>'; } 77 function html_table_row_start() 78 { return '<tr>'; } 79 function html_table_row_end() 80 { return '</tr>'; } 81 function html_table_cell_start($span = 1) 82 { 83 if($span == 1) 84 { return '<td style="border: 1px solid black; padding: 2px;">'; } 85 else 86 { return '<td style="border: 1px solid black; padding: 2px;" colspan="' . $span . '">'; } 87 } 88 function html_table_cell_end() 89 { return '</td>'; } 90 function html_time($time) 91 { 92 global $TimeZoneOff; 93 if($time == '') { return lang('never'); } 94 95 return lang(date('l',$time + $TimeZoneOff * 60)).', '.date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' '. 96 ((int) $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i:s a' : 'H:i:s'), $time + $TimeZoneOff * 60); 97 } 98 function html_gmtime($time) 99 { 100 return gmdate($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $time) . 'T' . 101 gmdate((int) $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i:s a' : 'H:i:s', $time) . 'Z'; 102 } 103 function html_timestamp($time) 104 { 105 global $TimeZoneOff; 106 107 return date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' '. 108 ((int) $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i:s a' : 'H:i:s'), $time + $TimeZoneOff * 60); 109 } 110 111 function html_url($url, $text) 112 { 113 // egw: urls are relative to the egw install-dir and if they have only 2 parts (appname,image) they are resolved via 114 // common::image() - the template is taken into account 115 if (substr($url,0,4) == 'egw:') 116 { 117 $url = preg_replace('/egw:\\/?/i','',$url); 118 $parts = explode('/',$url); 119 if (count($parts) == 2 && preg_match('/(.jpe?g|.png|.gif|.bmp)$/i', $url)) 120 { 121 $url = $GLOBALS['egw']->common->image($parts[0],$parts[1]); 122 // this deals with angles icon-thems 123 if (empty($url) && $parts[0] == 'email') 124 { 125 $icon_theme = $GLOBALS['egw_info']['user']['preferences']['email']['icon_theme']; 126 $path = '/email/templates/default/images/'.($icon_theme ? $icon_theme : 'idots').'/'.$parts[1]; 127 if (file_exists(EGW_SERVER_ROOT.$path)) 128 { 129 $url = $GLOBALS['egw_info']['server']['webserver_url'].$path; 130 } 131 } 132 } 133 elseif (substr($url,-4) == '.php' || substr($url,-1) == '/') 134 { 135 $url = $GLOBALS['egw']->link('/'.$url); 136 } 137 else 138 { 139 $url = $GLOBALS['egw_info']['server']['webserver_url'].'/'.$url; 140 } 141 } 142 $is_image = preg_match('/(.jpe?g|.png|.gif|.bmp)$/i', $url); 143 144 // vfs: urls are urls into the eGW VFS 145 if (substr($url,0,4) == 'vfs:') 146 { 147 if (!file_exists(EGW_SERVER_ROOT.'/wiki') || !$GLOBALS['egw_info']['user']['apps']['filemanager']) 148 { 149 return $url; 150 } 151 $parts = explode('/',substr($url,4)); 152 $file = array_pop($parts); 153 $path = implode('/',$parts); 154 $linkdata['menuaction'] = 'filemanager.uifilemanager.view'; 155 $linkdata['path'] = rawurlencode(base64_encode($path)); 156 $linkdata['file'] = rawurlencode(base64_encode($file)); 157 $url = $GLOBALS['egw']->link('/index.php',$linkdata); 158 } 159 if($is_image) 160 { 161 return '<img src="'.$url.'" title="'.htmlspecialchars($text[0]=='[' ? substr($text,1,-1) : $text).'" />'; 162 } 163 if (preg_match('/^mailto:([^@]*)@(.*)$/i',$url,$matchs)) // spamsaver emailaddress 164 { 165 $url = "#"; 166 $domains = "'".implode("'+unescape('%2E')+'",explode('.',$matchs[2]))."'"; 167 $onClick = " onClick=\"document.location='mai'+'lto:$matchs[1]'+unescape('%40')+$domains; return false;\""; 168 $text = str_replace('@',' AT ',str_replace('mailto:','',str_replace('.',' DOT ',$text))); 169 } 170 if ($text{0} == '[' && substr($text,-1) == ']' && !is_numeric($t=substr($text,1,-1))) $text = $t; 171 172 return '<a href="'.$url.'" '.($onClick ? $onClick : 'target="_blank"').">$text</a>"; 173 } 174 175 function html_ref($page, $appearance, $hover = '', $anchor = '', $anchor_appearance = '') 176 { 177 global $SeparateLinkWords,$EditBase; 178 179 if (!is_array($page) && strstr($page,':')) 180 { 181 list($name,$lang) = explode(':',$page); 182 if (strlen($lang) == 2 || strlen($lang) == 5 && $lang[2] == '-') 183 { 184 $page = array( 185 'name' => $name, 186 'lang' => $lang 187 ); 188 } 189 } 190 $title = get_title($page); 191 if (is_array($appearance)) 192 { 193 $appearance = $appearance['lang'] && $appearance['lang'] != $GLOBALS['egw_info']['user']['preferences']['common']['lang'] ? $appearance['title'].':'.$appearance['lang'] : $appearance['title']; 194 } 195 if($hover != '') 196 { $hover = ' title="' . $hover . '"'; } 197 198 global $pagestore; 199 $p = $pagestore->page($page); 200 201 if($p->exists()) 202 { 203 if($SeparateLinkWords && $title == $appearance) 204 { $appearance = html_split_name($title); } 205 return '<a href="' . viewURL($page) . $anchor . '"' . $hover . ' class="wiki">' 206 . $appearance . $anchor_appearance . '</a>'; 207 } 208 elseif(!$p->acl_check() || !$EditBase) 209 { 210 if(validate_page($title) == 1 // Normal WikiName 211 && $appearance == $title) // ... and is what it appears 212 { return $title; } 213 else // Free link. 214 { return $appearance; } 215 } 216 else 217 { 218 if(validate_page($title) == 1 // Normal WikiName 219 && $appearance == $title) // ... and is what it appears 220 { return $title . '<a href="' . editURL($page) . '"' . $hover . '>?</a>'; } 221 else // Free link. 222 { return '(' . $appearance . ')<a href="' . editURL($page) . '"' . $hover . '>?</a>'; } 223 } 224 } 225 function html_interwiki($url, $text) 226 { 227 return '<a href="' . $url . '" class="wiki">' . $text . '</a>'; 228 } 229 function html_twin($base, $ref) 230 { 231 global $pagestore; 232 233 return '<a href="' . $pagestore->interwiki($base) . $ref . '" class="wiki">' . 234 '<span class="twin"><em>[' . $base . ']</em></span></a>'; 235 } 236 function html_category($time, $page, $host, $user, $comment, $lang='') 237 { 238 global $pagestore; 239 240 $text = '(' . html_timestamp($time) . ') (' . 241 '<a href="' . historyURL($page) . '">'.lang('history').'</a>) ' . 242 html_ref($lang ? array('title'=>$page,'lang'=>$lang) : $page, $page); 243 244 if(count($twin = $pagestore->twinpages($page))) 245 { 246 foreach($twin as $site) 247 { $text = $text . ' ' . html_twin($site[0], $site[1]); } 248 } 249 250 $text = $text . ' . . . . ' . 251 ($user == '' ? $host : html_ref($user, $user, $host)); 252 253 if($comment != '') 254 { 255 $text = $text . ' ' . html_bold_start() . '[' . 256 str_replace('<', '<', str_replace('&', '&', $comment)) . 257 ']' . html_bold_end(); 258 } 259 260 return $text; 261 } 262 function html_fulllist($page, $count) 263 { 264 return '<strong><a href="' . viewURL($page, '', 1) . '">' . 265 lang('See complete list (%1 entries)',$count).'</a></strong>'; 266 } 267 function html_fullhistory($page, $count) 268 { 269 return '<tr><td colspan="3"><strong><a href="' . historyURL($page, 1) . 270 '" class="wiki">' . lang('See complete list (%1 entries)',$count). 271 '</a></strong></td></tr>'; 272 } 273 function html_toolbar_top() 274 { 275 global $HomePage, $PrefsScript,$AdminScript; 276 277 return html_ref($HomePage, $HomePage) . ' | ' . 278 html_ref('RecentChanges', lang('Recent Changes')); 279 /* 280 ' | <a href="' . $PrefsScript . '">Preferences</a>' . 281 ($GLOBALS['egw_info']['user']['apps']['admin'] ? 282 ' | <a href="'.$AdminScript.'">Administration</a>' : '') . '<br>'; 283 */ 284 } 285 function html_history_entry($page, $version, $time, $host, $user, $c1, $c2, 286 $comment) 287 { 288 return "<tr><td>" . 289 "<input type=\"radio\" name=\"ver1\" value=\"$version\"" . 290 ($c1 ? ' checked="checked"' : '') . " /></td>\n" . 291 " <td>" . 292 "<input type=\"radio\" name=\"ver2\" value=\"$version\"" . 293 ($c2 ? ' checked="checked"' : '') . " /></td>\n" . 294 "<td><a href=\"" . viewURL($page, $version) . "\">" . 295 html_time($time) . "</a> . . . . " . 296 ($user == '' ? $host : html_ref($user, $user, $host)) . 297 ($comment == '' ? '' : 298 (' ' . html_bold_start() . '[' . 299 str_replace('<', '<', str_replace('&', '&', $comment)) . 300 ']' . html_bold_end())) . 301 "</td></tr>\n"; 302 } 303 function html_lock_start() 304 { 305 global $AdminScript; 306 307 return '<form method="post" action="' . $AdminScript . "\">\n" . 308 '<div class="form">' . "\n" . 309 '<input type="hidden" name="locking" value="1" />' . "\n" . 310 html_bold_start() . lang('Locked') . html_bold_end() . html_newline(); 311 } 312 function html_lock_end($count) 313 { 314 return '<input type="hidden" name="count" value="' . $count . '" />' . "\n" . 315 '<input type="submit" name="Save" value="'.lang('Save').'" />' . "\n" . 316 '</div>' . "\n" . 317 '</form>' . "\n"; 318 } 319 function html_lock_page($page, $mutable) 320 { 321 static $count = 0; 322 $count++; 323 return '<input type="hidden" name="name' . $count . 324 '" value="' . urlencode($page) . '" />' . "\n" . 325 '<input type="checkbox" name="lock' . $count . '" value="1"' . 326 ($mutable ? '' : ' checked="checked"') . ' />' . "\n" . 327 "\n" . $page . html_newline(); 328 } 329 function html_rate_start() 330 { 331 return '<br /><strong>'.lang('Blocked IP address ranges').'</strong>' . 332 "\n<dl>\n"; 333 } 334 function html_rate_end() 335 { 336 global $AdminScript; 337 338 return "</dl>\n" . 339 '<form method="post" action="' . $AdminScript . "\">\n" . 340 '<div class="form">' . "\n" . 341 '<input type="hidden" name="blocking" value="1" />' . "\n" . 342 lang('Enter IP address range in form <tt>12.*</tt>, <tt>34.56.*</tt>, or <tt>78.90.123.*</tt>'). 343 '<br />' . "\n" . 344 '<input type="text" name="address" value="" size="40" /><br />' . 345 "\n" . 346 '<input type="submit" name="Block" value="'.lang('Block').'" />' . "\n" . 347 '<input type="submit" name="Unblock" value="'.lang('Unblock').'" />' . "\n" . 348 '</div>' . "\n"; 349 '</form>' . "\n"; 350 } 351 function html_rate_entry($address) 352 { 353 return '<dd>' . $address . "</dd>\n"; 354 } 355 356 // This function splits up a traditional WikiName so that individual 357 // words are separated by spaces. 358 359 function html_split_name($page) 360 { 361 global $UpperPtn, $LowerPtn; 362 363 $title = get_title($page); 364 if(validate_page($page) != 1) 365 { return $title; } 366 $page = preg_replace("/(?<=$UpperPtn|$LowerPtn)($UpperPtn$LowerPtn)/", 367 ' \\1', $title, -1); 368 $page = preg_replace("/($LowerPtn)($UpperPtn)/", 369 '\\1 \\2', $title, -1); 370 return $page; 371 } 372 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |