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; }
$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, '');
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'); }
<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";