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


PHP PHPParser::getPageTitle方法代码示例

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


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

示例1: ParseFileContent

function ParseFileContent($filesrc, $params = array())
{
    /////////////////////////////////////
    // Parse prolog, epilog, title
    /////////////////////////////////////
    $filesrc = trim($filesrc);
    $prolog = $epilog = '';
    $php_doubleq = false;
    $php_singleq = false;
    $php_comment = false;
    $php_star_comment = false;
    $php_line_comment = false;
    $php_st = "<" . "?";
    $php_ed = "?" . ">";
    if ($params["use_php_parser"] && substr($filesrc, 0, 2) == $php_st) {
        $phpChunks = PHPParser::getPhpChunks($filesrc);
        if (!empty($phpChunks)) {
            $prolog = $phpChunks[0];
            $filesrc = substr($filesrc, strlen($prolog));
        }
    } elseif (substr($filesrc, 0, 2) == $php_st) {
        $fl = strlen($filesrc);
        $p = 2;
        while ($p < $fl) {
            $ch2 = substr($filesrc, $p, 2);
            $ch1 = substr($ch2, 0, 1);
            if ($ch2 == $php_ed && !$php_doubleq && !$php_singleq && !$php_star_comment) {
                $p += 2;
                break;
            } elseif (!$php_comment && $ch2 == "//" && !$php_doubleq && !$php_singleq) {
                $php_comment = $php_line_comment = true;
                $p++;
            } elseif ($php_line_comment && ($ch1 == "\n" || $ch1 == "\r" || $ch2 == "?>")) {
                $php_comment = $php_line_comment = false;
            } elseif (!$php_comment && $ch2 == "/*" && !$php_doubleq && !$php_singleq) {
                $php_comment = $php_star_comment = true;
                $p++;
            } elseif ($php_star_comment && $ch2 == "*/") {
                $php_comment = $php_star_comment = false;
                $p++;
            } elseif (!$php_comment) {
                if (($php_doubleq || $php_singleq) && $ch2 == "\\\\") {
                    $p++;
                } elseif (!$php_doubleq && $ch1 == '"') {
                    $php_doubleq = true;
                } elseif ($php_doubleq && $ch1 == '"' && substr($filesrc, $p - 1, 1) != '\\') {
                    $php_doubleq = false;
                } elseif (!$php_doubleq) {
                    if (!$php_singleq && $ch1 == "'") {
                        $php_singleq = true;
                    } elseif ($php_singleq && $ch1 == "'" && substr($filesrc, $p - 1, 1) != '\\') {
                        $php_singleq = false;
                    }
                }
            }
            $p++;
        }
        $prolog = substr($filesrc, 0, $p);
        $filesrc = substr($filesrc, $p);
    } elseif (preg_match("'(.*?<title>.*?</title>)(.*)\$'is", $filesrc, $reg)) {
        $prolog = $reg[1];
        $filesrc = $reg[2];
    }
    $title = PHPParser::getPageTitle($filesrc, $prolog);
    $arPageProps = array();
    if (strlen($prolog)) {
        if (preg_match_all("'\\\$APPLICATION->SetPageProperty\\(([\"\\'])(.*?)(?<!\\\\)[\"\\'] *, *([\"\\'])(.*?)(?<!\\\\)[\"\\']\\);'i", $prolog, $out)) {
            foreach ($out[2] as $i => $m1) {
                $arPageProps[UnEscapePHPString($m1, $out[1][$i])] = UnEscapePHPString($out[4][$i], $out[3][$i]);
            }
        }
    }
    if (substr($filesrc, -2) == "?" . ">") {
        if (isset($phpChunks) && count($phpChunks) > 1) {
            $epilog = $phpChunks[count($phpChunks) - 1];
            $filesrc = substr($filesrc, 0, -strlen($epilog));
        } else {
            $p = strlen($filesrc) - 2;
            $php_start = "<" . "?";
            while ($p > 0 && substr($filesrc, $p, 2) != $php_start) {
                $p--;
            }
            $epilog = substr($filesrc, $p);
            $filesrc = substr($filesrc, 0, $p);
        }
    }
    return array("PROLOG" => $prolog, "TITLE" => $title, "PROPERTIES" => $arPageProps, "CONTENT" => $filesrc, "EPILOG" => $epilog);
}
开发者ID:gitkv,项目名称:bash,代码行数:88,代码来源:tools.php

示例2: GetDirList

