source: trunk/home/home_cache_cron.php @ 1820

Revision 1820, 3.8 KB checked in by Xiping.Wang, 21 months ago (diff)

[trunk]merge the code from trunk

Line 
1<?php
2require_once( dirname(__file__) . '/../common/omconfig.php' );
3
4if (defined('OMCOLLAB_CACHE_KEY'))
5{
6        $supplied_key = (isset($_GET['key'])) ? htmlspecialchars($_GET['key']) : '';
7        if ($supplied_key == ''||trim($supplied_key) != trim(OMCOLLAB_CACHE_KEY))
8        {
9                echo 'no permission';
10                exit;
11        }
12}
13
14
15require_once( dirname(__file__) . '/../common/json_service.php' );
16require_once( FS_COMMON_SKIN_DIRECTORY . '/common.php' );
17require_once( FS_COMMON_DIRECTORY.'/utils.php');
18require_once(dirname(__file__) . '/contribution/contributionStatistics.php');
19require_once('includes/config.php');
20require_once ('includes/classes/DB.php' );
21require_once(dirname(__file__) . '/contribution/teamContributionStatistic.php');
22require_once('portlets/PortletsClass.php');
23$oDb          = &newDb( 'wiki',true );
24$bDb          = &newDb( 'blogs',true);
25$mDb          = &newDb( 'bookmarks',true );
26$fDb          = &newDb( 'forum',true );
27$ContributorPortlet = new ContributorPortlet($oDb,$bDb,$mDb,$fDb);
28$SkillPortlet = new SkillPortlet($oDb,$bDb,$mDb,$fDb);
29$CommunityChartPortlet = new CommunityChartPortlet($oDb);
30$ActivityPortlet = new ActivityPortlet($oDb,$bDb,$mDb,$fDb);
31$ArticlePortlet = new ArticlePortlet($oDb);
32$TeamContributionStatistics = new TeamContributionStatistics($oDb);
33/*********  generate top 5 contributio team ******/
34saveCache(TeamContribution,$TeamContributionStatistics->_GetTop5ContributionThisMonth_v2());
35
36/*********  cache featured article     **********/
37saveCache(ArticlePortlet,$ArticlePortlet->getPortlet());
38saveCache(LatestArticlePortlet, $ArticlePortlet->getNewPostedArticlePortlet(3));
39
40/*********       **********/
41saveCache(Notes,$ContributorPortlet->loadNotes());
42
43//community skills ->community skills
44saveCache(SkillChart,$SkillPortlet->loadSkillChart(null));
45saveCache(SkillPortlet, $SkillPortlet->loadSkillPortlet());
46//community chart -> article usage
47saveCache(UserUsage, $CommunityChartPortlet->loadUserUsage('incremental',true));
48//community chart -> article score
49saveCache(UserScores, $CommunityChartPortlet->loadUserScores());
50//recent activity -> site activity\
51saveCache(SiteActivity, $ActivityPortlet->loadSiteActivity(7));             
52
53saveCache(Information, $ContributorPortlet->loadInformation());
54saveCache(ContributorActivity, $ContributorPortlet->loadActivity(10));
55saveCache(ContributorUserScores, $ContributorPortlet->loadUserScores());
56saveCache(SkillsSkill, $ContributorPortlet->loadSkills('skill'));
57saveCache(SkillsRole, $ContributorPortlet->loadSkills('role'));
58saveCache(FeaturedContributor, $ContributorPortlet->loadFeaturedContributor()); // New Featured Contributor Portlet
59saveCache(TopContributors, $ContributorPortlet->getTopContributors()); // Top Contributors Portlet
60
61
62/************** ***************/
63$ContributionStatistics = new ContributionStatistics('', false);
64$ContributionStatistics -> setExistingDBConnection($oDb,$bDb,$mDb,$fDb);
65saveCache(Top10ContributorThisMonth,$ContributionStatistics->_GetTop10ContributionThisMonth());
66
67
68$contributorThisWeek = $ContributorPortlet->getUserName();
69saveCache(ContributionMonthlyLastYear,
70file_get_contents('http://'.$_SERVER['HTTP_HOST'].
71RR_OMCOLLAB_DIRECTORY.'home/contribution/IndividualContributionWidget.php?userName='.
72$contributorThisWeek.'&displayFor=contributorThisWeek'));
73
74
75saveCache(MembersPage,loadWikiMainPage("Members",10000));
76saveCache(ShortcutsPage,loadWikiMainPage("Shortcuts",10000));
77saveCache(WelcomePage,loadWikiMainPage("Welcome",10000));
78
79function saveCache($cacheName,$content,$type='wb'){
80        $cachePath='./omcache/';
81        if(!@is_dir($cachePath)){
82                if(!@mkdir($cache_dirname,0777)){
83                        return;
84                }
85        }
86        if (!$handle = fopen($cachePath.$cacheName.'.html', $type)) {
87                return;
88        }
89
90        if (fwrite($handle, $content) === FALSE) {
91                return;
92        }
93        fclose($handle);
94}
95?>
Note: See TracBrowser for help on using the repository browser.