public function collectStats()
    {
        Container::get('hooks')->fire('model.index.collect_stats_start');

        // Collect some statistics from the database
        if (!Container::get('cache')->isCached('users_info')) {
            Container::get('cache')->store('users_info', Cache::getUsersInfo());
        }

        $stats = Container::get('cache')->retrieve('users_info');

        $query = DB::forTable('forums')
            ->select_expr('SUM(num_topics)', 'total_topics')
            ->select_expr('SUM(num_posts)', 'total_posts');

        $query = Container::get('hooks')->fireDB('model.index.collect_stats_query', $query);

        $query = $query->find_one();

        $stats['total_topics'] = Utils::numberFormat((int)$query['total_topics']);
        $stats['total_posts'] = Utils::numberFormat((int)$query['total_posts']);

        if (User::get()->g_view_users == '1') {
            $stats['newest_user'] = '<a href="'.
                Router::pathFor('userProfile', ['id' => $stats['last_user']['id']]).'">'.
                Utils::escape($stats['last_user']['username']).'</a>';
        } else {
            $stats['newest_user'] = Utils::escape($stats['last_user']['username']);
        }
        $stats['total_users'] = Utils::numberFormat((int)$stats['total_users']);

        $stats = Container::get('hooks')->fire('model.index.collect_stats', $stats);

        return $stats;
    }
public function collectStats()
    {
        Container::get('hooks')->fire('model.index.collect_stats_start');

        // Collect some statistics from the database
        if (!Container::get('cache')->isCached('users_info')) {
            Container::get('cache')->store('users_info', Cache::getUsersInfo());
        }

        $stats = Container::get('cache')->retrieve('users_info');

        $query = DB::forTable('forums')
            ->select_expr('SUM(num_topics)', 'total_topics')
            ->select_expr('SUM(num_posts)', 'total_posts');

        $query = Container::get('hooks')->fireDB('model.index.collect_stats_query', $query);

        $query = $query->find_one();

        $stats['total_topics'] = Utils::numberFormat((int)$query['total_topics']);
        $stats['total_posts'] = Utils::numberFormat((int)$query['total_posts']);

        if (User::get()->g_view_users == '1') {
            $stats['newest_user'] = '<a href="'.
                Router::pathFor('userProfile', ['id' => $stats['last_user']['id']]).'">'.
                Utils::escape($stats['last_user']['username']).'</a>';
        } else {
            $stats['newest_user'] = Utils::escape($stats['last_user']['username']);
        }
        $stats['total_users'] = Utils::numberFormat((int)$stats['total_users']);

        $stats = Container::get('hooks')->fire('model.index.collect_stats', $stats);

        return $stats;
    }
public function collectStats ( ) { Container :: get ( 'hooks' ) -> fire ( 'model.index.collect_stats_start' ) ; // Collect some statistics from the database if ( ! Container :: get ( 'cache' ) -> isCached ( 'users_info' ) ) { Container :: get ( 'cache' ) -> store ( 'users_info' , Cache :: getUsersInfo ( ) ) ; } $ stats = Container :: get ( 'cache' ) -> retrieve ( 'users_info' ) ; $ query = DB :: forTable ( 'forums' ) -> select_expr ( 'SUM(num_topics)' , 'total_topics' ) -> select_expr ( 'SUM(num_posts)' , 'total_posts' ) ; $ query = Container :: get ( 'hooks' ) -> fireDB ( 'model.index.collect_stats_query' , $ query ) ; $ query = $ query -> find_one ( ) ; $ stats [ 'total_topics' ] = Utils :: numberFormat ( ( int ) $ query [ 'total_topics' ] ) ; $ stats [ 'total_posts' ] = Utils :: numberFormat ( ( int ) $ query [ 'total_posts' ] ) ; if ( User :: get ( ) -> g_view_users == '1' ) { $ stats [ 'newest_user' ] = '<a href="' . Router :: pathFor ( 'userProfile' , [ 'id' => $ stats [ 'last_user' ] [ 'id' ] ] ) . '">' . Utils :: escape ( $ stats [ 'last_user' ] [ 'username' ] ) . '</a>' ; } else { $ stats [ 'newest_user' ] = Utils :: escape ( $ stats [ 'last_user' ] [ 'username' ] ) ; } $ stats [ 'total_users' ] = Utils :: numberFormat ( ( int ) $ stats [ 'total_users' ] ) ; $ stats = Container :: get ( 'hooks' ) -> fire ( 'model.index.collect_stats' , $ stats ) ; return $ stats ; }
Returns the elements needed to display stats
Returns the elements needed to display stats