function pugpig_theme_manifest_string($theme_path, $theme_dir, $theme_name = '', $exclude_paths = array(), $theme_version = null) { $cache = array(); // Normalise the slashes $theme_dir = str_replace(DIRECTORY_SEPARATOR, '/', $theme_dir); if (substr($theme_dir, -1) != '/') { $theme_dir = $theme_dir . '/'; } if ($theme_path != '' && substr($theme_path, -1) != '/') { $theme_path = $theme_path . '/'; } $theme_comment = "# Theme assets: "; if (!empty($theme_name)) { $theme_comment .= $theme_name; } if (!empty($theme_version)) { $theme_comment .= " ({$theme_version})"; } $cache[] = $theme_comment; // Get all the static assets for the theme $separator = substr($theme_dir, -1) == '/' ? '' : '/'; // array_push($cache, "# From Path: " . $theme_path . "\n"); // array_push($cache, "# From Dir: " . $theme_dir . "\n"); $files = _pugpig_directory_get_files($theme_dir . "public"); if (!$files) { $cache[] = "# ERROR: Failed to read {$theme_dir}"; } $cache[] = "# Total Directory File Count: " . count($files); $c = 0; if ($files) { foreach ($files as $file) { if (!is_dir($file) && !strpos($file, '/.svn/')) { if ($file != "./manifest.php" && substr($file, 0, 1) != ".") { //$stamp = '?t=' . $file->getMTime(); //$clean_path = str_replace($file, rawurlencode($file), $file) ; $clean_path = str_replace(DIRECTORY_SEPARATOR, '/', $file); $clean_url = str_replace($theme_dir, $separator, $clean_path); $clean_url = str_replace(DIRECTORY_SEPARATOR, '/', $clean_url); if (!in_array($clean_url, $exclude_paths) && isAllowedExtension($file)) { $parts = explode("/", $theme_path . $clean_url); $parts = array_map("rawurlencode", $parts); $clean = implode("/", $parts); $cache[] = $clean; $c++; } else { // array_push($cache, "# Skipped: " . $theme_path . $clean_url . "\n"); } } } } } $cache[] = "# Got {$c} assets before custom filtering"; $cache[] = "\n"; return implode("\n", $cache); }
function pugpig_theme_manifest_string($theme_path, $theme_dir, $theme_name = '', $exclude_paths = array()) { // Normalise the slashes $theme_dir = str_replace(DIRECTORY_SEPARATOR, '/', $theme_dir); if (substr($theme_dir, -1) != '/') { $theme_dir = $theme_dir . '/'; } $cache = array(); if ($theme_name != '') { array_push($cache, "# Theme assets: " . $theme_name . "\n"); } if ($theme_path != '' && substr($theme_path, -1) != '/') { $theme_path = $theme_path . '/'; } // Get all the static assets for the theme $separator = substr($theme_dir, -1) == '/' ? '' : '/'; // array_push($cache, "# From Path: " . $theme_path . "\n"); // array_push($cache, "# From Dir: " . $theme_dir . "\n"); $c = 0; $files = _pugpig_directory_get_files($theme_dir); if (!$files) { array_push($cache, "# ERROR: Failed to read {$theme_dir}\n"); } array_push($cache, "# Total Directory File Count: " . count($files) . "\n"); if ($files) { foreach ($files as $file) { if (!is_dir($file) && !strpos($file, '/.svn/')) { if ($file != "./manifest.php" && substr($file, 0, 1) != ".") { //$stamp = '?t=' . $file->getMTime(); //$clean_path = str_replace($file, rawurlencode($file), $file) ; $clean_path = str_replace(DIRECTORY_SEPARATOR, '/', $file); $clean_url = str_replace($theme_dir, $separator, $clean_path); $clean_url = str_replace(DIRECTORY_SEPARATOR, '/', $clean_url); if (!in_array($clean_url, $exclude_paths) && isAllowedExtension($file)) { $parts = explode("/", $theme_path . $clean_url); $parts = array_map("rawurlencode", $parts); $clean = implode("/", $parts); array_push($cache, $clean . "\n"); $c++; } else { // array_push($cache, "# Skipped: " . $theme_path . $clean_url . "\n"); } } } } } array_push($cache, "# Got " . $c . " assets" . "\n"); $output = ""; foreach ($cache as $file) { $output .= $file; } return $output; }