Projekt

Allgemein

Profil

GX-Bug #54155 » refs_#54155_2.patch

Mirko Janssen, 13.02.2018 10:14

Unterschiede anzeigen:

src/includes/classes/scssphp/scss.inc.php (date 1518512448000)
4464 4464
	 * @return string
4465 4465
	 */
4466 4466
	protected function compile($in, $out) {
4467
		$scssInput = file_get_contents($in);
4468
		if(isset($this->additionalScssFiles) && count($this->additionalScssFiles) > 0)
4469
		{
4470
			foreach($this->additionalScssFiles as $additionalScssFile)
4471
			{
4472
				if(file_exists($additionalScssFile))
4473
				{
4474
					$scssInput .= "\n\r" . file_get_contents($additionalScssFile);
4475
				}
4476
			}
4477
		}
4478
		
4467 4479
		$start = microtime(true);
4468
		$css = $this->scss->compile(file_get_contents($in), $in);
4480
		$css = $this->scss->compile($scssInput, $in);
4469 4481
		$elapsed = round((microtime(true) - $start), 4);
4470 4482

  
4471 4483
		$v = scssc::$VERSION;
......
4561 4573
		}
4562 4574
		$this->scss = $scss;
4563 4575
	}
4576
	
4577
	public function setAdditionalScssFiles($additionalScssFiles) {
4578
		$this->additionalScssFiles = $additionalScssFiles;
4579
	}
4564 4580

  
4565 4581
	/**
4566 4582
	 * Helper method to serve compiled scss
src/templates/Honeygrid/gm_dynamic.css.php (date 1518512495000)
77 77
}
78 78

  
79 79
$additionalCssFiles  = array();
80
$additionalScssFiles = array();
80 81
$additionalScssPaths = array();
81 82

  
82 83
if(file_exists(DIR_FS_CATALOG . 'templates/' . $currentTemplate . '/stylesheet.css'))
......
127 128
		}
128 129
		elseif(substr($file, -9) === 'main.scss')
129 130
		{
131
			$additionalScssFiles[] = substr($file, strlen(DIR_FS_CATALOG));
130 132
			$additionalScssPaths[] = substr(substr($file, 0, strripos($file, '/')), strlen(DIR_FS_CATALOG));
131 133
		}
132 134
	}
133 135
}
136
$additionalScssFiles = array_unique($additionalScssFiles);
134 137
$additionalScssPaths = array_unique($additionalScssPaths);
135 138

  
136 139
$cacheFile = DIR_FS_CATALOG . 'cache/' . (!array_key_exists('style_edit_cache', $_GET)  
......
409 412
	}
410 413

  
411 414
	$server = new scss_server($basePath, 'cache', $compiler);
415
	$server->setAdditionalScssFiles($additionalScssFiles);
412 416
	ob_start();
413 417
	try
414 418
	{
415 419
		$server->serve();
416
		if(count($additionalScssPaths) > 0)
417
		{
418
			foreach($additionalScssPaths as $additionalScssPath)
419
			{
420
				$server = new scss_server($additionalScssPath, 'cache', $compiler);
421
				$server->serve();
422
			}
423
		}
424 420
	}
425 421
	catch(\Exception $e)
426 422
	{
......
493 489
			}
494 490
		
495 491
			$server = new scss_server($basePath, 'cache', $compiler);
492
			$server->setAdditionalScssFiles($additionalScssFiles);
496 493
	
497 494
			// delete custom scss forcing to compile default css to ensure a working frontend
498 495
			@file_put_contents(DIR_FS_CATALOG . $customDir . '_bootstrap_variables.scss', '');
......
500 497
			@file_put_contents(DIR_FS_CATALOG . $customDir . '_custom_styles.scss', '');
501 498
			
502 499
			$server->serve();
503
			if(count($additionalScssPaths) > 0)
504
			{
505
				foreach($additionalScssPaths as $additionalScssPath)
506
				{
507
					$server = new scss_server($additionalScssPath, 'cache', $compiler);
508
					$server->serve();
509
				}
510
			}
511 500
			
512 501
			$scss  = ob_get_clean();
513 502
			$scss = $errorMessage . $styleEditErrorMessage . $scss;
(2-2/2)