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

		global $wf, $blog_id;
		
    $this->setup_view( array(
        "title_args" => array( "text" => sprintf( __("Masterplan - <small>Powered by %s</small>", MASTERPRESS_DOMAIN), '<a href="http://masterpressplugin.com" target="_blank">MasterPress</a>' ) )
      )
    );

    if (defined("MASTERPRESS_LEGACY_DIR_MIGRATE")) {
      
  		if (defined("MASTERPRESS_LEGACY_DIR") && MasterPress::$action != "legacy_dir_migrate") {
			
  			update_option("mp_legacy_dir", "1");
			
  			$ud = wp_upload_dir(); 

  			$steps  = WOOF_HTML::open("ul");
			
  			$new_ul_base = str_replace($wf->site->url, "", $ud["baseurl"]) . "/mp/files/$1";
			
  			$rules = <<<HTML
		
  			&lt;IfModule mod_rewrite.c&gt;<br>

  			RewriteEngine On<br>
  			RewriteBase /<br>
  			<br>
  			RewriteCond %{REQUEST_FILENAME} !-f<br>
  			RewriteRule ^wp-content/mp/uploads/(.+) $new_ul_base [PT]<br>
  			<br>
  			RewriteCond %{REQUEST_FILENAME} !-f<br>
  			RewriteRule ^wp-content/blogs.dir/([0-9]+)/mp/uploads/(.+) wp-content/blogs.dir/$1/mp/files/$2 [PT]<br>
  			<br>
  			RewriteCond %{REQUEST_FILENAME} !-f<br>
  			RewriteRule ^wp-content/mp/(.+) wp-content/uploads/mp/$1 [PT,L]<br>
  			&lt;/IfModule&gt;	
			
HTML;
	
  			$step = 1;
			
  			$steps .= WOOF_HTML::tag("li", "", __("<b>".$step++.".</b> Backup your WordPress database."), MASTERPRESS_DOMAIN );
			
  			$steps .= WOOF_HTML::tag("li", "", sprintf( __("<b>(Optional)</b>. To avoid 404s from existing links to your files, you may wish to place the following lines just above in your .htaccess file (at the root of your site).<code>%s</code><br><b>IMPORTANT:</b> These rules should be <b>placed just above the line # BEGIN WordPress </b> in your .htaccess file, as placing it above rules from caching plugins may cause issues.", MASTERPRESS_DOMAIN ), $rules ) );
			
  			if (MASTERPRESS_MULTI) {

  				if (WOOF_MS_FILES) {

  					if (is_main_site()) {
  						$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Move the masterpress content folder currently at:<br> <span class="tt">%s/mp</span><br>to:<br> <span class="tt">%s/mp</span>', MASTERPRESS_DOMAIN ), $step++, WP_CONTENT_DIR, $ud["basedir"] ) );
  						$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Rename the folder:<br> <span class="tt">%s/mp/uploads</span><br>to:<br> <span class="tt">%s/mp/files</span>', MASTERPRESS_DOMAIN ), $step++, WP_CONTENT_DIR, WP_CONTENT_DIR  ) );
  					}
				
  					$base = WP_CONTENT_DIR . WOOF_DIR_SEP . "blogs.dir" . WOOF_DIR_SEP . $blog_id;
  					$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d</b> Rename the folder:<br> <span class="tt">%s/mp/uploads</span><br>to:<br> <span class="tt">%s/mp/files</span>', MASTERPRESS_DOMAIN ), $step++, $base , $base  ) );
  					$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d</b> Click the migrate links button below to update your custom field database entries to point to the new location:<br>%s', MASTERPRESS_DOMAIN ), $step++, WOOF_HTML::tag("a", array("href" => MasterPress::admin_url( "masterplan", "legacy_dir_migrate", "", false ), "class" => "button button-small" ), "Migrate Links" ) ) ); 

  				} else {
				
  					if (is_main_site()) {

  						$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Move the masterpress content folder currently at:<br> <span class="tt">%s/mp</span><br>to:<br> <span class="tt">%s/mp</span>', MASTERPRESS_DOMAIN ), $step++, WP_CONTENT_DIR, $ud["basedir"] ) );
  						$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Rename the folder:<br> <span class="tt">%s/mp/uploads</span><br>to:<br> <span class="tt">%s/mp/files</span>', MASTERPRESS_DOMAIN ), $step++, $ud["basedir"], $ud["basedir"]  ) );
  						$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Click the migrate links button below to update your custom field database entries to point to the new location:<br>%s', MASTERPRESS_DOMAIN ), $step++, WOOF_HTML::tag("a", array("href" => MasterPress::admin_url( "masterplan", "legacy_dir_migrate", "", false ), "class" => "button button-small" ), "Migrate Links" ) ) ); 

  					} else {
					
  						$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Rename the folder:<br> <span class="tt">%s/mp/uploads</span><br>to:<br> <span class="tt">%s/mp/files</span>', MASTERPRESS_DOMAIN ), $step++, $ud["basedir"], $ud["basedir"]  ) );
  						$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Click the migrate links button below to update your custom field database entries to point to the new location:<br>%s', MASTERPRESS_DOMAIN ), $step++, WOOF_HTML::tag("a", array("href" => MasterPress::admin_url( "masterplan", "legacy_dir_migrate", "", false ), "class" => "button button-small" ), "Migrate Links" ) ) ); 
				
  					}
				
  				}
				
  			} else {
				
  				$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Move the masterpress content folder currently at:<br> <span class="tt">%s/mp</span><br>to:<br> <span class="tt">%s/mp</span>', MASTERPRESS_DOMAIN ), $step++, WP_CONTENT_DIR, $ud["basedir"] ) );
  				$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Rename the folder:<br> <span class="tt">%s/mp/uploads</span><br>to:<br> <span class="tt">%s/mp/files</span>', MASTERPRESS_DOMAIN ), $step++, $ud["basedir"], $ud["basedir"]  ) );
  				$steps .= WOOF_HTML::tag("li", "", sprintf( __('<b>%d.</b> Click the migrate links button below to update your custom field database entries to point to the new location:<br>%s', MASTERPRESS_DOMAIN ), $step++, WOOF_HTML::tag("a", array("href" => MasterPress::admin_url( "masterplan", "legacy_dir_migrate", "", false ), "class" => "button button-small" ), "Migrate Links" ) ) ); 
			
  			}
			
  			$steps .= WOOF_HTML::close("ul");
			
  			MPV::warn( sprintf( __('Your MasterPress installation is storing certain content in folders which are <a href="%s">no longer the default locations in version 1.0.1.</a><br><br>To migrate to the new location: %s', MASTERPRESS_DOMAIN ), "http://masterpressplugin.com/blog/content-in-101/", $steps ) );
			
  		} else if (get_option("mp_legacy_dir")) {
			
  			$migrate = sprintf( __('Click the migrate links button below to update your custom field database entries to point to the new location:<br>%s', MASTERPRESS_DOMAIN ), WOOF_HTML::tag("a", array("href" => MasterPress::admin_url( "masterplan", "legacy_dir_migrate", "", false ), "class" => "button button-small" ), "Migrate Links" ) ); 

  			MPV::warn( sprintf( __('It appears you\'ve moved your MasterPress content folder from the old <span class="tt">wp-content/mp</span> location without running the necessary database migration.<br><br>%s', MASTERPRESS_DOMAIN ), $migrate ) );
			
  		}
		
		}
    
    if (isset($_POST["import_masterplan"]) || isset($_POST["restore_masterplan"])) {
      self::import();
    } 

  }
Ejemplo n.º 2
0
 function enclosure($attr = array()) {
   
   $a = wp_parse_args($attr);
   
   $a["length"] = $this->bytes();
   $a["type"] = $this->mime();
   $a["url"] = $this->permalink();
   
   return WOOF_HTML::tag("enclosure", $a);
   
 }
Ejemplo n.º 3
0
  public function dump_item($key, $value) {
    $html = '';
    $html .= WOOF_HTML::open("tr");
    $html .= WOOF_HTML::tag("th", array("scope" => "row"), $key);

    if (is_array($value)) {
      
      $html .= WOOF_HTML::open("td");
      $html .= WOOF_HTML::open("table");
    
      foreach ($value as $sub_key => $sub_value) {
        $html .= $this->dump_item($sub_key, $sub_value);
      }

      $html .= WOOF_HTML::close("table");
      $html .= WOOF_HTML::close("td");
      
    } else {
      $html .= WOOF_HTML::tag("td", array(), $value);
    }
    
    $html .= WOOF_HTML::close("tr");
    
    return $html;
  }
Ejemplo n.º 4
0
  public static function prop_input($field, $key) {

    $attr = array(
      "id" => "{{prop_id}}-".$key,
      "name" => "{{prop_name}}[".$key."]",
      "autocomplete" => "off",
      "type" => "hidden",
      "class" => "prop-".$key
    );
    
    $val = $field->prop_val($key);
    
    if ($val && $val != "") {
      $attr["value"] = $val;
    }
      
    return WOOF_HTML::tag("input", $attr);
  }
