public function index($id = '') { if ($id == '') { View::AdminErrorMessage('goback', '非法入口!Go Die'); } $fields = Request::getRequest('page', 'int'); $page = isset($fields) && $fields > 0 ? $fields : 1; $article = self::$models->Article; $tag = self::$models->Tag; $mem = self::$models->Memcache; $ret = $mem->get('tagController_index_' . $id . '_' . $page); if (empty($ret)) { $ret = array(); $ret['tag'] = $tag->getTagById($id); if (empty($ret['tag'])) { NotFound(); } $ret['tagarticleShow'] = $article->getArticleTagShow($ret['tag']['tag'], $page); $ret['pushArticleList'] = $article->getPushArticleList(); $ret['newArticleList'] = $article->getNewArticleList(); $ret['commentArticleList'] = $article->getCommentArticleList(); $ret['pageNav'] = @array_pop($ret['tagarticleShow']); $mem->set('tagController_index_' . $id . '_' . $page, $ret, 12 * 3600); } View::Transmit('tagshow', $ret); }
public function index($id = '') { if ($id == '') { View::AdminErrorMessage('goback', '木有选择文章哦!'); } $fields = Request::getRequest('page', 'int'); $page = isset($fields) && $fields > 0 ? $fields : 1; $article = self::$models->Article; $comment = self::$models->Comment; $mem = self::$models->Memcache; $ret = $mem->get('articleshowController_index_id_' . $id); if (empty($ret)) { $ret = array(); $ret['articleShow'] = $article->getArticleShow($id); if (empty($ret['articleShow'])) { NotFound(); } $ret['articleShow']['tag'] = explode('|', $ret['articleShow']['tag']); $ret['articleRelevant'] = $article->getArticleRelevant($ret['articleShow']['mid'], $ret['articleShow']['id']); $ret['pushArticleList'] = $article->getPushArticleList(); $ret['newArticleList'] = $article->getNewArticleList(); $ret['commentArticleList'] = $article->getCommentArticleList(); $mem->set('articleshowController_index_id_' . $id, $ret); } $ret['comments'] = $comment->getArticleCommentList($id, $page); if (!empty($ret['comments']['counts'])) { $ret['articleShow']['counts'] = array_pop($ret['comments']); } if (!empty($ret['comments']['page'])) { $ret['articleShow']['commentPage_nav'] = array_pop($ret['comments']); } $article->updatePlus($id, 'clicks'); //文章的点击数+1 View::Transmit('articleshow', $ret); }
public function autoload($className) { $pathArr = explode('\\', $className); $filename = array_pop($pathArr); $dir = implode(DIRECTORY_SEPARATOR, $pathArr); $filename = $dir . '/' . $filename . '.php'; if (file_exists($filename)) { require_once $filename; } else { #exit('Error:'.$className.' loading Failed'); // 调试模式 #echo "Error:".$className." loading Failed <br/>"; // 兼容模式 NotFound(); //运营 } }
public function parse() { $pathInfo = !empty($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : array(); $className = !empty($pathInfo[1]) ? $pathInfo[1] : DEFAULT_CONTROLLER; $methodName = !empty($pathInfo[2]) ? $pathInfo[2] : DEFAULT_METHOD; $c = DEFAULT_APP_NAME . '\\Controller\\' . $className . 'Controller'; //$obj = new $c(); if (!class_exists($c)) { // 跳转到404页面,正式运营用。 NotFound(); } $obj = new $c(new Container()); if (!empty($pathInfo[2]) && is_numeric($pathInfo[2]) && empty($pathInfo[3])) { method_exists($obj, 'index') ? $obj->index($pathInfo[2]) : NotFound(); } if (!empty($pathInfo[3]) && empty($pathInfo[4])) { method_exists($obj, $methodName) ? $obj->{$methodName}($pathInfo[3]) : NotFound(); } else { method_exists($obj, $methodName) ? $obj->{$methodName}() : NotFound(); } }
private function loadPage($i) { if (!isset($this->pages[$i])) { $url = $this->path; if (strpos($this->path, '?') === false) { $url .= '?'; } else { $url .= '&'; } $result = $this->client->get($url . "per_page={$this->per_page}&page={$i}"); if (isset($result['response_data'])) { $this->response_data = $result['response_data']; unset($result['response_data']); $page = array_pop($result); if ($page !== NULL) { $this->pages[$i] = $page; } } } if (!isset($this->pages[$i])) { throw NotFound('The resource you requested is not a collection'); } return $this->pages[$i]; }
function FindDefect($id) { $query = GetDefectQueryUri($id); $searchresult = CallAPI($query); $count = GetCount($searchresult); if ($count == 0) { NotFound($id); } return GetFirstObjectFromSearchResult("Defect", $searchresult); }