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
4333791b
Commit
4333791b
authored
Aug 16, 2010
by
Richard Mansfield
Browse files
Fixes for blog pagination in html export (bug #617155)
Signed-off-by:
Richard Mansfield
<
richardm@catalyst.net.nz
>
parent
a3eb4e93
Changes
10
Hide whitespace changes
Inline
Side-by-side
htdocs/artefact/blog/blocktype/blog/lib.php
View file @
4333791b
...
...
@@ -57,6 +57,7 @@ class PluginBlocktypeBlog extends PluginBlocktype {
}
public
static
function
render_instance
(
BlockInstance
$instance
,
$editing
=
false
)
{
global
$exporter
;
$configdata
=
$instance
->
get
(
'configdata'
);
$result
=
''
;
...
...
@@ -75,19 +76,28 @@ class PluginBlocktypeBlog extends PluginBlocktype {
$limit
=
isset
(
$configdata
[
'count'
])
?
intval
(
$configdata
[
'count'
])
:
5
;
$posts
=
ArtefactTypeBlogpost
::
get_posts
(
$blog
->
get
(
'id'
),
$limit
,
0
,
$configdata
);
$template
=
'artefact:blog:viewposts.tpl'
;
$pagination
=
array
(
'baseurl'
=>
$instance
->
get_view
()
->
get_url
()
.
'&block='
.
$instance
->
get
(
'id'
),
'id'
=>
'blogpost_pagination_'
.
$instance
->
get
(
'id'
),
'datatable'
=>
'postlist_'
.
$instance
->
get
(
'id'
),
'jsonscript'
=>
'artefact/blog/posts.json.php'
,
);
if
(
$exporter
)
{
$pagination
=
false
;
}
else
{
$pagination
=
array
(
'baseurl'
=>
$instance
->
get_view
()
->
get_url
()
.
'&block='
.
$instance
->
get
(
'id'
),
'id'
=>
'blogpost_pagination_'
.
$instance
->
get
(
'id'
),
'datatable'
=>
'postlist_'
.
$instance
->
get
(
'id'
),
'jsonscript'
=>
'artefact/blog/posts.json.php'
,
);
}
ArtefactTypeBlogpost
::
render_posts
(
$posts
,
$template
,
$configdata
,
$pagination
);
$smarty
=
smarty_core
();
if
(
isset
(
$configdata
[
'viewid'
]))
{
$smarty
->
assign
(
'artefacttitle'
,
'<a href="'
.
get_config
(
'wwwroot'
)
.
'view/artefact.php?artefact='
.
$blog
->
get
(
'id'
)
.
'&view='
.
$configdata
[
'viewid'
]
.
'">'
.
hsc
(
$blog
->
get
(
'title'
))
.
'</a>'
);
$artefacturl
=
get_config
(
'wwwroot'
)
.
'view/artefact.php?artefact='
.
$blog
->
get
(
'id'
)
.
'&view='
.
$configdata
[
'viewid'
];
$smarty
->
assign
(
'artefacttitle'
,
'<a href="'
.
$artefacturl
.
'">'
.
hsc
(
$blog
->
get
(
'title'
))
.
'</a>'
);
if
(
$exporter
&&
$posts
[
'count'
]
>
$limit
)
{
$posts
[
'pagination'
]
=
'<a href="'
.
$artefacturl
.
'">'
.
get_string
(
'allposts'
,
'artefact.blog'
)
.
'</a>'
;
}
}
else
{
$smarty
->
assign
(
'artefacttitle'
,
hsc
(
$blog
->
get
(
'title'
)));
...
...
htdocs/artefact/blog/export/html/lib.php
View file @
4333791b
...
...
@@ -62,8 +62,8 @@ class HtmlExportBlog extends HtmlExportArtefactPlugin {
$postcount
=
$artefact
->
count_published_posts
();
$perpage
=
ArtefactTypeBlog
::
pagination
;
if
(
$postcount
>
$perpage
)
{
for
(
$i
=
2
;
$i
<=
ceil
(
$postcount
/
$perpage
)
;
$i
++
)
{
$rendered
=
$artefact
->
render_self
(
array
(
'
page
'
=>
$i
));
for
(
$i
=
$perpage
;
$i
<=
$postcount
;
$i
+=
$perpage
)
{
$rendered
=
$artefact
->
render_self
(
array
(
'
limit'
=>
$perpage
,
'offset
'
=>
$i
));
$smarty
->
assign
(
'rendered_blog'
,
$outputfilter
->
filter
(
$rendered
[
'html'
]));
$content
=
$smarty
->
fetch
(
'export:html/blog:index.tpl'
);
...
...
htdocs/artefact/blog/lang/en.utf8/artefact.blog.php
View file @
4333791b
...
...
@@ -35,6 +35,7 @@ $string['addblog'] = 'Create Blog';
$string
[
'addpost'
]
=
'New Post'
;
$string
[
'alignment'
]
=
'Alignment'
;
$string
[
'allowcommentsonpost'
]
=
'Allow comments on your post.'
;
$string
[
'allposts'
]
=
'All posts'
;
$string
[
'attach'
]
=
'Attach'
;
$string
[
'attachedfilelistloaded'
]
=
'Attached file list loaded'
;
$string
[
'attachedfiles'
]
=
'Attached files'
;
...
...
htdocs/artefact/blog/lib.php
View file @
4333791b
...
...
@@ -219,7 +219,10 @@ class ArtefactTypeBlog extends ArtefactType {
$template
=
'artefact:blog:viewposts.tpl'
;
$baseurl
=
get_config
(
'wwwroot'
)
.
'view/artefact.php?artefact='
.
$this
->
id
.
'&view='
.
$options
[
'viewid'
];
$baseurl
=
get_config
(
'wwwroot'
)
.
'view/artefact.php?artefact='
.
$this
->
id
;
if
(
!
empty
(
$options
[
'viewid'
]))
{
$baseurl
.
=
'&view='
.
$options
[
'viewid'
];
}
$pagination
=
array
(
'baseurl'
=>
$baseurl
,
'id'
=>
'blogpost_pagination'
,
...
...
@@ -670,8 +673,8 @@ class ArtefactTypeBlogPost extends ArtefactType {
$posts
[
'tablerows'
]
=
$smarty
->
fetch
(
$template
);
if
(
$posts
[
'limit'
])
{
$pagination
=
build_pagination
(
array
(
if
(
$posts
[
'limit'
]
&&
$pagination
)
{
$pagination
=
build_pagination
(
$foo
=
array
(
'id'
=>
$pagination
[
'id'
],
'class'
=>
'center'
,
'datatable'
=>
$pagination
[
'datatable'
],
...
...
htdocs/artefact/blog/theme/raw/blog.tpl
View file @
4333791b
...
...
@@ -10,10 +10,14 @@
{
$posts.tablerows
|
safe
}
</tbody>
</table>
{
if
$posts.pagination
}
<div
id=
"blogpost_page_container_
{
$blockid
}
"
class=
"hidden center"
>
{
$posts.pagination
|
safe
}
</div>
{/
if
}
{
if
$posts.pagination_js
}
<script>
addLoadEvent
(
function
()
{
literal
}{{/
literal
}
{
$posts.pagination_js
|
safe
}
removeElementClass
(
'blogpost_page_container_{$blockid}'
,
'hidden'
);
{
literal
}}{/
literal
}
);
</script>
{/
if
}
htdocs/blocktype/myfriends/lib.php
View file @
4333791b
...
...
@@ -56,6 +56,11 @@ class PluginBlocktypeMyfriends extends SystemBlocktype {
$smarty
=
smarty_core
();
$smarty
->
assign_by_ref
(
'friends'
,
$friendarray
);
$friends
[
'tablerows'
]
=
$smarty
->
fetch
(
'blocktype:myfriends:myfriendrows.tpl'
);
if
(
$friends
[
'limit'
]
===
false
)
{
return
;
}
$baseurl
=
$instance
->
get_view
()
->
get_url
()
.
'&block='
.
$instance
->
get
(
'id'
);
$baseurl
.
=
'&user='
.
(
int
)
$userid
;
$pagination
=
build_pagination
(
array
(
...
...
@@ -76,14 +81,17 @@ class PluginBlocktypeMyfriends extends SystemBlocktype {
}
public
static
function
render_instance
(
BlockInstance
$instance
,
$editing
=
false
)
{
global
$USER
;
global
$USER
,
$exporter
;
$userid
=
$instance
->
get_view
()
->
get
(
'owner'
);
if
(
!
$userid
)
{
// 'My Friends' doesn't make sense for group/site views
return
''
;
}
$friends
=
get_friends
(
$userid
,
MAXFRIENDDISPLAY
,
0
);
$limit
=
isset
(
$exporter
)
?
false
:
MAXFRIENDDISPLAY
;
$friends
=
get_friends
(
$userid
,
$limit
,
0
);
if
(
$friends
[
'count'
])
{
self
::
build_myfriends_html
(
$friends
,
$userid
,
$instance
);
}
...
...
htdocs/export/html/lib.php
View file @
4333791b
...
...
@@ -526,7 +526,7 @@ class HtmlExportOutputFilter {
// Links to artefacts
$html
=
preg_replace_callback
(
'#<a[^>]+href="('
.
$wwwroot
.
')?/?view/artefact\.php\?artefact=(\d+)(&view=\d+)?(&
page
=\d+)?"[^>]*>([^<]*)</a>#'
,
'#<a[^>]+href="('
.
$wwwroot
.
')?/?view/artefact\.php\?artefact=(\d+)(&view=\d+)?(&
offset
=\d+)?"[^>]*>([^<]*)</a>#'
,
array
(
$this
,
'replace_artefact_link'
),
$html
);
...
...
@@ -582,9 +582,9 @@ class HtmlExportOutputFilter {
switch
(
$artefact
->
get
(
'artefacttype'
))
{
case
'blog'
:
$
page
=
(
$matches
[
4
])
?
intval
(
substr
(
$matches
[
4
],
strlen
(
'&
page
='
)))
:
1
;
$
page
=
(
$page
==
1
)
?
'index'
:
$
page
;
return
'<a href="'
.
$this
->
basepath
.
'/files/blog/'
.
PluginExportHtml
::
text_to_path
(
$artefact
->
get
(
'title'
))
.
'/'
.
$
page
.
'.html">'
.
$matches
[
5
]
.
'</a>'
;
$
offset
=
(
$matches
[
4
])
?
intval
(
substr
(
$matches
[
4
],
strlen
(
'&
offset
='
)))
:
0
;
$
offset
=
(
$offset
==
0
)
?
'index'
:
$
offset
;
return
'<a href="'
.
$this
->
basepath
.
'/files/blog/'
.
PluginExportHtml
::
text_to_path
(
$artefact
->
get
(
'title'
))
.
'/'
.
$
offset
.
'.html">'
.
$matches
[
5
]
.
'</a>'
;
case
'file'
:
case
'folder'
:
case
'image'
:
...
...
htdocs/export/html/theme/raw/static/style/style.css
View file @
4333791b
...
...
@@ -50,6 +50,10 @@ a img {
.r1
{
background-color
:
#f8f8f8
;
}
div
.pagination
span
.selected
,
span
.pagination
{
padding
:
5px
;
}
/* Headings */
h1
{
...
...
htdocs/lib/user.php
View file @
4333791b
...
...
@@ -1899,7 +1899,12 @@ function get_friends($userid, $limit=10, $offset=0) {
SELECT f.* '
.
$from
.
"
ORDER BY CASE WHEN NOT f.preferredname IS NULL AND f.preferredname <> '' THEN f.preferredname ELSE f.firstname || f.lastname END"
;
$result
[
'data'
]
=
get_records_sql_array
(
$sql
,
$values
,
$offset
,
$limit
);
if
(
$limit
===
false
)
{
$result
[
'data'
]
=
get_records_sql_array
(
$sql
,
$values
);
}
else
{
$result
[
'data'
]
=
get_records_sql_array
(
$sql
,
$values
,
$offset
,
$limit
);
}
return
$result
;
}
...
...
htdocs/lib/web.php
View file @
4333791b
...
...
@@ -2804,7 +2804,7 @@ function build_pagination($params) {
if
(
isset
(
$params
[
'forceoffset'
])
&&
!
is_null
(
$params
[
'forceoffset'
]))
{
$params
[
'offset'
]
=
(
int
)
$params
[
'forceoffset'
];
}
else
{
else
if
(
!
isset
(
$params
[
'offset'
]))
{
$params
[
'offset'
]
=
param_integer
(
$params
[
'offsetname'
],
0
);
}
...
...
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