<commit_before><?php
namespace wcf\system\cache\builder;
use wcf\data\package\Package;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\package\PackageDependencyHandler;
use wcf\system\WCF;
use wcf\util\FileUtil;

/**
 * Caches the paths of icons.
 * 
 * @author	<NAME>
 * @copyright	2001-2011 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	com.woltlab.wcf
 * @subpackage	system.cache.builder
 * @category 	Community Framework
 */
class IconCacheBuilder implements ICacheBuilder {
	/**
	 * @see wcf\system\cache\ICacheBuilder::getData()
	 */
	public function getData(array $cacheResource) {
		list($cache, $packageID, $styleID) = explode('-', $cacheResource['cache']); 
		$data = array();

		// get active package
		$activePackage = new Package($packageID);
		$activePackageDir = FileUtil::getRealPath(WCF_DIR.$activePackage->packageDir);
		
		// get package dirs
		$packageDirs = array();
		$conditionBuilder = new PreparedStatementConditionBuilder();
		$conditionBuilder->add("dependency.packageID IN (?) AND package.packageDir <> ''", array(PackageDependencyHandler::getDependencies()));
		$sql = "SELECT		DISTINCT package.packageDir
			FROM		wcf".WCF_N."_package_dependency dependency
			LEFT JOIN	wcf".WCF_N."_package package
			ON		(package.packageID = dependency.dependency)
			".$conditionBuilder->__toString()."
			ORDER BY	dependency.priority DESC";
		$statement = WCF::getDB()->prepareStatement($sql);
		$statement->execute($conditionBuilder->getParameters());
		while ($row = $statement->fetchArray()) {
			$packageDirs[] = FileUtil::getRealPath(WCF_DIR.$row['packageDir']);
		}
		$packageDirs[] = FileUtil::unifyDirSeperator(WCF_DIR);
		
		// get style icon path
		$iconDirs = array();
		$sql = "SELECT	variableValue
			FROM	wcf".WCF_N."_style_variable
			WHERE	styleID = ?
				AND variableName = ?";
		$statement = WCF::getDB()->prepareStatement($sql);
		$statement->execute(array($styleID, 'global.icons.location'));
		$row = $statement->fetchArray();
		if (!empty($row['variableValue'])) $iconDirs[] = FileUtil::addTrailingSlash($row['variableValue']);
		if (!in_array('icon/', $iconDirs)) $iconDirs[] = 'icon/';
		
		// get icons
		foreach ($packageDirs as $packageDir) {
			$relativePackageDir = ($activePackageDir != $packageDir ? FileUtil::getRelativePath($activePackageDir, $packageDir) : '');
			echo $relativePackageDir."\n";
			foreach ($iconDirs as $iconDir) {
				$path = FileUtil::addTrailingSlash($packageDir.$iconDir);
				
				// get png icons<commit_msg>Removed debug code<commit_after><?php
namespace wcf\system\cache\builder;
use wcf\data\package\Package;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\package\PackageDependencyHandler;
use wcf\system\WCF;
use wcf\util\FileUtil;

/**
 * Caches the paths of icons.
 * 
 * @author	<NAME>
 * @copyright	2001-2011 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	com.woltlab.wcf
 * @subpackage	system.cache.builder
 * @category 	Community Framework
 */
class IconCacheBuilder implements ICacheBuilder {
	/**
	 * @see wcf\system\cache\ICacheBuilder::getData()
	 */
	public function getData(array $cacheResource) {
		list($cache, $packageID, $styleID) = explode('-', $cacheResource['cache']); 
		$data = array();

		// get active package
		$activePackage = new Package($packageID);
		$activePackageDir = FileUtil::getRealPath(WCF_DIR.$activePackage->packageDir);
		
		// get package dirs
		$packageDirs = array();
		$conditionBuilder = new PreparedStatementConditionBuilder();
		$conditionBuilder->add("dependency.packageID IN (?) AND package.packageDir <> ''", array(PackageDependencyHandler::getDependencies()));
		$sql = "SELECT		DISTINCT package.packageDir
			FROM		wcf".WCF_N."_package_dependency dependency
			LEFT JOIN	wcf".WCF_N."_package package
			ON		(package.packageID = dependency.dependency)
			".$conditionBuilder->__toString()."
			ORDER BY	dependency.priority DESC";
		$statement = WCF::getDB()->prepareStatement($sql);
		$statement->execute($conditionBuilder->getParameters());
		while ($row = $statement->fetchArray()) {
			$packageDirs[] = FileUtil::getRealPath(WCF_DIR.$row['packageDir']);
		}
		$packageDirs[] = FileUtil::unifyDirSeperator(WCF_DIR);
		
		// get style icon path
		$iconDirs = array();
		$sql = "SELECT	variableValue
			FROM	wcf".WCF_N."_style_variable
			WHERE	styleID = ?
				AND variableName = ?";
		$statement = WCF::getDB()->prepareStatement($sql);
		$statement->execute(array($styleID, 'global.icons.location'));
		$row = $statement->fetchArray();
		if (!empty($row['variableValue'])) $iconDirs[] = FileUtil::addTrailingSlash($row['variableValue']);
		if (!in_array('icon/', $iconDirs)) $iconDirs[] = 'icon/';
		
		// get icons
		foreach ($packageDirs as $packageDir) {
			$relativePackageDir = ($activePackageDir != $packageDir ? FileUtil::getRelativePath($activePackageDir, $packageDir) : '');
			
			foreach ($iconDirs as $iconDir) {
				$path = FileUtil::addTrailingSlash($packageDir.$iconDir);
				
				// get png icons
{'fraction_non_alphanumeric': 0.15292062875994566, 'fraction_numerical': 0.0031049873859887445, 'mean_word_length': 5.077830188679245, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5327700', 'n_tokens_mistral': 1791, 'n_tokens_neox': 1593, 'n_words': 313}