* @param Style $style
*/
public function compile(Style $style) {
- // read stylesheets by dependency order
- $conditions = new PreparedStatementConditionBuilder();
- $conditions->add("filename REGEXP ?", ['style/([a-zA-Z0-9\_\-\.]+)\.scss']);
-
- // TESTING ONLY
- $conditions->add("packageID <> ?", [1]);
- // TESTING ONLY
+ $files = $this->getCoreFiles();
+ // read stylesheets in dependency order
$sql = "SELECT filename, application
FROM wcf".WCF_N."_package_installation_file_log
- ".$conditions."
+ WHERE filename REGEXP ?
+ AND packageID <> ?
ORDER BY packageID";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute($conditions->getParameters());
-
- $files = [];
-
- // TESTING ONLY
- if ($handle = opendir(WCF_DIR.'style/')) {
- while (($file = readdir($handle)) !== false) {
- if ($file === '.' || $file === '..' || $file === 'bootstrap' || is_file(WCF_DIR.'style/'.$file)) {
- continue;
- }
-
- $file = WCF_DIR."style/{$file}/";
- if ($innerHandle = opendir($file)) {
- while (($innerFile = readdir($innerHandle)) !== false) {
- if ($innerFile === '.' || $innerFile === '..' || !is_file($file.$innerFile) || !preg_match('~^[a-zA-Z0-9]+\.scss$~', $innerFile)) {
- continue;
- }
-
- $files[] = $file.$innerFile;
- }
- closedir($innerHandle);
- }
- }
-
- closedir($handle);
-
- // directory order is not deterministic in some cases
- sort($files);
- }
-
- // TESTING ONLY
-
+ $statement->execute([
+ 'style/([a-zA-Z0-9\-\.]+)\.scss',
+ 1
+ ]);
while ($row = $statement->fetchArray()) {
$files[] = Application::getDirectory($row['application']).$row['filename'];
}
* Compiles SCSS stylesheets for ACP usage.
*/
public function compileACP() {
- // read stylesheets by dependency order
- $conditions = new PreparedStatementConditionBuilder();
- $conditions->add("filename REGEXP ?", ['style/([a-zA-Z0-9\_\-\.]+)\.scss']);
-
- // TESTING ONLY
- $conditions->add("packageID <> ?", [1]);
- // TESTING ONLY
-
- $sql = "SELECT filename, application
- FROM wcf".WCF_N."_package_installation_file_log
- ".$conditions."
- ORDER BY packageID";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute($conditions->getParameters());
-
- $files = [];
-
- // TESTING ONLY
- if ($handle = opendir(WCF_DIR.'style/')) {
- while (($file = readdir($handle)) !== false) {
- if ($file === '.' || $file === '..' || $file === 'bootstrap' || is_file(WCF_DIR.'style/'.$file)) {
- continue;
- }
-
- $file = WCF_DIR."style/{$file}/";
- if ($innerHandle = opendir($file)) {
- while (($innerFile = readdir($innerHandle)) !== false) {
- if ($innerFile === '.' || $innerFile === '..' || !is_file($file.$innerFile) || !preg_match('~^[a-zA-Z]+\.scss$~', $innerFile)) {
- continue;
- }
-
- $files[] = $file.$innerFile;
- }
- closedir($innerHandle);
- }
- }
-
- closedir($handle);
-
- // directory order is not deterministic in some cases
- sort($files);
- }
-
- $additional = ['layout'];
- for ($i = 0, $length = count($additional); $i < $length; $i++) {
- $files[] = WCF_DIR . 'acp/style/' . $additional[$i] . '.scss';
- }
- // TESTING ONLY
+ $files = $this->getCoreFiles();
- //$files = glob(WCF_DIR.'style/*.less');
+ // ACP uses a slightly different layout
+ $files[] = WCF_DIR . 'acp/style/layout.scss';
// read default values
$sql = "SELECT variableName, defaultValue
$variables['wcfFontFamily'] = '"' . $variables['wcfFontFamilyGoogle'] . '", ' . $variables['wcfFontFamily'];
}
- // insert blue temptation files
- //array_unshift($files, WCF_DIR.'acp/style/blueTemptation/variables.scss', WCF_DIR.'acp/style/blueTemptation/override.scss');
-
- $variables['style_image_path'] = "'../images/blueTemptation/'";
+ $variables['style_image_path'] = "'../images/'";
$this->compileStylesheet(
WCF_DIR.'acp/style/style',
// fix relative paths
$content = str_replace('../font/', '../../font/', $content);
$content = str_replace('../icon/', '../../icon/', $content);
- $content = preg_replace('~\.\./images/(?!blueTemptation)~', '../../images/', $content);
+ $content = preg_replace('~\.\./images/~', '../../images/', $content);
return "/* stylesheet for ACP, generated on ".gmdate('r')." -- DO NOT EDIT */\n\n" . $content;
})
);
}
+ /**
+ * Returns a list of common stylesheets provided by the core.
+ *
+ * @return string[] list of common stylesheets
+ */
+ protected function getCoreFiles() {
+ $files = [];
+ if ($handle = opendir(WCF_DIR.'style/')) {
+ while (($file = readdir($handle)) !== false) {
+ if ($file === '.' || $file === '..' || $file === 'bootstrap' || is_file(WCF_DIR.'style/'.$file)) {
+ continue;
+ }
+
+ $file = WCF_DIR."style/{$file}/";
+ if ($innerHandle = opendir($file)) {
+ while (($innerFile = readdir($innerHandle)) !== false) {
+ if ($innerFile === '.' || $innerFile === '..' || !is_file($file.$innerFile) || !preg_match('~^[a-zA-Z0-9\-\.]+\.scss$~', $innerFile)) {
+ continue;
+ }
+
+ $files[] = $file.$innerFile;
+ }
+ closedir($innerHandle);
+ }
+ }
+
+ closedir($handle);
+
+ // directory order is not deterministic in some cases
+ sort($files);
+ }
+
+ return $files;
+ }
+
/**
* Prepares the style compiler by adding variables to environment.
*