| 103 |
- |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/***************************************************************************
|
|
|
4 |
* Copyright (C) 2009-2011 by Geo Varghese(www.seopanel.in) *
|
|
|
5 |
* sendtogeo@gmail.com *
|
|
|
6 |
* *
|
|
|
7 |
* This program is free software; you can redistribute it and/or modify *
|
|
|
8 |
* it under the terms of the GNU General Public License as published by *
|
|
|
9 |
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
10 |
* (at your option) any later version. *
|
|
|
11 |
* *
|
|
|
12 |
* This program is distributed in the hope that it will be useful, *
|
|
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
15 |
* GNU General Public License for more details. *
|
|
|
16 |
* *
|
|
|
17 |
* You should have received a copy of the GNU General Public License *
|
|
|
18 |
* along with this program; if not, write to the *
|
|
|
19 |
* Free Software Foundation, Inc., *
|
|
|
20 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
21 |
***************************************************************************/
|
|
|
22 |
|
|
|
23 |
# class defines all graph controller functions
|
|
|
24 |
class GraphController extends Controller {
|
|
|
25 |
|
|
|
26 |
# function to show graph
|
|
|
27 |
public function showKeywordPostionGraph($keywordId, $fromTimeDate, $toTimeDate, $searchEngineId = '') {
|
|
|
28 |
|
|
|
29 |
$conditions .= !empty($searchEngineId) ? " and s.searchengine_id=".intval($searchEngineId) : "";
|
|
|
30 |
$sql = "select s.*,se.domain from searchresults s,searchengines se
|
|
|
31 |
where s.searchengine_id=se.id and result_date>='$fromTimeDate' and result_date<='$toTimeDate'
|
|
|
32 |
and s.keyword_id=" . intval($keywordId). " $conditions order by s.result_date";
|
|
|
33 |
$repList = $this->db->select($sql);
|
|
|
34 |
|
|
|
35 |
// if reports not empty
|
|
|
36 |
if (!empty($repList)) {
|
|
|
37 |
|
|
|
38 |
$reportList = array ();
|
|
|
39 |
$seList = array();
|
|
|
40 |
foreach ($repList as $repInfo) {
|
|
|
41 |
$var = $repInfo['searchengine_id'] . $repInfo['keyword_id'] . $repInfo['result_date'];
|
|
|
42 |
|
|
|
43 |
if (empty ($reportList[$var])) {
|
|
|
44 |
$reportList[$var] = $repInfo;
|
|
|
45 |
} else {
|
|
|
46 |
|
|
|
47 |
if ($repInfo['rank'] < $reportList[$var]['rank']) {
|
|
|
48 |
$reportList[$var] = $repInfo;
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
if(empty($seList[$repInfo['searchengine_id']])){
|
|
|
54 |
$seList[$repInfo['searchengine_id']] = $repInfo['domain'];
|
|
|
55 |
}
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
$dataList = array();
|
|
|
59 |
foreach($reportList as $repInfo){
|
|
|
60 |
$seId = $repInfo['searchengine_id'];
|
|
|
61 |
$dataList[$repInfo['result_date']][$seId] = $repInfo['rank'];
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
ksort($seList);
|
|
|
65 |
$dataArr = "['Date', '" . implode("', '", array_values($seList)) . "']";
|
|
|
66 |
|
|
|
67 |
// loop through data list
|
|
|
68 |
foreach ($dataList as $dateVal => $dataInfo) {
|
|
|
69 |
|
|
|
70 |
$valStr = "";
|
|
|
71 |
foreach ($seList as $seId => $seVal) {
|
|
|
72 |
$valStr .= ", ";
|
|
|
73 |
$valStr .= !empty($dataInfo[$seId]) ? $dataInfo[$seId] : 101;
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
$dataArr .= ", ['$dateVal' $valStr]";
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
$this->set('reverseDir', true);
|
|
|
80 |
$this->set('dataArr', $dataArr);
|
|
|
81 |
$this->set('minValue', 1);
|
|
|
82 |
$this->set('maxValue', 100);
|
|
|
83 |
$this->set('graphTitle', $this->spTextKeyword["Keyword Position Report"]);
|
|
|
84 |
|
|
|
85 |
return $this->getViewContent('report/graph');
|
|
|
86 |
|
|
|
87 |
} else {
|
|
|
88 |
return showErrorMsg($_SESSION['text']['common']['No Records Found'], false, true);
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
}
|
|
|
94 |
?>
|