Exemplo n.º 1
0
  public function manage() { 

    global $meow_provider, $wf;
    
    $this->setup_view( array(
        "title_args" => array( "text" => __("Site Content", MASTERPRESS_DOMAIN) )
      )
    );

    
    $site = $wf->site();
    
    MasterPress::$view->sets = self::assigned_field_sets();
    
    MPC::incl("meta");
    MPV::incl("meta");
    
    if (MPC::is_postback()) {
      // save the meta - this code should be moved into the controller at some stage
      MPC_Meta::save_site_meta($site->id());
      // redirect back to here
      wp_redirect( MasterPress::admin_url( "site-content", "manage", array("updated" => "true"), false ) );
      exit();
    }
    
  } 
Exemplo n.º 2
0
  public function delete_field() {

    if (!MasterPress::current_user_can("delete_site_fields")) {
      wp_die(__("Sorry, you do not have the required capability to delete site fields.", MASTERPRESS_DOMAIN));
    }
 
    $this->delete( array(
        "cap_verified" => true,
        "model" => "field",
      )
    );
    
  }
Exemplo n.º 3
0
  function manage() {
    
    global $wf;
    
    ?>

    <?php MPV::messages() ?>

    <?php MPV::form_open() ?>


    <div id="settings">

    <button id="bt-save-changes-top" type="submit" class="simple-primary"><?php _e("Save Settings", MASTERPRESS_DOMAIN) ?></button>
    
    <div class="fs fs-licence fs-with-tabs">
    
      <div class="fst">
      <div class="fstb">
        <h3><i class="certificate"></i><strong><?php _e("Licence", MASTERPRESS_DOMAIN) ?></strong> - <?php _e("your registration info", MASTERPRESS_DOMAIN) ?></h3>
      </div>
      </div>
        
      <div class="fsc">
      <div class="fscb">
        
        <div class="f">
          <label for="licence_key" class="icon"><i class="key"></i><?php _e("Key", MASTERPRESS_DOMAIN)?>:</label>
          <div class="fw">
            <input id="licence_key" name="licence_key" type="text" value="<?php echo get_site_option("mp_licence_key") ?>" class="text mono" />
            
            <div id="licence-progress"></div>
            
            <?php
            
            // check the transient
            
            $current_key = MasterPress::licence_key();
            
            $cache_key = MPC_Settings::cache_key($current_key);
            
            $info = array("valid" => false, "reason" => "");
            
            $valid = $wf->cache($cache_key);
              
            if ($valid != "yes") {

              // if it's not valid, let's check again
              $info = MPC_Settings::do_validate_licence_key($current_key);

            } else {
              $info["valid"] = true;
            }
            
            $valid_style = ( $current_key && $info["valid"] ) ? 'display: block;" ' : 'display: none;';
            $invalid_style = ( $current_key != "" && !$info["valid"] ) ? 'display: block;" ' : 'display: none;';
            $empty_style = ( $current_key == "" ) ? 'display: block;" ' : 'display: none;';
            
            if ($info["reason"] != "") {
              $info["reason"] = " - ".$info["reason"];
            }
            
            ?>
            
            <p id="licence-empty" class="note" style="<?php echo $empty_style ?>">
              <?php _e("A valid licence key is required for access to automatic updates and support.", MASTERPRESS_DOMAIN); ?>
            </p>

            <p id="licence-valid" class="note" style="<?php echo $valid_style ?>">
              <i class="tick-circle"></i>
              <?php _e("Your licence key is valid", MASTERPRESS_DOMAIN); ?>
            </p>

            <p id="licence-invalid" class="note" style="<?php echo $invalid_style ?>">
              <i class="error-circle"></i>
              <?php _e("Key not valid", MASTERPRESS_DOMAIN); ?>
              <span class="reason"><?php echo $info["reason"] ?></span>
            </p>
            
          </div>
        </div>
        <!-- /.f -->
    
        
      </div>
      </div>
    
    </div>
    <!-- /.fs -->


    

    <div class="fs fs-capabilities fs-with-tabs">
    
      <div class="fst">
      <div class="fstb">
        <h3><i class="masterpress"></i><strong><?php _e("MasterPress Capabilities", MASTERPRESS_DOMAIN) ?></strong> - <?php _e("the keys used to control access to features of MasterPress", MASTERPRESS_DOMAIN) ?></h3>
      </div>
      </div>
        
      <div class="fsc">
      <div class="fscb">
        
    
        <?php $cap = get_site_option("mp_cap", "standard") ?>
        
          <div class="fw fwl">
            <input id="mp_cap_standard" name="mp_cap" value="standard" <?php echo WOOF_HTML::checked_attr( $cap == "standard" ) ?> type="radio" class="radio" />
            <label for="mp_cap_standard" class="radio"><?php _e('<em>Standard</em> - all features are allowed for user roles with the <span class="tt">manage_options</span> capability (typical plug-in setup)', MASTERPRESS_DOMAIN) ?></label>
          </div>
          <!-- /.fw -->

          <div class="fw fwl">
            <input id="mp_cap_specific" name="mp_cap" value="specific" <?php echo WOOF_HTML::checked_attr( $cap == "specific" ) ?> type="radio" class="radio" />
            <label for="mp_cap_specific" class="radio"><?php _e('<em>Specific</em> - allows fine-grained control over MasterPress', MASTERPRESS_DOMAIN) ?></label>

            <?php
            
            $style = "";
            
            if ($cap == "standard") {
              $style = ' style="display: none;"';
            }
            
            ?>
            
            <div id="specific-keys" <?php echo $style ?> class="eg">
              <p><strong><?php _e("Section Access", MASTERPRESS_DOMAIN) ?>:</strong> <span class="tt">manage_masterplan, manage_post_types, manage_taxonomies, manage_templates, manage_user_roles, manage_site_field_sets, manage_shared_field_sets, manage_mp_settings, manage_mp_tools</span></p>
              <p><strong><?php _e("Masterplans", MASTERPRESS_DOMAIN) ?>:</strong> <span class="tt">export_masterplan, import_masterplan, backup_masterplan, restore_masterplan</span></p>
              <p><strong><?php _e("Post Types", MASTERPRESS_DOMAIN) ?>:</strong> <span class="tt">create_post_types, edit_post_types, delete_post_types, manage_post_type_field_sets, create_post_type_field_sets, edit_post_type_field_sets, delete_post_type_field_sets, create_post_type_fields, edit_post_type_fields, delete_post_type_fields</span></p>
              <p><strong><?php _e("Taxonomies", MASTERPRESS_DOMAIN) ?>:</strong> <span class="tt">create_taxonomies, edit_taxonomies, delete_taxonomies, manage_taxonomy_field_sets, create_taxonomy_field_sets, edit_taxonomy_field_sets, delete_taxonomy_field_sets, create_taxonomy_fields, edit_taxonomy_fields, delete_taxonomy_fields</span></p>
              <p><strong><?php _e("Templates", MASTERPRESS_DOMAIN) ?>:</strong> <span class="tt">edit_templates, manage_template_field_sets, create_template_field_sets, edit_template_field_sets, delete_template_field_sets, create_template_fields, edit_template_fields, delete_template_fields</span></p>
              <p><strong><?php _e("User Roles", MASTERPRESS_DOMAIN) ?>:</strong> <span class="tt">create_user_roles, edit_user_roles, manage_user_role_field_sets, create_user_role_field_sets, edit_user_role_field_sets, delete_user_role_field_sets, create_user_role_fields, edit_user_role_fields, delete_user_role_fields</span></p>
              <p><strong><?php _e("Site Field Sets", MASTERPRESS_DOMAIN) ?>:</strong> <span class="tt">create_site_field_sets, edit_site_field_sets, delete_site_field_sets, create_site_fields, edit_site_fields, delete_site_fields</span></p>
              <p><strong><?php _e("Shared Field Sets", MASTERPRESS_DOMAIN) ?>:</strong> <span class="tt">create_shared_field_sets, edit_shared_field_sets, delete_shared_field_sets, create_shared_fields, edit_shared_fields, delete_shared_fields</span></p>
            </div>
            
            
            
            <div id="mp-grant" <?php echo $style ?> class="mp-grant">
            <input id="mp_cap_grant" name="mp_cap_grant" value="true" type="checkbox" <?php echo WOOF_HTML::checked_attr($cap == "standard") ?> class="checkbox" />
            <label for="mp_cap_grant" class="radio"><?php _e('On save, add all capabilities above to roles with the <span class="tt">manage_options</span> capability.', MASTERPRESS_DOMAIN) ?></label>
            <p class="note">
            <?php _e("Note: you can also add these capabilities at a later time in the <em>User Roles</em> section, under the <b>Masterpress</b> tab when creating or editing a user role."); ?>
            </p>
                
            </div>

          </div>
          <!-- /.fw -->
       
      </div>
      </div>
    
    </div>
    <!-- /.fs -->
    
    
    
    <div class="fs fs-server-info">
    
      <div class="fst">
      <div class="fstb">
        <h3><i class="server"></i><strong><?php _e("Support Info", MASTERPRESS_DOMAIN) ?></strong> - <?php _e("useful information for support requests", MASTERPRESS_DOMAIN) ?></h3>
        <div class="buttons">
          <button id="select-all-server-info" class="button button-small button-select-all" type="button"><?php _e('Select <strong>All</strong>', MASTERPRESS_DOMAIN) ?></button>
        </div>
      </div>
      </div>
        
      <div class="fsc">
      <div class="fscb">
        
        <?php
        
        global $wp_version, $wpdb;
        
        $active_plugin_list = array();
        $inactive_plugin_list = array();
        
        $plugins = get_plugins();
        
        foreach( $plugins as $plugin_file => $data ) {

          $pi = $data["Name"] . " v" . $data["Version"] . " - ".$data["PluginURI"];

      		if ( is_plugin_active( $plugin_file ) )  { 
      		  $active_plugin_list[] = $pi;
          } else {
      		  $inactive_plugin_list[] = $pi;
          }
      	}
      	
      	
        ?>
        
        <textarea id="server-info" readonly="readonly"><?php printf( __( "MasterPress Version: %s", MASTERPRESS_DOMAIN), MASTERPRESS_VERSION ) ?>  
<?php printf( __( "WordPress Version: %s", MASTERPRESS_DOMAIN), $wp_version ) ?>  
<?php printf( __( "Multi-site: %s", MASTERPRESS_DOMAIN), is_multisite() ? __("yes") : __("no") ) ?>  
<?php printf( __( "Host: %s", MASTERPRESS_DOMAIN), $_SERVER["HTTP_HOST"] ) ?>  

# PHP ENVIRONMENT

<?php printf( __( "PHP Version: %s", MASTERPRESS_DOMAIN), phpversion() ) ?>  
<?php printf( __( "MySQL Version: %s", MASTERPRESS_DOMAIN), $wpdb->db_version() ) ?>  
<?php printf( __( "Operating System: %s", MASTERPRESS_DOMAIN), PHP_OS ) ?>  

<?php printf( __( "Memory Limit: %s", MASTERPRESS_DOMAIN), ini_get( 'memory_limit' ) ) ?>  
<?php printf( __( "Max Execution Time: %ss", MASTERPRESS_DOMAIN), ini_get( 'max_execution_time' ) ) ?>  
<?php printf( __( "File Uploads: %s", MASTERPRESS_DOMAIN), MasterPress::ini_get_off_on( 'file_uploads' ) ) ?>  
<?php printf( __( "Post Max Size: %s", MASTERPRESS_DOMAIN), ini_get( 'post_max_size' ) ) ?>  
<?php printf( __( "Upload Max File Size: %s", MASTERPRESS_DOMAIN), ini_get( 'upload_max_filesize' ) ) ?>  
<?php printf( __( "Allow URL fopen: %s", MASTERPRESS_DOMAIN), MasterPress::ini_get_off_on( 'allow_url_fopen' ) ) ?>  

<?php printf( __( "Short Open Tag: %s", MASTERPRESS_DOMAIN), MasterPress::ini_get_off_on( 'short_open_tag' ) ) ?>  
<?php printf( __( "Display Errors: %s", MASTERPRESS_DOMAIN), MasterPress::ini_get_off_on( 'register_globals' ) ) ?>  

<?php printf( __( "Register Globals: %s", MASTERPRESS_DOMAIN), MasterPress::ini_get_setting( 'register_globals' ) ) ?>  
<?php printf( __( "Magic Quotes GPC: %s", MASTERPRESS_DOMAIN), MasterPress::ini_get_setting( 'magic_quotes_gpc' ) ) ?>  
<?php printf( __( "Magic Quotes Runtime: %s", MASTERPRESS_DOMAIN), MasterPress::ini_get_setting( 'magic_quotes_runtime' ) ) ?>  
<?php printf( __( "Safe Mode: %s", MASTERPRESS_DOMAIN), MasterPress::ini_get_setting( 'safe_mode' ) ) ?>  

# ACTIVE WORDPRESS PLUGINS

<?php echo implode("\n", $active_plugin_list); ?>


# INACTIVE WORDPRESS PLUGINS

<?php echo implode("\n", $inactive_plugin_list); ?>


# SERVER SOFTWARE

<?php echo $_SERVER["SERVER_SOFTWARE"] ?>

</textarea>
      </div>
      </div>
    
    </div>
    <!-- /.fs -->
    
    
    
    </div>
    <!-- /#settings -->
    
    <?php

  }
