Skip to content

Commit

Permalink
Blog: Modification to tags block #275667
Browse files Browse the repository at this point in the history
  • Loading branch information
hien.dinh authored and sammarshallou committed Jan 3, 2019
1 parent fd49f79 commit 46b7e3e
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 17 deletions.
6 changes: 4 additions & 2 deletions lang/ca/oublog.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
$string['olderposts'] = '< Missatges antics';
$string['newerposts'] = 'Missatges recents >';
$string['extranavolderposts'] = 'Missatges antics: {$a->from}-{$a->to}';
$string['extranavtag'] = 'Etiqueta: {$a}';
$string['extranavtag'] = 'Filtre: {$a}';

$string['comments'] = 'Comentaris';
$string['ncomments'] = '{$a} comentaris';
Expand Down Expand Up @@ -110,6 +110,8 @@
$string['bloginfo']='Informació del blog';

$string['feedhelp']='Notícies';
$string['filter'] = 'Filtre:';
$string['filter-tooltip'] = "Feu clic per eliminar l'etiqueta del filtre";

$string['unsupportedbrowser']='<p>El teu navegador no pot mostrar notícias Atom o RSS directament.</p>
<p>Feeds are most useful in separate computer programs or websites. If you want
Expand All @@ -124,4 +126,4 @@
$string['completioncommentshelp']='Es requereix comentari per a completar';

$string['maybehiddenposts']='Aquest blog conté missatges que únicament són visibles pels usuaris registrats. Si vosté té un compte d\'usuari, sisplau <a href=\'{$a}\'>entri per poder veure\'ls</a>.';
$string['noposts']='No hi ha missatges visibles en aquest blog.';
$string['noposts']='No hi ha missatges visibles en aquest blog.';
6 changes: 4 additions & 2 deletions lang/de/oublog.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
$string['olderposts'] = '&lt; Ältere Beiträge';
$string['newerposts'] = 'Neuere Beiträge &gt;';
$string['extranavolderposts'] = 'Ältere Beiträge: {$a->von}-{$a->an}';
$string['extranavtag'] = 'Tag: {$a}';
$string['extranavtag'] = 'Filter: {$a}';

$string['comments'] = 'Kommentare';
$string['ncomments'] = '{$a} Kommentare';
Expand All @@ -81,6 +81,8 @@

$string['subscribefeed'] = 'Einen Feed abonnieren (erfordert entsprechende Software) um eine Nachricht zu erhalten wenn der Blog aktualisiert wurde.';
$string['feeds'] = 'Feeds';
$string['filter'] = 'Filter:';
$string['filter-tooltip'] = 'Klicken Sie hier, um das Filter-Tag zu entfernen';
$string['blogfeed'] = 'Blog Feeds';
$string['commentsfeed'] = 'Nur Kommentare';
$string['atom'] = 'Atom';
Expand Down Expand Up @@ -136,4 +138,4 @@
$string['overviewnumentrylog1'] = 'Eintrag seit letztem Login';
$string['overviewnumentrylog'] = 'Einträge seit letztem Login';
$string['overviewnumentryvw1'] = 'Eintrag seit dem letzten Anschauen';
$string['overviewnumentryvw'] = 'Einträge seit dem letzten Anschauen';
$string['overviewnumentryvw'] = 'Einträge seit dem letzten Anschauen';
4 changes: 3 additions & 1 deletion lang/en/oublog.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
$string['olderposts'] = 'Previous posts';
$string['newerposts'] = 'Newer posts';
$string['extranavolderposts'] = 'Older posts: {$a->from}-{$a->to}';
$string['extranavtag'] = 'Tag: {$a}';
$string['extranavtag'] = 'Filter: {$a}';

$string['comments'] = 'Comments';
$string['recentcomments'] = 'Recent comments';
Expand Down Expand Up @@ -600,6 +600,8 @@
$string['order'] = 'Order:';
$string['alpha'] = 'A to Z';
$string['use'] = 'Most used';
$string['filter'] = 'Filter:';
$string['filter-tooltip'] = 'Click to remove filter tag';
$string['order_help'] = 'You can choose to order the display of the list of tags used,
either in alphabetical order or by number of posts used in.
Select the two links to switch between ordering methods,
Expand Down
6 changes: 4 additions & 2 deletions lang/es/oublog.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
$string['olderposts'] = '&lt; Mensajes antiguos';
$string['newerposts'] = 'Mensaje recientes &gt;';
$string['extranavolderposts'] = 'Mensajes antiguos: {$a->from}-{$a->to}';
$string['extranavtag'] = 'Etiqueta: {$a}';
$string['extranavtag'] = 'Filtrar: {$a}';

$string['comments'] = 'Comentarios';
$string['ncomments'] = '{$a} comments';
Expand All @@ -65,6 +65,8 @@

$string['subscribefeed'] = 'Suscribir a las noticias (requiere el software apropiado) para recibir notificaciones cuando este blog se actualice. ';
$string['feeds'] = 'Noticias';
$string['filter'] = 'Filtrar:';
$string['filter-tooltip'] = 'Haga clic para eliminar la etiqueta de filtro';
$string['blogfeed'] = 'Noticias de blog';
$string['commentsfeed'] = 'Solo comentarios';
$string['atom'] = 'Atom';
Expand Down Expand Up @@ -112,4 +114,4 @@
$string['completioncommentshelp']='Se requiere comentario para completar';

$string['maybehiddenposts']='Este blog contiene mensajes que Únicamente son visibles para los usuarios inscritos. Si usted tiene una cuenta de usuario, por favor <a href=\'{$a}\'>acceda para poder verlos</a>.';
$string['noposts']='No hay mensajes visibles en este blog.';
$string['noposts']='No hay mensajes visibles en este blog.';
6 changes: 4 additions & 2 deletions lang/ja/oublog.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
$string['editpost'] = 'ブログ記事を更新する';
$string['editsummary'] = '編集者: {$a->editby} - 編集日時: {$a->editdate}';
$string['extranavolderposts'] = '古い記事: {$a->from}-{$a->to}';
$string['extranavtag'] = 'タグ: {$a}';
$string['extranavtag'] = 'フィルター: {$a}';
$string['feedhelp'] = 'フィード';
$string['feeds'] = 'フィード';
$string['filter'] = 'フィルター:';
$string['filter-tooltip'] = 'クリックしてフィルタータグを削除';
$string['guestblog'] = 'あなたがシステムにアカウントを登録している場合、<a href=\"{$a}\">ブログにフルアクセスするには、ログインしてください</a>。';
$string['lastcomment'] = '(最終コメント by {$a->fullname} - {$a->timeposted})';
$string['links'] = '関連リンク';
Expand Down Expand Up @@ -91,4 +93,4 @@
$string['visibleloggedinusers'] = 'システムにログインしている誰でも閲覧できる';
$string['visiblepublic'] = '世界中の誰でも閲覧できる';
$string['visibleyou'] = 'ブログオーナーのみ閲覧できる (プライベート)';
$string['yes'] = 'Yes';
$string['yes'] = 'Yes';
4 changes: 3 additions & 1 deletion lang/pt_br/oublog.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@
$string['externaldashboardadd'] = 'Adicionar blog ao dashboard';
$string['externaldashboardremove'] = 'Remover blog do dashboard';
$string['extranavolderposts'] = 'Última postagem: {$a->from}-{$a->to}';
$string['extranavtag'] = 'Marca: {$a}';
$string['extranavtag'] = 'Filtrar: {$a}';
$string['feedhelp'] = 'feeds';
$string['feedhelp_help'] = '<p> Se você usa um programa leitor de noticias ou página web, você pode adicionar o endereço web do Atom ou link RSS para ficar atualizado sobre as novas postagens. </p> <p> Se o blog mermitir comentários, você poderá ver os novos comentários realizados.</p> <p> Seu curso não requer que você use esse recurso.</p> <h3>Atom e RSS</h3> <p> Atom e RSS são dois formatos com a mesma finalidade. O primeiro é um modelo tecnologicamente mais puro, o último é mais conhecido. A maioria dos leitores de notícias suportam ambos os formatos. Tente o link Atom, se isto não funcionar, tente o RSS.</p>';
$string['feeds'] = 'Feeds';
$string['filter'] = 'Filtrar:';
$string['filter-tooltip'] = 'Clique para remover a tag de filtro';
$string['feedsnotenabled'] = 'Feeds não estão habilitadas';
$string['globalblogmissing'] = 'Blog Global faltando';
$string['guestblog'] = 'Se você tem uma conta no sistema, por favor <a href=\'{$a}\'>logue para ter total acesso</a>.';
Expand Down
14 changes: 10 additions & 4 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1129,35 +1129,41 @@ function oublog_get_tags($oublog, $groupid, $cm, $oubloginstanceid=null, $indivi


/**
* Print a tag cloud for a given blog or blog instance
* Print a tag cloud for a given blog or blog instance and return current filter object
*
* @param string $baseurl
* @param int $oublogid
* @param int $groupid
* @param object $cm
* @param int $oubloginstanceid
* @param object $masterblog
* @return string Tag cloud HTML
* @return array Tag cloud HTML, current filter tag
*/
function oublog_get_tag_cloud($baseurl, $oublog, $groupid, $cm, $oubloginstanceid=null, $individualid=-1, $tagorder,
$masterblog = null) {
global $PAGE;
$cloud = '';
$currenttag = $PAGE->url->get_param('tag');
$currentfiltertag = '';
$urlparts= array();

$baseurl = oublog_replace_url_param($baseurl, 'tag');
if (!$tags = oublog_get_tags($oublog, $groupid, $cm, $oubloginstanceid, $individualid, $tagorder, $masterblog)) {
return($cloud);
return [$cloud, $currentfiltertag];
}

$cloud .= html_writer::start_tag('div', array('class' => 'oublog-tag-items'));
foreach ($tags as $tag) {
$cloud .= '<a href="'.$baseurl.'&amp;tag='.urlencode($tag->tag).'" class="oublog-tag-cloud-'.
$tag->weight.'"><span class="oublog-tagname">'.strtr(($tag->tag), array(' '=>'&nbsp;')).
'</span><span class="oublog-tagcount">('.$tag->count.')</span></a> ';
if (!is_null($currenttag) && $tag->tag == $currenttag) {
$currentfiltertag = $tag;
}
}
$cloud .= html_writer::end_tag('div');

return($cloud);
return [$cloud, $currentfiltertag];
}

/**
Expand Down
17 changes: 17 additions & 0 deletions pix/close_button_rgb_30px.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1867,6 +1867,42 @@ public function render_export_type(moodle_url $url) {
return $output;
}

/**
* Render html current filter tag.
*
* @param $tag current filter tag
* @return html
* @throws coding_exception
* @throws moodle_exception
*/
public function render_current_filter($tag, $baseurl) {
$output = '';
$baseurl = oublog_replace_url_param($baseurl, 'tag');
$closefiltericon = html_writer::empty_tag('img',
['src' => $this->output->image_url('close_button_rgb_30px', 'oublog'), 'class' => 'close-filter-icon']);
$output .= html_writer::start_tag('div', ['class' => 'oublog-filter-tag clearfix']);
$output .= get_string('filter', 'oublog');
$output .= "&nbsp;";

$output .= html_writer::start_tag('span', ['class' => 'oublog-filter-tag-item']);
$output .= html_writer::start_tag('a',
['href' => $baseurl . '&tag=' . urlencode($tag->tag), 'class' => 'oublog-filter-tag-cloud-' . $tag->weight]);
$output .= html_writer::start_tag('span', ['class' => 'oublog-filter-tagname']);
$output .= strtr(($tag->tag), [' ' => '&nbsp;']);
$output .= html_writer::end_tag('span');
$output .= html_writer::start_tag('span', ['class' => 'oublog-filter-tagcount']);
$output .= ' (' . $tag->count . ')';
$output .= html_writer::end_tag('span');
$output .= html_writer::end_tag('a');
$output .= html_writer::end_tag('span');

$output .= html_writer::tag('a', $closefiltericon,
['href' => $baseurl, 'title' => get_string('filter-tooltip', 'oublog'),
'id' => 'close-filter-icon']);
$output .= html_writer::end_tag('div');

return $output;
}
}

