From 5557c75a9f194379e2bdd248ffa7a483a8ad76d4 Mon Sep 17 00:00:00 2001 From: luizlaydner Date: Fri, 3 Aug 2007 21:41:09 +0000 Subject: [PATCH] - added block support for tag pages --- lib/weblib.php | 26 ++++++++++ tag/index.php | 86 ++++++++++++++++++++++++++------ tag/lib.php | 17 +++---- tag/search.php | 6 +-- theme/standard/styles_layout.css | 30 +++++++---- user/tag.php | 2 +- 6 files changed, 127 insertions(+), 40 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index 12f914aad4..b0f15f83aa 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -4458,6 +4458,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 "
frametarget method=\"get\" action=\"$CFG->wwwroot/tag/index.php\">". + "
". + "". + "". + "
"; +} + /** * Prints the editing button on a module "view" page * diff --git a/tag/index.php b/tag/index.php index 48913277b6..83bb9d5c62 100644 --- a/tag/index.php +++ b/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 @@ if (empty($CFG->usetags)) { } $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 @@ if (!$tag) { 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 ''; +echo ''; + +//----------------- left column ----------------- + +$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210); + +echo ''; + + + +//----------------- 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 ''; + + + +//----------------- right column ----------------- + +$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210); + +echo ''; + +/// Finish the page +echo '
'; +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 ''; -$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 = '' . $tagname . ''; } -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.'&', 'userpage'); - + print_tagged_users_table($tag, $userpage * $perpage, $perpage); } -print_footer(); +if (!empty($THEME->customcorners)) print_custom_corners_end(); +echo ''; +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 '
'; + +$PAGE->print_footer(); ?> diff --git a/tag/lib.php b/tag/lib.php index 82f8083c60..88802cbfae 100644 --- a/tag/lib.php +++ b/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 '
'.get_string('relatedtags','tag').': ' . tag_links_csv($related_tags); + echo '

'.get_string('relatedtags','tag').': ' . 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)) { diff --git a/tag/search.php b/tag/search.php index 2a966c2dc2..37b347fb49 100644 --- a/tag/search.php +++ b/tag/search.php @@ -19,15 +19,13 @@ $navlinks = array(); $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 = "wwwroot}/tag/manage.php\">" . get_string('managetags', 'tag') . "" ; - 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(); diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css index 0eb2cb9c3e..c5bda559c3 100644 --- a/theme/standard/styles_layout.css +++ b/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; } diff --git a/user/tag.php b/user/tag.php index 01cb131517..a3bf0ce7db 100644 --- a/user/tag.php +++ b/user/tag.php @@ -23,7 +23,7 @@ switch ($action) { 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); -- 2.39.5