Ejemplo n.º 1
0
 /**
  * Creates an image from an existing file.
  *
  * @param string $fileName
  * @param integer $inputType IMAGETYPE_XYZ constant representing image type
  *
  * @return XenForo_Image_Gd|false
  */
 public static function createFromFileDirect($fileName, $inputType)
 {
     $invalidType = false;
     try {
         switch ($inputType) {
             case IMAGETYPE_GIF:
                 if (!function_exists('imagecreatefromgif')) {
                     return false;
                 }
                 $image = imagecreatefromgif($fileName);
                 break;
             case IMAGETYPE_JPEG:
                 if (!function_exists('imagecreatefromjpeg')) {
                     return false;
                 }
                 $image = imagecreatefromjpeg($fileName);
                 break;
             case IMAGETYPE_PNG:
                 if (!function_exists('imagecreatefrompng')) {
                     return false;
                 }
                 $image = imagecreatefrompng($fileName);
                 break;
             default:
                 $invalidType = true;
         }
     } catch (Exception $e) {
         return false;
     }
     if ($invalidType) {
         throw new XenForo_Exception('Invalid image type given. Expects IMAGETYPE_XXX constant.');
     }
     $class = XenForo_Application::resolveDynamicClass(__CLASS__);
     return new $class($image);
 }
Ejemplo n.º 2
0
 /**
  * Single-stage logout procedure
  */
 public function actionIndex()
 {
     $csrfToken = $this->_input->filterSingle('_xfToken', XenForo_Input::STRING);
     $redirectResponse = $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(false, false));
     $userId = XenForo_Visitor::getUserId();
     if (!$userId) {
         return $redirectResponse;
     }
     if ($this->_noRedirect() || !$csrfToken) {
         // request is likely from JSON, probably XenForo.OverlayTrigger, so show a confirmation dialog
         return $this->responseView('XenForo_ViewPublic_LogOut', 'log_out');
     } else {
         $this->_checkCsrfFromToken($csrfToken);
         // remove an admin session if we're logged in as the same person
         if (XenForo_Visitor::getInstance()->get('is_admin')) {
             $class = XenForo_Application::resolveDynamicClass('XenForo_Session');
             $adminSession = new $class(array('admin' => true));
             $adminSession->start();
             if ($adminSession->get('user_id') == $userId) {
                 $adminSession->delete();
             }
         }
         $this->getModelFromCache('XenForo_Model_Session')->processLastActivityUpdateForLogOut(XenForo_Visitor::getUserId());
         XenForo_Application::get('session')->delete();
         XenForo_Helper_Cookie::deleteAllCookies($this->_getRetainedCookies(), array('user' => array('httpOnly' => false)));
         XenForo_Visitor::setup(0);
         return $redirectResponse;
     }
 }
Ejemplo n.º 3
0
 public function actionErrorNotFound()
 {
     $controllerName = $this->_request->getParam('_controllerName');
     $action = $this->_request->getParam('_action');
     if (substr($action, 0, 3) === 'Get') {
         // try to suggest POST entry point if available
         $newControllerName = XenForo_Application::resolveDynamicClass($controllerName, 'controller');
         if (method_exists($newControllerName, 'actionPost' . substr($action, 3))) {
             return $this->responseError(new XenForo_Phrase('bdapi_only_accepts_post_requests'), 400);
         }
     }
     if (is_callable(array($this, 'getNotFoundResponse'))) {
         // XenForo 1.2.0+ has this
         return $this->getNotFoundResponse();
     }
     if (XenForo_Application::debugMode()) {
         $controllerName = $this->_request->getParam('_controllerName');
         if (empty($controllerName)) {
             return $this->responseError(new XenForo_Phrase('controller_for_route_not_found', array('routePath' => $this->_request->getParam('_origRoutePath'))), 404);
         } else {
             return $this->responseError(new XenForo_Phrase('controller_x_does_not_define_action_y', array('controller' => $controllerName, 'action' => $this->_request->getParam('_action'))), 404);
         }
     } else {
         return $this->responseError(new XenForo_Phrase('requested_page_not_found'), 404);
     }
 }