class oublog_statsinfo implements renderable {
Expand Down
18 changes: 17 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#oublog-tags a {
text-decoration:none;
}
#oublog-tags a:hover .oublog-tagname{
#oublog-tags a:hover .oublog-tagname,
.oublog-filter-tag-item a:hover .oublog-filter-tagname {
text-decoration:underline;
}
.oublog-sideblock a:hover,
Expand Down Expand Up @@ -745,3 +746,18 @@ div.tagselector_result .tagselector_result_info {
.oublog-export_instance button[name="oublog-export-selected"] {
margin-left: 10px;
}

.oublog-filter-tag-item {
font-weight: normal;
}

.oublog-filter-tagname,
oublog-filter-tagcount {
font-size: 1em;
}

.close-filter-icon {
width: 18px;
height: 18px;
float: right;
}
31 changes: 31 additions & 0 deletions tests/behat/basic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -730,3 +730,34 @@ Feature: Test Post and Comment on OUBlog entry
Given I am on "Course 1" course homepage
When I follow "B.VG"
Then I should see "P2"

Scenario: Check filter label in tag block
Given I log in as "teacher1"
And I am on homepage
And I am on "Course 1" course homepage
And I follow "Test oublog basics"
And I press "New blog post"
And I set the following fields to these values:
| Title | Teacher1 blog |
| Message | Teacher1 post |
| Tags | tag1 |
And I press "Add post"
And I press "New blog post"
And I set the following fields to these values:
| Title | Teacher1 blog 2 |
| Message | Teacher1 post 2 |
| Tags | tag2 |
When I press "Add post"
Then I should see "Teacher1 blog" in the "div.oublog-post-top-details h2.oublog-title" "css_element"
And I should see "Teacher1 blog 2" in the "div.oublog-post-top-details h2.oublog-title" "css_element"
When I follow "tag1"
Then I should see "tag1" in the ".oublog-filter-tagname" "css_element"
And I should not see "tag2" in the ".oublog-filter-tagname" "css_element"
And I should see "Teacher1 blog" in the "div.oublog-post-top-details h2.oublog-title" "css_element"
And I should not see "Teacher1 blog 2" in the "div.oublog-post-top-details h2.oublog-title" "css_element"
When I follow "tag2"
Then I should see "tag2" in the ".oublog-filter-tagname" "css_element"
And I should see "Teacher1 blog 2" in the "div.oublog-post-top-details h2.oublog-title" "css_element"
When I click on "#close-filter-icon" "css_element"
Then I should see "Teacher1 blog" in the "div.oublog-post-top-details h2.oublog-title" "css_element"
And I should see "Teacher1 blog 2" in the "div.oublog-post-top-details h2.oublog-title" "css_element"
8 changes: 6 additions & 2 deletions view.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,18 @@
}

// Tag Cloud.
if ($tags = oublog_get_tag_cloud($returnurl, $oublog, $currentgroup, $cm,
$oubloginstanceid, $currentindividual, $tagorder, $masterblog)) {
list ($tags, $currentfiltertag) = oublog_get_tag_cloud($returnurl, $oublog, $currentgroup, $cm,
$oubloginstanceid, $currentindividual, $tagorder, $masterblog);
if ($tags) {
$bc = new block_contents();
$bc->attributes['id'] = 'oublog-tags';
$bc->attributes['class'] = 'oublog-sideblock block';
$bc->attributes['data-osepid'] = $id . '_oublog_blocktags';
$bc->title = $strtags;
$bc->content = $oublogoutput->render_tag_order($tagorder);
if ($currentfiltertag) {
$bc->content .= $oublogoutput->render_current_filter($currentfiltertag, $returnurl);
}
$bc->content .= $tags;
$PAGE->blocks->add_fake_block($bc, BLOCK_POS_RIGHT);
}
Expand Down

0 comments on commit 46b7e3e

Please sign in to comment.