Return css class marks file permissions

@param  Object  file
@return String
961385
function(o) {
		var c = '';
		
		if (!o.read && !o.write) {
			c = 'elfinder-na';
		} else if (!o.read) {
			c = 'elfinder-wo';
		} else if (!o.write) {
			c = 'elfinder-ro';
		}
		
		if (o.type) {
			c += ' elfinder-' + this.escape(o.type);
		}
		
		return c;
	}
1318411
public static function css_files(array $files) {
        if (empty($files)) {
            return '';
        }

        $compressed = array();
        foreach ($files as $file) {
            $content = file_get_contents($file);
            if ($content === false) {
                $compressed[] = "\n\n/* Cannot read CSS file ".basename(dirname(dirname($file))).'/'.basename(dirname($file)).'/'.basename($file)."*/\n\n";
                continue;
            }
            $compressed[] = self::css($content);
        }

        return implode("\n", $compressed);
    }
1081875
public static function getClassNameFromFile($file)
    {
        $fp = fopen($file, 'r');

        $class = $namespace = $buffer = '';
        $i = 0;

        while (!$class) {
            if (feof($fp)) {
                break;
            }

            // Read entire lines to prevent keyword truncation
            for ($line = 0; $line <= 20; $line++) {
                $buffer .= fgets($fp);
            }
            $tokens = @token_get_all($buffer);

            if (strpos($buffer, '{') === false) {
                continue;
            }

            for (;$i < count($tokens);$i++) {
                if ($tokens[$i][0] === T_NAMESPACE) {
                    for ($j = $i + 1;$j < count($tokens); $j++) {
                        if ($tokens[$j][0] === T_STRING) {
                            $namespace .= '\\' . $tokens[$j][1];
                        } elseif ($tokens[$j] === '{' || $tokens[$j] === ';') {
                            break;
                        }
                    }
                }

                if ($tokens[$i][0] === T_CLASS) {
                    for ($j = $i + 1;$j < count($tokens);$j++) {
                        if ($tokens[$j] === '{') {
                            $class = $tokens[$i + 2][1];
                        }
                    }
                }
            }
        };

        if (!$class) {
            return;
        }

        return $namespace . '\\' . $class;
    }
1144492
private function psr4_get_file_name_from_class( $class ) {
		$class = strtolower( $class );
		if ( stristr( $class, '\\' ) ) {

			// If the first item is == the collection name, trim it off.
			$class = str_ireplace( static::$autoload_class_prefix, '', $class );

			// Maybe fix formatting underscores to dashes and double to single slashes.
			$class     = str_replace( [ '_', '\\' ], [ '-', '/' ], $class );
			$class     = explode( '/', $class );
			$file_name = &$class[ count( $class ) - 1 ];
			$file_name = static::$filename_prefix . $file_name . '.php';
			$file_path = join( DIRECTORY_SEPARATOR, $class );

			return $file_path;
		} else {
			return static::$filename_prefix . str_replace( '_', '-', $class ) . '.php';
		}
	}
651687
function formatUserstyleCSSHeader(metadata) {
  const CSSmeta = JSON.parse(JSON.stringify(metadata)); // Local copy

  let header = '';
  header += '/* ==UserStyle==\n';

  let documentRules;

  Object.keys(userstyleSpec).forEach(prop => {
    if (_safePropGet(prop, CSSmeta) && _isAllowedCSSMetaProp(prop)) {
      if (prop === 'match') {
        documentRules = CSSmeta.match;
      } else {
        header += `@${_padPropName(prop, longestPropLength)} ${CSSmeta[prop]}\n`;
      }
    }
  });

  header += '==/UserStyle== */\n';
  if (documentRules && Object.keys(documentRules).length) {
    header += `@-moz-document\n  ${documentRules.join(',\n  ')}\n{\n`;
  }
  return header;
}
90452
public function cssMinify($file, $type = 'file')
    {
        $file = $this->getFile($file, $type);
        $file = $this->cleanSpaces($file);
        $file = $this->fixMaster($file);
        $file = $this->removeComments($file);

        return preg_replace(['/;[\s\r\n\t]*?}[\s\r\n\t]*/ims', '/;[\s\r\n\t]/ims', '/[\s\r\n\t]*:[\s\r\n\t][\s+\/]/ims', '/[\s\r\n\t]*,[\s\r\n\t]*?([^\s\r\n\t]\.[\s+\/])/ims', '/[\s\r\n\t]/ims', '/([\d\.]+)[\s\r\n\t]+(px|em|pt|%)/ims', '/([^\s\.]0)(px|em|pt|%|ex|mm|in|pc|vh|vw|vmin)/ims', '/\s+/'], ['}', ';$1', ',$1', '$1', '$1$2', '$1$2', ' '], $file);
    }
303831
private function getClassForFile($file)
    {
        // Open a file pointer to the file
        $fp = fopen($file, 'r');

        // Initialise some variables
        $class = $namespace = $buffer = '';
        $i     = 0;

        // Loop through each line of the file until a class is found
        while (!$class) {
            // If we reach the end of the file then exit the loop
            if (feof($fp)) {
                break;
            }

            // Read a portion from the file and append it to the buffer
            $buffer .= fread($fp, 512);

            // Scan the file for tokens
            //
            // We suppress errors here, as we expect errors because we are
            // only parsing a portion of the file at a time
            $tokens = @token_get_all($buffer);

            // Don't bother trying to parse the output until we
            // can see an opening curly brace
            if (strpos($buffer, '{') === false) {
                continue;
            }

            // Loop through each of the found tokens
            for (;$i < count($tokens);$i++) {
                // Check if the namespace keyword has been found yet
                if ($tokens[$i][0] === T_NAMESPACE) {
                    // Continue looping through the found tokens
                    for ($j = $i + 1;$j < count($tokens); $j++) {
                        // A string immediately after the namespace keyword
                        // is the name of the namespace
                        if ($tokens[$j][0] === T_STRING) {
                            // Add each section of the namespace to
                            // our predefined variable
                            $namespace .= '\\'.$tokens[$j][1];
                        } elseif ($tokens[$j] === '{' || $tokens[$j] === ';') {
                            // If we reach a curly brace or a semicolon
                            // we've got the full namespace
                            break;
                        }
                    }
                }

                // Check if the class keyword has been found yet
                if ($tokens[$i][0] === T_CLASS) {
                    // Continue looping through the found tokens
                    for ($j = $i + 1;$j < count($tokens);$j++) {
                        // When we reach the curly brace, store the
                        // class name in the predefined variable
                        if ($tokens[$j] === '{') {
                            $class = $tokens[$i + 2][1];
                        }
                    }
                }
            }
        }

        // If no class is found, return null
        if (!$class) {
            return;
        }

        // Return the fully-qualified class name
        return Str::namespaced("$namespace\\$class");
    }
686033
public function addCssFile($file, $docRoot = null)
    {
        if (null === $docRoot) {
            $docRoot = $this->getDocRoot();
        }

        $docRoot = (string) $docRoot;

        if ('' !== $docRoot) {
            $docRoot .= DIRECTORY_SEPARATOR;
        }

        $file    = preg_replace('/^https?:\/\/[^\/]+/i', '', $file);
        $abspath = $docRoot . $file;

        $this->getCssFileList()->addFile($file, $abspath);

        return $this;
    }
982468
private function getClassByToken($file)
    {

        if (false === file_exists($file)) {
            throw new FileNotFoundException(sprintf("File %s is not readable or not exist", $file));
        }

        $fp = fopen($file, 'r');

        $class = $namespace = $buffer = '';
        $i     = 0;

        while (!$class) {

            if (feof($fp)) {
                break;
            }

            $buffer .= fread($fp, 512);
            $tokens = token_get_all($buffer);

            if (strpos($buffer, '{') === false) {
                continue;
            }

            list($namespace, $class) = $this->loopToken($i, $tokens, $namespace);
        }

        if ($namespace == '') {
            return $class;
        }

        return sprintf("%s\\%s", $namespace, $class);
    }
1250129
public static function style($file, array $attributes = NULL, $protocol = NULL, $index = FALSE)
    {
        if (strpos($file, '://') === FALSE)
        {
            // Add the base URL
            $file = Ioc::url($file);
        }
    
        // Set the stylesheet link
        $attributes['href'] = $file;
    
        // Set the stylesheet rel
        $attributes['rel'] = 'stylesheet';
    
        // Set the stylesheet type
        $attributes['type'] = 'text/css';
        
        return '<link' . self::attributes($attributes) .' />';
    }
1018396
function iconStyle (files, useIcons) {
  if (!useIcons) return '';
  var className;
  var i;
  var iconName;
  var list = [];
  var rules = {};
  var selector;
  var selectors = {};
  var style = '';

  for (i = 0; i < files.length; i++) {
    var file = files[i];

    var isDir = '..' == file.name || (file.stat && file.stat.isDirectory());
    var icon = isDir
      ? { className: 'icon-directory', fileName: icons.folder }
      : iconLookup(file.name);
    var iconName = icon.fileName;

    selector = '#files .' + icon.className + ' .name';

    if (!rules[iconName]) {
      rules[iconName] = 'background-image: url(data:image/png;base64,' + load(iconName) + ');'
      selectors[iconName] = [];
      list.push(iconName);
    }

    if (selectors[iconName].indexOf(selector) === -1) {
      selectors[iconName].push(selector);
    }
  }

  for (i = 0; i < list.length; i++) {
    iconName = list[i];
    style += selectors[iconName].join(',\n') + ' {\n  ' + rules[iconName] + '\n}\n';
  }

  return style;
}
1019482
function cssToJsFn(filePath, file) {
    var STYLE_HEADER = 'css = \'',
        STYLE_FOOTER = '\';';

    var css = new CleanCss({})
        .minify(file.contents.toString())
        .styles;

    file.contents = new Buffer(STYLE_HEADER + escapeStr(css) + STYLE_FOOTER);

    return file.contents.toString('utf8');
}
525085
public function getFileClassNamespace($file)
    {
        $filenameBlock = explode(DIRECTORY_SEPARATOR, $file);
        $filename = explode('.', end($filenameBlock), 2);
        $filename = reset($filename);

        preg_match('/\snamespace\s+(.+?);/s', file_get_contents($file), $match);

        return    is_array($match) && isset($match[1])
                ? $match[1] . '\\' . $filename
                : false;
    }
832048
static function file(string $file, ?int $activeLine = null, ?array $lineRange = null, ?string $className = null): string
    {
        return static::process((string) @highlight_file($file, true), $activeLine, $lineRange, $className);
    }
1282119
public static String parent(String file) {
      if (StringUtils.isNullOrBlank(file)) {
         return StringUtils.EMPTY;
      }
      file = StringUtils.trim(file);
      String path = path(file);
      int index = indexOfLastSeparator(path);
      if (index <= 0) {
         return SystemInfo.isUnix() ? Character.toString(UNIX_SEPARATOR) : Character.toString(WINDOWS_SEPARATOR);
      }
      return path.substring(0, index);
   }
629088
private function _getDomainObjectsFromFile($file)
    {
        $result = array();

        if (fnmatch("*.php", $file)) {
            foreach ($this->_getClassFiles($file) as $namespace=>$classes) {
                foreach ($classes as $class) {
                    $fullClass = empty($namespace) ? "\\$class" : "\\$namespace\\$class";

                    $reflection = new \ReflectionClass($fullClass);
                    if (is_a($fullClass, "\Pheasant\DomainObject", true) && $reflection->isInstantiable()) {
                        $result []= $fullClass;
                    }
                }
            }
        }

        return $result;
    }
806740
static public function getFileExt($file)
    {
        $s = strrchr($file, '.');
        if ($s === false)
        {
            return false;
        }
        return strtolower(trim(substr($s, 1)));
    }