Ejemplo n.º 4
0
 public function actionTest()
 {
     $this->assertAdminPermission('user');
     $this->_routeMatch->setSections('testPermissions');
     $class = XenForo_Application::resolveDynamicClass('XenForo_Session');
     $publicSession = new $class();
     $publicSession->start();
     if ($publicSession->get('user_id') != XenForo_Visitor::getUserId()) {
         return $this->responseError(new XenForo_Phrase('please_login_via_public_login_page_before_testing_permissions'));
     }
     if ($this->_request->isPost()) {
         $username = $this->_input->filterSingle('username', XenForo_Input::STRING);
         /* @var $userModel XenForo_Model_User */
         $userModel = $this->getModelFromCache('XenForo_Model_User');
         $user = $userModel->getUserByName($username);
         if (!$user) {
             return $this->responseError(new XenForo_Phrase('requested_user_not_found'), 404);
         }
         $publicSession->set('permissionTest', array('user_id' => $user['user_id'], 'username' => $user['username']));
         $publicSession->save();
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('index'));
     } else {
         return $this->responseView('XenForo_ViewAdmin_Permission_Test', 'permission_test');
     }
 }
Ejemplo n.º 5
0
 /**
  *
  * @see XenForo_Route_Prefix_Forums::buildLink()
  */
 public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
 {
     if (isset($data['social_forum_id'])) {
         if (ThemeHouse_SocialGroups_SocialForum::hasInstance()) {
             $socialForum = ThemeHouse_SocialGroups_SocialForum::getInstance()->toArray();
         } else {
             $socialForum = $data;
         }
         $class = XenForo_Application::resolveDynamicClass('ThemeHouse_SocialGroups_Route_Prefix_SocialForums', 'route_prefix');
         $router = new $class();
         $link = $router->buildLink('social-forums', 'social-forums', $action, $extension, $socialForum, $extraParams);
         if (XenForo_Application::isRegistered('routeFiltersOut')) {
             $routeFilters = XenForo_Application::get('routeFiltersOut');
             if (isset($routeFilters['social-forums'])) {
                 foreach ($routeFilters['social-forums'] as $filter) {
                     if (array_key_exists('find_route', $filter) && array_key_exists('replace_route', $filter)) {
                         list($from, $to) = XenForo_Link::translateRouteFilterToRegex($filter['find_route'], $filter['replace_route']);
                         $newLink = preg_replace($from, $to, $link);
                     } else {
                         $newLink = $link;
                     }
                     if ($newLink != $link) {
                         $link = $newLink;
                         break;
                     }
                 }
             }
         }
         return $link;
     }
     return parent::buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, $extraParams);
 }
Ejemplo n.º 6
0
 /**
  * Factory method to get the named container params listener.
  * The class must exist or be autoloadable or an exception will be thrown.
  *
  * @param string Class to load
  * @param array $params
  * @param XenForo_Dependencies_Abstract $dependencies
  *
  * @return ThemeHouse_Listener_ContainerPublicParams
  */
 public static function create($class, array &$params, XenForo_Dependencies_Abstract $dependencies)
 {
     $createClass = XenForo_Application::resolveDynamicClass($class, 'listener_th');
     if (!$createClass) {
         throw new XenForo_Exception("Invalid listener '{$class}' specified");
     }
     return new $createClass($params, $dependencies);
 }
Ejemplo n.º 7
0
 /**
  * Factory method to get the named navigation tabs listener.
  * The class must exist or be autoloadable or an exception will be thrown.
  *
  * @param string $className Class to load
  * @param array $extraTabs
  * @param $selectedTabId
  *
  * @return ThemeHouse_Listener_NavigationTabs
  */
 public static function create($className, array &$extraTabs, $selectedTabId)
 {
     $createClass = XenForo_Application::resolveDynamicClass($className, 'listener_th');
     if (!$createClass) {
         throw new XenForo_Exception("Invalid listener '{$className}' specified");
     }
     return new $createClass($extraTabs, $selectedTabId);
 }
