[ Index ]

MailPress 7.1

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-admin/includes/ -> form_fields.php (source)

   1  <?php
   2  
   3  if ( !( function_exists( 'current_user_can' ) && current_user_can( MP_AdminPage::capability ) ) ) die( 'Access denied' );
   4  
   5  $url_parms = MP_AdminPage::get_url_parms( array( 's', 'paged', 'id', 'form_id' ) );
   6  
   7  $form = MP_Form::get( $url_parms['form_id'] );
   8  
   9  //
  10  // MANAGING H1
  11  //
  12  
  13  $h1 = sprintf( __( 'Fields in form &#8220;%1$s&#8221;', 'MailPress' ), $form->label );
  14  $h1_preview_url = esc_url( MP_AdminPage::url( admin_url( 'admin-ajax.php' ), array( 'id' => $form->id, 'action' => 'mp_ajax', 'mp_action' => 'ifview', 'TB_iframe' => 'true' ) ) );
  15  
  16  //
  17  // MANAGING MESSAGE
  18  //
  19  
  20  $messages[1] = __( 'Field added.', 'MailPress' );
  21  $messages[2] = __( 'Field updated.', 'MailPress' );
  22  $messages[3] = __( 'Field deleted.', 'MailPress' );
  23  $messages[4] = __( 'Fields deleted.', 'MailPress' );
  24  $messages[91] = __( 'Field not added.', 'MailPress' );
  25  $messages[92] = __( 'Field not updated.', 'MailPress' );
  26  
  27  if ( isset( MP_AdminPage::$get_['message'] ) )
  28  {
  29      $message = $messages[MP_AdminPage::$get_['message']];
  30      $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message' ), $_SERVER['REQUEST_URI'] );
  31  }
  32  
  33  //
  34  // MANAGING BULK ACTIONS
  35  //
  36  
  37  $bulk_actions['']         = __( 'Bulk Actions' );
  38  $bulk_actions['delete']    = __( 'Delete', 'MailPress' );
  39  
  40  //
  41  // MANAGING CONTENT
  42  //
  43  
  44  // Form field types
  45  
  46  $field_types = MP_Form_field_types::get_all();
  47  
  48  // Form templates
  49  
  50  $form_templates = new MP_Form_templates();
  51  $xform_subtemplates = $form_templates->get_all_fields( $form->template );
  52  
  53  global $action;
  54  wp_reset_vars( array( 'action' ) );
  55  if ( 'edit' == $action ) 
  56  {
  57      $action = 'edited';
  58      $cancel = '<input type="submit" name="cancel" class="button" value="' . esc_attr( __( 'Cancel', 'MailPress' ) ) . '" />';
  59  
  60      $id = ( int ) $url_parms['id'];
  61      $field = MP_Form_field::get( $id );
  62  
  63      $h3 = sprintf( __( 'Edit Form Field # %1$s', 'MailPress' ), $id );
  64      $hb3= __( 'Update' );
  65      $hbclass = '-primary';
  66  
  67  // protected
  68      $disabled = '';
  69      if ( isset( $field->settings['options']['protected'] ) && $field->settings['options']['protected'] ) $disabled = ' disabled="disabled"';
  70  }
  71  else 
  72  {
  73      $action = MP_AdminPage::add_form_id;
  74      $cancel = '';
  75  
  76      $field = new stdClass();
  77      $field->type = 'text';
  78  
  79      $h3 = $hb3 = __( 'Add Form Field', 'MailPress' );
  80      $hbclass = '';
  81  
  82      $disabled = '';
  83  }
  84  
  85  $field->form_incopy = ( isset( $form->settings['visitor']['mail'] ) && ( $form->settings['visitor']['mail'] != '0' ) );
  86  
  87  //
  88  // MANAGING LIST
  89  //
  90  
  91  $url_parms['paged'] = isset( $url_parms['paged'] ) ? $url_parms['paged'] : 1;
  92  $_per_page = MP_AdminPage::get_per_page();
  93  do
  94  {
  95      $start = ( $url_parms['paged'] - 1 ) * $_per_page;
  96      list( $items, $total ) = MP_AdminPage::get_list( array( 'start' => $start, '_per_page' => $_per_page, 'url_parms' => $url_parms ) );
  97      $url_parms['paged']--;        
  98  } while ( $total <= $start );
  99  $url_parms['paged']++;
 100  
 101  ?>
 102  <div class="wrap nosubsub">
 103      <h1>
 104          <?php echo esc_html( $h1 ); ?> 
 105          <?php printf( '<a href="%1$s" title="%2$s" class="thickbox thickbox-preview add-new-h2" >%3$s</a>', $h1_preview_url, esc_attr( sprintf( __( 'Form preview #%1$s (%2$s)', 'MailPress' ), $form->id, $form->label ) ), esc_html( __( 'Preview', 'MailPress' ) ) ); ?>
 106  <?php if ( isset( $url_parms['s'] ) ) printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_attr( $url_parms['s'] ) ); ?>
 107      </h1>
 108  <?php if ( isset( $message ) ) MP_AdminPage::message( $message, ( MP_AdminPage::$get_['message'] < 90 ) ); ?>
 109      <form class="search-form topmargin" method="get">
 110  
 111          <input type="hidden" name="page" value="<?php echo MailPress_page_forms; ?>" />
 112          <input type="hidden" name="file" value="fields" />
 113          <?php MP_AdminPage::post_url_parms( $url_parms, array( 'form_id' ) ); ?>
 114  
 115          <p class="search-box">
 116              <input type="text" name="s" class="search-input" value="<?php if ( isset( $url_parms['s'] ) ) echo esc_attr( $url_parms['s'] ); ?>" />
 117              <input type="submit" class="button" value="<?php _e( 'Search', 'MailPress' ); ?>" />
 118          </p>
 119  
 120      </form>
 121      <br class="clear" />
 122      <div id="col-container">
 123          <div id="col-right">
 124              <div class="col-wrap">    
 125                  <form id="posts-filter" method="get">
 126  
 127                      <input type="hidden" name="page" value="<?php echo MailPress_page_forms; ?>" />
 128                      <input type="hidden" name="file" value="fields" />
 129  <?php MP_AdminPage::post_url_parms( $url_parms, array( 's', 'id', 'form_id' ) ); ?>
 130  
 131                      <div class="tablenav top">
 132  <?php MP_AdminPage::pagination( $total ); ?>
 133                          <div class="alignleft actions bulkactions">
 134  <?php    MP_AdminPage::get_bulk_actions( $bulk_actions ); ?>
 135                          </div>
 136                          <br class="clear" />
 137                      </div>
 138                      <div class="clear"></div>
 139                      <table class="wp-list-table widefat fixed striped zyxw">
 140                          <thead>
 141                              <tr>
 142  <?php MP_AdminPage::columns_list(); ?>
 143                              </tr>
 144                          </thead>
 145                          <tbody id="<?php echo MP_AdminPage::list_id; ?>" class="list:<?php echo MP_AdminPage::tr_prefix_id; ?>">
 146  <?php if ( $items ) : ?>
 147  <?php foreach ( $items as $item ) { echo MP_AdminPage::get_row( $item->id, $url_parms ); } ?>
 148  <?php endif; ?>
 149                          </tbody>
 150                          <tfoot>
 151                              <tr>
 152  <?php MP_AdminPage::columns_list( false ); ?>
 153                              </tr>
 154                          </tfoot>
 155                      </table>
 156                      <div class="tablenav bottom">
 157  <?php MP_AdminPage::pagination( $total, 'bottom' ); ?>
 158                          <div class="alignleft actions bulkactions">
 159  <?php    MP_AdminPage::get_bulk_actions( $bulk_actions, 'action2' ); ?>
 160                          </div>
 161                          <br class="clear" />
 162                      </div>
 163                      <br class="clear" />
 164                  </form>
 165              </div>
 166          </div><!-- /col-right -->
 167          <div id="col-left">
 168              <div class="col-wrap">
 169                  <div class="form-wrap">
 170                      <h3><?php echo esc_html( $h3 ); ?></h3>
 171                      <div id="ajax-response"></div>
 172                      <form name="<?php echo $action; ?>" id="<?php echo $action; ?>" method="post" class="<?php echo $action; ?>:<?php echo MP_AdminPage::list_id; ?>: validate">
 173  
 174                          <input type="hidden" name="action" value="<?php echo $action; ?>" />
 175  <?php MP_AdminPage::post_url_parms( $url_parms, array( 'id', 'form_id' ) ); ?>
 176                          <?php wp_nonce_field( 'update-' . MP_AdminPage::tr_prefix_id ); ?>
 177  
 178                          <div class="form-field form-required nopm">
 179                              <label for="field_label"><?php _e( 'Label', 'MailPress' ); ?></label>
 180                              <input type="text" name="label" id="field_label" size="40" aria-required="true" value="<?php if ( isset( $field->label ) ) echo esc_attr( $field->label ); ?>" />
 181                              <p>&#160;</p>
 182                          </div>
 183                          <div class="form-field nopm">
 184                              <span class="fr">
 185                                  <span class="description"><small><?php _e( 'order in form', 'MailPress' ); ?></small></span>
 186                                  <select name="ordre" id="field_ordre">
 187  <?php MP_AdminPage::select_number( 1, 100, ( isset( $field->ordre ) ) ? $field->ordre : 1 ); ?>
 188                                  </select>
 189                                  <span class="description"><small><?php _e( 'sub template', 'MailPress' ); ?></small></span>
 190                                  <select name="template" id="field_template">
 191  <?php MP_AdminPage::select_option( $xform_subtemplates, ( isset( $field->template ) ) ? $field->template : ( ( isset( $xform_subtemplates[$field->type] ) ) ? $field->type : 'standard' ) ); ?>
 192                                  </select>
 193                              </span>
 194                              <label for="field_description" class="di"><?php _e( 'Description', 'MailPress' ); ?></label>
 195                              <input type="text" name="description" id="field_description" size="40" value="<?php if ( isset( $field->description ) ) echo esc_attr( $field->description ); ?>" />
 196                              <p><small><?php _e( 'The description can be use to give further explanations', 'MailPress' ); ?></small></p>
 197                          </div>
 198                          <div>
 199                              <label><?php _e( 'Type', 'MailPress' ) ?></label>
 200                              <table class="bkgndc bd1sc fttab">
 201  <?php
 202  $col = 2;
 203  $td = 0;
 204  $tr = false;
 205  foreach ( $field_types as $key => $field_type )
 206  {
 207      if ( intval ( $td/$col ) == $td/$col ) echo "\t\t\t\t\t\t\t\t<tr>\n";
 208  ?>
 209                                      <td>
 210                                          <input type="radio" value="<?php echo $key; ?>" name="_type" id="field_type_<?php echo $key; ?>" class="field_type"<?php checked( $key, $field->type ); ?><?php if ( ( !empty( $disabled ) ) && ( $key != $field->type ) ) echo ' disabled="disabled"'; ?> />
 211                                      </td>
 212                                      <td>
 213                                          <label for="field_type_<?php echo $key; ?>" class="field_type_<?php echo $key; ?>"><?php echo $field_type['desc']; ?></label>
 214                                      </td>
 215  <?php
 216      $td++;
 217      if ( intval ( $td/$col ) == $td/$col ) echo "\t\t\t\t\t\t\t\t</tr>\n";
 218  }
 219  if ( intval ( $td/$col ) != $td/$col ) while ( intval ( $td/$col ) != $td/$col ) {echo "\t\t\t\t\t\t\t\t\t" . '<td colspan="2"></td>' . "\n"; ++$td; $tr = true;}
 220  if ( $tr ) echo "\t\t\t\t\t\t\t\t</tr>\n";
 221  ?>
 222                              </table>
 223                          </div>
 224                          <div id="form_fields_specs">
 225  <?php foreach ( $field_types as $key => $field_type ) { MP_Form_field_types::settings_form( $key, $field ); } ?>
 226                          </div>
 227                          <p class="submit">
 228                              <input type="submit" name="submit" id="form_submit" class="button<?php echo $hbclass; ?>" value="<?php echo $hb3; ?>" />
 229                              <?php echo $cancel; ?>
 230                          </p>
 231                      </form>
 232                  </div>
 233              </div>
 234          </div><!-- /col-left -->
 235      </div><!-- /col-container -->
 236  </div><!-- /wrap -->


Generated: Mon Mar 11 18:33:33 2019 Cross-referenced by PHPXref 0.7.1