• R/O
  • HTTP
  • SSH
  • HTTPS

magic3: Commit

Cloud computing platform


Commit MetaInfo

Révision1f22eb7c0b4ccf2727bac6c8cf3ded82e300f104 (tree)
l'heure2016-04-27 08:15:29
Auteurnaoki hirata <naoki@magi...>
Commiternaoki hirata

Message de Log

ブログメインウィジェット更新。

Change Summary

Modification

--- a/widgets/blog_main/include/container/admin_blog_mainAnalyticsWidgetContainer.php
+++ b/widgets/blog_main/include/container/admin_blog_mainAnalyticsWidgetContainer.php
@@ -25,8 +25,10 @@ class admin_blog_mainAnalyticsWidgetContainer extends admin_blog_mainBaseWidgetC
2525 private $termTypeArray; // 期間タイプ
2626 private $calcType; // 選択中の集計タイプ
2727 private $termType; // 選択中の期間タイプ
28- private $yTickValueArray; // Y軸の最大値リスト
28+ private $yMaxTickArray; // Y軸の最大値リスト
2929 private $weekTypeArray; // 曜日表示名
30+ private $xTitleArray; // X軸値
31+ private $yValueArray; // Y軸値
3032 private $maxViewCount; // コンテン参照数最大値
3133 private $graphDataKeyArray; // グラフデータ取得用キー
3234 private $graphDataArray; // グラフデータ(X軸値をキー、Y軸値を値とする連想配列)
@@ -75,7 +77,7 @@ class admin_blog_mainAnalyticsWidgetContainer extends admin_blog_mainBaseWidgetC
7577 array( 'name' => 'すべて', 'value' => self::TERM_TYPE_ALL));
7678
7779 // Y軸の最大値リスト
78- $this->yTickValueArray = array(1000000, 500000, 100000, 50000, 10000, 5000, 1000, 500, 100, 0);
80+ $this->yMaxTickArray = array(1000000, 500000, 100000, 50000, 10000, 5000, 1000, 500, 100, 0);
7981
8082 // 曜日表示名
8183 $this->weekTypeArray = array('日', '月', '火', '水', '木', '金', '土');
@@ -197,110 +199,19 @@ class admin_blog_mainAnalyticsWidgetContainer extends admin_blog_mainBaseWidgetC
197199 // 集計タイプメニュー作成
198200 $this->createCalcTypeMenu();
199201
200- // ##### 集計グラフ作成 #####
201- $xTitleArray = array();
202- $yValueArray = array();
203- $this->graphDataKeyArray = array(); // グラフデータ取得用キー
204-
205- // 集計グラフ用データ取得
206- if ($this->calcType == 'day'){ // 日単位で集計の場合
207- $this->db->getAllContentViewCountByDate(blog_mainCommonDef::VIEW_CONTENT_TYPE, $this->startDate, $this->endDate, array($this, 'contentViewCountLoop'));
208-
209- // X軸ラベル作成
210- $dateTimestamp = strtotime($this->startDate);
211- $startTimestamp = $dateTimestamp;
212- $endTimestamp = strtotime($this->endDate);
213- $date = $this->startDate;
214- $graphDataKey = date($this->graphDataKeyFormat, $dateTimestamp);
215- while (true){
216- if ($dateTimestamp > $endTimestamp) break;
217- $this->graphDataKeyArray[] = $graphDataKey; // グラフデータ取得用キー
218-
219- // グラフ用のデータ作成
220- $xTitleArray[] = date('n/j', $dateTimestamp); // X軸タイトル。表示フォーマットに変換。
221- $value = $this->graphDataArray[$graphDataKey];
222- if (isset($value)){
223- $yValueArray[] = intval($value);
224- } else {
225- $yValueArray[] = 0;
226- }
227- $dateTimestamp = strtotime("$date 1 day");
228- $date = date(self::DATE_FORMAT, $dateTimestamp); // 次の日に更新
229- $graphDataKey = date($this->graphDataKeyFormat, $dateTimestamp);
230- }
231- } else if ($this->calcType == 'month'){ // 月単位で集計の場合
232- $this->db->getAllContentViewCountByMonth(blog_mainCommonDef::VIEW_CONTENT_TYPE, $this->startDate, $this->endDate, array($this, 'contentViewCountLoop'));
233-
234- // X軸ラベル作成
235- $year = $startYear;
236- $month = $startMonth;
237- $dateTimestamp = strtotime("$year-$month-1");
238- $graphDataKey = date($this->graphDataKeyFormat, $dateTimestamp);
239-
240- for ($i = 0; $i < 12; $i++){
241- $this->graphDataKeyArray[] = $graphDataKey; // グラフデータ取得用キー
242-
243- // グラフ用のデータ作成
244- $xTitleArray[] = date('n月', $dateTimestamp); // X軸タイトル。表示フォーマットに変換。
245- $value = $this->graphDataArray[$graphDataKey];
246- if (isset($value)){
247- $yValueArray[] = intval($value);
248- } else {
249- $yValueArray[] = 0;
250- }
251-
252- // 次の月へ進む
253- $month++;
254- if ($month > 12){
255- $month = 1;
256- $year++;
257- }
258- $dateTimestamp = strtotime("$year-$month-1");
259- $graphDataKey = date($this->graphDataKeyFormat, $dateTimestamp);
260- }
261- } else if ($this->calcType == 'hour'){ // 時間単位で集計の場合
262- $this->db->getAllContentViewCountByHour(blog_mainCommonDef::VIEW_CONTENT_TYPE, $this->startDate, $this->endDate, array($this, 'contentViewCountLoop'));
263-
264- // X軸ラベル作成
265- for ($i = 0; $i < 24; $i++){
266- $this->graphDataKeyArray[] = $i; // グラフデータ取得用キー
267-
268- // グラフ用のデータ作成
269- $xTitleArray[] = $i . '時'; // X軸タイトル(時間)
270- $value = $this->graphDataArray[$i];
271- if (isset($value)){
272- $yValueArray[] = intval($value);
273- } else {
274- $yValueArray[] = 0;
275- }
276- }
277- } else if ($this->calcType == 'week'){ // 曜日単位で集計の場合
278- $this->db->getAllContentViewCountByWeek(blog_mainCommonDef::VIEW_CONTENT_TYPE, $this->startDate, $this->endDate, array($this, 'contentViewCountLoop'));
279-
280- // X軸ラベル作成
281- for ($i = 0; $i < 7; $i++){
282- $this->graphDataKeyArray[] = $i; // グラフデータ取得用キー
283-
284- // グラフ用のデータ作成
285- $xTitleArray[] = $this->weekTypeArray[$i]; // X軸タイトル(曜日)
286- $value = $this->graphDataArray[$i];
287- if (isset($value)){
288- $yValueArray[] = intval($value);
289- } else {
290- $yValueArray[] = 0;
291- }
292- }
293- }
202+ // ##### グラフ用データ作成 #####
203+ $this->createGraphData();
294204
295205 // グラフ用データをスクリプト化
296- $graphDataXStr = '[' . implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $xTitleArray)) . ']';
297- $graphDataYStr = '[' . implode(', ', $yValueArray) . ']';
206+ $graphDataXStr = '[' . implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $this->xTitleArray)) . ']';
207+ $graphDataYStr = '[' . implode(', ', $this->yValueArray) . ']';
208+ $graphDataKeyStr = '[' . implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $this->graphDataKeyArray)) . ']';
298209
299210 // グラフY座標最大値取得
300211 $yMax = self::DEFAULT_Y_TICK_VALUE;
301- for ($i = 0; $i < count($this->yTickValueArray) -1; $i++){
302- if ($this->maxViewCount >= $this->yTickValueArray[$i + 1]){
303- $yMax = $this->yTickValueArray[$i];// Y座標最大値
212+ for ($i = 0; $i < count($this->yMaxTickArray) -1; $i++){
213+ if ($this->maxViewCount >= $this->yMaxTickArray[$i + 1]){
214+ $yMax = $this->yMaxTickArray[$i];// Y座標最大値
304215 break;
305216 }
306217 }
@@ -314,11 +225,11 @@ class admin_blog_mainAnalyticsWidgetContainer extends admin_blog_mainBaseWidgetC
314225 }
315226
316227 // X軸タイトル作成
317- array_unshift($xTitleArray, '総数');// 左端は総数のカラムを追加
318- $xTitleCount = count($xTitleArray);
228+ array_unshift($this->xTitleArray, '総数');// 左端は総数のカラムを追加
229+ $xTitleCount = count($this->xTitleArray);
319230 for ($i = 0; $i < $xTitleCount; $i++){
320231 $row = array(
321- 'date' => $this->convertToDispString($xTitleArray[$i]) // X軸タイトル
232+ 'date' => $this->convertToDispString($this->xTitleArray[$i]) // X軸タイトル
322233 );
323234 $this->tmpl->addVars('datelist', $row);
324235 $this->tmpl->parseTemplate('datelist', 'a');
@@ -335,6 +246,7 @@ class admin_blog_mainAnalyticsWidgetContainer extends admin_blog_mainBaseWidgetC
335246 $this->tmpl->addVar('_widget', 'end_date', $this->convertToDispDate($this->endDate)); // 集計期間(終了)
336247 $this->tmpl->addVar('draw_graph', 'x_ticks', $graphDataXStr); // グラフX軸タイトル
337248 $this->tmpl->addVar('draw_graph', 'y_values', $graphDataYStr); // グラフY軸値
249+ $this->tmpl->addVar('draw_graph', 'keys', $graphDataKeyStr); // グラフデータキー
338250 $this->tmpl->addVar('draw_graph', 'y_max', $yMax); // グラフY座標最大値
339251 }
340252 /**
@@ -531,5 +443,109 @@ class admin_blog_mainAnalyticsWidgetContainer extends admin_blog_mainBaseWidgetC
531443 }
532444 return $viewData;
533445 }
446+ /**
447+ * グラフ用データ作成
448+ *
449+ * @return なし
450+ */
451+ function createGraphData()
452+ {
453+ // ##### 集計グラフ作成 #####
454+ $this->xTitleArray = array();
455+ $this->yValueArray = array();
456+ $this->graphDataKeyArray = array(); // グラフデータ取得用キー
457+
458+ // 集計グラフ用データ取得
459+ if ($this->calcType == 'day'){ // 日単位で集計の場合
460+ $this->db->getAllContentViewCountByDate(blog_mainCommonDef::VIEW_CONTENT_TYPE, $this->startDate, $this->endDate, array($this, 'contentViewCountLoop'));
461+
462+ // X軸ラベル作成
463+ $dateTimestamp = strtotime($this->startDate);
464+ $startTimestamp = $dateTimestamp;
465+ $endTimestamp = strtotime($this->endDate);
466+ $date = $this->startDate;
467+ $graphDataKey = date($this->graphDataKeyFormat, $dateTimestamp);
468+ while (true){
469+ if ($dateTimestamp > $endTimestamp) break;
470+ $this->graphDataKeyArray[] = $graphDataKey; // グラフデータ取得用キー
471+
472+ // グラフ用のデータ作成
473+ $this->xTitleArray[] = date('n/j', $dateTimestamp); // X軸タイトル。表示フォーマットに変換。
474+ $value = $this->graphDataArray[$graphDataKey];
475+ if (isset($value)){
476+ $this->yValueArray[] = intval($value);
477+ } else {
478+ $this->yValueArray[] = 0;
479+ }
480+ $dateTimestamp = strtotime("$date 1 day");
481+ $date = date(self::DATE_FORMAT, $dateTimestamp); // 次の日に更新
482+ $graphDataKey = date($this->graphDataKeyFormat, $dateTimestamp);
483+ }
484+
485+ $this->tmpl->setAttribute('graph_clickable', 'visibility', 'visible'); // 1日分のグラフ画面への遷移を可能にする
486+ } else if ($this->calcType == 'month'){ // 月単位で集計の場合
487+ $this->db->getAllContentViewCountByMonth(blog_mainCommonDef::VIEW_CONTENT_TYPE, $this->startDate, $this->endDate, array($this, 'contentViewCountLoop'));
488+
489+ // X軸ラベル作成
490+ $year = $startYear;
491+ $month = $startMonth;
492+ $dateTimestamp = strtotime("$year-$month-1");
493+ $graphDataKey = date($this->graphDataKeyFormat, $dateTimestamp);
494+
495+ for ($i = 0; $i < 12; $i++){
496+ $this->graphDataKeyArray[] = $graphDataKey; // グラフデータ取得用キー
497+
498+ // グラフ用のデータ作成
499+ $this->xTitleArray[] = date('n月', $dateTimestamp); // X軸タイトル。表示フォーマットに変換。
500+ $value = $this->graphDataArray[$graphDataKey];
501+ if (isset($value)){
502+ $this->yValueArray[] = intval($value);
503+ } else {
504+ $this->yValueArray[] = 0;
505+ }
506+
507+ // 次の月へ進む
508+ $month++;
509+ if ($month > 12){
510+ $month = 1;
511+ $year++;
512+ }
513+ $dateTimestamp = strtotime("$year-$month-1");
514+ $graphDataKey = date($this->graphDataKeyFormat, $dateTimestamp);
515+ }
516+ } else if ($this->calcType == 'hour'){ // 時間単位で集計の場合
517+ $this->db->getAllContentViewCountByHour(blog_mainCommonDef::VIEW_CONTENT_TYPE, $this->startDate, $this->endDate, array($this, 'contentViewCountLoop'));
518+
519+ // X軸ラベル作成
520+ for ($i = 0; $i < 24; $i++){
521+ $this->graphDataKeyArray[] = $i; // グラフデータ取得用キー
522+
523+ // グラフ用のデータ作成
524+ $this->xTitleArray[] = $i . '時'; // X軸タイトル(時間)
525+ $value = $this->graphDataArray[$i];
526+ if (isset($value)){
527+ $this->yValueArray[] = intval($value);
528+ } else {
529+ $this->yValueArray[] = 0;
530+ }
531+ }
532+ } else if ($this->calcType == 'week'){ // 曜日単位で集計の場合
533+ $this->db->getAllContentViewCountByWeek(blog_mainCommonDef::VIEW_CONTENT_TYPE, $this->startDate, $this->endDate, array($this, 'contentViewCountLoop'));
534+
535+ // X軸ラベル作成
536+ for ($i = 0; $i < 7; $i++){
537+ $this->graphDataKeyArray[] = $i; // グラフデータ取得用キー
538+
539+ // グラフ用のデータ作成
540+ $this->xTitleArray[] = $this->weekTypeArray[$i]; // X軸タイトル(曜日)
541+ $value = $this->graphDataArray[$i];
542+ if (isset($value)){
543+ $this->yValueArray[] = intval($value);
544+ } else {
545+ $this->yValueArray[] = 0;
546+ }
547+ }
548+ }
549+ }
534550 }
535551 ?>
--- a/widgets/blog_main/include/template/admin_analytics.tmpl.html
+++ b/widgets/blog_main/include/template/admin_analytics.tmpl.html
@@ -11,7 +11,6 @@
1111 * @link http://www.magic3.org
1212 */
1313 <patTemplate:tmpl name="_widget">
14-<!--<script type="text/javascript" src="{_SCRIPTS_URL}/{LIB_DIR}/plugins/jqplot.dateAxisRenderer.min.js"></script>-->
1514 <script type="text/javascript" src="{_SCRIPTS_URL}/{LIB_DIR}/plugins/jqplot.categoryAxisRenderer.min.js"></script>
1615 <script type="text/javascript" src="{_SCRIPTS_URL}/{LIB_DIR}/plugins/jqplot.barRenderer.js"></script>
1716 <script type="text/javascript" src="{_SCRIPTS_URL}/{LIB_DIR}/plugins/jqplot.highlighter.js"></script>
@@ -23,15 +22,13 @@ function changeCalcType(){
2322 return true;
2423 }
2524 $(function(){
26- // テーブルを作成
27-// m3SetConfigTable('mainconfig');
28-
2925 <patTemplate:tmpl name="draw_graph">
3026 // アクセス数グラフ作成
3127 var values = {Y_VALUES};
3228 var ticks = {X_TICKS};
29+ var keys = {KEYS};
3330
34- plot1 = $.jqplot('chart1', [values], {
31+ $.jqplot('chart1', [values], {
3532 animate: !$.jqplot.use_excanvas,
3633 seriesDefaults:{
3734 renderer:$.jqplot.BarRenderer,
@@ -59,11 +56,22 @@ $(function(){
5956 formatString: '%s'
6057 }
6158 });
59+<patTemplate:tmpl name="graph_clickable" visibility="hidden">
60+ $("#chart1 .jqplot-xaxis-tick").css({
61+ cursor: "pointer",
62+ zIndex: "1"
63+ }).click(function(){
64+ var index = $('#chart1 .jqplot-xaxis-tick').index(this);
65+// alert('項目番号:' +index);
66+ alert(keys[index]);
67+ // 画面遷移
68+ //location.href = "http://google.com";
69+ });
70+</patTemplate:tmpl>
6271 </patTemplate:tmpl>
6372
6473 // 上位アクセスコンテンツテーブル
6574 $('#mainconfig').m3stickyheader();
66-
6775 });
6876 //]]>
6977 </script>
Afficher sur ancien navigateur de dépôt.