Skip to content
GitLab
Menu
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
798c556e
Commit
798c556e
authored
Oct 02, 2007
by
Richard Mansfield
Committed by
Nigel McNie
Oct 17, 2007
Browse files
Put general table rendering stuff in separate template
parent
c98fc782
Changes
9
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/searchlib.php
View file @
798c556e
...
...
@@ -118,23 +118,6 @@ function search_user($query_string, $limit, $offset = 0) {
function
build_admin_user_search_results
(
$search
,
$offset
,
$limit
,
$sortby
,
$sortdir
)
{
$smarty
=
smarty_core
();
$params
=
array
();
foreach
(
$search
as
$k
=>
$v
)
{
if
(
!
empty
(
$v
))
{
$params
[]
=
$k
.
'='
.
$v
;
}
}
$params
[]
=
'limit='
.
$limit
;
$params
=
join
(
'&'
,
$params
);
$smarty
->
assign_by_ref
(
'params'
,
$params
);
$smarty
->
assign_by_ref
(
'sortby'
,
$sortby
);
$smarty
->
assign_by_ref
(
'sortdir'
,
$sortdir
);
$fieldnames
=
array
(
'firstname'
,
'lastname'
,
'username'
,
'email'
,
'institution'
);
$smarty
->
assign_by_ref
(
'fieldnames'
,
$fieldnames
);
// In admin search, the search string is interpreted as either a
// name search or an email search depending on its contents
$queries
=
array
();
...
...
@@ -171,20 +154,46 @@ function build_admin_user_search_results($search, $offset, $limit, $sortby, $sor
$results
=
admin_user_search
(
$queries
,
$constraints
,
$offset
,
$limit
,
$sortby
,
$sortdir
);
$url
=
get_config
(
'wwwroot'
)
.
'admin/users/search.php?'
.
$params
.
'&sortby='
.
$sortby
.
'&sortdir='
.
$sortdir
;
$pagelinks
=
table_page_links
(
$results
[
'limit'
],
$results
[
'offset'
],
$results
[
'count'
],
$url
);
$smarty
->
assign_by_ref
(
'pagelinks'
,
$pagelinks
);
$params
=
array
();
foreach
(
$search
as
$k
=>
$v
)
{
if
(
!
empty
(
$v
))
{
$params
[]
=
$k
.
'='
.
$v
;
}
}
$searchurl
=
get_config
(
'wwwroot'
)
.
'admin/users/search.php?'
.
join
(
'&'
,
$params
)
.
'&limit='
.
$limit
;
$templatedir
=
get_config
(
'docroot'
)
.
'theme/'
.
get_config
(
'theme'
)
.
'/templates/admin/users/'
;
$cols
=
array
(
'icon'
=>
array
(
'name'
=>
''
,
'template'
=>
file_get_contents
(
$templatedir
.
'icon.tpl'
)),
'firstname'
=>
array
(
'name'
=>
get_string
(
'firstname'
)),
'lastname'
=>
array
(
'name'
=>
get_string
(
'lastname'
)),
'username'
=>
array
(
'name'
=>
get_string
(
'username'
),
'template'
=>
file_get_contents
(
$templatedir
.
'username.tpl'
)),
'email'
=>
array
(
'name'
=>
get_string
(
'email'
)),
'institution'
=>
array
(
'name'
=>
get_string
(
'institution'
),
'template'
=>
file_get_contents
(
$templatedir
.
'institution.tpl'
)),
'suspend'
=>
array
(
'name'
=>
''
,
'template'
=>
file_get_contents
(
$templatedir
.
'suspendlink.tpl'
))
);
$smarty
=
smarty_core
();
$smarty
->
assign_by_ref
(
'results'
,
$results
);
$smarty
->
assign_by_ref
(
'institutions'
,
get_records_assoc
(
'institution'
,
''
,
''
,
''
,
'name,displayname'
));
return
$smarty
->
fetch
(
'admin/users/resulttable.tpl'
);
$smarty
->
assign
(
'searchurl'
,
$searchurl
);
$smarty
->
assign
(
'sortby'
,
$sortby
);
$smarty
->
assign
(
'sortdir'
,
$sortdir
);
$smarty
->
assign
(
'pagebaseurl'
,
$searchurl
.
'&sortby='
.
$sortby
.
'&sortdir='
.
$sortdir
);
$smarty
->
assign
(
'cols'
,
$cols
);
$smarty
->
assign
(
'ncols'
,
count
(
$cols
));
return
$smarty
->
fetch
(
'searchresulttable.tpl'
);
}
function
admin_user_search
(
$queries
,
$constraints
,
$offset
,
$limit
,
$sortfield
,
$sortdir
)
{
$plugin
=
get_config
(
'searchplugin'
);
//$plugin='internal';
safe_require
(
'search'
,
$plugin
);
return
call_static_method
(
generate_class_name
(
'search'
,
$plugin
),
'admin_search_user'
,
$queries
,
$constraints
,
$offset
,
$limit
,
$sortfield
,
$sortdir
);
...
...
htdocs/lib/smarty/plugins/function.mahara_pagelinks.php
0 → 100644
View file @
798c556e
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Creates pagination links for a table
* appends an 'offset=n' parameter to the url to get the url for a different page
* @param integer $limit number of items per page
* @param integer $offset offset of first data item on this page
* @param integer $count total number of items
* @param string $url where to get results from
* @return string
*/
function
smarty_function_mahara_pagelinks
(
$params
,
&
$smarty
)
{
$output
=
''
;
if
(
$params
[
'limit'
]
<=
$params
[
'count'
])
{
$pages
=
ceil
(
$params
[
'count'
]
/
$params
[
'limit'
]);
$page
=
$params
[
'offset'
]
/
$params
[
'limit'
];
$last
=
$pages
-
1
;
$next
=
min
(
$last
,
$page
+
1
);
$prev
=
max
(
0
,
$page
-
1
);
$pagenumbers
=
array_values
(
array
(
0
=>
0
,
$prev
=>
$prev
,
$page
=>
$page
,
$next
=>
$next
,
$last
=>
$last
));
if
(
$page
!=
0
)
{
$output
.
=
mahara_pagelink
(
'prev'
,
$params
[
'url'
],
$params
[
'limit'
]
*
$prev
,
get_string
(
'prevpage'
));
}
foreach
(
$pagenumbers
as
$k
=>
$i
)
{
if
(
$k
!=
0
&&
$prevpagenum
<
$i
-
1
)
{
$output
.
=
'...'
;
}
$output
.
=
mahara_pagelink
(
$i
==
$page
?
' selected'
:
''
,
$params
[
'url'
],
$params
[
'limit'
]
*
$i
,
$i
+
1
);
$prevpagenum
=
$i
;
}
if
(
$page
<
$pages
-
1
)
{
$output
.
=
mahara_pagelink
(
'next'
,
$params
[
'url'
],
$params
[
'limit'
]
*
$next
,
get_string
(
'nextpage'
));
}
}
if
(
!
empty
(
$params
[
'assign'
]))
{
$smarty
->
assign
(
$params
[
'assign'
],
$output
);
return
;
}
return
$output
;
}
function
mahara_pagelink
(
$class
,
$url
,
$offset
,
$text
)
{
return
'<span class="search-results-page'
.
(
!
empty
(
$class
)
?
"
$class
"
:
''
)
.
'"><a href="'
.
$url
.
'&offset='
.
$offset
.
'">'
.
$text
.
'</a></span>'
.
"
\n
"
;
}
?>
\ No newline at end of file
htdocs/lib/web.php
View file @
798c556e
...
...
@@ -1822,42 +1822,5 @@ function clean_attributes_2($htmlArray) {
}
/**
* Creates pagination links for a table
* appends an 'offset=n' parameter to the url to get the url for a different page
* @param integer $limit number of items per page
* @param integer $offset offset of first data item on this page
* @param integer $count total number of items
* @param string $url where to get results from
* @return string
*/
function
table_page_links
(
$limit
,
$offset
,
$count
,
$url
)
{
if
(
$limit
<=
$count
)
{
$pages
=
ceil
(
$count
/
$limit
);
$page
=
$offset
/
$limit
;
$last
=
$pages
-
1
;
$next
=
min
(
$last
,
$page
+
1
);
$prev
=
max
(
0
,
$page
-
1
);
$pagenumbers
=
array_values
(
array
(
0
=>
0
,
$prev
=>
$prev
,
$page
=>
$page
,
$next
=>
$next
,
$last
=>
$last
));
$smarty
=
smarty_core
();
$smarty
->
assign_by_ref
(
'pagenumbers'
,
$pagenumbers
);
$smarty
->
assign_by_ref
(
'prev'
,
$prev
);
$smarty
->
assign_by_ref
(
'page'
,
$page
);
$smarty
->
assign_by_ref
(
'pages'
,
$pages
);
$smarty
->
assign_by_ref
(
'next'
,
$next
);
$smarty
->
assign_by_ref
(
'limit'
,
$limit
);
$smarty
->
assign_by_ref
(
'url'
,
$url
);
return
$smarty
->
fetch
(
'pager.tpl'
);
}
return
''
;
}
?>
htdocs/theme/default/templates/admin/users/icon.tpl
0 → 100644
View file @
798c556e
<img
src=
"
{
$WWWROOT
}
thumb.php?type=profileicon&size=40x40&id=
{
$r.id
}
"
alt=
"
{
str
tag
=
profileimage
}
"
/>
\ No newline at end of file
htdocs/theme/default/templates/admin/users/institution.tpl
0 → 100644
View file @
798c556e
{
$institutions
[
$r.institution
]->
displayname
}
\ No newline at end of file
htdocs/theme/default/templates/admin/users/resulttable.tpl
deleted
100644 → 0
View file @
c98fc782
{
if
!
empty
(
$results.data
)
}
<h3>
{
str
tag
=
"results"
}
</h3>
<table
id=
"searchresults"
class=
"tablerenderer"
>
<thead>
{
if
!
empty
(
$pagelinks
)
}
<tr
class=
"search-results-pages"
>
<td
colspan=
7
>
{
$pagelinks
}
</td>
</tr>
{/
if
}
<tr>
<th></th>
{
foreach
from
=
$fieldnames
item
=
f
}
<th
class=
"search-results-sort-column
{
if
$f
==
$sortby
}
{
$sortdir
}{/
if
}
"
><a
href=
"?
{
$params
}
&sortby=
{
$f
}
&sortdir=
{
if
$f
==
$sortby
&&
$sortdir
==
'asc'
}
desc
{
else
}
asc
{/
if
}
"
>
{
str
tag
=
"$f"
}
</a></th>
{/
foreach
}
<th></th>
</tr>
</thead>
<tbody>
{
foreach
from
=
$results.data
item
=
r
}
<tr>
<td><img
src=
"
{
$WWWROOT
}
thumb.php?type=profileicon&size=40x40&id=
{
$r.id
}
"
alt=
"
{
str
tag
=
profileimage
}
"
/></td>
<td>
{
$r.firstname
}
</td>
<td>
{
$r.lastname
}
</td>
<td><a
href=
"
{
$WWWROOT
}
user/view.php?id=
{
$r.id
}
"
>
{
$r.username
}
</a></td>
<td>
{
$r.email
}
</td>
<td>
{
$institutions
[
$r.institution
]->
displayname
}
</td>
<td><a
class=
"suspend-user-link"
href=
"
{
$WWWROOT
}
admin/users/suspend.php?id=
{
$r.id
}
"
>
{
str
tag
=
suspenduser
section
=
admin
}
</a></td>
</tr>
{/
foreach
}
</tbody>
{
if
!
empty
(
$pagelinks
)
}
<tfoot>
<tr
class=
"search-results-pages"
>
<td
colspan=
7
>
{
$pagelinks
}
</td>
</tr>
</tfoot>
{/
if
}
</table>
{
else
}
<div>
{
str
tag
=
"noresultsfound"
}
</div>
{/
if
}
htdocs/theme/default/templates/admin/users/suspendlink.tpl
0 → 100644
View file @
798c556e
<a
class=
"suspend-user-link"
href=
"
{
$WWWROOT
}
admin/users/suspend.php?id=
{
$r.id
}
"
>
{
str
tag
=
suspenduser
section
=
admin
}
</a>
\ No newline at end of file
htdocs/theme/default/templates/admin/users/username.tpl
0 → 100644
View file @
798c556e
<a
href=
"
{
$WWWROOT
}
user/view.php?id=
{
$r.id
}
"
>
{
$r.username
}
</a>
\ No newline at end of file
htdocs/theme/default/templates/searchresulttable.tpl
0 → 100644
View file @
798c556e
{
if
!
empty
(
$results.data
)
}
<h3>
{
str
tag
=
"results"
}
</h3>
<table
id=
"searchresults"
class=
"tablerenderer"
>
<thead>
{
mahara_pagelinks
offset
=
$results.offset
limit
=
$results.limit
count
=
$results.count
url
=
$pagebaseurl
assign
=
pagelinks
}
{
if
(!
empty
(
$pagelinks
))
}
<tr
class=
"search-results-pages"
>
<td
colspan=
{
$ncols
}
>
{
$pagelinks
}
</td
>
</tr>
{/
if
}
<tr>
{
foreach
from
=
$cols
key
=
f
item
=
c
}
{
if
empty
(
$c.name
)
}
<th></th>
{
else
}
<th
class=
"search-results-sort-column
{
if
$f
==
$sortby
}
{
$sortdir
}{/
if
}
"
>
<a
href=
"
{
$searchurl
}
&sortby=
{
$f
}
&sortdir=
{
if
$f
==
$sortby
&&
$sortdir
==
'asc'
}
desc
{
else
}
asc
{/
if
}
"
>
{
$c.name
}
</a>
</th>
{/
if
}
{/
foreach
}
</tr>
</thead>
<tbody>
{
foreach
from
=
$results.data
item
=
r
}
<tr>
{
foreach
from
=
$cols
key
=
f
item
=
c
}
{
if
empty
(
$c.template
)
}
<td>
{
$r
[
$f
]
}
</td>
{
else
}
<td>
{
eval
var
=
$c.template
}
</td>
{/
if
}
{/
foreach
}
</tr>
{/
foreach
}
</tbody>
{
if
(!
empty
(
$pagelinks
))
}
<tfoot>
<tr
class=
"search-results-pages"
>
<td
colspan=
{
$ncols
}
>
{
$pagelinks
}
</td
>
</tr>
</tfoot>
{/
if
}
</table>
{
else
}
<div>
{
str
tag
=
"noresultsfound"
}
</div>
{/
if
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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