Exemplo n.º 4
0
  public function manage_url($set) {
    
    $url = "";
    
    switch ($set->type) {
      
      case "p" : // Post type
        $pt = MPM_PostType::find_by_name($set->vis("post_types"));

        if (!$pt) {
          return '';
        }

        $url = MasterPress::admin_url("post-types", "edit-field", array("id" => $this->id, "gparent" => $pt->id, "parent" => $set->id ) );
        break;

      case "t" : // Template
        $url = MasterPress::admin_url("templates", "edit-field", array("id" => $this->id, "gparent" => $set->vis("templates"), "parent" => $set->id) );
        break;

      case "x" : // taXonomy
        
        $tax = MPM_Taxonomy::find_by_name($set->vis("taxonomies"));
        
        if (!$tax) {
          return '';
        }

        $url = MasterPress::admin_url("taxonomies", "edit-field", array("id" => $this->id, "gparent" => $tax->id, "parent" => $set->id) );
        break;

      case "s" : // Shared
        $url = MasterPress::admin_url("shared-field-sets", "edit-field", array("id" => $this->id, "parent" => $set->id) );
        break;

      case "r" : // Role
      $url = MasterPress::admin_url("roles", "edit-field", array("id" => $this->id, "gparent" => $set->vis("roles"), "parent" => $set->id) );
        break;

      case "w" : // site-Wide
        $url = MasterPress::admin_url("site-field-sets", "edit-field", array("id" => $this->id, "parent" => $set->id) );
        break;

    } 
    
    return $url;
  }
Exemplo n.º 5
0
  public function json($fields) {
    
    global $wf;
    
    $type = $this->type_name();

    $json = array();
    
    if ( apply_filters("mp_rest_post_href_field", true ) ) {
      $json["href"] = $this->json_href();
    }

    if (!is_array($fields)) {
      $fields = $wf->parse_field_list( $fields );
    } 
    
    if (!isset($fields)) {
      $fields = $wf->parse_field_list( self::json_fields() );
    }
    
    MasterPress::$context = "json";
    
    foreach ($fields as $name => $sub_fields) {
      
      $val = null;

      switch ($name) {

        case "id" : 
        
          $val = (int) $this->id();
          break;
        
        case "author" :

          $val = $this->author->json();

          break;
        case "type" :

          $val = $this->type_name;
          break;

        case "date" :

          $val = $this->date("c");
          break;

        case "modified" :

          $val = $this->item->post_modified;
          
          if ($val == 0) {
            $val = null;
          } else {
            $val = $this->modified("c");
          }
          break;

        case "comments_open" :

          $val = $this->comment_status == "open";
          break;

        case "pings_open" :

          $val = $this->ping_status == "open";
          break;

        case "comment_count" : 
        
          $val = (int) $this->comment_count();
          break;
         
        default: {
          $val = $this->eval_json_field($name, $sub_fields); 
        }

      }

      $json[$name] = $val;
    }
    
    MasterPress::$context = "string";
    
    return $json;
    
  }
