diff --git a/Blick.module b/Blick.module index 8a96310..8fac7be 100644 --- a/Blick.module +++ b/Blick.module @@ -10,7 +10,7 @@ * @author Christian (owzim) Raunitschka * @copyright Copyright (c) 2015, Christian Raunitschka * - * @version 0.7.0 + * @version 0.8.0 * * @filesource * @@ -31,6 +31,7 @@ class Blick extends Wire implements Module 'Versioning', 'VersioningFormat', 'Min', 'MinFormat', 'AppendNewLine', + 'OptionsExtension', 'SharedOptionsName' ); /** @@ -50,7 +51,7 @@ class Blick extends Wire implements Module return array( 'title' => 'Blick', 'summary' => 'A small helper module for including JS, CSS and image files', - 'version' => '0.7.0', + 'version' => '0.8.0', 'icon' => 'eye', 'requires' => array('PHP>=5.4','ProcessWire>=2.5.5'), 'singular' => true, @@ -78,36 +79,38 @@ class Blick extends Wire implements Module $urls = $config->urls; return array( - 'jsPath' => $paths->templates . 'scripts', - 'jsUrl' => $urls->templates . 'scripts', - 'jsMarkup' => '', - 'jsDefault' => 'markup', - 'jsVersioning' => false, - 'jsVersioningFormat' => '?v={version}', - 'jsMin' => false, - 'jsMinFormat' => "{file}.min.{ext}", - - 'cssPath' => $paths->templates . 'styles', - 'cssUrl' => $urls->templates . 'styles', - 'cssMarkup' => '', - 'cssDefault' => 'markup', - 'cssVersioning' => false, - 'cssVersioningFormat' => '?v={version}', - 'cssMin' => false, - 'cssMinFormat' => "{file}.min.{ext}", - - 'imgPath' => $paths->templates . 'images', - 'imgUrl' => $urls->templates . 'images', - 'imgMarkup' => '{0}', - 'imgDefault' => 'markup', - 'imgVariations' => array(), - 'imgVariationSubDir' => 'variations', - 'imgVersioning' => false, - 'imgVersioningFormat' => '', - 'imgMin' => false, - 'imgMinFormat' => '', - - 'appendNewLine' => true, + 'jsPath' => $paths->templates . 'scripts', + 'jsUrl' => $urls->templates . 'scripts', + 'jsMarkup' => '', + 'jsDefault' => 'markup', + 'jsVersioning' => false, + 'jsVersioningFormat' => '?v={version}', + 'jsMin' => false, + 'jsMinFormat' => "{file}.min.{ext}", + + 'cssPath' => $paths->templates . 'styles', + 'cssUrl' => $urls->templates . 'styles', + 'cssMarkup' => '', + 'cssDefault' => 'markup', + 'cssVersioning' => false, + 'cssVersioningFormat' => '?v={version}', + 'cssMin' => false, + 'cssMinFormat' => "{file}.min.{ext}", + + 'imgPath' => $paths->templates . 'images', + 'imgUrl' => $urls->templates . 'images', + 'imgMarkup' => '{0}', + 'imgDefault' => 'markup', + 'imgVariations' => array(), + 'imgVariationSubDir' => 'variations', + 'imgVersioning' => false, + 'imgVersioningFormat' => '', + 'imgMin' => false, + 'imgMinFormat' => '', + 'imgOptionsExtension' => 'txt', + 'imgSharedOptionsName' => 'shared-options', + + 'appendNewLine' => true, ); } diff --git a/owzim/blick/Image.php b/owzim/blick/Image.php index 7d5b0fd..4ae63e9 100644 --- a/owzim/blick/Image.php +++ b/owzim/blick/Image.php @@ -6,7 +6,7 @@ * @author Christian (owzim) Raunitschka * @copyright Copyright (c) 2015, Christian Raunitschka * - * @version 0.4.0 + * @version 0.5.0 * * @filesource * @@ -291,25 +291,32 @@ public function height($n = 0, $options = array()) */ protected function ___getTextOptions() { + $config = \Blick::getConfig(); + $imgConfig = $config->img; + $rtn = null; $path = "{$this->dir}/{$this->name}"; - $optsTxtFile = "$path.txt"; + $fileOptsTxtFile = "$path.{$imgConfig->optionsExtension}"; + $sharedOptsTxtFile = "{$this->dir}/{$imgConfig->sharedOptionsName}.{$imgConfig->optionsExtension}"; // save pased text options in a static array static $textOptions = null; if (is_null($textOptions)) $textOptions = array(); // return parsed options if already exist for that specific image - if (isset($textOptions[$optsTxtFile])) return $textOptions[$optsTxtFile]; - - if (file_exists($optsTxtFile)) { - $rtn = array(); - $content = str_replace("\n", ',', trim(file_get_contents($optsTxtFile))); - $selectors = new \Selectors($content); - foreach ($selectors as $selector) { - $rtn[$selector->field] = $selector->value; + if (isset($textOptions[$fileOptsTxtFile])) return $textOptions[$fileOptsTxtFile]; + + foreach (array($sharedOptsTxtFile, $fileOptsTxtFile) as $optsTxtFile) + { + if (file_exists($optsTxtFile)) { + if (is_null($rtn)) $rtn = array(); + $content = str_replace("\n", ',', trim(file_get_contents($optsTxtFile))); + $selectors = new \Selectors($content); + foreach ($selectors as $selector) { + $rtn[$selector->field] = $selector->value; + } } } - // return an save it to static array - return $textOptions[$optsTxtFile] = $rtn; + + return $textOptions[$fileOptsTxtFile] = $rtn; } }