Ejemplo n.º 8
0
 /**
  * @return bdApi_Template_Helper_Core
  */
 public static function getInstance()
 {
     if (self::$_instance === null) {
         $templateHelperClass = XenForo_Application::resolveDynamicClass(__CLASS__, 'bdapi_template_helper');
         self::$_instance = new $templateHelperClass();
     }
     return self::$_instance;
 }
 /**
  * @return XenForo_Helper_UserChangeLog
  */
 protected function _getHelper()
 {
     if ($this->_helperObject === null) {
         $class = XenForo_Application::resolveDynamicClass('XenForo_Helper_UserChangeLog');
         $this->_helperObject = new $class();
     }
     return $this->_helperObject;
 }
Ejemplo n.º 10
0
 public static function create($class)
 {
     $class = XenForo_Application::resolveDynamicClass($class);
     $object = new $class();
     if (!$object instanceof XenGallery_Thumbnail_Abstract) {
         return false;
     }
     return $object;
 }
Ejemplo n.º 11
0
 /**
  * Need to put this method in the abstract class unfortunately because PHP 5.2 doesn't support late static binding
  */
 protected static function _resolveClass()
 {
     if (class_exists('XenForo_Application')) {
         $class = XenForo_Application::resolveDynamicClass('DigitalPointBetterAnalytics_Helper_Reporting');
         self::$_instance = new $class();
     } else {
         self::$_instance = new DigitalPointBetterAnalytics_Helper_Reporting();
     }
 }
Ejemplo n.º 12
0
 /**
  * Match a specific route for an already matched prefix.
  *
  * @see XenForo_Route_Interface::match()
  */
 public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
 {
     $action = $router->resolveActionWithIntegerParam($routePath, $request, 'node_id');
     if (!class_exists('XFCP_ThemeHouse_SocialGroups_ControllerAdmin_SocialCategory', false)) {
         $createClass = XenForo_Application::resolveDynamicClass('XenForo_ControllerAdmin_Forum', 'controller');
         eval('class XFCP_ThemeHouse_SocialGroups_ControllerAdmin_SocialCategory extends ' . $createClass . ' {}');
     }
     return $router->getRouteMatch('ThemeHouse_SocialGroups_ControllerAdmin_SocialCategory', $action, 'nodeTree');
 }
Ejemplo n.º 13
0
 /**
  * Gets the specified importer.
  *
  * @param string $key Name of importer (key); just last part of name, not full path.
  *
  * @return XenForo_Importer_Abstract
  */
 public function getImporter($key)
 {
     if (strpos($key, '_') && !in_array($key, self::$extraImporters)) {
         throw new XenForo_Exception('Trying to load a non-registered importer.');
     }
     $class = strpos($key, '_') ? $key : 'XenForo_Importer_' . $key;
     $createClass = XenForo_Application::resolveDynamicClass($class, 'importer');
     return new $createClass();
 }
