Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
9c1e947c
Commit
9c1e947c
authored
Apr 19, 2010
by
Richard Mansfield
Browse files
Add pie graphs for view types & group types
Signed-off-by:
Richard Mansfield
<
richardm@catalyst.net.nz
>
parent
c9457a4a
Changes
6
Hide whitespace changes
Inline
Side-by-side
htdocs/admin/thumb.php
View file @
9c1e947c
...
...
@@ -34,6 +34,8 @@ $type = param_alpha('type');
switch
(
$type
)
{
case
'weekly'
:
case
'institutions'
:
case
'viewtypes'
:
case
'grouptypes'
:
$maxage
=
3600
;
header
(
'Content-type: '
.
'image/png'
);
header
(
'Expires: '
.
gmdate
(
'D, d M Y H:i:s'
,
time
()
+
$maxage
)
.
' GMT'
);
...
...
htdocs/lang/en.utf8/admin.php
View file @
9c1e947c
...
...
@@ -176,6 +176,7 @@ $string['Rank'] = 'Rank';
$string
[
'rankingsupdated'
]
=
'Rankings last updated: %s'
;
$string
[
'uptodate'
]
=
'up to date'
;
$string
[
'latestversionis'
]
=
'latest version is <a href="%s">%s</a>'
;
$string
[
'viewsbytype'
]
=
'Views by Type'
;
// Site options
$string
[
'adminsonly'
]
=
'Administrators only'
;
...
...
htdocs/lang/en.utf8/view.php
View file @
9c1e947c
...
...
@@ -291,4 +291,8 @@ $string['viewcopywouldexceedquota'] = 'Copying this View would exceed your file
$string
[
'blockcopypermission'
]
=
'Block copy permission'
;
$string
[
'blockcopypermissiondesc'
]
=
'If you allow other users to copy this View, you may choose how this block will be copied'
;
// View types
$string
[
'profile'
]
=
'Profile'
;
$string
[
'portfolio'
]
=
'Portfolio'
;
?>
htdocs/lib/registration.php
View file @
9c1e947c
...
...
@@ -456,6 +456,50 @@ function user_stats_table($limit, $offset) {
return
$result
;
}
function
user_institution_graph
()
{
// Draw a bar graph showing the number of users in each institution
require_once
(
get_config
(
'libroot'
)
.
'institution.php'
);
$institutions
=
Institution
::
count_members
(
false
,
true
);
if
(
count
(
$institutions
)
>
1
)
{
$dataarray
=
array
();
foreach
(
$institutions
as
&
$i
)
{
$dataarray
[
$i
->
displayname
]
=
$i
->
members
;
}
arsort
(
$dataarray
);
require_once
(
get_config
(
'libroot'
)
.
"pear/Image/Graph.php"
);
$Graph
=&
Image_Graph
::
factory
(
'graph'
,
array
(
300
,
200
));
$Font
=&
$Graph
->
addNew
(
'font'
,
'Vera'
);
$Font
->
setSize
(
9
);
$Graph
->
setFont
(
$Font
);
$Graph
->
add
(
Image_Graph
::
vertical
(
Image_Graph
::
factory
(
'title'
,
array
(
get_string
(
'institutionmembers'
,
'admin'
),
9
)),
$Plotarea
=
Image_Graph
::
factory
(
'plotarea'
),
5
)
);
$Dataset
=&
Image_Graph
::
factory
(
'dataset'
,
array
(
$dataarray
));
$Plot
=&
$Plotarea
->
addNew
(
'bar'
,
array
(
&
$Dataset
));
$Plot
->
setLineColor
(
'gray'
);
$FillArray
=&
Image_Graph
::
factory
(
'Image_Graph_Fill_Array'
);
$Plot
->
setFillStyle
(
$FillArray
);
$FillArray
->
addColor
(
'blue@0.6'
);
$FillArray
->
addColor
(
'green@0.6'
);
$FillArray
->
addColor
(
'red@0.6'
);
$FillArray
->
addColor
(
'yellow@0.6'
);
$FillArray
->
addColor
(
'orange@0.6'
);
$Graph
->
done
(
array
(
'filename'
=>
get_config
(
'dataroot'
)
.
'institutions.png'
));
}
}
function
group_statistics
(
$limit
,
$offset
)
{
$data
=
array
();
$data
[
'tableheadings'
]
=
array
(
...
...
@@ -483,6 +527,10 @@ function group_statistics($limit, $offset) {
GROUP BY jointype
ORDER BY groups DESC"
,
array
()
));
if
(
file_exists
(
get_config
(
'dataroot'
)
.
'grouptypes.png'
))
{
$smarty
->
assign
(
'groupgraph'
,
get_config
(
'wwwroot'
)
.
'admin/thumb.php?type=grouptypes'
);
}
$data
[
'summary'
]
=
$smarty
->
fetch
(
'admin/groupstatssummary.tpl'
);
return
$data
;
...
...
@@ -557,6 +605,60 @@ function group_stats_table($limit, $offset) {
return
$result
;
}
function
group_type_graph
()
{
$grouptypes
=
get_records_sql_array
(
"
SELECT grouptype, jointype, COUNT(id) AS groups
FROM
{
group
}
WHERE deleted = 0
GROUP BY grouptype, jointype
ORDER BY groups DESC"
,
array
()
);
if
(
count
(
$grouptypes
)
>
1
)
{
$dataarray
=
array
();
foreach
(
$grouptypes
as
&
$t
)
{
$strtype
=
get_string
(
'name'
,
'grouptype.'
.
$t
->
grouptype
);
$strjoin
=
get_string
(
'membershiptype.'
.
$t
->
jointype
,
'group'
);
$dataarray
[
$strtype
.
': '
.
$strjoin
]
=
$t
->
groups
;
}
arsort
(
$dataarray
);
require_once
(
get_config
(
'libroot'
)
.
"pear/Image/Graph.php"
);
$Graph
=&
Image_Graph
::
factory
(
'graph'
,
array
(
300
,
200
));
$Font
=&
$Graph
->
addNew
(
'font'
,
'Vera'
);
$Font
->
setSize
(
9
);
$Graph
->
setFont
(
$Font
);
$Graph
->
add
(
$Plotarea
=
Image_Graph
::
factory
(
'plotarea'
)
);
$Plotarea
->
hideAxis
();
$Dataset
=&
Image_Graph
::
factory
(
'dataset'
,
array
(
$dataarray
));
$Plot
=&
$Plotarea
->
addNew
(
'pie'
,
array
(
&
$Dataset
));
$Plot
->
setLineColor
(
'black'
);
$FillArray
=&
Image_Graph
::
factory
(
'Image_Graph_Fill_Array'
);
$Plot
->
setFillStyle
(
$FillArray
);
$FillArray
->
addColor
(
'blue@0.6'
);
$FillArray
->
addColor
(
'green@0.6'
);
$FillArray
->
addColor
(
'red@0.6'
);
$FillArray
->
addColor
(
'yellow@0.6'
);
$FillArray
->
addColor
(
'orange@0.6'
);
$Marker
=&
$Plot
->
addNew
(
'Image_Graph_Marker_Value'
,
IMAGE_GRAPH_VALUE_X
);
$Marker
->
setBorderColor
(
'white'
);
$Marker
->
setFontSize
(
8
);
$PointingMarker
=&
$Plot
->
addNew
(
'Image_Graph_Marker_Pointing_Angular'
,
array
(
20
,
&
$Marker
));
$Plot
->
setMarker
(
$PointingMarker
);
$Graph
->
done
(
array
(
'filename'
=>
get_config
(
'dataroot'
)
.
'grouptypes.png'
));
}
}
function
view_statistics
(
$limit
,
$offset
)
{
$data
=
array
();
$data
[
'tableheadings'
]
=
array
(
...
...
@@ -568,6 +670,10 @@ function view_statistics($limit, $offset) {
);
$data
[
'table'
]
=
view_stats_table
(
$limit
,
$offset
);
if
(
file_exists
(
get_config
(
'dataroot'
)
.
'viewtypes.png'
))
{
$viewtypes
=
get_config
(
'wwwroot'
)
.
'admin/thumb.php?type=viewtypes'
;
}
$smarty
=
smarty_core
();
$maxblocktypes
=
5
;
$smarty
->
assign
(
'blocktypecounts'
,
get_records_sql_array
(
"
...
...
@@ -583,6 +689,7 @@ function view_statistics($limit, $offset) {
ORDER BY blocks DESC"
,
array
(),
0
,
$maxblocktypes
));
$smarty
->
assign
(
'viewtypes'
,
$viewtypes
);
$data
[
'summary'
]
=
$smarty
->
fetch
(
'admin/viewstatssummary.tpl'
);
return
$data
;
...
...
@@ -641,6 +748,63 @@ function view_stats_table($limit, $offset) {
return
$result
;
}
function
view_type_graph
()
{
// Draw a pie graph of views broken down by view type.
$viewtypes
=
get_records_sql_array
(
'
SELECT type, COUNT(id) AS views
FROM {view}
GROUP BY type'
,
array
()
);
if
(
count
(
$viewtypes
)
>
1
)
{
$dataarray
=
array
();
foreach
(
$viewtypes
as
&
$t
)
{
$dataarray
[
get_string
(
$t
->
type
,
'view'
)]
=
$t
->
views
;
}
arsort
(
$dataarray
);
require_once
(
get_config
(
'libroot'
)
.
"pear/Image/Graph.php"
);
$Graph
=&
Image_Graph
::
factory
(
'graph'
,
array
(
300
,
200
));
$Font
=&
$Graph
->
addNew
(
'font'
,
'Vera'
);
$Font
->
setSize
(
9
);
$Graph
->
setFont
(
$Font
);
$Graph
->
add
(
Image_Graph
::
vertical
(
Image_Graph
::
factory
(
'title'
,
array
(
get_string
(
'viewsbytype'
,
'admin'
),
9
)),
$Plotarea
=
Image_Graph
::
factory
(
'plotarea'
),
5
)
);
$Plotarea
->
hideAxis
();
$Dataset
=&
Image_Graph
::
factory
(
'dataset'
,
array
(
$dataarray
));
$Plot
=&
$Plotarea
->
addNew
(
'pie'
,
array
(
&
$Dataset
));
$Plot
->
setLineColor
(
'black'
);
$FillArray
=&
Image_Graph
::
factory
(
'Image_Graph_Fill_Array'
);
$Plot
->
setFillStyle
(
$FillArray
);
$FillArray
->
addColor
(
'blue@0.6'
);
$FillArray
->
addColor
(
'green@0.6'
);
$FillArray
->
addColor
(
'red@0.6'
);
$FillArray
->
addColor
(
'yellow@0.6'
);
$FillArray
->
addColor
(
'orange@0.6'
);
$Marker
=&
$Plot
->
addNew
(
'Image_Graph_Marker_Value'
,
IMAGE_GRAPH_VALUE_X
);
$Marker
->
setBorderColor
(
'white'
);
$Marker
->
setFontSize
(
8
);
$PointingMarker
=&
$Plot
->
addNew
(
'Image_Graph_Marker_Pointing_Angular'
,
array
(
20
,
&
$Marker
));
$Plot
->
setMarker
(
$PointingMarker
);
$Graph
->
done
(
array
(
'filename'
=>
get_config
(
'dataroot'
)
.
'viewtypes.png'
));
}
}
function
graph_site_data_weekly
()
{
$lastyear
=
db_format_timestamp
(
time
()
-
60
*
60
*
12
*
365
);
...
...
@@ -664,7 +828,7 @@ function graph_site_data_weekly() {
$Graph
=&
Image_Graph
::
factory
(
'graph'
,
array
(
300
,
200
));
$Font
=&
$Graph
->
addNew
(
'font'
,
'Vera'
);
$Font
->
setSize
(
8
);
$Font
->
setSize
(
9
);
$Graph
->
setFont
(
$Font
);
$Graph
->
add
(
...
...
@@ -678,9 +842,9 @@ function graph_site_data_weekly() {
$Legend
->
setPlotarea
(
$Plotarea
);
$datasetinfo
=
array
(
'user-count'
=>
array
(
'color'
=>
'
red
@0.
4
'
,
'name'
=>
get_string
(
'users'
)),
'view-count'
=>
array
(
'color'
=>
'green@0.
4
'
,
'name'
=>
get_string
(
'views'
)),
'group-count'
=>
array
(
'color'
=>
'
blue
@0.
4
'
,
'name'
=>
get_string
(
'groups'
)),
'user-count'
=>
array
(
'color'
=>
'
blue
@0.
6
'
,
'name'
=>
get_string
(
'users'
)),
'view-count'
=>
array
(
'color'
=>
'green@0.
6
'
,
'name'
=>
get_string
(
'views'
)),
'group-count'
=>
array
(
'color'
=>
'
red
@0.
6
'
,
'name'
=>
get_string
(
'groups'
)),
);
$yaxis
=
array
(
'min'
=>
array
(),
'max'
=>
array
());
...
...
@@ -707,36 +871,9 @@ function graph_site_data_weekly() {
}
function
graph_site_data_daily
()
{
// Bar graph of number of users in each institution
require_once
(
get_config
(
'libroot'
)
.
'institution.php'
);
$institutions
=
Institution
::
count_members
(
false
,
true
);
if
(
count
(
$institutions
)
>
1
)
{
$dataarray
=
array
();
foreach
(
$institutions
as
&
$i
)
{
$dataarray
[
$i
->
displayname
]
=
$i
->
members
;
}
arsort
(
$dataarray
);
require_once
(
get_config
(
'libroot'
)
.
"pear/Image/Graph.php"
);
$Graph
=&
Image_Graph
::
factory
(
'graph'
,
array
(
300
,
200
));
$Font
=&
$Graph
->
addNew
(
'font'
,
'Vera'
);
$Font
->
setSize
(
8
);
$Graph
->
setFont
(
$Font
);
$Graph
->
add
(
$Plotarea
=
Image_Graph
::
factory
(
'plotarea'
)
);
$Dataset
=&
Image_Graph
::
factory
(
'dataset'
,
array
(
$dataarray
));
$Plot
=&
$Plotarea
->
addNew
(
'bar'
,
array
(
&
$Dataset
));
$Plot
->
setLineColor
(
'gray'
);
$Plot
->
setFillColor
(
'blue@0.2'
);
$Graph
->
done
(
array
(
'filename'
=>
get_config
(
'dataroot'
)
.
'institutions.png'
));
}
// @todo: Pie graph of views broken down by view type.
user_institution_graph
();
group_type_graph
();
view_type_graph
();
}
?>
htdocs/theme/raw/templates/admin/groupstatssummary.tpl
View file @
9c1e947c
...
...
@@ -12,4 +12,6 @@
{/
foreach
}
</ul>
</p>
{
if
$groupgraph
}
<img
src=
"
{
$groupgraph
}
"
alt=
""
/>
{/
if
}
htdocs/theme/raw/templates/admin/viewstatssummary.tpl
View file @
9c1e947c
...
...
@@ -7,4 +7,7 @@
</ul>
</p>
{/
if
}
{
if
$viewtypes
}
<img
src=
"
{
$viewtypes
}
"
alt=
""
/>
{/
if
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment