Ejemplo n.º 1
0
 public static function extension_type_keys($sort = true) {
   if (!self::$extension_type_keys) {
     self::$extension_type_keys = MPU::file_list( MPU::extension_type_dir() );
   }
   
   return self::$extension_type_keys;
 }
Ejemplo n.º 2
0
  protected function build_package($rep, $filename, $readme = "") {
    $export_filename = MASTERPRESS_TMP_DIR.$filename;

    $destination_filename = MASTERPRESS_CONTENT_MASTERPLANS_DIR.$filename;

    $info["filename"] = $export_filename;
    
    // setup PCL Zip to create the package containing a json Masterplan and any referenced menu icons

    require_once(ABSPATH . 'wp-admin/includes/class-pclzip.php');
    
    $zip = new PclZip($export_filename);

    // create a file out of the representation
    
    $pi = pathinfo($filename);
    
    $dir = MASTERPRESS_TMP_DIR.$pi["filename"];
    
    wp_mkdir_p($dir);
    wp_mkdir_p($dir.WOOF_DIR_SEP."icons");
    
    $handle = fopen( $dir.WOOF_DIR_SEP."masterplan.json", "w");
    
    fwrite($handle, WOOF::json_indent( json_encode($rep) ) );
    fclose($handle);

    if (trim($readme) != "") {
      $handle = fopen( $dir.WOOF_DIR_SEP."README.markdown", "w");
      fwrite($handle, $readme );
      fclose($handle);
    }
  
    $file_list  = array($dir);
  
    $icon_list = array();
    $type_list = array();
      
    // grab any referenced icons
    
    foreach ($rep["icons"] as $icon_file) {
      $icon = MASTERPRESS_CONTENT_MENU_ICONS_DIR.$icon_file;
      
      if (file_exists($icon)) {
        $dest = $dir.WOOF_DIR_SEP."icons".WOOF_DIR_SEP.$icon_file;
        $icon_list[] = array("name" => $icon_file, "url" => MASTERPRESS_CONTENT_MENU_ICONS_URL.$icon_file);
        copy($icon, $dest);
      }
    }
    
    // now check if there are any field type extensions we need too
    
    $ft_dir = $dir.WOOF_DIR_SEP."field-types";
    
    foreach ($rep["field_types"] as $type) {
      if (MPU::extension_type_exists($type)) {
        wp_mkdir_p($ft_dir);
        $source = MPU::extension_type_dir($type);
        $dest = $ft_dir.WOOF_DIR_SEP.$type;
        $type_list[] = array("key" => $type, "icon" => MPU::type_icon_url($type));
        MPU::copyr($source, $dest);
      }
    }
    

      
    $zip->create( $file_list, PCLZIP_OPT_REMOVE_PATH, MASTERPRESS_TMP_DIR );
    
    copy($export_filename, $destination_filename);

    unlink($export_filename);
    MPU::rmdir_r($dir);
    
    return array("path" => $destination_filename, "icon_list" => $icon_list, "type_list" => $type_list);
    
  } 
Ejemplo n.º 3
0
 public static function type_file_path($type, $file) {
   if (MPU::core_type_exists($type)) {
     $base = MPU::core_type_dir($type);
     return $base.$file;
   } else {
     if (MPU::extension_type_exists($type)) {
       $base = MPU::extension_type_dir($type);
       return $base.$file;
     }
   }
 }