Ejemplo n.º 5
0
 function terms($taxonomy) {
   
   global $wf;
   
   $label = $wf->taxonomy($taxonomy)->singular_label();
   
   $post_type = "post";
   
   if (isset($_GET["post_type"])) {
     $post_type = $_GET["post_type"];
   }
   
   $terms = $this->post->terms($taxonomy);
   
   $ret = array();
   
   foreach ($terms as $term) {
     $ret[] = WOOF_HTML::tag("a", array("href" => admin_url("edit.php?post_type=".$post_type."&".$taxonomy."=".$term->slug()."&mp_view=".urlencode( sprintf( __("With the %s '%s'", WOOF_DOMAIN), $label, $term->name) ))), $term->name);
   }
   
   return implode(", ", $ret);
   
 }
Ejemplo n.º 6
0
    function pagination($args = array()) {
      /* Based on code from Sparklette studios http://design.sparklette.net/teaches/how-to-add-wordpress-pagination-without-a-plugin/# */

      $html = "";
      
      global $wp_query;

      $r = wp_parse_args( 
        $args,
        array(
          "pages" => '', 
          "page_var" => "paged",
          "range" => 5,
          
          "link_callback" => "get_pagenum_link",
          "class_page" => "page",

          "class_current" => "current",
          "class_inactive" => "inactive",
          "class_wrap" => "pagination",
          "tag_wrap" => "nav",

          "tag_wrap_pages" => "div",
          "class_pages" => "pages",
          
          "show_page_count" => true,
          "tag_page_count" => "span",
          "class_page_count" => "page-count",
          "t_page_count" => __("Page %d of %d", WOOF_DOMAIN),
          
          "show_first" => true,
          "class_first" => "first",
          "title_first" => __("First Page", WOOF_DOMAIN),
          "t_first" => __("&laquo; First", WOOF_DOMAIN),
          
          "show_previous" => true,
          "class_previous" => "previous",
          "title_previous" => __("Previous Page", WOOF_DOMAIN),
          "t_previous" => __("&lsaquo; Previous", WOOF_DOMAIN),

          "show_next" => true,
          "class_next" => "next",
          "title_next" => __("Next Page", WOOF_DOMAIN),
          "t_next" => __("Next &rsaquo;", WOOF_DOMAIN),
          
          "show_last" => true,
          "class_last" => "last",
          "title_last" => __("Last Page", WOOF_DOMAIN),
          "t_last" => __("Last &raquo;", WOOF_DOMAIN)
        )
      );

      
      extract($r);

      $showitems = ($range * 2) + 1;  
      
      $paged = get_query_var($r["page_var"]);
      
      if (!$paged) $paged = 1;

      if ($pages == '') {

        $pages = $wp_query->max_num_pages;

        if (!$pages) {
          $pages = 1;
        }

      }   

      if (1 != $pages) {
        
        if ($show_page_count) {
          $html .= WOOF_HTML::tag($tag_page_count, array("class" => $class_page_count), sprintf($t_page_count, $paged, $pages));
        }
        

        $limit = !($paged > 2 && $paged > $range + 1 && $showitems < $pages);
        
        if ($show_first && ($show_first == "always" || !$limit)) {
          if ($paged == 1) {
            $html .= WOOF_HTML::tag("span", array("class" => $class_first), $t_first);
          } else {
            $href = call_user_func( $r["link_callback"], 1 );
            $html .= WOOF_HTML::tag("a", array("href" => $href, "title" => $title_first, "class" => $class_first), $t_first);
          }
        }

        $limit = !($paged > 1 && $showitems < $pages);
        
        if ($show_previous && ($show_previous == "always" || !$limit)) {
          if ($paged == 1) {
            $html .= WOOF_HTML::tag("span", array("class" => $class_previous), $t_previous);
          } else {
            $href = call_user_func( $r["link_callback"], $paged - 1 );
            $html .= WOOF_HTML::tag("a", array("href" => $href, "title" => $title_previous, "class" => $class_previous), $t_previous);
          }
        }

        $html .= WOOF_HTML::open($tag_wrap_pages, array("class" => $class_pages));

        $pc = 0;

        for ($i=1; $i <= $pages; $i++) {
          if (1 != $pages && ( !($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems )) {
            $pc++;
            
            $class = array($class_page);
            
            if ($paged == $i) {
              $class[] = $class_current;
              $html .= WOOF_HTML::tag("span", array("class" => implode(" ", $class)), $i);
              
            } else {
              $class[] = $class_inactive;
              $href = call_user_func( $r["link_callback"], $i );
              $html .= WOOF_HTML::tag("a", array("href" => $href, "class" => implode(" ", $class)), $i);
            }
            
            
          }
        }

        $html = WOOF_HTML::open($tag_wrap, array("class" => $class_wrap." with-$pc-pages $class_wrap-with-$pc-pages")).$html;
        
        $html .= WOOF_HTML::close($tag_wrap_pages);

        $limit = !( $paged < $pages && $showitems < $pages );
        
        if ($show_next && ($show_next == "always" || !$limit)) {
          
          if ($pages == $paged) {
            $html .= WOOF_HTML::tag("span", array("class" => $class_next), $t_next);
          } else {
            $href = call_user_func( $r["link_callback"], $paged + 1 );
            $html .= WOOF_HTML::tag("a", array("href" => $href, "title" => $title_next, "class" => $class_next), $t_next);
          }
        
        }

        $limit = !($pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages);
        
        if ($show_last && ($show_last == "always" || !$limit)) {
          if ($pages == $paged) {
            $html .= WOOF_HTML::tag("span", array("class" => $class_last), $t_last);
          } else {
            $href = call_user_func( $r["link_callback"], $pages );
            $html .= WOOF_HTML::tag("a", array("href" => $href, "title" => $title_last, "class" => $class_last), $t_last);
          }
        }

        
        $html .= WOOF_HTML::close($tag_wrap);
    
      }
      
      return $html;
      
    }
Ejemplo n.º 7
0
  public static function create_directories() {
    
    MPU::incl("view/mpv.php");

    global $wf;
    global $blog_id;
    
    $main_exists = true;
    $global_exists = true;
		$try_content = true;
		

    self::$is_masterplan = ( isset($_GET["page"] ) && $_GET["page"] == "masterpress" );
    
    
    if (!file_exists(MASTERPRESS_CONTENT_DIR)) {
      
			if ($try_content) {

	      // if the base uploads directory doesn't exist, try to create it
	      if (!wp_mkdir_p(MASTERPRESS_CONTENT_DIR)) {
	        $main_exists = FALSE;
			
					// check that the base blogs.dir actually exists!
					$bd_base_dir = WP_CONTENT_DIR.WOOF_DIR_SEP."blogs.dir";
				
	        if (is_multisite()) {
	  				MPV::warn(sprintf(__('<strong>Note: the MasterPress content folder %s for this site does not yet exist and cannot be automatically created</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give the %s folder permission <strong>777</strong> so that MasterPress can create the necessary folders.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved.', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_CONTENT_DIR.'</span>', '<span class="tt">wp-content/blogs.dir/'.$blog_id.'/</span>', self::dir_cmd(WP_CONTENT_DIR.WOOF_DIR_SEP."blogs.dir".WOOF_DIR_SEP.$blog_id.WOOF_DIR_SEP), '"'.MPU::current_url().'"')); 
	        } else {
	          MPV::warn(sprintf(__('<strong>Note: the MasterPress content folder %s does not yet exist and cannot be automatically created</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give the %s folder the permission <strong>777</strong> so that MasterPress can create the necessary folders.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved.', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_CONTENT_DIR.'</span>', '<span class="tt">wp-content</span>', self::dir_cmd(WP_CONTENT_DIR), '"'.MPU::current_url().'"')); 
	        }
      
	        update_site_option("mp_dir_problem", true);
        
	      } else {
        
	        chmod(MASTERPRESS_CONTENT_DIR, 0755);
        
	      }

			}
		
    }
    
    
    if (!file_exists(MASTERPRESS_GLOBAL_CONTENT_DIR)) {
      // if the global content directory doesn't exist, try to create it
      if (MASTERPRESS_GLOBAL_CONTENT_DIR != MASTERPRESS_CONTENT_DIR) {
        
        if (!wp_mkdir_p(MASTERPRESS_GLOBAL_CONTENT_DIR)) {
          $global_exists = FALSE;
          MPV::warn(sprintf(__('<strong>Note: the MasterPress shared content folder %s for your multi-site network does not yet exist and cannot be automatically created</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give the %s folder the permission <strong>777</strong> so that MasterPress can create the necessary folders.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_GLOBAL_CONTENT_DIR.'</span>', '<span class="tt">wp-content</span>', self::dir_cmd(WP_CONTENT_DIR), '"'.MPU::current_url().'"')); 

          update_site_option("mp_dir_problem", true);
        
        } else {
        
          chmod(MASTERPRESS_GLOBAL_CONTENT_DIR, 0755);

        }
        
      } 
      
    } 

    $warning_777 = __('Please change the permissions of your <span class="tt">wp-content</span> directory to <span class="tt">755</span>. <br />');

    $stop_trying_global = false;
    $stop_trying = false;

    
    if ($main_exists && $global_exists) {
      
      $stop_trying = false;
      $stop_trying_global = false;
      
      // test if the standard sub-directories exist
      
      $not_writable_warning = sprintf(__('<strong>Note: the MasterPress folder %s does not seem to be writable</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give this folder the permission 777.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_CONTENT_DIR.'.</span>', self::chmod_cmd(MASTERPRESS_CONTENT_DIR), '"'.MPU::current_url().'"');
      
      if (is_multisite()) {
        $not_writable_global_warning = sprintf(__('<strong>Note: the MasterPress shared folder %s for your multi-site network does not seem to be writable</strong>, which will cause problems when using MasterPress.<br /><br />Using your FTP client, server admin panel, or operating system (for local installations), please give this folder the permission 777.<br /><br />Alternatively, use the following command if you have shell or terminal access: %s<br /><a href=%s>Click here</a> once this is complete, to verify this problem has been solved', MASTERPRESS_DOMAIN), '<span class="tt">'.MASTERPRESS_GLOBAL_CONTENT_DIR.'</span>', self::chmod_cmd(MASTERPRESS_GLOBAL_CONTENT_DIR), '"'.MPU::current_url().'"');
      } else {
        $not_writable_global_warning = $not_writable_warning;
      }
      
      if (!$stop_trying) {
        
        if (!file_exists(MASTERPRESS_CONTENT_IMAGE_CACHE_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_IMAGE_CACHE_DIR)) {
            $stop_trying = TRUE;
            MPV::warn($not_writable_warning); 
          }
        }
        
      }
      
      if (!$stop_trying) {
        
        if (!file_exists(MASTERPRESS_CONTENT_IMAGE_FROM_URL_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_IMAGE_FROM_URL_DIR)) {
            $stop_trying = TRUE;
          MPV::warn($not_writable_warning); 
          }
        }
        
      }

      if (!$stop_trying) {
        
        if (!file_exists(MASTERPRESS_CONTENT_FILE_FROM_URL_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_FILE_FROM_URL_DIR)) {
            $stop_trying = TRUE;
          MPV::warn($not_writable_warning); 
          }
        }
        
      }

      
      if (!$stop_trying) {
        
        if (!file_exists(MASTERPRESS_CONTENT_UPLOADS_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_UPLOADS_DIR)) {
          $stop_trying = TRUE;
          MPV::warn($not_writable_warning); 
          } 
        }
        
      }      
      
      if (!is_multisite() && $stop_trying) {
        // global and site are the same path
        $stop_trying_global = true;
      }
      

      if (!$stop_trying_global) {
            
        if (!file_exists(MASTERPRESS_CONTENT_MENU_ICONS_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_MENU_ICONS_DIR)) {
            $stop_trying_global = true;
            MPV::warn($not_writable_global_warning); 
          
          }
        } 
      
      }
      
      if (!$stop_trying_global) {
        
        if (!file_exists(MASTERPRESS_CONTENT_MASTERPLANS_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_MASTERPLANS_DIR)) {
          $stop_trying_global = TRUE;
          MPV::warn($not_writable_global_warning); 
          }
        }
        
      }

      if (!$stop_trying_global) {
        
        if (!file_exists(MASTERPRESS_CONTENT_MPFT_CACHE_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_CONTENT_MPFT_CACHE_DIR)) {
            $stop_trying_global = TRUE;
            MPV::warn($not_writable_global_warning); 
          }
        }
        
      }
      
      
      if (!$stop_trying_global) {
        
        if (!file_exists(MASTERPRESS_TMP_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_TMP_DIR)) {
            $stop_trying_global = TRUE;
            MPV::warn($not_writable_warning); 
          }
        }
        
      }


      if (!$stop_trying_global) {
        
        if (!file_exists(MASTERPRESS_EXTENSIONS_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_EXTENSIONS_DIR)) {
          $stop_trying_global = TRUE;
          MPV::warn($not_writable_global_warning); 
          }
        }
        
      }

      if (!$stop_trying_global) {
        
        if (!file_exists(MASTERPRESS_EXTENSIONS_FIELD_TYPES_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_EXTENSIONS_FIELD_TYPES_DIR)) {
          $stop_trying_global = TRUE;
          MPV::warn($not_writable_extensions_warning); 
          }
        }
        
      }

      if (!$stop_trying_global) {
        
        if (!file_exists(MASTERPRESS_EXTENSIONS_ICONS_DIR)) {
          if (!wp_mkdir_p(MASTERPRESS_EXTENSIONS_ICONS_DIR)) {
          $stop_trying_global = TRUE;
          MPV::warn($not_writable_extensions_warning); 
          }
        }
        
      }
  
      
      if (!$stop_trying) {

        // check the writable status of MasterPress directories

        $not_writables = self::check_writable( array(
          MASTERPRESS_CONTENT_MENU_ICONS_DIR, 
          MASTERPRESS_CONTENT_IMAGE_CACHE_DIR, 
          MASTERPRESS_CONTENT_IMAGE_FROM_URL_DIR, 
          MASTERPRESS_CONTENT_FILE_FROM_URL_DIR, 
          MASTERPRESS_CONTENT_MPFT_CACHE_DIR, 
          MASTERPRESS_TMP_DIR, 
          MASTERPRESS_CONTENT_MASTERPLANS_DIR, 
          MASTERPRESS_EXTENSIONS_DIR, 
          MASTERPRESS_EXTENSIONS_FIELD_TYPES_DIR, 
          MASTERPRESS_EXTENSIONS_ICONS_DIR, 
          MASTERPRESS_CONTENT_UPLOADS_DIR
        ));
        
        if (count($not_writables)) {
          $content_paths = WOOF_HTML::open("p");
          $chmods = WOOF_HTML::open("code");
          
          foreach ($not_writables as $nw) {
            $content_paths .= WOOF_HTML::tag("span", "class=tt", $nw["content_path"]."<br />");
            $chmods .= $nw["chmod"];
          }

          $content_paths .= WOOF_HTML::close("p");
          $chmods .= WOOF_HTML::close("code");

          MPV::warn(sprintf(__('<p><strong>Note:</strong> these MasterPress folders in <span class="tt">wp-content</span> are not writable which will cause problems using WordPress:%s<br /></p><p>Using your FTP client, server admin panel, or operating system (for local installations), please give these folders permission 777.<br /><br />Alternatively, use the following commands if you have shell or terminal access:<br />%s', MASTERPRESS_DOMAIN), $content_paths, $chmods)); 

        } 
      

        
      }
      
      
    }

		


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

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

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

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

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

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


    }

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

  }
Ejemplo n.º 9
0
 function icon() {
   $class = array("mp-bool");
   
   $checked = $this->checked();
   
   if ($checked) {
     $class[] = "yes";
   } else {
     $class[] = "no";
   }
   
   return WOOF_HTML::tag("div", array("class" => implode(" ", $class)), $checked ? __("yes") : __("no"));
 }
Ejemplo n.º 10
0
  public function debug($args = array()) {
    
    global $wf;
    
    $r = array();
    
    $parse = true;
    
    if (is_string($args)) {
      
      $check = explode("&", $args);
      $check_2 = explode("=", $check[0]);
      
      if (count($check_2) == 1) {
        $parse = false;
        // simple label
        $r["l"] = $check_2[0];
        $r["pre"] = true;
      }
    }
    
    if ($parse) {
      
      $r = wp_parse_args( 
        $args, 
        array(
          "pre" => "1"
        )
      );
    
    } 
  
    if (isset($r["l"])) {
      echo '<h2 class="debug-label">'.$r["l"].'</h2>';
    }
    
    if (WOOF::is_true_arg($r, "pre")) {
      echo "<pre>";
    }
  
    $data = $this->debug_data();
    
    $class = get_class( $this );
    
		$my_class = $class;
		
    $parents = array();
    
    if (is_object($data)) {
      $data = (array) $data;
    } else if (!is_array($data)) {
      $data = array("value" => $data);
    }
  
    while ($class = get_parent_class($class)) {
      $parents[] = WOOF_HTML::tag("a", "target=_blank&href=" . $wf->woof_docs_base . WOOF_Inflector::dasherize($class), $class);
    }
       
    $data = array(
			"EXTENDS" => implode(", ", $parents),
			"site_id" => $this->_site_id
		) + $data;
    
		// TODO - add support for displaying collection items in this new format
		
		$out = preg_replace("/^Array/", WOOF_HTML::tag("a", "target=_blank&href=" . $wf->woof_docs_base . WOOF_Inflector::dasherize($my_class) , $my_class), print_r($data, true));
		
		echo $out;
    
    if (WOOF::is_true_arg($r, "pre")) {
      echo "</pre>";
    }
    
    return false;
    
  }
Ejemplo n.º 11
0
  public static function options_form( $options ) {

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

    $defaults = array();

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

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

    if (MPC::is_create()) {
      $options["post_types"] = array();
    }

    // setup variables to insert into the heredoc string
    // (this is required where we cannot call functions within heredoc strings)

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

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

    $taxonomies_items = array();

    MPM::incl("taxonomy");

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

    $ts = array();
    
    foreach ($taxonomies as $taxonomy) {

      if (MPC::is_create()) {
        $options["taxonomies"][] = $taxonomy->name;
      }
    
      if (!$taxonomy->disabled && $taxonomy->show_ui && $taxonomy->still_registered()) {
        $taxonomies_items[$taxonomy->display_label()] = $taxonomy->name;
        $ts[] = $taxonomy->name;
      }

    }

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

    $id = $p."taxonomies-";
    
    $taxonomies_checkboxes = "";
    
    foreach ($taxonomies as $taxonomy) {


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

      }

    }
    

    $basic = MPFT::options_select_basic( $p, $options );
    $multi_layout = MPFT::options_select_multi_layout( $p, $options );
    $control_style = MPFT::options_select_control_style( $p, $options );
    $maxwidth = MPFT::options_maxwidth( $p, $options );
    $height = MPFT::options_height( $p, $options );
    $placeholder = MPFT::options_placeholder($p, $options);

    $control_selections_label = __("Selection Display - <span>settings for the display of the selected taxonomies</span>", MASTERPRESS_DOMAIN); 


