Location: PHPKode > projects > JaxBlog > JaxBlog/app/common/refolder.php
<?php

// Redo css and js foldering.
function templateRefolderCSSAndJavascript($file_template) {
	$template = fileRead(FOLDER_RELATIVE_BASE . FOLDER_TEMPLATE . $file_template);
	$template = refolderTags($template, 'css', FOLDER_RELATIVE_BASE . FOLDER_CSS, false);
	$template = refolderTags($template, 'css', FOLDER_RELATIVE_BASE, true);
	$template = refolderTags($template, 'js', FOLDER_RELATIVE_BASE, true);
	$template = refolderTags($template, 'js', FOLDER_RELATIVE_BASE . FOLDER_JAVASCRIPT, false);
	
	// If debug is turned on, append all the js files we can to the header.  By nature 
	// of being appended AFTER the header (which will include the combined.js file), 
	// they will override any functions in it.
	if (FLAG_DEBUG == 'Y') {
		$scripts = "";
		$scripts .= "<script language='JavaScript' type='text/javascript' src='../../../module/common/jax-common.js'></script>\n";
		$scripts .= "<script language='JavaScript' type='text/javascript' src='../../../module/common/jax-xmlhttprequest.js'></script>\n";
		$scripts .= "<script language='JavaScript' type='text/javascript' src='../../../module/common/jax-dialog.js'></script>\n";
		$scripts .= "<script language='JavaScript' type='text/javascript' src='../../../module/common/jax-effect.js'></script>\n";
		$scripts .= "<script language='JavaScript' type='text/javascript' src='../../../module/common/jax-highlight.js'></script>\n";
		$scripts .= "<script language='JavaScript' type='text/javascript' src='../../../module/JaxCalendar/jax-calendar.js'></script>\n";
		$scripts .= "<script language='JavaScript' type='text/javascript' src='../../../module/JaxEditor/jax-editor.js'></script>\n";
		$scripts .= "<script language='JavaScript' type='text/javascript' src='../../../module/JaxForm/jax-form.js'></script>\n";
		$scripts .= "<script language='JavaScript' type='text/javascript' src='../../../module/JaxLogin/jax-login.js'></script>\n";
		$scripts .= "<script language='JavaScript' type='text/javascript' src='../../../module/JaxModal/jax-modal.js'></script>\n";
		$scripts .= "<script language='JavaScript' type='text/javascript' src='../../../module/JaxSlideshow/jax-slideshow.js'></script>\n";
		$scripts .= "<script language='JavaScript' type='text/javascript' src='../../../module/JaxTable/jax-table.js'></script>\n";
		$scripts .= "<script language='JavaScript' type='text/javascript' src='../../../module/JaxTree/jax-tree.js'></script>\n";
		$template = str_replace('[Header]', $scripts . '[Header]', $template);
	}
		
	return $template;
}

function refolderTags($content, $extension, $folder, $checkmodule) {
	$paths = refolderGetPaths($content, $extension, $checkmodule);
	$files = refolderGetFiles($paths, $extension, $folder, $checkmodule);
	$output = str_replace($paths, $files, $content);
	return $output;
}
function refolderGetPaths($content, $extension, $checkmodule) {
	$matches = null;
	if ($checkmodule) {
		$expression = "/\"(?=[\.\w\/-]*(module))[\.\/\w-]+\." . $extension . "\"/i";
	} else {
//		$expression = "/\"[0-9a-zA-Z\.\/_-]*\." . $extension . "\"/i";
		$expression = "/\"(?![\.\w\/-]*(module))[\.\/\w-]+\." . $extension . "\"/i";
	}
	preg_match_all($expression, $content, $matches);
	return $matches[0];
}
function refolderGetFiles($paths, $extension, $folder, $checkmodule) {
	$matches = null;
	if ($checkmodule) {
		$expression = "/(?=(module))[\.\/\w-]+\." . $extension . "/i";
	} else {
		$expression = "/[0-9a-zA-Z_-]*\." . $extension . "/i";
	}
	$files = array();
	$count = 0;
	for ($i = 0; $i < count($paths); $i++) {
		preg_match($expression, $paths[$i], $matches);
		$files[] = '"' . $folder . $matches[0] . '"';
//		echo $paths[$i] . ' &lt;&lt; changes to &gt;&gt; ' . $files[$i] . '<br />';
	}
	return $files;
}
function fileRead($path) {
	$file = fopen($path, 'r');
	if (!$file) {
		echo 'Unable to read file ' . $path . '<br />';
		return null;
	}
	// Check for empty file.
	if (filesize($path) == 0) {
		return '';
	}
	$string = fread($file, filesize($path));
	fclose ($file);
	return $string;
}
?>
Return current item: JaxBlog