Ejemplo n.º 14
0
 public function actionLogin()
 {
     if (!$this->_request->isPost()) {
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL, XenForo_Link::buildAdminLink('index'));
     }
     $data = $this->_input->filter(array('login' => XenForo_Input::STRING, 'password' => XenForo_Input::STRING, 'redirect' => XenForo_Input::STRING, 'cookie_check' => XenForo_Input::UINT));
     $redirect = $data['redirect'] ? $data['redirect'] : XenForo_Link::buildAdminLink('index');
     $loginModel = $this->_getLoginModel();
     if ($data['cookie_check'] && count($_COOKIE) == 0) {
         // login came from a page, so we should at least have a session cookie.
         // if we don't, assume that cookies are disabled
         return $this->responseError(new XenForo_Phrase('cookies_required_to_log_in_to_site'));
     }
     $needCaptcha = $loginModel->requireLoginCaptcha($data['login']);
     if ($needCaptcha) {
         // just block logins here instead of using the captcha
         return $this->responseError(new XenForo_Phrase('your_account_has_temporarily_been_locked_due_to_failed_login_attempts'));
     }
     $userModel = $this->_getUserModel();
     $userId = $userModel->validateAuthentication($data['login'], $data['password'], $error);
     if (!$userId) {
         $loginModel->logLoginAttempt($data['login']);
         if ($loginModel->requireLoginCaptcha($data['login'])) {
             return $this->responseError(new XenForo_Phrase('your_account_has_temporarily_been_locked_due_to_failed_login_attempts'));
         }
         if ($this->_input->filterSingle('upgrade', XenForo_Input::UINT)) {
             return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $redirect);
         } else {
             // note - JSON view will return responseError($text)
             return $this->responseView('XenForo_ViewAdmin_Login_Error', 'login_form', array('text' => $error, 'defaultLogin' => $data['login'], 'redirect' => $redirect), array('containerTemplate' => 'LOGIN_PAGE'));
         }
     }
     $loginModel->clearLoginAttempts($data['login']);
     XenForo_Model_Ip::log($userId, 'user', $userId, 'login_admin');
     $visitor = XenForo_Visitor::setup($userId);
     XenForo_Application::getSession()->userLogin($userId, $visitor['password_date']);
     // if guest on front-end, login there too
     $class = XenForo_Application::resolveDynamicClass('XenForo_Session');
     $publicSession = new $class();
     $publicSession->start();
     if (!$publicSession->get('user_id')) {
         $publicSession->userLogin($userId, $visitor['password_date']);
         $publicSession->save();
     }
     // now check that the user will be able to get into the ACP (is_admin)
     if (!$visitor->is_admin) {
         return $this->responseError(new XenForo_Phrase('your_account_does_not_have_admin_privileges'));
     }
     if ($this->_input->filterSingle('repost', XenForo_Input::UINT)) {
         $postVars = $this->_input->filterSingle('postVars', XenForo_Input::JSON_ARRAY);
         $postVars['_xfToken'] = $visitor['csrf_token_page'];
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $redirect, '', array('repost' => 1, 'postVars' => $postVars));
     } else {
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $redirect);
     }
 }
Ejemplo n.º 15
0
 /**
  * Match a specific route for an already matched prefix.
  *
  * @see XenForo_Route_Interface::match()
  */
 public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
 {
     $action = $router->resolveActionWithIntegerOrStringParam($routePath, $request, 'social_forum_id', 'url_portion');
     $action = $router->resolveActionAsPageNumber($action, $request);
     if (!class_exists('XFCP_ThemeHouse_SocialGroups_ControllerPublic_SocialForum', false)) {
         $createClass = XenForo_Application::resolveDynamicClass('XenForo_ControllerPublic_Forum', 'controller');
         eval('class XFCP_ThemeHouse_SocialGroups_ControllerPublic_SocialForum extends ' . $createClass . ' {}');
     }
     return $router->getRouteMatch('ThemeHouse_SocialGroups_ControllerPublic_SocialForum', $action, 'forums');
 }