function GetDirList($path, &$arDirs, &$arFiles, $arFilter = array(), $sort = array(), $type = "DF", $bLogical = false, $task_mode = false)
{
    global $USER, $APPLICATION;
    CMain::InitPathVars($site, $path);
    $DOC_ROOT = CSite::GetSiteDocRoot($site);
    $arDirs = array();
    $arFiles = array();
    $exts = strtolower($arFilter["EXTENSIONS"]);
    $arexts = explode(",", $exts);
    if (isset($arFilter["TYPE"])) {
        $type = strtoupper($arFilter["TYPE"]);
    }
    $io = CBXVirtualIo::GetInstance();
    $path = $io->CombinePath("/", $path);
    $abs_path = $io->CombinePath($DOC_ROOT, $path);
    if (!$io->DirectoryExists($abs_path)) {
        return false;
    }
    $date_format = CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL"));
    $tzOffset = CTimeZone::GetOffset();
    $dir = $io->GetDirectory($abs_path);
    $arChildren = $dir->GetChildren();
    foreach ($arChildren as $child) {
        $arFile = array();
        if (($type == "F" || $type == "") && $child->IsDirectory()) {
            continue;
        }
        if (($type == "D" || $type == "") && !$child->IsDirectory()) {
            continue;
        }
        $file = $child->GetName();
        if ($bLogical) {
            if ($child->IsDirectory()) {
                $sSectionName = "";
                $fsn = $io->CombinePath($abs_path, $file, ".section.php");
                if (!$io->FileExists($fsn)) {
                    continue;
                }
                include $io->GetPhysicalName($fsn);
                $arFile["LOGIC_NAME"] = $sSectionName;
            } else {
                if (CFileMan::GetFileTypeEx($file) != "php") {
                    continue;
                }
                if ($file == '.section.php') {
                    continue;
                }
                if (!preg_match('/^\\.(.*)?\\.menu\\.(php|html|php3|php4|php5|php6|phtml)$/', $file, $regs)) {
                    $f = $io->GetFile($abs_path . "/" . $file);
                    $filesrc = $f->GetContents();
                    $title = PHPParser::getPageTitle($filesrc);
                    if ($title === false) {
                        continue;
                    }
                    $arFile["LOGIC_NAME"] = $title;
                }
            }
        }
        $arFile["PATH"] = $abs_path . "/" . $file;
        $arFile["ABS_PATH"] = $path . "/" . $file;
        $arFile["NAME"] = $file;
        $arPerm = $APPLICATION->GetFileAccessPermission(array($site, $path . "/" . $file), $USER->GetUserGroupArray(), $task_mode);
        if ($task_mode) {
            $arFile["PERMISSION"] = $arPerm[0];
            if (count($arPerm[1]) > 0) {
                $arFile["PERMISSION_EX"] = $arPerm[1];
            }
        } else {
            $arFile["PERMISSION"] = $arPerm;
        }
        $arFile["TIMESTAMP"] = $child->GetModificationTime() + $tzOffset;
        $arFile["DATE"] = date($date_format, $arFile["TIMESTAMP"]);
        if (isset($arFilter["TIMESTAMP_1"]) && strtotime($arFile["DATE"]) < strtotime($arFilter["TIMESTAMP_1"])) {
            continue;
        }
        if (isset($arFilter["TIMESTAMP_2"]) && strtotime($arFile["DATE"]) > strtotime($arFilter["TIMESTAMP_2"])) {
            continue;
        }
        if (is_set($arFilter, "MIN_PERMISSION") && $arFile["PERMISSION"] < $arFilter["MIN_PERMISSION"] && !$task_mode) {
            continue;
        }
        if (!$child->IsDirectory() && $arFile["PERMISSION"] <= "R" && !$task_mode) {
            continue;
        }
        if ($bLogical) {
            if (strlen($arFilter["NAME"]) > 0 && strpos($arFile["LOGIC_NAME"], $arFilter["NAME"]) === false) {
                continue;
            }
        } else {
            if (strlen($arFilter["NAME"]) > 0 && strpos($arFile["NAME"], $arFilter["NAME"]) === false) {
                continue;
            }
        }
        //if(strlen($arFilter["NAME"])>0 && strpos($arFile["NAME"], $arFilter["NAME"])===false)
        //	continue;
        if (substr($arFile["ABS_PATH"], 0, strlen(BX_ROOT . "/modules")) == BX_ROOT . "/modules" && !$USER->CanDoOperation('edit_php') && !$task_mode) {
            continue;
        }
        if ($arFile["PERMISSION"] == "U" && !$task_mode) {
            $ftype = GetFileType($arFile["NAME"]);
//.........这里部分代码省略.........
开发者ID:rasuldev,项目名称:torino,代码行数:101,代码来源:admin_tools.php


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