Portfolio: Fix HTML structure for articles - refs BT#18201

pull/4368/head
Angel Fernando Quiroz Campos 4 years ago
parent 80bc97a381
commit c0acb1585f
  1. 102
      main/inc/lib/PortfolioController.php
  2. 119
      main/template/default/portfolio/items.html.twig
  3. 150
      main/template/default/portfolio/view.html.twig

@ -1063,8 +1063,8 @@ class PortfolioController
$query->getArrayResult(),
[
'decorate' => true,
'rootOpen' => '<ul class="media-list">',
'rootClose' => '</ul>',
'rootOpen' => '<div class="media-list">',
'rootClose' => '</div>',
'childOpen' => function ($node) use ($commentsRepo) {
/** @var PortfolioComment $comment */
$comment = $commentsRepo->find($node['id']);
@ -1080,12 +1080,12 @@ class PortfolioController
]
);
return '<li class="media" id="comment-'.$node['id'].'">
return '<article class="media" id="comment-'.$node['id'].'">
<div class="media-left"><img class="media-object thumbnail" src="'.$userPicture.'" alt="'
.$author->getCompleteName().'"></div>
<div class="media-body">';
},
'childClose' => '</div></li>',
'childClose' => '</div></article>',
'nodeDecorator' => function ($node) use ($commentsRepo, $clockIcon, $item) {
/** @var PortfolioComment $comment */
$comment = $commentsRepo->find($node['id']);
@ -1163,22 +1163,23 @@ class PortfolioController
}
}
$nodeHtml = '<p class="media-heading h4">'.PHP_EOL
.$comment->getAuthor()->getCompleteName().PHP_EOL.'<small>'.$clockIcon.PHP_EOL
.Display::dateToStringAgoAndLongDate($comment->getDate()).'</small>'.PHP_EOL;
$nodeHtml = '<div class="pull-right">'.implode(PHP_EOL, $commentActions).'</div>'.PHP_EOL
.'<footer class="media-heading h4">'.PHP_EOL
.'<p>'.$comment->getAuthor()->getCompleteName().'</p>'.PHP_EOL;
if ($comment->isImportant()
&& ($this->itemBelongToOwner($comment->getItem()) || $isAllowedToEdit)
) {
$nodeHtml .= '<span class="label label-warning origin-style">'
$nodeHtml .= '<span class="pull-right label label-warning origin-style">'
.get_lang('CommentMarkedAsImportant')
.'</span>'.PHP_EOL;
}
$nodeHtml .= '</p>'.PHP_EOL
.'<div class="pull-right">'.implode(PHP_EOL, $commentActions).'</div>'
.Security::remove_XSS($comment->getContent())
.PHP_EOL;
$nodeHtml .= '<p class="small">'.$clockIcon.PHP_EOL
.Display::dateToStringAgoAndLongDate($comment->getDate()).'</p>'.PHP_EOL;
$nodeHtml .= '</footer>'.PHP_EOL
.Security::remove_XSS($comment->getContent()).PHP_EOL;
$nodeHtml .= $this->generateAttachmentList($comment);
@ -1219,12 +1220,79 @@ class PortfolioController
$interbreadcrumb[] = ['name' => get_lang('Portfolio'), 'url' => $this->baseUrl];
$editLink = $actions[] = Display::url(
Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_MEDIUM),
$this->baseUrl.http_build_query(['action' => 'edit_item', 'id' => $item->getId()])
);
$actions = [];
$actions[] = Display::url(
Display::return_icon('back.png', get_lang('Back'), [], ICON_SIZE_MEDIUM),
$this->baseUrl
);
if ($this->itemBelongToOwner($item)) {
$actions[] = $editLink;
$visibilityUrl = $this->baseUrl.http_build_query(['action' => 'visibility', 'id' => $item->getId()]);
if ($item->getVisibility() === Portfolio::VISIBILITY_HIDDEN) {
$actions[] = Display::url(
Display::return_icon('invisible.png', get_lang('MakeVisible'), [], ICON_SIZE_MEDIUM),
$visibilityUrl
);
} elseif ($item->getVisibility() === Portfolio::VISIBILITY_VISIBLE) {
$actions[] = Display::url(
Display::return_icon('visible.png', get_lang('MakeVisibleForTeachers'), [], ICON_SIZE_MEDIUM),
$visibilityUrl
);
} elseif ($item->getVisibility() === Portfolio::VISIBILITY_HIDDEN_EXCEPT_TEACHER) {
$actions[] = Display::url(
Display::return_icon('eye-slash.png', get_lang('MakeInvisible'), [], ICON_SIZE_MEDIUM),
$visibilityUrl
);
}
$actions[] = Display::url(
Display::return_icon('delete.png', get_lang('Delete'), [], ICON_SIZE_MEDIUM),
$this->baseUrl.http_build_query(['action' => 'delete_item', 'id' => $item->getId()])
);
} else {
$actions[] = Display::url(
Display::return_icon('copy.png', get_lang('CopyToMyPortfolio'), [], ICON_SIZE_MEDIUM),
$this->baseUrl.http_build_query(['action' => 'copy', 'id' => $item->getId()])
);
}
if (api_is_allowed_to_edit()) {
$actions[] = Display::url(
Display::return_icon('copy.png', get_lang('CopyToStudentPortfolio'), [], ICON_SIZE_MEDIUM),
$this->baseUrl.http_build_query(['action' => 'teacher_copy', 'copy' => 'item', 'id' => $item->getId()])
);
$actions[] = $editLink;
$highlightedUrl = $this->baseUrl.http_build_query(['action' => 'highlighted', 'id' => $item->getId()]);
if ($item->isHighlighted()) {
$actions[] = Display::url(
Display::return_icon('award_red.png', get_lang('UnmarkAsHighlighted'), [], ICON_SIZE_MEDIUM),
$highlightedUrl
);
} else {
$actions[] = Display::url(
Display::return_icon('award_red_na.png', get_lang('MarkAsHighlighted'), [], ICON_SIZE_MEDIUM),
$highlightedUrl
);
}
if ($itemCourse && '1' === api_get_course_setting('qualify_portfolio_item')) {
$actions[] = Display::url(
Display::return_icon('quiz.png', get_lang('QualifyThisPortfolioItem'), [], ICON_SIZE_MEDIUM),
$this->baseUrl.http_build_query(['action' => 'qualify', 'item' => $item->getId()])
);
}
}
$this->renderView($content, $item->getTitle(true), $actions, false);
}
@ -2403,7 +2471,7 @@ class PortfolioController
}
if ($actions) {
$actions = implode(PHP_EOL, $actions);
$actions = implode('', $actions);
$actionsStr .= Display::toolbarAction('portfolio-toolbar', [$actions]);
}
@ -2852,6 +2920,7 @@ class PortfolioController
$formAction = $this->baseUrl.http_build_query(['action' => 'view', 'id' => $item->getId()]);
$form = new FormValidator('frm_comment', 'post', $formAction);
$form->addHeader(get_lang('AddNewComment'));
$form->addHtmlEditor('content', get_lang('Comments'), true, false, ['ToolbarSet' => 'Minimal']);
$form->addHidden('item', $item->getId());
$form->addHidden('parent', 0);
@ -2948,10 +3017,7 @@ class PortfolioController
}
if ($attachment->getComment()) {
$listItems .= PHP_EOL.Display::span(
Security::remove_XSS($attachment->getComment()),
['class' => 'text-muted']
);
$listItems .= '<p class="text-muted">'.Security::remove_XSS($attachment->getComment()).'</p>';
}
$listItems .= '</li>';
@ -2960,7 +3026,7 @@ class PortfolioController
$listItems .= '</ul>';
if ($includeHeader) {
$listItems = Display::page_subheader(get_lang('AttachmentFiles'), null, 'h5', ['class' => 'h4'])
$listItems = '<h1 class="h4">'.get_lang('AttachmentFiles').'</h1>'
.$listItems;
}

