Example #1
0
 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);
 }
Example #2
0
 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);
 }
Example #3
0
 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;
 }
Example #4
0
 public static function doNotStartWith(&$haystack, $needles)
 {
     $haystack = \UString::notStartWith($haystack, $needles);
 }