当前位置: 首页>>代码示例>>PHP>>正文


PHP Filesystem::find_relative_path方法代码示例

本文整理汇总了PHP中Filesystem::find_relative_path方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::find_relative_path方法的具体用法?PHP Filesystem::find_relative_path怎么用?PHP Filesystem::find_relative_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Filesystem的用法示例。


在下文中一共展示了Filesystem::find_relative_path方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getInstalledLibs

 public static function getInstalledLibs($libDirectoryPath)
 {
     $arrInstalledLibs = array();
     $arrBowerJsonFiles = \Filesystem::folderSearch($libDirectoryPath, '/.*bower.json/');
     foreach ($arrBowerJsonFiles as $bowerJsonFilePath) {
         if (!isset($arrInstalledLibs[basename(dirname($bowerJsonFilePath))])) {
             $dotBowerJsonFilePath = dirname($bowerJsonFilePath) . '/.bower.json';
             if (file_exists($dotBowerJsonFilePath)) {
                 $objBowerInfo = json_decode(file_get_contents($dotBowerJsonFilePath));
             } else {
                 $objBowerInfo = json_decode(file_get_contents($bowerJsonFilePath));
             }
             $objLibData = new \stdClass();
             $objLibData->name = '(' . basename(dirname($dotBowerJsonFilePath)) . ') ' . $objBowerInfo->name;
             $objLibData->version = isset($objBowerInfo->version) ? $objBowerInfo->version : '[NO DEFINIDA]';
             $objLibData->dependencies = isset($objBowerInfo->dependencies) ? (array) $objBowerInfo->dependencies : array();
             $objLibData->main = array();
             if (isset($objBowerInfo->main)) {
                 $objLibData->main = is_array($objBowerInfo->main) ? $objBowerInfo->main : array(0 => $objBowerInfo->main);
             }
             $arrJsFiles = array();
             $arrCssFiles = array();
             $arrOtherFiles = array();
             $objLibData->js = array();
             $objLibData->css = array();
             $objLibData->less = array();
             $objLibData->otherFiles = array();
             foreach ($objLibData->main as $fileRelPath) {
                 $baseURI = "./" . \Filesystem::find_relative_path(SKEL_ROOT_DIR, $libDirectoryPath) . "/";
                 $includeFilePath = $baseURI . basename(dirname($bowerJsonFilePath)) . DIRECTORY_SEPARATOR . $fileRelPath;
                 $fileExt = pathinfo($includeFilePath, PATHINFO_EXTENSION);
                 switch ($fileExt) {
                     case 'js':
                         if (!in_array($includeFilePath, $arrJsFiles)) {
                             $objLibData->js[] = $includeFilePath;
                         }
                         break;
                     case 'css':
                         if (!in_array($includeFilePath, $arrCssFiles)) {
                             $objLibData->css[] = $includeFilePath;
                         }
                         break;
                     case 'less':
                         if (!in_array($includeFilePath, $arrCssFiles)) {
                             $objLibData->less[] = $includeFilePath;
                         }
                         break;
                     default:
                         if (!in_array($includeFilePath, $arrOtherFiles)) {
                             $objLibData->otherFiles[] = $includeFilePath;
                         }
                         break;
                 }
             }
             $arrInstalledLibs[basename(dirname($bowerJsonFilePath))] = $objLibData;
         }
     }
     return $arrInstalledLibs;
 }
开发者ID:neslonso,项目名称:Sintax,代码行数:59,代码来源:composer.php