@ -5,58 +5,61 @@
{% set delete_img = 'delete.png'|img(22, 'Delete'|get_lang) %}
{% set baseurl = _p.web_self ~ '?' ~ (_p.web_cid_query ? _p.web_cid_query ~ '&' : '') %}
<div class="row portfolio-items">
<div class="portfolio-items">
{% for item in items %}
{% set item_url = baseurl ~ {'action':'view', 'id':item.id}|url_encode %}
{% set comments = item.lastComments %}
<div class="col-md-12">
<div class="panel {{ item.isHighlighted ? 'panel-success' : 'panel-default' }} portfolio-item" id="portfolio-item-{{ item.id }}">
<div class="panel-body">
<div class="portfolio-actions pull-right">
{% if _u.id == item.user.id %}
<a href="{{ baseurl ~ {'action':'edit_item', 'id':item.id}|url_encode }}">
{{ 'edit.png'|img(22, 'Edit'|get_lang) }}
<div class="panel panel-default">
<article class="panel-body portfolio-item" id="portfolio-item-{{ item.id }}">
<div class="portfolio-actions pull-right">
{% if _u.id == item.user.id %}
<a href="{{ baseurl ~ {'action':'edit_item', 'id':item.id}|url_encode }}">
{{ 'edit.png'|img(22, 'Edit'|get_lang) }}
</a>
{% if item.visibility == 0 %}
<a href="{{ baseurl ~ {'action':'visibility', 'id':item.id}|url_encode }}">
{{ 'invisible.png'|img(22, 'MakeVisible'|get_lang) }}
</a>
{% if item.visibility == 0 %}
<a href="{{ baseurl ~ {'action':'visibility', 'id':item.id}|url_encode }}">
{{ 'invisible.png'|img(22, 'MakeVisible'|get_lang) }}
</a>
{% elseif item.visibility == 1 %}
<a href="{{ baseurl ~ {'action':'visibility', 'id':item.id}|url_encode }}">
{{ 'visible.png'|img(22, 'MakeVisibleForTeachers'|get_lang) }}
</a>
{% elseif item.visibility == 2 %}
<a href="{{ baseurl ~ {'action':'visibility', 'id':item.id}|url_encode }}">
{{ 'eye-slash.png'|img(22, 'MakeInvisible'|get_lang) }}
</a>
{% endif %}
<a href="{{ baseurl ~ {'action':'delete_item', 'id':item.id}|url_encode }}" class="btn-delete">
{{ 'delete.png'|img(22, 'Delete'|get_lang) }}
{% elseif item.visibility == 1 %}
<a href="{{ baseurl ~ {'action':'visibility', 'id':item.id}|url_encode }}">
{{ 'visible.png'|img(22, 'MakeVisibleForTeachers'|get_lang) }}
</a>
{% elseif false|api_is_allowed_to_edit %}
<a href="{{ baseurl ~ {'action':'edit_item', 'id':item.id}|url_encode }}">
{{ 'edit.png'|img(22, 'Edit'|get_lang) }}
{% elseif item.visibility == 2 %}
<a href="{{ baseurl ~ {'action':'visibility', 'id':item.id}|url_encode }}">
{{ 'eye-slash.png'|img(22, 'MakeInvisible'|get_lang) }}
</a>
{% endif %}
<a href="{{ baseurl ~ {'action':'delete_item', 'id':item.id}|url_encode }}" class="btn-delete">
{{ 'delete.png'|img(22, 'Delete'|get_lang) }}
</a>
{% elseif false|api_is_allowed_to_edit %}
<a href="{{ baseurl ~ {'action':'edit_item', 'id':item.id}|url_encode }}">
{{ 'edit.png'|img(22, 'Edit'|get_lang) }}
</a>
{% endif %}
{% if false|api_is_allowed_to_edit %}
{% if item.isHighlighted %}
<a href="{{ baseurl ~ {'action':'highlighted', 'id':item.id}|url_encode }}">
{{ 'award_red.png'|img(22, 'UnmarkAsHighlighted'|get_lang) }}
</a>
{% else %}
<a href="{{ baseurl ~ {'action':'highlighted', 'id':item.id}|url_encode }}">
{{ 'award_red_na.png'|img(22, 'MarkAsHighlighted'|get_lang) }}
</a>
{% endif %}
{% if false|api_is_allowed_to_edit %}
{% if item.isHighlighted %}
<a href="{{ baseurl ~ {'action':'highlighted', 'id':item.id}|url_encode }}">
{{ 'award_red.png'|img(22, 'UnmarkAsHighlighted'|get_lang) }}
</a>
{% else %}
{% if item.isHighlighted %}
{{ 'award_red.png'|img(22, 'MarkedAsHighlighted'|get_lang) }}
{% endif %}
<a href="{{ baseurl ~ {'action':'highlighted', 'id':item.id}|url_encode }}">
{{ 'award_red_na.png'|img(22, 'MarkAsHighlighted'|get_lang) }}
</a>
{% endif %}
</div>
{% endif %}
</div>
{% if item.isHighlighted %}
<span class="label label-success">
<span class="fa fa-fw fa-star-o" aria-hidden="true"></span>
{{ 'Highlighted'|get_lang }}
</span>
{% endif %}
<header>
<h3>
<a href="{{ item_url }}">{{ item.title|remove_xss }}</a>
</h3>
@ -93,13 +96,15 @@
</li>
{% endif %}
</ul>
</header>
<hr>
<hr>
<p>{{ item.excerpt }}</p>
<p>{{ item.excerpt }}</p>
<hr>
<hr>
<section>
{% if comments|length > 0 %}
<h4>
<a href="{{ item_url }}#portfolio-item-comments">
@ -108,27 +113,25 @@
&centerdot;
<a href="{{ item_url }}#frm_comment">{{ 'AddNewComment'|get_lang }}</a>
</h4>
<ul class="fa-ul">
{% for comment in comments %}
<li>
<span class="fa-li fa fa-commenting-o" aria-hidden="true"></span>
<div>
<strong>{{ comment.author.completeName }}</strong>
<small class="fa fa-clock-o fa-fw text-muted" aria-hidden="true"></small>
<small class="text-muted">{{ comment.date|date_to_time_ago }}</small>
</div>
<p>{{ comment.excerpt }}</p>
</li>
{% endfor %}
</ul>
{% for comment in comments %}
<article>
<footer>
<span class="fa fa-fw fa-commenting-o" aria-hidden="true"></span>
<strong>{{ comment.author.completeName }}</strong>
<small class="fa fa-clock-o fa-fw text-muted" aria-hidden="true"></small>
<small class="text-muted">{{ comment.date|date_to_time_ago }}</small>
</footer>
<p>{{ comment.excerpt }}</p>
</article>
{% endfor %}
{% else %}
<a href="{{ item_url }}#portfolio-item-comments">
<span class="fa fa-commenting-o fa-fw" aria-hidden="true"></span>
{{ 'AddNewComment'|get_lang }}
</a>
{% endif %}
</div>
</div>
</section>
</article>
</div>
{% endfor %}
</div>

