pagecontent/app/controllers/page_contents_controller.rb

24 lines
865 B
Ruby
Raw Normal View History

2014-05-06 09:20:15 +00:00
class PageContentsController < OrbitAdminController
2014-08-05 06:45:30 +00:00
def index
params = OrbitHelper.params
2016-08-24 13:28:22 +00:00
if params["wiki"].present?
page = WikiPage.where(:uid => params["wiki"]).first
name = page.title rescue ""
html = page.content rescue ""
url_to_edit = OrbitHelper.user_can_edit?(page) ? "/admin/wiki_pages/#{page.id}/edit?page_id=#{page.page.id.to_s}" : ""
else
page = Page.where(:page_id => params[:page_id]).first
name = page.name rescue ""
html = page.page_contexts.last.content rescue ""
url_to_edit = OrbitHelper.user_can_edit?(page) ? "/admin/page_contents/new?page_id=#{page.id.to_s}" : ""
end
2014-08-05 06:45:30 +00:00
{
2016-08-24 13:28:22 +00:00
"html" => html,
"title" => name,
2015-04-13 06:35:21 +00:00
"view_count" => (page.view_count rescue ""),
2015-04-13 06:13:41 +00:00
"view-count-head" =>t('page_content.view_count'),
2014-08-05 06:45:30 +00:00
"url_to_edit" => url_to_edit
}
end
2014-05-06 09:20:15 +00:00
end