本文整理匯總了PHP中Stats::newInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Stats::newInstance方法的具體用法?PHP Stats::newInstance怎麽用?PHP Stats::newInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Stats
的用法示例。
在下文中一共展示了Stats::newInstance方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: doModel
function doModel()
{
switch ($this->action) {
case 'logout':
// unset only the required parameters in Session
$this->logout();
$this->redirectTo(osc_admin_base_url(true));
break;
default:
//default dashboard page (main page at oc-admin)
$this->_exportVariableToView("numItemsPerCategory", osc_get_non_empty_categories());
$this->_exportVariableToView("numUsers", User::newInstance()->count());
$this->_exportVariableToView("numItems", Item::newInstance()->count());
$this->_exportVariableToView('newsList', osc_listNews());
$this->_exportVariableToView('twitterRSS', osc_latestTweets());
// stats
$items = array();
$stats_items = Stats::newInstance()->new_items_count(date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d") - 10, date("Y"))), 'day');
for ($k = 10; $k >= 0; $k--) {
$items[date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - $k, date("Y")))] = 0;
}
foreach ($stats_items as $item) {
$items[$item['d_date']] = $item['num'];
}
$users = array();
$stats_users = Stats::newInstance()->new_users_count(date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d") - 10, date("Y"))), 'day');
for ($k = 10; $k >= 0; $k--) {
$users[date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - $k, date("Y")))] = 0;
}
foreach ($stats_users as $user) {
$users[$user['d_date']] = $user['num'];
}
$this->_exportVariableToView("item_stats", $items);
$this->_exportVariableToView("user_stats", $users);
//calling the view...
$this->doView('main/index.php');
}
}
示例2: doModel
function doModel()
{
switch ($this->action) {
case 'logout':
// unset only the required parameters in Session
osc_run_hook('logout_admin');
$this->logout();
$this->redirectTo(osc_admin_base_url(true));
break;
default:
//default dashboard page (main page at oc-admin)
$this->_exportVariableToView("numItemsPerCategory", osc_get_non_empty_categories());
$this->_exportVariableToView("numUsers", User::newInstance()->count());
$this->_exportVariableToView("numItems", Item::newInstance()->count());
// stats
$items = array();
$stats_items = Stats::newInstance()->new_items_count(date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d") - 10, date("Y"))), 'day');
for ($k = 10; $k >= 0; $k--) {
$items[date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - $k, date("Y")))] = 0;
}
foreach ($stats_items as $item) {
$items[$item['d_date']] = $item['num'];
}
$users = array();
$stats_users = Stats::newInstance()->new_users_count(date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d") - 10, date("Y"))), 'day');
for ($k = 10; $k >= 0; $k--) {
$users[date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - $k, date("Y")))] = 0;
}
foreach ($stats_users as $user) {
$users[$user['d_date']] = $user['num'];
}
if (function_exists('disk_free_space')) {
$freedisk = @disk_free_space(osc_uploads_path());
if ($freedisk !== false && $freedisk < 52428800) {
//52428800 = 50*1024*1024
osc_add_flash_error_message(_m('You have very few free space left, users will not be able to upload pictures'), 'admin');
}
}
// show messages subscribed
$status_subscribe = Params::getParam('subscribe_osclass');
if ($status_subscribe != '') {
switch ($status_subscribe) {
case -1:
osc_add_flash_error_message(_m('Entered an invalid email'), 'admin');
break;
case 0:
osc_add_flash_warning_message(_m("You're already subscribed"), 'admin');
break;
case 1:
osc_add_flash_ok_message(_m('Subscribed correctly'), 'admin');
break;
default:
osc_add_flash_warning_message(_m("Error subscribing"), 'admin');
break;
}
}
$this->_exportVariableToView("item_stats", $items);
$this->_exportVariableToView("user_stats", $users);
//calling the view...
$this->doView('main/index.php');
}
}
示例3: doModel
function doModel()
{
parent::doModel();
//specific things for this class
switch ($this->action) {
case 'reports':
// manage stats view
$reports = array();
if (Params::getParam('type_stat') == 'week') {
$stats_reports = Stats::newInstance()->new_reports_count(date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - 70, date("Y"))), 'week');
for ($k = 10; $k >= 0; $k--) {
$reports[date('W', mktime(0, 0, 0, date("m"), date("d"), date("Y"))) - $k]['views'] = 0;
$reports[date('W', mktime(0, 0, 0, date("m"), date("d"), date("Y"))) - $k]['spam'] = 0;
$reports[date('W', mktime(0, 0, 0, date("m"), date("d"), date("Y"))) - $k]['repeated'] = 0;
$reports[date('W', mktime(0, 0, 0, date("m"), date("d"), date("Y"))) - $k]['bad_classified'] = 0;
$reports[date('W', mktime(0, 0, 0, date("m"), date("d"), date("Y"))) - $k]['offensive'] = 0;
$reports[date('W', mktime(0, 0, 0, date("m"), date("d"), date("Y"))) - $k]['expired'] = 0;
}
} else {
if (Params::getParam('type_stat') == 'month') {
$stats_reports = Stats::newInstance()->new_reports_count(date('Y-m-d', mktime(0, 0, 0, date("m") - 10, date("d"), date("Y"))), 'month');
for ($k = 10; $k >= 0; $k--) {
$reports[date('F', mktime(0, 0, 0, date("m") - $k, date("d"), date("Y")))]['views'] = 0;
$reports[date('F', mktime(0, 0, 0, date("m") - $k, date("d"), date("Y")))]['spam'] = 0;
$reports[date('F', mktime(0, 0, 0, date("m") - $k, date("d"), date("Y")))]['repeated'] = 0;
$reports[date('F', mktime(0, 0, 0, date("m") - $k, date("d"), date("Y")))]['bad_classified'] = 0;
$reports[date('F', mktime(0, 0, 0, date("m") - $k, date("d"), date("Y")))]['offensive'] = 0;
$reports[date('F', mktime(0, 0, 0, date("m") - $k, date("d"), date("Y")))]['expired'] = 0;
}
} else {
$stats_reports = Stats::newInstance()->new_reports_count(date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - 10, date("Y"))), 'day');
for ($k = 10; $k >= 0; $k--) {
$reports[date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - $k, date("Y")))]['views'] = 0;
$reports[date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - $k, date("Y")))]['spam'] = 0;
$reports[date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - $k, date("Y")))]['repeated'] = 0;
$reports[date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - $k, date("Y")))]['bad_classified'] = 0;
$reports[date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - $k, date("Y")))]['offensive'] = 0;
$reports[date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - $k, date("Y")))]['expired'] = 0;
}
}
}
$max = array();
$max['views'] = 0;
$max['other'] = 0;
foreach ($stats_reports as $report) {
$reports[$report['d_date']]['views'] = $report['views'];
$reports[$report['d_date']]['spam'] = $report['spam'];
$reports[$report['d_date']]['repeated'] = $report['repeated'];
$reports[$report['d_date']]['bad_classified'] = $report['bad_classified'];
$reports[$report['d_date']]['offensive'] = $report['offensive'];
$reports[$report['d_date']]['expired'] = $report['expired'];
if ($report['views'] > $max['views']) {
$max['views'] = $report['views'];
}
if ($report['spam'] > $max['other']) {
$max['other'] = $report['spam'];
}
if ($report['repeated'] > $max['other']) {
$max['other'] = $report['repeated'];
}
if ($report['bad_classified'] > $max['other']) {
$max['other'] = $report['bad_classified'];
}
if ($report['offensive'] > $max['other']) {
$max['other'] = $report['offensive'];
}
if ($report['expired'] > $max['other']) {
$max['other'] = $report['expired'];
}
}
$this->_exportVariableToView("reports", $reports);
$this->_exportVariableToView("max", $max);
$this->doView("stats/reports.php");
break;
case 'comments':
// manage stats view
$comments = array();
if (Params::getParam('type_stat') == 'week') {
$stats_comments = Stats::newInstance()->new_comments_count(date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d") - 70, date("Y"))), 'week');
for ($k = 10; $k >= 0; $k--) {
$comments[date('W', mktime(0, 0, 0, date("m"), date("d"), date("Y"))) - $k] = 0;
}
} else {
if (Params::getParam('type_stat') == 'month') {
$stats_comments = Stats::newInstance()->new_comments_count(date('Y-m-d H:i:s', mktime(0, 0, 0, date("m") - 10, date("d"), date("Y"))), 'month');
for ($k = 10; $k >= 0; $k--) {
$comments[date('F', mktime(0, 0, 0, date("m") - $k, date("d"), date("Y")))] = 0;
}
} else {
$stats_comments = Stats::newInstance()->new_comments_count(date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d") - 10, date("Y"))), 'day');
for ($k = 10; $k >= 0; $k--) {
$comments[date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - $k, date("Y")))] = 0;
}
}
}
$max = 0;
foreach ($stats_comments as $comment) {
$comments[$comment['d_date']] = $comment['num'];
if ($comment['num'] > $max) {
$max = $comment['num'];
//.........這裏部分代碼省略.........