PHP automatically generates a front-end form frame

Source: Internet
Author: User

<?PHP/** * For the current menu item style * @param string $controller _name * @param string $action _name * @param string $style * @return Strin G*/function Activedlink ($menu _item, $style) {if(isset ($menu _item["checked"]) )    {        return$style; }}/** Get gravatar Avatar * @param string $email * @return String*/function Getgravatar ($email) {return "';}/** * Generate input TextBox * @param string $name text box name * @param int $size text box size * @param string $value text box default value * @param String $class CSS class * @return string*/function Gentext ($name, $size, $value, $class) {    return "<input type= ' text ' class= ' {$class} '"           . "size= ' {$size} ' name= ' {$name} ' value= ' {$value} '/>";}/** * Generate input Password box * @param string $name Password box name * @param string $size Password box size * @param string $value Password box default value * @param String $class CSS class * @return string*/function Genpassword ($name, $size, $value, $class) {    return "<input type= ' password ' class= ' {$class} '"           . "size= ' {$size} ' name= ' {$name} ' value= ' {$value} '/>";}/** * Generate select Dropdown box * @param string $name drop-down box name * @param array $list drop-down box optional * @param int $seleced Default * @ param string $class CSS class * @return string*/function genselect ($name, array $list, $selected=0, $class="') {$html="<select name= ' {$name} ' class= ' {$class} ' >"; $i=0; foreach($list as$text =$value) {$html.= Indent ()."<option value= ' {$value} '"; if($i = =$selected) {$html.="selected= ' selected '"; } $html.=">{$text}</option>"; $i++; } $html.="</select>"; return$html;}/** * Generate Radio Box * @param string $name The name of the radio box @param string $text a radio box to display the text * @param string $value a radio box Value * @param boolean $checked whether to select * @param string $class CSS class * @return string*/function Genradio ($name, $text, $value, $checked=false, $class="') {$html="<input type= ' Radio ' name= ' {$name} '"            . "value= ' {$value} ' class= ' {$class} '"; if($checked) {$html.="checked= ' checked '"; } $html.="/> {$text}"; return$html;}/** * Generate radio Single Box group * @param string $name Radio Box name * @param array $list Radio box list * @param int $checked checked * @param string $class CSS class * @return string*/function Genradios ($name, array $list, $checked=0, $class="') {$html="'; $i=0; foreach($list as$text =$value) {$html.= $i = = $checked? Genradio ($name, $text, $value,true, $class): genradio ($name, $text, $value); $i++; }    return$html;}/** * Generate checkbox check box * @param string $name check box name * @param string $text check box to display text * @param string $value Check Box Value * @param boolean $checked whether to select * @param string $class CSS class * @return string*/function Gencheckbox ($name, $text, $value, $checked=false, $class="') {$html="<input type= ' checkbox ' name= ' {$name}[] '"            . "value= ' {$value} ' class= ' {$class} '"; if($checked) {$html.="checked= ' checked '"; } $html.="/> {$text}"; return$html;}/** * Generate checkbox for CheckBox Group * @param string $name check box name * @param array $list check box list * @param string $checked whether to select in, ', ' separated * @param string $class CSS class * @return string*/function Gencheckboxs ($name, array $list, $checked, $class="') {$html="'; $checked= Array_filter (explode (',', $checked), function ($pos) {return! (empty ($POS) &&0!== $pos &&'0'!==$pos);    }); $i=0; foreach($list as$text =$value) {$html.= In_array ($i, $checked) ?gencheckbox ($name, $text, $value,true, $class): gencheckbox ($name, $text, $value); $i++; }    return$html;}/** * Generate File Upload * @param string $name file Field name * @return String*/function Genfile ($name, $class="') {    return "<input type= ' file ' name= ' {$name} ' class= ' {$class} '/>";}/** * Generate DatePicker * @param string $name form domain name * @param string $class CSS class * @return string*/function Gendate ($name, $value, $class="') {$src= __app__.'/.. /public/javascripts/admin/datepicker/images2/cal.gif'; $id= Rand_code (8); return "<input type= ' text ' id= ' {$id} '"           . "value= ' {$value} ' class= ' {$class} ' name= ' {$name} '/>"           . ""           . "onclick= ' javascript:newcsscal (\ "{$id}\", \ "yyyymmdd\") '/>";}/** * Generate textarea Text field * @param string $name text field name * @param string $value text field value * @param int $rows       Text field rows * @param int $cols text field cols * @param string $placeholder text field holder * @param string $class CSS class * @return string*/function Gentextarea ($name, $value, $cols, $rows, $placeholder="', $class) {$html="<textarea name= ' {$name} ' class= ' {$class} '"            . "rows= ' {$rows} ' cols= ' {$cols} '"; if(isset ($value) &&!Empty ($value)) {$html.=">{$value}</textarea>"; } Else if("'!=$placeholder) {$html.="placeholder= ' {$placeholder} ' ></textarea>"; } Else{$html.="></textarea>"; }    return$html;}/** * Generate editor * @param string $name text field name * @param string $value text field value * @param int $rows text field rows * @param int $cols text field cols * @param string $type Editor type * @return string*/function Geneditor ($name, $value, $cols, $rows, $type=' simple') {$id= Rand_code (8); $html="<textarea name= ' {$name} ' id= ' {$id} '"            . "rows= ' {$rows} ' cols= ' {$cols} '"; if(' simple'==$type) {$js="<script type= ' text/javascript ' >$ (function () {kindeditor.ready (function (K) {k.create (' #{$id} ', { resizetype:1,items:[' fontname ', ' fontsize ', ' | ', ' ForeColor ', ' Hilitecolor ', ' bold ', ' italic ', ' underline ', ' Removeformat ', ' | ', ' Justifyleft ', ' justifycenter ', ' justifyright ', ' insertorderedlist ', ' insertunorderedlist ', ' | ', ' Emoticons ', ' image ', ' link '],afterblur:function () {this.sync ();});}); </script>"; } Else{$js="<script type= ' text/javascript ' >$ (function () {kindeditor.ready (function (K) {k.create (' #{$id} ', { Resizetype:1,afterblur:function () {this.sync ();});}); </script>"; }    if(isset ($value) &&!Empty ($value)) {$html.=">{$value}</textarea>"; } Else{$html.="></textarea>"; }    return$html. $js;}/** * indent * @param integer $space indent the number of spaces * @return String*/function Indent ($space=4) {$indent="';  for($i =0; $i < $space; $i + +) {$indent.=' '; }    return$indent;}

PHP automatically generates a front-end form frame

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.