Exemplo n.º 6
0
  public function delete_field() {

    if (!MasterPress::current_user_can("create_post_type_field_sets")) {
      wp_die(__("Sorry, you do not have the required capability to delete post type fields.", MASTERPRESS_DOMAIN));
    }

    $this->delete( array(
        "cap_verified" => true,
        "manage" => "manage-field-sets",
        "model" => "field",
      )
    );
    
  }
Exemplo n.º 7
0
  public function import() {
    global $wf;

    $base_dir = MASTERPRESS_TMP_DIR;
    $base_url = MASTERPRESS_TMP_URL;
    
    $restore = false;
    
    if (isset($_POST["import_masterplan"])) {
      $masterplan = $_POST["import_masterplan"];
    } else {
      if (isset($_POST["restore_masterplan"])) {
        $masterplan = $_POST["restore_masterplan"];
        $base_dir = MASTERPRESS_CONTENT_MASTERPLANS_DIR;
        $base_url = MASTERPRESS_CONTENT_MASTERPLANS_URL;
        $restore = true;
      }
    }
    
    
    $view = MasterPress::$view;
    
    if (isset($masterplan)) {
      
      extract(self::open_masterplan($masterplan, true, $base_dir, $base_url));
    
      if ($rep) {



        $icon_dest = MASTERPRESS_CONTENT_MENU_ICONS_DIR;
        $icon_src = $dir.WOOF_DIR_SEP."icons".WOOF_DIR_SEP;

        $field_type_dest = MASTERPRESS_EXTENSIONS_FIELD_TYPES_DIR;
        $field_type_src = $dir.WOOF_DIR_SEP."field-types".WOOF_DIR_SEP;
        
                   
        // install field type extensions
        
        foreach ($field_types as $field_type) {
          $dest = $field_type_dest.$field_type["name"];
          $src = $field_type_src.$field_type["name"];
          
          if (!(file_exists($dest) && !isset($_POST["import_types_overwrite"]))) {
            MPU::copyr($src, $dest);
          }
        
        }
        
        $info = array("log" => array());
          
        $mode = $_REQUEST["import_mode"];
        
        if ($restore) {
          $mode = "replace";
        }
        
        $log = &$info["log"];
        
        $backup = isset($_REQUEST["import_backup"]);

        $view->rep = $rep;
        $view->backup = $backup;
        $view->mode = $mode;
        
        // first obtain the current representation
        
        $current = self::get_current_rep();
        $view->current = $current;
      
        if ($backup) {
          
          // build the backup (a rollback point)
      
          $backup_filename = "_backup.pre-import.".$wf->format_date("[date-time-sortable]").".masterplan.zip";
          $backup_readme = "# Backup Masterplan for ".$wf->sites()->first()->name." #

+ Created: ".$wf->format_date("[date-time-long]");
        
          $backup_rep = $this->export_rep($current);
          $package = $this->build_package($backup_rep, $backup_filename, $backup_readme);
        
          if ($package) {
            $info["backup_package"] = $package;
            $info["backup_url"] = MASTERPRESS_CONTENT_MASTERPLANS_URL.$backup_filename;
            $info["backup_filename"] = $backup_filename;
          }
        
        }
        
        // process the representation

        // store all objects by key to look them up for potential removal (if mode is replace)
        
        $import = array(
          "post_types" => array(),
          "taxonomies" => array(),
          "shared_field_sets" => array(),
          "site_field_sets" => array(),
          "templates" => array(),
          "roles" => array()
        );

        $taxonomies_by_key = array();
        $shared_field_sets_by_key = array();
        $shared_field_sets_by_key = array();
        
        if (isset($rep["post_types"])) {
        
          foreach ($rep["post_types"] as $post_type) {
          
            $data = $post_type;
            unset($data["field_sets"], $data["id"], $data["sites"]);
          
            $name = $post_type["name"];
          
            $insert = true;
          
            if ($model = MPM_PostType::find_by_name($name)) {
              $insert = false;

            } else {
              $model = new MPM_PostType();
            }
            
            $model->set($data, true);
          
            if ($insert) {
              $model->insert();
            } else {
              $model->update();
            }
        
            // install icons
        
            if ($post_type["_builtin"] == "0" && !is_null($post_type["menu_icon"]) && $post_type["menu_icon"] != "") {
              copy($icon_src.$post_type["menu_icon"], $icon_dest.$post_type["menu_icon"]);
            }

            $import["post_types"][$name] = $post_type;
          
            // now run through the field sets, taking care to preserve 
            $import["post_types"][$name]["field_sets"] = self::import_field_sets($post_type["field_sets"], " AND `type` = 'p' AND ".MPM::visibility_rlike("post_types", $name), $dir);


          }
        
        }
        
        if (isset($rep["taxonomies"])) {
        
          foreach ($rep["taxonomies"] as $tax) {
          
            $data = $tax;
            unset($data["field_sets"], $data["id"], $data["sites"]);
          
            $name = $tax["name"];
            
            $insert = true;
          
            if ($model = MPM_Taxonomy::find_by_name($name)) {
              $insert = false;
            } else {
              $model = new MPM_Taxonomy();
            }
            
            $model->set($data, true);
          
            if ($insert) {
              $model->insert();
            } else {
              $model->update();
            }
      
            // install icons
        
            if ($tax["_builtin"] == "0" && !is_null($tax["title_icon"]) && $tax["title_icon"] != "") {
              copy($icon_src.$tax["title_icon"], $icon_dest.$tax["title_icon"]);
            }
          
            $import["taxonomies"][$name] = $tax;
          
            $import["taxonomies"][$name]["field_sets"] = self::import_field_sets($tax["field_sets"], " AND `type` = 'x' AND ".MPM::visibility_rlike("taxonomies", $name), $dir);
          
          }
          
        }

        if (isset($rep["shared_field_sets"])) {
          $import["shared_field_sets"] = self::import_field_sets($rep["shared_field_sets"], " AND `type` = 's' ", $dir);
        }

        if (isset($rep["site_field_sets"])) {
          $import["site_field_sets"] = self::import_field_sets($rep["site_field_sets"], " AND `type` = 'w' ", $dir);
        }
        
        if (isset($rep["templates"])) {
          foreach ($rep["templates"] as $template) {
            
            $id = $template["id"];
            
            // template models are self-creating, so no need for special handling here
            $model = MPM_Template::find_by_id($id);
            
            $data = $template;
            unset($data["field_sets"]);
            
            $model->set($data, true);
            $model->update();

            $import["templates"][$id] = $template;
            
            if (isset($template["field_sets"])) {
              $import["templates"][$id]["field_sets"] = self::import_field_sets($template["field_sets"], " AND `type` = 't' AND ".MPM::visibility_rlike("templates", $id), $dir);
            }

          
          }
        }

        if (isset($rep["roles"])) {
          foreach ($rep["roles"] as $role) {
            if (isset($role["field_sets"])) {
              $name = $role["name"];
              
              $import["roles"][$name] = $role;
              $import["roles"][$name]["field_sets"] = self::import_field_sets($role["field_sets"], " AND `type` = 'r' AND ".MPM::visibility_rlike("roles", $name), $dir);

            }
            
          }
        }
        
        
        if ($mode == "replace") {
          
          // we now need to remove anything in the current setup that ISN'T in the imported masterplan

          if (isset($current["post_types"])) {
            foreach ($current["post_types"] as $post_type) {
              
              $name = $post_type["name"];
              $builtin = $post_type["_builtin"] == "1";
              
              if (!isset($import["post_types"][$name]) && !$builtin) {
                
                $model = MPM_PostType::find_by_name($name);
    
                if ($model) {
                  $model->delete( array(
                    "posts" => "leave",
                    "posts_reassign_type" => "",
                    "field_sets" => "delete",
                    "field_data" => "keep"
                  ));
                }
                
              } else {
                
                if (isset($post_type["field_sets"])) {
                  self::replace_field_sets($post_type["field_sets"], $import["post_types"][$name]["field_sets"]);
                }
                
              }
              
            }
          }
          
          

          if (isset($current["taxonomies"])) {
            foreach ($current["taxonomies"] as $tax) {

              $name = $tax["name"];
              $builtin = $tax["_builtin"] == "1";
              
              if (!isset($import["taxonomies"][$name]) && !$builtin) {
                
                $model = MPM_Taxonomy::find_by_name($name);
                
                if ($model) {
                  $model->delete( array(
                    "existing_terms" => "leave",
                    "existing_terms_reassign_taxonomy" => "",
                    "field_sets" => "delete",
                    "field_data" => "leave"
                  ));
                }
                
              } else {
                if (isset($tax["field_sets"])) {
                  self::replace_field_sets($tax["field_sets"], $import["taxonomies"][$name]["field_sets"]);
                }
              
              }
              
            }
          }

          if (isset($current["shared_field_sets"])) {
            self::replace_field_sets($current["shared_field_sets"], $import["shared_field_sets"]);
          }

          if (isset($current["site_field_sets"])) {
            self::replace_field_sets($current["site_field_sets"], $import["site_field_sets"]);
          }

          if (isset($current["templates"])) {

            foreach ($current["templates"] as $template) {

              $id = $template["id"];

              if (isset($import["templates"][$id])) {
                if (isset($template["field_sets"])) {
                  self::replace_field_sets($template["field_sets"], $import["templates"][$id]["field_sets"]);
                }
              }
              
            }

          }


          if (isset($current["roles"])) {

            foreach ($current["roles"] as $name => $role) {

              if (isset($import["roles"][$name])) {
                  
                if (isset($role["field_sets"])) {
                  self::replace_field_sets($role["field_sets"], $import["roles"][$name]["field_sets"]);
                }
              }
              
            }
          }
          
        } // mode = replace
        
        
        // cleanup the unzipped folder
        
        MPU::rmdir_r($dir);
        
        if ($restore) {
          wp_redirect( MasterPress::admin_url( $this->key(), "manage", array("restore-complete" => "1"), false ) );
        } else {
          wp_redirect( MasterPress::admin_url( $this->key(), "manage", array("import-complete" => "1"), false ) );
        }
      
        
        $view->info = $info;
        
      } else {
        self::ajax_error(__("The Masterplan is no longer valid. Please try another file", MASTERPRESS_DOMAIN));
      }
      
    } else {
      self::ajax_error(__("The Masterplan is no longer valid. Please try another file", MASTERPRESS_DOMAIN));
    }

    
    
  }
