| [ PHPXref.com ] | [ Generated: Sun Jul 20 18:21:30 2008 ] | [ JFFNMS 0.8.2 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <? 2 /* This file is part of JFFNMS 3 * Copyright (C) <2002-2005> Javier Szyszlican <javier@szysz.com> 4 * This program is licensed under the GNU GPL, full terms in the LICENSE file 5 */ 6 /* Basic HTML Structures */ 7 8 function tag ($name, $id = "", $class = "", $others = "", $indent = true, $keep_lines = false) { 9 return 10 html_indenter(). 11 "<".$name. 12 (!empty($id)?" id='".$id."'":""). 13 (!empty($class)?" class='".$class."'":""). 14 (!empty($others)?" ".trim($others):""). 15 ">". 16 (($keep_lines)?"":"\n"). 17 (($indent)?html_indent_more():""); 18 } 19 20 function tag_close($name, $indent = true, $indent_after = true) { 21 return 22 (($indent)?html_indent_less():""). 23 (($indent_after)?html_indenter():""). 24 "</".$name.">\n"; 25 } 26 27 function html ($name, $content, $id = "", $class = "", $others = "", $indent = true, $keep_lines = false) { 28 return 29 tag ($name, $id, $class, $others, $indent, $keep_lines). 30 (!empty($content) 31 ?re_indent($content,$keep_lines) 32 :""). 33 tag_close($name, $indent, $indent); 34 } 35 36 function re_indent($text, $keep_lines = false) { 37 38 if ($keep_lines) return $text; 39 40 $ind = html_indenter(); 41 42 $lines = explode("\n",$text); 43 44 foreach ($lines as $line) 45 if ($line!=="") { 46 $line = rtrim($line); 47 if (++$i==1) $cant = @substr_count("\t",$line); 48 49 $line = substr($line,$count); 50 $result .= $ind.$line."\n"; 51 } 52 53 return rtrim($result)."\n"; 54 } 55 56 /* Complex HTML Structures */ 57 58 function table ($id="", $class = "") { 59 return tag("table", $id, $class, "", false); 60 } 61 62 function table_close() { 63 return tag_close ("table", false); 64 } 65 66 function tr_open($id = "", $class = "", $bgcolor = "", $rowspan = "", $style = "") { 67 return 68 tag("tr", $id, $class, 69 (!empty($bgcolor)?" bgcolor='$bgcolor'":""). 70 (!empty($rowspan)?" rowspan=$rowspan":""). 71 (!empty($style)?" style='$style'":"")); 72 } 73 74 function td ($content="", $class = "", $id = "", $colspan = "", $rowspan = "", $keep_lines = false) { 75 return 76 html ("td", $content, $id, $class, 77 (is_numeric($colspan)?" colspan='$colspan'":""). 78 (is_numeric($rowspan)?" rowspan='$rowspan'":""), true, $keep_lines); 79 } 80 81 function table_row($text = "", $class = "", $colspan="", $rowspan="", $echo = true) { 82 83 $result = 84 tr_open("", "", "", $rowspan). 85 td($text, $class, "", $colspan). 86 tag_close("tr"); 87 88 if ($echo) 89 echo $result; 90 91 return $result; 92 } 93 94 function tr ($tds = "", $classes = "", $colspans="", $rowspan="") { 95 96 $tds = !is_array($tds)?array($tds):$tds; 97 $classes = !is_array($classes)?array($classes):$classes; 98 $colspans = !is_array($colspans)?array($colspans):$colspans; 99 100 $result = tr_open("", "", "", $rowspan); 101 102 foreach ($tds as $key=>$td_content) 103 $result .= td ($td_content, 104 (isset($classes[$key])?$classes[$key]:current($classes)), "", 105 (isset($colspans[$key])?$colspans[$key]:current($colspans))); 106 107 $result .= tag_close("tr"); 108 109 return $result; 110 } 111 112 function script ($content) { 113 return 114 tag ("script","","","type='text/javascript'"). 115 re_indent($content,true)."\n". 116 tag_close("script"); 117 } 118 119 function br() { 120 return tag ("br","","","",false); 121 } 122 123 function memobox($name,$rows,$cols,$value) { 124 return 125 html ("textarea", $value, "", "", "rows='$rows' cols='$cols' name='$name'", false, true); 126 } 127 128 function checkbox($name, $var, $form = true) { 129 return checkbox_value($name,1,$var,$form); 130 } 131 132 function checkbox_value($name,$value, $check = false, $form = true, $onclick="") { 133 if ($form==false) { 134 $name = "checkbox_".rand(1000,9999); 135 $disabled = " disabled"; 136 } 137 138 if ($check==true) $checked=" checked"; 139 if (!empty($onclick)) $js = " onClick=\"$onclick\""; 140 141 return 142 tag("input", $name, "", 143 "type='checkbox' name='$name' value='$value'".$checked.$js.$disabled, false); 144 } 145 146 function textbox($name, $var, $len = 0, $maxsize = 0, $disabled = 0) { 147 return tag("input", $name, "", 148 "type='text' name='$name' value='$var' size='".(($len==0)?strlen($var):$len)."'". 149 (($maxsize>0)?" maxsize='$maxsize'":""). 150 (($disabled==1)?" disabled":""), false); 151 } 152 153 function form ($id = "", $action = "", $method = "POST", $target = "_self", $class = "") { 154 return 155 tag ("form", $id, $class, 156 (!empty($action)?" action='".$action."'":""). 157 (!empty($method)?" method='".$method."'":""). 158 (!empty($target)?" target='".$target."'":"") 159 ,false); 160 } 161 162 function adm_form_submit($value = "Submit", $name = "") { 163 return 164 tag ("input", "" ,"", 165 (!empty($name)?"name='$name'":""). 166 " type='submit' value='$value'", false); 167 } 168 169 function form_close() { 170 return tag_close("form", false); 171 } 172 173 function image($src, $w = "", $h = "", $title = "", $class="", $id = "", $onclick="", $others = "") { 174 175 if (!empty($src) && (strpos($src,"/")===false)) { //when we were given a file without a path 176 if (($w==="") && ($h==="")) //only when w and h are not set, but if you use NULL you will avoid the w/h fields 177 list($w, $h) = getimagesize($GLOBALS["jffnms_real_path"]."/htdocs/images/".$src); 178 179 $src = $GLOBALS["jffnms_rel_path"]."/images/".$src; //add default path 180 } 181 182 return 183 tag ("img", $id, $class, 184 "src='".$src."'". 185 " title='".$title."' alt='".$title."'". 186 (!empty($w)?" width='".$w."'":""). 187 (!empty($h)?" height='".$h."'":""). 188 (!empty($onclick)?" OnClick='javascript: ".$onclick."'":""). 189 (!empty($others)?" ".$others:"") 190 , false); 191 } 192 193 function linktext ($text, $url, $target="" ,$class = "", $on_click = "", $id = "", $style = "") { 194 return 195 html ("a", $text, $id, $class, 196 (!empty($target)?" target='".$target."'":""). 197 (!empty($url)?" href=\"".htmlspecialchars($url)."\"":""). 198 (!empty($on_click)?" onClick=\"".$on_click."\"":""). 199 (!empty($style)?" style='".$style."'":"") 200 ); 201 } 202 203 function radiobutton($name, $selected, $value) { 204 return tag ("input", $name, ""," type='radio' name='".$name."' value='".$value."'". 205 (($selected==1)?" checked":""), false); 206 } 207 208 function hidden($name,$value) { 209 return tag ("input","","","type='hidden' name='".$name."' value='".$value."'", false); 210 } 211 212 function select_custom ($control_name,$options,$mark_values,$onclick="", $size = 1, $echo = false, $class = "", $ondblclick = "") { 213 214 if ($size > 1) { 215 $multi = "multiple size='".$size."'"; 216 $control_name.="[]"; 217 } 218 219 if (!is_array($mark_values)) $mark_values=explode(",",$mark_values); 220 221 $result .= tag ("select", $control_name, $class, "name='".$control_name."'". 222 (($onclick)?" onChange=\"".$onclick."\"":""). 223 (($ondblclick)?" onDblClick=\"".$ondblclick."\"":""). 224 (!empty($multi)?" ".$multi:"")); 225 226 foreach ($options as $key=>$value){ 227 //debug ($key." - ".in_array($key,$mark_values)." - ".$mark_values[0]." - ".($mark_values[0]==="SELECT_ALL")); 228 229 $encoded_key = ((strpos($key,"=")===false) && (strlen($key) > 3))?urlencode($key):$key; 230 231 $result .= html("option",$value,"","","value='".$encoded_key."'". 232 ((in_array($key,$mark_values) or ($mark_values[0]==="SELECT_ALL"))?" selected":"") 233 , false, true); 234 } 235 236 $result .= tag_close("select"); 237 238 if ($echo) 239 echo $result; 240 return $result; 241 } 242 243 /* HTML Automatic Indenting Functions */ 244 245 function html_indent_none() { 246 html_indent_init(); 247 $GLOBALS["html_indents"][$GLOBALS["html_indent"]]=0; 248 } 249 250 function html_indent_more () { 251 $GLOBALS["html_indent"]++; 252 return html_indent_none(); 253 } 254 255 function html_indent_less () { 256 $GLOBALS["html_indent"]--; 257 return html_indent_none(); 258 } 259 260 function html_indent_init () { 261 if (!isset($GLOBALS["html_indent"]) || !isset($GLOBALS["html_indents"])) { 262 $GLOBALS["html_indent"] = 0; 263 $GLOBALS["html_indents"] = array($GLOBALS["html_indent"]=>0); 264 } 265 } 266 267 function html_indent_already() { 268 html_indent_init(); 269 return $GLOBALS["html_indents"][$GLOBALS["html_indent"]]; 270 } 271 272 function html_indenter ($verify = 0, $count = 1) { 273 if ((html_indent_already()==0) || (!$verify)) { 274 275 $result = ""; 276 for ($i = 0; $i < $GLOBALS["html_indent"]; $i++) $result .= "\t"; 277 278 if ($count) $GLOBALS["html_indents"][$GLOBALS["html_indent"]]=1; 279 280 return $result; 281 } else 282 echo "!"; 283 } 284 285 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |