Gera a tag de script
@param array|string $fileName
@param bool $base_path
@return string
354263
public static function js($fileName, $base_path = true)
    {
        if (!is_array($fileName))
            $fileName = array($fileName);
        $data = null;
        foreach ($fileName as $file)
        {
            $data .= '<script src="';
            $data .= ($base_path) ? self::getJSLink() : '';
            $data .= $file . '"></script>' . PHP_EOL;
        }
        return $data;
    }
761835
public function setHtmlBody(string $html, string $basePath = null)
    {
        if ($basePath) {
            $cids = [];
            $matches = Strings::matchAll(
                $html,
                '#
					(<img[^<>]*\s src\s*=\s*
					|<body[^<>]*\s background\s*=\s*
					|<[^<>]+\s style\s*=\s* ["\'][^"\'>]+[:\s] url\(
					|<style[^>]*>[^<]+ [:\s] url\()
					(["\']?)(?![a-z]+:|[/\\#])([^"\'>)\s]+)
					|\[\[ ([\w()+./@~-]+) \]\]
				#ix',
                PREG_OFFSET_CAPTURE
            );
            foreach (\array_reverse($matches) as $m) {
                $file = \rtrim($basePath, '/\\') . '/' . (isset($m[4]) ? $m[4][0] : \urldecode($m[3][0]));
                if (!isset($cids[$file])) {
                    $cids[$file] = \substr($this->addEmbeddedFile($file)->getHeader('Content-ID'), 1, -1);
                }
                $html = \substr_replace($html,
                    "{$m[1][0]}{$m[2][0]}cid:{$cids[$file]}",
                    $m[0][1], \strlen($m[0][0])
                );
            }
        }

        if ($this->getSubject() == null) { // intentionally ==
            $html = Strings::replace($html, '#<title>(.+?)</title>#is', function (array $m): void {
                $this->setSubject(\html_entity_decode($m[1], ENT_QUOTES, 'UTF-8'));
            });
        }

        $this->htmlBody = \ltrim(\str_replace("\r", '', $html), "\n");

        if ($html !== '' && $this->getBody() === '') {
            $this->setBody($this->buildText($html));
        }

        return $this;
    }
746676
function(filePath, baseURL, System) {
      // Convert file paths to module name by stripping the baseURL and the ".js" extension
      if (System.defaultJSExtensions) {
        filePath = filePath.replace(/\.js$/, '');
      }
      return filePath
        .replace(new RegExp('^' + baseURL.replace('/', '\/')), '');
    }
208598
public function findPath($classname, $basepath = null)
    {
        $path = false;

        /*
         * Exception rule for Exception classes
        *
        * Transform class to lower case to always load the exception class from the /exception/ folder.
        */
        if ($pos = strpos($classname, 'Exception')) {
            $filename = substr($classname, $pos + strlen('Exception'));
            $classname = str_replace($filename, ucfirst(strtolower($filename)), $classname);
        }

        $word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', ' \\1', $classname));

        $parts = explode(' ', $word);

        if (array_shift($parts) == 'com') {
            //Switch the basepath
            if (!empty($basepath)) {
                $this->_basepath = $basepath;
            }

            $component = 'com_'.strtolower(array_shift($parts));
            $file = array_pop($parts);
            $path = null;
            if (!empty($parts)) {
                if ($parts[0] != 'view') {
                    foreach ($parts as $key => $value) {
                        $parts[$key] = AnInflector::pluralize($value);
                    }
                } else {
                    $parts[0] = AnInflector::pluralize($parts[0]);
                }
                $path = implode('/', $parts);
            }

            $path = '/components/'.$component.'/'.$path;

            $filepath = $path.'/'.$file.'.php';
            $basepath = $this->_basepath;

            if (array_value($parts, -1) == 'exceptions') {
                if (!file_exists($basepath.$filepath)) {
                    $filepath = $path.'/default.php';
                }
            }

            if (count($parts) == 2 && $parts[0] == 'domains') {
                if ($parts[1] == 'entities' && ANPATH_SITE != $this->_basepath) {
                    //set the basepath of entities to the site
                    if (!file_exists($basepath.$filepath)) {
                        $basepath = ANPATH_SITE;
                    }
                }
            }

            $path = $basepath.$filepath;
        }

        return $path;
    }
976975
protected function baseUrl()
    {
        $path       = dirname($_SERVER['SCRIPT_NAME']);
        $path       = trim($path, '/');
        $baseUrl    = Request::getUrl();
        $baseUrl    = trim($baseUrl, '/');
        return $baseUrl.'/'.$path.( $path ? '/' : '' );
    }
39759
protected function detectBasePath()
    {
        $request = Rails::application()->dispatcher()->request();
        
        $baseUrl        = '';
        $filename       = $request->get('SCRIPT_FILENAME');
        $scriptName     = $request->get('SCRIPT_NAME');
        $phpSelf        = $request->get('PHP_SELF');
        $origScriptName = $request->get('ORIG_SCRIPT_NAME');

        if ($scriptName !== null && basename($scriptName) === $filename) {
            $baseUrl = $scriptName;
        } elseif ($phpSelf !== null && basename($phpSelf) === $filename) {
            $baseUrl = $phpSelf;
        } elseif ($origScriptName !== null && basename($origScriptName) === $filename) {
            $baseUrl = $origScriptName;
        } else {
            $baseUrl  = '/';
            $basename = basename($filename);
            if ($basename) {
                $path     = ($phpSelf ? trim($phpSelf, '/') : '');
                $baseUrl .= substr($path, 0, strpos($path, $basename)) . $basename;
            }
        }

        $requestUri = $request->get('REQUEST_URI');

        if (0 === strpos($requestUri, $baseUrl)) {
            return $baseUrl;
        }

        $baseDir = str_replace('\\', '/', dirname($baseUrl));
        if (0 === strpos($requestUri, $baseDir)) {
            return $baseDir;
        }

        $truncatedRequestUri = $requestUri;

        if (false !== ($pos = strpos($requestUri, '?'))) {
            $truncatedRequestUri = substr($requestUri, 0, $pos);
        }

        $basename = basename($baseUrl);

        if (empty($basename) || false === strpos($truncatedRequestUri, $basename)) {
            return '';
        }
        
        if (strlen($requestUri) >= strlen($baseUrl)
            && (false !== ($pos = strpos($requestUri, $baseUrl)) && $pos !== 0)
        ) {
            $baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl));
        }

        return $baseUrl;
    }
1087633
public function getFilesList( $basePath )
    {
        // The custom iterator filters out the file path in order to get a relative one
        return new eZDFSFileHandlerDFSBackendFilterIterator(
            new RecursiveIteratorIterator(
                new RecursiveDirectoryIterator(
                    $this->mountPointPath . '/' . $basePath,
                    FilesystemIterator::SKIP_DOTS|FilesystemIterator::UNIX_PATHS
                )
            ),
            $this->mountPointPath
        );
    }
353307
function getBasename($includeExtensions = true)
    {
        $basename = basename($this->path);

        if (!$includeExtensions) {
            $basename = substr($basename, 0, strpos($basename, '.'));
        }

        return $basename;
    }
175849
public function getFilename()
	{
		if (is_null($this->filename)) {
			$this->filename = pathinfo($this->path, PATHINFO_BASENAME);
		}
		return $this->filename;
	}
1175089
public function stylesheetLinkTag($filename, $attributes)
    {
        $webPaths = array();
        $absolutePaths = $this->parser->stylesheetFiles($filename);

        foreach ($absolutePaths as $absolutePath)
        {
            $webPaths[] = $this->parser->absolutePathToWebPath($absolutePath);
        }

        $config = $this->getConfig();
        $composer = $config['stylesheet_link_tag'];

        return $composer->process($webPaths, $absolutePaths, $attributes);
    }
1159088
protected function load_array_from_file( $file, $base_directory = null ) {
		// Grab our file's basename
		$file_base = basename( $file, '.php' );

		// Define our file path
		$file_path = $base_directory ? $base_directory . $file : $file;

		// Include the file
		require( $file_path );

		// Set the file's returned configuration in a namespaced key
		$array = array( $file_base => ${$this->callback_name}() );

		// Garbage collect
		unset( ${$this->callback_name} );

		return $array;
	}
1134091
public function isFile($filename, $basePath = null)
    {
        if (!empty($basePath)) {
            $filename = $this->concatPaths([$basePath, $filename]);
        }

        if (file_exists($filename)) {
            return is_file($filename);
        }

        $fileExtension = pathinfo($filename, PATHINFO_EXTENSION);
        if (!empty($fileExtension)) {
            return true;
        }

        return false;
    }
343057
function basename(file){
    var extname = path.extname(file);
    return path.basename(file, extname);
}
109193
protected function find_handler_path($filename) {
	$filename = strtolower($filename);
	
	if (preg_match('{[^a-z0-9/_-]}', $filename)) {
		return false;
	}
	
	$base_path = \alsvanzelf\fem\ROOT_DIR_APP.$this->handler_base_path.'/';
	$full_path = $base_path.$filename.'.php';
	if (file_exists($full_path) == false) {
		return false;
	}
	
	// sanity check to prevent escaping outside the base dir
	if (strpos($full_path, $base_path) !== 0) {
		return false;
	}
	
	return $full_path;
}
537646
def base_name
      name = File.basename(destination_root)
      root = destination_root
      while %w[trunk branches tags].include? name
        root = File.expand_path(File.join(root, ".."))
        name = File.basename(root)
      end
      name
    end
209641
private function LanguageCsvFile($basePath)
    {
        $ext = IO\Path::Extension($basePath);
        $baseFile = IO\Path::RemoveExtension($basePath);
        $langFile = IO\Path::AddExtension($baseFile, $this->language);
        return IO\Path::AddExtension($langFile, $ext);
    }
241985
public static function loadFromXMLFile($file_path, $base_dir)
    {
        $file_contents = file_get_contents($file_path);

        if ($file_contents === false) {
            throw new \InvalidArgumentException('Cannot open ' . $file_path);
        }

        try {
            $config = self::loadFromXML($base_dir, $file_contents);
            $config->hash = sha1($file_contents);
        } catch (ConfigException $e) {
            throw new ConfigException(
                'Problem parsing ' . $file_path . ":\n" . '  ' . $e->getMessage()
            );
        }

        return $config;
    }