<commit_before><?php

class CM_Response_Resource_CSS extends CM_Response_Resource_Abstract {

	public function process() {
		$this->setHeader('Content-Type', 'text/css');
		$this->enableCache();

		if ($this->_getFilename() == 'library.css') {
			$content = '';
			foreach (CM_Util::rglob('*.css', DIR_PUBLIC . 'static/css/library/') as $path) {
				$content .= new CM_File($path);
			}
		} elseif ($this->_getFilename() == 'internal.css') {
			$css = new CM_Css();
			$css->add(new CM_Css($this->getRender()->getLayoutFile('presets.style')->read()));
			$css->add(new CM_Css($this->getRender()->getLayoutFile('layout.style')->read()));

			foreach ($this->getSite()->getNamespaces() as $namespace) {
				foreach (array_reverse($this->getSite()->getThemes()) as $theme) {
					foreach (CM_Util::rglob('*.css', $this->getRender()->getThemeDir(true, $theme, $namespace) . 'css/') as $path) {
						$file = new CM_File($path);
						$css->add(new CM_Css($file->read()));
					}
				}
			}

			foreach (array('Component', 'Page', 'FormField') as $viewType) {
				$viewClasses = array();
				foreach ($this->getSite()->getNamespaces() as $namespace) {
					$viewClasses = array_merge($viewClasses, CM_Util::rglob('*.php', DIR_LIBRARY . $namespace . '/' . $viewType . '/'));
				}
				foreach ($this->_getClasses($viewClasses) as $viewClass) {
					if (!preg_match('#^(\w+)_' . $viewType . '_(.+)$#', $viewClass['name'], $matches)) {
						throw new CM_Exception("Cannot detect namespace from component's class-name");
					}
					$namespace = $matches[1];
					$viewName = $matches[2];
					$relativePaths = array();
					foreach ($this->getRender()->getSite()->getThemes() as $theme) {
						$basePath = $this->getRender()->getThemeDir(true, $theme, $namespace) . $viewType . '/' . $viewName . '/';
						foreach (CM_Util::rglob('*.style', $basePath) as $path) {
							$relativePaths[] = preg_replace('#^' . $basePath . '#', '', $path);
						}
					}
					foreach (array_unique($relativePaths) as $path) {
						$prefix = '.' . $viewClass['name'];
						if ('Component' == $viewType) {
							if ($path != 'default.style' && strpos($path, '/') === false) {
								$prefix .= '.' . preg_replace('#.style$#', '', $path);
							}
						}

						$file = $this->getRender()->getLayoutFile($viewType . '/' . $viewName . '/' . $path, $namespace);<commit_msg>t162: renamed .style and .css files that are parsed by less to .less<commit_after><?php

class CM_Response_Resource_CSS extends CM_Response_Resource_Abstract {

	public function process() {
		$this->setHeader('Content-Type', 'text/css');
		$this->enableCache();

		if ($this->_getFilename() == 'library.css') {
			$content = '';
			foreach (CM_Util::rglob('*.css', DIR_PUBLIC . 'static/css/library/') as $path) {
				$content .= new CM_File($path);
			}
		} elseif ($this->_getFilename() == 'internal.css') {
			$css = new CM_Css();
			$css->add(new CM_Css($this->getRender()->getLayoutFile('presets.less')->read()));
			$css->add(new CM_Css($this->getRender()->getLayoutFile('layout.less')->read()));

			foreach ($this->getSite()->getNamespaces() as $namespace) {
				foreach (array_reverse($this->getSite()->getThemes()) as $theme) {
					foreach (CM_Util::rglob('*.less', $this->getRender()->getThemeDir(true, $theme, $namespace) . 'css/') as $path) {
						$file = new CM_File($path);
						$css->add(new CM_Css($file->read()));
					}
				}
			}

			foreach (array('Component', 'Page', 'FormField') as $viewType) {
				$viewClasses = array();
				foreach ($this->getSite()->getNamespaces() as $namespace) {
					$viewClasses = array_merge($viewClasses, CM_Util::rglob('*.php', DIR_LIBRARY . $namespace . '/' . $viewType . '/'));
				}
				foreach ($this->_getClasses($viewClasses) as $viewClass) {
					if (!preg_match('#^(\w+)_' . $viewType . '_(.+)$#', $viewClass['name'], $matches)) {
						throw new CM_Exception("Cannot detect namespace from component's class-name");
					}
					$namespace = $matches[1];
					$viewName = $matches[2];
					$relativePaths = array();
					foreach ($this->getRender()->getSite()->getThemes() as $theme) {
						$basePath = $this->getRender()->getThemeDir(true, $theme, $namespace) . $viewType . '/' . $viewName . '/';
						foreach (CM_Util::rglob('*.less', $basePath) as $path) {
							$relativePaths[] = preg_replace('#^' . $basePath . '#', '', $path);
						}
					}
					foreach (array_unique($relativePaths) as $path) {
						$prefix = '.' . $viewClass['name'];
						if ('Component' == $viewType) {
							if ($path != 'default.less' && strpos($path, '/') === false) {
								$prefix .= '.' . preg_replace('#.less#', '', $path);
							}
						}

						$file = $this->getRender()->getLayoutFile($viewType . '/' . $viewName . '/' . $path, $namespace);
{'fraction_non_alphanumeric': 0.2236952861952862, 'fraction_numerical': 0.001473063973063973, 'mean_word_length': 3.5701923076923077, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 63, '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': '1680949', 'n_tokens_mistral': 1897, 'n_tokens_neox': 1558, 'n_words': 285}