$html = <<<HTML


    {$control_style}

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

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

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

      <p class="note">{$taxonomies_note}</p>
      </div>
    </div>
    <!-- /.f -->

    {$basic}
    {$placeholder}
    {$maxwidth}

    <div id="{$p}control-selections-wrap" class="divider">
    <h4><i class="buttons"></i>{$control_selections_label}</h4>  
    {$multi_layout}
    </div>

HTML;

    return $html;

  }
Ejemplo n.º 12
0
 function tag_wrap($tag = "li", $name, $attr = array(), $args = array("separator" => "")) {
 
   $ip = array();
   
   $r = wp_parse_args($args);
   
   if (isset($r["separator"])) {
     unset($r["separator"]);
   }
   
   $items = $this->extract($name, $r);
   
   foreach ($items as $item) {
     $ip[] = WOOF_HTML::tag($tag, $attr, $item);
   }
   
   return implode($args["separator"], $ip);
 }
Ejemplo n.º 13
0
  public static function ui( MEOW_Field $field ) {

    // $field here is a MEOW_Field, which is a class that encapsulates the value of a field AND the info associated with it

    $options = $field->info->type_options;

    $readonly = WOOF_HTML::readonly_attr( !$field->is_editable() );

    $value = "";

    if (!$field->blank()) {
      $value = htmlspecialchars($field->raw());
      
      $hiddenmode = $field->prop("mode");

    } else {
      $hiddenmode = self::option_value($options, "mode");
    }

    
    
    $class = "";
    
    
    $mode_select = '';

    if (isset($options["modeselect"]) && $options["modeselect"] == "yes") {
      $mode_select = WOOF_HTML::open("div", array("class" => "modeselect-wrap"));
      $mode_select .= WOOF_HTML::tag("label", array(), __("Syntax Mode: ", MASTERPRESS_DOMAIN));
      
      $class = " editor-ui-with-modeselect";
      
      $attr = array("id" => "{{prop_id}}-mode", "name" => "{{prop_name}}[mode]", "class" => "modeselect");
      
      if ($readonly) {
        $attr["readonly"] = "readonly";
      }
      
      $mode_select .= WOOF_HTML::select(
        $attr,
        self::modes(),
        $hiddenmode
      );
    
      $mode_select .= WOOF_HTML::close("div");
      
    }
    
    $html = <<<HTML

    <div class="editor-ui{$class}">
    <textarea id="{{id}}" $readonly name="{{name}}">{$value}</textarea>
    <input type="hidden" name="hiddenmode" id="{{id}}-hiddenmode" class="hiddenmode" value="{$hiddenmode}" />
      {$mode_select}
    </div>

HTML;

    return $html;

  }
