| 1 | using System; | = | 1 | using System; |
| 2 | using System.Collections; | +- | ||
| 3 | using com.plumtree.openfoundation.util; | = | 2 | using com.plumtree.openfoundation.util; |
| 4 | using com.plumtree.openlog; | 3 | using com.plumtree.openlog; | |
| 5 | using com.plumtree.portalnavigation.common.constants; | 4 | using com.plumtree.portalnavigation.common.constants; | |
| 6 | using com.plumtree.portalpages.browsing.myportal; | 5 | using com.plumtree.portalpages.browsing.myportal; | |
| 7 | using com.plumtree.portalpages.browsing.myportal.communities; | 6 | using com.plumtree.portalpages.browsing.myportal.communities; | |
| 8 | using com.plumtree.portalpages.common.mediator; | 7 | using com.plumtree.portalpages.common.mediator; | |
| 45 | /// JavaScriptIncludes() method on NavTypeJSPortalMenuDropDown to return | = | 44 |   /// JavaScriptIncludes() method on NavTypeJSPortalMenuDropDown to return |
| 46 | /// proper javascript to support this view. | 45 |   /// proper javascript to support this view. | |
| 47 | /// </summary> | 46 |   /// </summary> | |
| 48 | /// <author>robertz</author> | 47 |   /// <author>robertz</author> | |
| 49 | /// <author>DavidP</author> | 48 |   /// <author>DavidP</author> | |
| 50 | /// <author>MichaelD</author> | 49 |   /// <author>MichaelD</author> | |
| 51 | public class subcommalphaorder : IView | <> | 50 |   public class NavigationCommSectionDropDownView : IView |
| 52 | { | = | 51 |   { |
| 53 | public subcommalphaorder() : base() | <> | 52 | public NavigationCommSectionDropDownView() : base() |
| 54 | { | = | 53 | { |
| 55 | } | 54 | } | |
| 56 | private static OpenLogger log = OpenLogService.GetLogger(OpenLogService.GetComponent(PTDebugHelpers.COMPONENT_PORTAL_COMMON), | 55 | private static OpenLogger log = OpenLogService.GetLogger(OpenLogService.GetComponent(PTDebugHelpers.COMPONENT_PORTAL_COMMON), | |
| 57 | "com.plumtree.portalnavigation.views.subcommalphaorder"); | <> | 56 | "com.plumtree.portalnavigation.views.NavigationCommSectionDropDownView"); |
| 58 | = | 57 | ||
| 59 | /// <summary> | 58 | /// <summary> | |
| 60 | /// MVC ID | 59 | /// MVC ID | |
| 61 | /// </summary> | 60 | /// </summary> | |
| 62 | public const String STR_MVC_CLASS_NAME = "NavigationCommSectionDropDown"; | 61 | public const String STR_MVC_CLASS_NAME = "NavigationCommSectionDropDown"; | |
| 63 | // IDs for each of the tabs | 62 | // IDs for each of the tabs | |
| 72 | // we use these views for dynamic routing of browser handling | = | 71 | // we use these views for dynamic routing of browser handling |
| 73 | private NavigationCommSectionComboBoxView m_communityComboBoxView = null; | 72 | private NavigationCommSectionComboBoxView m_communityComboBoxView = null; | |
| 74 | 73 | |||
| 75 | /// <seealso cref="com.plumtree.uiinfrastructure.activityspace.IManagedObject#Create()"></seealso> | 74 | /// <seealso cref="com.plumtree.uiinfrastructure.activityspace.IManagedObject#Create()"></seealso> | |
| 76 | public virtual Object Create() | 75 | public virtual Object Create() | |
| 77 | { | 76 | { | |
| 78 | return new subcommalphaorder(); | <> | 77 | return new NavigationCommSectionDropDownView(); |
| 79 | } | = | 78 | } |
| 80 | 79 | |||
| 81 | /// <seealso cref="com.plumtree.uiinfrastructure.activityspace.IView#Display()"></seealso> | 80 | /// <seealso cref="com.plumtree.uiinfrastructure.activityspace.IView#Display()"></seealso> | |
| 82 | public virtual HTMLElement Display() | 81 | public virtual HTMLElement Display() | |
| 83 | { | 82 | { | |
| 84 | HTMLElementCollection result = new HTMLElementCollection(); | 83 | HTMLElementCollection result = new HTMLElementCollection(); | |
| 195 | HTMLDiv rowdiv = new HTMLDiv(); | = | 185 | HTMLDiv rowdiv = new HTMLDiv(); |
| 196 | rowdiv.SetID("rowdivcontainer"); | 186 | rowdiv.SetID("rowdivcontainer"); | |
| 197 | HTMLLayer rowlayer = new HTMLLayer(); | 187 | HTMLLayer rowlayer = new HTMLLayer(); | |
| 198 | rowlayer.SetID("rowlayercontainer"); | 188 | rowlayer.SetID("rowlayercontainer"); | |
| 199 | // First community pages | 189 | // First community pages | |
| 200 | ICPListEntryIterator cpList = commP.GetCurCommPages(); | 190 | ICPListEntryIterator cpList = commP.GetCurCommPages(); | |
| 201 | result.AddInnerHTMLElement(PopulateLinksRow(m_strInCommID, cpList, false)); | <> | 191 | result.AddInnerHTMLElement(PopulateLinksRow(m_strInCommID, cpList)); |
| 202 | // Subcommunities | = | 192 | // Subcommunities |
| 203 | if (cpSubComms.GetTotalCount() > 0) | 193 | if (cpSubComms.GetTotalCount() > 0) | |
| 204 | { | 194 | { | |
| 205 | result.AddInnerHTMLElement(PopulateLinksRow(m_strSubComms, cpSubComms, true)); | <> | 195 | result.AddInnerHTMLElement(PopulateLinksRow(m_strSubComms, cpSubComms)); |
| 206 | } | = | 196 | } |
| 207 | // The js variable containing the HTML table for the tabs | 197 | // The js variable containing the HTML table for the tabs | |
| 208 | result.AddInnerHTMLElement(JSHelper.AddSafeJSVariable(VARNAME_TABSHTML, | 198 | result.AddInnerHTMLElement(JSHelper.AddSafeJSVariable(VARNAME_TABSHTML, | |
| 209 | "\'" + table.GetDisplayString() + "\'")); | 199 | "\'" + table.GetDisplayString() + "\'")); | |
| 210 | // Display the "In this community" links row when page finishes loading, | 200 | // Display the "In this community" links row when page finishes loading, | |
| 211 | // register the page onload even through the PPC | 201 | // register the page onload even through the PPC | |
| 435 | myAnchor.AddInnerHTMLString(label); | = | 425 | myAnchor.AddInnerHTMLString(label); |
| 436 | elt.AddInnerHTMLElement(myAnchor); | 426 | elt.AddInnerHTMLElement(myAnchor); | |
| 437 | } | 427 | } | |
| 438 | } | 428 | } | |
| 439 | } | 429 | } | |
| 440 | ||||
| 441 | /// <summary> | +- | ||
| 442 | /// Helper function that generates HTMLAnchors from the list of provided links | |||
| 443 | /// and adds them to the specified HTMLElement. | |||
| 444 | /// </summary> | |||
| 445 | /// <param name="cpList1">List of links to generate the HTMLAnchors from</param> | |||
| 446 | /// <param name="elt">HTMLElement to add the HTMLAnchors to</param> | |||
| 447 | /// <throws>HTMLException</throws> | |||
| 448 | protected virtual void GenerateAlphabetizedLinksList(ICPListEntryIterator cpList1, | |||
| 449 | HTMLElement elt) | |||
| 450 | { | |||
| 451 | // this is a new method added to reverse a behavior changed between 5.x and 6.x. | |||
| 452 | // the desired behavior of 5.x was that subcommunities and related communities | |||
| 453 | // were given in an alphabetized list. but in 6.x these are ordered by objectid. | |||
| 454 | // so here we basically loop through the regular iterator, jam it into a hash map | |||
| 455 | // then alphabetize the keys, then extract values from the map based on the array | |||
| 456 | // | |||
| 457 | // this shouldn't be used to show the pages within a community though because | |||
| 458 | // those pages are explicitly ordered within the community editor. | |||
| 459 | log.Info("Inside " + GetName()); | |||
| 460 | int i = 0; | |||
| 461 | ICPListIterator mediator = new CListURLTemplateMediator(m_asOwner, cpList1); | |||
| 462 | mediator.SetLabelMaxLength(50); | |||
| 463 | HTMLAnchor myAnchor; | |||
| 464 | Hashtable hash = new Hashtable(); | |||
| 465 | = | |||
| 466 | while (mediator.Next()) | +- | ||
| 467 | { | |||
| 468 | String[] arURLTempl = (String[]) mediator.GetEntry(); | |||
| 469 | if (1 == arURLTempl.Length) | |||
| 470 | { | |||
| 471 | String label = arURLTempl[CListURLTemplateMediator.TEMPLATEARR_INDEX_LABEL]; | |||
| 472 | hash.Add(label,"__SKIP__URL__PARMS__"); | |||
| 473 | } | |||
| 474 | else | |||
| 475 | { | |||
| 476 | String label = arURLTempl[CListURLTemplateMediator.TEMPLATEARR_INDEX_LABEL]; | |||
| 477 | String urlTempl = arURLTempl[CListURLTemplateMediator.TEMPLATEARR_INDEX_URL]; | |||
| 478 | hash.Add(label,urlTempl); | |||
| 479 | } | |||
| 480 | } | |||
| 481 | ArrayList keys = GetKeys(hash); | |||
| 482 | keys.Sort(); | |||
| 483 | i=0; | |||
| 484 | foreach (string lab in keys) | |||
| 485 | { | |||
| 486 | if (i++ != 0) | |||
| 487 | { | |||
| 488 | // Spacing between links only is required after the first one | |||
| 489 | elt.AddInnerHTMLString(CommonHTMLStrings.SPACE + " |" + CommonHTMLStrings.SPACE); | |||
| 490 | } | |||
| 491 | if ("__SKIP__URL__PARMS__" == hash[lab].ToString()) | |||
| 492 | { // and the current page doesn't need a link | |||
| 493 | String label = lab; | |||
| 494 | elt.AddInnerHTMLString(NavigationCommonHelpers.EscapeSingleQuotes(label)); | |||
| 495 | } | |||
| 496 | else | |||
| 497 | { // but all other pages get the link | |||
| 498 | String urlTempl = hash[lab].ToString(); | |||
| 499 | String label = lab; | |||
| 500 | // Need to escape any eventual single quotes in the name since the generated html | |||
| 501 | // will be put into a javascript variable | |||
| 502 | label = GeneralHelpers.Replace(label, "\'", "\\\'"); | |||
| 503 | myAnchor = new HTMLAnchor("#"); | |||
| 504 | myAnchor.SetOnClick(NavigationCommonHelpers.URLTEMPLATE_REDIRECT_JSFUNCNAME + "(\\\'" + urlTempl + "\\\'); return false;"); | |||
| 505 | myAnchor.AddInnerHTMLString(label); | |||
| 506 | elt.AddInnerHTMLElement(myAnchor); | |||
| 507 | } | |||
| 508 | } | |||
| 509 | } | |||
| 510 | = | |||
| 511 | public static ArrayList GetKeys(Hashtable table) | +- | ||
| 512 | { | |||
| 513 | return (new ArrayList(table.Keys)); | |||
| 514 | } | |||
| 515 | = | 430 | ||
| 516 | /// <summary> | 431 | /// <summary> | |
| 517 | /// Puts the rows of links in a javascript variable. Also adds a Join this Community | 432 | /// Puts the rows of links in a javascript variable. Also adds a Join this Community | |
| 518 | /// button if the user isn't member of the current community and Edit This Community button | 433 | /// button if the user isn't member of the current community and Edit This Community button | |
| 519 | /// if the user has at least Edit access to the current community. | 434 | /// if the user has at least Edit access to the current community. | |
| 520 | /// </summary> | 435 | /// </summary> | |
| 521 | /// <param name="strID">Name of the javascript variable</param> | 436 | /// <param name="strID">Name of the javascript variable</param> | |
| 522 | /// <param name="cpList">List of links</param> | 437 | /// <param name="cpList">List of links</param> | |
| 523 | /// <returns>HTMLScript HTMLScript block with the variable definition</returns> | 438 | /// <returns>HTMLScript HTMLScript block with the variable definition</returns> | |
| 524 | /// <throws>HTMLException</throws> | 439 | /// <throws>HTMLException</throws> | |
| 525 | /// <throws>Exception</throws> | 440 | /// <throws>Exception</throws> | |
| 526 | protected virtual HTMLScript PopulateLinksRow(String strID, ICPListEntryIterator cpList, bool bIsAlphaSort) | <> | 441 | protected virtual HTMLScript PopulateLinksRow(String strID, ICPListEntryIterator cpList) |
| 527 | { | = | 442 | { |
| 528 | if (cpList != null) | 443 | if (cpList != null) | |
| 529 | { | 444 | { | |
| 530 | // Spacer image for padding | 445 | // Spacer image for padding | |
| 531 | HTMLImg image = null; | 446 | HTMLImg image = null; | |
| 532 | image = PlumtreeHelpers.GetSpacerImage("5", "1"); | 447 | image = PlumtreeHelpers.GetSpacerImage("5", "1"); | |
| 557 | HTMLTableCell tSectionTabCell = new HTMLTableCell(); | = | 472 | HTMLTableCell tSectionTabCell = new HTMLTableCell(); |
| 558 | tSectionTabCell.SetWidth(CommonHTMLStrings.ONE_HUNDRED_PERCENT); | 473 | tSectionTabCell.SetWidth(CommonHTMLStrings.ONE_HUNDRED_PERCENT); | |
| 559 | tSectionTabCell.SetHeight("20"); | 474 | tSectionTabCell.SetHeight("20"); | |
| 560 | HTMLSpan span = new HTMLSpan(); | 475 | HTMLSpan span = new HTMLSpan(); | |
| 561 | span.SetStyleClass(PTStyleClass.BREADCRUMB_TEXT); | 476 | span.SetStyleClass(PTStyleClass.BREADCRUMB_TEXT); | |
| 562 | // adds links nested in one span | 477 | // adds links nested in one span | |
| 563 | if (bIsAlphaSort) | +- | ||
| 564 | { | |||
| 565 | GenerateAlphabetizedLinksList(cpList, span); | |||
| 566 | } else { | |||
| 567 | GenerateLinksList(cpList, span); | = | 478 | GenerateLinksList(cpList, span); |
| 568 | } | +- | ||
| 569 | tSectionTabCell.AddInnerHTMLElement(span); | = | 479 | tSectionTabCell.AddInnerHTMLElement(span); |
| 570 | tRow.AddInnerHTMLElement(tSectionTabCell); | 480 | tRow.AddInnerHTMLElement(tSectionTabCell); | |
| 571 | // Add the Edit this Community and Join this Community buttons if applicable | 481 | // Add the Edit this Community and Join this Community buttons if applicable | |
| 572 | // Spacer image | 482 | // Spacer image | |
| 573 | HTMLImg image2 = null; | 483 | HTMLImg image2 = null; | |
| 574 | image2 = (HTMLImg) UIConstructFactory.GetConstruct(PTImageType.SPACER, | 484 | image2 = (HTMLImg) UIConstructFactory.GetConstruct(PTImageType.SPACER, | |
| 722 | // No related Communities | = | 632 | // No related Communities |
| 723 | innerSpan.AddInnerHTMLString(m_asOwner.GetString(330, ResourceConstants.PORTALCOMMONMSGS)); | 633 | innerSpan.AddInnerHTMLString(m_asOwner.GetString(330, ResourceConstants.PORTALCOMMONMSGS)); | |
| 724 | innerSpan.AddInnerHTMLString(CommonHTMLStrings.SPACE); | 634 | innerSpan.AddInnerHTMLString(CommonHTMLStrings.SPACE); | |
| 725 | } else | 635 | } else | |
| 726 | { | 636 | { | |
| 727 | // adds links nested in span | 637 | // adds links nested in span | |
| 728 | GenerateAlphabetizedLinksList(cpList, innerSpan); | <> | 638 | GenerateLinksList(cpList, innerSpan); |
| 729 | } | = | 639 | } |
| 730 | tSectionTabCell.AddInnerHTMLElement(innerSpan); | 640 | tSectionTabCell.AddInnerHTMLElement(innerSpan); | |
| 731 | } | 641 | } | |
| 732 | tRow.AddInnerHTMLElement(tSectionTabCell); | 642 | tRow.AddInnerHTMLElement(tSectionTabCell); | |
| 733 | // Put the entire HTML in a javascript variable (using SafeJSVar) and return it | 643 | // Put the entire HTML in a javascript variable (using SafeJSVar) and return it | |
| 734 | return JSHelper.AddSafeJSVariable(strID, "\'" + tTable.GetDisplayString() + "\'"); | 644 | return JSHelper.AddSafeJSVariable(strID, "\'" + tTable.GetDisplayString() + "\'"); | |
| 735 | } | 645 | } | |
| 736 | } | 646 |   } | |
| 737 | } | 647 | } | |