Ejemplo n.º 1
0
 /**
  * Get information for a page
  * @param int $pageid
  * @param array $routeData -- The needed to render this pages route.  Will vary by page
  *
  * @return array
  *  	pageid int
  * 		parentid int -- the parent page (currently unused)
  *    pagetemplateid int
  *    title string
  *    metadescription string -- the metadescription to display when page is rendered as html
  *    routeid int -- route associated with this page
  *    moderatorid int -- need to determine
  *    displayorder int -- the order to display page when displaying lists of pages
  * 		pagetype string -- default or custom depending of if this is a page we install with the system
  *		product string -- product the page belongs to 'vbulletin' for pages created by the system and via the admincp
  *		guid string -- globally unique identifier
  *		screenlayoutid int -- layout for the page
  * 		screenlayouttemplate string -- name of the layout template
  *		templatetitle string -- need to determine
  *		ishomepage boolean -- is this the homepage
  * 		makehomepagecheckattr string -- DEPRECATED 'checked=checked' if this is the homepage
  * 		isgeneric boolean -- DEPRECATED true if this is of type default
  *		urlprefix string -- prefix for the route
  *		url string -- url generated from the route -- will be relative to the frontend base
  *		urlscheme string -- DEPRECATED -- will be blank
  *		urlhostname string -- DEPRECATED -- will be blank
  *		noindex boolean -- should this page be indexed.
  *		nofollow boolean -- should this page be followed.
  */
 public function fetchPageById($pageid, $routeData = array())
 {
     $pageid = intval($pageid);
     $db = vB::getDbAssertor();
     $conditions = array('pageid' => $pageid);
     //$page = $db->getRow('fetch_page_pagetemplate_screenlayout', $conditions);
     $page = $db->assertQuery('fetch_page_pagetemplate_screenlayout', $conditions);
     $page = $page->current();
     if ($page) {
         // Fetch phrases
         $guidforphrase = vB_Library::instance('phrase')->cleanGuidForPhrase($page['guid']);
         $phrases = vB_Api::instanceInternal('phrase')->fetch(array('page_' . $guidforphrase . '_title', 'page_' . $guidforphrase . '_metadesc'));
         $page['title'] = !empty($phrases['page_' . $guidforphrase . '_title']) ? $phrases['page_' . $guidforphrase . '_title'] : $page['title'];
         $page['metadescription'] = !empty($phrases['page_' . $guidforphrase . '_metadesc']) ? $phrases['page_' . $guidforphrase . '_metadesc'] : $page['metadescription'];
         // check if this is currently the homepage
         $route = vB5_Route::getHomePageRouteInfo();
         if ($route and $route['contentid'] == $page['pageid']) {
             $page['ishomepage'] = true;
             //todo shouldn't use html in the API.
             $page['makehomepagecheckattr'] = ' checked="checked"';
         } else {
             $page['ishomepage'] = false;
             $page['makehomepagecheckattr'] = '';
         }
         $page['isgeneric'] = $page['pagetype'] == vB_Page::TYPE_DEFAULT;
         // get url scheme, hostname and path
         $route = vB5_Route::getRoute(intval($page['routeid']), $routeData);
         if ($route) {
             $page['urlprefix'] = $route->getCanonicalPrefix();
             $page['url'] = $route->getCanonicalUrl();
             $parsed = vB_String::parseUrl($page['url']);
             $page['urlscheme'] = isset($parsed['scheme']) ? $parsed['scheme'] : '';
             $page['urlhostname'] = isset($parsed['host']) ? $parsed['host'] : '';
             $page['urlpath'] = base64_encode($parsed['path']);
             $page['noindex'] = false;
             $page['nofollow'] = false;
             $arguments = $route->getArguments();
             if (!empty($arguments['noindex'])) {
                 $page['noindex'] = $arguments['noindex'];
             }
             if (!empty($arguments['nofollow'])) {
                 $page['nofollow'] = $arguments['nofollow'];
             }
         }
     }
     return $page;
 }