Ejemplo n.º 16
0
 /**
  * Loads the specified sub-rule and then tries to match it.
  *
  * @param string Route class name
  * @param string Route path to pass to match
  * @param Zend_Controller_Request_Http
  * @param XenForo_Router
  *
  * @return XenForo_RouteMatch|false
  */
 protected function _loadAndRunSubRule($routeClass, $newRoutePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
 {
     if (XenForo_Application::autoload($routeClass)) {
         $routeClass = XenForo_Application::resolveDynamicClass($routeClass, 'route_prefix');
         $route = new $routeClass();
         return $route->match($newRoutePath, $request, $router);
     } else {
         return false;
     }
 }
Ejemplo n.º 17
0
 /**
  * @param string $providerId
  *
  * @return XenForo_Tfa_AbstractProvider|null
  */
 public function getValidProvider($providerId)
 {
     $class = $this->_getDb()->fetchOne("\n\t\t\tSELECT provider_class\n\t\t\tFROM xf_tfa_provider\n\t\t\tWHERE provider_id = ?\n\t\t\t\tAND active = 1\n\t\t", $providerId);
     if ($class && class_exists($class)) {
         $class = XenForo_Application::resolveDynamicClass($class);
         return new $class($providerId);
     } else {
         return null;
     }
 }
Ejemplo n.º 18
0
 /**
  * Factory method to get the named news feed handler. The class must exist and be autoloadable
  * or an exception will be thrown.
  *
  * @param string Class to load
  *
  * @return XenForo_NewsFeedHandler_Abstract
  */
 public static function create($class)
 {
     if (XenForo_Application::autoload($class)) {
         $class = XenForo_Application::resolveDynamicClass($class);
         $obj = new $class();
         if ($obj instanceof XenForo_NewsFeedHandler_Abstract) {
             return $obj;
         }
     }
     throw new XenForo_Exception("Invalid news feed handler '{$class}' specified");
 }
Ejemplo n.º 19
0
 /**
  * factory method to get the content itemhandler
  * @param $class
  * @return SimplePortal_ItemHandler_Abstract
  * @throws XenForo_Exception
  */
 public static function create($class)
 {
     $classResolved = XenForo_Application::resolveDynamicClass($class);
     if (XenForo_Application::autoload($classResolved)) {
         $obj = new $classResolved();
         if ($obj instanceof SimplePortal_ItemHandler_Abstract) {
             return $obj;
         }
     }
     throw new XenForo_Exception("Invalid extraportal_handler '{$class}' specified");
 }
Ejemplo n.º 20
0
 /**
  * Factory method to get the named tab handler.
  * The class must exist and be autoloadable or an exception will be thrown.
  *
  * @param string Class to load
  *
  * @return Waindigo_Tabs_TabHandler_Abstract
  */
 public static function create($class)
 {
     $createClass = XenForo_Application::resolveDynamicClass($class, 'tab_handler');
     if ($createClass) {
         $obj = new $createClass();
         if ($obj instanceof Waindigo_Tabs_TabHandler_Abstract) {
             return $obj;
         }
     }
     throw new XenForo_Exception("Invalid tab handler '{$class}' specified");
 }
Ejemplo n.º 21
0
 /**
  * Gets the single instance of class.
  *
  * @return DigitalPointBetterAnalytics_Helper_Reporting
  */
 public static final function getInstance()
 {
     if (!self::$_instance) {
         $class = XenForo_Application::resolveDynamicClass('DigitalPointBetterAnalytics_Helper_Reporting');
         self::$_instance = new $class();
         if (self::canUseCurlMulti()) {
             self::$_curlMultiHandle = curl_multi_init();
         }
     }
     return self::$_instance;
 }
Ejemplo n.º 22
0
 /**
  * Setup the session.
  *
  * @param string $action
  */
 protected function _setupSession($action)
 {
     if (XenForo_Application::isRegistered('session')) {
         return;
     }
     $class = XenForo_Application::resolveDynamicClass('XenForo_Session');
     $session = new $class(array('admin' => true));
     XenForo_Application::set('session', $session);
     $session->start();
     XenForo_Visitor::setup($session->get('user_id'));
 }
Ejemplo n.º 23
0
 /**
  * @param string $class
  *
  * @return XenForo_Deferred_Abstract|bool
  */
 public static function create($class)
 {
     if (strpos($class, '_') === false) {
         $class = 'XenForo_Deferred_' . $class;
     }
     $class = XenForo_Application::resolveDynamicClass($class);
     $object = new $class();
     if (!$object instanceof XenForo_Deferred_Abstract) {
         return false;
     }
     return $object;
 }
Ejemplo n.º 24
0
 /**
  *
  * @see XenForo_Model_Session::addSessionActivityDetailsToList()
  */
 public function addSessionActivityDetailsToList(array $activities)
 {
     foreach ($activities as $key => $activity) {
         if ($activity['controller_name'] == 'ThemeHouse_SocialGroups_ControllerPublic_SocialForum') {
             if (!class_exists('XFCP_ThemeHouse_SocialGroups_ControllerPublic_SocialForum', false)) {
                 $createClass = XenForo_Application::resolveDynamicClass('XenForo_ControllerPublic_Forum', 'controller');
                 eval('class XFCP_ThemeHouse_SocialGroups_ControllerPublic_SocialForum extends ' . $createClass . ' {}');
                 break;
             }
         }
     }
     return parent::addSessionActivityDetailsToList($activities);
 }
Ejemplo n.º 25
0
 /**
  * Gets all reflection handler classes.
  *
  * @return array [content type] =>
  * ThemeHouse_Reflection_ReflectionHandler_Abstract
  */
 public function getReflectionHandlers()
 {
     $classes = $this->getContentTypesWithField('reflection_handler_class');
     $handlers = array();
     foreach ($classes as $contentType => $class) {
         if (!class_exists($class)) {
             continue;
         }
         $class = XenForo_Application::resolveDynamicClass($class);
         $handlers[$contentType] = new $class();
     }
     return $handlers;
 }
Ejemplo n.º 26
0
 protected function _getExternalExtendedHelper($class)
 {
     if (strpos($class, '_') === false) {
         $class = 'ExternalExtended_Helper_' . $class;
     }
     $class = XenForo_Application::resolveDynamicClass($class);
     // create a dummy controller
     $request = new Zend_Controller_Request_Http();
     $response = new Zend_Controller_Response_Http();
     $routeMatch = new XenForo_RouteMatch();
     $controller = new XenForo_ControllerAdmin_Tools($request, $response, $routeMatch);
     return new $class($controller);
 }
Ejemplo n.º 27
0
 public static function runImport()
 {
     $db = self::_getDb();
     $sql = "SELECT * FROM geek_listings_importers WHERE importer_status=1 AND importer_last_run + importer_interval < " . XenForo_Application::$time;
     //$sql = "SELECT * FROM geek_listings_importers WHERE importer_status=1";
     $results = $db->fetchAll($sql);
     foreach ($results as $row) {
         XenForo_Application::resolveDynamicClass($row['importer_class']);
         $job = new $row['importer_class']();
         $job->setup($row);
         $job->run();
     }
 }
Ejemplo n.º 28
0
 /**
  * @param XenForo_View $view View object
  * @param string $fieldPrefix Prefix for the HTML form field name
  * @param array $preparedOption Prepared option info
  * @param boolean $canEdit True if an "edit" link should appear
  *
  * @return XenForo_Template_Abstract Template object
  */
 public static function renderCheckbox(XenForo_View $view, $fieldPrefix, array $preparedOption, $canEdit)
 {
     /** @var XenForo_Model_Sitemap $sitemapModel */
     $sitemapModel = XenForo_Model::create('XenForo_Model_Sitemap');
     $types = $sitemapModel->getSitemapContentTypes(true);
     unset($types['core']);
     // always enabled
     $preparedOption['formatParams'] = array();
     foreach ($types as $type => $handlerClass) {
         $handlerClass = XenForo_Application::resolveDynamicClass($handlerClass);
         $handler = new $handlerClass();
         $preparedOption['formatParams'][] = array('name' => "{$fieldPrefix}[{$preparedOption['option_id']}][{$type}]", 'label' => new XenForo_Phrase($handler->getPhraseKey($type)), 'selected' => empty($preparedOption['option_value'][$type]));
     }
     return XenForo_ViewAdmin_Helper_Option::renderOptionTemplateInternal('option_list_option_checkbox', $view, $fieldPrefix, $preparedOption, $canEdit);
 }
Ejemplo n.º 29
0
 public static function renderFromHtml($html, array $options = array())
 {
     //echo $html; exit;
     //echo '<pre>' . htmlspecialchars($html) . '</pre>'; exit;
     $class = XenForo_Application::resolveDynamicClass(__CLASS__);
     /** @var $renderer XenForo_Html_Renderer_BbCode */
     $renderer = new $class($options);
     $html = $renderer->preFilter($html);
     $parser = new XenForo_Html_Parser($html);
     $parsed = $parser->parse();
     //$parser->printTags($parsed);
     $rendered = $renderer->render($parsed);
     //echo '<pre>' . htmlspecialchars($rendered) . '</pre>'; exit;
     return $rendered;
 }
Ejemplo n.º 30
0
 public function execute(array $deferred, array $data, $targetRunTime, &$status)
 {
     $data = array_merge(array('content_types' => null, 'current_type' => null, 'last_id' => 0, 'set_id' => null, 'file_counter' => 1, 'file_length' => 0, 'file_entry_count' => 0, 'total_entry_count' => 0, 'finalize_file' => 1), $data);
     /** @var XenForo_Model_Sitemap $siteMapModel */
     $siteMapModel = XenForo_Model::create('XenForo_Model_Sitemap');
     $this->_sitemapModel = $siteMapModel;
     // workaround IDE completion quirk
     $allContentTypes = $this->_sitemapModel->getSitemapContentTypes();
     $this->_contentTypes = $data['content_types'];
     if (!is_array($this->_contentTypes)) {
         $this->_contentTypes = array_keys($allContentTypes);
     }
     $this->_fileCounter = $data['file_counter'];
     $this->_fileLength = $data['file_length'];
     $this->_fileEntryCount = $data['file_entry_count'];
     $this->_totalEntryCount = $data['total_entry_count'];
     $this->_setId = $data['set_id'];
     if (!$this->_setId) {
         $this->_setId = XenForo_Application::$time;
     }
     $contentType = $this->_getContentType($data['current_type'], $allContentTypes);
     if (!$contentType) {
         $finalizeFile = $this->_finalizeSitemap($data['finalize_file'], $targetRunTime);
         if ($finalizeFile === false) {
             return false;
         }
         $data['finalize_file'] = $finalizeFile;
         $actionPhrase = new XenForo_Phrase('rebuilding');
         $typePhrase = new XenForo_Phrase(new XenForo_Phrase('sitemap'));
         $text = new XenForo_Phrase(new XenForo_Phrase('finalizing'));
         $status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, "{$text} {$data['finalize_file']}");
         $newLast = $data['last_id'];
     } else {
         if ($contentType != $data['current_type']) {
             $data['last_id'] = 0;
         }
         $handlerClass = XenForo_Application::resolveDynamicClass($allContentTypes[$contentType]);
         $handler = new $handlerClass();
         $newLast = $this->_buildSitemap($handler, $data['last_id'], $targetRunTime);
         $this->_sitemapModel->insertPendingSitemap($this->_setId, $this->_fileCounter, $this->_totalEntryCount);
         $actionPhrase = new XenForo_Phrase('rebuilding');
         $typePhrase = new XenForo_Phrase(new XenForo_Phrase('sitemap'));
         $text = new XenForo_Phrase($handler->getPhraseKey($contentType));
         $status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, "{$text} {$data['last_id']}");
     }
     return array('content_types' => $this->_contentTypes, 'current_type' => $newLast ? $contentType : null, 'last_id' => $newLast, 'set_id' => $this->_setId, 'file_counter' => $this->_fileCounter, 'file_length' => $this->_fileLength, 'file_entry_count' => $this->_fileEntryCount, 'total_entry_count' => $this->_totalEntryCount, 'finalize_file' => $data['finalize_file']);
 }