## ---------- Common variables ---------- ##

#set ($theme_display = $themeDisplay)
#set ($portlet_display = $portletDisplay)

#set ($theme_timestamp = $themeDisplay.getTheme().getTimestamp())
#set ($theme_settings = $themeDisplay.getTheme().getSettings())

#set ($css_class = $theme_display.getColorScheme().getCssClass())

#if ($layout)
	#set ($page_group = $layout.getGroup())

	#if ($page_group.isStagingGroup())
		#set ($css_class = $css_class + " staging")
	#elseif ($theme_display.isShowStagingIcon() && $page_group.hasStagingGroup())
		#set ($css_class = $css_class + " live-view")
	#elseif ($theme_display.isShowStagingIcon() && $page_group.isStagedRemotely())
		#set ($css_class = $css_class + " remote-staging")
	#end
#end

<!-- EDIT For gCube Portal Bundle. Make Toggle edit control untoggled at the beginning for all users, and bur unpinned-->

#set ($liferay_toggle_controls = $sessionClicks.get($request, "liferay_toggle_controls", "hidden"))
#set ($liferay_dockbar_pinned = $sessionClicks.get($request, "liferay_dockbar_pinned", "false"))
<!-- END EDIT For Portal Bundle. -->

#if ($liferay_toggle_controls == "visible")
	#set ($css_class = $css_class + " controls-visible")
#else
	#set ($css_class = $css_class + " controls-hidden")
#end

#if($liferay_dockbar_pinned == "true")
	#set ($css_class = $css_class + " lfr-dockbar-pinned")
#end

#if ($layoutTypePortlet.hasStateMax())
	#set ($css_class = $css_class + " page-maximized")
#end

#set ($css_folder = "$theme_display.getPathThemeCss()")
#set ($images_folder = "$theme_display.getPathThemeImages()")
#set ($javascript_folder = "$theme_display.getPathThemeJavaScript()")
#set ($templates_folder = "$theme_display.getPathThemeTemplates()")

#set ($full_css_path = $fullCssPath)
#set ($full_templates_path = $fullTemplatesPath)

#set ($css_main_file = $htmlUtil.escape($portalUtil.getStaticResourceURL($request, "$css_folder/main.css")))
#set ($js_main_file = $htmlUtil.escape($portalUtil.getStaticResourceURL($request, "$javascript_folder/javascript.js")))

#set ($company_id = $company.getCompanyId())
#set ($company_name = $company.getName())
#set ($company_logo = $theme_display.getCompanyLogo())
#set ($company_logo_height = $theme_display.getCompanyLogoHeight())
#set ($company_logo_width = $theme_display.getCompanyLogoWidth())
#set ($company_url = $theme_display.getURLHome())

#if (!$request.isRequestedSessionIdFromCookie())
	#set ($company_url = $portalUtil.getURLWithSessionId($company_url, $request.getSession().getId()))
#end

#set ($user_id = $user.getUserId())
#set ($is_default_user = $user.isDefaultUser())
#set ($user_first_name = $user.getFirstName())
#set ($user_middle_name = $user.getMiddleName())
#set ($user_last_name = $user.getLastName())
#set ($user_name = $user.getFullName())
#set ($is_male = $user.isMale())
#set ($is_female = $user.isFemale())
#set ($user_birthday = $user.getBirthday())
#set ($user_email_address = $user.getEmailAddress())
#set ($language_id = $user.getLanguageId())
#set ($w3c_language_id = $localeUtil.toW3cLanguageId($language_id))
#set ($time_zone = $user.getTimeZoneId())
#set ($user_greeting = $htmlUtil.escape($user.getGreeting()))
#set ($user_comments = $user.getComments())
#set ($user_login_ip = $user.getLoginIP())
#set ($user_last_login_ip = $user.getLastLoginIP())

#set ($is_signed_in = $theme_display.isSignedIn())

#set ($group_id = $theme_display.getScopeGroupId())

## ---------- URLs ---------- ##

#set ($show_add_content = $theme_display.isShowAddContentIcon())

#if ($show_add_content)
	#set ($add_content_text = $languageUtil.get($locale, "add-application"))
	#set ($add_content_url = $theme_display.getURLAddContent())

	#set ($layout_text = $languageUtil.get($locale, "layout-template"))
	#set ($layout_url = $theme_display.getURLLayoutTemplates())
#end

#set ($show_control_panel = $theme_display.isShowControlPanelIcon())

#if ($show_control_panel)
	#set ($control_panel_text = $languageUtil.get($locale, "control-panel"))
	#set ($control_panel_url = $htmlUtil.escape($theme_display.getURLControlPanel()))
#end

#set ($show_home = $theme_display.isShowHomeIcon())

#if ($show_home)
	#set ($home_text = $languageUtil.get($locale, "home"))
	#set ($home_url = $htmlUtil.escape($theme_display.getURLHome()))

	#if (!$request.isRequestedSessionIdFromCookie())
		#set ($home_url = $htmlUtil.escape($portalUtil.getURLWithSessionId($home_url, $request.getSession().getId())))
	#end
#end

#set ($show_my_account = $theme_display.isShowMyAccountIcon())

#if ($show_my_account)
	#set ($my_account_text = $languageUtil.get($locale, "my-account"))
	#set ($my_account_url = $htmlUtil.escape($theme_display.getURLMyAccount().toString()))
#end

#set ($show_page_settings = $theme_display.isShowPageSettingsIcon())

#if ($show_page_settings)
	#set ($page_settings_text = $languageUtil.get($locale, "manage-pages"))
	#set ($page_settings_url = $htmlUtil.escape($theme_display.getURLPageSettings().toString()))
#end

#set ($show_sign_in = $theme_display.isShowSignInIcon())

#if ($show_sign_in)
	#set ($sign_in_text = $languageUtil.get($locale, "sign-in"))
	#set ($sign_in_url = $htmlUtil.escape($theme_display.getURLSignIn()))
#end

#set ($show_sign_out = $theme_display.isShowSignOutIcon())

#if ($show_sign_out)
	#set ($sign_out_text = $languageUtil.get($locale, "sign-out"))
	#set ($sign_out_url = $htmlUtil.escape($theme_display.getURLSignOut()))
#end

#set ($show_toggle_controls = $theme_display.isSignedIn())

#if ($show_toggle_controls)
	#set ($toggle_controls_text = $languageUtil.get($locale, "toggle-edit-controls"))
	#set ($toggle_controls_url = "javascript:;")
#end

#if ($permissionChecker.isOmniadmin() && $portalUtil.isUpdateAvailable())
	#set ($update_available_url = $htmlUtil.escape($theme_display.getURLUpdateManager().toString()))
#end

## ---------- Page ---------- ##

#set ($the_title = "")
#set ($selectable = $theme_display.isTilesSelectable())
#set ($is_maximized = $layoutTypePortlet.hasStateMax())
#set ($is_freeform = $themeDisplay.isFreeformLayout())

#set ($page_javascript_1 = "")
#set ($page_javascript_2 = "")
#set ($page_javascript_3 = "")

