本文整理汇总了PHP中Owner::getTopTeamProjects方法的典型用法代码示例。如果您正苦于以下问题:PHP Owner::getTopTeamProjects方法的具体用法?PHP Owner::getTopTeamProjects怎么用?PHP Owner::getTopTeamProjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Owner
的用法示例。
在下文中一共展示了Owner::getTopTeamProjects方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getStats
/**
* Collect overall projects stats
*
* @return array
*/
public function getStats($model, $cron = false, $publishing = false, $period = 'alltime', $limit = 3)
{
// Incoming
$period = Request::getVar('period', $period);
$limit = Request::getInt('limit', $limit);
if ($cron == true) {
$publicOnly = false;
$saveLog = true;
} else {
$publicOnly = $model->reviewerAccess('admin') ? false : true;
$saveLog = false;
}
// Collectors
$stats = array();
$updated = NULL;
$lastLog = NULL;
$pastMonth = Date::of(time() - 32 * 24 * 60 * 60)->toSql('Y-m-d');
$thisYearNum = Date::format('y');
$thisMonthNum = Date::format('m');
$thisWeekNum = Date::format('W');
// Pull recent stats
if ($this->loadLog($thisYearNum, $thisMonthNum, $thisWeekNum)) {
$lastLog = json_decode($this->stats, true);
$updated = $this->processed;
} else {
// Save stats
$saveLog = true;
}
// Get project table class
$tbl = $model->table();
// Get inlcude /exclude lists
$exclude = $tbl->getProjectsByTag('test', true, 'id');
$include = $tbl->getProjectsByTag('test', false, 'id');
$validProjects = $tbl->getProjectsByTag('test', false, 'alias');
$validCount = count($validProjects) > 0 ? count($validProjects) : 1;
// Collect overview stats
$stats['general'] = array('total' => $tbl->getCount(array('exclude' => $exclude, 'all' => 1), true), 'setup' => $tbl->getCount(array('exclude' => $exclude, 'setup' => 1), true), 'active' => $tbl->getCount(array('exclude' => $exclude, 'active' => 1), true), 'public' => $tbl->getCount(array('exclude' => $exclude, 'private' => '0'), true), 'sponsored' => $tbl->getCount(array('exclude' => $exclude, 'reviewer' => 'sponsored'), true), 'sensitive' => $tbl->getCount(array('exclude' => $exclude, 'reviewer' => 'sensitive'), true), 'new' => $tbl->getCount(array('exclude' => $exclude, 'created' => date('Y-m', time()), 'all' => 1), true));
$active = $stats['general']['active'] ? $stats['general']['active'] : 1;
$total = $stats['general']['total'] ? $stats['general']['total'] : 1;
// Activity stats
$objAA = new Activity($this->_db);
$recentlyActive = $tbl->getCount(array('exclude' => $exclude, 'timed' => $pastMonth, 'active' => 1), true);
$perc = round($recentlyActive * 100 / $active) . '%';
$stats['activity'] = array('total' => $objAA->getActivityStats($include, 'total'), 'average' => $objAA->getActivityStats($include, 'average'), 'usage' => $perc);
$stats['topActiveProjects'] = $objAA->getTopActiveProjects($exclude, 5, $publicOnly);
// Collect team stats
$objO = new Owner($this->_db);
$multiTeam = $objO->getTeamStats($exclude, 'multi');
$activeTeam = $objO->getTeamStats($exclude, 'registered');
$invitedTeam = $objO->getTeamStats($exclude, 'invited');
$multiProjectUsers = $objO->getTeamStats($exclude, 'multiusers');
$teamTotal = $activeTeam + $invitedTeam;
$perc = round($multiTeam * 100 / $total) . '%';
$stats['team'] = array('total' => $teamTotal, 'average' => $objO->getTeamStats($exclude, 'average'), 'multi' => $perc, 'multiusers' => $multiProjectUsers);
$stats['topTeamProjects'] = $objO->getTopTeamProjects($exclude, $limit, $publicOnly);
// Collect files stats
if ($lastLog) {
$stats['files'] = $lastLog['files'];
} else {
// Get repo model
require_once PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'models' . DS . 'repo.php';
// Compute
$repo = new \Components\Projects\Models\Repo();
$fTotal = $repo->getStats($validProjects);
$fAverage = number_format($fTotal / $validCount, 0);
$fUsage = $repo->getStats($validProjects, 'usage');
$fDSpace = $repo->getStats($validProjects, 'diskspace');
$fCommits = $repo->getStats($validProjects, 'commitCount');
$pDSpace = $repo->getStats($validProjects, 'pubspace');
$perc = round($fUsage * 100 / $active) . '%';
$stats['files'] = array('total' => $fTotal, 'average' => $fAverage, 'usage' => $perc, 'diskspace' => \Hubzero\Utility\Number::formatBytes($fDSpace), 'commits' => $fCommits, 'pubspace' => \Hubzero\Utility\Number::formatBytes($pDSpace));
}
// Collect publication stats
if ($publishing) {
$objP = new \Components\Publications\Tables\Publication($this->_db);
$objPV = new \Components\Publications\Tables\Version($this->_db);
$prPub = $objP->getPubStats($include, 'usage');
$perc = round($prPub * 100 / $total) . '%';
$stats['pub'] = array('total' => $objP->getPubStats($include, 'total'), 'average' => $objP->getPubStats($include, 'average'), 'usage' => $perc, 'released' => $objP->getPubStats($include, 'released'), 'versions' => $objPV->getPubStats($include));
}
// Save weekly stats
if ($saveLog) {
$this->year = $thisYearNum;
$this->month = $thisMonthNum;
$this->week = $thisWeekNum;
$this->processed = Date::toSql();
$this->stats = json_encode($stats);
$this->store();
}
$stats['updated'] = $updated ? $updated : NULL;
return $stats;
}