Exemplo n.º 8
0
 public static function enqueue() {
   MasterPress::enqueue_codemirror();
 }
Exemplo n.º 9
0
 public static function enqueue() {
   MasterPress::enqueue_mediaelement();
 }
Exemplo n.º 10
0
  public static function term_column_content( $out, $key, $term) {

    global $taxonomy, $wf;
    
    $mode = "list";
    
    if (isset($_GET["mode"])) {
      $mode = $_GET["mode"];
    } 

    $the_term = $wf->term_by_id($term, $taxonomy);

    $tax = self::manage_taxonomy();
    
    $columns = $tax->columns_by_key();
    $column = $columns[$key];
    
    if (!isset($column["core"])) {
      
      // we only need to output custom columns
      
      if (isset($column["content"])) {
        $content = stripslashes($column["content"]);
        MasterPress::$context = "col";
        $out = WOOF::eval_expression($content, $the_term);
        MasterPress::$context = "";
        echo $out;
      }
      
    }
    
  }
Exemplo n.º 11
0
  public static function upgrade() {
    
    global $wpdb;
    
    // run an upgrade, based on the version number

    if (get_option("masterpress_version") != MasterPress::$version || !self::table_exists("post_types") || isset($_GET["mp_install"])) {
      // Always add the latest table definitions here (when required) with dbDelta calls
      update_option("masterpress_version", MasterPress::$version);
      MasterPress::install();
    }
    
  }
Exemplo n.º 12
0
  public function submit() {
    
    global $wpdb;
    
    $action = MasterPress::$action;
    
    if ($action == "create" || $action == "edit") {
      
      $field_set = new $this->model_class();
      // consume the post data
      
      $field_set->name = $_POST["name"];
      $field_set->singular_name = $_POST["singular_name"];
      $field_set->disabled = isset($_POST["disabled"]);
      $field_set->labels = $_POST["labels"];
      $field_set->visibility = MPC::post_val("visibility");
      $field_set->capabilities = self::handle_capabilities();
      $field_set->allow_multiple = isset($_POST["allow_multiple"]);
      $field_set->type = $this->db_type;
      $field_set->position = $_POST["position"];
      $field_set->icon = self::handle_icon("icon", "icon_select");
      $field_set->expanded = isset($_POST["expanded"]);
      $field_set->sidebar = isset($_POST["sidebar"]);
      $field_set->versions = $_POST["versions"];
      $field_set->visibility = $this->get_visibility_val();

      if ($action == "create") {
        $field_set->insert();
      } else if ($action == "edit") {
        $field_set->update(MasterPress::$id);
      }

      if ($field_set->is_valid()) {

        if (MPC::is_edit()) {
          global $meow_provider;
          $meow_provider->migrate_field_set_meta($field_set, $_POST["name_original"]);
        }

        // update other menu positions
        
        $op = MPC::post_val("other_position");
        
        if (isset($op) && is_array($op)) {
          foreach ($op as $id => $position) {
            $wpdb->update(MPM::table("field-sets"), array( "position" => $position ), array( "id" => $id ), "%d", "%d" ); 
          }
          
        }
        
        
      }        
      
      return $field_set;
      
    } else if ($action == "delete") { 

      $fg = MasterPress::$view->parent = call_user_func_array( array($this->model_class, "find_by_id"), array(MasterPress::$id));

      if ($fg) {

        $field_data_action = $_POST["field_data"];
        
        if ($field_data_action == "delete") {
          $fg->delete_meta();
        }

      }
      
      $fg->delete();
      
      return true;

    } else if ($action == "delete-field") {

      $f = MPM_Field::find_by_id(MasterPress::$id);
      
      if ($f) {

        $field_data_action = $_POST["field_data"];
        
        if ($field_data_action == "delete") {
          $f->delete_meta();
        }

      }
      
      $f->delete();
      
      return true;
      
    } else if ($action == "create-field" || $action == "edit-field") {
      
      // FIELD OPERATIONS (NOT FIELD GROUPS!)
       
      $field = new MPM_Field();
      // consume the post data
      
      $field->field_set_id = $_POST["parent"];
      $field->name = $_POST["name"];
      $field->disabled = isset($_POST["disabled"]);
      $field->summary_options = $_POST["summary_options"];
      $field->required = isset($_POST["required"]);
      $field->labels = $_POST["labels"];
      $field->type = $_POST["type"]; 
      $field->icon = self::handle_icon("icon", "icon_select");
      $field->type_options = $_POST["type_options"];
      $field->position = $_POST["position"];
      $field->visibility = $this->get_visibility_val();
      $field->capabilities = self::handle_capabilities();

      if (MPC::is_create()) {
        $field->insert();
      } else if (MPC::is_edit()) {
        $field->update(MasterPress::$id);
      }

      if ($field->is_valid()) {

        if (MPC::is_edit()) {
          global $meow_provider;
          $meow_provider->migrate_field_meta($field, $_POST["name_original"]);
        }
        
        // update other menu positions
        
        $op = MPC::post_val("other_position");
        
        if (isset($op) && is_array($op)) {
          foreach ($op as $id => $position) {
            $wpdb->update(MPM::table("fields"), array( "position" => $position ), array( "id" => $id ), "%d", "%d" ); 
          }
          
        }

        // clear the parent for the redirect
      
        MasterPress::$parent = null;

        
      }    
      
      
      return $field;
    } 
    
    
  }
