[ Index ]

MailPress 544

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

title

Body

[close]

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

   1  <?php
   2  
   3  // Form templates
   4  
   5  $form_templates = new MP_Form_templates();
   6  $templates = $form_templates->get_all();
   7  
   8  if (isset($_GET['template']))    $template = $_GET['template'];
   9  if (!isset($template) )        $template = reset($templates);
  10  
  11  $root  = MP_CONTENT_DIR . 'advanced/forms';
  12  $root  = apply_filters('MailPress_advanced_forms_root', $root);
  13  $root .= '/templates';
  14  $template_file = "$root/$template.xml";
  15  
  16  if ( ! is_file($template_file) ) wp_die(sprintf('<p>%s</p>', __('No such file exists! Double check the name and try again.')));
  17  
  18  $content = file_get_contents( $template_file );
  19  $content = htmlspecialchars( $content );
  20  $codepress_lang = 'html';
  21  
  22  // messages
  23  $messages[1] = __('File edited successfully.', MP_TXTDOM);
  24  $messages[2] = __('Could not save to file.',   MP_TXTDOM);
  25  $messages[3] = __('Could not save to file, xml errors',   MP_TXTDOM);
  26  if (isset($_GET['message'])) $message = $messages[$_GET['message']];
  27  
  28  // file status
  29  
  30  $file_status = is_writeable($template_file);
  31  
  32  ?>
  33  <div class='wrap'>
  34      <div id='icon-mailpress-tools' class='icon32'><br /></div>
  35      <h1><?php _e('Edit Form templates', MP_TXTDOM); ?></h1>
  36  <?php if (isset($message)) MP_AdminPage::message($message); ?>
  37      <br class='clear' />
  38      <div class='fileedit-sub'>
  39          <div class='alignleft'>
  40              <big>
  41  <?php echo ($file_status) ? sprintf(__('Editing <strong>%s</strong>', MP_TXTDOM), $template) : sprintf(__('Browsing <strong>%s</strong>', MP_TXTDOM), $template);     ?>
  42              </big>
  43          </div>
  44          <div class='alignright'>
  45              <form action='' method='post'>
  46                  <strong>
  47                      <label for='plugin'>
  48                          <?php _e('Select template to edit:', MP_TXTDOM); ?> 
  49                      </label>
  50                  </strong>
  51                  <input type='hidden' name='action' value='toedit' />
  52                  <select name='template' id='plugin'>
  53  <?php MP_AdminPage::select_option($templates, $template ); ?>
  54                  </select>
  55                  <input type='submit' name='Submit' value='<?php esc_attr_e('Select') ?>' class='button' />
  56              </form>
  57          </div>
  58          <br class="clear" />
  59      </div>
  60      <form name='Template' id='Template' action='' method='post'>
  61          <?php wp_nonce_field('edit-mp-template_' . $template) ?>
  62          <input type='hidden' name='action' value='update' />
  63          <input type='hidden' name='template' value='<?php echo $template; ?>' />
  64  
  65  <div style="border:1px solid #c0c0c0;padding:0px;">
  66              <textarea cols='100' rows='30' name='newcontent' id='newcontent' tabindex='1' ><?php echo $content ?></textarea>
  67  </div>
  68  <?php if ($file_status) : ?>
  69          <p class='submit'><input type='submit' name='submit' id='submit_xml' class='button-primary' value="<?php echo esc_attr(__('Update File')); ?>" tabindex='2' /></p>
  70  <?php else : ?>
  71          <p><em><?php _e('You need to make this file writable before you can save your changes. See <a href="http://codex.wordpress.org/Changing_File_Permissions">the Codex</a> for more information.'); ?></em></p>
  72  <?php endif; ?>
  73      </form>
  74  <br class="clear" />
  75  </div>


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1