@ -1,68 +1,36 @@
<article class="panel {{ item.isHighlightedd ? 'panel-success' : 'panel-default' }} portfolio-item">
<div class="panel-body">
<div class="portfolio-actions pull-right">
{% if _u.id == item.user.id %}
<a href="{{ baseurl ~ {'action':'edit_item', 'id':item.id}|url_encode }}">
{{ 'edit.png'|img(22, 'Edit'|get_lang) }}
</a>
{% if item.visibility == 0 %}
<a href="{{ baseurl ~ {'action':'visibility', 'id':item.id}|url_encode }}">
{{ 'invisible.png'|img(22, 'MakeVisible'|get_lang) }}
</a>
{% elseif item.visibility == 1 %}
<a href="{{ baseurl ~ {'action':'visibility', 'id':item.id}|url_encode }}">
{{ 'visible.png'|img(22, 'MakeVisibleForTeachers'|get_lang) }}
</a>
{% elseif item.visibility == 2 %}
<a href="{{ baseurl ~ {'action':'visibility', 'id':item.id}|url_encode }}">
{{ 'eye-slash.png'|img(22, 'MakeInvisible'|get_lang) }}
</a>
{% endif %}
<a href="{{ baseurl ~ {'action':'delete_item', 'id':item.id}|url_encode }}" class="btn-delete">
{{ 'delete.png'|img(22, 'Delete'|get_lang) }}
</a>
{% endif %}
{% if _u.id != item.user.id %}
<a href="{{ baseurl ~ {'action':'copy', 'copy':'item', 'id':item.id}|url_encode }}">
{{ 'copy.png'|img(22, 'CopyToMyPortfolio'|get_lang) }}
</a>
{% endif %}
{% if item.isHighlighted %}
<span class="label label-success">
<span class="fa fa-fw fa-star-o" aria-hidden="true"></span>
{{ 'Highlighted'|get_lang }}
</span>
{% endif %}
<article class="portfolio-item">
<header>
<h4 class="h3">{{ item.title|remove_xss }}</h4>
{% if false|api_is_allowed_to_edit %}
<a href="{{ baseurl ~ {'action':'teacher_copy', 'copy':'item', 'id':item.id}|url_encode }}">
{{ 'copy.png'|img(22, 'CopyToStudentPortfolio'|get_lang) }}
</a>
<a href="{{ baseurl ~ {'action':'edit_item', 'id':item.id}|url_encode }}">
{{ 'edit.png'|img(22, 'Edit'|get_lang) }}
</a>
{% if item.isHighlighted %}
<a href="{{ baseurl ~ {'action':'highlighted', 'id':item.id}|url_encode }}">
{{ 'award_red.png'|img(22, 'UnmarkAsHighlighted'|get_lang) }}
</a>
{% else %}
<a href="{{ baseurl ~ {'action':'highlighted', 'id':item.id}|url_encode }}">
{{ 'award_red_na.png'|img(22, 'MarkAsHighlighted'|get_lang) }}
</a>
{% endif %}
<ul class="fa-ul list-inline">
<li>
<span class="fa-li fa fa-user" aria-hidden="true"></span>
{{ item.user.completeName }}
</li>
<li>
<span class="fa-li fa fa-clock-o" aria-hidden="true"></span>
{{ 'CreationDate'|get_lang ~ ': ' ~ item.creationDate|date_to_time_ago }}
</li>
{% if item.course and '1' == 'qualify_portfolio_item'|api_get_course_setting %}
<a href="{{ baseurl ~ {'action':'qualify', 'item':item.id}|url_encode }}">
{{ 'quiz.png'|img(22, 'QualifyThisPortfolioItem'|get_lang) }}
</a>
{% endif %}
{% else %}
{% if item.isHighlighted %}
{{ 'award_red.png'|img(22, 'Highlighted'|get_lang) }}
{% endif %}
{% if last_edit %}
<li>
<span class="fa-li fa fa-clock-o" aria-hidden="true"></span>
{{ 'UpdatedDateXByUserY'|get_lang|format(last_edit.date|date_to_time_ago, last_edit.user) }}
</li>
{% elseif item.creationDate != item.updateDate %}
<li>
<span class="fa-li fa fa fa-clock-o" aria-hidden="true"></span>
{{ 'UpdatedDateX'|get_lang|format(item.updateDate|date_to_time_ago) }}
</li>
{% endif %}
</div>
<h4 class="h3">{{ item.title|remove_xss }}</h4>
<ul class="fa-ul list-inline">
{% if _c is empty %}
{% if item.session %}
<li>
@ -75,59 +43,29 @@
{{ 'Course'|get_lang ~ ': ' ~ item.course.title }}
</li>
{% endif %}
{% else %}
<li>
<span class="fa-li fa fa-user" aria-hidden="true"></span>
{{ item.user.completeName }}
</li>
{% endif %}
<li>
<span class="fa-li fa fa-clock-o" aria-hidden="true"></span>
{{ 'CreationDate'|get_lang ~ ': ' ~ item.creationDate|date_to_time_ago }}
</li>
<li>
<span class="fa-li fa fa-comment-o" aria-hidden="true"></span>
{{ 'XComments'|get_lang|format(item.comments.count) }}
</li>
</ul>
</header>
<hr>
{{ item_content }}
{% if attachment_list %}
<hr>
{{ item_content }}
{% if attachment_list %}
<section>
{{ attachment_list }}
{% endif %}
{% if last_edit %}
<hr>
<p>
<span class="fa fa-fw fa-clock-o" aria-hidden="true"></span>
{{ 'UpdatedOnDateXByUserY'|get_lang|format(last_edit.date|date_to_time_ago, last_edit.user) }}
</p>
{% elseif item.creationDate != item.updateDate %}
<hr>
<p>
<span class="fa fa-fw fa fa-clock-o" aria-hidden="true"></span>
{{ 'UpdatedOnDateX'|get_lang|format(item.updateDate|date_to_time_ago) }}
</p>
{% endif %}
</div>
</article>
</section>
{% endif %}
<hr>
<section id="portfolio-item-comments">
<h1 class="h3">
<span class="fa fa-fw fa-comment-o" aria-hidden="true"></span>
{{ 'XComments'|get_lang|format(item.comments.count) }}
</h1>
<div id="portfolio-item-comments">
<h5 class="h4">{{ 'XComments'|get_lang|format(item.comments.count) }}</h5>
{{ comments }}
{{ comments }}
{{ form }}
</div>
{{ form }}
</section>
</article>
<script>
$(function () {

Loading…
Cancel
Save