/** * 解析一个静态资源的地址 * * @param string $resource 文件地址 */ public static function parseResourceUrl($resource = '') { if ($GLOBALS['debug'] && CML_IS_MULTI_MODULES) { //简单判断没有.的时候当作是目录不加版本号 $isDir = strpos($resource, '.') === false ? true : false; $file = Response::url("cmlframeworkstaticparse/{$resource}", false); $isDir || ($file .= (\Cml\Config::get("url_model") == 3 ? "&v=" : "?v=") . Cml::$nowTime); } else { $file = Config::get("static__path", \Cml\Route::$urlParams["root"] . "public/{$resource}"); } echo $file; }
/** * 解析一个静态资源的地址 * * @param string $resource 文件地址 */ public static function parseResourceUrl($resource = '') { //简单判断没有.的时候当作是目录不加版本号 $isDir = strpos($resource, '.') === false ? true : false; if (Cml::$debug) { $file = Response::url("cmlframeworkstaticparse/{$resource}", false); if (Config::get('url_model') == 2) { $file = rtrim($file, Config::get('url_html_suffix')); } $isDir || ($file .= (Config::get("url_model") == 3 ? "&v=" : "?v=") . Cml::$nowTime); } else { $file = Config::get("static__path", Cml::getContainer()->make('cml_route')->getSubDirName() . "public/") . $resource; $isDir || ($file .= (Config::get("url_model") == 3 ? "&v=" : "?v=") . Config::get('static_file_version')); } echo $file; }
/** *输出分页 */ public function show() { if ($this->totalRows == 0) { return ''; } $nowCoolPage = ceil($this->nowPage / $this->barShowPage); $delimiter = Config::get('url_pathinfo_depr'); $params = array_merge($this->param, [$this->pageShowVarName => '__PAGE__']); $paramsString = ''; foreach ($params as $key => $val) { $paramsString == '' || ($paramsString .= '/'); $paramsString .= $key . '/' . $val; } if ($this->url) { $url = rtrim(Response::url($this->url . '/' . $paramsString, false), $delimiter); } else { $url = rtrim(Response::url(Cml::getContainer()->make('cml_route')->getFullPathNotContainSubDir() . '/' . $paramsString, false), $delimiter); } $upRow = $this->nowPage - 1; $downRow = $this->nowPage + 1; $upPage = $upRow > 0 ? '<li><a href = "' . str_replace('__PAGE__', $upRow, $url) . '">' . $this->config['prev'] . '</a></li>' : ''; $downPage = $downRow <= $this->totalPages ? '<li><a href="' . str_replace('__PAGE__', $downRow, $url) . '">' . $this->config['next'] . '</a></li>' : ''; // << < > >> if ($nowCoolPage == 1) { $theFirst = $prePage = ''; } else { $preRow = $this->nowPage - $this->barShowPage; $prePage = '<li><a href="' . str_replace('__PAGE__', $preRow, $url) . '">上' . $this->barShowPage . '页</a></li>'; $theFirst = '<li><a href="' . str_replace('__PAGE__', 1, $url) . '">' . $this->config['first'] . '</a></li>'; } if ($nowCoolPage == $this->coolPages) { $nextPage = $theEnd = ''; } else { $nextRow = $this->nowPage + $this->barShowPage; $theEndRow = $this->totalPages; $nextPage = '<li><a href="' . str_replace('__PAGE__', $nextRow, $url) . '">下' . $this->barShowPage . '页</a></li>'; $theEnd = '<li><a href="' . str_replace('__PAGE__', $theEndRow, $url) . '">' . $this->config['last'] . '</a></li>'; } //1 2 3 4 5 $linkPage = ''; for ($i = 1; $i <= $this->barShowPage; $i++) { $page = ($nowCoolPage - 1) * $this->barShowPage + $i; if ($page != $this->nowPage) { if ($page <= $this->totalPages) { $linkPage .= ' <li><a href="' . str_replace('__PAGE__', $page, $url) . '"> ' . $page . ' </a></li>'; } else { break; } } else { if ($this->totalPages != 1) { $linkPage .= ' <li class="active"><a>' . $page . '</a></li>'; } } } $pageStr = str_replace(['%header%', '%nowPage%', '%totalRow%', '%totalPage%', '%upPage%', '%downPage%', '%first%', '%prePage%', '%linkPage%', '%nextPage%', '%end%'], [$this->config['header'], $this->nowPage, $this->totalRows, $this->totalPages, $upPage, $downPage, $theFirst, $prePage, $linkPage, $nextPage, $theEnd], $this->config['theme']); return '<ul>' . $pageStr . '</ul>'; }