Exemple #1
0
  public function init() {
    
    $action = MasterPress::$action;
    
    // inform the view what to render in the info panel
    MasterPress::$view->is_role_set = true;

    if ($action == "edit-field" || $action == "create-field") {
      // inform the view what to render in the info panel
      MasterPress::$view->parent = MPM_FieldSet::find_by_id(MasterPress::$parent);

      // enqueue the field type CSS
      $type = MasterPress::$model->type;
      
      MPFT::options_admin_head($type);

      // enqueue dependent scripts for all field types (could improve this in the future)
      foreach (MPFT::type_keys() as $type) {
        if ($ftc = MPFT::type_class($type)) {
          call_user_func( array($ftc, "enqueue") );
        }
      }


    }

    if ($action == "create-field") {
      MasterPress::$model->field_set_id = MasterPress::$parent;
      MasterPress::$model->infer_position();
    }

  }
Exemple #2
0
  public function dispatch() {
    
    $type = str_replace("_", "-", $_REQUEST["type"]);
    $method = $_REQUEST["type_method"];

    if ($ftc = MPFT::type_class($type)) {

      if (method_exists($ftc, $method)) {
        return call_user_func( array($ftc, $method) );
      } else {
        self::ajax_error( sprintf(__("The method '%s' could not be called in the PHP Field Type Class '%s'. Please check that the method exists.", MASTERPRESS_DOMAIN), $method, $ftc) );
      }
      
    } else {
      self::ajax_error( sprintf(__("AJAX method '%s' could not be called as the PHP Field Type Class '%s' could not be found for type key '%s'. Please check that everything is setup correctly in this field type.", MASTERPRESS_DOMAIN), $ftc, $type));
    }
  
  }
  function __construct($name, $object, $info) {
   
    $this->name = $name; // a full name (set.field)
    $this->set_index = 0;
    $this->object = $object;
    $this->info = $info;
    
    if ($this->exists()) {

      if ($type_class = MPFT::type_class($this->info->type)) {
        // instantiate the delegate
        $this->type_delegate = new $type_class($this->info, $this);
      } else {
        $this->type_delegate = new MPFT($this->info, $this);
      }
    
    }
    
  }
  public function grid() {

    MPC::incl("post-types");
    MPV::incl("fields");
    MPV::incl("post-types");
    
    $info = MasterPress::$view;
    
    ?>
    
    
    <?php MPV::messages(); ?>


    <div class="grid-set">
    
    <?php $field_sets = MPM_SharedFieldSet::find( array("orderby" => "name ASC" ) ); ?>

    <?php MPV::field_set_icon_styles($field_sets); ?>

    <?php
    
    $has_actions = MasterPress::current_user_can("edit_shared_field_sets,delete_shared_field_sets,edit_shared_fields,delete_shared_fields");

    $can_edit = MasterPress::current_user_can("edit_shared_field_sets");
    $can_delete = MasterPress::current_user_can("delete_shared_field_sets");
    $can_create = MasterPress::current_user_can("create_shared_field_sets");

    $can_edit_fields = MasterPress::current_user_can("edit_shared_fields");
    $can_delete_fields = MasterPress::current_user_can("delete_shared_fields");
    $can_create_fields = MasterPress::current_user_can("create_shared_fields");

    $less = ($can_create_fields) ? 1 : 0;

    $colspan = ( $has_actions ? 7 : 6 ) - $less;
    
    foreach ($field_sets as $field_set) {

      if (MPC::is_deleting($field_set->id, "delete")) {
        
        $this->confirm_delete($field_set);
        
      } else {
        
        foreach ($field_set->fields() as $field) {
          
          if (MPC::is_deleting($field->id, "delete-field")) {
            $this->confirm_delete_field($field);
          }
          
        }
        
      }
      
    }
    
    ?>
    
    <?php if (count($field_sets)) : ?>
    
    <table cellspacing="0" class="grid grid-field-sets grid-shared-field-sets">

    <thead>
    <tr>
      <th class="first type"><i class="types"></i><span><?php _e("Type", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="label"><i class="label-string"></i><span><?php _e("Label", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="front-end-name"><i class="script-php"></i><span><?php _e("Front End Name", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="post-types"><i class="pins"></i><span><?php _e("Post Types", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="taxonomies"><i class="tags"></i><span><?php _e("Taxonomies", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="roles <?php echo $has_actions ? "" : "last" ?>"><i class="user-role"></i><span><?php _e("User Roles", MASTERPRESS_DOMAIN) ?></span></th>
      <?php if ($has_actions) : ?>
      <th class="actions last"><i class="buttons"></i><span><?php _e("Actions", MASTERPRESS_DOMAIN) ?></span></th>
      <?php endif; ?>
    </tr>
    </thead>
   
    <tbody>
    

    <?php $fg_count = 0; ?>
    <?php foreach ($field_sets as $field_set) : $fg_count++; ?>  
      
    <?php $display = $field_set->display_label(); ?>
    
    <?php
      
      $display_td = $display;
      
      if ($field_set->icon != "") {
        $display_td = WOOF_HTML::tag("span", array("class" => "with-icon field-set-".$field_set->id), $display);
      }
    
    ?>
    
    <?php 

      $deleting_class = MPC::is_deleting($field_set->id, "delete") ? 'deleting' : ''; 
      $editable_class = $can_edit ? " editable " : "";
      $meta = $can_edit ? "{ href: '".MasterPress::admin_url("shared-field-sets", "edit", array("id" => $field_set->id) )."' }" : "";

    ?>

    <?php $disabled = $field_set->disabled ? "disabled" : ""; $title = $field_set->disabled ? ' title="'.__("this field set is disabled", MASTERPRESS_DOMAIN).'" ' : ""; ?>

    <?php
    
    if (!$field_set->in_current_site()) {
      $disabled = "disabled";
      $title = ' title="'.__("field set is not currently available in this site (multi-site setting)", MASTERPRESS_DOMAIN).'" ';
    }
    
    ?>

        
    <tr id="field_set_<?php echo $field_set->name ?>" <?php echo $title ?> class="<?php echo $disabled ?> <?php echo $editable_class ?> <?php echo $deleting_class ?> <?php echo MPV::updated_class("edit,create", $field_set->id) ?> <?php echo $meta ?>">
      <?php if ($field_set->allow_multiple) : ?>
      <th class="first type icon"><i class="metabox-add-remove-large" title="<?php _e("Field Set (Multiple Items)", MASTERPRESS_DOMAIN) ?>"></i></th>
      <?php else : ?>
      <th class="first type icon"><i class="metabox-large" title="<?php _e("Field Set", MASTERPRESS_DOMAIN) ?>"></i></th>
      <?php endif; ?>
      <th class="label"><strong><?php echo $display_td ?></strong></th>
      <th class="front-end-name"><span class="tt"><?php echo $field_set->display_name() ?></span></th>
      <th class="post-types">
        
        <?php 
        
        $post_types = $field_set->post_types(); 

        $vis = $field_set->visibility;
        
        $vis_post_types = "";

        if (isset($vis["post_types"])) {
          $vis_post_types = $vis["post_types"];
        }
        
        if ($vis_post_types == "*") {
          $post_type_display = __("( All )", MASTERPRESS_DOMAIN);
          
        } else {

          $post_type_display = __("( None )", MASTERPRESS_DOMAIN);

          if (count($post_types)) {
            $post_type_links = array();

            foreach ($post_types as $post_type) {
              $post_type_links[] = $post_type->labels["name"];
            }

            $post_type_display = implode($post_type_links, ", ");
          }
        }
        
        echo $post_type_display;
        ?>
        
        
        
      </th>

      <th class="taxonomies">
        
        <?php 
        
        $vis = $field_set->visibility;
        
        
        $vis_tax = "";
        
        if (isset($vis["taxonomies"])) {
          $vis_tax = $vis["taxonomies"];
        }
        
        if ($vis_tax == "*") {
          $taxonomy_display = __("( All )", MASTERPRESS_DOMAIN);
          
        } else {
        
          $taxonomy_display = __("( None )", MASTERPRESS_DOMAIN);
          
          if ($vis_tax != "") {
            
            $tax_models = MPM_Taxonomy::find_by_name_in(explode(",", $vis_tax));
            
            $td = array();
            
            foreach ($tax_models as $tax) {
              $td[] = $tax->display_label();
            }
            
            $taxonomy_display = implode(", ", $td);
          }
        
        }
        
        echo $taxonomy_display;
        ?>
        
      </th>

      <th class="roles <?php echo $has_actions ? "" : "last" ?>">
        
        <?php 
        
        $vis = $field_set->visibility;
        
        $vis_roles = "";
        
        if (isset($vis["roles"])) {
          $vis_roles = $vis["roles"];
        }
        
        if ($vis_roles == "*") {
          $role_display = __("( All )", MASTERPRESS_DOMAIN);
          
        } else {
          
          if (is_null($vis_roles) || $vis_roles == "") {
            $role_display = __("( None )", MASTERPRESS_DOMAIN);
          } else {
            $role_display = implode(", ", explode(",", $vis_roles));
          }
        
        }
        
        echo $role_display;
        ?>
        
      </th>

      <?php if ($has_actions) : ?>
            
      <th class="actions last">
      <?php if (MPC::is_deleting($field_set->id, "delete")) : ?>
        <span class="confirm-action">&nbsp;</span>
      <?php else: ?>
      <div>
        <?php if ($can_edit) : ?>
          <?php echo MPV::action_button("shared-field-sets", "edit", self::__edit(), array("id" => $field_set->id), array("class" => "button button-edit") ); ?>
        <?php endif; ?>
        
        <?php if ($can_delete) : ?>
          <?php echo MPV::action_button("shared-field-sets", "delete", self::__delete(), array("id" => $field_set->id), array("class" => "button button-delete") ); ?>
        <?php endif; ?>
      </div>
      <?php endif; ?>
      </th>

      <?php endif; // has_actions ?>

    </tr>  
    
    
    <?php 
    
    $count = 0; 
    $fields = $field_set->fields();
    
    ?>
    
    <?php foreach ($fields as $field) : $count++; $first = $count == 1 ? 'first' : ''; $disabled = $field_set->disabled || $field->disabled ? "disabled" : ""; $title = $field_set->disabled || $field->disabled ? ' title="'.__("this field is disabled", MASTERPRESS_DOMAIN).'" ' : ""; ?>

    <?php
    if (!$field_set->in_current_site() || !$field->in_current_site()) {
      $disabled = "disabled";
      $title = ' title="'.__("field is not currently available in this site (multi-site setting)", MASTERPRESS_DOMAIN).'" ';
    }
    ?>
        
    <?php 
    
    $deleting_class = MPC::is_deleting($field_set->id, "delete") || MPC::is_deleting($field->id, "delete-field") ? 'deleting' : ''; 
    $editable_class = $can_edit_fields ? " editable " : "";
    $meta = $can_edit ? "{ href: '".MasterPress::admin_url("shared-field-sets", "edit-field", array("id" => $field->id, "parent" => $field_set->id) )."' }" : "";

    
    ?>
  
    <?php if ($type_class = MPFT::type_class($field->type)) : ?>

    <tr <?php echo $title ?> class="sub <?php echo $editable_class.$deleting_class ?> <?php echo $first ?> <?php echo $disabled ?> <?php echo $count % 2 == 0 ? "even" : "" ?> <?php echo MPV::updated_class("edit-field,create-field", $field->id) ?> <?php echo $meta ?>">
      <td class="type icon first" title="<?php echo call_user_func( array($type_class, "__s") ) ?>"><span class="mp-icon mp-icon-field-type-<?php echo $field->type ?>"></span></td>
      <td class="label"><strong><?php echo $field->display_label() ?></strong></td>
      <td class="front-end-name"><span class="tt"><span class="arrow">-&gt;&nbsp;</span><?php echo $field->display_name() ?></span></td>
      <td class="post-types">
        
        <?php 
        
        $vis = $field->visibility;
        
        $vis_post_types = "";

        if (isset($vis["post_types"])) {
          $vis_post_types = $vis["post_types"];
        }
        
        if ($vis_post_types == "*") {

          $post_type_display = '<span class="inherit">( '.__("same as set", MASTERPRESS_DOMAIN).' )</span>';

        } else {

          $post_types = $field->post_types(); 
          
          $post_type_display = MPV::note_none();
        
          if (count($post_types)) {
            $post_type_links = array();
          
            foreach ($post_types as $post_type) {
              $post_type_links[] = $post_type->labels["name"];
            }

            $post_type_display = implode($post_type_links, ", ");
          }
        
        }
        
        echo $post_type_display;
          
        ?>
        
      </td>

      <td class="taxonomies">
        
        <?php 
        
        $vis = $field->visibility;

        $vis_tax = "";
        
        if (isset($vis["taxonomies"])) {
          $vis_tax = $vis["taxonomies"];
        }
        
        if ($vis_tax == "*") {

          $tax_display = '<span class="inherit">( '.__("same as set", MASTERPRESS_DOMAIN).' )</span>';

        } else {

          $tax_display = MPV::note_none();
        
          if ($vis_tax != "") {
            
            $tax_models = MPM_Taxonomy::find_by_name_in(explode(",", $vis_taxonomies));
            
            $td = array();
            
            foreach ($tax_models as $tax) {
              $td[] = $tax->display_label();
            }
            
            $tax_display = implode(", ", $td);
          }
        
        }
        
        echo $tax_display;
          
        ?>
        
      </td>
      
      <td class="roles <?php echo $has_actions ? "" : "last" ?>">
        
        <?php 
        
        $vis = $field->visibility;
        
        $vis_roles = "";
        
        if (isset($vis["roles"])) {
          $vis_roles = $vis["roles"];
        }
        
        if ($vis_roles == "*") {

          $role_display = '<span class="inherit">( '.__("same as set", MASTERPRESS_DOMAIN).' )</span>';

        } else {

          $role_display = MPV::note_none();
        
          if ($vis_roles != "") {
            $role_display = implode(", ", explode(",", $vis_roles));
          }
        
        }
        
        echo $role_display;
          
        ?>
        
      </td>

      <?php if ($has_actions) : ?>

      <td class="actions last">
      <?php if (MPC::is_deleting($field->id, "delete-field")) : ?>
        <span class="confirm-action">&nbsp;</span>
      <?php else: ?>
      <div>
        <?php if ($can_edit_fields) : ?>
          <?php echo MPV::action_button("shared-field-sets", "edit-field", self::__edit(), array("id" => $field->id, "parent" => $field_set->id), array("class" => "button button-edit") ); ?>
        <?php endif; ?>

        <?php if ($can_delete_fields) : ?>
          <?php echo MPV::action_button("shared-field-sets", "delete-field", self::__delete(), array("id" => $field->id, "parent" => $field_set->id), array("class" => "button button-delete") ); ?>
        <?php endif; ?>
        
      </div>
      <?php endif; ?>
      
      </td>
      <?php endif; // has_actions ?>
    </tr>
    
    <?php endif; ?>
      
    <?php endforeach; ?>
  
    <tr class="summary <?php echo $can_create_fields ? "editable" : "" ?>">
      <?php if (count($fields)) : ?>
      <td colspan="<?php echo $colspan ?>" class="first <?php echo $can_create_fields ? "" : "last" ?>"><?php printf( __( "%s contains %s", MASTERPRESS_DOMAIN ), $display, MPU::__items( $field_set->field_count(), __("%d custom field", MASTERPRESS_DOMAIN), __("%d custom fields", MASTERPRESS_DOMAIN) ) ) ?></td>
      <?php else: ?>
      <?php if ($can_create_fields) : ?>
      <td colspan="<?php echo $colspan ?>" class="hl first last"><span><?php printf( __( "<strong>%s</strong> is not yet active as it contains <em>no custom fields</em>. Click here to create one", MASTERPRESS_DOMAIN ), $display ); ?></span></td>
      <?php endif; ?>
      <?php endif; ?>

      <?php if ($can_create_fields) : ?>
      <td class="last actions <?php echo count($fields) ? "" : "hl" ?>">
      <?php echo MPV::action_button("shared-field-sets", "create-field", self::__create(MPV_Fields::__s()), array("parent" => $field_set->id), array("class" => "button create-field")  ); ?>
      </td>
      <?php endif; ?>
    </tr>
    <tr class="gap <?php if ($fg_count == count($field_sets)) { echo "gap-last"; } ?>">
    <td colspan="7">&nbsp;</td>  
    </tr>
    
  
    <?php endforeach; ?>

    </tbody>
  
    </table>

    <?php if ($can_create) : ?>
    <div class="grid-foot-controls">
    <?php echo MPV::action_button("shared-field-sets", "create", MPV::__create( MPV_SharedFieldSets::__s() ), array() ); ?>
    </div>
    <?php endif; ?>
    
    <?php else: ?>
  
    <?php if ($can_create) : ?>
    <a href="<?php echo MasterPress::admin_url("shared-field-sets", "create") ?>" class="no-items-create">
	<i class="plus-circle"></i>
    <span><?php _e( "There are currently no Shared Field Sets. Click here to create one." ) ?></span>
    </a>
    <?php endif; ?>
  
    <?php endif; ?>

    
    </div>
  
  
    <?php

  } // end grid()
Exemple #5
0
  public function prop($name = null, $value = null) {
    
    if (is_null($name)) {
      return $this->data->prop;
    }
    
    if ($this->type_delegate) {

      if (!is_null($value)) {
        
        if (method_exists($this->type_delegate, "set_prop")) {
          $this->type_delegate->set_prop($name, $value);
          
        } else {
          $this->data->prop[$name] = $value;

          if ($type_class = MPFT::type_class($this->info->type)) {
            // re-instantiate the delegate
            $this->type_delegate = new $type_class($this->info, $this);
          } else {
            $this->type_delegate = new MPFT($this->info, $this);
          }
          

        }

        $this->mark_dirty();

        return $this->data->prop[$name];
        
      } else {
      
        if (method_exists($this->type_delegate, "get_prop")) {
          return $this->type_delegate->get_prop($name);
        }
        
        if (isset($this->data->prop[$name])) {
          return $this->data->prop[$name];
        }
      
      }

    } 
    
    if (!is_null($value)) {
      $this->data->prop[$name] = $value;
    }
    
    if (isset($this->data->prop[$name])) {
      return $this->data->prop[$name];
    }
    
    return null;
  }
  function update() {
    
    if ($this->dirty && $this->exists()) {
      
      $this->dirty = false; // do this now in case of any SQL errors
      $this->updated = true;
      
      global $wpdb;
      global $wf, $meow_provider;
  
      $value_type = null;
      
      $object_type = $meow_provider->type_key($this->object);
   
      $object_id = $this->object->id();
      
      if ($object_type == "term") {
        $tax = $this->object->taxonomy->name();
        
        if ($tax && !is_woof_silent($tax)) {
          $value_type = $tax;
        }
      }

      /* Delete the old post meta */
  
			$this->object->switch_site();
			
      $set_name = $this->name;
  
      foreach ( $this->info->fields as $field) {
        
        if (!$field->disabled && $field->in_current_site()) {
         
          $meta_name = $set_name.".".$field->name;

          MPC_Meta::delete_object_meta($object_type, $object_id, $meta_name);
  
          // now go through the properties too

          $dont_care = MPFT::type_class($field->type);
    
          foreach (MPFT::type_properties($field->type) as $prop) {
            MPC_Meta::delete_object_meta($object_type, $object_id, $meta_name.":".$prop);
          }
        
        }
      
      }
  
      $model_id_prop_stored = array();
  
    
      // Create the new values
    
      foreach( $this->_items as $set_index => $set_item ) {
      
        foreach ($this->info->fields as $field) {
          
          if (!$field->disabled && $field->in_current_site()) {

            // here the field type should prepare the value, if necessary
    
            // grab the type
    
            $model_id = $field->id;
    
            $model = $field;
    
            $field_item = $this->field($field->name, $set_index);
      
            if ($field_item->exists()) {
              
              $value = $field_item->raw();
              
              $val = MPU::db_encode($value);
    
              if ($type_class = MPFT::type_class($model->type)) {
                $val = MPU::db_encode( call_user_func_array( array($type_class, "value_for_save"), array($value, $model)) );
              }
              
  
              // create the post meta
    
              $meta_name = MPFT::meta_key($set_name, $field->name);
    
              //echo "would add $object_type, $object_id, $meta_name, $val<br>";

              
              if (! (!$this->info->allow_multiple && $val == "") ) {
                // don't record blank entries for non-multiple field sets, as this is wasteful
              
                MPC_Meta::add_object_meta($object_type, $object_id, "{$meta_name}", $val, $value_type);

                // now store the properties
    
                foreach (MPFT::type_properties($model->type) as $prop) {

                  if ($prop == "field_id" && !isset($model_id_prop_stored[$model_id])) {
                    $model_id_prop_stored[$model_id] = true;
          
                    MPC_Meta::add_object_meta($object_type, $object_id, "{$meta_name}:{$prop}", $model_id, $value_type);
        
                  } else {

                    $prop_value = $field_item->prop_val($prop);
        
                    if (!isset($prop_value)) {
                      $prop_value = "";
                    }
                    
                    if ($prop != "field_id") {
                      MPC_Meta::add_object_meta($object_type, $object_id, "{$meta_name}:{$prop}", $prop_value, $value_type);
                    }
                  
                  } // $prop = field_id

                } // foreach MPFT::type_properties
            
              } // if (!allow_multiple)
            
            } // if (field_item->exists)
          
          } // if (!field->disabled)
        
    
        } // endforeach $fields
    
    
      } // endforeach ($this->items)

      $this->object->restore_site();

    } // if ($dirty)
    
    
  }
Exemple #7
0
  public function options() {
    
    // construct the HTML for the options UI
    
    $id = "";
    $type = "";
    
    if (isset($_REQUEST["type"])) {
      $type = $_REQUEST["type"];
    }
  
    if (isset($_GET["id"])) {
      $id = $_GET["id"];
    }
  
    // if the id is present, load a model
    
    if ($id && $id != "") {
      MPM::incl("field");
      $model = MPM_Field::find_by_id($id);
    }
      
    if ($type != "") {

      if ($type_class = MPFT::type_class($type)) {
        $type_options = array();
        
        if (isset($model) && isset($model->type_options)) {
          $type_options = $model->type_options;
        }
        
        $form = call_user_func_array( array($type_class, "options_form"), array(MPM::array_stripslashes($type_options)) );
      }
      
      $css_url = "";
      
      $css_file = MPU::type_file_path($type, "mpft-$type.options.css");

      if (file_exists($css_file)) {
        $css_url = MPU::type_file_url($type, "mpft-$type.options.css")."?".filemtime($css_file);
      }
      
      $js_file = MPU::type_file_path($type, "mpft-$type.options.js");

      if (file_exists($js_file)) {
        $js_url = MPU::type_file_url($type, "mpft-$type.options.js")."?".filemtime($js_file);
      }
    
      $ret = array( "form" => $form, "css_file" => $css_url, "type" => $type );
      
      if (isset($js_url)) {
        $ret["js_file"] = $js_url;
      }

      self::ajax_success( $ret );
      
    } else {
      self::ajax_error( __("field type options could not be loaded", MASTERPRESS_DOMAIN) );
    }
    
  }
Exemple #8
0
  public static function type_properties($type) {

    if (!$type) {
      return false;
    }
    
    if (!isset(self::$type_properties[$type])) {
      
      $prop_keys = array("field_id");
      
      if ($type_class = MPFT::type_class($type)) {
        
        $ui_prop = call_user_func( array($type_class, "ui_prop") );
        
        if (!is_array($ui_prop)) {
          $ui_prop = explode(",", $ui_prop);
        }
        
        $prop_keys = wp_parse_args( $ui_prop, $prop_keys);
      }

      self::$type_properties[$type] = $prop_keys;
      
    }
      
    return self::$type_properties[$type];
    
  }
Exemple #9
0
  function manage() {
    
    global $wf;
    
    ?>

    <?php MPV::messages() ?>
  
    <?php

    MPV::incl("post-types");
    MPV::incl("shared-field-sets");
    MPV::incl("templates");
    MPV::incl("taxonomies");
    MPV::incl("roles");
  
    $disabled = "";
  
    $view = MasterPress::$view;
    
    $post_types = MPM_PostType::find("orderby=disabled,name ASC");
    $taxonomies = MPM_Taxonomy::find("orderby=disabled,name ASC");
    $shared_field_sets = MPM_SharedFieldSet::find("orderby=disabled,name ASC");
    $templates = get_page_templates();
    $site_field_sets = MPM_SiteFieldSet::find("orderby=disabled,name ASC"); 
    $roles = $wf->roles(); 

    ?>

    <div class="fs fs-masterplan fs-with-tabs">
    
        
      <div class="fsc">
      <div class="fscb">
        
        <?php
            $tab = "";
            
            if (isset($_REQUEST["tab"])) {
              $tab = $_REQUEST["tab"];
            }
          ?>

          <?php 
            
            // check for restoreable backups

            
            $backups = array();
            
            if (file_exists(MASTERPRESS_CONTENT_MASTERPLANS_DIR)) {

            $iterator = new DirectoryIterator(MASTERPRESS_CONTENT_MASTERPLANS_DIR);
            
            foreach ($iterator as $file) {

              $file_name = $file->getFileName();
    
              if (substr($file_name, 0, 1) == ".") {
                continue;
              }
              
              if (preg_match("/\_backup\.(?:(.*)\.)?([0-9]+)\.masterplan\.zip/", $file_name, $matches)) {
                
                $tag = $matches[1];
                $date = $matches[2];
                
                $fdate = $wf->date_format("[date-time-long]", strtotime($date));
                
                $label = $fdate;
                
                if ($tag != "") {
                  $label = $fdate." ( ".$tag." )";
                }
                
                $backups[] = array("file" => $file_name, "label" => $label);
                
                
              }
              
            }
            
            }
          
          ?>
          
        <ul class="fs-tabs">
          <li><a href="#masterplan-overview" class="<?php echo $tab != '' ? '' : 'current' ?>"><span><i class="info"></i>Overview</span></a></li>
          <?php if (MasterPress::current_user_can("export_masterplan")) : ?>
          <li><a href="#masterplan-export" class="<?php echo $tab == "export" ? 'current' : '' ?>"><span><i class="arrow-curve-right"></i>Export</span></a></li>
          <?php endif; ?>
          <?php if (MasterPress::current_user_can("import_masterplan")) : ?>
          <li><a href="#masterplan-import" class="<?php echo $tab == "import" ? 'current' : '' ?>"><span class="import"><i class="arrow-curve-left"></i>Import</span></a></li>
          <?php endif; ?>
          <?php if (MasterPress::current_user_can("backup_masterplan")) : ?>
          <li><a href="#masterplan-backup" class="<?php echo $tab == "backup" ? 'current' : '' ?>"><span class="backup"><i class="buoy"></i>Backup</span></a></li>
          <?php endif; ?>
          <?php if (count($backups)) : ?>
          <?php if (MasterPress::current_user_can("restore_masterplan")) : ?>
          <li><a href="#masterplan-restore" class="<?php echo $tab == "restore" ? 'current' : '' ?>"><span class="restore"><i class="clock-history"></i>Restore</span></a></li>
          <?php endif; ?>
          <?php endif; ?>
        </ul>
    
<!-- OVERVIEW -->


        <div id="masterplan-overview" class="tab-panel <?php echo $tab != '' ? '' : 'current' ?>">
          
          <?php if (isset($_GET["import-complete"])) : ?>
          
          <ul class="mp-messages">
            <li class="success"><?php _e("Import Complete - your new site Masterplan is shown below.", MASTERPRESS_DOMAIN) ?></li>
          </ul>
          
          <?php endif; ?>

          <?php if (isset($_GET["restore-complete"])) : ?>
          
          <ul class="mp-messages">
            <li class="success"><?php _e("Restore Complete - your site Masterplan is shown below.", MASTERPRESS_DOMAIN) ?></li>
          </ul>
          
          <?php endif; ?>
        
          <div class="row first-row">
          
            <div class="col post-types">
            
              <?php 
              
              $count = 0;
              
              foreach ($post_types as $post_type) { 
                if ($post_type->still_registered()) {
                  $count++;
                }
              }
              
              ?>
                
              <h4><i class="pin"></i>
              <?php if (MasterPress::current_user_can("manage_post_types")) : ?>
              <a href="<?php echo MasterPress::admin_url("post-types", "manage") ?>" title="<?php _e("Manage Post Types", MASTERPRESS_DOMAIN) ?>" class="icon">
              <?php else : ?>
              <span class="icon">
              <?php endif; ?>
              
              <?php echo WOOF::items_number( $count, __("<em>No</em> Post Types", MASTERPRESS_DOMAIN), __("<b>%d</b> Post Type", MASTERPRESS_DOMAIN), __("<b>%d</b> Post Types", MASTERPRESS_DOMAIN) ) ?>
              
              <?php if (MasterPress::current_user_can("manage_post_types")) : ?>
              </a>
              <?php else : ?>
              </span>
              <?php endif; ?>
              </h4>
            
              <div class="body">
              
                <ul class="count-<?php echo $count ?>">
                <?php foreach ($post_types as $post_type) : $default_icon = $post_type->menu_icon_exists() ? "" : "default-icon"; $field_sets = $post_type->post_type_field_sets(); $fsc = count($field_sets); $disabled = $post_type->disabled ? 'disabled ' : ''; $disabled_title = $post_type->disabled ? __('This post type is currently disabled', MASTERPRESS_DOMAIN) : ''; ?>
                  
                <?php if ($post_type->still_registered()) : ?>
                <li class="<?php echo $disabled ?>post-type-<?php echo $post_type->name ?> <?php echo $default_icon ?> linkify" data-name="<?php echo $post_type->name ?>" title="<?php echo $disabled_title ?>">
                  
                  <?php if (MasterPress::current_user_can("manage_post_types+edit_post_types")) : ?>
                  <a href="<?php echo MasterPress::admin_url("post-types", "edit", "id=".$post_type->id) ?>" class="item mp-icon-post-type mp-icon-post-type-<?php echo $post_type->name ?>">
                  <?php else: ?>
                  <div class="item mp-icon-post-type mp-icon-post-type-<?php echo $post_type->name ?>">  
                  <?php endif; ?>
                  
                  <?php echo WOOF::truncate($post_type->display_label(), "length=15&words=0") ?>

                  <?php if (MasterPress::current_user_can("manage_post_types+edit_post_types")) : ?>
                  </a>
                  <?php else: ?>
                  </div>  
                  <?php endif; ?>
                  
                  <?php if (MasterPress::current_user_can("manage_post_types+manage_post_type_field_sets")) : ?>
                  <a href="<?php echo MasterPress::admin_url("post-types", "manage-field-sets", "parent=".$post_type->id) ?>" title="<?php _e("Manage Field Sets", MASTERPRESS_DOMAIN) ?>" class="field-sets count-<?php echo $fsc ?>"><?php echo $fsc ?></a>
                  <?php else : ?>
                  <div title="<?php _e("Field Sets", MASTERPRESS_DOMAIN) ?>" class="field-sets count-<?php echo $fsc ?>"><?php echo $fsc ?></div>
                  <?php endif; ?>
                    
                  <?php foreach ($post_type->taxonomies() as $tax) : ?> 
                  <span class="tax-link-<?php echo $tax->name ?> related-link asterisk"></span>
                  <?php endforeach; ?>

                  <?php foreach ($post_type->field_sets() as $fs) : ?>
                  <?php if ($fs->is_shared()) : ?>
                  <span class="shared-field-set-link-<?php echo $fs->name ?> related-link asterisk"></span>
                  <?php endif; ?>
                  <?php endforeach; ?>


                </li>
                <?php endif; ?>

                <?php endforeach; ?>
                
                <?php if (MasterPress::current_user_can("create_post_types")) : ?>
                <li class="divide"><a href="<?php echo MasterPress::admin_url("post-types", "create") ?>" class="create-link"><i></i><?php echo MPV::__create( MPV_PostTypes::__s() ) ?></a></li>
                <?php endif; ?>

                </ul>
            
              </div>
              <!-- /.body -->
            
            </div>
            <!-- /.col -->
          
          
            <div class="col taxonomies">
            
              <?php 
              
              $count = 0;
              
              foreach ($taxonomies as $tax) { 
                if ($tax->still_registered()) {
                  $count++;
                }
              }
              
              ?>
              
              <h4><i class="tag"></i>
              <?php if (MasterPress::current_user_can("manage_taxonomies")) : ?>
              <a href="<?php echo MasterPress::admin_url("taxonomies", "manage") ?>" title="<?php _e("Manage Taxonomies", MASTERPRESS_DOMAIN) ?>" class="icon">              
              <?php else : ?>
              <span class="icon">
              <?php endif; ?>
              
              <?php echo WOOF::items_number( $count, __("<em>No</em> Taxonomies", MASTERPRESS_DOMAIN), __("<b>%d</b> Taxonomy", MASTERPRESS_DOMAIN), __("<b>%d</b> Taxonomies", MASTERPRESS_DOMAIN) ) ?>
              
              <?php if (MasterPress::current_user_can("manage_taxonomies")) : ?>
              </a>
              <?php else : ?>
              </span>
              <?php endif; ?>
              </h4>
              
              <div class="body">
              
                <ul class="count-<?php $count ?>">
                <?php foreach ($taxonomies as $tax) : $field_sets = $tax->taxonomy_field_sets(); $fsc = count($field_sets); $disabled = $tax->disabled ? 'disabled ' : ''; $disabled_title = $tax->disabled ? __('This taxonomy is currently disabled', MASTERPRESS_DOMAIN) : ''; ?>
                
                <?php if ($tax->still_registered()) : ?>

                <li class="<?php echo $disabled ?> linkify" data-name="<?php echo $tax->name ?>" title="<?php echo $disabled_title ?>">
                  
                  <?php if (MasterPress::current_user_can("manage_taxonomies+edit_taxonomies")) : ?>
                  <a href="<?php echo MasterPress::admin_url("taxonomies", "edit", "id=".$tax->id) ?>" class="item mp-icon-taxonomy mp-icon-taxonomy-<?php echo $tax->name ?>">
                  <?php else: ?>
                  <div class="item mp-icon-taxonomy mp-icon-taxonomy-<?php echo $tax->name ?>">  
                  <?php endif; ?>
                  
                  <?php echo WOOF::truncate($tax->display_label(), "length=15&words=0") ?>
                  
                  <?php if (MasterPress::current_user_can("manage_taxonomies+edit_taxonomies")) : ?>
                  </a>
                  <?php else: ?>
                  </div>  
                  <?php endif; ?>
                  
                  
                  <?php if (MasterPress::current_user_can("manage_taxonomies+manage_taxonomy_field_sets")) : ?>
                  <a href="<?php echo MasterPress::admin_url("taxonomies", "manage-field-sets", "parent=".$tax->id) ?>" title="<?php _e("Manage Field Sets", MASTERPRESS_DOMAIN) ?>" class="field-sets count-<?php echo $fsc ?>"><?php echo $fsc ?></a>
                  <?php else : ?>
                  <div title="<?php _e("Field Sets", MASTERPRESS_DOMAIN) ?>" class="field-sets count-<?php echo $fsc ?>"><?php echo $fsc ?></div>
                  <?php endif; ?>


                  <?php foreach ($tax->post_types() as $pt) : ?> 
                  <span class="post-type-link-<?php echo $pt->name ?> related-link asterisk"></span>
                  <?php endforeach; ?>

                  <?php foreach ($tax->field_sets() as $fs) : ?>
                  <?php if ($fs->is_shared()) : ?>
                  <span class="shared-field-set-link-<?php echo $fs->name ?> related-link asterisk"></span>
                  <?php endif; ?>
                  <?php endforeach; ?>
                
                </li>
                
                <?php endif; ?>

                <?php endforeach; ?>
                
                <?php if (MasterPress::current_user_can("create_taxonomies")) : ?>
                <li class="divide"><a href="<?php echo MasterPress::admin_url("taxonomies", "create") ?>" class="create-link"><i></i><?php echo MPV::__create( MPV_Taxonomies::__s() ) ?></a></li>
                <?php endif; ?>
                </ul>
            
              </div>
              <!-- /.body -->
            
            </div>
            <!-- /.col -->
          
            <div class="col field-sets shared-field-sets">
            
            
              <h4><i class="metabox-share"></i>
              <?php if (MasterPress::current_user_can("manage_shared_field_sets")) : ?>
              <a href="<?php echo MasterPress::admin_url("shared-field-sets", "manage") ?>" title="<?php _e("Manage Shared Field Sets", MASTERPRESS_DOMAIN) ?>" class="icon">              
              <?php else : ?>
              <span class="icon">
              <?php endif; ?>
              
              <?php echo WOOF::items_number( count($shared_field_sets), __("<em>No</em> Shared Field Sets", MASTERPRESS_DOMAIN), __("<b>%d</b> Shared Field Set", MASTERPRESS_DOMAIN), __("<b>%d</b> Shared Field Sets", MASTERPRESS_DOMAIN) ) ?>
              
              <?php if (MasterPress::current_user_can("manage_shared_field_sets")) : ?>
              </a>
              <?php else : ?>
              </span>
              <?php endif; ?>
              </h4>
            
              <div class="body">
              
                <ul class="count-<?php echo count($shared_field_sets) ?>">
                <?php foreach ($shared_field_sets as $field_set) : $multiple = $field_set->allow_multiple ? "allow-multiple" : ''; $disabled = $field_set->disabled ? 'disabled ' : ''; $disabled_title = $field_set->disabled ? __('This shared field set is currently disabled', MASTERPRESS_DOMAIN) : ''; ?>
                <li class="<?php echo $disabled ?>shared-field-set-<?php echo $field_set->name ?> linkify" data-name="<?php echo $field_set->name ?>" title="<?php echo $disabled_title ?>">



                  <?php if (MasterPress::current_user_can("manage_shared_field_sets+edit_shared_field_sets")) : ?>
                  <a href="<?php echo MasterPress::admin_url("shared-field-sets", "edit", "id=".$field_set->id) ?>" title="<?php _e("Edit Shared Field Set", MASTERPRESS_DOMAIN) ?>" class="item <?php echo $multiple ?>">
                  <?php else: ?>
                  <div class="item <?php echo $multiple ?>">  
                  <?php endif; ?>

                  <?php if ($multiple) : ?>
                  <i class="metabox-add-remove"></i>
                  <?php else : ?>
                  <i class="metabox"></i>
                  <?php endif; ?>
                  
                  <?php echo $field_set->display_label() ?></a>
                  
                  <?php if (MasterPress::current_user_can("manage_shared_field_sets+edit_shared_field_sets")) : ?>
                  </a>
                  <?php else: ?>
                  </div>
                  <?php endif; ?>
                
                  <?php foreach ($field_set->post_types() as $post_type) : ?> 
                  <span class="post-type-link-<?php echo $post_type->name ?> related-link asterisk"></span>
                  <?php endforeach; ?>

                  <?php foreach ($field_set->taxonomies() as $tax) : ?> 
                  <span class="tax-link-<?php echo $tax->name ?> related-link asterisk"></span>
                  <?php endforeach; ?>
                
                  <?php foreach ($field_set->roles() as $role) : ?> 
                  <span class="role-link-<?php echo $role->id ?> related-link asterisk"></span>
                  <?php endforeach; ?>
                
                </li>
                <?php endforeach; ?>
                
                <?php if (MasterPress::current_user_can("create_shared_field_sets")) : ?>
                <li class="divide"><a href="<?php echo MasterPress::admin_url("shared-field-sets", "create") ?>" class="create-link"><i></i><?php echo MPV::__create( MPV_SharedFieldSets::__s() ) ?></a></li>
                <?php endif; ?>

                </ul>
            
              </div>
              <!-- /.body -->
            
            </div>
            <!-- /.col -->
          
          
          </div>
          <!-- /.row -->
        
          <div class="row">
          
          
          
            <div class="col templates">

              <h4><i class="template"></i>
              <?php if (MasterPress::current_user_can("manage_templates")) : ?>
              <a href="<?php echo MasterPress::admin_url("templates", "manage") ?>" title="<?php _e("Manage Templates", MASTERPRESS_DOMAIN) ?>" class="icon">              
              <?php else : ?>
              <span class="icon">
              <?php endif; ?>
              
              <?php echo WOOF::items_number( count($templates), __("<em>No</em> Templates", MASTERPRESS_DOMAIN), __("<b>%d</b> Template", MASTERPRESS_DOMAIN), __("<b>%d</b> Templates", MASTERPRESS_DOMAIN) ) ?>
              
              <?php if (MasterPress::current_user_can("manage_templates")) : ?>
              </a>
              <?php else : ?>
              </span>
              <?php endif; ?>
              </h4>
              
              
              <div class="body">
              
                <ul class="count-<?php echo count($templates) ?>">
                <?php $count = 0; ?>
                <?php foreach ($templates as $template => $file) : $count++; 
              
                $fsc = count(MPM_TemplateFieldSet::find_by_template( $file ));
              
                ?>
                <li class="linkify" data-name="<?php echo $file ?>">

                  <?php if (MasterPress::current_user_can("manage_templates+edit_templates")) : ?>
                  <a href="<?php echo MasterPress::admin_url("templates", "edit", "id=".$file) ?>" class="item">
                  <?php else: ?>
                  <div class="item">  
                  <?php endif; ?>
                  
                  <?php echo WOOF::truncate($template, "length=20&words=0") ?>
                  
                  <?php if (MasterPress::current_user_can("manage_templates+edit_templates")) : ?>
                  </a>
                  <?php else: ?>
                  </div>  
                  <?php endif; ?>
                  
                  
                  <?php if (MasterPress::current_user_can("manage_templates+manage_template_field_sets")) : ?>
                  <a href="<?php echo MasterPress::admin_url("templates", "manage-field-sets", "parent=".$file) ?>" title="<?php _e("Manage Field Sets", MASTERPRESS_DOMAIN) ?>" class="field-sets count-<?php echo $fsc ?>"><?php echo $fsc ?></a>
                  <?php else : ?>
                  <div title="<?php _e("Field Sets", MASTERPRESS_DOMAIN) ?>" class="field-sets count-<?php echo $fsc ?>"><?php echo $fsc ?></div>
                  <?php endif; ?>
                  
                </li>
                <?php endforeach; ?>
                </ul>
            
              </div>
              <!-- /.body -->
            
            </div>
            <!-- /.col -->
          
            <div class="col field-sets site-field-sets">
            
              <h4><i class="sitemap"></i>
              <?php if (MasterPress::current_user_can("manage_site_field_sets")) : ?>
              <a href="<?php echo MasterPress::admin_url("site-field-sets", "manage") ?>" title="<?php _e("Manage Site Field Sets", MASTERPRESS_DOMAIN) ?>" class="icon">
              <?php else : ?>
              <span class="icon">
              <?php endif; ?>
              
              <?php echo WOOF::items_number( count($site_field_sets), __("<em>No</em> Site Field Sets", MASTERPRESS_DOMAIN), __("<b>%d</b> site Field Set", MASTERPRESS_DOMAIN), __("<b>%d</b> site Field Sets", MASTERPRESS_DOMAIN) ) ?>
              
              <?php if (MasterPress::current_user_can("manage_site_field_sets")) : ?>
              </a>
              <?php else : ?>
              </span>
              <?php endif; ?>
              </h4>
              
              <div class="body">
              
                <ul class="count-<?php echo count($site_field_sets) ?>">
                <?php foreach ($site_field_sets as $field_set) : $multiple = $field_set->allow_multiple ? "allow-multiple" : '';  $disabled = $field_set->disabled ? 'disabled ' : ''; $disabled_title = $field_set->disabled ? __('This site field set is currently disabled', MASTERPRESS_DOMAIN) : ''; ?>
                <li class="<?php echo $disabled ?>site-field-set-<?php echo $field_set->name ?> linkify" data-name="<?php echo $field_set->name ?>" title="<?php echo $disabled_title ?>">

                  <?php if (MasterPress::current_user_can("manage_site_field_sets+edit_site_field_sets")) : ?>
                  <a href="<?php echo MasterPress::admin_url("site-field-sets", "edit", "id=".$field_set->id) ?>" title="<?php _e("Edit Site Field Set", MASTERPRESS_DOMAIN) ?>" class="item <?php echo $multiple ?>">
                  <?php else: ?>
                  <div class="item <?php echo $multiple ?>">  
                  <?php endif; ?>

                  <?php if ($multiple) : ?>
                  <i class="metabox-add-remove"></i>
                  <?php else : ?>
                  <i class="metabox"></i>
                  <?php endif; ?>

                  <?php echo $field_set->display_label() ?></a>
                  
                  <?php if (MasterPress::current_user_can("manage_site_field_sets+edit_site_field_sets")) : ?>
                  </a>
                  <?php else: ?>
                  </div>
                  <?php endif; ?>
                  

                </li>
                <?php endforeach; ?>
                <?php if (MasterPress::current_user_can("create_site_field_sets")) : ?>
                <li class="divide"><a href="<?php echo MasterPress::admin_url("site-field-sets", "create") ?>" class="create-link"><i></i><?php echo MPV::__create( __("Site Field Set", MASTERPRESS_DOMAIN) ) ?></a></li>
                <?php endif; ?>
                </ul>
            
              </div>
              <!-- /.body -->
            
            </div>
            <!-- /.col -->

            <div class="col roles">

              <h4><i class="user"></i>
              <?php if (MasterPress::current_user_can("manage_user_roles")) : ?>
              <a href="<?php echo MasterPress::admin_url("roles", "manage") ?>" title="<?php _e("Manage User Roles", MASTERPRESS_DOMAIN) ?>" class="icon">              
              <?php else : ?>
              <span class="icon">
              <?php endif; ?>

              <?php echo WOOF::items_number( count($roles), __("<em>No</em> User Roles", MASTERPRESS_DOMAIN), __("<b>%d</b> User Role", MASTERPRESS_DOMAIN), __("<b>%d</b> User Roles", MASTERPRESS_DOMAIN) ) ?>
              
              <?php if (MasterPress::current_user_can("manage_user_roles")) : ?>
              </a>
              <?php else : ?>
              </span>
              <?php endif; ?>
              </h4>
              
              
              <div class="body">
                
                <?php
                
                // cap checking has side-effects to the roles collection, causing an infinite loop. We need to cache the info here
                
                $role_cache = array();
                
                foreach ($roles as $role) {
                  $role_cache[] = array("name" => $role->name(), "id" => $role->id());
                  
                
                }
                
                ?>
                
                <ul class="count-<?php echo count($roles) ?>">
                <?php foreach ($role_cache as $role) : $count++; 
                $fsc = count(MPM_RoleFieldSet::find_by_role( $role["id"] ));
                ?>
                <li class="linkify" data-name="<?php echo $role["id"] ?>">
                  
                  <?php if (MasterPress::current_user_can("manage_user_roles+edit_user_roles")) : ?>
                  <a href="<?php echo MasterPress::admin_url("roles", "edit", "id=".$role["id"]) ?>" class="item">
                  <?php else: ?>
                  <div class="item">  
                  <?php endif; ?>
                                
                  <i class="user-role"></i>

                  <?php echo WOOF::truncate($role["name"], "length=20&words=0") ?>
                  
                  <?php if (MasterPress::current_user_can("manage_user_roles+edit_user_roles")) : ?>
                  </a>
                  <?php else: ?>
                  </div>  
                  <?php endif; ?>
                  
                  
                  <?php if (MasterPress::current_user_can("manage_user_roles+manage_user_role_field_sets")) : ?>
                  <a href="<?php echo MasterPress::admin_url("roles", "manage-field-sets", "parent=".$role["id"]) ?>" title="<?php _e("Manage Field Sets", MASTERPRESS_DOMAIN) ?>" class="field-sets count-<?php echo $fsc ?>"><?php echo $fsc ?></a>
                  <?php else : ?>
                  <div title="<?php _e("Field Sets", MASTERPRESS_DOMAIN) ?>" class="field-sets count-<?php echo $fsc ?>"><?php echo $fsc ?></div>
                  <?php endif; ?>
                  
                  
                  <?php foreach ($shared_field_sets as $fs) : ?>
                  <?php if ($fs->visible_in("roles", $role["id"])) : ?>
                  <span class="shared-field-set-link-<?php echo $fs->name ?> related-link asterisk"></span>
                  <?php endif; ?>
                  <?php endforeach; ?>
                
                </li>
                <?php endforeach; ?>
                <?php if (MasterPress::current_user_can("create_user_roles")) : ?>
                <li class="divide"><a href="<?php echo MasterPress::admin_url("roles", "create") ?>" class="create-link"><i></i><?php echo MPV::__create( __("User Role", MASTERPRESS_DOMAIN) ) ?></a></li>
                <?php endif; ?>
                </ul>
            
              </div>
              <!-- /.body -->
            
            </div>
            <!-- /.col -->
                    
          </div>
          <!-- /.row -->
        
        </div>
        <!-- /#masterplan-overview -->


<!-- EXPORT -->

      <?php if (MasterPress::current_user_can("export_masterplan")) : ?>

        <div id="masterplan-export" class="masterplan-export tab-panel <?php echo $tab == "export" ? 'current' : '' ?>">

        <?php MPV::form_open() ?>

          <div id="export-progress" class="progress">
            <?php _e("Exporting Masterplan. Please wait&hellip;", MASTERPRESS_DOMAIN) ?>
          </div>
          <!-- /#export-progress -->
          
          <div id="export-summary" class="summary">
            
            <div id="export-download">

              <p><?php _e("Export completed successfully", MASTERPRESS_DOMAIN) ?></p>
              <a id="export-file-download" href="#" data-message="<?php _e( "Download %s", MASTERPRESS_DOMAIN) ?>"><?php printf( __( "Download %s", MASTERPRESS_DOMAIN ), "file.zip" ) ?></a>
              
            </div>
            <!-- /#export-download -->
            
            
            <div id="extras-summary" class="extras-summary">
              
              <p>
                <?php _e("Note: the following dependent files were included in the Masterplan package", MASTERPRESS_DOMAIN) ?>
              </p>
                
              <div id="extras-icons">
                <h4><?php _e("Icons", MASTERPRESS_DOMAIN); ?></h4>
                
                <ul>
                  
                </ul>
              </div>
              <!-- /#extras-icons -->

              <div id="extras-types">
                <h4><?php _e("Field Types", MASTERPRESS_DOMAIN); ?></h4>
                
                <ul>
                  
                </ul>
              </div>
              <!-- /#extras-field-types -->
              
              
            </div>
            
          </div>
          <!-- /#export-summary -->

          <div id="export-ui">
            
          <div id="export-package">
            
            <div class="title">
              <h4 class="package-file"><i class="zip"></i><?php _e("Package File", MASTERPRESS_DOMAIN) ?></h4>
              <button id="button-export" type="submit" class="button-export simple-primary">Export</button>
            </div>
            <!-- /.title -->
            
            <div id="f-export-filename" class="f">
            
              <label for="export_filename"><?php _e("Name:", MASTERPRESS_DOMAIN) ?></label>
            
              <div class="fw">
                <input id="export_filename" spellcheck="false" name="export_filename" type="text" value="<?php echo $wf->sanitize( $wf->site_name() ) ?>" class="text" />
                <span id="export_filename_extension" class="note"><?php echo ".".$wf->format_date("[date-time-sortable]") ?>.masterplan.zip</span>
              </div>
              <!-- /.fw -->
            
            </div>
            <!-- /.f -->

          </div>
          <!-- /#export-package -->
          
          <div id="export-readme">
            
            <h4 class="readme"><i class="document-text"></i><?php _e('Read Me<span> - this Markdown-formatted text will be stored in <span class="tt">README.markdown</span> inside the Masterplan package</span>', MASTERPRESS_DOMAIN); ?></h4>
            
            <div id="f-export_readme">
<textarea id="export_readme" name="export_readme">
# Masterplan for <?php echo $wf->sites()->first()->name ?> #

+ By: <?php echo $wf->the_user()->fullname() ?>

+ Created: <?php echo $wf->format_date("[date-time-long]") ?>


-------------------------------------------------

</textarea>
          </div>
          
          </div>
          <!-- /#export-readme -->
          
          <div id="export-items">
            
            <div class="title-buttons">
              <h4 class="export-items"><i class="hand-point"></i><?php _e("Export Items<span> - check the items you wish to include in the Masterplan package</span>", MASTERPRESS_DOMAIN); ?></h4>
              <div class="buttons">
                <button id="export-select-all" type="button" class="button">Select <span class="all">All</span></button>
                <button id="export-select-none" type="button" class="button">Select <span class="none">None</span></button>
              </div>
              
            </div>
            <!-- /.title-buttons -->
            
            <div class="fsi">
            <div class="fsibv">
              <div class="fsit">
                <h4 class="post-types"><i class="pin"></i><?php _e("Post Types", MASTERPRESS_DOMAIN) ?></h4>
                <input id="post-types-check" name="post-types-all" type="checkbox" class="checkbox" checked="checked" />
              </div>
              
              <div class="fsic">
                
                <ul class="object-tree post-types">
                <?php foreach ($post_types as $post_type) : ?>
                  
                <?php if ($post_type->still_registered()) : ?>

                <li class="post-type-<?php echo $post_type->name ?>">
                  <input id="ref-post-type-<?php echo $post_type->name ?>" name="ref[post_types][<?php echo $post_type->name ?>][selected]" checked="checked" value="true" type="hidden" />
                  <input id="export-post-type-<?php echo $post_type->name ?>" name="export[post_types][<?php echo $post_type->name ?>][selected]" checked="checked" value="true" type="checkbox" class="checkbox" />
                  <label for="export-post-type-<?php echo $post_type->name ?>" class="mp-icon-post-type mp-icon-post-type-<?php echo $post_type->name ?>"><?php echo $post_type->display_label() ?></label>

                <?php $field_sets = $post_type->post_type_field_sets() ?>
                
                <?php if (count($field_sets)) : ?>
                  <ul class="field-sets">
                  <?php foreach ($field_sets as $field_set) : $class = $field_set->allow_multiple ? 'metabox-add-remove-large' : 'metabox-large'; ?>
                  <li class="field-set<?php echo $class ?>">
                    <input id="export-post-type-<?php echo $post_type->name ?>-field-set-<?php echo $field_set->id ?>" checked="checked" name="export[post_types][<?php echo $post_type->name ?>][field_sets][<?php echo $field_set->id ?>][selected]" value="true" type="checkbox" class="checkbox" />
                    <input id="ref-post-type-<?php echo $post_type->name ?>-field-set-<?php echo $field_set->id ?>" name="ref[post_types][<?php echo $post_type->name ?>][field_sets][<?php echo $field_set->id ?>][selected]" value="true" type="hidden" />
                    <label for="export-post-type-<?php echo $post_type->name ?>-field-set-<?php echo $field_set->id ?>" class="field-set"><i class="<?php echo $class ?>"></i><?php echo $field_set->display_label() ?></label>
                    
                    <?php $fields = $field_set->fields() ?>
                
                    <?php if (count($fields)) : ?>
                      <ul class="fields">
                      <?php foreach ($fields as $field) : ?>
                      <?php if ($type_class = MPFT::type_class($field->type)) : ?>
                      <li class="field">
                        <input id="export-post-type-<?php echo $post_type->name ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" checked="checked" name="export[post_types][<?php echo $post_type->name ?>][field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="checkbox" class="checkbox" />
                        <input id="ref-post-type-<?php echo $post_type->name ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" checked="checked" name="ref[post_types][<?php echo $post_type->name ?>][field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="hidden" />
                        <label for="export-post-type-<?php echo $post_type->name ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" class="mp-icon-field-type-<?php echo $field->type ?>"><?php echo $field->display_label() ?></label>
                      </li>  
                      <?php endif; ?>
                      <?php endforeach; ?>
                      </ul>
                    <?php endif; ?>
                
                  </li>  
                  <?php endforeach; ?>
                  </ul>
                <?php endif; ?>
                
                </li>
                
                <?php endif; ?>
                
                <?php endforeach; ?>  
                </ul>
                
                
              </div>
              <!-- /.fsic -->
              
            </div>
            </div>
            <!-- /.fsi -->
            
            
            
            <div class="fsi">
            <div class="fsibv">
              <div class="fsit">
                <h4 class="taxonomies"><i class="tag"></i><?php _e("Taxonomies", MASTERPRESS_DOMAIN) ?></h4>
                <input id="taxonomies-check" name="taxonomies-all" type="checkbox" class="checkbox" checked="checked" />
              </div>
              
              <div class="fsic">
                
                <ul class="object-tree taxonomies">
                <?php foreach ($taxonomies as $tax) : ?>

                <?php if ($tax->still_registered()) : ?>

                <li>
                  <input id="ref-taxonomy-<?php echo $tax->name ?>" name="ref[taxonomies][<?php echo $tax->name ?>][selected]" value="true" type="hidden" />
                  <input id="export-taxonomy-<?php echo $tax->name ?>" name="export[taxonomies][<?php echo $tax->name ?>][selected]" checked="checked" value="true" type="checkbox" class="checkbox" />
                  <label for="export-taxonomy-<?php echo $tax->name ?>" class="mp-icon-taxonomy mp-icon-taxonomy-<?php echo $tax->name ?>"><?php echo $tax->display_label() ?></label>

                <?php $field_sets = $tax->taxonomy_field_sets() ?>
                
                <?php if (count($field_sets)) : ?>
                  <ul class="field-sets">
                  <?php foreach ($field_sets as $field_set) : $class = $field_set->allow_multiple ? 'metabox-add-remove-large' : 'metabox-large'; ?>
                  <li class="field-set<?php echo $class ?>">
                    <input id="ref-taxonomy-<?php echo $tax->name ?>-field-set-<?php echo $field_set->id ?>" name="ref[taxonomies][<?php echo $tax->name ?>][field_sets][<?php echo $field_set->id ?>][selected]" value="true" type="hidden" />
                    <input id="export-taxonomy-<?php echo $tax->name ?>-field-set-<?php echo $field_set->id ?>" name="export[taxonomies][<?php echo $tax->name ?>][field_sets][<?php echo $field_set->id ?>][selected]" value="true" checked="checked" type="checkbox" class="checkbox" />
                    <label for="export-taxonomy-<?php echo $tax->name ?>-field-set-<?php echo $field_set->id ?>" class="field-set"><i class="<?php echo $class ?>"></i><?php echo $field_set->display_label() ?></label>

                    <?php $fields = $field_set->fields() ?>
                
                    <?php if (count($fields)) : ?>
                      <ul class="fields">
                      <?php foreach ($fields as $field) : ?>
                      <?php if ($type_class = MPFT::type_class($field->type)) : ?>
                      <li class="field">
                        <input id="ref-taxonomy-<?php echo $tax->name ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" name="ref[taxonomies][<?php echo $tax->name ?>][field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="hidden" />
                        <input id="export-taxonomy-<?php echo $tax->name ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" checked="checked" name="export[taxonomies][<?php echo $tax->name ?>][field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="checkbox" class="checkbox" />
                        <label for="export-taxonomy-<?php echo $tax->name ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>"  class="mp-icon-field-type-<?php echo $field->type ?>"><?php echo $field->display_label() ?></label>
                      </li>  
                      <?php endif; ?>
                      <?php endforeach; ?>
                      </ul>
                    <?php endif; ?>
                
                  </li>  
                  <?php endforeach; ?>
                  </ul>
                <?php endif; ?>
                
                </li>
                <?php endif; ?>

                <?php endforeach; ?>  
                </ul>
                
                
              </div>
              <!-- /.fsic -->
              
            </div>
            </div>
            <!-- /.fsi -->
            
            <?php if (count($shared_field_sets)) : ?>

            <div class="fsi">
            <div class="fsibv">
              <div class="fsit">
                <h4 class="shared-field-sets"><i class="metabox-share"></i><?php _e("Shared Field Sets", MASTERPRESS_DOMAIN) ?></h4>
                <input id="shared-field-sets-check" name="shared-field-sets-all" type="checkbox" class="checkbox" checked="checked" />
              </div>
              
              <div class="fsic">
                
                <ul class="object-tree shared-field-sets field-sets">
                <?php foreach ($shared_field_sets as $field_set) : $class = $field_set->allow_multiple ? 'metabox-add-remove-large' : 'metabox-large'; ?>
                <li class="field-set<?php echo $class ?>">
                  <input id="ref-shared-field-set-<?php echo $field_set->id ?>" name="ref[shared_field_sets][<?php echo $field_set->id ?>][selected]" value="true" type="hidden" />
                  <input id="export-shared-field-set-<?php echo $field_set->id ?>" name="export[shared_field_sets][<?php echo $field_set->id ?>][selected]" value="true" checked="checked" type="checkbox" class="checkbox" />
                  <label for="export-shared-field-set-<?php echo $field_set->id ?>" class="field-set"><i class="<?php echo $class ?>"></i><?php echo $field_set->display_label() ?></label>

                  <?php $fields = $field_set->fields() ?>
              
                  <?php if (count($fields)) : ?>
                    <ul class="fields">
                    <?php foreach ($fields as $field) : ?>
                    <?php if ($type_class = MPFT::type_class($field->type)) : ?>
                    <li class="field">
                      <input id="ref-shared-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" checked="checked" name="ref[shared_field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="hidden" />
                      <input id="export-shared-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" checked="checked" name="export[shared_field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="checkbox" class="checkbox" />
                      <label for="export-shared-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" class="mp-icon-field-type-<?php echo $field->type ?>"><?php echo $field->display_label() ?></label>
                    </li>  
                    <?php endif; ?>
                    <?php endforeach; ?>
                    </ul>
                  <?php endif; ?>
              
                </li>  
                <?php endforeach; ?>
                </ul>
                
                
              </div>
              <!-- /.fsic -->
              
            </div>
            </div>
            <!-- /.fsi -->
            
            <?php endif; ?>
          
          
            <?php if (count($site_field_sets)) : ?>

            <div class="fsi">
            <div class="fsibv">
              <div class="fsit">
                <h4 class="site-field-sets"><i class="sitemap"></i><?php _e("Site Field Sets", MASTERPRESS_DOMAIN) ?></h4>
                <input id="site-field-sets-check" name="site-field-sets-all" type="checkbox" class="checkbox" checked="checked" />
              </div>
              
              <div class="fsic">
                
                  <ul class="object-tree site-field-sets field-sets">
                  <?php foreach ($site_field_sets as $field_set) : $class = $field_set->allow_multiple ? 'metabox-add-remove-large' : 'metabox-large'; ?>
                  <li class="field-set<?php echo $class ?>">
                    <input id="ref-site-field-set-<?php echo $field_set->id ?>" name="ref[site_field_sets][<?php echo $field_set->id ?>][selected]" value="true" type="hidden" />
                    <input id="export-site-field-set-<?php echo $field_set->id ?>" name="export[site_field_sets][<?php echo $field_set->id ?>][selected]" value="true" checked="checked" type="checkbox" class="checkbox" />
                    <label for="export-site-field-set-<?php echo $field_set->id ?>" class="field-set"><i class="<?php echo $class ?>"></i><?php echo $field_set->display_label() ?></label>

                    <?php $fields = $field_set->fields() ?>
                
                    <?php if (count($fields)) : ?>
                      <ul class="fields">
                      <?php foreach ($fields as $field) : ?>
                      <?php if ($type_class = MPFT::type_class($field->type)) : ?>
                      <li class="field">
                        <input id="ref-site-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" checked="checked" name="ref[site_field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="hidden" />
                        <input id="export-site-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" checked="checked" name="export[site_field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="checkbox" class="checkbox" />
                        <label for="export-site-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" class="mp-icon-field-type-<?php echo $field->type ?>"><?php echo $field->display_label() ?></label>
                      </li>  
                      <?php endif; ?>
                      <?php endforeach; ?>
                      </ul>
                    <?php endif; ?>
                
                  </li>  
                  <?php endforeach; ?>
                  </ul>
                
                
              </div>
              <!-- /.fsic -->
              
            </div>
            </div>
            <!-- /.fsi -->
            
            <?php endif; ?>
            
          
          
            <div class="fsi">
            <div class="fsibv">
              <div class="fsit">
                <h4 class="templates"><i class="template"></i><?php _e("Templates", MASTERPRESS_DOMAIN) ?></h4>
                <input id="templates-check" name="templates-all" type="checkbox" class="checkbox" checked="checked" />
              </div>
              
              <div class="fsic">
                
                <ul class="object-tree">
              

                <?php foreach ($templates as $template => $file) : $id = $wf->sanitize($file); ?>
                <li class="template-<?php echo $id ?>">

                  <input id="ref-template-<?php echo $wf->sanitize($file) ?>" name="ref[templates][<?php echo $file ?>][selected]" checked="checked" value="true" type="hidden" />
                  <input id="export-template-<?php echo $wf->sanitize($file) ?>" name="export[templates][<?php echo $file ?>][selected]" checked="checked" value="true" type="checkbox" class="checkbox" />
                  <label for="export-template-<?php echo $wf->sanitize($file) ?>" class="template"><i class="template"></i><?php echo $template ?></label>


                  <?php $field_sets = MPM_TemplateFieldSet::find_by_template( $file ); ?>

                <?php if (count($field_sets)) : ?>
                  <ul class="field-sets">
                  <?php foreach ($field_sets as $field_set) : $class = $field_set->allow_multiple ? 'metabox-add-remove-large' : 'metabox-large'; ?>
                  <li class="field-set<?php echo $class ?>">
                    <input id="ref-template-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>" name="ref[templates][<?php echo $file ?>][field_sets][<?php echo $field_set->id ?>][selected]" value="true" type="hidden" />
                    <input id="export-template-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>" checked="checked" name="export[templates][<?php echo $file ?>][field_sets][<?php echo $field_set->id ?>][selected]" value="true" type="checkbox" class="checkbox" />
                    <label for="export-template-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>" class="field-set"><i class="<?php echo $class ?>"></i><?php echo $field_set->display_label() ?></label>
                    
                    <?php $fields = $field_set->fields(); ?>
                
                    <?php if (count($fields)) : ?>
                      <ul class="fields">
                      <?php foreach ($fields as $field) : ?>
                      <?php if ($type_class = MPFT::type_class($field->type)) : ?>
                      <li class="field">
                        <input id="ref-template-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" name="ref[templates][<?php echo $file ?>][field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="hidden" />
                        <input id="export-template-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" checked="checked" name="export[templates][<?php echo $file ?>][field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="checkbox" class="checkbox" />
                        <label for="export-template-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" class="mp-icon-field-type-<?php echo $field->type ?>"><?php echo $field->display_label() ?></label>
                      </li>  
                      <?php endif; ?>
                      <?php endforeach; ?>
                      </ul>
                    <?php endif; ?>
                
                  </li>  
                  <?php endforeach; ?>
                  </ul>
                <?php endif; ?>
                
                </li>

                <?php endforeach; ?>  

                </ul>
                
                
              </div>
              <!-- /.fsic -->
              
            </div>
            </div>
            <!-- /.fsi -->
            
            
            
            <div class="fsi">
            <div class="fsibv">
              <div class="fsit">
                <h4 class="roles"><i class="user-role"></i><?php _e("User Roles", MASTERPRESS_DOMAIN) ?></h4>
                <input id="roles-check" name="roles-all" type="checkbox" class="checkbox" checked="checked" />
              </div>
              
              <div class="fsic">
                
                <ul class="object-tree">
              

                <?php foreach ($roles as $role) : $id = $role->id() ?>
                <li>
                  <input id="ref-role-<?php echo $id ?>" name="ref[roles][<?php echo $id ?>][selected]" checked="checked" value="true" type="hidden" />
                  <input id="export-role-<?php echo $id ?>" name="export[roles][<?php echo $id ?>][selected]" checked="checked" value="true" type="checkbox" class="checkbox" />
                  <label for="export-role-<?php echo $id ?>" class="role"><i class="user-role"></i><?php echo $role->name ?></label>


                <?php $field_sets = MPM_RoleFieldSet::find_by_role( $id ) ?>

                <?php if (count($field_sets)) : ?>
                  <ul class="field-sets">
                  <?php foreach ($field_sets as $field_set) : $class = $field_set->allow_multiple ? 'metabox-add-remove-large' : 'metabox-large'; ?>
                  <li class="field-set<?php echo $class ?>">
                    <input id="ref-role-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>" checked="checked" name="ref[roles][<?php echo $id ?>][field_sets][<?php echo $field_set->id ?>][selected]" value="true" type="hidden" />
                    <input id="export-role-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>" checked="checked" name="export[roles][<?php echo $id ?>][field_sets][<?php echo $field_set->id ?>][selected]" value="true" type="checkbox" class="checkbox" />
                    <label for="export-role-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>" class="field-set"><i class="<?php echo $class ?>"></i><?php echo $field_set->display_label() ?></label>
                    
                    <?php $fields = $field_set->fields(); ?>
                
                    <?php if (count($fields)) : ?>
                      <ul class="fields">
                      <?php foreach ($fields as $field) : ?>
                      <?php if ($type_class = MPFT::type_class($field->type)) : ?>
                      <li class="field">
                        <input id="ref-role-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" name="ref[roles][<?php echo $id ?>][field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="hidden" />
                        <input id="export-role-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" checked="checked" name="export[roles][<?php echo $id ?>][field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="checkbox" class="checkbox" />
                        <label for="export-role-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" class="mp-icon-field-type-<?php echo $field->type ?>"><?php echo $field->display_label() ?></label>
                      </li>  
                      <?php endif; ?>
                      <?php endforeach; ?>
                      </ul>
                    <?php endif; ?>
                
                  </li>  
                  <?php endforeach; ?>
                  </ul>
                <?php endif; ?>
                
                </li>

                <?php endforeach; ?>  

                </ul>
                
                
              </div>
              <!-- /.fsic -->
              
            </div>
            </div>
            <!-- /.fsi -->
            
          
          
            
          </div>
          <!-- /#export-items -->
          
          
          </div>
          <!-- /#export-ui -->

          
          
        <?php MPV::form_close() ?>

              
        </div>
        <!-- /#masterplan-export -->
        
      <?php endif; ?>


      <?php if (MasterPress::current_user_can("import_masterplan")) : ?>

        <div id="masterplan-import" class="tab-panel <?php echo $tab == "import" ? 'current' : '' ?>">

          <?php if (!MPV::is_postback()) : ?>

          <?php MPV::form_open() ?>
            
          <div id="import-file-wrap">
            
            <div class="title">
              <h4 class="upload"><i class="upload"></i><?php _e("Package Upload", MASTERPRESS_DOMAIN) ?></h4>
            </div>
            <!-- /.title -->

            
            <label id="label-import_file" for="import_file"><?php _e("Upload a Masterplan zip package to begin.<br  /><b>Note:</b> you will be able to review the contents of the package before going ahead with the import.") ?></label>
          
            <div id="import-file-uploader" class="file-uploader { allowedExtensions: ['zip'], ids: { drop: 'import_file_drop_area' }, input: '#import_file', inputName: 'import_file_ul', base_url: '<?php echo MASTERPRESS_GLOBAL_CONTENT_URL ?>', params: { dir: 'tmp/' }, limit: 1, lang: { buttonReplace: '<?php _e("Select a Different File&hellip;") ?>', buttonChoose: '<?php _e("Choose from Computer&hellip;", MASTERPRESS_DOMAIN) ?>'} }">
            
              <div id="import_file_drop_area" class="drop-area"><?php _e("Drop file here to upload", MASTERPRESS_DOMAIN) ?></div>

              <?php 
            
              $file_name = __("( None )", MASTERPRESS_DOMAIN);
              $file_class = "name-none";

              ?>
            
              <div class="file">
                <span class="preview"></span><span data-none="<?php echo __("( None )", MASTERPRESS_DOMAIN) ?>" class="name <?php echo $file_class ?>"><?php echo $file_name ?></span>
              </div>
            
              <input id="import_file" name="import_file" value="" type="hidden" />
              <div class="uploader-ui"></div>
            
            </div>
            <!-- /.file-uploader -->
          
          </div>
          <!-- /#import-file-wrap -->
          
          <p id="import-fetching-summary"><?php _e("Fetching Masterplan info - Please wait&hellip;", MASTERPRESS_DOMAIN); ?></p>
          

          <div id="import-confirmation">
            
            <div class="title">
              <h4 class="upload"><i class="tick-circle"></i><?php _e("Confirmation", MASTERPRESS_DOMAIN) ?> - <span><?php _e("select import options and review the uploaded package", MASTERPRESS_DOMAIN) ?></span></h4>
              <button id="button-import" type="submit" class="button-import simple-primary">Import</button>
            </div>
            <!-- /.title -->
                
            <div class="content">
                        
              <div class="f">
                <div class="fw">
                  <input id="import-backup" name="import_backup" value="yes" checked="checked" type="checkbox" class="checkbox" />
                  <label for="import-backup" class="checkbox"><?php _e("<strong>Backup the existing setup</strong> before importing ( highly recommended )", MASTERPRESS_DOMAIN); ?></label>
                </div>
              </div>
              <!-- /.f -->

              <div id="f-types-overwrite" class="f">
                <div class="fw">
                  <input id="import-types-overwrite" name="import_types_overwrite" value="yes" checked="checked" type="checkbox" class="checkbox" />
                  <label for="import-types-overwrite" class="checkbox"><?php _e("<strong>Overwrite</strong> existing field type extensions with those included in the imported package", MASTERPRESS_DOMAIN); ?></label>
                </div>
              </div>
              <!-- /.f -->
            
              <div class="f f-mode">
                <p>
                  <?php _e("When items are present in the existing setup, but not in the imported Masterplan:", MASTERPRESS_DOMAIN) ?>
                </p>
                
                <div class="fw">
                  <input id="import-mode-replace" name="import_mode" value="replace" checked="checked" type="radio" class="radio" />
                  <label for="import-mode-replace" class="radio"><?php _e('Remove the items from the existing setup ( <strong class="replace">completely replace</strong> the existing setup )', MASTERPRESS_DOMAIN); ?></label>
                </div>

                <div class="fw">
                  <input id="import-mode-append" name="import_mode" value="append" type="radio" class="radio" />
                  <label for="import-mode-append" class="radio"><?php _e('Keep the items in the existing setup ( <strong class="append">append to</strong> the existing setup )', MASTERPRESS_DOMAIN); ?></label>
                </div>

                
              </div>
              <!-- /.f -->
            
            
            </div>
            <!-- /.content -->
            
          </div>
                  

          
          <div id="import-preview" class="import-preview">

            <input type="hidden" name="tab" value="import" />
            <input id="import-masterplan" type="hidden" name="import_masterplan" value="" />
            
            
            <?php
            
            // build a template list for the importer, since get_page_templates() is not available early in execution
            
            foreach (get_page_templates() as $template => $file) :
              ?>
              <input name="templates[<?php echo $file ?>]" type="hidden" value="<?php echo $template ?>" />
            <?php endforeach; ?>
            
            <div id="import-rep">
              
              <div class="fsi post-types">
              <div class="fsibv">
                <div class="fsit">
                  <h4 class="post-types"><i class="pin"></i><?php _e("Post Types", MASTERPRESS_DOMAIN) ?></h4>
                </div>
              
                <div class="fsic">
                
                  <ul class="object-tree post-types">
                 
                  </ul>
                
                </div>
                <!-- /.fsic -->
              
              </div>
              </div>
              <!-- /.fsi -->
            
            
            
              <div class="fsi taxonomies">
              <div class="fsibv">
                <div class="fsit">
                  <h4 class="taxonomies"><i class="tag"></i><?php _e("Taxonomies", MASTERPRESS_DOMAIN) ?></h4>
                </div>
              
                <div class="fsic">
                
                  <ul class="object-tree taxonomies">
                
                  </ul>
                
                
                </div>
                <!-- /.fsic -->
              
              </div>
              </div>
              <!-- /.fsi -->
            
              <div class="fsi shared-field-sets">
              <div class="fsibv">
                <div class="fsit">
                  <h4 class="shared-field-sets"><i class="metabox-share"></i><?php _e("Shared Field Sets", MASTERPRESS_DOMAIN) ?></h4>
                </div>
              
                <div class="fsic">
                  <ul class="object-tree shared-field-sets field-sets">
                  </ul>
                </div>
                <!-- /.fsic -->
              
              </div>
              </div>
              <!-- /.fsi -->
          
              <div class="fsi site-field-sets">
              <div class="fsibv">
                <div class="fsit">
                  <h4 class="site-field-sets"><i class="sitemap"></i><?php _e("Site Field Sets", MASTERPRESS_DOMAIN) ?></h4>
                </div>
              
                <div class="fsic">
                
                    <ul class="object-tree site-field-sets field-sets">
                    </ul>
                
                </div>
                <!-- /.fsic -->
              
              </div>
              </div>
              <!-- /.fsi -->
          
          
              <div class="fsi templates">
              <div class="fsibv">
                <div class="fsit">
                  <h4 class="templates"><i class="template"></i><?php _e("Templates", MASTERPRESS_DOMAIN) ?></h4>
                </div>
              
                <div class="fsic">
                
                  <ul class="object-tree">
                  </ul>
                
                </div>
                <!-- /.fsic -->
              
              </div>
              </div>
              <!-- /.fsi -->
            
            
            
              <div class="fsi roles">
              <div class="fsibv">
                <div class="fsit">
                  <h4 class="roles"><i class="user-role"></i><?php _e("User Roles", MASTERPRESS_DOMAIN) ?></h4>
                </div>
                
                <div class="fsic">
                
                  <ul class="object-tree">
                  </ul>
                
                </div>
                <!-- /.fsic -->
              
              </div>
              </div>
              <!-- /.fsi -->
            
              
            </div>
            <!-- /#import-rep -->
              

          </div>
          <!-- /#import-summary -->

          <?php MPV::form_close() ?>
          
          <?php else: ?>
          
          
          
          <?php endif; ?>
        
        </div>
        <!-- /#masterplan-import -->
        
      <?php endif; ?>

      <?php if (MasterPress::current_user_can("backup_masterplan")) : ?>
        
        <div id="masterplan-backup" class="masterplan-export tab-panel" style="display: none;">
          
          <ul class="mp-messages">
            <li class="notification"><?php _e("Note - this utility does <b>not</b> backup your WordPress content.", MASTERPRESS_DOMAIN) ?></li>
          </ul>
          
          
          <?php MPV::form_open() ?>

            <div id="backup-progress" class="progress">
              <?php _e("Backing up Masterplan. Please wait&hellip;", MASTERPRESS_DOMAIN) ?>
            </div>
            <!-- /#backup-progress -->

            <div id="backup-summary" class="summary">

              <div id="backup-message">
                <p><?php _e("Backup created successfully", MASTERPRESS_DOMAIN) ?></p>
              </div>
              <!-- /#backup-message -->


              <div id="backup-extras-summary" class="extras-summary">
                <p>
                  <?php _e("Note: the following dependent files were included in the Masterplan package", MASTERPRESS_DOMAIN) ?>
                </p>

                <div id="backup-extras-icons">
                  <h4><?php _e("Icons", MASTERPRESS_DOMAIN); ?></h4>

                  <ul>

                  </ul>
                </div>
                <!-- /#backup-extras-icons -->

                <div id="backup-extras-types">
                  <h4><?php _e("Field Types", MASTERPRESS_DOMAIN); ?></h4>

                  <ul>

                  </ul>
                </div>
                <!-- /#backup-extras-field-types -->

              </div>
              <!-- /#backup-extras-summary -->

            </div>

            <div id="backup-ui">

            <div class="title">
              <h4 class="package-file"><i class="zip"></i><?php _e("Package File", MASTERPRESS_DOMAIN) ?></h4>
              <button id="button-backup" type="submit" class="button-export simple-primary">Backup</button>
            </div>
            <!-- /.title -->

            <div id="f-backup-filename" class="f">
              
              <label for="backup_filename"><?php _e("Name:", MASTERPRESS_DOMAIN) ?></label>

              <div class="fw">
                <span id="backup_filename_prefix" class="note">_backup.</span>
                <input id="backup_filename" spellcheck="false" name="backup_filename" type="text" value="" class="text" />
                <input id="backup_filename_suffix" spellcheck="false" name="backup_filename_suffix" type="hidden" value="<?php echo ".".$wf->format_date("[date-time-sortable]") ?>.masterplan.zip" class="text" />
                <span id="backup_filename_extension" class="note"><?php echo ".".$wf->format_date("[date-time-sortable]") ?>.masterplan.zip</span>
              </div>
              <!-- /.fw -->

              <p id="backup_note"><?php _e("Use the editable field as a way to tag the backup for reference later ( optional )") ?></p>

            </div>
            <!-- /.f -->


            <div id="backup-readme">

              <h4 class="readme"><i class="document-text"></i><?php _e('Read Me<span> - this Markdown-formatted text will be stored in <span class="tt">README.markdown</span> inside the Masterplan backup</span>', MASTERPRESS_DOMAIN); ?></h4>

              <div id="f-backup_readme">
<textarea id="backup_readme" name="backup_readme">
# Masterplan Backup for <?php echo $wf->sites()->first()->name ?> #

+ By: <?php echo $wf->the_user()->fullname() ?>

+ Created: <?php echo $wf->format_date("[date-time-long]") ?>


-------------------------------------------------

</textarea>
            </div>

            </div>
            <!-- /#backup-readme -->
          
          </div>
          
          <?php MPV::form_close() ?>
          
        </div>
        <!-- /#masterplan-backup -->

      <?php endif; ?>

      <?php if (MasterPress::current_user_can("restore_masterplan")) : ?>
        
        <?php if (count($backups)) : ?>

        <div id="masterplan-restore" class="tab-panel <?php echo $tab == "restore" ? 'current' : '' ?>">

        <?php MPV::form_open() ?>

          <div class="title">
            <h4 class="package-file"><i class="zip"></i><?php _e("Package Selection", MASTERPRESS_DOMAIN) ?> - <span><?php _e("select a backup package to restore from", MASTERPRESS_DOMAIN) ?></span></h4>
            <button id="button-restore" type="submit" class="button-restore simple-primary">Restore</button>
          </div>
          <!-- /.title -->

          <div id="f-restore-file" class="f">
           
          <label for="restore-masterplan" class="select"><?php _e("File:", MASTERPRESS_DOMAIN) ?></label>
          
          <div class="fw">
          
          <select id="restore-masterplan" data-empty="<?php _e("Please Select a Masterplan to restore", MASTERPRESS_DOMAIN) ?>" name="restore_masterplan">
            <option value=""><?php _e("Select a backup package") ?></option>
            <?php foreach ( $backups as $backup ) : ?>
            <option value="<?php echo $backup["file"] ?>"><?php echo $backup["label"] ?></option>
            <?php endforeach; ?>
          </select>
               
                   
          </div>
                 
        
          <?php MPV::form_close() ?>
  
        </div>
        <!-- /#masterplan-restore -->
        
        <?php endif; ?>
      
      <?php endif; ?>
      
      </div>
      </div>

    </div>
    <!-- /.fs .fs-masterplan -->
    


  <?php
  }
Exemple #10
0
  public static function admin_enqueue_scripts() {
    
    global $wf;
  
    global $menu;
    global $submenu;


    wp_enqueue_script('jquery-ui-core');
    wp_enqueue_script('jquery-ui-widget');
    wp_enqueue_script('jquery-ui-mouse');
    wp_enqueue_script('jquery-ui-accordion');
    wp_enqueue_script('jquery-ui-slider');
    wp_enqueue_script('jquery-ui-tabs');
    wp_enqueue_script('jquery-ui-sortable');
    wp_enqueue_script('jquery-ui-draggable');
    wp_enqueue_script('jquery-ui-droppable');
    wp_enqueue_script('jquery-ui-selectable');
    wp_enqueue_script('jquery-ui-datepicker');
    wp_enqueue_script('jquery-ui-resizable');
    wp_enqueue_script('jquery-ui-dialog');
    wp_enqueue_script('jquery-effects-pulsate');

		wp_enqueue_script('thickbox'); // include thickbox for tinyMCE
		wp_enqueue_script('editor-functions'); // for tinyMCE

		wp_enqueue_script("woof-html", MASTERPRESS_URL."core/api/woof/woof-html.js", array( "jquery" ) );
    
    if (WP_DEBUG || MASTERPRESS_DEBUG) {

      wp_enqueue_script('jquery-fancybox');
      wp_enqueue_script('jquery-metadata');
      wp_enqueue_script('jquery-scroll-to');
      wp_enqueue_script('handlebars');
      wp_enqueue_script('inflection');
  		wp_enqueue_script('select2');
      wp_enqueue_script('date-js');


			wp_enqueue_script("sprintf", MASTERPRESS_URL."js/src/sprintf-0.7-beta1.js");
			wp_enqueue_script("jquery-reveal", MASTERPRESS_URL."js/src/jquery.reveal.js", array( "jquery" ), MASTERPRESS_VERSION );
			wp_enqueue_script("jquery-affix", MASTERPRESS_URL."js/src/jquery.affix.js", array( "jquery" ), MASTERPRESS_VERSION );
			wp_enqueue_script("jquery-linkify", MASTERPRESS_URL."js/src/jquery.linkify.js", array( "jquery" ) , MASTERPRESS_VERSION);
			wp_enqueue_script("jquery-tabs", MASTERPRESS_URL."js/src/jquery.mp-tabs.js", array( "jquery" ), MASTERPRESS_VERSION );
			wp_enqueue_script("jquery-auto-grow-input", MASTERPRESS_URL."js/src/jquery.auto-grow-input.js", array( "jquery" ), MASTERPRESS_VERSION );
			wp_enqueue_script("jquery-inputmask", MASTERPRESS_URL."js/src/jquery.inputmask.js", array( "jquery" ), MASTERPRESS_VERSION );
			wp_enqueue_script("jquery-client", MASTERPRESS_URL."js/src/jquery.client.js", array( "jquery" ), MASTERPRESS_VERSION );
			wp_enqueue_script("jquery-limit-maxlength", MASTERPRESS_URL."js/src/jquery.limit-maxlength.js", array( "jquery" ), MASTERPRESS_VERSION );
			wp_enqueue_script("jquery-inputspinner", MASTERPRESS_URL."js/src/jquery.inputspinner.js", array( "jquery" ), MASTERPRESS_VERSION );
			wp_enqueue_script("valums-file-uploader", MASTERPRESS_URL."js/src/fileuploader.js", array( "jquery" ), MASTERPRESS_VERSION );
			wp_enqueue_script("jquery-mp-select2", MASTERPRESS_URL."js/src/jquery.mp-select2.js", array( "jquery", "jquery-ui-core" ), MASTERPRESS_VERSION );

			wp_enqueue_script("masterpress-mpv", MASTERPRESS_URL."js/src/mpv.js", array( "jquery" ), MASTERPRESS_VERSION );
			wp_enqueue_script("masterpress-mp-uploader", MASTERPRESS_URL."js/src/mp-file-uploader.js", array( "jquery" ), MASTERPRESS_VERSION );
			wp_enqueue_script("masterpress-mpft", MASTERPRESS_URL."js/src/mpft.js", array( "jquery", "jquery-ui-core", "jquery-ui-widget" ), MASTERPRESS_VERSION );
			wp_enqueue_script("jquery-ui-datetimepicker", MASTERPRESS_URL."js/src/jquery-ui-timepicker-addon.js", array( "jquery", "jquery-ui-datepicker" ), MASTERPRESS_VERSION );
			wp_enqueue_script("jquery-autoresize", MASTERPRESS_URL."js/src/jquery.autoresize.min.js", array( "jquery" ), MASTERPRESS_VERSION );
			wp_enqueue_script("masterpress-mp", MASTERPRESS_URL."js/src/mp.js", array( "jquery", "jquery-ui-core" ), MASTERPRESS_VERSION );
      wp_enqueue_script("masterpress-mpv-meta", MASTERPRESS_URL."js/src/mpv-meta.js", array( "jquery", "jquery-ui-core", "jquery-ui-widget"), MASTERPRESS_VERSION ); 

	  } else {
	    
			wp_enqueue_script("masterpress-plugins", MASTERPRESS_URL."js/mp.all.min.js", array( "jquery", "jquery-ui-core", "jquery-ui-widget", "jquery-ui-datepicker" ), MASTERPRESS_VERSION);		    

    }

    // Add library stylesheets

    wp_enqueue_style("jquery-fancybox");
    wp_enqueue_style("select2");
    
    // Add MasterPress UI stylesheet
		wp_enqueue_style("mpv", MASTERPRESS_URL."css/mp.css", array(), MASTERPRESS_VERSION);



    // setup menu label overrides (wordpress doesn't respect the post type labels currently)

    $na = false;
    
    if (function_exists("is_network_admin") && is_network_admin()) {
      $na = true;
    }
    
    if (!$na) {
      
      if (isset(MasterPress::$post_types["post"])) {
        
        if (isset($menu[self::$post_menu_index][0], $menu[self::$post_menu_index][1])) {
          if ($menu[self::$post_menu_index][1] == "edit_posts") {
            $label = MasterPress::$post_types["post"]->labels["menu_name"];
          
            if ($label != __("Posts")) {
              $menu[self::$post_menu_index][0] = $label;
            }
          }
      
        }

    

        if (isset($submenu[self::$post_submenu_index][self::$post_submenu_all_index][0])) {
          if (isset(MasterPress::$post_types["post"]->labels["all_items"])) {
            $label = MasterPress::$post_types["post"]->labels["all_items"];

            if ($label != "" && $label != __("All Posts")) {
              $submenu[self::$post_submenu_index][self::$post_submenu_all_index][0] = MasterPress::$post_types["post"]->labels["all_items"];
            }
          }
        }
      
      }
    
    
      if (isset(MasterPress::$post_types["page"])) {

      
        if (isset($menu[self::$page_menu_index][0], $menu[self::$page_menu_index][1])) {
          if ($menu[self::$page_menu_index][1] == "edit_pages") {
            $label = MasterPress::$post_types["page"]->labels["menu_name"];
          
            if ($label != __("Pages")) {
              $menu[self::$page_menu_index][0] = $label;
            }
          }
        }
    
        if (isset($submenu[self::$page_submenu_index][self::$page_submenu_all_index][0])) {
          if (isset(MasterPress::$post_types["page"]->labels["all_items"])) {
            $label = MasterPress::$post_types["page"]->labels["all_items"];

            if ($label != "" && $label != __("All Pages")) {
              $submenu[self::$page_submenu_index][self::$page_submenu_all_index][0] = MasterPress::$post_types["page"]->labels["all_items"];
            }
          }
        }

      }

    }


    if (self::is_post_editor()) {
      
      self::enqueue_mce(!$wf->the->type->supports("editor"));
      
      foreach (MPC_Post::assigned_field_types() as $type) {

        if ($type_class = MPFT::type_class($type)) {
          call_user_func( array($type_class, "enqueue") );
        }
      
      }

    } else if (self::is_term_editor() || self::is_term_manage()) {
      
      wp_enqueue_style("editor-buttons");

      self::enqueue_mce();
      
      MPC::incl("term");
      
      foreach (MPC_Term::assigned_field_types() as $type) {

        if ($type_class = MPFT::type_class($type)) {
          call_user_func( array($type_class, "enqueue") );
        }
      
      }
      
    } else if (self::is_user_editor()) {

      wp_enqueue_style("editor-buttons");

      self::enqueue_mce();
      
      foreach (MPC_User::assigned_field_types() as $type) {

        if ($type_class = MPFT::type_class($type)) {
          call_user_func( array($type_class, "enqueue") );
        }
      
      }
    
    } else if (self::is_site_content_editor()) {
      
      MPV::incl("site-content");
      
      wp_enqueue_style("editor-buttons");

      self::enqueue_mce();
      
      foreach (MPC_SiteContent::assigned_field_types() as $type) {

        if ($type_class = MPFT::type_class($type)) {
          call_user_func( array($type_class, "enqueue") );
        }
      
      }
      
    } 
    
  }
Exemple #11
0
  public static function set_item_template_data(MEOW_FieldSet &$set, $args = array()) {
    
    $r = wp_parse_args(
      $args,
      array("preview" => false, "readonly" => !$set->is_editable(), "id_base" => "mp_meta_", "name_base" => "mp_meta", "order_base" => "mp_meta_order", "summary_preview_base" => "mp_summary_preview_", "summary_base" => "mp_summary_" )
    );
    
    $d = array();
     
    $set_item_classes = array();
    $set_fields_classes = array();
    $set_summary_classes = array();
    
    $d["allow_remove"] = true;
    
    if ($r["preview"]) {
      $d["preview"] = true;
      $d["allow_remove"] = false;
    } 
    
    if ($r["readonly"]) {
      $d["readonly"] = true;
      $d["allow_remove"] = false;
    }

    
    $info = $set->info();
    
    if ($info->expanded) {
      $d["toggle_class"] = "collapse";
      $set_item_classes[] = "expanded";
      $set_summary_classes[] = "hidden";
    } else {
      $d["toggle_class"] = "expand";
      $set_item_classes[] = "collapsed";
      $set_fields_classes[] = "hidden";
    }
    
    if (isset($args["versions_select"])) {
      $d["versions_select"] = $args["versions_select"];
    }
    
    $d["lang_are_you_sure"] = esc_js(__("Are you sure?", MASTERPRESS_DOMAIN));

    $d["label_collapse"] = __("Collapse", MASTERPRESS_DOMAIN);
    

    $d["set_item_classes"] = implode(" ", $set_item_classes);
    $d["set_fields_classes"] = implode(" ", $set_fields_classes);
    
    $d["description"] = trim( $info->label("description") );

    $d["allow_multiple"] = $info->allow_multiple;

    $d["labels_toggle"] = __("Toggle", MASTERPRESS_DOMAIN);
    
    $d["set_labels_remove_plain"] = strip_tags($info->label("remove"));
    $d["set_labels_remove"] = $info->label("remove");
        
    $d["fields"] = array();

    if ( WOOF::is_true_arg($args, "creator") ) {
      $i = "!!set_index!!";
    } else if ($set->creator) {
      // leave a placeholder for Handlebars to render into
      $i = "{{set_index}}";
    } else { 
      $i = $set->index();
    }
    
    
    
    $d["set_index"] = $i;
    
    $set_id = $r["id_base"]."{$info->name}_$i"; 
    $set_name = $r["name_base"]."[{$info->name}][$i]"; 
    
    if (WOOF::is_true_arg($r, "nested")) {
      $d["order_name"] = $r["order_base"]."[$i]"; 
    } else {
      $d["order_name"] = $r["order_base"]."[{$info->name}][$i]"; 
    }
  
    
    
    $d["fields"] = array();
    
    $fields = $info->fields(); 
    $fi = 0; 
    $fc = 0;
    
    foreach ($fields as $field) {
      if ($type_class = MPFT::type_class($field->type)) {
        $fc++;
      }
    }
    
    foreach ($fields as $field) {

      if ($field->current_user_can_see()) {

        $field_id = "{$set_id}_{$field->name}";
        $field_name = "{$set_name}[{$field->name}]";

        if ($r["preview"]) {
          $field_summary_id = $r["summary_preview_base"]."{$info->name}_{$field->name}";
        } else {
          $field_summary_id = $r["summary_base"]."{$info->name}_{$field->name}";
        }
      
      
        $fd = array(); // the field data

        if ($ftc = MPFT::type_class($field->type)) {
          $fi++; 

          $fd["model_id"] = $field->id;
          $fd["readonly"] = false; // reset
    
          $fd["label_is_header"] = call_user_func_array( array($ftc, "label_is_header"), array($field->type_options));
          $fd["type"] = $field->type;
          $fd["type_widget"] = "mpft_".str_replace("-", "_", $field->type);
          $fd["label"] = $field->display_label();
          $fd["esc_label"] = esc_attr($field->display_label());
          $fd["label_suffix"] = call_user_func( array($ftc, "label_suffix") );
        
          $fd["field_path"] = $info->name."-".$field->name;

          $fd["prop_list"] = implode(",", MPFT::type_properties($field->type));
        
          $fd["description"] = trim( $field->label("description") );

          $fd["pos_class"] = WOOF_HTML::pos_class_1($fi, $fc, " mp-field-");

          if ($field->current_user_can_manage()) {
            $mu = $field->manage_url($info);
            
            $mu .= "&mp_redirect=".urlencode($_SERVER["REQUEST_URI"]);
            
            if ($mu) {
              $fd["go"] = '<a href="'.$mu.'" class="mp-go with-mptt" data-tooltip="'.__("Edit Field Definition", MASTERPRESS_DOMAIN).'">'.__("Edit Field Definition").'</a>';
            }


          }
          
          $field_classes = array("mpft-".$field->type);
        
          if ($fi == $fc) {
            $field_classes[] = "mp-field-last";
          }
        
          $field_summary_classes = array();
        
          if ($field->required) {
            $field_classes[] = "required";
            $field_summary_classes[] = "required";
          }
        
          if (isset($field->summary_options["emphasise"])) {
            $field_summary_classes[] = "em";
          }
        
          $fd["name"] = $field->name;
          $fd["template_id"] = "{$info->name}_{$field->name}";
          $fd["summary_id"] = $field_summary_id."_".$i;
          $fd["field_id"] = $field_id;


        
          $fd["id_first"] = $field_id;
        
          $opts = call_user_func( array($ftc, "ui_options") );
        
          $ui = array();
        
          if (count($opts) ) {
            $ui = call_user_func_array( array($ftc, "extract_options"), array($field->type_options, $opts) );
            $ui = call_user_func_array( array($ftc, "normalize_options"), array($ui) );
          }
        
        
        
          $ui_parts = array();
        
          if (count($ui)) {
            foreach( $ui as $key => $value ) {
              $ui_parts[] = "'$key':'".esc_attr(esc_js($value))."'"; 
            } 
          }
        
          // $fd["lang"] = "{".implode(",", $lang_parts)."}";

          $fd["ui"] = "{".implode(",", $ui_parts)."}";
        
          if (isset($field->labels["tooltip_help"])) {
            $tooltip_help = trim($field->label("tooltip_help"));

            if ($tooltip_help != "") {
              $fd["label_tooltip"] = "#mptt_".$info->id."_".$field->id;
            }
          }

          if (!$field->current_user_can_edit($set->is_editable()) && !$r["preview"]) {
            $fd["readonly"] = true;
          }
        
          $strip_whitespace = !call_user_func( array($ftc, "ui_preserve_whitespace") );
        
          $ftd_args = $r;
          
          if ($set->creator) {
            
            $meow_field = new MEOW_FieldCreator($field->name, null, $field);
          
            call_user_func_array( array($ftc, "apply_default"), array($meow_field, $set, $ftc) );
            $field_ui_data = self::field_ui_template_data($set, $meow_field, $ftd_args);
            $field_ui = WOOF::render_template( self::field_ui_template(), $field_ui_data, $strip_whitespace );
          
          } else {

            // here we regard the actual field value, and build the UI from that
            $meow_field = $set->field($field->name); 

            $action = "";
          
            if (isset($_GET["action"])) {
              $action = $_GET["action"];
            }

            if (!$info->allow_multiple && $action != "edit") {
              call_user_func_array( array($ftc, "apply_default"), array($meow_field, $set, $ftc) );
            }

            $field_ui_data = self::field_ui_template_data($set, $meow_field, $ftd_args);
            $field_ui = WOOF::render_template( self::field_ui_template(), $field_ui_data, $strip_whitespace );
        
          }

          
          if ($fi == $fc) {
            if ($meow_field->blank()) {
              $set_summary_classes[] = "last-empty";
            }
        
          }
          
          $fd["field_ui"] = $field_ui;
        
        
          // now build out the summary info
        
        
          $fd["summary_width"] = call_user_func( array($ftc, "summary_width") );
        
          if (isset($field->summary_options["width"])) {
            $sw = (int) $field->summary_options["width"];
          
            if ($sw >= 1 && $sw <= 5) {
              $fd["summary_width"] = $sw;
            }
          
          }
        
        
          $max_length = ( $fd["summary_width"] * 138 ) / 10;
        
          $fd["label_truncated"] = WOOF::truncate_basic( $fd["label"], $max_length, "<span>&hellip;</span>" );
      
          if ($fd["label"] != $fd["label_truncated"]) {
            $fd["label_title"] = strip_tags($fd["label"]);
          }
        
          $label_classes = array();
        
          if (method_exists($ftc, "summary_label_classes")) {
            $label_classes = call_user_func_array( array($ftc, "summary_label_classes"), array($meow_field) );
          } 
          
          $fd["label_classes"] = implode(" ", $label_classes);
        
          $empty = $meow_field->blank();


          $fd["empty_summary"] = call_user_func_array( array($ftc, "empty_summary"), array($meow_field) );
          $fd["summary"] = call_user_func_array( array($ftc, "summary"), array($meow_field) );

          if ($empty) {
            $field_summary_classes[] = "empty";
          } else {
            $fd["is_edit"] = "is-edit";
          }
        
          $fd["classes"] = implode(" ", $field_classes);
          $fd["summary_classes"] = implode(" ", $field_summary_classes);
        
          // add the field data to the main data array
          $d["fields"][] = $fd;  
      
      
        } // endif class_exists($ftc)
    
      } // current user can see
    
    } // endforeach
      
    
    $d["set_summary_classes"] = implode(" ", $set_summary_classes);


    return $d;
    
  }
Exemple #12
0
  public function form() {
    
    global $wf;
    
    $model = MasterPress::$model;
    
    $info = MasterPress::$view;
    
    $parent = $info->parent;
    
    $post_type = null;
    
    $post_type = $info->post_type;
  
    $prefix = "";
    $default_key = "";
    $keys = array();
    
    ?>
    
    <?php if (is_object($parent)) : ?>
    <div class="title-info-panel">
      <div class="title-info-panel-lt">
        <?php if ($parent->type == 's') : ?>
        <h3><i class="metabox-share"></i><span class="label"><?php _e("Shared Field Set", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $parent->display_label() ?></span></h3> 
        <?php elseif ($parent->type == 'w') : ?>
        <h3><i class="metabox-sitemap-large"></i><span class="label"><?php _e("Site Field Set", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $parent->display_label() ?></span></h3> 
        <?php elseif ($parent->type == "p") : ?>
          
        <?php

        $prefix = $post_type->name."_"; 
        $keys = array("edit_".$post_type->capability_type."s");

        ?>
        
        <h3><i class="mp-icon mp-icon-post-type mp-icon-post-type-<?php echo $post_type->name ?>"></i><span class="label"><?php _e("Post Type", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $post_type->display_label() ?></span></h3> 
        <h3><i class="divide"></i><i class="metabox"></i><span class="label"><?php _e("Field Set", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $parent->display_label() ?></span></h3> 
        
        <?php elseif ($parent->type == 't') : ?>
        <?php
        
        $file = $parent->visibility["templates"];
        $page_templates = array_flip(get_page_templates());
        $template_name = $page_templates[$file];
        
        ?>
        <input id="templates" name="templates" type="hidden" value="<?php echo $file ?>" />
        
        <h3><i class="template"></i><span class="label"><?php _e("Template:", MASTERPRESS_DOMAIN) ?></span><span class="value"> <?php echo $template_name ?></span></h3> 
        <h3><i class="divide"></i><i class="metabox"></i><span class="label"><?php _e("Field Set", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $parent->display_label() ?></span></h3> 
        
        <?php elseif ($parent->type == 'r') : ?>
        <?php
        
        $role_name = $parent->visibility["roles"];
        $prefix = $role_name."_";
        
        ?>
        <input id="templates" name="templates" type="hidden" value="<?php echo $role_name ?>" />
        <h3><i class="user-role"></i><span class="label"><?php _e("User Role:", MASTERPRESS_DOMAIN) ?></span><span class="value"> <?php echo $role_name ?></span></h3> 
        <h3><i class="divide"></i><i class="metabox"></i><span class="label"><?php _e("Field Set", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $parent->display_label() ?></span></h3> 
        
        
        <?php elseif ($parent->type == 'x') : ?>
        <?php
        
        $taxonomy_name = $parent->visibility["taxonomies"];
        $prefix = $taxonomy_name."_";
        $tax = MPM_Taxonomy::find_by_name($taxonomy_name);

        $keys = array(
          $tax->capabilities["manage_terms"],
          $tax->capabilities["edit_terms"],
          $tax->capabilities["assign_terms"]
        );
        
        ?>
        <input id="taxonomies" name="taxonomies" type="hidden" value="<?php echo $taxonomy_name ?>" />
        <h3><i class="mp-icon mp-icon-taxonomy-<?php echo $taxonomy_name ?>"></i><span class="label"><?php _e("Taxonomy:", MASTERPRESS_DOMAIN) ?></span><span class="value"> <?php echo $tax->display_label() ?></span></h3> 
        <h3><i class="divide"></i><i class="metabox"></i><span class="label"><?php _e("Field Set", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $parent->display_label() ?></span></h3> 
        
        <?php endif; ?>
      </div>
    </div>
    <?php endif; ?>

    <?php MPV::messages(); ?>

    <div class="mpv-fields-form">
      
    <div class="f">
      <label for="name" class="icon"><i class="script-php"></i><?php _e("Name", MASTERPRESS_DOMAIN)?>:</label>
      <div class="fw">
        <input id="name_original" name="name_original" type="hidden" class="text mono key" maxlength="20" value="<?php echo $model->name ?>" />
        <input id="name_last" name="name_last" type="hidden" class="text mono key" maxlength="20" value="<?php echo $model->name ?>" />

        <input id="name" name="name" type="text" class="text mono key" maxlength="255" value="<?php echo $model->name ?>" /><em class="required">(required)</em>
        <p>
          <?php _e("This is a unique identifier for the field in the MasterPress API. Since it can be used as a PHP variable name, it is restricted to being a lowercase string with words separated by underscores.", MASTERPRESS_DOMAIN); ?>
        </p>
      </div>

    </div>
    <!-- /.f -->

    
    
    <div id="f-type" class="f clearfix">
      <label for="type" class="icon"><i class="types"></i><?php _e("Field Type", MASTERPRESS_DOMAIN)?>:</label>
      <div class="fw">
        
        
        <select id="type" name="type" class="with-icons select2-source" data-icon="mp-icon mp-icon-field-type-<?php echo $model->type ?>">
        <?php foreach (MPFT::types_by_category() as $category => $types) : ?>
        <?php if (count($types)) : ?>

        <optgroup label="<?php echo $category ?>">

        <?php foreach ($types as $type) : ?>
          <?php
            $type_class = MPFT::type_class($type);
          ?>
          <option data-icon="mp-icon mp-icon-field-type-<?php echo $type ?>" <?php echo WOOF_HTML::selected_attr($type == $model->type) ?> data-description="<?php echo addslashes(call_user_func( array($type_class, "__description") ) ) ?>" value="<?php echo $type ?>"><?php echo call_user_func( array($type_class, "__s") ) ?></option>  
        <?php endforeach; ?>
        
        </optgroup>
        
        <?php endif; ?>
        <?php endforeach; ?>
        </select>
        
        
        <p id="field-type-description"></p>
        
      </div>
    </div>
    <!-- /.f -->


    <div class="f">
      <label for="required" class="icon"><i class="warning-octagon"></i><?php _e("Required", MASTERPRESS_DOMAIN) ?>?</label>
      <div class="fw">
        <input id="required" name="required" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->required ) ?> class="checkbox" />
        <p class="checkbox-alt-label { for_el: '#required' }">
          <?php _e("A field value must be specified by the user, or the content editing form will not submit.", MASTERPRESS_DOMAIN); ?>
        </p>
      </div>
    </div>
    <!-- /.f -->
    
    <div id="f-disabled" class="f">
      <label for="disabled" class="icon"><i class="slash"></i><?php _e("Disabled", MASTERPRESS_DOMAIN) ?>?</label>
      <div class="fw">
        <input id="disabled" name="disabled" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->disabled ) ?> class="checkbox" />
        <p class="checkbox-alt-label { for_el: '#disabled' }">
          <?php _e("disabling a field will hide it from all content editing screens in WordPress, which may be <strong>preferable to deleting it</strong> completely.", MASTERPRESS_DOMAIN); ?>
        </p>
      </div>
    </div>
    <!-- /.f -->  
    
    <?php
      
      $options_form = "";
      
      $type_options = $model->type_options;
      
      if (isset($_POST["type_options"])) {
        $type_options = $_POST["type_options"];
      }
              
      if ($type_class = MPFT::type_class($model->type)) { 
        $options_form = call_user_func_array( array($type_class, "options_form"), array(MPM::array_stripslashes($type_options)) );
      }
      
    ?>
    
    <div class="fs fs-field-type-options" <?php echo $options_form == "" ? ' style="display:none;"' : '' ?>>
    
      <div class="fst">
      <div class="fstb">
        <h3><i class="switch"></i><strong><?php _e("Field Type Options", MASTERPRESS_DOMAIN) ?></strong> - <?php _e("defines the user-interface for this field", MASTERPRESS_DOMAIN) ?></h3>
      </div>
      </div>
    
        
      <div class="fsc">
      <div class="fscb">
      
        <div id="field-type-loading" class="fs-loading">Please wait&hellip;</div>
        
        <div id="field-type-options-content">
          <?php if ($type_class = MPFT::type_class($model->type)): ?>
            
          <div id="mpft-<?php echo $model->type ?>-options" class="mpft-options">
          <?php echo $options_form ?>
          </div>
          
          <?php endif; ?>
          
        </div>
        <!-- /#field-type-options-content -->
      
      </div>
      </div>

    </div>
    <!-- /.fs -->
    
        

    <div class="fs fs-labels">
    
      <div class="fst">
      <div class="fstb">
        <h3><i class="label-string"></i><strong><?php _e("Labels", MASTERPRESS_DOMAIN) ?></strong> - <?php _e("displayed throughout the WordPress administration UI", MASTERPRESS_DOMAIN) ?></h3>
      </div>
      </div>
    
        
      <div class="fsc">
      <div class="fscb">
      
        <div class="f">
          <label for="label_name"><?php _e("Field Label", MASTERPRESS_DOMAIN) ?>:</label>
          <div class="fw">
            <input id="label_name" name="labels[name]" value="<?php echo stripslashes($model->labels["name"]) ?>" type="text" class="text { tmpl: '{{name}}' }" />
            <em class="recommended">(recommended)</em>
          </div>
        </div>
        <!-- /.f -->

        <div class="f">
          <label for="label_description"><?php _e("Description", MASTERPRESS_DOMAIN)?>:</label>
          <div class="fw">
            <input id="label_description" name="labels[description]" type="text" maxlength="50" value="<?php echo stripslashes($model->label("description")) ?>" class="text" />
            <p>
              <?php _e("Appears adjacent to the label in brackets to provide a little extra information about the field.<br />For more extensive information, use <em>Tooltip Help</em>.", MASTERPRESS_DOMAIN); ?>
            </p>
          </div>
        </div>
        <!-- /.f -->

        <div class="f">
          <label for="label_tooltip_help"><?php _e("Tooltip Help", MASTERPRESS_DOMAIN)?>:</label>
          <div class="fw">
            <textarea id="label_tooltip_help" name="labels[tooltip_help]"><?php echo stripslashes($model->label("tooltip_help")) ?></textarea>
            <p>
              <?php _e("Provides more extensive help for this field through a tooltip, revealed by mousing over a question-mark badge adjacent to the field label", MASTERPRESS_DOMAIN); ?>
            </p>
          </div>
        </div>
        <!-- /.f -->
    
        
      
      </div>
      </div>

    </div>
    <!-- /.fs .fs-labels -->
    
    
    
    
    
    <?php
    
      
    $args = array();

    $args["supports"] = array();

    // $args["supports"][] = "fields"; COMING SOON

    $fields = $parent->fields();
    
    $fields_to_use = array();
    
    foreach ($fields as $field) {
      if ($field->id != $model->id) {
        $fields_to_use[] = $field;
      }
    }
    
    $args["fields"] = $fields_to_use;


    
    if (is_multisite()) {
      $args["supports"][] = "multisite";
    }
    
    if ($parent->is_shared()) {
      $args["supports"][] = "post_types";
      $args["supports"][] = "roles";
      $args["supports"][] = "taxonomies";
      $args["supports"][] = "templates";
    }
    
    $args["labels"] = array(
      "title" =>  __("control the visibility of this field within WordPress", MASTERPRESS_DOMAIN),   
      "title_multisite" =>  __("specify the sites in the multisite network that this field is available in", MASTERPRESS_DOMAIN),   
      "title_post_types" =>  __("specify the post types that this field is available in", MASTERPRESS_DOMAIN),   

      "templates_all" => sprintf( __( "All Templates <span>( that the <em>%s</em> field set is available in )</span>" ), $parent->display_label() ),
      "multisite_all" => sprintf( __( "All Sites <span>( that the <em>%s</em> field set is available in )</span>" ), $parent->display_label() ),
      "post_types_all" => sprintf( __( "All Post Types <span>( that the <em>%s</em> field set is available in )</span>" ), $parent->display_label() ),
      "roles_all" => sprintf( __( "All User Roles <span>( that the <em>%s</em> field set is available in )</span>" ), $parent->display_label() ),
      "taxonomies_all" => sprintf( __( "All Taxonomies <span>( that the <em>%s</em> field set is available in )</span>" ), $parent->display_label() )
    );

    $args["defaults"] = array(
      "taxonomies" => "all",
      "roles" => "all",
      "post_types" => "all",
      "multisite" => "all"
    );
  
    $args["post_types"] = $parent->post_types();
    
    if (isset($parent) && is_multisite()) {
      
      $site_options = array();
      
      foreach ($parent->sites() as $site) {
        $site_options[$site->full_path()] = $site->id();
      }
      
      $args["sites"] = $site_options;
      
    };
    
    // filter the available roles
    $roles = $parent->vis("roles");
    
    if ($roles != "" && $roles != "*") {
      $role_names = explode(",", $roles);
      
      $rc = array();
      
      foreach ($role_names as $role_name) {
        $rc[] = $wf->role($role_name);  
      }
      
      $args["roles"] = new WOOF_Collection($rc);
    }
    
    MPV::fs_visibility( $model, $args ); 
  
    ?>
    
    
    <div class="fs fs-capability-keys clearfix">
    
      <div class="fst">
      <div class="fstb">
        <h3><i class="key"></i><strong><?php _e("Capabilities", MASTERPRESS_DOMAIN) ?></strong> - <?php _e('the keys used to control access to this field', MASTERPRESS_DOMAIN) ?></h3>
      </div>
      </div>
    
      <div class="fsc">
      <div class="fscb clearfix">
      
      <div class="f f-capabilities f-capabilities-editable clearfix">
          <label for="label-capabilities-editable"><?php _e("Editable", MASTERPRESS_DOMAIN) ?>:</label>
          <div class="fw">
            
            <?php 
            
              $val = $model->capability("editable", false);
              $custom_val = "";

              $caps = array_unique(array_merge($keys, array("edit_posts", "edit_pages", "edit_".$prefix.$parent->name)));
              
              $caps = array( __("-- None (Same as Field Set) --", MASTERPRESS_DOMAIN) => "" ) + $caps;
              
              if (MPC::is_edit()) {
                $caps[] = "edit_".$prefix.$parent->name."_".$model->name;
              }


              if (!in_array($val, $caps)) {
                $custom_val = $val;
              } 
              
              echo WOOF_HTML::select( array("id" => "capabilities-editable", "name" => "capabilities[editable]", "class" => "capabilities" ), 
                $caps,
                $val
              );
      
            ?>
            
            <label for="capabilities-editable-custom" class="capabilities-custom"><?php _e("OR custom value") ?></label>
            <input id="capabilities-editable-custom" name="capabilities_custom[editable]" value="<?php echo $custom_val ?>" type="text" class="text mono capabilities-custom" />

            <p class="note">
              <?php _e("This field will be read-only for users without this capability", MASTERPRESS_DOMAIN) ?>
            </p>
          </div>
        </div>
        <!-- /.f -->
        
        <div class="f f-capabilities f-capabilities-visible clearfix">
          <label for="label-capabilities-visible"><?php _e("Visible", MASTERPRESS_DOMAIN) ?>:</label>
          <div class="fw">
            
            <?php 
            
              $val = $model->capability("visible", false);
              
              $caps = array_unique(array_merge($keys, array("edit_posts", "edit_pages", "view_".$prefix.$parent->name)));
              
              $caps = array( __("-- None (Same as Field Set) --", MASTERPRESS_DOMAIN) => "" ) + $caps;
              
              if (MPC::is_edit()) {
                $caps[] = "view_".$prefix.$parent->name."_".$model->name;
              }

              $custom_val = "";
              
              if (!in_array($val, $caps)) {
                $custom_val = $val;
              } 

              echo WOOF_HTML::select( array("id" => "capabilities-visible", "name" => "capabilities[visible]", "class" => "capabilities" ), 
                $caps,
                $val
              );
      
            ?>
            
            <label for="capabilities-visible-custom" class="capabilities-custom"><?php _e("OR custom value") ?></label>
            <input id="capabilities-visible-custom" name="capabilities_custom[visible]" value="<?php echo $custom_val ?>" type="text" class="text mono capabilities-custom" />
            
            <p class="note">
              <?php _e("This field will be invisible for users without this capability", MASTERPRESS_DOMAIN) ?>
            </p>
          </div>
        </div>
        <!-- /.f -->

        
      
      </div>
      </div>

    </div>
    <!-- /.fs -->
    

    <div class="fs fs-summary-options clearfix">
    
      <div class="fst">
      <div class="fstb">
        <h3><i class="set-summary"></i><strong><?php _e("Summary Options", MASTERPRESS_DOMAIN) ?></strong> - <?php _e('settings for the collapsed summary display', MASTERPRESS_DOMAIN) ?></h3>
      </div>
      </div>
    
      <div class="fsc">
      <div class="fscb clearfix">
        

      <div class="f">
        <label for="summary_options_emphasise"><?php _e("Emphasise", MASTERPRESS_DOMAIN) ?>?</label>
        <div class="fw">
          <input id="summary_options_emphasise" name="summary_options[emphasise]" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( isset($model->summary_options["emphasise"]) && $model->summary_options["emphasise"] ) ?> class="checkbox" />
          <p class="checkbox-alt-label { for_el: '#summary_options_emphasise' }">
            <?php _e("Show the summary for this field in <strong>bold text</strong>, which may often be appropriate for the first field in a set, or for other important fields in your content.", MASTERPRESS_DOMAIN); ?>
          </p>
        </div>
      </div>
      <!-- /.f -->

      <div class="f f-summary_width">
        <label for="summary_options_width"><?php _e("Block Width", MASTERPRESS_DOMAIN) ?>?</label>
        <div class="fw">
          <input id="summary_options_width" name="summary_options[width]" type="text" maxlength="1" value="<?php echo isset($model->summary_options["width"]) ? $model->summary_options["width"] : "" ?>" class="text" />
          <p class="note">
            <?php _e("Override block width of the summary, when the field's set is collapsed (min value 1, max value 5)<br />Leave this value empty to use the block width recommended by the field type<br />The pixel width of the summary will be the value here x 150.", MASTERPRESS_DOMAIN); ?>
          </p>
        </div>
      </div>
      <!-- /.f -->

      <div class="f clearfix">
        <label id="label-icon" for="icon"><?php _e("Icon (16 x 16)", MASTERPRESS_DOMAIN) ?>:</label>
        <div class="fw">

          <div id="icon-file-uploader" class="icon-uploader file-uploader { ids: { drop: 'icon_drop_area' }, input: '#icon', inputName: 'icon_ul', base_url: '<?php echo MASTERPRESS_GLOBAL_CONTENT_URL ?>', params: { dir: 'menu-icons/' }, limit: 1, lang: { buttonChoose: '<?php _e("Choose from Computer&hellip;", MASTERPRESS_DOMAIN) ?>', buttonReplace: '<?php _e("Replace file&hellip;", MASTERPRESS_DOMAIN) ?>' } }">
          
            <div id="icon_drop_area" class="drop-area"><?php _e("Drop file here to upload", MASTERPRESS_DOMAIN) ?></div>

            <?php 
          
          
            $file_name = $model->icon;
            $file_class = "";
            $preview_class = "";
            $clear_class = "";
          
            if ($file_name == "") {
              $file_name = __("( None )", MASTERPRESS_DOMAIN);
              $file_class = "name-none";
              $preview_class = "preview-none";
              $clear_class = "hidden";
              $style = "";
            } else {
              $style = ' style="background-image: url('.MPU::field_set_icon_url($model->icon).')" ';
            }
          
          
            ?>
          
            <div class="file">
              <span class="preview <?php echo $preview_class ?>" <?php echo $style ?>></span><span data-none="<?php echo __("( None )", MASTERPRESS_DOMAIN) ?>" class="name <?php echo $file_class ?>"><?php echo $file_name ?></span>
              <button type="button" class="<?php echo $clear_class ?> clear ir" title="<?php _e("Clear", MASTERPRESS_DOMAIN) ?>">Clear</button>
            </div>
          
            <input id="icon" name="icon" value="<?php echo $model->icon ?>" type="hidden" />
            <div class="uploader-ui"></div>
          
          </div>
          <!-- /.file-uploader -->
        
          <?php MPV::icon_select($model->icon, "menu-icon-select", "icon_select", "icon-file-uploader"); ?>
        

        </div>
      </div>
      <!-- /.f -->
                
            
      
      </div>
      </div>

    </div>
    <!-- /.fs -->
    
    

    <?php
    
      // build a field list
      
      $fields = $parent->fields();
    
    ?>
    
    
    <?php if ( ( MPC::is_edit() && count($fields) > 1) || (MPC::is_create() && count($fields) > 0) ) : ?>
      
    <div id="f-position" class="f clearfix">
      <p class="label label-icon icon position"><?php _e("Position in set", MASTERPRESS_DOMAIN)?>:</p>
      <div class="fw">

          <div class="sortable-list sortable-list-fields">
            <span class="arrow"></span>
            
            <?php
            
            // build a field list
            
            $sort_fields = array();
            
            // now build a representable list of fields
            
                
            foreach ($fields as $field) {
              
              $position = $field->position;
            
              if (isset($_POST["other_position"]) && isset($_POST["other_position"][$field->id])) {
                $position = $_POST["other_position"][$field->id];
              }

              if ($ftc = MPFT::type_class($field->type)) {
                $sort_fields[] = array( "position" => $position, "disabled" => (bool) $field->disabled, "current" => $field->id == $model->id, "label" => $field->display_label(), "type" => $field->type, "id" => $field->id );
              }
            }
            
            if (MPC::is_create()) {
              $label = $model->display_label();
              
              if (!$label || $label == "") {
                $label = "?";
              }
            
            
              $sort_fields[] = array( "position" => $model->position, "disabled" => (bool) $field->disabled, "current" => true, "label" => $model->display_label(), "type" => $model->type );

            }
            
            $count = 0;
            
            ?>
            
            <ul>
              <?php foreach ($sort_fields as $f) : $count++; $first = $count == 1 ? "first " : ""; $current = $f["current"] ? 'current ' : '';  ?>

              <?php
                $disabled = $f["disabled"] ? 'disabled' : '';
                $disabled_title = $f["disabled"] ? __("This field is disabled", MASTERPRESS_DOMAIN) : '';
              ?>

              <li class="<?php echo $first.$current ?>  <?php echo $disabled ?>" title="<?php echo $disabled_title ?>">
                <span class="icon mp-icon mp-icon-field-type-<?php echo $f["type"] ?>"></span>
                <?php if ($f["current"]) : ?>
                <span class="fill { src: '#label_name'}"><?php echo $f["label"] ?></span>
                <input id="position" name="position" value="<?php echo $f["position"] ?>" type="hidden" />
                <?php else: ?>
                <span><?php echo $f["label"] ?></span>
                <input id="other_position_<?php echo $f["id"] ?>" name="other_position[<?php echo $f["id"] ?>]" value="<?php echo $f["position"] ?>" type="hidden" />
                <?php endif; ?>
              </li>
              <?php endforeach; ?>
            </ul>
            
          </div>
          <!-- /.sortable-list -->
          
        <p>
          <?php printf(__("Drag field to the desired position in the %s set.<br />Note: changes to the positions of other fields will also be saved.", MASTERPRESS_DOMAIN), '<em>'.$parent->display_label().'</em>') ?>
        </p>
      </div>
    </div>
    <!-- /.f -->
    
    <?php else: ?>
    <input id="position" name="position" value="1" type="hidden" />
    <?php endif; ?>
    
    
    
    </div>
    <!-- /.mpv-fields-form -->
    
    <?php
  } // end form()
Exemple #13
0
  public function load_prop($name, $value, $field) {

    if ($type_class = MPFT::type_class($field->type)) {
      return MPU::db_decode( call_user_func_array( array($type_class, "prop_from_load"), array($name, $value, $field)) );
    }
  
    return MPU::db_decode($value);
  }
Exemple #14
0
  public static function save_meta($object_id, $object_type) {
    
    global $wpdb, $meow_provider;
    global $wf;
    
    do_action("mp_pre_save_meta", $object_id, $object_type);
    
    if (apply_filters("mp_do_save_meta", $do = true, $object_id, $object_type)) { 
    
      MPM::incl("field");

      $object_type_type = "";
    
      $current_data = array();

      if ($object_type == "post") {

        // check the edit post meta cap for this type
      
        $cap = "edit_post";
      
        $post = $wf->post($object_id);

      
        if ($post->exists()) {
          $type = $post->type();
      
          $cap = $type->cap("edit_post", "edit_post");
      
          // update the template meta
        
          if ($type->supports("mp-page-attributes")) {
            if (isset($_POST["page_template"])) {
              $template = $_POST["page_template"];
            
              if ($template == "") {
                delete_post_meta($object_id, "_wp_page_template");
              } else {
                update_post_meta($object_id, "_wp_page_template", $template);
              }
            }
          
          }
        
        }
      
        if ( !current_user_can( $cap, $object_id ) ) {
          return $object_id;
        }

      
      } else if ($object_type == "term") {
      
        // check the edit terms cap for the taxonomy
        $cap = "manage_categories";

        $taxonomy_name = self::infer_taxonomy_name();
        $tax = $wf->taxonomy($taxonomy_name);
      
        $object_type_type = $taxonomy_name;
      
        if ($tax->exists()) {
          $cap = $tax->cap("edit_terms", "manage_categories");
        }
    
        if ( !current_user_can( $cap ) ) {
          return $object_id;
        }
      } else if ($object_type == "user") {
        if ( !current_user_can( 'edit_users' ) ) {
          return $object_id;
        }
      } else if ($object_type == "site") {
        if ( !current_user_can( 'edit_posts' ) ) {
          return $object_id;
        }
      }
  
      $meta = self::post_val('mp_meta', array());
      $meta_order = self::post_val('mp_meta_order', array());
      $meta_model = self::post_val('mp_meta_model', array());
      $meta_prop = self::post_val('mp_meta_prop', array());
      $meta_field_ids = self::post_val('mp_meta_field_ids', array());

      $meta_dirty = self::post_val('mp_meta_dirty', array());
      $meta_versions = self::post_val('mp_meta_versions', array());

      $field_models = array();
    
      if (is_array($meta_field_ids)) {
        $meta_field_ids = array_unique($meta_field_ids);
      
        $results = MPM_Field::find_by_id_in($meta_field_ids);
      
        foreach ($results as $field) {
          $field_models[$field->id] = $field;
        }
      
      }
    
      $wpdb->show_errors();
    
      if (isset($_POST["mp_meta_model"])) {
      
        if ($object_type == "post") {
          if ( $the_post = wp_is_post_revision( $object_id ) ) {
            $object_id = $the_post;
          }
        } 

        try {
          $meow_provider->create_version($object_id, $object_type, $object_type_type, "initial", $meta_versions);
        } catch( Exception $e) {
          // silently catch, we REALLY don't want this to prevent a data save if something goes wrong!
        }
      
        /* Delete the old post meta */

        foreach ( $meta_model as $set_name => $fields ) {
        
          foreach ($fields as $field_name => $model_id) {
            $field = $field_models[$model_id];
          
            $meta_name = $set_name.".".$field_name;

            self::delete_object_meta($object_type, $object_id, $meta_name);
        
            // now go through the properties too

            $dont_care = MPFT::type_class($field->type);
          
            foreach (MPFT::type_properties($field->type) as $prop) {
              self::delete_object_meta($object_type, $object_id, $meta_name.":".$prop);
            }
             
          
          }
        
        }

        $model_id_prop_stored = array();
      
        // Create the new values
        foreach( $meta as $set_name => $set_items ) {
        
          $set_index = 0;
        
          if (is_array($set_items)) {
        
            foreach ($set_items as $fields) {

              $set_index++;

          
              foreach ($fields as $field_name => $value) {
            
                // here the field type should prepare the value, if necessary
            
                // grab the type
            
                $model_id = $meta_model[$set_name][$field_name];
            
                $model = $field_models[$model_id];
            
                $val = MPU::db_encode($value);
            
                if ($model) {
              
                  if ($type_class = MPFT::type_class($model->type)) {
                    $val = MPU::db_encode(call_user_func_array( array($type_class, "value_for_save"), array($value, $model)));
                  }
            
                  // create the post meta
              
                  $meta_name = MPFT::meta_key($set_name, $field_name);
              
                  self::add_object_meta($object_type, $object_id, "{$meta_name}", $val);

                  // now store the properties
              
                  foreach (MPFT::type_properties($model->type) as $prop) {

                    if ($prop == "field_id" && !isset($model_id_prop_stored[$model_id])) {
                      $model_id_prop_stored[$model_id] = true;

                      self::add_object_meta($object_type, $object_id, "{$meta_name}:{$prop}", $model_id);
                  
                    } else {
                  
                      $prop_set_index = $meta_order[$set_name][$set_index];

                      if (isset($meta_prop[$set_name][(int) $prop_set_index][$field_name][$prop])) {
                        $prop_value = $meta_prop[$set_name][(int) $prop_set_index][$field_name][$prop];
                      }
                  
                      if (isset($prop_value)) {
                        self::add_object_meta($object_type, $object_id, "{$meta_name}:{$prop}", $prop_value);
                      }
                  
                    }

                  }
          
              
                }
            
              } // endforeach $fields
          
          
              // fill in blanks for any values that weren't submitted (this happens with checkboxes that are not checked)
          
              foreach ($meta_model[$set_name] as $field_name => $model_id) {
                if (!isset($fields[$field_name])) {
                  $meta_name = MPFT::meta_key($set_name, $field_name);
                  self::add_object_meta($object_type, $object_id, "{$meta_name}", "");
              
                  // now store the properties for blanks (if required)
              
                  foreach (MPFT::type_properties($field->type) as $prop) {

                    if ($prop == "field_id" && !isset($model_id_prop_stored[$model_id])) {
                      $model_id_prop_stored[$model_id] = true;
                      self::add_object_meta($object_type, $object_id, "{$meta_name}:{$prop}", $model_id);

                    } else {
                  
                      if (isset($meta_prop[$set_name][$set_index][$field_name][$prop])) {
                        $prop_value = $meta_prop[$set_name][$set_index][$field_name][$prop];
                        self::add_object_meta($object_type, $object_id, "{$meta_name}:{$prop}", $prop_value);
                      }
                  
                    }

                  }

              
                }

              }

          
            } 

    
          } // endif is_array(set_items)


        } // foreach $set_name => $set_items


        // create the current content version

        if (!self::$version_saved) {
          try {
            $meow_provider->create_version($object_id, $object_type, $object_type_type, $meta_dirty, $meta_versions);
          } catch( Exception $e) {
          
            // silently catch, we REALLY don't want this to prevent a data save if something goes wrong!
          }

          self::$version_saved = true;
        }
      
      } // isset $_POST["mp_meta_model"]
    
    }
  
    do_action("mp_after_save_meta", $object_id, $object_type);

    
  }
Exemple #15
0
  public static function fs_visibility($model, $args = array()) {
  
    global $wf;
    
    $first = true;
    
    $r = array(
      "sites" => null,
      "templates" => null,
      "post_types" => null,
      "taxonomies" => null,
      "fields" => null,
      "roles" => null      
    );
    
    $r["labels"] = wp_parse_args(
      
      $args["labels"], 
      array(
          "title" => __("control the visibility of this object in your site", MASTERPRESS_DOMAIN),
          "title_multisite" => __("specify the network sites that this object is available in", MASTERPRESS_DOMAIN),   
          "title_post_types" => __("specify the post types that this object is available in", MASTERPRESS_DOMAIN),   
          "title_templates" => __("specify the templates that this object is available in", MASTERPRESS_DOMAIN),   
          "title_roles" => __("specify the user roles that this object is available in", MASTERPRESS_DOMAIN),   
          "title_taxonomies" => __("specify the taxonomies that this object is available in", MASTERPRESS_DOMAIN),   
          "title_fields" => __("control display of this field based on the value of another field in the set", MASTERPRESS_DOMAIN),   

          "radio_multisite" => __("Make avalable in:", MASTERPRESS_DOMAIN),

          "multisite_all" => __('<em class="all">All</em> sites in the network', MASTERPRESS_DOMAIN),   
          "multisite_allow" => __( '<em class="allow">Include</em> only in specific Sites'),
          "multisite_deny" => __( '<em class="deny">Exclude</em> from specific Sites'),
          "multisite_allow_note" => "",       
          "multisite_deny_note" => "",        

          "post_types_all" => __('<em class="all">All</em> Post Types', MASTERPRESS_DOMAIN),
          "post_types_none" => __('<em class="none">No</em> Post Types', MASTERPRESS_DOMAIN),
          "post_types_allow" => __('<em class="allow">Include</em> only in specific Post Types', MASTERPRESS_DOMAIN),
          "post_types_deny" => __('<em class="deny">Exclude</em> from specific Post Types', MASTERPRESS_DOMAIN),

          "templates_all" => __('<em class="all">All</em> Templates', MASTERPRESS_DOMAIN),
          "templates_allow" => __('<em class="allow">Include</em> only in specific Templates', MASTERPRESS_DOMAIN),
          "templates_deny" => __('<em class="deny">Exclude</em> from specific Templates', MASTERPRESS_DOMAIN),

          "roles_all" => __('<em class="all">All</em> User Roles', MASTERPRESS_DOMAIN),
          "roles_none" => __('<em class="none">No</em> User Roles', MASTERPRESS_DOMAIN),
          "roles_allow" => __('<em class="allow">Include</em> only in specific Roles', MASTERPRESS_DOMAIN),
          "roles_deny" => __('<em class="deny">Exclude</em> from specific Roles', MASTERPRESS_DOMAIN),
          
          "taxonomies_all" => __('<em class="all">All</em> Taxonomies', MASTERPRESS_DOMAIN),
          "taxonomies_none" => __('<em class="none">No</em> Taxonomies', MASTERPRESS_DOMAIN),
          "taxonomies_allow" => __('<em class="allow">Include</em> only in specific Taxonomies', MASTERPRESS_DOMAIN),
          "taxonomies_deny" => __('<em class="deny">Exclude</em> from specific Taxonomies', MASTERPRESS_DOMAIN),
          
          "fields_all" => __('No conditions', MASTERPRESS_DOMAIN),
          "fields_allow" => __('When another field <em class="allow">has a specific value</em>', MASTERPRESS_DOMAIN),
          "fields_deny" => __('When another field <em class="deny">does not have a specific value</em>', MASTERPRESS_DOMAIN)

      )
    );
    
    $r["supports"] = wp_parse_args($args["supports"], array());
    
    $r["defaults"] = wp_parse_args(
      $args["defaults"], 
      array(
        "multisite"   => "all",
        "post_types"  => "none",
        "templates"   => "all",
        "roles"       => "none",
        "taxonomies"  => "none",
        "fields"      => "all"
      )
    );

    
    if (isset($args["sites"])) {
      $r["sites"] = $args["sites"];
    }
    
    if (isset($args["templates"])) {
      $r["templates"] = $args["templates"];
    }
    
    if (isset($args["post_types"])) {
      $r["post_types"] = $args["post_types"];
    }
    
    if (isset($args["taxonomies"])) {
      $r["taxonomies"] = $args["taxonomies"];
    }
  
    if (isset($args["roles"])) {
      $r["roles"] = $args["roles"];
    }
    
    if (isset($args["fields"])) {
      $r["fields"] = $args["fields"];
    }
    
    if (is_array($r["sites"])) {
      $r["sites"] = implode(",", $r["sites"]);
    }

    if (is_array($r["templates"])) {
      //$r["templates"] = implode(",", $r["templates"]);
    }

    $supports = $r["supports"];
    $labels = $r["labels"];
    
    if ($r["supports"] && count($r["supports"])) :
  ?>
  
    <div class="fs fs-visibility clearfix">
      
      <div class="fst">
      <div class="fstb">
        <h3><i class="light-globe"></i><strong><?php _e("Availability", MASTERPRESS_DOMAIN) ?></strong> - <?php echo $labels["title"] ?></h3>
      </div>
      </div>
    
      <div class="fsc">
      <div class="fscb clearfix">

        <?php if (in_array("fields", $supports)) : ?>
        
        <?php $mode = self::visibility_mode($model->visibility, "fields", $r["defaults"]["fields"]); ?>
        
        <?php
        
        $fo = array("");
        $fo_attr = array(array());
        
        foreach ($r["fields"] as $field) {

          if ($type_class = MPFT::type_class($field->type)) {
            $fo[$field->display_label()] = $field->name;
            $fo_attr[] = array("class" => "mp-icon field-type-".$field->type);
          } 

        }
        
        $fields_select = WOOF_HTML::select(array("style" => "max-width: 280px", "id" => "visibility-fields", "name" => "visibility_fields", "class" => "with-icons select2-source", "data-placeholder" => __("-- Select a Field --", MASTERPRESS_DOMAIN)), $fo, "", $fo_attr);

        ?>

        <div class="fsg fsg-fields <?php echo $first ? "" : "divider" ?>">
              
          <h4><i class="question-octagon"></i><?php _e("Conditional Display", MASTERPRESS_DOMAIN) ?><span>&nbsp;&nbsp;-&nbsp;&nbsp;<?php echo $labels["title_fields"] ?></span></h4>

          <div class="f clearfix">
            
            <div class="fsg-radios">
              
            <div class="fw fwl fw-all">
              <input id="visibility-type-fields-all" name="visibility_type[fields]" type="radio" value="all" <?php echo WOOF_HTML::checked_attr( $mode == "all" ) ?> class="radio" />
              <label for="visibility-type-fields-all" class="radio"><?php echo $labels["fields_all"] ?></label>
            </div>
            <!-- /.fw -->

            <div class="fw fwl fw-none">
              <input id="visibility-type-fields-allow" name="visibility_type[fields]" type="radio" value="none" <?php echo WOOF_HTML::checked_attr( $mode == "allow" ) ?> class="radio" />
              <label for="visibility-type-fields-allow" class="radio"><?php echo $labels["fields_allow"] ?></label>
            </div>
            <!-- /.fw -->

            <div class="fw fwl fw-none">
              <input id="visibility-type-fields-deny" name="visibility_type[fields]" type="radio" value="none" <?php echo WOOF_HTML::checked_attr( $mode == "deny" ) ?> class="radio" />
              <label for="visibility-type-fields-deny" class="radio"><?php echo $labels["fields_deny"] ?></label>
            </div>
            <!-- /.fw -->

            </div>
            <!-- /.fsg-radios -->
          
            <div id="visibility-fields-options">
            
              <div id="fw-field" class="fw">
                <label for="visibility-fields" class="select2"><?php _e("Field:", MASTERPRESS_DOMAIN) ?></label>
                <?php echo $fields_select ?>
              </div>

              <div id="fw-value" class="fw">
                <label for="visibility-fields-value"><?php _e("Value:", MASTERPRESS_DOMAIN) ?></label>
                <textarea name="visibility_fields_value" class="mono"></textarea>
              </div> 
               
            
            </div>
            
          </div>
          <!-- /.f -->
        
        </div>
        <!-- /.fsg -->
        
        
        
        
        <?php $first = false; ?>
        
        <?php endif; ?>
        
        <?php if (in_array("post_types", $supports)) : ?>

          <?php
          
          if (is_null($r["post_types"])) {
            $available_post_types = MPM_PostType::find(array("orderby" => "name ASC"));
          } else {
            $available_post_types = $r["post_types"];
          }
          
          $mode = self::visibility_mode($model->visibility, "post_types", $r["defaults"]["post_types"]);
          
          ?>
          
          <div class="fsg fsg-post-types <?php echo $first ? "" : "divider" ?>">
              
          <h4><i class="pins"></i><?php _e("Post Types", MASTERPRESS_DOMAIN) ?><span>&nbsp;&nbsp;-&nbsp;&nbsp;<?php echo $labels["title_post_types"] ?></span></h4>

          <div class="f clearfix">
            
            <div class="fsg-radios">
              
            <div class="fw fwl fw-all">
              <input id="visibility-type-post-types-all" name="visibility_type[post_types]" type="radio" value="all" <?php echo WOOF_HTML::checked_attr( $mode == "all" ) ?> class="radio" />
              <label for="visibility-type-post-types-all" class="radio"><?php echo $labels["post_types_all"] ?></label>
            </div>
            <!-- /.fw -->

            <div class="fw fwl fw-none">
              <input id="visibility-type-post-types-none" name="visibility_type[post_types]" type="radio" value="none" <?php echo WOOF_HTML::checked_attr( $mode == "none" ) ?> class="radio" />
              <label for="visibility-type-post-types-none" class="radio"><?php echo $labels["post_types_none"] ?></label>
            </div>
            <!-- /.fw -->
            
            <?php if (count($available_post_types)) : ?>
        

            <div class="fw fwl">
              <input id="visibility-type-post-types-allow" name="visibility_type[post_types]" type="radio" value="allow" <?php echo WOOF_HTML::checked_attr( $mode == "allow" ) ?> class="radio" />
              <label for="visibility-type-post-types-allow" class="radio"><?php echo $labels["post_types_allow"] ?></label>
            </div>
            <!-- /.fw -->

            <div class="fw fwl">
              <input id="visibility-type-post-types-deny" name="visibility_type[post_types]" type="radio" value="deny" <?php echo WOOF_HTML::checked_attr( $mode == "deny"  ) ?> class="radio" />
              <label for="visibility-type-post-types-deny" class="radio"><?php echo $labels["post_types_deny"] ?></label>
            </div>
            <!-- /.fw -->

            </div>
            <!-- /.fsg-radios -->

            
            <div id="visibility-post-types-list" class="list checkbox-list">
          
              
              <div class="items">
              <?php foreach ($available_post_types as $post_type) : $disabled = $post_type->disabled ? ' disabled' : ''; $disabled_title = $post_type->disabled ? __("This post type is disabled", MASTERPRESS_DOMAIN) : ''; $builtin = $post_type->_builtin ? '&nbsp;'.__('(Built-in)', MASTERPRESS_DOMAIN) : ''; ?>
              <?php
      
                $linked_to_post_type = false;

                // todo, update this code to use visibility

                if (MPC::is_edit()) {
                  $linked_to_post_type = $model->linked_to_post_type($post_type);
                }

                $checked = $linked_to_post_type;


                if ($mode == "deny") {
                  $checked = !$checked;
                } 
                
              ?>
            
              <?php if ($post_type->still_registered()) : ?>
            
              <div class="fw">
                <input id="visibility-post-types-<?php echo $post_type->name ?>" name="visibility_post_types[]" value="<?php echo $post_type->name ?>" type="checkbox" <?php echo WOOF_HTML::checked_attr( $checked || MPV::in_post_array("post_types", $post_type->name) ) ?> class="checkbox" />
                <label for="visibility-post-types-<?php echo $post_type->name ?>" class="checkbox <?php echo $disabled ?>" title="<?php echo $disabled_title ?>"><?php echo $post_type->labels["name"] ?><span><?php echo $builtin ?></span></label>
              </div>
              <!-- /.fw -->
              
              <?php endif; ?>
            
              <?php endforeach; ?>
      
              </div>
              <!-- /.items -->
              

              <div class="controls">
                <button type="button" class="button list-select-all"><?php _e("Select All", MASTERPRESS_DOMAIN) ?></button>
                <button type="button" class="button list-select-none"><?php _e("Select None", MASTERPRESS_DOMAIN) ?></button>
              </div>
              <!-- /.controls -->
      
          
            </div>
            <!-- /#visibility-post-types -->
              
            <?php endif; ?>
          
          </div>
          <!-- /.f -->
          
          </div>
          <!-- /#fsg-post-types --> 
                  
        <?php $first = false; ?>
          
        
        <?php endif; // supports post_types ?>
        
        
        <?php if (in_array("templates", $supports)) : ?>
          
          <?php
          
          if (is_null($r["templates"])) {
            $available_templates = array_merge( array("Page" => "page.php"), get_page_templates() ); 
          } else {
            $available_templates = $r["templates"];
          }
          
          $mode = self::visibility_mode($model->visibility, "templates", $r["defaults"]["templates"]);
          
          ?>
          
          <div class="fsg fsg-templates <?php echo $first ? "" : "divider" ?>">
              
          <h4><i class="template"></i><?php _e("Templates", MASTERPRESS_DOMAIN) ?><span>&nbsp;&nbsp;-&nbsp;&nbsp;<?php echo $labels["title_templates"] ?></span></h4>

          <div class="f clearfix">

            <div class="fsg-radios">

            <div class="fw fwl fw-all">
              <input id="visibility-type-templates-all" name="visibility_type[templates]" type="radio" value="all" <?php echo WOOF_HTML::checked_attr( $mode == "all" ) ?> class="radio" />
              <label for="visibility-type-templates-all" class="radio"><?php echo $labels["templates_all"] ?></label>
            </div>
            <!-- /.fw -->
            
            <div class="fw fwl">
              <input id="visibility-type-templates-allow" name="visibility_type[templates]" type="radio" value="allow" <?php echo WOOF_HTML::checked_attr( $mode == "allow" ) ?> class="radio" />
              <label for="visibility-type-templates-allow" class="radio"><?php echo $labels["templates_allow"] ?></label>
            </div>
            <!-- /.fw -->

            <div class="fw fwl">
              <input id="visibility-type-templates-deny" name="visibility_type[templates]" type="radio" value="deny" <?php echo WOOF_HTML::checked_attr( $mode == "deny" ) ?> class="radio" />
              <label for="visibility-type-templates-deny" class="radio"><?php echo $labels["templates_deny"] ?></label>
            </div>
            <!-- /.fw -->

            </div>
            <!-- /.fsg-radios -->
            
            <div id="visibility-templates-list" class="list checkbox-list">
          
              <?php if (count($available_templates)) : ?>

              <div class="items">
                
              <?php
              $templates = $model->vis("templates");
              $not_templates = $model->vis("not_templates");
              ?>
                
              <?php foreach ($available_templates as $name => $file) : ?>
                
              <?php 
                

              if ($mode == "deny") {
                $checked = MPV::in_csv($file, $not_templates);
              } else {
                $checked = MPV::in_csv($file, $templates);
              }
              
              ?>
              
              <div class="fw">
                <input id="templates_<?php echo WOOF_Inflector::underscore($file) ?>" name="visibility_templates[]" value="<?php echo $file ?>" type="checkbox" <?php echo WOOF_HTML::checked_attr( $checked ) ?> class="checkbox" />
                <label for="templates_<?php echo WOOF_Inflector::underscore($file) ?>" class="checkbox"><span class="tt"><?php echo $file ?></span></label>
              </div>
              <?php endforeach; ?>
      
              </div>
              <!-- /.items -->
              

              <div class="controls">
                <button type="button" class="button list-select-all"><?php _e("Select All", MASTERPRESS_DOMAIN) ?></button>
                <button type="button" class="button list-select-none"><?php _e("Select None", MASTERPRESS_DOMAIN) ?></button>
              </div>
              <!-- /.controls -->
              
              <?php else: ?>
            
              <span class="soft-warning"><i class="warning-triangle"></i><?php sprintf( __("The Field Set <em>%s</em> is not yet associated with <em>any</em> field types, so this option is not yet available", MASTERPRESS_DOMAIN), $parent->display_label() ); ?></span>
            
              <?php endif; ?>
          
            </div>
            <!-- /#visibility-templates -->
          
          </div>
          <!-- /.f -->
          
          </div>
          <!-- /#fsg-templates --> 
                  
        <?php $first = false; ?>
        <?php endif; // supports templates ?>
        
        
        <?php if (in_array("taxonomies", $supports)) : ?>

          <?php
          
          if (is_null($r["taxonomies"])) {
            $available_taxonomies = MPM_Taxonomy::find();
          } else {
            $available_taxonomies = $r["taxonomies"];
          }
          
          $mode = self::visibility_mode($model->visibility, "taxonomies", $r["defaults"]["taxonomies"]);
          
          ?>
          
          <div class="fsg fsg-taxonomies <?php echo $first ? "" : "divider" ?>">
              
          <h4><i class="tags"></i><?php _e("Taxonomies", MASTERPRESS_DOMAIN) ?><span>&nbsp;&nbsp;-&nbsp;&nbsp;<?php echo $labels["title_taxonomies"] ?></span></h4>

          <div class="f clearfix">

            <div class="fsg-radios">

            <div class="fw fwl fw-all">
              <input id="visibility-type-taxonomies-all" name="visibility_type[taxonomies]" type="radio" value="all" <?php echo WOOF_HTML::checked_attr( $mode == "all" ) ?> class="radio" />
              <label for="visibility-type-taxonomies-all" class="radio"><?php echo $labels["taxonomies_all"] ?></label>
            </div>
            <!-- /.fw -->
            
            <div class="fw fwl fw-all">
              <input id="visibility-type-taxonomies-none" name="visibility_type[taxonomies]" type="radio" value="none" <?php echo WOOF_HTML::checked_attr( $mode == "none" ) ?> class="radio" />
              <label for="visibility-type-taxonomies-none" class="radio"><?php echo $labels["taxonomies_none"] ?></label>
            </div>
            <!-- /.fw -->

            <div class="fw fwl">
              <input id="visibility-type-taxonomies-allow" name="visibility_type[taxonomies]" type="radio" value="allow" <?php echo WOOF_HTML::checked_attr( $mode == "allow" ) ?> class="radio" />
              <label for="visibility-type-taxonomies-allow" class="radio"><?php echo $labels["taxonomies_allow"] ?></label>
            </div>
            <!-- /.fw -->

            <div class="fw fwl">
              <input id="visibility-type-taxonomies-deny" name="visibility_type[taxonomies]" type="radio" value="deny" <?php echo WOOF_HTML::checked_attr( $mode == "deny" ) ?> class="radio" />
              <label for="visibility-type-taxonomies-deny" class="radio"><?php echo $labels["taxonomies_deny"] ?></label>
            </div>
            <!-- /.fw -->

            </div>
            <!-- /.fsg-radios -->
            
            <div id="visibility-taxonomies-list" class="list checkbox-list">

              <?php if (count($available_taxonomies)) : ?>

              <?php
              
              $taxonomies = $model->vis("taxonomies");
              $not_taxonomies = $model->vis("not_taxonomies");
              
              ?>
              
              <div class="items">

              <?php foreach ($available_taxonomies as $tax) : ?>
                
              <?php 
              
              $tax_name = $tax->name;
              
              if ($mode == "deny") {
                $checked = MPV::in_csv($tax_name, $not_taxonomies);
              } else {
                $checked = MPV::in_csv($tax_name, $taxonomies);
              }
              
              ?>
              
              <?php if ($tax->still_registered()) : ?>

              <div class="fw">
                <input id="taxonomies_<?php echo WOOF_Inflector::underscore($tax_name) ?>" name="visibility_taxonomies[]" value="<?php echo $tax_name ?>" type="checkbox" <?php echo WOOF_HTML::checked_attr( $checked ) ?> class="checkbox" />
                <label for="taxonomies_<?php echo WOOF_Inflector::underscore($tax_name) ?>" class="checkbox"><span class="tt"><?php echo $tax->display_label() ?></span></label>
              </div>

              <?php endif; ?>
              
              <?php endforeach; ?>
          
              </div>
              <!-- /.items -->
              

              <div class="controls">
                <button type="button" class="button list-select-all"><?php _e("Select All", MASTERPRESS_DOMAIN) ?></button>
                <button type="button" class="button list-select-none"><?php _e("Select None", MASTERPRESS_DOMAIN) ?></button>
              </div>
              <!-- /.controls -->
                
              <?php endif; ?>
          
            </div>
            <!-- /#visibility-taxonomies -->
          
          </div>
          <!-- /.f -->
          
          </div>
          <!-- /#fsg-taxonomies --> 
                  
        <?php $first = false; ?>
        <?php endif; // supports taxonomies ?>
        
        
        <?php if (in_array("roles", $supports)) : ?>

          <?php
          
          if (is_null($r["roles"])) {
            $available_roles = $wf->roles(); 
          } else {
            $available_roles = $r["roles"];
          }
          
          $mode = self::visibility_mode($model->visibility, "roles", $r["defaults"]["roles"]);
          
          ?>
          
          <div class="fsg fsg-roles <?php echo $first ? "" : "divider" ?>">
              
          <h4><i class="user-role"></i><?php _e("User Profiles", MASTERPRESS_DOMAIN) ?><span>&nbsp;&nbsp;-&nbsp;&nbsp;<?php echo $labels["title_roles"] ?></span></h4>

          <div class="f clearfix">

            <div class="fsg-radios">

            <div class="fw fwl fw-all">
              <input id="visibility-type-roles-all" name="visibility_type[roles]" type="radio" value="all" <?php echo WOOF_HTML::checked_attr( $mode == "all" ) ?> class="radio" />
              <label for="visibility-type-roles-all" class="radio"><?php echo $labels["roles_all"] ?></label>
            </div>
            <!-- /.fw -->
            
            <div class="fw fwl fw-none">
              <input id="visibility-type-roles-none" name="visibility_type[roles]" type="radio" value="none" <?php echo WOOF_HTML::checked_attr( $mode == "none" ) ?> class="radio" />
              <label for="visibility-type-roles-none" class="radio"><?php echo $labels["roles_none"] ?></label>
            </div>
            <!-- /.fw -->

            <div class="fw fwl">
              <input id="visibility-type-roles-allow" name="visibility_type[roles]" type="radio" value="allow" <?php echo WOOF_HTML::checked_attr( $mode == "allow" ) ?> class="radio" />
              <label for="visibility-type-roles-allow" class="radio"><?php echo $labels["roles_allow"] ?></label>
            </div>
            <!-- /.fw -->

            <div class="fw fwl">
              <input id="visibility-type-roles-deny" name="visibility_type[roles]" type="radio" value="deny" <?php echo WOOF_HTML::checked_attr( $mode == "deny" ) ?> class="radio" />
              <label for="visibility-type-roles-deny" class="radio"><?php echo $labels["roles_deny"] ?></label>
            </div>
            <!-- /.fw -->

            </div>
            <!-- /.fsg-radios -->
            
            <div id="visibility-roles-list" class="list checkbox-list">
            
              <div class="items">

              <?php if (count($available_roles)) : ?>
                
              <?php
              
              $roles = $model->vis("roles");
              $not_roles = $model->vis("not_roles");
              
              ?>
              
              <?php foreach ($available_roles as $role) : ?>
                
              <?php 
              
              $role_name = $role->id();
              
              if ($mode == "deny") {
                $checked = MPV::in_csv($role_name, $not_roles);
              } else {
                $checked = MPV::in_csv($role_name, $roles);
              }
              
              ?>
              
              <div class="fw">
                <input id="roles_<?php echo WOOF_Inflector::underscore($role_name) ?>" name="visibility_roles[]" value="<?php echo $role_name ?>" type="checkbox" <?php echo WOOF_HTML::checked_attr( $checked ) ?> class="checkbox" />
                <label for="roles_<?php echo WOOF_Inflector::underscore($role_name) ?>" class="checkbox"><span class="tt"><?php echo $role_name ?></span></label>
              </div>
              <?php endforeach; ?>
            
              </div>
              <!-- /.items -->
              

              <div class="controls">
                <button type="button" class="button list-select-all"><?php _e("Select All", MASTERPRESS_DOMAIN) ?></button>
                <button type="button" class="button list-select-none"><?php _e("Select None", MASTERPRESS_DOMAIN) ?></button>
              </div>
              <!-- /.controls -->
            
              <?php endif; ?>
          
            </div>
            <!-- /#visibility-roles -->
          
          </div>
          <!-- /.f -->
          
          </div>
          <!-- /#fsg-roles --> 
                  
        <?php $first = false; ?>
        <?php endif; // supports roles ?>
        
        
        
        
        <?php if (in_array("multisite", $supports) && is_multisite() && MASTERPRESS_MULTISITE_SHARING ) : ?>
          
          <?php $sites = $model->vis("sites"); ?>
          <?php $not_sites = $model->vis("not_sites"); ?>
          
          <?php 
        
            $mode = self::visibility_mode($model->visibility, "sites", $r["defaults"]["multisite"]);
    
            global $blog_id;
        
            $sites_args = array("public_only" => false);
          
            if (!is_null($r["sites"])) {
              $sites_args["include_id"] = $r["sites"];
            }
          
            $sites_options = array();
            $sites_options_attr = array();
          
            $the_site = $wf->site();
          
          
            // build the sites options
            foreach ($wf->sites( $sites_args ) as $site) {
            
              $attr = array();
            
              if ($site->id() == $the_site->id()) {
                $attr["class"] = "hl";
                $attr["title"] = __("This is the current site", MASTERPRESS_DOMAIN);
              }
            
              $sites_options_attr[] = $attr;
            
              $sites_options[$site->full_path()] = $site->id();
            }
      
          ?>
            
          <div class="fsg fsg-multisite <?php echo $first ? "" : "divider" ?>">
                
          <h4><i class="globe"></i><?php _e("Multi-site", MASTERPRESS_DOMAIN) ?><span>&nbsp;&nbsp;-&nbsp;&nbsp;<?php echo $labels["title_multisite"] ?></span></h4>

          <div class="f clearfix">

            <div class="fsg-radios">

            <div class="fw fw-all">
              <input id="visibility-type-sites-all" name="visibility_type[sites]" type="radio" value="all" <?php echo WOOF_HTML::checked_attr( $mode == "all" ) ?> class="radio" />
              <label for="visibility-type-sites-all" class="radio"><?php echo $labels["multisite_all"] ?></label>
            </div>
            
            <div class="fw">
              <input id="visibility-type-sites-allow" name="visibility_type[sites]" type="radio" value="allow" <?php echo WOOF_HTML::checked_attr( $mode == "allow" ) ?> class="radio" />
              <label for="visibility-type-sites-allow" class="radio"><?php echo $labels["multisite_allow"] ?></label>
            </div>
            
            <div class="fw">
              <input id="visibility-type-sites-deny" name="visibility_type[sites]" type="radio" value="deny" <?php echo WOOF_HTML::checked_attr( $mode == "deny" ) ?> class="radio" />
              <label for="visibility-type-sites-deny" class="radio"><?php echo $labels["multisite_deny"] ?></label>
            </div>
            
            </div>
            <!-- /.fsg-radios -->
            
            <div id="visibility-sites-list" class="sites-list">
          
            <?php 
          
              if ($mode == "allow") {
                $selected_sites = explode(",", $sites);
              } else if ($mode == "deny") {
                $selected_sites = explode(",", $not_sites);
              } else {
                $selected_site_objects = $wf->sites(array("public_only" => false));
                $selected_sites = $selected_site_objects->extract("id");
              }

            
              echo WOOF_HTML::select( 
                array("multiple" => "multiple", "id" => "visibility-sites", "name" => "visibility_sites[]"),
                $sites_options,
                $selected_sites,
                $sites_options_attr
              );

            ?>

            <?php if ($labels["multisite_allow_note"] != "") : ?>
            <p class="note"><?php echo $labels["multisite_allow_note"] ?></p>  
            <?php endif; ?>

            </div>
            <!-- /#visibility-sites-list -->

          
          </div>
          <!-- /.f -->
        
          </div>
          <!-- /#fsg-multisite --> 
          
        <?php $first = false; ?>
        <?php endif; // supports multisite ?>
        
        
        

      
      </div>
      </div>

    </div>
    <!-- /.fs -->
    
  <?php
    endif; // count support
  } 
Exemple #16
0
  public static function options_form( $options ) {

    global $meow_provider;

    global $wf;
    
    $p = self::type_prefix(__CLASS__);

    $defaults = array();

    if (MPC::is_create()) {
      $defaults = array("maxwidth" => 580, "height" => 300, "control_style" => "drop_down_list");
    }

    $options = wp_parse_args( $options, $defaults );

    if (MPC::is_create()) {
      $options["post_types"] = array();
    }
      
    // setup variables to insert into the heredoc string
    // (this is required where we cannot call functions within heredoc strings)

    $taxonomies_label = __("Available Taxonomies:", MASTERPRESS_DOMAIN);

    $taxonomies_note = __("Select the taxonomies of terms available for selection in the field control", MASTERPRESS_DOMAIN);

    $taxonomies_items = array();

    MPM::incl("taxonomy");

    $taxonomies = MPM_Taxonomy::find("orderby=disabled,name ASC");

    $taxonomies_selected = array();

    foreach ($taxonomies as $taxonomy) {
    
      if (!$taxonomy->disabled && $taxonomy->show_ui && $taxonomy->still_registered()) {
        $taxonomies_selected[] = $taxonomy->name;
        $taxonomies_items[$taxonomy->display_label()] = $taxonomy->name;
      }

    }

    if (!MPC::is_create()) {
      $taxonomies_selected = self::option_value($options, "taxonomies");
    }

    if (!is_array($taxonomies_selected)) {
      $taxonomies_selected = explode(",", $taxonomies_selected);
    }
  
    $id = $p."taxonomies-";
    
    $taxonomies_checkboxes = "";
    
    foreach ($taxonomies as $taxonomy) {


      if (!$taxonomy->disabled && $taxonomy->show_ui && $taxonomy->still_registered()) {
      
        $value = $taxonomy->name;
        $label = $taxonomy->display_label();
      
        $id_suffix = WOOF::sanitize($value);
      
        $attr = array( "id" => $id."_".$id_suffix, "class" => "checkbox", "type" => "checkbox", "name" => "type_options[taxonomies][]", "value" => $value );
      
        if (in_array($value, $taxonomies_selected)) {
          $attr["checked"] = "checked";
        }
      
        $taxonomies_checkboxes .= WOOF_HTML::open("div", "class=fwi");
        $taxonomies_checkboxes .= WOOF_HTML::tag("input", $attr );
        $taxonomies_checkboxes .= WOOF_HTML::tag("label", array( "for" => $id."_".$id_suffix, "class" => "checkbox mp-icon-taxonomy mp-icon-taxonomy-".$value ), $label );
        $taxonomies_checkboxes .= WOOF_HTML::close("div");

      }

    }
    
    $ex_label = __("Description", MASTERPRESS_DOMAIN);
    $title_label = __("Name", MASTERPRESS_DOMAIN);
    
    $results_row_style = MPFT::options_select_results_row_style( $p, $options, array("excerpt" => $ex_label, "title" => $title_label ) );

    $placeholder = MPFT::options_placeholder($p, $options);

    $basic = MPFT::options_select_basic( $p, $options );
    $multi_layout = MPFT::options_select_multi_layout( $p, $options );
    $control_style = MPFT::options_select_control_style( $p, $options );
    $maxwidth = MPFT::options_maxwidth( $p, $options );
    $height = MPFT::options_height( $p, $options );
    $grouping = MPFT::options_select_grouping( $p, $options, __("Taxonomy", MASTERPRESS_DOMAIN) );

    $results_input_length = MPFT::options_input_text( $p, $options, "results_input_length", __("Minimum Input Length", MASTERPRESS_DOMAIN), __("Enter the number of characters required before any results are displayed.<br />This is useful for large numbers of posts, where performance may become poor.", MASTERPRESS_DOMAIN));


    $data_source_label = __("Data Source - <span>specify the terms available for selection</span>", MASTERPRESS_DOMAIN); 
    $control_options_label = __("Control Options", MASTERPRESS_DOMAIN); 
    $control_results_label = __("Results Display - <span>settings for the display of the available terms</span>", MASTERPRESS_DOMAIN); 
    $control_selections_label = __("Selection Display - <span>settings for the display of the selected terms</span>", MASTERPRESS_DOMAIN); 



    // build a taxonomies grid
    
    $results_row_item_prop_label = __("Row Item Properties:", MASTERPRESS_DOMAIN);
    $results_row_item_prop_note = __("Defines the term properties used to derive the info shown in result rows.<br /><b>Note: </b>Descriptions and images will be truncated / resized automatically.", MASTERPRESS_DOMAIN);
    
    
    $row_style = self::option_value($options, "row_style", "icon_title");

    $grid  = WOOF_HTML::open("table", "class=grid mini not-selectable grid-row-item-prop&cellspacing=0");
      $grid .= WOOF_HTML::open("thead");
      
        $grid .= WOOF_HTML::tag("th", "class=icon taxonomy", WOOF_HTML::tag("i", "class=tags", "") . WOOF_HTML::tag("span", null, __("Taxonomy", MASTERPRESS_DOMAIN)));

        $grid .= WOOF_HTML::tag("th", "class=icon title", WOOF_HTML::tag("i", "class=title-bar", "") . WOOF_HTML::tag("span", null, $title_label));
        $grid .= WOOF_HTML::tag("th", "class=".(($row_style == "icon_title" || $row_style == "image_title") ? "disabled " : "")."icon excerpt", WOOF_HTML::tag("i", "class=content-bar", "") . WOOF_HTML::tag("span", null, $ex_label));
        $grid .= WOOF_HTML::tag("th", "class=".(($row_style == "icon_title" || $row_style == "icon_title_excerpt") ? "disabled " : "")."icon image", WOOF_HTML::tag("i", "class=image", "") . WOOF_HTML::tag("span", null, __("Image", MASTERPRESS_DOMAIN)));



      $grid .= WOOF_HTML::close("thead");

      $grid .= WOOF_HTML::open("tbody");
      
      $count = 1;
      
      
      foreach ($taxonomies as $taxonomy) {
        if (!$taxonomy->disabled && $taxonomy->show_ui) {
          
          $classes = array("taxonomy-".$taxonomy->name);
          
          if ($count == 1) {
            $classes[] = "first";
          }
          
          $attr = array("class" => implode(" ", $classes));
          
          if (!in_array($taxonomy->name, $taxonomies_selected)) {
            $attr["style"] = "display: none;";
          }

  
          $grid .= WOOF_HTML::open("tr", $attr);

          $count++;
            
            $span = WOOF_HTML::tag("span", array("class" => "mp-icon-taxonomy mp-icon-taxonomy-".$taxonomy->name ), $taxonomy->display_label());
            
            $grid .= WOOF_HTML::tag("td", "class=first taxonomy", $span);
            $grid .= WOOF_HTML::open("td", "class=title");
            
              $default = "name";
              $value = isset($options["result_row_prop"][$taxonomy->name]["title"]) ? $options["result_row_prop"][$taxonomy->name]["title"] : $default;
              
              if ($value == "") {
                $value = $default;
              }
              
              $input_attr = array(
                "type" => "text",
                "name" => "type_options[result_row_prop][".$taxonomy->name."][title]",
                "class" => "text",
                "value" => $value
              );

              $grid .= WOOF_HTML::open("div");

              $grid .= WOOF_HTML::tag("input", $input_attr);

              $grid .= WOOF_HTML::tag(
                "button", 
                array(
                  "type" => "button",
                  "class" => "ir",
                  "data-dialog" => "dialog-taxonomy-".$taxonomy->name,
                  "data-filter" => "text",
                  "title" => __("Select Field", MASTERPRESS_DOMAIN)
                ),
                "select"
              );

              $grid .= WOOF_HTML::close("div");
            
            $grid .= WOOF_HTML::close("td");
            $grid .= WOOF_HTML::open("td", "class=excerpt".(($row_style == "icon_title" || $row_style == "image_title") ? " disabled" : ""));

              $default = "description";
              $value = isset($options["result_row_prop"][$taxonomy->name]["excerpt"]) ? $options["result_row_prop"][$taxonomy->name]["excerpt"] : $default;
              
              if ($value == "") {
                $value = $default;
              }

              $input_attr = array(
                "type" => "text",
                "name" => "type_options[result_row_prop][".$taxonomy->name."][excerpt]",
                "class" => "text",
                "value" => $value
              );

              $grid .= WOOF_HTML::open("div");

              $grid .= WOOF_HTML::tag("input", $input_attr);

              $grid .= WOOF_HTML::tag(
                "button", 
                array(
                  "type" => "button",
                  "class" => "ir",
                  "data-dialog" => "dialog-taxonomy-".$taxonomy->name,
                  "data-filter" => "text",
                  "title" => __("Select Field", MASTERPRESS_DOMAIN)
                ),
                "select"
              );

              $grid .= WOOF_HTML::close("div");
                          
            $grid .= WOOF_HTML::close("td");
            $grid .= WOOF_HTML::open("td", "class=image".(($row_style == "icon_title" || $row_style == "icon_title_excerpt") ? " disabled" : ""));

              $default = "";
              $value = isset($options["result_row_prop"][$taxonomy->name]["image"]) ? $options["result_row_prop"][$taxonomy->name]["image"] : $default;
              
              if ($value == "") {
                $value = $default;
              }
              
              $input_attr = array(
                "type" => "text",
                "name" => "type_options[result_row_prop][".$taxonomy->name."][image]",
                "class" => "text",
                "value" => $value
              );

              $grid .= WOOF_HTML::open("div");

              $grid .= WOOF_HTML::tag("input", $input_attr);
            
              $grid .= WOOF_HTML::tag(
                "button", 
                array(
                  "type" => "button",
                  "class" => "ir",
                  "data-dialog" => "dialog-taxonomy-".$taxonomy->name,
                  "data-filter" => "image",
                  "title" => __("Select Field", MASTERPRESS_DOMAIN)
                ),
                "select"
              );

              $grid .= WOOF_HTML::close("div");
              
            $grid .= WOOF_HTML::close("td");

          $grid .= WOOF_HTML::close("tr");
          
        }
      }

      $grid .= WOOF_HTML::close("tbody");
    $grid .= WOOF_HTML::close("table");
  
    
    // build dialogs for selecting row properties in the grid
    
    $dialogs = "";
    
    foreach ($taxonomies as $taxonomy) {
      
      if (!$taxonomy->disabled && $taxonomy->show_ui) {
      
        $dialogs .= WOOF_HTML::open(
          "div", 
          array(
            "class" => "dialog dialog-fields",
            "id" => "dialog-taxonomy-".$taxonomy->name,
            "data-title" => __("Select a Field", MASTERPRESS_DOMAIN)
          )
        );
      
        $fs = $meow_provider->taxonomy_field_sets($taxonomy->name);

        $field_options = array();
        $field_options[""] = "";

        $field_options_attr = array("");

        $field_options[__("( Built-in Fields )", MASTERPRESS_DOMAIN)] = array(
          
          "options" => array(
            __("Name", MASTERPRESS_DOMAIN) => "name",
            __("Description", MASTERPRESS_DOMAIN) => "description"
          ),
          "options_attr" => array(
            array("data-icon" => "mp-icon mp-icon-field-type-text-box", "class" => "text"),
            array("data-icon" => "mp-icon mp-icon-field-type-text-box-multiline", "class" => "text")
          )

        );
          
        foreach ($fs as $set) {
        
          $fo = array();
          $fo_attr = array();
          
          foreach ($set->fields() as $field) {

            if ($type_class = MPFT::type_class($field->type)) {
              $image = call_user_func( array($type_class, "supports_image") ) ? " image" : "";
              $text = call_user_func( array($type_class, "supports_text") ) ? " text" : "";

              $fo[$field->display_label()] = $set->name.".".$field->name;
              $fo_attr[] = $field_options_attr[] = array("class" => $image.$text, "data-icon" => "mp-icon mp-icon-field-type-".$field->type);
            } 

            $field_options[$set->display_label()] = array("options" => $fo, "options_attr" => $fo_attr);

          }

        } 
                
        $dialogs .= WOOF_HTML::select(array("name" => "add-field-column-field-sets", "class" => "with-icons select2-source", "data-placeholder" => __("-- Select a Field --", MASTERPRESS_DOMAIN)), $field_options, "", $field_options_attr);
        $dialogs .= WOOF_HTML::close("div");
      
      }
      
    }
    


$html = <<<HTML

    {$dialogs}
    {$control_style}

    <div class="f f-taxonomies">
      <p class="label">{$taxonomies_label}</p>
      <div class="fw">

      <div id="{$p}taxonomies-wrap">
      {$taxonomies_checkboxes}
      </div>

      <div id="{$p}taxonomies-controls" class="controls">
        <button type="button" class="button button-small select-all">Select All</button>
        <button type="button" class="button button-small select-none">Select None</button>
      </div>
      <!-- /.controls -->

      <p class="note">{$taxonomies_note}</p>
      </div>
    </div>
    <!-- /.f -->
    
    {$placeholder}
    {$basic}
    {$maxwidth}
    
    
    
    <div class="divider">
    <h4><i class="menu-gray"></i>{$control_results_label}</h4>  
    {$grouping}
    {$results_input_length}
    {$results_row_style}
    
    <div id="{$p}results-row-item-prop-f" class="results-row-item-prop-f f">
    <p class="label">{$results_row_item_prop_label}</p> 
    
    <div class="fw">
      {$grid}
      <p class="note">{$results_row_item_prop_note}</p> 
    </div>
    
    </div>
    <!-- /.f -->
    
    </div>
    
    <div id="{$p}control-selections-wrap" class="divider">
    <h4><i class="buttons"></i>{$control_selections_label}</h4>  
    {$multi_layout}
    </div>



HTML;

    return $html;

  }
Exemple #17
0
  public function init() {
    
    global $wf;
    
    // check if we're in a child theme
    
    $template_dir = get_template_directory();
    $stylesheet_dir = get_stylesheet_directory();
    
    
    // check if there are any templates that have the same name, which can cause confusion

    $names = array(); 
    $dupes = array();
    
    self::get_names($template_dir, $names, $dupes);
    
    if ($stylesheet_dir != $template_dir) {
      self::get_names($stylesheet_dir, $names, $dupes);
    }
    
    
    if (count($dupes)) {
      
      $msg  = WOOF_HTML::tag("p", array(), __("<strong>Warning:</strong> your theme appears to contain multiple template files with the same <b>Template Name</b>.<br />This may cause some templates to become invisible to both WordPress and MasterPress.<br />Please verify the following, and make changes to your template files as necessary:", MASTERPRESS_DOMAIN)); 
      $msg .= WOOF_HTML::open("ul");
      
      foreach ($dupes as $template_name => $file_name) {
        $msg .= WOOF_HTML::tag("li", array(), sprintf( __('<span class="tt">%s</span> is called <b>%s</b>, which is already used by <span class="tt">%s</span>', MASTEPRESS_DOMAIN), $file_name, $template_name, $names[$template_name]) );
      }
         
      $msg .= WOOF_HTML::close("ul");

      MPV::warn($msg);
      
    }
  
    $action = MasterPress::$action;
    
    // inform the view what to render in the info panel
    MasterPress::$view->is_template_set = true;

    
    
    if ($action == "edit-field" || $action == "create-field") {
      // inform the view what to render in the info panel
      MasterPress::$view->parent = MPM_FieldSet::find_by_id(MasterPress::$parent);

      // enqueue the field type CSS
      $type = MasterPress::$model->type;
      
      MPFT::options_admin_head($type);

      // enqueue dependent scripts for all field types (could improve this in the future)
      foreach (MPFT::type_keys() as $type) {
        if ($ftc = MPFT::type_class($type)) {
          call_user_func( array($ftc, "enqueue") );
        }
      }


    }

    if ($action == "create-field") {
      MasterPress::$model->field_set_id = MasterPress::$parent;
      MasterPress::$model->infer_position();
    }

  }
  public function grid() {

    MPC::incl("post-types");
    MPV::incl("fields");
    MPV::incl("post-types");
    
    $info = MasterPress::$view;
    
    $role_name = MasterPress::$parent;

    ?>
    
    <div class="title-info-panel">
      <div class="title-info-panel-lt">
        <h3><i class="user-role"></i><span class="label"><?php _e("User Role:", MASTERPRESS_DOMAIN) ?></span><span class="value"> <?php echo $role_name ?></span></h3> 
      </div>
    </div>
    

  
    <?php MPV::messages(); ?>
    
    <div class="grid-set">
    
    <?php $field_sets = MPM_RoleFieldSet::find_by_role( $role_name, "name" ); ?>

    <?php MPV::field_set_icon_styles($field_sets); ?>

    <?php
    
    $has_actions = MasterPress::current_user_can("edit_user_role_field_sets,delete_user_role_field_sets,edit_user_role_fields,delete_user_role_fields");

    $can_edit = MasterPress::current_user_can("edit_user_role_field_sets");
    $can_delete = MasterPress::current_user_can("delete_user_role_field_sets");
    $can_create = MasterPress::current_user_can("create_user_role_field_sets");

    $can_edit_fields = MasterPress::current_user_can("edit_user_role_fields");
    $can_delete_fields = MasterPress::current_user_can("delete_user_role_fields");
    $can_create_fields = MasterPress::current_user_can("create_user_role_fields");

    $less = ($can_create_fields) ? 1 : 0;

    $colspan = ( $has_actions ? 4 : 3 ) - $less;


    foreach ($field_sets as $field_set) {

      if (MPC::is_deleting($field_set->id, "delete-field-set")) {
        
        $this->confirm_delete($field_set);
        
      } else {
        
        foreach ($field_set->fields() as $field) {
          
          if (MPC::is_deleting($field->id, "delete-field")) {
            $this->confirm_delete_field($field);
          }
          
        }
        
      }
      
    }
    
    ?>
    
    <?php $fg_count = 0; ?>

    <?php if (count($field_sets)) : ?>

    <table cellspacing="0" class="grid grid-field-sets">

    <thead>
    <tr>
      <th class="first type"><i class="types"></i><span><?php _e("Type", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="label"><i class="label-string"></i><span><?php _e("Label", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="front-end-name <?php echo $has_actions ? "" : "last" ?>"><i class="script-php"></i><span><?php _e("Front End Name", MASTERPRESS_DOMAIN) ?></span></th>
      <?php if ($has_actions) : ?>
      <th class="actions last"><i class="buttons"></i><span><?php _e("Actions", MASTERPRESS_DOMAIN) ?></span></th>
      <?php endif; ?>
    </tr>
    </thead>
   
    <tbody>
   
    
    <?php foreach ($field_sets as $field_set) : $fg_count++; ?>  
      
    <?php 
    $display = $field_set->display_label(); 
    
      $display_td = $display;
      
      if ($field_set->icon != "") {
        $display_td = WOOF_HTML::tag("span", array("class" => "with-icon field-set-".$field_set->id), $display);
      }
    
    $deleting_class = MPC::is_deleting($field_set->id, "delete-field-set") ? 'deleting' : ''; 
    $editable_class = $can_edit ? " editable " : "";
    $meta = $can_edit ? "{ href: '".MasterPress::admin_url("roles", "edit-field-set", array("id" => $field_set->id, "parent" => $role_name) )."' }" : "";
    
    
    ?>
  
    <?php $disabled = $field_set->disabled ? "disabled" : ""; $title = $field_set->disabled ? ' title="'.__("this field set is disabled", MASTERPRESS_DOMAIN).'" ' : ""; ?>

    <?php
    if (!$field_set->in_current_site()) {
      $disabled = "disabled";
      $title = ' title="'.__("this field set is not currently available in this site (multi-site setting)", MASTERPRESS_DOMAIN).'" ';
    }
    ?>

    <tr <?php echo $title ?> class="<?php echo $disabled ?> <?php echo $editable_class.$deleting_class ?> <?php echo MPV::updated_class("edit-field-set,create-field-set", $field_set->id) ?> <?php echo $meta ?>">
      <?php if ($field_set->allow_multiple) : ?>
      <th class="first type icon"><i class="metabox-add-remove-large" title="<?php _e("Field Set (Multiple Items)", MASTERPRESS_DOMAIN) ?>"></i></th>
      <?php else : ?>
      <th class="first type icon"><i class="metabox-large" title="<?php _e("Field Set", MASTERPRESS_DOMAIN) ?>"></i></th>
      <?php endif; ?>
      <th class="label"><strong><?php echo $display_td ?></strong></th>
      <th class="front-end-name <?php echo $has_actions ? "" : "last" ?>"><span class="tt"><?php echo $field_set->display_name() ?></span></th>

      <?php if ($has_actions) : ?>
      
      <th class="actions last">
      <div>
      <?php if (MPC::is_deleting($field_set->id, "delete-field-set")) : ?>
        <span class="confirm-action">&nbsp;</span>
      <?php else: ?>
        <?php if ($can_edit) : ?>
          <?php echo MPV::action_button("roles", "edit-field-set", self::__edit(), array("id" => $field_set->id, "parent" => $role_name), array("class" => "button button-edit") ); ?>
        <?php endif; ?>

        <?php if ($can_delete) : ?>
          <?php echo MPV::action_button("roles", "delete-field-set", self::__delete(), array("id" => $field_set->id, "parent" => $role_name), array("class" => "button button-delete") ); ?>
        <?php endif; ?>
      <?php endif; ?>
      </div>
      </th>

      <?php endif; // has_actions ?>

    </tr>  
    
    <?php 
    
    $count = 0; 
    $fields = $field_set->fields();
    
    ?>
    
    <?php foreach ($fields as $field) : $count++; $first = $count == 1 ? 'first' : ''; $disabled = $field_set->disabled || $field->disabled ? "disabled" : ""; $title = $field_set->disabled ? ' title="'.__("this field is disabled", MASTERPRESS_DOMAIN).'" ' : ""; ?>

    <?php
    if (!$field_set->in_current_site() || !$field->in_current_site()) {
      $disabled = "disabled";
      $title = ' title="'.__("this field is not currenty available in this site (multi-site setting)", MASTERPRESS_DOMAIN).'" ';
    }
    ?>


    <?php 
    
    $deleting_class = MPC::is_deleting($field_set->id, "delete-field-set") || MPC::is_deleting($field->id, "delete-field") ? 'deleting' : ''; 
    $editable_class = $can_edit_fields ? " editable " : "";
    $meta = $can_edit ? "{ href: '".MasterPress::admin_url("roles", "edit-field", array("id" => $field->id, "gparent" => $_GET["parent"], "parent" => $field_set->id) )."' }" : "";

    ?>
      
    <?php if ($type_class = MPFT::type_class($field->type)) : ?>

    <tr <?php echo $title ?> class="sub <?php echo $editable_class.$deleting_class ?> <?php echo $disabled ?> <?php echo $first ?> <?php echo $count % 2 == 0 ? "even" : "" ?> <?php echo MPV::updated_class("edit-field,create-field", $field->id) ?> <?php echo $meta ?>">
      <td class="type icon first" title="<?php echo call_user_func( array($type_class, "__s") ) ?>"><span class="mp-icon mp-icon-field-type-<?php echo $field->type ?>"></span></td>
      <td class="label"><strong><?php echo $field->display_label() ?></strong></td>
      <td class="front-end-name <?php echo $has_actions ? "" : "last" ?>"><span class="tt"><span class="arrow">-&gt;&nbsp;</span><?php echo $field->display_name() ?></span></td>

      <?php if ($has_actions) : ?>

      <td class="actions last">
      <?php if (MPC::is_deleting($field->id, "delete-field")) : ?>
        <span class="confirm-action">&nbsp;</span>
      <?php else: ?>
      <div>
        <?php if ($can_edit_fields) : ?>
          <?php echo MPV::action_button("roles", "edit-field", self::__edit(), array("id" => $field->id, "gparent" => $_GET["parent"], "parent" => $field_set->id), array("class" => "button button-edit") ); ?>
        <?php endif; ?>

        <?php if ($can_delete_fields) : ?>
          <?php echo MPV::action_button("roles", "delete-field", self::__delete(), array("id" => $field->id, "gparent" => $_GET["parent"], "parent" => $role_name), array("class" => "button button-delete") ); ?>
        <?php endif; ?>

      </div>
      <?php endif; ?>

      </td>

      <?php endif; // has_actions ?>

    </tr>
    

    <?php endif; ?>
    
    <?php endforeach; ?>
  
    <tr class="summary <?php echo $can_create_fields ? "editable" : "" ?>">
      <?php if (count($fields)) : ?>
      <td colspan="<?php echo $colspan ?>" class="first <?php echo $can_create_fields ? "" : "last" ?>"><?php printf( __( "%s contains %s", MASTERPRESS_DOMAIN ), $display, MPU::__items( $field_set->field_count(), __("%d custom field", MASTERPRESS_DOMAIN), __("%d custom fields", MASTERPRESS_DOMAIN) ) ) ?></td>
      <?php else: ?>
      <td colspan="<?php echo $colspan ?>" class="hl first last"><span><?php printf( __( "<strong>%s</strong> is not yet active as it contains <em>no custom fields</em>. Click here to create one", MASTERPRESS_DOMAIN ), $field_set->display_label() ); ?></span></td>
      <?php endif; ?>

      <?php if ($can_create_fields) : ?>
      <td class="last actions <?php echo count($fields) ? "" : "hl" ?>">
      <?php echo MPV::action_button("roles", "create-field", self::__create(MPV_Fields::__s()), array("gparent" => $_GET["parent"], "parent" => $field_set->id), array("class" => "button create-field")  ); ?>
      </td>
      <?php endif; // can_create_fields ?>

    </tr>
    <tr class="gap <?php if ($fg_count == count($field_sets)) { echo "gap-last"; } ?>">
    <td colspan="4">&nbsp;</td>  
    </tr>
    
  
    <?php endforeach; ?>

    </tbody>
  
    </table>
  
    <?php if ($can_create) : ?>
    <div class="grid-foot-controls">
    <?php echo MPV::action_button("roles", "create-field-set", MPV::__create( MPV_RoleFieldSets::__s() ), array( "parent" => $role_name ) ); ?>
    </div>
    <?php endif; ?>
    
    <?php else: ?>
  
    <?php if ($can_create) : ?>
    <a href="<?php echo MasterPress::admin_url("roles", "create-field-set", array("parent" => MasterPress::$parent ) ) ?>" class="no-items-create">
	<i class="plus-circle"></i>
    <span><?php printf( __( "The '<em>%s</em>' role currently has <em>no field sets</em>. Click here to create one.", MASTERPRESS_DOMAIN ), $role_name  ) ?></span>
    </a>
    <?php endif; ?>
  
    <?php endif; ?>

    
    </div>
  

  
    <?php

  } // end grid()