#if ($layout)
	#set ($page = $layout)

	#set ($is_first_child = $page.isFirstChild())
	#set ($is_first_parent = $page.isFirstParent())

	#set ($the_title = $languageUtil.get($locale, $the_title, $page.getName($locale)))

	#if ($page.getType().equals("portlet"))
		#set ($is_portlet_page = true)
	#end

	#if ($is_portlet_page && $theme_display.isWapTheme())
		#set ($all_portlets = $layoutTypePortlet.getPortlets())
		#set ($column_1_portlets = $layoutTypePortlet.getAllPortlets("column-1"))
		#set ($column_2_portlets = $layoutTypePortlet.getAllPortlets("column-2"))
		#set ($column_3_portlets = $layoutTypePortlet.getAllPortlets("column-3"))
		#set ($column_4_portlets = $layoutTypePortlet.getAllPortlets("column-4"))
		#set ($column_5_portlets = $layoutTypePortlet.getAllPortlets("column-5"))

		#if ($layoutTypePortlet.hasStateMax())
			#set ($maximized_portlet_id = $layoutTypePortlet.getStateMaxPortletId())
		#end
	#end

	#set ($typeSettingsProperties = $layout.getTypeSettingsProperties())

	#set ($page_javascript_1 = $typeSettingsProperties.getProperty("javascript-1"))
	#set ($page_javascript_2 = $typeSettingsProperties.getProperty("javascript-2"))
	#set ($page_javascript_3 = $typeSettingsProperties.getProperty("javascript-3"))

	#set ($community_name = $htmlUtil.escape($page_group.getDescriptiveName()))

	#if	($page_group.getName() == "Guest")
		#set ($css_class = $css_class + " guest-community")
	#end

	#if	($is_signed_in)
		#set ($css_class = $css_class + " signed-in")
	#else
		#set ($css_class = $css_class + " signed-out")
	#end

	#if	($layout.isPublicLayout())
		#set ($css_class = $css_class + " public-page")
	#else
		#set ($css_class = $css_class + " private-page")
	#end

	#if	($page_group.isUser() && $layout.isPrivateLayout())
		#set ($community_name = $languageUtil.get($locale, "my-community"))
	#end

	#set ($my_places_portlet_url = $portletURLFactory.create($request, "49", $page.getPlid(), "ACTION_PHASE"))

	$my_places_portlet_url.setWindowState("normal")
	$my_places_portlet_url.setPortletMode("view")

	$my_places_portlet_url.setParameter("struts_action", "/my_places/view")
	$my_places_portlet_url.setParameter("groupId", "$page.getGroupId()")
	$my_places_portlet_url.setParameter("privateLayout", "false")

	#set ($community_default_public_url = $htmlUtil.escape($my_places_portlet_url.toString()))

	$my_places_portlet_url.setParameter("privateLayout", "true")

	#set ($community_default_private_url = $htmlUtil.escape($my_places_portlet_url.toString()))

	#set ($community_default_url = $community_default_public_url)

	#if ($layout.isPrivateLayout())
		#set ($community_default_url = $community_default_private_url)
	#end
#end

#if ($layout.getHTMLTitle($locale))
	#set ($the_title = $layout.getHTMLTitle($locale))
#end

#if ($pageTitle)
	#set ($the_title = $pageTitle)
#end

#if ($pageSubtitle)
	#set ($the_title = $pageSubtitle + " - " + $the_title)
#end

#if ($tilesTitle != "")
	#set ($the_title = $languageUtil.get($locale, $tilesTitle))
#end

#set ($the_title = $htmlUtil.escape($the_title))

#if ($layouts)
	#set ($pages = $layouts)
#end

## ---------- Navigation ---------- ##

#if ($navItems)
	#set ($nav_items = $navItems)
	#set ($has_navigation = ($nav_items && $nav_items.size() > 0))
#end

## ---------- Staging ---------- ##

#set ($show_staging = $theme_display.isShowStagingIcon())

#if ($show_staging)
	#set ($staging_text = $languageUtil.get($locale, "staging"))
#end

## ---------- My places ---------- ##

#set ($show_my_places = $user.hasMyPlaces())

#if ($show_my_places)
	#set ($my_places_text = $languageUtil.get($locale, "my-places"))
#end

## ---------- Includes ---------- ##

#if ($is_portlet_page && $theme_display.isWapTheme())
	#set ($dir_include = "/wap")
#else
	#set ($dir_include = "/html")
#end

#set ($bottom_include = "$dir_include/common/themes/bottom.jsp")
#set ($bottom_ext_include = $bottom_include)
#set ($content_include = "$dir_include$tilesContent")
#set ($top_head_include = "$dir_include/common/themes/top_head.jsp")
#set ($top_messages_include = "$dir_include/common/themes/top_messages.jsp")

## ---------- Date ---------- ##

#set ($date = $dateUtil)

#set ($current_time = $date.getCurrentDate())
#set ($the_year = $date.getCurrentDate("yyyy", $locale))

## ---------- Custom init ---------- ##

#parse ("$full_templates_path/init_custom.vm")