public function acceptDir($basename, $pathname, $depth) { // Skip over the assets directory in the site root. if ($depth == 1 && $basename == ASSETS_DIR) { return false; } // Skip over any lang directories in the top level of the module. if ($depth == 2 && $basename == self::LANG_DIR) { return false; } // If we're not in testing mode, then skip over the tests directory in // the module root. if ($this->getOption('ignore_tests') && $depth == 2 && $basename == self::TESTS_DIR) { return false; } // Ignore any directories which contain a _manifest_exclude file. if (file_exists($pathname . '/' . self::EXCLUDE_FILE)) { return false; } // Only include top level module directories which have a configuration // _config.php file. However, if we're in themes mode then include // the themes dir without a config file. $lackingConfig = $depth == 1 && !($this->getOption('include_themes') && $basename == THEMES_DIR) && !file_exists($pathname . '/' . self::CONFIG_FILE) && !file_exists($pathname . '/' . self::CONFIG_DIR); if ($lackingConfig) { return false; } return parent::acceptDir($basename, $pathname, $depth); }
public function testMaxDepth() { $finder = new SS_FileFinder(); $finder->setOption('max_depth', 1); $this->assertFinderFinds($finder, array('file1.txt', 'file2.txt', 'dir1/dir1file1.txt', 'dir1/dir1file2.txt'), 'The finder respects the max depth setting.'); }
/** * Gets a list of email templates suitable for populating the email template dropdown. * * @return array */ public function getEmailTemplateDropdownValues() { $templates = array(); $finder = new SS_FileFinder(); $finder->setOption('name_regex', '/^.*\\.ss$/'); $found = $finder->find(BASE_PATH . '/' . UserDefinedForm::config()->email_template_directory); foreach ($found as $key => $value) { $template = pathinfo($value); $templates[$template['filename']] = $template['filename']; } return $templates; }
public function testMultipleGenerateManipulationCalls_Regeneration() { $image = $this->objFromFixture('Image', 'imageWithoutTitle'); $folder = new SS_FileFinder(); $imageFirst = $image->Pad(200, 200); $this->assertNotNull($imageFirst); $expected = 200; $actual = $imageFirst->getWidth(); $this->assertEquals($expected, $actual); $imageSecond = $imageFirst->setHeight(100); $this->assertNotNull($imageSecond); $expected = 100; $actual = $imageSecond->getHeight(); $this->assertEquals($expected, $actual); $imageThird = $imageSecond->Pad(600, 600, '0F0F0F'); // Encoding of the arguments is duplicated from cacheFilename $argumentString = Convert::base64url_encode(array(600, 600, '0F0F0F')); $this->assertNotNull($imageThird); $this->assertContains($argumentString, $imageThird->getFullPath(), 'Image contains background color for padded resizement'); $resampledFolder = dirname($image->getFullPath()) . "/_resampled"; $filesInFolder = $folder->find($resampledFolder); $this->assertEquals(3, count($filesInFolder), 'Image folder contains only the expected number of images before regeneration'); $imageThirdPath = $imageThird->getFullPath(); $stats = getimagesize($imageThirdPath); $this->assertEquals(3, $image->regenerateFormattedImages(), 'Cached images were regenerated in the right number'); $this->assertEquals($stats, getimagesize($imageThirdPath), 'Regeneration of third image is correct'); /* Check that no other images exist, to ensure that the regeneration did not create other images */ $this->assertEquals($filesInFolder, $folder->find($resampledFolder), 'Image folder contains only the expected image files after regeneration'); }