Ejemplo n.º 14
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()
Ejemplo n.º 15
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()
Ejemplo n.º 16
0
  function col() {
    
    global $wf;

    
    $links = array();
    
    $terms = $this->terms();
    
    $tbt = $terms->group_by("taxonomy_name");
    
    $use_labels = false;
    
    if (count($tbt) > 1) {
      $use_labels = true;
    }
    
    foreach ($tbt as $tax_name => $items) {
      
      $tax = $wf->taxonomy($tax_name);
      $label = trim( $tax->singular_label() );
      
      foreach ($items as $term) {
      
        $text = $term->name();
        
        $title = "";
        
        if ($use_labels && $label != "") {
          $title = $label.":&nbsp;".$text;
        }
        
        $attr = array(
          "href" => admin_url("edit-tags.php?action=edit&taxonomy=".$tax_name."&tag_ID=".$term->id()),
          "title" => $title
        );
        
        $links[] = WOOF_HTML::tag("a", $attr, $text);
      }

    }
    
    return WOOF_HTML::tag("div", "class=mp-col", implode(", ", $links));

  }
Ejemplo n.º 17
0
  function col() {
    
    global $wf;
    
    $p = $this->post();
    
    if ($this->is_multi_select()) {
      
      $posts = $this->posts("post_status=any");
        
      if (count($posts)) {
      
        if (count($posts) == 1) {

          return $posts->first()->edit_link();
        } else {
        
          $links = array();
          
          $pbt = $posts->group_by("type_name");

          foreach ($pbt as $type => $items) {
            
            $ids = $items->flatten("id", "sep=,");
        
            $attr = array(
              "href" => admin_url("edit.php?post_type=".$type."&mp_post__in=".$ids."&mp_view=".urlencode( sprintf( __("Related to '%s'", MASTERPRESS_DOMAIN), $wf->the->title() ) ))
            );
            
            $pt = $wf->type($type);
            
            $text = WOOF::items_number(count($items), sprintf( __("No %s", MASTERPRESS_DOMAIN), $pt->plural_label()), sprintf( __("1 %s", MASTERPRESS_DOMAIN), $pt->singular_label()), sprintf( __("%d %s", MASTERPRESS_DOMAIN), count($items), $pt->plural_label() ) );
            $links[] = WOOF_HTML::tag("a", $attr, $text);
          }
          
          return WOOF_HTML::tag("div", "class=mp-col", implode("<br />", $links));
          
        }
      } else {
        return "";
      }
      
    } else {

      if (!is_null($p) && $p->exists()) {
        return $p->edit_link();
      }
      
    }
    
    
    

  }
