protected function initRoute($routeInfo, $matches, $queryString = '', $anchor = '') { parent::initRoute($routeInfo, $matches, $queryString, $anchor); // if we don't have a numeric userid at this point, make it 0 $this->arguments['userid'] = isset($this->arguments['userid']) ? intval($this->arguments['userid']) : 0; //there are lots of places we can get the username from if we don't have it, check them. if (!empty($this->arguments['userid']) and empty($this->arguments['username'])) { //node records provide both the username and the userid but under a different value. We generate profile links for node //display frequently and we'd like to avoid an extra database trip if (!empty($matches['authorname'])) { $this->arguments['username'] = $matches['authorname']; } else { //a lot of our profile links are for the current user -- who's information we have cached. $currentuser = vB::getCurrentSession()->fetch_userinfo(); if ($this->arguments['userid'] == $currentuser['userid']) { $this->arguments['username'] = $currentuser['username']; } else { $user = vB_User::fetchUserinfo($this->arguments['userid']); $this->arguments['username'] = $user['username']; } } } }
protected function initRoute($routeInfo, $matches, $queryString = '', $anchor = '') { parent::initRoute($routeInfo, $matches, $queryString, $anchor); // add querystring parameters for permalink (similar to vB5_Route_PrivateMessage constructor) if (isset($matches['innerPost']) and $innerPost = intval($matches['innerPost'])) { // TODO: make $innerPost a route argument in route record? if ($innerPost != $this->arguments['nodeid']) { // it's not the starter, either a reply or a comment $this->queryParameters['p'] = intval($matches['innerPost']); if (isset($matches['innerPostParent']) and $innerPostParent = intval($matches['innerPostParent']) and $this->arguments['nodeid'] != $innerPostParent) { // it's a comment $this->queryParameters['pp'] = $innerPostParent; } } } // If the parent's initRoute didn't find a pagenum or contentpagenum, the route's arguments will just get the strings // '$pagenum' or '$contentpagenum'. // Let's set default values for pagenum and contentpagenum to be 1 if they didn't have an integer value. // Note that the isset on pagenum probably isn't necessary, since most* conversation routes will probably have it set. // (*Some older custom URLs may lack the pagenum in the regex) // contentpagenum, however, was added recently (mainly for articles) and some older routes may lack them. If we start // using it for conversations, we should add an upgrade step to refresh all old conversation routes, and/or put an else // block to define some default value for when it just lacks the contentpagenum argument. if (isset($this->arguments['pagenum'])) { $this->arguments['pagenum'] = intval($this->arguments['pagenum']) > 0 ? intval($this->arguments['pagenum']) : 1; } if (isset($this->arguments['contentpagenum'])) { $this->arguments['contentpagenum'] = intval($this->arguments['contentpagenum']) > 0 ? intval($this->arguments['contentpagenum']) : 1; } }