[ Index ]

MailPress 544

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

title

Body

[close]

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

   1  <?php
   2  class MP_AdminPage extends MP_adminpage_
   3  {
   4      const screen         = 'mailpress_page_templates';
   5      const capability     = 'MailPress_manage_forms';
   6      const help_url        = 'http://blog.mailpress.org/tutorials/add-ons/form/';
   7      const file            = __FILE__;
   8  
   9  ////  Redirect  ////
  10  
  11  	public static function redirect() 
  12      {
  13          if ( isset($_POST['action']) )    $action = $_POST['action'];
  14          elseif ( isset($_GET['action']) ) $action = $_GET['action'];
  15          if (!isset($action)) return;
  16  
  17          switch($action) 
  18          {
  19              case 'update' :
  20                  $template = $_POST['template'];
  21  
  22                  $root  = MP_CONTENT_DIR . 'advanced/forms';
  23                  $root  = apply_filters('MailPress_advanced_forms_root', $root);
  24                  $root .= '/templates';
  25                  $template_file = "$root/$template.xml";
  26  
  27                  $args['action']  = 'edit';
  28                  $args['template']= $template;
  29                  $args['message'] = 2;
  30  
  31                  $xml = stripslashes($_POST['newcontent']);
  32  
  33                  if (!simplexml_load_string($xml))                 $args['message'] = 3;
  34                  else if (file_put_contents($template_file, $xml))     $args['message'] = 1;
  35                  self::mp_redirect(self::url(MailPress_templates, $args));
  36              break;
  37              case 'toedit' :
  38                  $template = $_POST['template'];
  39                  $args['action']  = 'edit';
  40                  $args['template']= $template;
  41                  self::mp_redirect(self::url(MailPress_templates, $args));
  42              break;
  43          }
  44      }
  45  
  46  ////  Title  ////
  47  
  48  	public static function title() { global $title; $title = __('MailPress Forms Templates', MP_TXTDOM); }
  49  
  50  ////  Styles  ////
  51  
  52  	public static function print_styles($styles = array()) 
  53      {
  54          wp_register_style ( self::screen,        '/' . MP_PATH . 'mp-admin/css/form_templates.css' );
  55          $styles[] = self::screen;
  56  
  57          parent::print_styles($styles);
  58      }
  59  
  60  //// Scripts ////
  61  
  62  	public static function print_scripts($scripts, $footer) 
  63      {
  64          if ($footer)
  65          {
  66  ?>
  67  <script type='text/javascript'>
  68  var cm_editor;
  69  jQuery(document).ready(function(){
  70      cm_editor = CodeMirror.fromTextArea(
  71          'newcontent', 
  72          {
  73              height    : '450px',
  74              parserfile    : ['parsexml.js'],
  75              stylesheet    : ['<?php echo site_url() . '/' . MP_PATH; ?>mp-includes/js/codemirror/css/xmlcolors.css'],
  76              path        :  '<?php echo site_url() . '/' . MP_PATH; ?>mp-includes/js/codemirror/js/',
  77              continuousScanning: 500,
  78              lineNumbers    : true,
  79              textWrapping: false
  80          }
  81      );
  82  });
  83  </script>
  84  <?php
  85          }
  86          wp_register_script( 'mp-codemirror','/' . MP_PATH . 'mp-includes/js/codemirror/js/codemirror.js', false, false, 1);
  87  
  88          wp_register_script( self::screen,    '/' . MP_PATH . 'mp-admin/js/form_templates.js', array('mp-codemirror'), false, 1);
  89  
  90          $scripts[] = self::screen;
  91          parent::print_scripts($scripts);
  92      }
  93  }


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