Ejemplo n.º 18
0
  public function embed($attr = array(), $params = array()) {
    
    if ($this->blank()) {

      return new WOOF_Silent( __( "Cannot show an image - the location for this map field has not been set", MASTERPRESS_DOMAIN ) );

    } else {
      $r = wp_parse_args( 
        $attr,
        array(
          "width" => "100%", 
          "height" => "300", 
          "frameborder" => "0",
          "scrolling" => "no",
          "marginheight" => "0",
          "marginwidth" => "0"
        )
      );

      $p = wp_parse_args(
        $params,
        array(
          "oe" => "UTF-8",
          "ie" => "UTF8",
          "t" => "m",
          "output" => "embed"
        )
      );
    
      $zoom = $this->prop("zoom");

      if (!$zoom) {
        $zoom = 7;
      } else {
        $zoom = max(1, $zoom - 1);
      }
      
      $p["z"] = $zoom;
      $p["ll"] = $this->value();
    
      $r["src"] = "http://maps.google.com/maps?" . build_query($p);
    
      return WOOF_HTML::tag("iframe", $r, "");  
    
    }
    
  }
Ejemplo n.º 19
0
 public function col() {
   
   if (!$this->blank()) {
     return WOOF_HTML::tag("a", array("href" => admin_url("user-edit.php?user_id=".$this->val())), $this->user->fullname());
   }
   
 }