当前位置: 首页>>代码示例>>PHP>>正文


PHP rating::getMonthParts方法代码示例

本文整理汇总了PHP中rating::getMonthParts方法的典型用法代码示例。如果您正苦于以下问题:PHP rating::getMonthParts方法的具体用法?PHP rating::getMonthParts怎么用?PHP rating::getMonthParts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rating的用法示例。


在下文中一共展示了rating::getMonthParts方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GetRating

function GetRating($type, $login = null, $width = null)
{
    session_start();
    $objResponse = new xajaxResponse();
    $login = change_q_x($login, TRUE);
    $user = new users();
    $user->GetUser($login);
    $uid = $user->uid;
    if (!$uid) {
        $uid = get_uid(false);
    }
    if (!$uid) {
        $objResponse->script('this.document.location.reload();');
        return $objResponse;
    }
    $user->GetUserByUID($uid);
    $rating = new rating();
    switch ($type) {
        case 'year':
            $TIME = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
            $pro_periods_date = date('Y-01-01', $TIME);
            $res = $rating->getRatingByYear($uid, date('Y', $TIME));
            $periods = rating::getMonthParts(date('Y-01-01'));
            $data = array();
            if ($res) {
                foreach ($periods as $m => $mm) {
                    if ($m < date('m')) {
                        foreach ($mm as $d) {
                            if ($d > time() || $d < strtotime($user->reg_date)) {
                                continue;
                            }
                            $data[$m][date('Y-m-d', $d)] = null;
                            if ($d >= strtotime($user->reg_date)) {
                                $data[$m][date('Y-m-d', $d)] = 0;
                            }
                        }
                    }
                }
            }
            $start_r = null;
            if ($res) {
                if (date('Y', strtotime($res[0]['_date'])) == date('Y') - 1) {
                    $start_r = $res[0]['rating'];
                    if (isset($res[1]) && strtotime($res[1]['_date']) != $periods[0][0]) {
                        $res[0]['_date'] = date('Y-m-d', $periods[0][0]);
                    } else {
                        $res = array_slice($res, 1);
                    }
                }
            } else {
                $res = array();
            }
            $verify_factor = 0;
            $verify_date = rating::GetVerifyDate($uid);
            foreach ($res as $row) {
                $t = strtotime($row['_date']);
                $m = (int) date('m', $t);
                $verify_factor = 0;
                if ($row['is_verify'] == 't') {
                    if ($verify_date) {
                        if (strtotime($verify_date) < $t) {
                            $verify_factor = 0.2;
                        }
                    } else {
                        $verify_factor = 0.2;
                    }
                }
                $data[$m - 1][date('Y-m-d', $t)] = array('rating' => floatval($row['rating']), 'verify' => floatval($row['rating'] * $verify_factor), 'pro' => 0);
            }
            $lastval = null;
            foreach ($data as $i => $mon) {
                foreach ($mon as $d => $prt) {
                    $vl = !$prt ? $lastval : $prt;
                    $data[$i][$d] = $vl;
                    //                    if($prt !== null)
                    $lastval = $vl;
                }
            }
            $pro_periods = promotion::GetUserProPeriods($uid, $pro_periods_date, TRUE);
            if ($pro_periods) {
                $pro = array();
                foreach ($pro_periods as $p => $period) {
                    if (date('Y', strtotime($period['from_time'])) > date('Y', $TIME) && date('Y', strtotime($period['to_time']) > date('Y', $TIME))) {
                        continue;
                    }
                    $d1 = (int) date('z', strtotime($period['from_time']));
                    $d2 = (int) date('z', strtotime($period['to_time']));
                    if (date('Y', strtotime($period['from_time'])) < date('Y', $TIME)) {
                        $d1 = 0;
                    }
                    if (date('Y', strtotime($period['to_time'])) > date('Y', $TIME)) {
                        $d2 = (int) date('z', mktime(0, 0, 0, 12, 31, date('Y')));
                    }
                    $_factor = 0.2;
                    if ($period['is_profi'] == 1) {
                        $_factor = 0.4;
                    }
                    foreach ($data as $mon => $val) {
                        foreach ($val as $per => $r) {
                            $day = (int) date('z', strtotime($per));
//.........这里部分代码省略.........
开发者ID:kapai69,项目名称:fl-ru-damp,代码行数:101,代码来源:rating.server.php

示例2: createGraph

 /**
  * Строит график.
  */
 public function createGraph()
 {
     $periods = rating::getMonthParts(date('Y-m-d', $this->_time));
     foreach ($periods as $m => $p) {
         foreach ($this->_pro as $pr) {
             for ($c = 0; $c < 4; ++$c) {
                 if ($p[$c] >= strtotime($pr['from_time']) && $p[$c] <= strtotime($pr['to_time'])) {
                     $this->_ratingData[$m]['part' . ($c + 1)] *= rating::PRO_FACTOR;
                 }
             }
         }
     }
     $dots = array();
     // месяцы
     $labels_group = $this->doc->createElement('g');
     $this->svg->appendChild($labels_group);
     $last = null;
     $c = count($this->_data);
     $max = $this->_getMax();
     $min = $this->_min;
     //var_dump($min);
     if ($min < 0) {
         $h_diff = $min * -1;
         $h_diff *= 1.2;
         $max = ($max == $min || $max < 0 ? 0 : $max) + $h_diff;
     }
     $r_last = 0;
     for ($i = 0; $i < $this->_columns; ++$i) {
         $t = mktime(0, 0, 0, $i + 1, date('d', $this->_time), date('Y', $this->_time));
         $m_params = array('fill' => '#B2B2B2');
         $m_params['fill'] = date('Y-m', $this->_time) == date('Y-m', $t) ? '#666666' : $m_params['fill'];
         $label = $this->addText($this->_columnWidth * $i + $this->_columnWidth / 2, 155, $this->_labels[$i], $m_params);
         $labels_group->appendChild($label);
         if ($c <= 0) {
             continue;
         }
         for ($ii = 0; $ii < 4; ++$ii) {
             $x = $this->_columnWidth / 4 * $ii + $this->_columnWidth * $i + $this->_columnWidth / 8;
             $y = $this->_graphSize[1];
             if (isset($this->_ratingData[$i])) {
                 $field = 'part' . ($ii + 1);
                 $y = $this->_graphSize[1] - ($this->_ratingData[$i][$field] + $h_diff) * $this->_graphSize[1] / $max * $this->_zoom;
             }
             if (!isset($this->_ratingData[$i]['_date']) && $last) {
                 $y = $last;
             }
             if ($ii == 0 && $i == 0) {
                 $this->_fillCoord[] = 'M0, ' . $this->_graphSize[1];
                 $this->_pathCoord[] = "M0, {$y}";
                 $this->_fillCoord[] = "L0, {$y}";
             }
             $this->_pathCoord[] = "L{$x}, {$y}";
             $this->_fillCoord[] = "L{$x}, {$y}";
             $this->_path[] = array($x, $y);
             $rating = $r_last;
             if (isset($this->_ratingData[$i])) {
                 $rating = $this->_ratingData[$i][$field];
             }
             $date = date('d.m.Y', $periods[$i][$ii]);
             $dots[] = array($x, $y, floatval($rating), $date);
             $last = $y;
             $r_last = $rating;
         }
         if (isset($this->_ratingData[$i]['_date'])) {
             $c--;
         }
     }
     $this->drawPart();
     // точки
     $this->_dots = $dots;
     $dots_group = $this->doc->createElement('g');
     $dots_group->setAttribute('id', 'dots_group');
     $dots_group->setIdAttribute('id', true);
     $this->svg->appendChild($dots_group);
     if ($dots) {
         foreach ($dots as $i => $dot) {
             $params = array();
             if (isset($dot[2])) {
                 $params['ratingvalue'] = $dot[2];
             }
             if (isset($dot[3])) {
                 $params['ratingdate'] = $dot[3];
             }
             $dots_group->appendChild($this->addCircle($dot[0], $dot[1], $params));
         }
     }
     $this->_setPro();
 }
开发者ID:kapai69,项目名称:fl-ru-damp,代码行数:91,代码来源:rating_svg_monthly.php

示例3: date

     $graph_class = 'Rating_Svg_Daily';
     $pro_periods_date = date('Y-m-01', $TIME);
     $file = "/users/" . substr($u_login, 0, 2) . "/{$u_login}/upload/{$file_name}.{$file_ext}";
     $cfile = new CFile($file);
     $overwrite = date('Y-m') != date('Y-m', strtotime($cfile->modified));
     break;
 case 'year':
     $TIME = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
     $file_name = 'rating_year';
     $get_rating_by = 'getRatingByYear';
     $get_rating_date = date('Y', $TIME);
     $graph_class = 'Rating_Svg_Monthly';
     $pro_periods_date = date('Y-01-01', $TIME);
     $file = "/users/" . substr($u_login, 0, 2) . "/{$u_login}/upload/{$file_name}.{$file_ext}";
     $cfile = new CFile($file);
     $periods = rating::getMonthParts(date('Y-01-01'));
     $cur_period = $periods[intval(date('m', $TIME)) - 1];
     if ($TIME <= $cur_period[0]) {
         $file_maxtime = mktime(0, 0, 0, date('m', $cur_period[0]), 0, date('Y', $cur_period[0]));
     } elseif ($TIME > $cur_period[0] && $TIME <= $cur_period[1]) {
         $file_maxtime = $cur_period[0];
     } elseif ($TIME > $cur_period[1] && $TIME <= $cur_period[2]) {
         $file_maxtime = $cur_period[1];
     } elseif ($TIME > $cur_period[2] && $TIME <= $cur_period[3]) {
         $file_maxtime = $cur_period[2];
     }
     $overwrite = strtotime($cfile->modified) < $file_maxtime;
     break;
 default:
     $TIME = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
     $file_name = 'rating';
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:31,代码来源:svg.php


注:本文中的rating::getMonthParts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。