From ecec98aac95ad82a6b22deacc4cfa11b5889a8f5 Mon Sep 17 00:00:00 2001 From: yanxd Date: Thu, 23 Jan 2014 10:08:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=A0=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 28 ++++++++++++++++++++++++ app/views/layouts/_base_header.html.erb | 4 +++- app/views/layouts/base.html.erb | 22 +++++++++++++++++++ app/views/layouts/base_bids.html.erb | 1 + app/views/layouts/base_contest.html.erb | 1 + app/views/layouts/base_courses.html.erb | 1 + app/views/layouts/base_forums.html.erb | 1 + app/views/layouts/base_homework.html.erb | 1 + app/views/layouts/base_memos.html.erb | 1 + app/views/layouts/base_projects.html.erb | 1 + app/views/layouts/base_users.html.erb | 1 + 11 files changed, 61 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 28df9a281..26180d815 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1498,5 +1498,33 @@ module ApplicationHelper end end end + + def render_dynamic_nav + home_link = link_to l(:field_homepage), home_path + courses_link = link_to l(:label_course_practice), {:controller => 'projects', :action => 'course', :project_type => 1} + projects_link = link_to l(:label_project_deposit), {:controller => 'projects', :action => 'index', :project_type => 0} + users_link = link_to l(:label_software_user), {:controller => 'users', :action => 'index'} + contest_link = link_to l(:label_contest_innovate), {:controller => 'bids', :action => 'contest', :project_type => 1} + bids_link = link_to l(:label_requirement_enterprise), {:controller => 'bids', :action => 'index'} + forum_link = link_to l(:label_project_module_forums), forums_path + stores_link = link_to l(:label_stores_index), stores_path + + #@nav_dispaly_project_label + nav_list = Array.new + nav_list.push(home_link) + nav_list.push(courses_link) if @nav_dispaly_course_label + nav_list.push(projects_link) if @nav_dispaly_project_label + nav_list.push(users_link) if @nav_dispaly_user_label + nav_list.push(contest_link) if @nav_dispaly_contest_label + nav_list.push(bids_link) if @nav_dispaly_bid_label + nav_list.push(forum_link) if @nav_dispaly_forum_label + nav_list.push(stores_link) + + content_li = '' + nav_list.collect do |nav_item| + content_li << content_tag(:li, nav_item) + end + content_tag :ul, content_li.html_safe + end end diff --git a/app/views/layouts/_base_header.html.erb b/app/views/layouts/_base_header.html.erb index 6d65108eb..3e3ea5a80 100644 --- a/app/views/layouts/_base_header.html.erb +++ b/app/views/layouts/_base_header.html.erb @@ -23,7 +23,9 @@ <% end -%> - <%= render_menu :top_menu if User.current.logged? || !Setting.login_required? -%> + <%#= render_menu :top_menu if User.current.logged? || !Setting.login_required? -%> + <%= render_dynamic_nav if User.current.logged? || !Setting.login_required? -%> + <%# 自建导航条在base页面中以 (@nav_dispaly......) 开头变量设定, 全局搜索即可发现 %>
diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb index fe42d00e8..ff02ca08e 100644 --- a/app/views/layouts/base.html.erb +++ b/app/views/layouts/base.html.erb @@ -1,3 +1,25 @@ +<% + if (request.headers['REQUEST_URI'].match(/course/)) + @nav_dispaly_course_label = 1 + elsif (request.headers['REQUEST_URI'].match(/projects/)) + @nav_dispaly_project_label = 1 + elsif (request.headers['REQUEST_URI'].match(/users/)) + @nav_dispaly_user_label = 1 + elsif (request.headers['REQUEST_URI'].match(/contest/)) + @nav_dispaly_contest_label = 1 + elsif (request.headers['REQUEST_URI'].match(/calls/)) + @nav_dispaly_bid_label = 1 + elsif (request.headers['REQUEST_URI'].match(/forums/)) + @nav_dispaly_forum_label = 1 + else + @nav_dispaly_course_label = 1 + @nav_dispaly_project_label = 1 + @nav_dispaly_user_label = 1 + @nav_dispaly_contest_label = 1 + @nav_dispaly_bid_label = 1 + @nav_dispaly_forum_label = 1 + end +%> diff --git a/app/views/layouts/base_bids.html.erb b/app/views/layouts/base_bids.html.erb index 7024d1713..a8e4963ca 100644 --- a/app/views/layouts/base_bids.html.erb +++ b/app/views/layouts/base_bids.html.erb @@ -1,3 +1,4 @@ +<% @nav_dispaly_bid_label = 1 %> diff --git a/app/views/layouts/base_contest.html.erb b/app/views/layouts/base_contest.html.erb index b62ef96fc..409d1e0a6 100644 --- a/app/views/layouts/base_contest.html.erb +++ b/app/views/layouts/base_contest.html.erb @@ -1,3 +1,4 @@ +<% @nav_dispaly_contest_label = 1 %> diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 5eb34dc99..a4384ea80 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -1,3 +1,4 @@ +<% @nav_dispaly_course_label = 1 %> diff --git a/app/views/layouts/base_forums.html.erb b/app/views/layouts/base_forums.html.erb index 15a12784a..035c71ad6 100644 --- a/app/views/layouts/base_forums.html.erb +++ b/app/views/layouts/base_forums.html.erb @@ -1,3 +1,4 @@ +<% @nav_dispaly_forum_label = 1%> diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index bc328dff5..e9b583ee6 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -1,3 +1,4 @@ +<% @nav_dispaly_course_label = 1 %> diff --git a/app/views/layouts/base_memos.html.erb b/app/views/layouts/base_memos.html.erb index 11c0c672b..5fe199e85 100644 --- a/app/views/layouts/base_memos.html.erb +++ b/app/views/layouts/base_memos.html.erb @@ -1,3 +1,4 @@ +<% @nav_dispaly_forum_label = 1%> diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 15b46fe00..0783a01f5 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -1,3 +1,4 @@ +<% @nav_dispaly_project_label = 1 %> diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index d71555e8d..a08b48314 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -1,3 +1,4 @@ +<% @nav_dispaly_user_label = 1 %>