protected function globDataFile($pattern, $asId = false) { $path = $this->folder; $folders = \Staq::App()->getExtensions(); array_walk($folders, function (&$a) use($path) { $a = realpath($a . $path); }); $folders = array_filter($folders, function ($a) { return !empty($a); }); $files = []; foreach ($folders as $folder) { $fullFolder = $folder . DIRECTORY_SEPARATOR . $pattern; foreach (glob($fullFolder . '\\.*') as $filename) { if ($asId) { $id = \UString::notStartWith($filename, $folder . '/'); \UString::doSubstrBeforeLast($id, '.'); $files[$id] = $id; } else { $files[] = $filename; } } } if ($asId) { array_values($files); } return array_reverse($files); }
public function test_not_start_with__multiple_match() { $assertion = \UString::notStartWith('https://http://www.example.com', array('file://', 'https://', 'http://')); $this->assertEquals('www.example.com', $assertion); }
protected function getDefaultBaseUri() { $baseUri = NULL; if (isset($_SERVER['DOCUMENT_ROOT']) && isset($_SERVER['SCRIPT_FILENAME'])) { $rootFolderPath = \UString::notEndWith($_SERVER['DOCUMENT_ROOT'], '/'); $scriptFolderPath = dirname($_SERVER['SCRIPT_FILENAME']); if (\UString::isStartWith($rootFolderPath, $scriptFolderPath)) { $baseUri = \UString::notStartWith($rootFolderPath, $scriptFolderPath); } } if (empty($baseUri)) { $baseUri = '/'; } return $baseUri; }
public static function doNotStartWith(&$haystack, $needles) { $haystack = \UString::notStartWith($haystack, $needles); }