Plugin Directory

Changeset 1710712


Ignore:
Timestamp:
08/09/2017 04:54:30 AM (9 years ago)
Author:
faaiq
Message:

now nofile render

File:
1 edited

Legend:

Unmodified
Added
Removed
  • dynamic-donation/trunk/wp-dynamic-donation.php

    r1129230 r1710712  
    148148    function handle_submit() {
    149149        global $wpdb;
    150         //print_r($_REQUEST);
     150
    151151        if(isset($_REQUEST['donation'])) {
    152152            $donation = $_REQUEST['donation'];
     
    238238    function process_payment() {
    239239        global $wpdb;
    240         $payment = $_POST['submit'];
     240        $payment = $_POST['payment'];
    241241       
    242242        $this->gateway_type = get_option('_ddf_paypal_sandbox','test');
     
    329329        }
    330330       
     331
     332
    331333        $theme_path =  get_template_directory();
     334
    332335        $form_path = $theme_path . '/' . 'template-dynamic-donation-form.php';
     336
    333337        if(file_exists($form_path)) {
    334338            ob_start();
     
    338342           
    339343        }else {
    340             $html = 'Error : Please export template from donation menu and create a file  template-dynamic-donation-form.php in your theme directory';
     344           
     345            return $this->export_template_nofile();
     346           
     347            //$html = 'Error : Please export template from donation menu and create a file  template-dynamic-donation-form.php in your theme directory';
    341348        }
    342349       
     
    347354   
    348355   
    349     function export_template() {
     356    function export_template($return =false) {
    350357        global $wpdb;
    351358       
    352359        $fields_row = $wpdb->get_results("SELECT * FROM " . $this->field_table ." WHERE enable = 1 order by id");
     360
     361
    353362        $form = '<form  method="post">' .chr(13);
    354363        $form .= '<input type="hidden" name="donation-form-submission" value="1">' .chr(13);
     
    407416        $form .= $this->get_payment_form();
    408417        $form .= '</form>' . chr(13);
    409        
    410         $html = '<div class="wrap">';
    411         $html .= '<h2>Dynamic Donation Export Template</h2><br>';
    412         $html .= '<p>Copy paste code of this file in your current theme directory. template-dynamic-donation-form.php, You can change its html as your need</p><br>';
    413         $html .= '<form method="post">';
    414         $html .= '<textarea rows="30" cols="80"><div id="donation-form">'.htmlentities($form).'</div></textarea><br><br>';
    415         $html .= '</form>';
    416         $html .= '</div>';
    417         print $html;
    418     }
     418        if($return == false ) {
     419            $html = '<div class="wrap">';
     420            $html .= '<h2>Dynamic Donation Export Template</h2><br>';
     421            $html .= '<p>Copy paste code of this file in your current theme directory. template-dynamic-donation-form.php, You can change its html as your need</p><br>';
     422            $html .= '<form method="post">';
     423            $html .= '<textarea rows="30" cols="80"><div id="donation-form">'.htmlentities($form).'</div></textarea><br><br>';
     424            $html .= '</form>';
     425            $html .= '</div>';
     426            print $html;
     427        }else {
     428            return $form;
     429        }
     430    }
     431
     432    function export_template_nofile() {
     433        global $wpdb;
     434       
     435        $fields_row = $wpdb->get_results("SELECT * FROM " . $this->field_table ." WHERE enable = 1 order by id");
     436       
     437
     438        $form = '<form  method="post">' .chr(13);
     439        $form .= '<input type="hidden" name="donation-form-submission" value="1">' .chr(13);
     440        for($i =0 ; $i < count($fields_row); ++$i) {
     441            $form .= '<div class="form-control">' . chr(13);
     442           
     443            $form .= chr(9) . '<div class="form-label">' . chr(13);
     444            $form .= chr(9) . chr(9) . $fields_row[$i]->field_label. chr(13);
     445            $form .= chr(9) . '</div>' . chr(13);
     446           
     447            $form .= chr(9) . '<div class="form-field">' . chr(13);
     448           
     449            if($fields_row[$i]->field_type == 'text') {
     450                $form .=  chr(9) . chr(9) . '<input type="text" name="'.$fields_row[$i]->field_name.'" id="'.$fields_row[$i]->field_name.'" value="" size="30">' . chr(13);
     451            }else if($fields_row[$i]->field_type == 'select') {
     452                $field_options = explode(",",$fields_row[$i]->field_options);
     453               
     454               
     455                $form .= chr(9) . chr(9) . '<select name="'.$fields_row[$i]->field_name.'" id="'.$fields_row[$i]->field_name.'">' . chr(13);
     456                for($fo = 0; $fo < count($field_options); ++$fo) {
     457
     458                    list($label,$opt) = explode("|",$field_options[$fo]);
     459
     460                    if($opt && $label) {
     461                        $form .= chr(9) . chr(9) . chr(9) . '<option  value="'.$opt.'">'.$label.'</option>' . chr(13);
     462                    }
     463                }
     464                $form .= chr(9) . chr(9) . '</select>' . chr(13);
     465            }else if($fields_row[$i]->field_type == 'checkbox') {
     466                $field_options = explode(",",$fields_row[$i]->field_options);
     467               
     468                $form .= chr(9) . chr(9) . '<?php if(!isset($'.$fields_row[$i]->field_name.')) {$'.$fields_row[$i]->field_name.' = array();} ?>';
     469                for($fo = 0; $fo < count($field_options); ++$fo) {
     470                    list($label,$opt) = explode("|",$field_options[$fo]);
     471                    if($opt && $label) {
     472                        $form .= chr(9) . chr(9) . '<input <?php print (in_array('.$opt.',$'.$fields_row[$i]->field_name.')) ? \'checked\' : \'\'; ?> type="checkbox" value="'.$opt.'" name="'.$fields_row[$i]->field_name.'[]" id="'.$fields_row[$i]->field_name.'1" > ' . $label . chr(13);
     473                    }
     474                }
     475               
     476            }else if($fields_row[$i]->field_type == 'radio') {
     477                $field_options = explode(",",$fields_row[$i]->field_options);
     478                for($fo = 0; $fo < count($field_options); ++$fo) {
     479                list($label,$opt) = explode("|",$field_options[$fo]);
     480                    if($opt && $label) {
     481                        $form .= chr(9) . chr(9) . '<input  <?php print ($'.$fields_row[$i]->field_name.' == '.$opt.') ? \'checked\' : \'\'; ?> type="radio" value="'.$opt.'" name="'.$fields_row[$i]->field_name.'" id="'.$fields_row[$i]->field_name.'1" > '. $label . chr(13);
     482                    }
     483                }
     484               
     485            }else if($fields_row[$i]->field_type == 'textarea') {
     486                $form .= chr(9) . chr(9) . '<textarea name="'.$fields_row[$i]->field_name.'" id="'.$fields_row[$i]->field_name.'" rows"3" cols="40"><?php print $'.$fields_row[$i]->field_name.'; ?></textarea>' . chr(13);
     487            }
     488           
     489            $form .= chr(9) . '</div>' . chr(13);
     490           
     491            $form .= '</div>' . chr(13);
     492        }
     493       
     494        $form .= $this->get_payment_form();
     495        $form .= '</form>' . chr(13);
     496        return $form;
     497    }   
    419498   
    420499    function get_payment_form() {
     
    747826            $checked = '';
    748827            if($fields_result[$i]->enable == 1) {
    749             $checked = 'checked';   
     828                $checked = 'checked';   
    750829            }
    751830            $html .= '<input type="checkbox" value="1" onclick="ddf_field_status(\''.$fields_result[$i]->id.'\');" name="field_enable['.$fields_result[$i]->id.'][]" '.$checked.'>';
     
    902981                field_type VARCHAR( 10 ) NULL ,
    903982                field_label VARCHAR( 100 ) NULL ,
     983                field_options VARCHAR( 250 ) NULL ,
    904984                enable INT( 1 ) NULL ,PRIMARY KEY (  `id` )
    905985            ) ENGINE = MYISAM ;";
     
    9311011        dbDelta($sql);
    9321012    }   
     1013
     1014    function render_if_noform() {
     1015       
     1016        $html = "";
     1017        $html .= '<div id="donation-form"><form  method="post">';
     1018        $html .= '<input type="hidden" name="donation-form-submission" value="1">';
     1019        $html .= '<div class="form-control">';
     1020        $html .= '<div class="form-label">';
     1021        $html .= 'Amount';
     1022        $html .= '</div>';
     1023        $html .= '<div class="form-field">';
     1024        $html .= '<input type="text" name="amount" id="amount" value="<?php print @$amount;?>" size="30">';
     1025        $html .= '</div>';
     1026        $html .= '</div>';
     1027        $html .= '<div class="form-control">';
     1028        $html .= '<div class="form-label">';
     1029        $html .= 'Title';
     1030        $html .= '</div>';
     1031        $html .= '<div class="form-field">';
     1032        $html .= '<select name="title" id="title">';
     1033        $html .= '</select>';
     1034        $html .= '</div>';
     1035        $html .= '</div>';
     1036        $html .= '<div class="form-control">';
     1037        $html .= '<div class="form-label">';
     1038        $html .= 'First Name';
     1039        $html .= '</div>';
     1040        $html .= '<div class="form-field">';
     1041        $html .= '<input type="text" name="first_name" id="first_name" value="<?php print @$first_name;?>" size="30">';
     1042        $html .= '</div>';
     1043        $html .= '</div>';
     1044        $html .= '<div class="form-control">';
     1045        $html .= '<div class="form-label">';
     1046        $html .= 'Last Name';
     1047        $html .= '</div>';
     1048        $html .= '<div class="form-field">';
     1049        $html .= '<input type="text" name="last_name" id="last_name" value="<?php print @$last_name;?>" size="30">';
     1050        $html .= '</div>';
     1051        $html .= '</div>';
     1052        $html .= '<div class="form-control">';
     1053        $html .= '<div class="form-label">';
     1054        $html .= 'Mobile';
     1055        $html .= '</div>';
     1056        $html .= '<div class="form-field">';
     1057        $html .= '<input type="text" name="mobile" id="mobile" value="<?php print @$mobile;?>" size="30">';
     1058        $html .= '</div>';
     1059        $html .= '</div>';
     1060        $html .= '<div class="form-control">';
     1061        $html .= '<div class="form-label">';
     1062        $html .= 'Address 1';
     1063        $html .= '</div>';
     1064        $html .= '<div class="form-field">';
     1065        $html .= '<input type="text" name="address1" id="address1" value="<?php print @$address1;?>" size="30">';
     1066        $html .= '</div>';
     1067        $html .= '</div>';
     1068        $html .= '<div class="form-control">';
     1069        $html .= '<div class="form-label">';
     1070        $html .= 'Address 2';
     1071        $html .= '</div>';
     1072        $html .= '<div class="form-field">';
     1073        $html .= '<input type="text" name="address2" id="address2" value="<?php print @$address2;?>" size="30">';
     1074        $html .= '</div>';
     1075        $html .= '</div>';
     1076        $html .= '<div class="form-control">';
     1077        $html .= '<div class="form-label">';
     1078        $html .= 'City';
     1079        $html .= '</div>';
     1080        $html .= '<div class="form-field">';
     1081        $html .= '<input type="text" name="city" id="city" value="<?php print @$city;?>" size="30">';
     1082        $html .= '</div>';
     1083        $html .= '</div>';
     1084        $html .= '<div class="form-control">';
     1085        $html .= '<div class="form-label">';
     1086        $html .= 'State';
     1087        $html .= '</div>';
     1088        $html .= '<div class="form-field">';
     1089        $html .= '<input type="text" name="state" id="state" value="<?php print @$state;?>" size="30">';
     1090        $html .= '</div>';
     1091        $html .= '</div>';
     1092        $html .= '<div class="form-control">';
     1093        $html .= '<div class="form-label">';
     1094        $html .= 'Zip';
     1095        $html .= '</div>';
     1096        $html .= '<div class="form-field">';
     1097        $html .= '<input type="text" name="zip" id="zip" value="<?php print @$zip;?>" size="30">';
     1098        $html .= '</div>';
     1099        $html .= '</div>';
     1100        $html .= '<div class="form-control">';
     1101        $html .= '<div class="form-label">';
     1102        $html .= 'Country';
     1103        $html .= '</div>';
     1104        $html .= '<div class="form-field">';
     1105        $html .= '<input type="text" name="country" id="country" value="<?php print @$country;?>" size="30">';
     1106        $html .= '</div>';
     1107        $html .= '</div>';
     1108        $html .= '<div class="form-control">';
     1109        $html .= '<div class="form-label">';
     1110        $html .= 'Name of Credit Card';
     1111        $html .= '</div>';
     1112        $html .= '<div class="form-field">';
     1113        $html .= '<input type="text" name="ccname" value="" size="40">';
     1114        $html .= '</div>';
     1115        $html .= '</div>';
     1116        $html .= '<div class="form-control">';
     1117        $html .= '<div class="form-label">';
     1118        $html .= 'Credit Card Number';
     1119        $html .= '</div>';
     1120        $html .= '<div class="form-field">';
     1121        $html .= '<input type="text" name="ccnum" value="" size="40">';
     1122        $html .= '</div>';
     1123        $html .= '</div>';
     1124        $html .= '<div class="form-control">';
     1125        $html .= '<div class="form-label">';
     1126        $html .= 'Credit expiry date';
     1127        $html .= '</div>';
     1128        $html .= '<div class="form-field">';
     1129        $html .= '<select name="month" id="month">';
     1130        $html .= '<option value="01">01</option>';
     1131        $html .= '<option value="02">02</option>';
     1132        $html .= '<option value="03">03</option>';
     1133        $html .= '<option value="04">04</option>';
     1134        $html .= '<option value="05">05</option>';
     1135        $html .= '<option value="06">06</option>';
     1136        $html .= '<option value="07">07</option>';
     1137        $html .= '<option value="08">08</option>';
     1138        $html .= '<option value="09">09</option>';
     1139        $html .= '<option value="10">10</option>';
     1140        $html .= '<option value="11">11</option>';
     1141        $html .= '<option value="12">12</option>';
     1142        $html .= '</select>';
     1143        $html .= '<select name="year" id="year">';
     1144        $html .= '<option value="17">17</option>';
     1145        $html .= '<option value="18">18</option>';
     1146        $html .= '<option value="19">19</option>';
     1147        $html .= '<option value="20">20</option>';
     1148        $html .= '<option value="21">21</option>';
     1149        $html .= '<option value="22">22</option>';
     1150        $html .= '<option value="23">23</option>';
     1151        $html .= '<option value="24">24</option>';
     1152        $html .= '<option value="25">25</option>';
     1153        $html .= '<option value="26">26</option>';
     1154        $html .= '<option value="27">27</option>';
     1155        $html .= '<option value="28">28</option>';
     1156        $html .= '<option value="29">29</option>';
     1157        $html .= '<option value="30">30</option>';
     1158        $html .= '<option value="31">31</option>';
     1159        $html .= '<option value="32">32</option>';
     1160        $html .= '<option value="33">33</option>';
     1161        $html .= '<option value="34">34</option>';
     1162        $html .= '<option value="35">35</option>';
     1163        $html .= '<option value="36">36</option>';
     1164        $html .= '<option value="37">37</option>';
     1165        $html .= '</select>';
     1166        $html .= '</div>';
     1167        $html .= '</div>';
     1168        $html .= '<div class="form-control">';
     1169        $html .= '<div class="form-label">';
     1170        $html .= 'CCV';
     1171        $html .= '</div>';
     1172        $html .= '<div class="form-field">';
     1173        $html .= '<input type="text" name="ccv" value="" size="4">';
     1174        $html .= '</div>';
     1175        $html .= '</div>';
     1176        $html .= '<div class="form-control">';
     1177        $html .= '<input type="submit" name="payment" value="Submit" >';
     1178        $html .= '</div>';
     1179        $html .= '<BR>-OR-<BR>';
     1180        $html .= '<div class="form-control">';
     1181        $html .= '<div class="form-label">';
     1182        $html .= 'Pay With Paypal';
     1183        $html .= '</div>';
     1184        $html .= '<div class="form-field">';
     1185        $html .= '<input type="submit" name="submit" value="Paypal">';
     1186        $html .= '</div>';
     1187        $html .= '</div>';
     1188        $html .= '</form>';
     1189        $html .= '</div>';
     1190        return $html;
     1191    }
    9331192}
    9341193
Note: See TracChangeset for help on using the changeset viewer.