public function analyze() { $report = null; $mail = (string) $this->m_mail; $desc = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w+'), 2 => array('pipe', 'w+')); $pipes = []; $pid = @proc_open(self::CMD_BIN . ' ' . escapeshellarg(self::CMD_ARG), $desc, $pipes); if (false !== $pid) { @fwrite($pipes[0], $mail); @fclose($pipes[0]); $report = stream_get_contents($pipes[1]); @proc_close($pid); } if (null === $report) { return; } $lines = explode("\n", $report); $lines = array_reverse($lines); $score = $lines[count($lines) - 1]; $chunks = explode('/', $score); $this->m_score = (double) reset($chunks); $this->m_scoreThreshold = (double) end($chunks); $this->m_tests = []; foreach ($lines as $line) { if (String::startsWith($line, '---')) { break; } $matches = []; preg_match('/([-+\\d.\\d]+)\\s+(\\w*)\\s+([\\s\\S]*)/', $line, $matches); if (isset($matches[3])) { $this->m_tests[$matches[2]] = array((double) $matches[1], $matches[3]); } } }
static function Response($ex, $app) { if ($ex instanceof RequestBodyException) { $app->response->status(400); return json_encode(array("RequestBodyException:" . $ex->getMessage())); } else { if ($ex instanceof RecordNotFoundException) { $app->response->status(404); return json_encode(array("RecordNotFoundException:" . $ex->getMessage())); } else { if ($ex instanceof RecordDuplicatedException) { $app->response->status(409); return json_encode(array("RecordDuplicatedException:" . $ex->getMessage())); } else { if (String::startsWith($ex->getMessage(), "SQLSTATE[23000]")) { $app->response->status(400); return json_encode(array("Duplicated record.")); } else { $app->response->status(500); //var_dump($ex->getMessage()); return json_encode(array($ex->getMessage())); //return json_encode(array($ex->__toString())); } } } } }
/** * startsWith test. * @return void */ public function testStartswith() { $this->assertTrue(String::startsWith('123', NULL), "String::startsWith('123', NULL)"); $this->assertTrue(String::startsWith('123', ''), "String::startsWith('123', '')"); $this->assertTrue(String::startsWith('123', '1'), "String::startsWith('123', '1')"); $this->assertFalse(String::startsWith('123', '2'), "String::startsWith('123', '2')"); $this->assertTrue(String::startsWith('123', '123'), "String::startsWith('123', '123')"); $this->assertFalse(String::startsWith('123', '1234'), "String::startsWith('123', '1234')"); }
/** * getAppNames * Devuelve una lista de los nombres de las apps * existentes en la instalacion de Yupp (lee el filesystem). */ public static function getAppNames() { $appNames = array(); $dir = dir('./apps'); while (false !== ($app = $dir->read())) { if (!String::startsWith($app, ".") && $app !== "core" && is_dir('./apps/' . $app)) { $appNames[] = $app; } } return $appNames; }
static function Response($ex, $app) { //var_dump($ex->getMessage()); if ($ex instanceof RequestBodyException) { $app->response->status(400); return json_encode(array("error" => "用户输入错误")); } else { if ($ex instanceof RecordNotFoundException) { //echo '404================'; $app->response->status(404); //return json_encode(array("RecordNotFoundException:" . $ex->getMessage())); //$xx=array("url_list"=>$data); //return json_encode(array("error" => "RecordNotFoundException:" . $ex->getMessage())); return json_encode(array("error" => "用户或记录不存在")); } else { if ($ex instanceof RecordDuplicatedException) { $app->response->status(409); return json_encode(array("error" => "重复记录输入")); } else { if ($ex instanceof OrderException) { $app->response->status(400); return json_encode(array("error" => "订单出错了")); } else { if ($ex instanceof SmsException) { $app->response->status(500); return json_encode(array("error" => "发送或认证短信验证码失败")); } else { if (String::startsWith($ex->getMessage(), "SQLSTATE[23000]")) { if (String::startsWith($ex->getMessage(), "SQLSTATE[23000]: Integrity constraint violation: 1452")) { $app->response->status(404); return json_encode(array("error" => "记录不存在.")); } else { if (String::startsWith($ex->getMessage(), "SQLSTATE[23000]: Integrity constraint violation: 1062")) { $app->response->status(400); return json_encode(array("error" => "重复数据或记录")); } else { $app->response->status(500); return json_encode(array("error" => "数据库出错了.")); } } } else { $app->response->status(500); return json_encode(array("error" => "系统未知错误")); //return json_encode(array($ex->__toString())); } } } } } } }
/** * Format telephone number according to known SK and CZ specifics * @param string $telephone * @return string */ public static function telephone($telephone) { if (NStrings::startsWith($telephone, '02')) { return self::format($telephone, array(2, 1, 2, 2, 2)); } elseif (String::startsWith($telephone, '0')) { return self::format($telephone, array(3, 1, 2, 2, 2)); } elseif (strlen($telephone) === 10) { return self::format($telephone, array(3, 1, 2, 2, 2)); } elseif (strlen($telephone) === 9) { return self::format($telephone, array(3, 3, 3)); } else { return self::format($telephone, array(1, 2, 2, 2)); } }
/** * Make relative url absolute * @param string image url * @param string single or double quote * @param string absolute css file path * @param string source path * @return string */ public static function absolutizeUrl($url, $quote, $cssFile, $sourcePath) { // is already absolute if (preg_match("/^([a-z]+:\\/)?\\//", $url)) { return $url; } $docroot = realpath(WWW_DIR); $basePath = rtrim(Environment::getVariable("baseUri"), '/'); // inside document root if (String::startsWith($cssFile, $docroot)) { $path = $basePath . substr(dirname($cssFile), strlen($docroot)) . DIRECTORY_SEPARATOR . $url; // outside document root } else { $path = $basePath . substr($sourcePath, strlen($docroot)) . DIRECTORY_SEPARATOR . $url; } $path = self::cannonicalizePath($path); return $quote === '"' ? addslashes($path) : $path; }
public function getBasePath() { if (!String::startsWith('/', $this->glob)) { return ''; } $pos = 0; $arr = str_split($this->glob); $size = count($arr); for ($i = 0; $i < $size; $i++) { if ($arr[$i] == '*') { break; } else { if ($arr[$i] == '/') { $pos = $i; } } } return substr($this->glob, 0, $pos + 1); }
/** * Auxiliar recursiva para getModel() */ private function getModelRecursive($dir) { $res = array(); $d = dir($dir); while (false !== ($entry = $d->read())) { if (!String::startsWith($entry, '.')) { if (is_file($dir . '/' . $entry)) { $res[] = $entry; } else { if (is_dir($dir . '/' . $entry)) { $res_recur = $this->getModelRecursive($dir . '/' . $entry); //$res = array_merge($res, $res_recur); $res[$entry] = $res_recur; } } } } $d->close(); return $res; }
/** * Esta devuelve los nombres de las clases dentro del directorio y sigue recorriendo recursivamente. * FIXME: En realidad es una operacion general, tal vez deberia ser parte de FileSystem. */ private static function getModelClassesRecursive($dir) { $res = array(); //$entries = FileSystem::getFileNames( $dir ); // subdirs y files $d = dir($dir); while (false !== ($entry = $d->read())) { //echo "$entry<br/>"; if (!String::startsWith($entry, ".")) { if (is_file("{$dir}/{$entry}")) { $res[] = $entry; } else { if (is_dir("{$dir}/{$entry}")) { $res_recur = self::getModelClassesRecursive("{$dir}/{$entry}"); $res = array_merge($res, $res_recur); } } } } $d->close(); return $res; }
*/ //var_dump($app->request->headers); /*echo $_SERVER['REQUEST_METHOD'] . "<br>"; echo $_SERVER['REQUEST_URI'] . "<br>"; if (String::startsWith($_SERVER['REQUEST_URI'], "/Producer/LoginName/") === FALSE) { echo "NOT startwith<br>"; } else { echo "startwith:[" . (String::startsWith($_SERVER['REQUEST_URI'], "/Producer/LoginName/") !== TRUE ) . "]<br>"; } flush();*/ //Check UserSessionId in header for all URIs(except for register and login pages). if ($_SERVER['REQUEST_METHOD'] == "POST" && !String::startsWith($_SERVER['REQUEST_URI'], "/Producer/BasicInfo/") && ($_SERVER['REQUEST_METHOD'] == "POST" && !String::startsWith($_SERVER['REQUEST_URI'], "/Consumer/BasicInfo/")) && ($_SERVER['REQUEST_METHOD'] == "GET" && !String::startsWith($_SERVER['REQUEST_URI'], "/Producer/LoginName/")) && ($_SERVER['REQUEST_METHOD'] == "GET" && !String::startsWith($_SERVER['REQUEST_URI'], "/Consumer/LoginName/"))) { //echo "TRAP<BR>"; if (!isset($app->request->headers["UserSessionId"])) { //echo "HTTP/1.1 403 Forbidden\r\n"; header("HTTP/1.1 403 Forbidden"); return; } } //echo "PASS<BR>"; //flush(); //header("HTTP/1.1 200 OK"); //return; //ProducerTest::Test1(); $app->run(); //echo '===0<br>\r\n'; //flush();
<?php include_once "libPalabras.php"; include $_SERVER['DOCUMENT_ROOT'] . 'KhunluungramnerkP/loginMySQL.php'; $handler = new WordHandler('localhost', 'khunluungramnerk', $usrDB["user"], $usrDB["passwd"]); $handler->conn(); if (!isset($_SESSION["usr"])) { header('Location: index.php'); } if (isset($_POST["crear"])) { $crearReforma = array("tipo" => "INSERT", "campos" => array("id" => $handler->getMaxTabla("id", "cte_reformas"), "acrónimo" => $_POST["acrónimo"], "nombre" => $_POST["nombre"], "descripción" => $_POST["descripción"], "fecha" => date("Y:m:d")), "tabla" => "cte_reformas"); $handler->query($crearReforma); } elseif (isset($_POST["ref_id"])) { foreach ($_POST as $clave => $campo) { $str = new String($clave); if ($str->startsWith("af_")) { $str->remove_prefix("af_"); $num = $str->get(); $handler->setWordID($_POST["pal_id_" . $num]); $handler->getDatosPalabra(); $handler->reformarPalabra($_POST["pal_" . $num], $_POST["ref_id"]); } } } $handler->shutdown(); session_start(); header('Location: ' . $_SESSION["urlVuelta"]);
/** * @test */ public function startsWith() { $this->assertTrue(String::startsWith('Foo', 'Foo')); $this->assertTrue(String::startsWith('Foo123', 'Foo')); $this->assertFalse(String::startsWith(' Foo123', 'Foo')); }
/** * @param string $path * @return bool */ public static function isAbsolute($path) { return String::startsWith('/', $path); }
<?php $m = Model::getInstance(); $app = $m->get('app'); ?> <html> <head> </head> <body> <h1>Aplicacion: <?php echo $app; ?> </h1> <h2>Controladores:</h2> <?php $app_dir = dir("./apps/" . $app . "/controllers"); $suffix = "Controller.class.php"; $prefix = "apps." . $app . ".controllers."; echo "<ul>"; while (false !== ($controller = $app_dir->read())) { if (!String::startsWith($controller, ".")) { $controller = substr($controller, strlen($prefix), -strlen($suffix)); $logic_controller = String::firstToLower($controller); echo '<li>[ <a href="' . Helpers::url(array("app" => $app, "controller" => $logic_controller, "action" => "index")) . '">' . $controller . '</a> ]</li>'; } } echo "</ul>"; ?> </body> </html>
} } elseif ($str->startsWith("edit_raíz_")) { $str->remove_prefix("edit_raíz_"); $nums = explode("_", $str->get()); $args = array("id" => (int) $nums[1], "raíz" => $_POST["raíz_" . $nums[0] . '_' . $nums[1]]); $tipo = "raíz"; } if ($args !== NULL) { $handler->editarEtimologia($tipo, $args); } } break; case "significados": foreach ($_POST as $clave => $campo) { $str = new String($clave); if ($str->startsWith("edit_")) { $str->remove_prefix("edit_"); $num = $str->get(); $handler->editarSignificado((int) $_POST["sign_id_" . $num], $_POST["sign_tipo_" . $num], $_POST["sign_" . $num]); } elseif ($str->startsWith("elim_")) { $str->remove_prefix("elim_"); $num = $str->get(); $handler->eliminarSignificado((int) $_POST["sign_id_" . $num]); } elseif ($str->equals("new_sign_creat")) { $handler->annadirSignificado($_POST['new_sign_tipo'], $_POST['new_sign']); } } break; } $handler->shutdown(); header('Location: palabra.php?id=' . $_SESSION["id"] . '&edicion=true');
public function crearPalabra($datos) { //Crear palabra $palabra_id = $this->getMaxTabla("id", "palabras"); $new_palabra = array("tipo" => "INSERT", "campos" => array("id" => $palabra_id, "palabra" => $datos["palabra"]), "tabla" => "palabras"); $this->query($new_palabra); //Agregar etimología $etimologias_id = $this->getMaxTabla("id", "etimologias"); if (isset($datos["raiz_1"])) { foreach ($datos as $clave => $campo) { $str = new String($clave); if ($str->startsWith("raiz_")) { $str->remove_prefix("raiz_"); $num = $str->get(); $raiz = new String($datos["raiz_" . $num]); $id_raiz = new String($datos["id_raiz_" . $num]); $idRaizVacia = false; if ($raiz->equals('') && !$id_raiz->equals('')) { $obtenerPalabra = array("tipo" => "SELECT", "campos" => array("palabra"), "tablas" => "palabras", "condicion" => array("id" => $datos["id_raiz_" . $num])); $this->query($obtenerPalabra); //@TODO: Este método de cálculo de palabras habrá que modificarlo en cuanto se borre la tabla palabras $raiz = new String($this->data->lista[0]["palabra"]); } elseif (!$raiz->equals('') && $id_raiz->equals('')) { $raiz = new String($datos["raiz_" . $num]); $idRaizVacia = true; } if (isset($datos["pref_" . $num])) { $raiz = $raiz->get() . '-'; } elseif (isset($datos["suf_" . $num])) { $raiz = '-' . $raiz->get(); } else { $raiz = $raiz->get(); } if ($num == 1) { $new_raiz_et = array("tipo" => "INSERT", "campos" => array("id" => $etimologias_id, "tipo" => 2, "palabra_id" => $palabra_id, "fecha" => date("Y:m:d"), "palabra" => $datos["palabra"]), "tabla" => "etimologias"); $this->query($new_raiz_et); } $new_raiz_et_raiz = array("tipo" => "INSERT", "campos" => array("id" => $this->getMaxTabla("id", "etim_raiz"), "etimologias_id" => $etimologias_id, "posición" => $num, "raíz" => $raiz), "tabla" => "etim_raiz"); if (!$idRaizVacia) { $new_raiz_et_raiz["campos"]["palabra_et"] = $datos["id_raiz_" . $num]; } $this->query($new_raiz_et_raiz); } } } else { $new_et = array("tipo" => "INSERT", "campos" => array("id" => $etimologias_id, "tipo" => 1, "palabra_id" => $palabra_id, "fecha" => date("Y:m:d"), "palabra" => $datos["palabra"]), "tabla" => "etimologias"); $this->query($new_et); $new_et_externa = array("tipo" => "INSERT", "campos" => array("id" => $etimologias_id, "idioma" => $datos["et_lang"], "etimología" => $datos["et_ext"]), "tabla" => "etim_ext"); $this->query($new_et_externa); } //Añadir significado $significados_id = $this->getMaxTabla("id", "significados"); $new_sign = array("tipo" => "INSERT", "campos" => array("id" => $significados_id, "palabra_id" => $palabra_id, "tipo" => $_POST["sign_tipo"], "acepción" => $_POST["sign"]), "tabla" => "significados"); $this->query($new_sign); }
/** * Si se hizo un redirect y se puso algo en flash, esos valores se pasan por GET. * Este metodo retorna todos los valors de GET que se correspondan con flash. */ public function getFlashParams() { $res = array(); $paramsKeys = array_keys($_GET); $current = current($paramsKeys); while ($current) { if (String::startsWith($current, "flash_")) { $res[substr($current, 6)] = $_GET[$current]; } $current = next($paramsKeys); } return $res; }
private static function fetchNameAndModifiers($code) { $name = LatteFilter::fetchToken($code); $modifiers = LatteFilter::formatArray($code); $name = String::startsWith($name, '$') ? $name : "'{$name}'"; $modifiers = $modifiers ? $modifiers : "array()"; return array($name, $modifiers); }
<?php return array('configs' => array('admin.title' => 'Control Panel', 'admin.default_route' => 'admin/user'), 'permissions' => array('admin.access' => 'Access to admin'), 'routes' => array('admin' => array('title' => 'Admin', 'callback' => array('admin', 'redirect')), 'admin/install' => array('title' => 'Install', 'callback' => array('admin', 'install'), 'hidden' => true)), 'events' => array('router.data' => function ($currentRoute, $data) { if (String::startsWith($currentRoute, 'admin')) { if (!Admin::isConfigured()) { if (!String::startsWith($currentRoute, 'admin/install')) { Url::redirect('admin/install'); } } elseif (!String::startsWith($currentRoute, 'admin/login')) { $noAccess = !User::current()->hasPermission('admin.access'); $isAnon = User::current()->isAnonymous(); if (!$isAnon && $noAccess) { Message::error('You do not have admin access permissions.'); unset($_SESSION[Config::get('user.session_key')]); } if ($isAnon || $noAccess) { Url::redirect('admin/login'); } } Admin::setInAdmin(true); View::setPath(ROOT . 'core/admin/'); } }, 'module.response' => function ($response = null) { if (Admin::inAdmin()) { View::data('adminContent', $response); } }, 'view.load' => function ($module, $controller, $method) { if (Admin::inAdmin()) { $paths = array(sprintf('%s/%s', $controller, $method), sprintf('%s_%s', $controller, $method)); foreach ($paths as $path) { $viewFile = Load::getModulePath($module) . Config::get('view.dir') . $path . EXT;
public function startsWith() { $str = new String('www.m�ller.com'); $this->assertTrue($str->startsWith('www.')); $this->assertFalse($str->startsWith('ww.')); $this->assertFalse($str->startsWith('m�ller')); }
/** * Generated from @assert ("", "abcdef") == false. * * @covers String::startsWith */ public function testStartsWith4() { $this->assertFalse(String::startsWith("", "abcdef")); }
/** * TODO Comments. */ private static function _getHtml($sorted, $data) { // Determine count of actual items about to be displayed, this is used to determine // the "first" and "last" classes to be added to the current item, but also if we should just return $totalCount = 0; foreach ($sorted as $route => $routeData) { if ($routeData['hidden'] !== true && !is_null($routeData['title'])) { $totalCount++; } } // If no items, just return if ($totalCount == 0) { return null; } $html = '<ul'; if (isset($data['attributes'])) { foreach ($data['attributes'] as $k => $v) { $html .= sprintf(' %s="%s"', $k, $v); } } $html .= '>'; // The current route is used to determine if the menu item is active or not $currentRoute = Router::getCurrentRoute(); $currentCount = 1; foreach ($sorted as $route => $routeData) { if ($routeData['hidden'] === true || is_null($routeData['title'])) { continue; } $classes = array(); if (String::startsWith($currentRoute['route'], $route)) { $classes[] = 'active'; } if ($currentCount == 1) { $classes[] = 'first'; } if ($currentCount == $totalCount) { $classes[] = 'last'; } $html .= '<li'; if ($classes) { $html .= ' class="' . implode(' ', $classes) . '"'; } $html .= '>'; $html .= '<a'; if ($classes) { $html .= ' class="' . implode(' ', $classes) . '"'; } $html .= ' href="' . Url::to($route) . '">'; //$html .= '<a href="' . Url::to($route) . '">'; if (is_callable($routeData['title'])) { $html .= call_user_func($routeData['title']); } else { $html .= $routeData['title']; } $html .= '</a>'; if ($routeData['children']) { $html .= self::_getHtml($routeData['children'], $data); } $html .= '</li>'; $currentCount++; } $html .= '</ul>'; return $html; }
/** * @covers Panadas\Util\String::startsWith() */ public function testStartsWith() { $this->assertTrue(String::startsWith("foo", "foobar")); $this->assertFalse(String::startsWith("bar", "foobar")); }
/** * Helper para crear titulos de columnas ordenables en los listados. * * attr es el nombre del atributo por la que se va a verficar el orden. * sort es el nombre del atributo por el que se esta ordenando actualmente. * */ public static function orderBy($params) { $model = Model::getInstance(); $sort = $model->get('sort'); // puede ser vacio //$params['sort']; // sort actual $current_dir = $model->get('dir'); // TODO> si hay max y offset, conservarlos. if (!isset($params['attrs'])) { $params['attrs'] = array(); } $dir = 'asc'; if ($sort === $params['attr']) { if ($current_dir === 'asc') { $dir = 'desc'; $params['attrs']['class'] = 'order_desc'; // FIXED> para CSS FIXME: me lo pone como params de la url, no en la tag. } else { $params['attrs']['class'] = 'order_asc'; // FIXED> para CSS FIXME: me lo pone como params de la url, no en la tag. } } //$res .= '<a href="'. Helpers::params2url( array('sort'=>$attr, 'dir'=>$dir) ) .'">'; // TODO: no tengo acceso a los params desde helpers. //$res .= $attr; // TODO: Habria que ver si esto es i18n, deberia haber algun "display name" asociado al nombre del campo. //$res .= '</a>'; // Agregado de params de filtrado a links (http://code.google.com/p/yupp/issues/detail?id=49) $_params = $model->getAll(); // params + lo que metio el controller como model para la view foreach ($_params as $k => $v) { if (String::startsWith($k, 'filter_')) { $params[$k] = $v; } } // Soporte para addParams, la vista puede decirle que otros // params quiere poner en la url (p.e. 'query' si se hizo // una busqueda y se quiere tener ordenamiento por los resultados). if (isset($params['addParams'])) { foreach ($params['addParams'] as $paramName) { $params[$paramName] = $model->get($paramName); // los params se sacan del modelo actual, la vista sabe cuales params quiere } $params['addParams'] = NULL; } // Para mantener el paginado. $params['offset'] = $model->get('offset'); // puede no estar $params['max'] = $model->get('max'); // puede no estar $params['dir'] = $dir; $params['sort'] = $params['attr']; if (!isset($params['body'])) { $params['body'] = $params['attr']; } $res = self::link($params); return $res; }
/** * File browser - projít soubory * @param string $folder */ public function actionListFiles($folder = "") { // check rights // if (!Environment::getUser()->isAuthenticated()) { // $this->sendError("Access denied."); // } try { $folderPath = $this->getFolderPath($folder); } catch (InvalidArgumentException $e) { $this->sendError("Folder does not exist or is not writeable."); } // list of files $folders = array(); $files = array(); // up if ($folder !== "") { $lastPos = strrpos($folder, "/"); $key = $lastPos === false ? "" : substr($folder, 0, $lastPos); $folders[] = array("type" => "up", "name" => "..", "key" => $key); } foreach (new DirectoryIterator($folderPath) as $fileInfo) { $fileName = $fileInfo->getFileName(); // skip hidden files, . and .. if (String::startsWith($fileName, ".")) { continue; } // filename with folder $key = ($folder ? $folder . "/" : "") . $fileName; // directory if ($fileInfo->isDir()) { $folders[] = array("type" => "folder", "name" => $fileName, "key" => $key); // file } elseif ($fileInfo->isFile()) { // image if (@getImageSize($fileInfo->getPathName())) { $thumbFileName = $this->thumbnailFileName($fileInfo->getPathName()); if (file_exists($this->tempDir . "/" . $thumbFileName)) { $thumbnailKey = $this->tempUri . "/" . $thumbFileName; } else { $thumbnailKey = $this->link("thumbnail", $key); } $files[] = array("type" => "image", "name" => $fileName, "insertUrl" => $key, "description" => $fileName, "thumbnailKey" => $thumbnailKey); // other file } else { $files[] = array("type" => "file", "name" => $fileName, "insertUrl" => $this->baseFolderUri . ($folder ? "{$folder}/" : "") . $fileName, "description" => $fileName); } } } // send response $this->terminate(new JsonResponse(array("list" => array_merge($folders, $files)))); }
private function _loadModelRecursive($model_path) { $dir = dir($model_path); while (false !== ($entry = $dir->read())) { if (is_dir($model_path . '/' . $entry) && !String::startsWith($entry, ".")) { self::_loadModelRecursive($model_path . "/" . $entry); // recursivo } else { if (!String::startsWith($entry, ".")) { $finfo = FileNames::getFilenameInfo($entry); if ($finfo) { // Al cargar una clase, esta podria cargar otras, si se declaran loads en esa clase, // por lo que verificando si la clase ya esta cargada antes de intentar cargarla de // nuevo, ahorraria esos loads en cascada. if (!$this->isLoadedClass($finfo['package'], $finfo['name'])) { $this->load($finfo['package'], $finfo['name']); } } } } } $dir->close(); }
/** * Handles CONTEXT_TAG. */ private function contextTag() { $matches = $this->match('~ (?P<end>/?>)(?P<tagnewline>[\\ \\t]*(?=\\r|\\n))?| ## end of HTML tag ' . $this->macroRe . '| ## curly tag \\s*(?P<attr>[^\\s/>={]+)(?:\\s*=\\s*(?P<value>["\']|[^\\s/>{]+))? ## begin of HTML attribute ~xsi'); if (!$matches || !empty($matches['macro'])) { // EOF or {macro} } elseif (!empty($matches['end'])) { // end of HTML tag /> $tag = end($this->tags); $isEmpty = !$tag->closing && ($matches['end'][0] === '/' || isset(Html::$emptyElements[strtolower($tag->name)])); if ($tag->isMacro || !empty($tag->attrs)) { if ($tag->isMacro) { $code = $this->handler->tagMacro(substr($tag->name, strlen(self::HTML_PREFIX)), $tag->attrs, $tag->closing); if ($code === NULL) { throw new InvalidStateException("Unknown tag-macro <{$tag->name}> on line {$this->line}."); } if ($isEmpty) { $code .= $this->handler->tagMacro(substr($tag->name, strlen(self::HTML_PREFIX)), $tag->attrs, TRUE); } } else { $code = substr($this->output, $tag->pos) . $matches[0] . (isset($matches['tagnewline']) ? "\n" : ''); $code = $this->handler->attrsMacro($code, $tag->attrs, $tag->closing); if ($code === NULL) { throw new InvalidStateException("Unknown macro-attribute " . self::HTML_PREFIX . implode(' or ' . self::HTML_PREFIX, array_keys($tag->attrs)) . " on line {$this->line}."); } if ($isEmpty) { $code = $this->handler->attrsMacro($code, $tag->attrs, TRUE); } } $this->output = substr_replace($this->output, $code, $tag->pos); $matches[0] = ''; // remove from output } if ($isEmpty) { $tag->closing = TRUE; } if (!$tag->closing && (strcasecmp($tag->name, 'script') === 0 || strcasecmp($tag->name, 'style') === 0)) { $this->context = self::CONTEXT_CDATA; $this->escape = strcasecmp($tag->name, 'style') ? 'TemplateHelpers::escapeJs' : 'TemplateHelpers::escapeCss'; } else { $this->context = self::CONTEXT_TEXT; $this->escape = 'TemplateHelpers::escapeHtml'; if ($tag->closing) { array_pop($this->tags); } } } else { // HTML attribute $name = $matches['attr']; $value = empty($matches['value']) ? TRUE : $matches['value']; // special attribute? if ($isSpecial = String::startsWith($name, self::HTML_PREFIX)) { $name = substr($name, strlen(self::HTML_PREFIX)); } $tag = end($this->tags); if ($isSpecial || $tag->isMacro) { if ($value === '"' || $value === "'") { if ($matches = $this->match('~(.*?)' . $value . '~xsi')) { // overwrites $matches $value = $matches[1]; } } $tag->attrs[$name] = $value; $matches[0] = ''; // remove from output } elseif ($value === '"' || $value === "'") { // attribute = "' $this->context = self::CONTEXT_ATTRIBUTE; $this->quote = $value; $this->escape = strncasecmp($name, 'on', 2) ? strcasecmp($name, 'style') ? 'TemplateHelpers::escapeHtml' : 'TemplateHelpers::escapeHtmlCss' : 'TemplateHelpers::escapeHtmlJs'; } } return $matches; }
/** * Returns a file for an absolute path or for a path that is relative to * the one of this file. * * @param string $path_ * * @return \Components\Io_File */ public function getRelated($path_) { if (String::startsWith($path_, '/')) { return new self($path_); } return new self($this->getDirectoryAsString() . "/{$path_}"); }