Pluf Framework

Pluf Framework Commit Details


Date:2010-04-10 08:56:58 (14 years 8 months ago)
Author:Loic d'Anterroches
Branch:develop, master
Commit:93554e74eb1de2e849e8fd550c8bcf9146811d07
Parents: a8919ef7836f3e8ab44586f9c34b77a2981201b1
Message:Started the work to display the visitor properties in the funnels.

Changes:

File differences

src/Pluf/AB/Funnel.php
5656
5757
5858
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
5994
6095
6196
}
/**
* Get all the properties for a given period.
*/
public static function getFunnelProps($funnel, $period='today')
{
$db = Pluf_AB::getDb();
switch ($period) {
case 'yesterday':
$q = array('t' => (int) gmdate('Ymd', time()-86400));
break;
case 'today':
$q = array('t' => (int) gmdate('Ymd'));
break;
case '7days':
$q = array('t' => array('$gte' => (int) gmdate('Ymd', time()-604800)));
break;
case 'all':
default:
$q = array();
break;
}
$q['f'] = $funnel;
$props = array();
foreach ($db->funnellogs->find($q) as $log) {
foreach ($log['p'] as $prop => $v) {
if (isset($props[$prop]) and !in_array($v, $props[$prop])) {
$props[$prop][] = $v;
} else {
$props[$prop] = array($v);
}
}
}
return $props;
}
/**
* Get stats for a given funnel.
*
* @param $funnel string Funnel
src/Pluf/AB/Views.php
121121
122122
123123
124
125
124
125
126
127
128
129
130
126131
127132
128133
129134
130135
136
137
131138
132139
133140
$period = $request->REQUEST['p'];
$nperiod = $periods[$request->REQUEST['p']];
}
//'yesterday', ('today'), '7days', 'all'
$stats = Pluf_AB_Funnel::getStats($match[1], $period);
$props = Pluf_AB_Funnel::getFunnelProps($match[1], $period);
$prop = null;
if (isset($request->REQUEST['prop']) and
in_array($request->REQUEST['prop'], array_keys($props))) {
$prop = $request->REQUEST['prop'];
}
$stats = Pluf_AB_Funnel::getStats($match[1], $period, $prop);
return Pluf_Shortcuts_RenderToResponse('pluf/ab/funnel.html',
array('stats' => $stats,
'funnel' => $match[1],
'nperiod' => $nperiod,
'period' => $period,
'props' => $props,
'prop' => $prop,
),
$request);
}
src/Pluf/templates/pluf/ab/base.html
1212
1313
1414
15
16
17
1815
1916
2017
2118
2219
2320
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
2439
2540
2641
......
118133
119134
120135
136
121137
138
139
140
122141
123142
124143
125144
126
127
145
146
147
148
149
150
128151
129152
body {
background: #fff;
font-family: Lucida Grande, Verdana, sans-serif;
padding: 1em 2em;
magrin-left: 100px;
width: 600px;
}
h1, h2 {
font-weight: normal;
}
#main {
width: 600px;
float: left;
position: relative;
margin: 1em 2em;
}
body.funnel #main {
width: 900px;
}
#details {
width: 300px;
float: left;
position: relative;
margin: 1em 2em;
}
hr {
border: 1px solid #d3d7cf;
border-collapse: collapse;
margin-top: 5px;
}
.clear{clear:both;display:block;overflow:hidden;visibility:hidden;width:0;height:0}
td {
vertical-align: bottom;
}
{/literal}
</style>
</head>
<body>
{block body}{/block}
<body{block bodyclass}{/block}>
<div>
<div id="main">{block body}{/block}</div>
<div id="details">{block details}{/block}</div>
<div class="clear"></div>
</div>
</body>
</html>
src/Pluf/templates/pluf/ab/funnel.html
11
2
2
33
44
55
66
77
8
9
10
11
12
13
8
9
10
1411
12
13
14
15
16
1517
1618
1719
1820
1921
22
2023
2124
22
2325
24
2526
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
2650
27
51
2852
2953
3054
......
3458
3559
3660
37
38
61
62
3963
4064
4165
......
4973
5074
5175
52
76
77
78
5379
5480
81
82
83
84
85
86
87
88
89
90
91
92
93
94
{extends "pluf/ab/base.html"}
{block bodyclass} class="funnel"{/block}
{block body}
<p class="right">&raquo; <a href="{url 'pluf_ab_funnels'}">All funnels</a></p>
<h1>Funnel {$funnel} - {$nperiod}</h1>
<p class="right">
<a{if $period == 'today'} class="strong"{/if} href="{url 'pluf_ab_funnel', array($funnel), array('p'=> 'today')}">Today</a> |
<a{if $period == 'yesterday'} class="strong"{/if} href="{url 'pluf_ab_funnel', array($funnel), array('p'=> 'yesterday')}">Yesterday</a> |
<a{if $period == '7days'} class="strong"{/if} href="{url 'pluf_ab_funnel', array($funnel), array('p'=> '7days')}">Last 7 days</a> |
<a{if $period == 'all'} class="strong"{/if} href="{url 'pluf_ab_funnel', array($funnel), array('p'=> 'all')}">All time</a>
<table summary=" ">
<tr>
<td width="600">
<p class="right">
<a{if $period == 'today'} class="strong"{/if} href="{url 'pluf_ab_funnel', array($funnel), array('p'=> 'today', 'prop'=> $prop)}">Today</a> |
<a{if $period == 'yesterday'} class="strong"{/if} href="{url 'pluf_ab_funnel', array($funnel), array('p'=> 'yesterday', 'prop'=> $prop)}">Yesterday</a> |
<a{if $period == '7days'} class="strong"{/if} href="{url 'pluf_ab_funnel', array($funnel), array('p'=> '7days', 'prop'=> $prop)}">Last 7 days</a> |
<a{if $period == 'all'} class="strong"{/if} href="{url 'pluf_ab_funnel', array($funnel), array('p'=> 'all', 'prop'=> $prop)}">All time</a>
</p>
{assign $i=1}
{foreach $stats as $step}{if $step}
{if $i>1}
<p class="right">{$step['total']} ({$step['conv']})<span class="arrow right"></span></p>
{/if}
<h2>Step {$i}: {$step['name']}</h2>
<h2>Step {$i}: {$step['name']}</h2>
</td>
<td>{if $i==1}
{if count($props)}
<h2>Filter by visitor property</h2>
<form method="get" action="{url 'pluf_ab_funnel', array($funnel)}">
<select name="prop">{foreach $props as $k=>$v}
<option value="">All</option>
<option value="{$k}"{if $prop==$k} selected="selected"{/if}>{$k}</option>{/foreach}
</select>
<input type="hidden" name="p" value="{$period}" />
<input type="submit" name="s" value="Filter" />
</form>
{/if}
{elseif isset($step['props'])}{assign $stepprops = $step['props']}
{foreach $stepprops as $k=>$t}
<p>{$k}: {$t}</p>
{/foreach}
{/if}
</td>
</tr>
<tr>
<td>
<p>
{if $i>1}
{if $i>1 and isset($step['conv1'])}
<span class="percent"><span style="width:{$step['conv1']}"></span></span>
{if $step['conv1'] != '100.00%'}<br />
<span class="margin"><span style="width:{$step['conv1']}"></span>{$step['conv1']}</span>{/if}
{blocktrans $t}{$t} unique visitor.{plural}{$t} unique visitors.{/blocktrans}
</p>
{assign $i += 1}
{/if}{/foreach}
{if count($stats)}
{/if}{/foreach}</td></tr></table>
{if count($stats) and isset($stats[$i-1]['conv1'])}
<hr />
{assign $i = $i-1}
{else}
<p>We do not have statistics for this period.</p>
{/if}
{*<pre>
{$stats|dump}
</pre>*}
{/block}
{block details} {*
{if count($props)}
<h2 style="margin-top: 4.5em;">Filter by visitor property</h2>
<form method="get" action="{url 'pluf_ab_funnel', array($funnel)}">
<select name="prop">{foreach $props as $k=>$v}
<option value="">All</option>
<option value="{$k}"{if $prop==$k} selected="selected"{/if}>{$k}</option>{/foreach}
</select>
<input type="hidden" name="p" value="{$period}" />
<input type="submit" name="s" value="Filter" />
</form>
{/if}
*}
{/block}

Archive Download the corresponding diff file

Branches

Tags

Number of commits:
Page rendered in 0.06646s using 13 queries.