Exemplo n.º 13
0
  public function grid($id = null) {

    MPV::incl("field-sets");
    MPV::incl("fields");
    MPV::incl("taxonomies");
    MPC::incl("taxonomies");
    

    $has_actions = MasterPress::current_user_can("edit_templates,delete_templates,manage_template_field_sets");
    $can_edit = MasterPress::current_user_can("edit_templates");
    $can_delete = MasterPress::current_user_can("delete_templates");
    $can_create = MasterPress::current_user_can("create_templates");
    $can_manage_field_sets = MasterPress::current_user_can("manage_template_field_sets");

    $colspan = $has_actions ? 8 : 7;

    
  ?>


  <?php MPV::messages(); ?>
  
  <table cellspacing="0" class="grid grid-post-types">
    <thead>
    <tr>
      <th class="first file-name front-end-name"><i class="script-php"></i><span><?php _e("File Name", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="name"><i class="template"></i><span><?php _e("Template Name", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="field-sets"><i class="metaboxes"></i><span><?php _e("Field Sets", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="post-types <?php echo $has_actions ? "" : "last" ?>"><i class="pins"></i><span><?php _e("Post Types", 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 $count = 0; $disabled = ""; ?>
    
    <?php $templates = get_page_templates();  ?>
    
    <?php foreach ($templates as $template => $file) : $count++; $first = $count == 1 ? 'first' : ''; $model = MPM_Template::find_by_id($file);
    
    
    $editable_class = $can_edit ? " editable " : "";
    $meta = $can_edit ? "{ href: '".MasterPress::admin_url("templates", "edit", "id=".$file)."' }" : "";


    ?>
    
    <tr class="<?php echo $first ?> <?php echo $editable_class.$disabled ?> <?php echo MPV::updated_class("edit,create", $file) ?> <?php echo $count % 2 == 0 ? "even" : "" ?> sub <?php echo $meta ?>">
      <td class="first file-name"><strong><span class="tt"><?php echo $file ?></span></strong></td>
      <td class="name"><?php echo $template ?></td>
      <td class="field-sets <?php echo $can_manage_field_sets ? "manage" : "" ?>">
        <?php if ($can_manage_field_sets) : ?>
        <a href="<?php echo MasterPress::admin_url( "templates", "manage-field-sets", "parent=".$file)?>">
		<i class="go"></i>
        <?php endif; ?>
        
        <?php 
        
        $field_sets = MPM_TemplateFieldSet::find_by_template( $file ); 

        $field_set_display = MPV::note_none();
        
        if (count($field_sets)) {
          $field_set_links = array();
          
          foreach ($field_sets as $field_set) {
            if (!$field_set->is_shared()) {
              $field_set_links[] =  $field_set->display_label();
            }
          }

          if (count($field_set_links)) {
            $field_set_display = implode($field_set_links, ", ");
          }
        
        }
        
        echo $field_set_display;
        ?>
        <?php if ($can_manage_field_sets) : ?>
        </a>
        <?php endif; ?>

      </td>
      
      <td class="post-types <?php echo $has_actions ? "" : "last" ?>">
        
        <?php 
        
        $vis = $model->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">( '.__("All", MASTERPRESS_DOMAIN).' )</span>';

        } else {
          
          if (is_null($vis_post_types) || $vis_post_types == "") {
          
            $post_type_display = __("( none )");
          
          } else {
            $post_types = $model->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>

      <?php if ($has_actions) : ?>

      <td class="actions last">
      <div>
        <?php if ($can_edit) : ?>
          <?php echo MPV::action_button("templates", "edit", self::__edit( ), "id=".$file, array("class" => "button button-edit")); ?>
        <?php endif; ?>

        <?php if ($can_manage_field_sets) : ?>
          <?php echo MPV::action_button("templates", "manage-field-sets", self::__manage( MPV_FieldSets::__p_short() ), "parent=".$file, array("class" => "button button-manage")); ?>
        <?php endif; ?>  
      </div>
      </td>

      <?php endif; // has_actions ?>

    </tr>
    
    <?php endforeach; ?>

    </tbody>
    </table>
    
    <?php
    
  } // end grid()
Exemplo n.º 14
0
  public static function post_column_content($key) {

    global $wf;
    
    $mode = "list";
    $post_type = "post";
    
    if (isset($_GET["mode"])) {
      $mode = $_GET["mode"];
    } 
    
    $pt = self::manage_post_type();

    if ($pt) {
      $columns = $pt->columns_by_key();
      if (isset($columns[$key])) {
        $column = $columns[$key];
    
        if (!isset($column["core"])) {
      
          // we only need to output custom columns
        
          if (isset($column["content"])) {
            $content = stripslashes($column["content"]);
            MasterPress::$context = "col";
            $out = WOOF::eval_expression($content, $wf->the);
            MasterPress::$context = "";
            echo $out;
          }
        }
      }
    }
    
  }
Exemplo n.º 15
0
  public static function do_validate_licence_key($key) {
    
    global $wf;
    
    // Please do not modify this code. 
    // Purchase a licence and help us support future development of this software. Thanks!

    $info = array();
    
    $current_key = MasterPress::licence_key();
    $cache_key = MPC_Settings::cache_key($current_key);

    // clear the current transient

    $wf->uncache($cache_key);
    
    if (self::valid_key_format($key)) {
      
      $args = array(
        "action" => "licence-check",
        "key" => $key,
        "domain" => $_SERVER['SERVER_NAME']
      );

      // Send the request to check for an update
    
      $response = MasterPress::update_request( $args );
      
      $result = $response->result;

      $info["error"] = $response->error;
      $info["valid"] = $result["valid"];
      $info["reason"] = $result["reason"];

      $wf->cache($cache_key, $info["valid"] ? "yes" : "no", "3d");
      
    } else {

      $info["error"] = __("Invalid licence key format", MASTERPRESS_DOMAIN);
      $info["valid"] = false;
      $info["reason"] = __("must be at least 33 characters long");
      
      $wf->cache($cache_key, $info["valid"] ? "yes" : "no", "3d");

    }
    
    return $info;
    
  }
Exemplo n.º 16
0
  public static function action_link( $controller, $action, $text, $qs = array(), $args = array(), $entities = true) {

    $def_args = array();
    $r = wp_parse_args($args, $def_args);

    $def_qs = array();
    $q = wp_parse_args($qs, $def_qs);
    
    $tag = '<a href="'.MasterPress::admin_url( $controller, $action, $qs, $entities ).'"';
    
    foreach ($r as $key => $value) {
      $tag .= ' '.$key.'="'.esc_attr($value).'" ';
    }
    
    if (!isset($r["title"])) {
      $tag .= ' title="'.strip_tags($text).'"';    
    }
    
    $tag .= ">";
    
    $tag .= $text.'</a>';
    
    return $tag;
  }
Exemplo n.º 17
0
  public static function ui( MEOW_Field $field ) {

    global $wf;

    $prop_inputs = self::prop_inputs($field, "attachment_id");

    
    $fileurl = "";
    $thumb = "";
    $width = "";
    $height = "";
    $filesize = "";
    $summary_thumb = "";
    $filename = "";
    $filetype = "";
    $empty = "";
    $orientation = "";
    
    $no_image = __("( no image )", MASTERPRESS_DOMAIN);

    $view_image = __("View Image", MASTERPRESS_DOMAIN);

    
    // setup defaults for an empty image

    list($tw, $th) = array(120, 90);
    list($stw, $sth) = array(82, 39);

    $empty = "empty";
    $orientation = "square";

    $thumb = WOOF_Image::empty_mp_thumb(array("w" => $tw, "h" => $th, "no_image" => $no_image, "class" => "managed thumb") );
    $summary_thumb = WOOF_Image::empty_mp_thumb(array("w" => $stw, "h" => $sth, "no_image" => $no_image, "class" => "managed summary-thumb" ) );
        
    if (!$field->blank()) {

      $image = $field->file();

      if ($image->exists()) {

        $empty = "";
         
        $width = $image->width();
        $height = $image->height();

        $orientation =  $height == $width ? "square" : ( $height > $width ? "portrait" : "landscape" );

        list($tw, $th) = self::thumb_wh($width, $height);
        list($stw, $sth) = self::summary_thumb_wh($width, $height);
        
        $filesize   = $image->filesize();
        $filename   = $image->basename();
        $filetype   = $image->filetype();
        
        if ($image->is_external()) {
          $fileurl    = $field->value();
          $source_url = $fileurl;
        } else {
          $fileurl    = $image->permalink();
        }

        $thumb = $image->mp_thumb(array("w" => $tw, "h" => $th, "no_image" => $no_image, "class" => "thumb managed", "href" => $fileurl));
        $summary_thumb = $image->mp_thumb(array("w" => $stw, "h" => $sth, "no_image" => $no_image, "class" => "managed summary-thumb", "thumb_only" => true ) );

      } 
          
    } else {
      $empty = "empty";
      $orientation = "square";
    }

    if (isset($source_url)) {
      $prop_source_url = $source_url;
    } else {
      $prop_source_url = $field->prop("source_url");
    }
    
    $prop_alt = esc_attr( $field->prop("alt") );
    $prop_title = esc_attr( $field->prop("title") );
      
    $replace_image_label = __("Replace Image:", MASTERPRESS_DOMAIN);
    $choose_image_label = __("Choose Image:", MASTERPRESS_DOMAIN);

    $attributes_label = __("Attributes", MASTERPRESS_DOMAIN);
    $attributes_title = __("Edit HTML attributes (alternate text / title)", MASTERPRESS_DOMAIN);

    $url_label = __("Enter Image URL:", MASTERPRESS_DOMAIN);

    $alt_label = __("Alternate Text:", MASTERPRESS_DOMAIN);
    $title_label = __("Title:", MASTERPRESS_DOMAIN);

    $attributes_title = __("Image Tag Attributes", MASTERPRESS_DOMAIN);

    $button_replace_label = __("Replace Image&hellip;", MASTERPRESS_DOMAIN);

    $button_from_computer_label = __("From Computer&hellip;", MASTERPRESS_DOMAIN);
    $button_from_media_library_label = __("From Media Library&hellip;", MASTERPRESS_DOMAIN);
    $button_from_url_label = __("From URL&hellip;", MASTERPRESS_DOMAIN);
    $button_from_existing_uploads_label = __("From Existing Uploads&hellip;", MASTERPRESS_DOMAIN);

    $button_from_media_library_data_library = MasterPress::use_new_media() ? "new" : "legacy";

    $button_clear_label = __("Clear", MASTERPRESS_DOMAIN);
    $button_delete_label = __("Delete", MASTERPRESS_DOMAIN);

    $button_download_label = __("Download", MASTERPRESS_DOMAIN);
    $button_cancel_label = __("Cancel", MASTERPRESS_DOMAIN);
    
    $button_clear_title = __("Clear field without deleting the image file", MASTERPRESS_DOMAIN);
    $button_delete_title = __("Clear field AND delete the image file", MASTERPRESS_DOMAIN);

    $w_times_h = __("width &times; height", MASTERPRESS_DOMAIN);

    $drop_label = __("Drop image<br />file here<br />to upload", MASTERPRESS_DOMAIN);

    $base_url = MASTERPRESS_CONTENT_URL;
    $dir = 'uploads/';

    $media_library_progress_message = __("Fetching URL from Media Library...", MASTERPRESS_DOMAIN);
    $upload_progress_message = __("Uploading...", MASTERPRESS_DOMAIN);
    $fetching_info_message = __("Fetching Image Information...", MASTERPRESS_DOMAIN);

    $dowloading_progress_message = __("Downloading Image...", MASTERPRESS_DOMAIN);

    $href = ' href="'.$fileurl.'" ';
      
    if ($fileurl == "") {
      $href = "";
    }
    
    // populate the media library dialog
    // $media_library_dialog 

    $upload_html = "";
    $download_html = "";
    $clear_html = "";
    $labels_html = "";
    $ml_html = "";
    
    $choose_html = "";
    
    $readonly = WOOF_HTML::readonly_attr( !$field->is_editable() );
    
    if ($wf->the_user->can("upload_files") && $field->is_editable()) {
      
      $choose_html = <<<HTML
      <div class="choose-controls">
        <h5 class="replace-label">{$replace_image_label}</h5>
        <h5 class="choose-label">{$choose_image_label}</h5>

        <div class="buttons">

          <div class="file-uploader { input: '#{{id}}', inputName: '{{id}}_file', ids: { drop: '{{id}}_drop_area' }, base_url: '{$base_url}', params: { dir: '{$dir}' }, limit: 1, lang: { buttonChoose: '{$button_from_computer_label}', buttonReplace: '{$button_from_computer_label}' } }">
            <input id="{{id}}" name="{{name}}" value="{$fileurl}" type="hidden" class="value" autocomplete="off" />
            <div class="uploader-ui"></div>
          </div>
          <!-- /.file-uploader -->

          <button type="button" class="button button-small button-from-url">{$button_from_url_label}</button>
          <button type="button" class="button button-small button-from-media-library" data-library="{$button_from_media_library_data_library}">{$button_from_media_library_label}</button>

        </div>
      
      </div>
      <!-- /.choose-controls -->
HTML;
   
    $clear_html = <<<HTML
    <ul class="controls">
      <li><button title="{$button_clear_title}" type="button" class="text with-icon clear">{$button_clear_label}</button></li>
    </ul>
HTML;

    } else {

      $choose_html = <<<HTML
<input id="{{id}}" name="{{name}}" value="{$fileurl}" type="hidden" class="value" autocomplete="off" />
HTML;

    }

    $html = <<<HTML

    <div class="ui-state {$empty}">
      

      {$prop_inputs}
    
      <div class="thumbs {$orientation}">

        <div id="{{id}}_drop_area" class="drop-area">{$drop_label}</div>

        {$summary_thumb}
        {$thumb}

      </div>
      <!-- /.thumbs -->

      <div class="info-controls">

        <div class="name-controls">
          <h5><a target="_blank" href="{$fileurl}" tabindex="-1" title="{$filename}" class="fancybox file-link with-icon"><span class="filename">{$view_image}</span></a></h5>
          {$clear_html}
        </div>

        <ul class="prop">
          <li class="filetype">{$filetype}</li>
          <li class="dimensions" title="{$w_times_h}"><span class="width">{$width}</span> &times; <span class="height">{$height}</span></li>
          <li class="filesize">{$filesize}</li>
          <li class="attributes"><button type="button" class="text with-icon attributes" title="{$attributes_title}">{$attributes_label}</button></li>
        </ul>

        {$choose_html}

        <div class="media-library-progress">
          <span class="fetching-message progress-message">{$media_library_progress_message}</span>  
          <span class="fetching-info-message progress-message">{$fetching_info_message}</span>  
        </div>
        <!-- /.media-library-progress -->
      
      
        <div class="upload-progress">

          <span class="name"></span>

          <div class="progress-bar-with-val">
            <div class="progress-bar"><div class="border"><div><span class="bar">&nbsp;</span></div></div></div>
            <div class="val">0%</div>
          </div>

          <span class="uploading-message progress-message">{$upload_progress_message}</span>  
          <span class="fetching-info-message progress-message">{$fetching_info_message}</span>  

        </div>
        <!-- /.upload-progress -->


        <div class="from-url-ui">
          <label for="{{id}}-url">{$url_label}</label>
          <input id="{{prop_id}}-source_url" name="{{prop_name}}[source_url]" type="text" value="{$prop_source_url}" class="text url" />

          <div class="buttons">
            <button type="button" class="button button-small download">{$button_download_label}</button>
            <button type="button" class="button button-small cancel">{$button_cancel_label}</button>
          </div>
        </div>
        <!-- /.from-url -->

        <div class="download-progress">
          <span class="downloading-message progress-message">{$dowloading_progress_message}</span>  
          <span class="fetching-info-message progress-message">{$fetching_info_message}</span>  
        </div>
        <!-- /.download-progress -->
      
      </div>
      <!-- /.info-controls -->

      <div class="dialogs">
        
        <div class="mpft-image-attributes-dialog mp-dialog mpv" data-title="{$attributes_title}">
          <div class="pad">
          
          <div class="f">
            <label for="{{prop_id}}-alt">{$alt_label}</label>
            <div class="fw">
              <input id="{{prop_id}}-alt" $readonly name="{{prop_name}}[alt]" value="{$prop_alt}" type="text" class="text alt" />
            </div>
            <!-- /.fw -->
          </div>
          <!-- /.f -->
        
          <div class="f">
            <label for="{{prop_id}}-title">{$title_label}</label>
            <div class="fw">
              <input id="{{prop_id}}-title" $readonly name="{{prop_name}}[title]" value="{$prop_title}" type="text" class="text title"  />
            </div>
            <!-- /.fw -->
          </div>
          <!-- /.f -->
        
          </div>
          <!-- /.pad -->
        </div>
    
      </div>
      <!-- /.dialogs -->
      
      
    </div>
    <!-- /.ui-state -->

HTML;

    return $html;

  }
Exemplo n.º 18
0
  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()
Exemplo n.º 19
0
  public function grid($id = null) {

    MPV::incl("field-sets");
    MPV::incl("fields");
    MPV::incl("taxonomies");
    MPC::incl("taxonomies");
    
    $post_types = MPM_PostType::find("orderby=disabled,name ASC");
    
    $has_actions = MasterPress::current_user_can("edit_post_types,delete_post_types,manage_post_type_field_sets");
    $can_edit = MasterPress::current_user_can("edit_post_types");
    $can_delete = MasterPress::current_user_can("delete_post_types");
    $can_create = MasterPress::current_user_can("create_post_types");
    $can_manage_field_sets = MasterPress::current_user_can("manage_post_type_field_sets");

    $less = $can_create ? 1 : 0;
    $colspan = ( $has_actions ? 8 : 7 ) - $less;


  ?>

  <?php MPV::messages(); ?>
  
  <?php 
  foreach ($post_types as $post_type) {
    if (MPC::is_deleting($post_type->id)) {
      self::confirm_delete($post_type);
    }
  }
  
  ?>
  
  <table cellspacing="0" class="grid grid-post-types">
    <thead>
    <tr>
      <th class="first menu-icon"><i class="menu-icon" title="<?php _e("Menu Icon", MASTERPRESS_DOMAIN) ?>"></i><span class="ac"><?php _e("Menu Icon", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="menu-label"><i class="label-string"></i><span><?php _e("Label", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="post-type-name"><i class="script-php"></i><span><?php _e("Name", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="hierarchical"><i class="hierarchy"></i><span class="ac" title="<?php _e("Hierarchical?", MASTERPRESS_DOMAIN) ?>"><?php _e("Hierarchical?", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="field-sets"><i class="metaboxes"></i><span><?php _e("Field Sets", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="shared-field-sets"><i class="med share-metaboxes"></i><span><?php _e("Shared Field Sets", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="taxonomies <?php echo $has_actions ? "" : "last" ?>"><i class="tags"></i><span><?php _e("Taxonomies", 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 $count = 0; ?>
    
    <?php foreach ($post_types as $post_type) : $disabled = ( $post_type->disabled ) ? "disabled" : "";  $title = $post_type->disabled ? ' title="'.__("this post type is disabled", MASTERPRESS_DOMAIN).'" ' : ""; 
    
    if (!$post_type->in_current_site()) {
      $disabled = "disabled";
      $title = ' title="'.__("this post type is not currently available in this site (multi-site setting)", MASTERPRESS_DOMAIN).'" ';
    }

    
    ?>
    
    <?php if ($post_type->still_registered()) : $count++; $first = $count == 1 ? 'first' : ''; ?>
      
    <?php 
    
    $deleting_class = MPC::is_deleting($post_type->id, "delete") ? 'deleting' : ''; 
    $editable_class = $can_edit ? " editable " : "";
    $meta = $can_edit ? "{ href: '".MasterPress::admin_url("post-types", "edit", "id=".$post_type->id)."' }" : "";
    
    ?>
    

    <tr <?php echo $title ?> class="<?php echo $first ?> <?php echo $editable_class.$deleting_class ?> <?php echo $disabled ?> <?php echo MPV::updated_class("edit,create", $post_type->id) ?> <?php echo $count % 2 == 0 ? "even" : "" ?> sub <?php echo $meta ?>">
      <td class="first menu-icon icon"><span class="mp-icon-post-type mp-icon-post-type-<?php echo $post_type->name ?>"></span></td>
      <td class="menu-label"><strong><?php echo $post_type->labels["menu_name"] ?></strong></td>
      <td class="post-type-name"><span class="tt"><?php echo $post_type->name ?></span></td>
      <td class="hierarchical"><?php echo $post_type->hierarchical ? '<i class="tick-small"></i><span class="ac" title="'.__("this post type is hierarchical", MASTERPRESS_DOMAIN).'">yes</span>' : '<span class="note" title="'.__("this post type is not hierarchical", MASTERPRESS_DOMAIN).'">&ndash;</span>' ?></td>

      <?php $field_sets = $post_type->field_sets("name ASC"); ?>

      <?php if ($post_type->show_ui) : ?>
        
      <td class="field-sets <?php echo $can_manage_field_sets ? "manage { href: '".MasterPress::admin_url( "post-types", "manage-field-sets", "parent=".$post_type->id)."' }" : "" ?>">
        <?php if ($can_manage_field_sets) : ?>
        <a href="<?php echo MasterPress::admin_url( "post-types", "manage-field-sets", "parent=".$post_type->id)?>" title="<?php echo strip_tags(self::__manage( MPV_FieldSets::__p() )) ?>">
		<i class="go"></i>
        <?php endif; ?>

        <?php 
        
        $field_set_display = MPV::note_none();
        
        if (count($field_sets)) {
          $field_set_links = array();
          
          foreach ($field_sets as $field_set) {
            if (!$field_set->is_shared()) {
              $field_set_links[] =  $field_set->display_label();
            }
          }

          if (count($field_set_links)) {
            $field_set_display = implode($field_set_links, ", ");
          }
        
        }
        
        echo $field_set_display;
        ?>
        <?php if ($can_manage_field_sets) : ?>
        </a>
        <?php endif; ?>
      </td>
      <?php else: ?>
      <td class="field-sets">
      <span title="<?php _e("This post type does not support field sets as the 'show ui' parameter is off", MASTERPRESS_DOMAIN); ?>"><i class="na"></i><?php _e("N/A", MASTERPRESS_DOMAIN); ?></span>  
      </td>
      <?php endif; ?>

      <?php if ($post_type->show_ui) : ?>
    
      <td class="shared-field-sets">
        
        <?php 
        
        $field_set_display = MPV::note_none();
      
        if (count($field_sets)) {
          $field_set_links = array();
          
          foreach ($field_sets as $field_set) {
            if ($field_set->is_shared()) {
              $field_set_links[] = $field_set->display_label(); 
            }
          }

          if (count($field_set_links)) {
            $field_set_display = implode($field_set_links, ", ");
          }
        
        }
        
        echo $field_set_display;
        ?>
        
      </td>
      
      <?php else: ?>
      <td class="shared-field-sets">
      <span title="<?php _e("This post type does not support shared field sets as the 'show ui' parameter is off", MASTERPRESS_DOMAIN); ?>"><i class="na"></i><?php _e("N/A", MASTERPRESS_DOMAIN); ?></span>  
      </td>
      <?php endif; ?>


      <td class="taxonomies <?php echo $has_actions ? "" : "last" ?>">
        <?php 
        $taxonomies = $post_type->taxonomies(); 
        
        $tax_display = MPV::note_none();
        
        if (count($taxonomies)) {
          $tax_links = array();
          
          foreach ($taxonomies as $tax) {
            $tax_links[] = $tax->labels["name"]; 
          }

          $tax_display = implode($tax_links, ", ");
        }
        
        echo $tax_display;
        ?>
      </td>      

      <?php if ($has_actions) : ?>

      <td class="actions last">
      <div>
        <?php if (MPC::is_deleting($post_type->id)) : ?>
        
        <span class="confirm-action"><?php _e("Please Confirm Delete Action", MASTERPRESS_DOMAIN) ?></span>
        
        <?php else: ?>

          <?php if ($can_manage_field_sets) : ?>

            <?php if ($post_type->show_ui) :  ?>
            <?php echo MPV::action_button("post-types", "manage-field-sets", self::__manage( MPV_FieldSets::__p_short() ), "parent=".$post_type->id, array("class" => "button button-manage")); ?>
            <?php else: ?>
            <?php echo MPV::action_button("post-types", "manage-field-sets", self::__manage( MPV_FieldSets::__p_short() ), "parent=".$post_type->id, array("title" => "This post type does not support field sets as the 'show ui' parameter is off", "disabled" => "disabled", "class" => "button button-manage")); ?>
            <?php endif; ?>
      
          <?php endif; ?>
        
          <?php if ($can_edit) : ?>
            <?php echo MPV::action_button("post-types", "edit", self::__edit( "" ), "id=".$post_type->id, array( "class" => "button primary button-edit" )); ?>
          <?php endif; ?>

          <?php if ($can_delete) : ?>
            <?php if ($post_type->_builtin) : ?>
            <span class="note" title="<?php _e("This post type cannot be deleted as it is built-in to WordPress", MASTERPRESS_DOMAIN) ?>"><?php _e("( Built-in )", MASTERPRESS_DOMAIN) ?></span>
            <?php elseif ($post_type->_external) : ?>
            <span class="note" title="<?php _e("This post type cannot be deleted as it was not created by MasterPress", MASTERPRESS_DOMAIN) ?>"><?php _e("( External )", MASTERPRESS_DOMAIN) ?></span>
            <?php else: ?>
        
            <?php echo MPV::action_button("post-types", "delete", self::__delete( "" ), "id=".$post_type->id, array( "class" => "button button-delete", "title" => "Delete - Requires Confirmation" )); ?>
            <?php endif; ?>
          <?php endif; ?>
      
        <?php endif; // has_actions ?>
      </div>
      </td>
      
      <?php endif; ?>
      
    </tr>
  
    <?php endif; ?>

    <?php endforeach; ?>

    <tr class="summary <?php echo $can_create ? "editable" : "" ?>">
      <td colspan="<?php echo $colspan ?>" class="first <?php echo $can_create ? "" : "last" ?>"><?php _e(  MPU::__items( $count, __("<strong>%d</strong> Post Type", MASTERPRESS_DOMAIN), __("%d Post Types", MASTERPRESS_DOMAIN)   ) ) ?></td>
      <?php if ($can_create) : ?>
      <td class="last">
      <?php echo MPV::action_button("post-types", "create", self::__create(MPV_PostTypes::__s()), "", array( "class" => "button button-create" ) ); ?>
      </td>
      <?php endif; ?>
    </tr>
    

    </tbody>
    </table>


    
    <?php
    


  } // end grid()
Exemplo n.º 20
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
  }
Exemplo n.º 21
0
  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()
Exemplo n.º 22
0
  public static function find_by_in($model, $field, $values, $format = "%s", $table = null) {
    
    global $wpdb;

    if (!$table) {
      $table = MPM::table($model);
    }

    if (!is_array($values)) {
      if (!$values || $values == "") {
        return array();
      } else {
        $values = array( $values );
      }
      
    } else if (!count($values)) {
      return array();
    } 
    
    $model_class = MasterPress::model_class($model);
    
    if (!is_array($format)) {
      $format = array_fill(0, count($values), $format);
    }
    
    // setup args for prepare
    
    $prepare_args = array_merge( array("SELECT * FROM `".$table."` WHERE {$field} IN (".implode(",", $format).")"), $values );
    
    $sql = call_user_func_array( array($wpdb, "prepare"), $prepare_args );

    $results = $wpdb->get_results($sql);
    
    $models = array();
    
    foreach ($results as $result) {
      $m = new $model_class();
      $m->set_from_row($result);
      $models[] = $m;
    }
    
    return $models;
  }
Exemplo n.º 23
0
  public function edit($args = array()) {
    
    $model = null;

    $defaults = array(
      "init_model" => true,
      "view" => $this->view_key(), 
      "model" => $this->model_key(),
      "manage" => "manage",
      "title_args" => array(),
      "cap_verified" => false
    );

    $r = wp_parse_args($args, $defaults);

    if (!$r["cap_verified"] && !MasterPress::current_user_can($this->cap("edit"))) {
      wp_die(__("Sorry, you do not have the required capability to edit this item.", MASTERPRESS_DOMAIN));
    }


    MasterPress::$model_class = MasterPress::model_class($r["model"]);
    MasterPress::$view_class = MasterPress::view_class($r["view"]);

    $view_class = MasterPress::$view_class;
    $model_class = MasterPress::$model_class;

    MPV::incl($r["view"]);

    $manage = $r["manage"];
    
    if ($this->is_postback()) {
      
      $key = $this->key();
        
      if (isset($_REQUEST["return"])) {
        $key = $_REQUEST["return"];

        if ($key == "masterpress") {
          $key = "";
        } else {
          $key = str_replace("masterpress-", "", $key);
        }
      
      }
          
      if (apply_filters("mp_mpc_edit", $do = true)) {

        $model = $this->submit();
        MasterPress::$model = $model; 
      
        $valid = false;
      
        if ($model && is_object($model)) {
          $valid = $model->is_valid();
        } else {
          $valid = $model;
        } 
      
        if ( $valid ) {
          // hallelulah! we can now do proper redirects, rather than a fake action.
          // this prevents issues with refreshing the manage page after a save showing the form with "this item already exists"

          $qs = array("from" => MasterPress::$action);
        
          self::fill_redirect_parent($qs);

          if (is_object($model)) {
            $id = $model->id;
        
            if (isset($id)) {
              $qs["id"] = $id;
            }
          } else {
            $qs["id"] = MasterPress::$id;
          }
      
          if (isset($_REQUEST["mp_redirect"])) {
            wp_redirect( $_REQUEST["mp_redirect"] . "&def_updated=1" );
            exit;
          }
          
          wp_redirect( MasterPress::admin_url( $key, $manage, $qs, false ) );

          exit();
          return true;
        } else {
          if (is_object($model)) {
            $this->log_model_errors($model);
          }
        }
      
      } else {

        $qs = array( "id" => $_POST["id"], "from" => MasterPress::$action );

        self::fill_redirect_parent($qs);
        
        // submit disabled - simply redirect back to the manage screen
        wp_redirect( MasterPress::admin_url( $key, $manage, $qs, false ) );
        exit;
        
      } // apply_filters
      
    } else {
      
      if ($r["init_model"] && class_exists($model_class)) {
        $model = call_user_func_array( array($model_class, "find_by_id"), array(MasterPress::$id) );
        MasterPress::$model = $model;
      }
    }
      
    // set view variables

    $this->setup_view( 
      array(
        "view" => $r["view"],
        "title_args" => wp_parse_args($r["title_args"], array( "text" => MPV::__edit( call_user_func( array( $view_class, "__s" ) ) ), "actions" => "update", "info_panel" => false, "controller" => $this->key() )),
        "form" => true,
        "method" => "form",
        "method_args" => array( "type" => "edit" ),
      )
    );

    
    
  }
Exemplo n.º 24
0
 public function current_user_can_manage() {
   
   $cap = "manage_options";
   
   if (MasterPress::$cap_mode == "specific") {
     switch ($this->type) {
       case "p" :
         $cap = "manage_post_type_field_sets";
         break;
       case "x" :
         $cap = "manage_taxonomy_field_sets";
         break;
       case "t" :
         $cap = "manage_template_field_sets";
         break;
       case "s" :
         $cap = "manage_shared_field_sets";
         break;
       case "w" :
         $cap = "manage_site_field_sets";
         break;
     }
     
   } 
   
   return MasterPress::current_user_can($cap);
   
 }