示例2: preg_replace

 $firephp->info($origHref, 'origHref:');
 $baseURI = preg_replace('#[^/]*$#', '', $href);
 //Quitamos todo desde el último slash (exclusive)
 if (substr($href, 0, 1) == '/' && substr($href, 0, 2) != '//') {
     $basePath = realpath($_SERVER["DOCUMENT_ROOT"] . $baseURI);
     $baseURI = \Filesystem::find_relative_path(dirname($_SERVER['SCRIPT_FILENAME']), $basePath) . "/";
     //$firephp->info($baseURI,'baseURI:');
     $href = realpath($_SERVER["DOCUMENT_ROOT"] . $href);
     if (!$href) {
         throw new Exception('realpath (' . $_SERVER["DOCUMENT_ROOT"] . $origHref . ') devolvió false, ¿existe el fichero?.');
     }
 } elseif (substr($href, 0, 2) == './') {
     //$firephp->info(SKEL_ROOT_DIR.' + '.$baseURI,'SKEL_ROOT_DIR y baseURI:');
     //$firephp->info(realpath(SKEL_ROOT_DIR.$baseURI),'realpath SKEL_ROOT_DIR y baseURI:');
     $basePath = realpath(SKEL_ROOT_DIR . $baseURI);
     $baseURI = \Filesystem::find_relative_path(dirname($_SERVER['SCRIPT_FILENAME']), $basePath) . "/";
     //$firephp->info($baseURI,'baseURI:');
     $href = realpath(SKEL_ROOT_DIR . $href);
     if (!$href) {
         throw new Exception('realpath (' . SKEL_ROOT_DIR . $origHref . ') devolvió false, ¿existe el fichero?.');
     }
 } elseif (substr($href, 0, 2) == '//') {
     $href = PROTOCOL . ":" . $href;
     $firephp->info($baseURI, 'baseURI:');
 }
 $firephp->info($href, 'Cargando HREF y reescribiendo URLs css:');
 $fileContent = file_get_contents($href) . "\n\n";
 if ($lessParse) {
     //TODO: Mejora: solo parsear ficheros .less, no todos.
     $lessParser = new Less_Parser($arrLessParserOptions);
     $lessParser->parseFile($href, '');
开发者ID:neslonso,项目名称:Sintax,代码行数:31,代码来源:css.php

示例3: acCrearAppSkel

 public function acCrearAppSkel($args)
 {
     $file = SKEL_ROOT_DIR . $args['fileApp'];
     $path = SKEL_ROOT_DIR . $args['rutaApp'];
     $relPathFileDirToSkel = \Filesystem::find_relative_path(dirname($file), SKEL_ROOT_DIR) . '/';
     if (file_exists($file)) {
         throw new \ActionException('El punto de entrada "' . realpath($file) . '" ya existe.', 1);
     }
     if (file_exists($path)) {
         throw new \ActionException('La carpeta de la app "' . realpath($path) . '" ya existe.', 1);
     }
     $mode = 0755;
     mkdir($path, $mode, true);
     if (!is_dir($path)) {
         throw new \ActionException('No se pudo crear "' . $path . '"', 1);
     }
     $htaccessDest = dirname($file) . "/.htaccess";
     if (!file_exists($file)) {
         if (!file_exists(dirname($file))) {
             mkdir(dirname($file), $mode, true);
         }
         copy(APP_IMGS_DIR . '../creacionApp/fileApp.php', $file);
     } else {
         throw new \Exception("El punto de entrada '" . $file . "' ya existe", 1);
     }
     if (!file_exists($htaccessDest)) {
         copy(APP_IMGS_DIR . '../creacionApp/.htaccess', $htaccessDest);
     } else {
         ReturnInfo::add("No se ha realizado la copia de htaccess a '" . $htaccessDest . "'", "htaccess ya existe");
     }
     try {
         \Filesystem::copyDir(APP_IMGS_DIR . '../creacionApp/appSkel/', $path);
     } catch (Exception $e) {
         throw new \Exception('Error durante copia de appSkel a "' . $path . '"', 1, $e);
     }
     $appKey = \Filesystem::find_relative_path(SKEL_ROOT_DIR, $file);
     ReturnInfo::add("\n\t\t<ul>\n\t\t\t<li>SKEL_ROOT_DIR: " . SKEL_ROOT_DIR . "</li>\n\t\t\t<li>File: " . $file . "</li>\n\t\t\t<li>Ruta: " . $path . "</li>\n\t\t\t<li>.htaccess: " . $htaccessDest . "</li>\n\t\t\t<li>Definición de APP:\n<pre>\n'" . $appKey . "' => array(\n\t'KEY_APP' => '" . $appKey . "',\n\t'FILE_APP' => '" . basename($file) . "',\n\t'RUTA_APP' => SKEL_ROOT_DIR.'" . str_replace(SKEL_ROOT_DIR, '', $path) . "/',\n\t'NOMBRE_APP' => 'Sitio web',\n),\n</pre>\n\t\t\t</li>\n\t\t\t<li>Definición SKEL_ROOT_DIR (debe ir en " . str_replace($_SERVER['DOCUMENT_ROOT'], '', $file) . "):\n<pre>\ndefine ('SKEL_ROOT_DIR',realpath(__DIR__.'/'.'<em style='color:red;'>" . $relPathFileDirToSkel . "</em>').'/');\n</pre>\n\t\t\t</li>\n\t\t\t<li>Definición RewriteBase (.htacces): RewriteBase " . str_replace($_SERVER['DOCUMENT_ROOT'], '', dirname($file) . '/') . "</li>\n<!--\n\t\t\t<li>Cambios en RewriteRule (.htacces):\n<pre>\n#Si la url tenía idNumerica\nRewriteRule ^([^/]*)/(.*)/([0-9]+)/(.*)/ \$4 [L] -> RewriteRule ^([^/]*)/(.*)/([0-9]+)/(.*)/ <em style='color:red;'>" . $relPathFileDirToSkel . "</em>\$4 [L]\n#Si no tenía id númerica\nRewriteRule ^([^/]*)/(.*)/\$ \$2 [L] -> RewriteRule ^([^/]*)/(.*)/\$ <em style='color:red;'>" . $relPathFileDirToSkel . "</em>\$2 [L]\n</pre>\n\t\t\t</li>\n-->\n\t\t</ul>", 'Skeleto creado con exito');
 }
开发者ID:neslonso,项目名称:Sintax,代码行数:38,代码来源:Creacion.php

示例4:

				<ul>
					<li><a href="'.BASE_URL.'sintax/">Página princiapl de S!nt@x</a></li>
					<li><a href="'.BASE_URL.'sintax/creacion/">Herramienta de creación</a></li>
					<li>Bibliotecas de cliente: <a href="'.BASE_URL.'sintax/composer/">Composer</a> o <a href="'.BASE_URL.'sintax/bower/">Bowerphp</a></li>
				</ul>
		';
		die();
	}
/******************************************************************************/

//Configuramos el FirePHP
require_once SKEL_ROOT_DIR."includes/server/FirePHP.php";

//Definimos todas las constantes de la aplicacion correspondiente al punto de entrada
$arrApps=unserialize(APPS);
$appKey=\Filesystem::find_relative_path(SKEL_ROOT_DIR,$_SERVER['SCRIPT_FILENAME']);
if (isset($arrApps[$appKey])) {
	foreach ($arrApps[$appKey] as $key => $value) {
		define ($key,$value);
	}
} else {
	throw new \Exception("No se encontró APP con clave: ".$appKey,1);
}

require_once SKEL_ROOT_DIR."includes/server/clientLibs.php";

if (defined('RUTA_APP')) {
	if (file_exists(RUTA_APP."server/appDefines.php")) {
		require_once RUTA_APP."server/appDefines.php";
		if (file_exists(RUTA_APP."server/appClasesPHP.php")) {
			require_once RUTA_APP."server/appClasesPHP.php";
开发者ID:neslonso,项目名称:sf,代码行数:31,代码来源:start.php


注:本文中的Filesystem::find_relative_path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。