Skip to content
Browse files

- added block support for tag pages

  • Loading branch information...
1 parent f615fba commit 5557c75a9f194379e2bdd248ffa7a483a8ad76d4 luizlaydner committed
Showing with 127 additions and 40 deletions.
  1. +26 −0 lib/weblib.php
  2. +70 −16 tag/index.php
  3. +7 −10 tag/lib.php
  4. +2 −4 tag/search.php
  5. +21 −9 theme/standard/styles_layout.css
  6. +1 −1 user/tag.php
View
26 lib/weblib.php
@@ -4459,6 +4459,32 @@ function update_mymoodle_icon() {
}
/**
+ * Returns a turn edit on/off button for tag in a self contained form.
+ *
+ * @uses $CFG
+ * @uses $USER
+ * @return string
+ */
+function update_tag_button($tagid) {
+
+ global $CFG, $USER;
+
+ if (!empty($USER->editing)) {
+ $string = get_string('turneditingoff');
+ $edit = '0';
+ } else {
+ $string = get_string('turneditingon');
+ $edit = '1';
+ }
+
+ return "<form $CFG->frametarget method=\"get\" action=\"$CFG->wwwroot/tag/index.php\">".
+ "<div>".
+ "<input type=\"hidden\" name=\"edit\" value=\"$edit\" />".
+ "<input type=\"hidden\" name=\"id\" value=\"$tagid\" />".
+ "<input type=\"submit\" value=\"$string\" /></div></form>";
+}
+
+/**
* Prints the editing button on a module "view" page
*
* @uses $CFG
View
86 tag/index.php
@@ -2,7 +2,11 @@
require_once('../config.php');
require_once('lib.php');
+require_once('pagelib.php');
require_once($CFG->dirroot.'/lib/weblib.php');
+if (!empty($THEME->customcorners)) {
+ require_once($CFG->dirroot.'/lib/custom_corners_lib.php');
+}
require_login();
@@ -11,8 +15,9 @@
}
$tagid = optional_param('id', 0, PARAM_INT); // tag id
+$edit = optional_param('edit', -1, PARAM_BOOL);
$userpage = optional_param('userpage', 0, PARAM_INT); // which page to show
-$perpage = optional_param('perpage', 20, PARAM_INT);
+$perpage = optional_param('perpage', 24, PARAM_INT);
$tag = tag_by_id($tagid);
@@ -20,44 +25,93 @@
redirect($CFG->wwwroot.'/tag/search.php');
}
-$tagname = tag_display_name($tag);
+//create a new page_tag object, defined in pagelib.php
+$PAGE = page_create_object(PAGE_TAG_INDEX, $tag->id);
+$pageblocks = blocks_setup($PAGE,BLOCKS_PINNED_BOTH);
+$PAGE->tag_object = $tag;
+
+if (($edit != -1) and $PAGE->user_allowed_editing()) {
+ $USER->editing = $edit;
+}
+
+
+$PAGE->print_header();
+
+
+echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">';
+echo '<tr valign="top">';
+
+//----------------- left column -----------------
+
+$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
+
+echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="left-column">';
+if(blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing()) {
+ if (!empty($THEME->customcorners)) print_custom_corners_start();
+ blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
+ if (!empty($THEME->customcorners)) print_custom_corners_end();
+}
+echo '</td>';
+
+
+
+//----------------- middle column -----------------
-$navlinks = array();
-$navlinks[] = array('name' => get_string('tags', 'tag'), 'link' => "{$CFG->wwwroot}/tag/search.php", 'type' => '');
-$navlinks[] = array('name' => $tagname, 'link' => '', 'type' => '');
+echo '<td valign="top" id="middle-column">';
-$navigation = build_navigation($navlinks);
-print_header_simple(get_string('tag', 'tag') . ' - ' . $tagname, '', $navigation);
+if (!empty($THEME->customcorners)) print_custom_corners_start(TRUE);
+
+
+$tagname = tag_display_name($tag);
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
if ($tag->flag > 0 && has_capability('moodle/tag:manage', $systemcontext)) {
$tagname = '<span class="flagged-tag">' . $tagname . '</span>';
}
-print_heading($tagname, '', 2);
-
-print_tag_management_box($tag);
+print_heading($tagname, '', 2, 'headingblock header tag-heading');
print_tag_description_box($tag);
-$usercount = count_items_tagged_with($tagid,'user');
+$usercount = count_items_tagged_with($tag->id,'user');
if ($usercount > 0) {
- print_heading(get_string('userstaggedwith', 'tag', $tagname) . ': ' . $usercount, '', 3);
+ $heading = get_string('userstaggedwith', 'tag', $tagname) . ': ' . $usercount;
+ print_heading($heading, '', 3);
+
+ $baseurl = $CFG->wwwroot.'/tag/index.php?id=' . $tag->id;
- $baseurl = $CFG->wwwroot.'/tag/index.php?id=' . $tagid;
-
print_paging_bar($usercount, $userpage, $perpage, $baseurl.'&amp;', 'userpage');
-
+
print_tagged_users_table($tag, $userpage * $perpage, $perpage);
}
-print_footer();
+if (!empty($THEME->customcorners)) print_custom_corners_end();
+echo '</td>';
+
+
+
+//----------------- right column -----------------
+
+$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
+
+echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="right-column">';
+if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing()) {
+ if (!empty($THEME->customcorners)) print_custom_corners_start();
+ blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
+ if (!empty($THEME->customcorners)) print_custom_corners_end();
+}
+echo '</td>';
+
+/// Finish the page
+echo '</tr></table>';
+
+$PAGE->print_footer();
?>
View
17 tag/lib.php
@@ -918,7 +918,7 @@ function tag_normalize($tag_names_csv, $lowercase=true) {
}
//$value = preg_replace('|[^\w ]|i', '', strtolower(trim($tag_names_csv)));
- $value = preg_replace('|[\!\@\#\$\%\^\&\*\(\)\-\+\=\~\`\.\[\]\{\}\:\;\?\´\^\\\/\<\>\|]|i', '', trim($value));
+ $value = preg_replace('|[\!\@\#\$\%\^\&\*\(\)\-\+\=\~\`\\"\'\_.\[\]\{\}\:\;\?\´\^\\\/\<\>\|]|i', '', trim($value));
//removes excess white spaces
$value = preg_replace('/\s\s+/', ' ', $value);
@@ -928,10 +928,6 @@ function tag_normalize($tag_names_csv, $lowercase=true) {
}
-function is_tag_clean($tag_names_csv) {
-
-}
-
function tag_flag_inappropriate($tag_names_or_ids_csv){
$tag_ids_csv = tag_id_from_string($tag_names_or_ids_csv);
@@ -1024,7 +1020,7 @@ function tag_names_csv($tag_objects) {
$tags[] = tag_display_name($tag);
}
- return implode(',', $tags);
+ return implode(', ', $tags);
}
@@ -1138,9 +1134,10 @@ function print_tag_description_box($tag_object) {
$tagname = tag_display_name($tag_object);
$related_tags = related_tags($tag_object->id); //get_item_tags('tags',$tag_object->id);
-
print_box_start('generalbox', 'tag-description');
+ print_tag_management_box($tag_object);
+
if (!empty($tag_object->description)) {
echo format_text($tag_object->description, $tag_object->descriptionformat );
}
@@ -1150,7 +1147,7 @@ function print_tag_description_box($tag_object) {
if ($related_tags) {
- echo '<br/><b>'.get_string('relatedtags','tag').': </b>' . tag_links_csv($related_tags);
+ echo '<br/><br/><b>'.get_string('relatedtags','tag').': </b>' . tag_links_csv($related_tags);
}
print_box_end();
@@ -1290,7 +1287,7 @@ function print_tag_search_results($query, $page, $perpage) {
if($tags) { // there are results to display!!
- print_heading(get_string('searchresultsfor', 'tag') . " \"{$query}\" : {$count}", '', 3);
+ print_heading(get_string('searchresultsfor', 'tag', $query) . " : {$count}", '', 3);
//print a link "Add $query to my interests"
if (!empty($addtaglink)) {
@@ -1316,7 +1313,7 @@ function print_tag_search_results($query, $page, $perpage) {
}
else { //no results were found!!
- print_heading(get_string('noresultsfor', 'tag') . " \"{$query}\" ", '', 3);
+ print_heading(get_string('noresultsfor', 'tag', $query), '', 3);
//print a link "Add $query to my interests"
if (!empty($addtaglink)) {
View
6 tag/search.php
@@ -19,15 +19,13 @@
$navlinks[] = array('name' => get_string('tags', 'tag'), 'link' => "{$CFG->wwwroot}/tag/search.php", 'type' => '');
$navigation = build_navigation($navlinks);
-
-print_header_simple(get_string('tags', 'tag'), '', $navigation);
-
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
if ( has_capability('moodle/tag:manage',$systemcontext) ) {
$manage_link = "<a href=\"{$CFG->wwwroot}/tag/manage.php\">" . get_string('managetags', 'tag') . "</a>" ;
- print_box($manage_link, '', 'tags-management-links');
}
+print_header_simple(get_string('tags', 'tag'), '', $navigation, '', '', '', $manage_link);
+
print_heading(get_string('searchtags', 'tag'), '', 2);
print_tag_search_box();
View
30 theme/standard/styles_layout.css
@@ -2750,15 +2750,26 @@ ul.tabrow1 li.here.selected a {
*** Tags
***/
+h2.tag-heading {
+ text-align:center;
+ margin-left:auto;
+ margin-right:auto;
+ display:block;
+ width:95%;
+ padding: 5px 5px 5px 5px;
+
+}
+
div#tag-description {
- width:60%;
- padding-top:0px;
- margin-top:20px;
+ width:95%;
+ padding: 5px 5px 5px 5px;
margin-left:auto;
margin-right:auto;
+ display:block;
}
div#tag-management-box {
+ margin-bottom:10px;
text-align:center;
line-height:20px;
display:block;
@@ -2766,21 +2777,22 @@ div#tag-management-box {
}
div#tag-user-table {
- width:60%;
+ padding:3px;
+ width:95%;
margin-left:auto;
margin-right:auto;
display:table;
}
div.user-box {
- margin-left:15px;
- margin-right:15px;
+ margin-left:10px;
+ margin-right:10px;
margin-top:5px;
margin-bottom:5px;
- width:115px;
- height:150px;
+ width:110px;
+ height:160px;
text-align:center;
- display:block;
+ display:block;
float:left;
}
View
2 user/tag.php
@@ -23,7 +23,7 @@
tag_an_item('user',$USER->id, $name);
if (!empty($name) && !$id) {
- $id = tag_id($name);
+ $id = tag_id(tag_normalize($name));
}
redirect($CFG->wwwroot.'/tag/index.php?id='.$id);

0 comments on commit 5557c75

Please sign in to comment.
Something went wrong with that request. Please try again.