// Copyright (C) Thomas Legault 2008 - All Rights Reserved

function ContentTypeCache()
{this.CoreInstanceObjectCache();}
copyPrototype(ContentTypeCache,CoreInstanceObjectCache);ContentTypeCache.prototype.getAjaxRequest=function()
{var ajaxRequest=new AjaxRequest(APP_URL+"/content_type.do");ajaxRequest.addParam("action","listContentTypes");return ajaxRequest;}
ContentTypeCache.prototype.onCreateCacheData=function(response)
{eval(response.getJavaScript());return contentTypes;}
function PortalContentType(contentTypeInstance,nameFieldId,itemLayoutFieldId,listLayoutFieldId)
{this.CoreInstanceObject(contentTypeInstance);this.m_nameFieldId=nameFieldId;this.m_itemLayoutFieldId=itemLayoutFieldId;this.m_listLayoutFieldId=listLayoutFieldId;}
copyPrototype(PortalContentType,CoreInstanceObject);PortalContentType.prototype.getName=function()
{var values=this.m_instance.getValues(this.m_nameFieldId);return values.getValue(0).text_value;}
PortalContentType.prototype.getItemLayout=function()
{return this.m_instance.getText_Value(this.m_itemLayoutFieldId);}
PortalContentType.prototype.setItemLayout=function(htmlVal)
{this.m_instance.setText_Value(this.m_itemLayoutFieldId,htmlVal);}
PortalContentType.prototype.getListLayout=function()
{return this.m_instance.getText_Value(this.m_listLayoutFieldId);}
PortalContentType.prototype.setListLayout=function(htmlVal)
{this.m_instance.setText_Value(this.m_listLayoutFieldId,htmlVal);}
function PortalPage(instance,parentFieldId,orderFieldId,securedFieldId,aliasFieldId,cannotDeleteFieldId)
{this.CoreTreeItem(instance,parentFieldId,orderFieldId);this.m_securedFieldId=securedFieldId;this.m_aliasFieldId=aliasFieldId;this.m_cannotDeleteFieldId=cannotDeleteFieldId;this.m_portalPageSections=null;}
copyPrototype(PortalPage,CoreTreeItem);PortalPage.prototype.isSecured=function()
{var values=this.m_instance.getValues(this.m_securedFieldId);if(values==null)
{return false;}
return values.getValue(0).int_value=="1";}
PortalPage.prototype.getAlias=function()
{return this.m_instance.getText_Value(this.m_aliasFieldId);}
PortalPage.prototype.setPortalPageSections=function(val)
{this.m_portalPageSections=val;}
PortalPage.prototype.getPortalPageSections=function(val)
{return this.m_portalPageSections;}
function PortalImage(imageInstance)
{this.CoreListItem(imageInstance);}
copyPrototype(PortalImage,CoreListItem);var PORTAL_PAGE_SECTION_TYPE_ITEM="1";var PORTAL_PAGE_SECTION_TYPE_LIST="2";var PORTAL_PAGE_SECTION_TYPE_CALENDAR="3";var PORTAL_PAGE_SECTION_TYPE_USER_CONTENT="4";var PORTAL_PAGE_SECTION_TYPE_SEARCH="6";var PORTAL_PAGE_SECTION_TYPE_CREATE_ITEM="7";var PORTAL_PAGE_SECTION_LIST_OPTION_ALPHABETICAL="alphabetical";function PortalPageSection(pageInstance,pageFieldId,typeFieldId,contentTypeFieldId,identifierFieldId,optionsFieldId,orderFieldId)
{this.CoreInstanceObject(pageInstance);this.m_pageFieldId=pageFieldId;this.m_typeFieldId=typeFieldId;this.m_contentTypeFieldId=contentTypeFieldId;this.m_identifierFieldId=identifierFieldId;this.m_optionsFieldId=optionsFieldId;this.m_orderFieldId=orderFieldId;this.m_query=null;}
copyPrototype(PortalPageSection,CoreInstanceObject);PortalPageSection.prototype.getPageInstanceId=function()
{var values=this.m_instance.getValues(this.m_pageFieldId);return values.getValue(0).int_value;}
PortalPageSection.prototype.getType=function()
{var values=this.m_instance.getValues(this.m_typeFieldId);return values.getValue(0).int_value;}
PortalPageSection.prototype.getTypeName=function()
{return this.m_instance.getDisplayValue(this.m_typeFieldId);}
PortalPageSection.prototype.getContentTypeInstanceId=function()
{var values=this.m_instance.getValues(this.m_contentTypeFieldId);return values.getValue(0).int_value;}
PortalPageSection.prototype.getContentTypeIdentifier=function()
{var values=this.m_instance.getValues(this.m_identifierFieldId);return values.getValue(0).int_value;}
PortalPageSection.prototype.setPageInstanceId=function(intVal)
{this.m_instance.setInt_Value(this.m_pageFieldId,intVal);}
PortalPageSection.prototype.setType=function(intVal)
{this.m_instance.setInt_Value(this.m_typeFieldId,intVal);}
PortalPageSection.prototype.setContentTypeInstanceId=function(intVal)
{this.m_instance.setInt_Value(this.m_contentTypeFieldId,intVal);}
PortalPageSection.prototype.setContentTypeIdentifier=function(intVal)
{this.m_instance.setInt_Value(this.m_identifierFieldId,intVal);}
PortalPageSection.prototype.setContentQuery=function(query)
{this.m_query=query;}
PortalPageSection.prototype.getContentQuery=function()
{return this.m_query;}
PortalPageSection.prototype.getOptions=function()
{this.m_instance.getText_Value(this.m_optionsFieldId);}
PortalPageSection.prototype.setOptionValue=function(option,value)
{var parsedOptions=parseOptionsString(this.getOptions());parsedOptions[option]=value;if(value==null||value.length==0)
{parsedOptions[option]=null;}
var options=createOptionsString(parsedOptions);this.setOptions(options);}
PortalPageSection.prototype.setOptions=function(options)
{this.m_instance.setText_Value(this.m_optionsFieldId,options);}
PortalPageSection.prototype.getOrder=function()
{return this.m_instance.getInt_Value(this.m_orderFieldId);}
PortalPageSection.prototype.setOrder=function(order)
{return this.m_instance.setInt_Value(this.m_orderFieldId,order);}
PortalPageSection.prototype.isUserContent=function()
{return this.getType()==PORTAL_PAGE_SECTION_TYPE_USER_CONTENT;}
function PortalUserContent(userContentInstance,itemInstance)
{this.CoreInstanceObject(userContentInstance);this.m_itemInstance=itemInstance;}
copyPrototype(PortalUserContent,CoreInstanceObject);PortalUserContent.prototype.getItemInstance=function()
{return this.m_itemInstance;}
function PortalMailingList(imageInstance)
{this.CoreListItem(imageInstance);}
copyPrototype(PortalMailingList,CoreListItem);function PortalFile(imageInstance)
{this.CoreListItem(imageInstance);}
copyPrototype(PortalFile,CoreListItem);var PORTAL_FIELD_INTERNAL_OPTION="portalInternal";var PORTAL_FIELD_TITLE_OPTION="portalTitle";DOC_MGR.registerFieldOption(new DocumentFieldOption("Portal: Internal Field",PORTAL_FIELD_INTERNAL_OPTION,DocumentFieldOption_Boolean,null));DOC_MGR.registerFieldOption(new DocumentFieldOption("Portal: Title Field",PORTAL_FIELD_TITLE_OPTION,DocumentFieldOption_Boolean,null));function PortalPageSectionsGridData(portalPageSections)
{this.GridData();this.m_portalPageSections=portalPageSections;if(this.m_portalPageSections==null)
{this.m_portalPageSections=new Array();}
this.m_contentTypeCache=coreApp.getContentTypeCache();}
copyPrototype(PortalPageSectionsGridData,GridData);PortalPageSectionsGridData.prototype.getColumnCount=function()
{return 2;}
PortalPageSectionsGridData.prototype.getRowCount=function()
{return this.m_portalPageSections.length;}
PortalPageSectionsGridData.prototype.displayColumnHeader=function()
{return true;}
PortalPageSectionsGridData.prototype.getColumnWidth=function(colIndex)
{if(colIndex==0)
{return 250;}
return 120;}
PortalPageSectionsGridData.prototype.getColumnHeader=function(colIndex)
{if(colIndex==0)
{var header=new GridHeader(getResource(PORTAL_UI_CONTENT_TYPE),getResource(PORTAL_UI_CONTENT_TYPE),colIndex);return header;}
var header=new GridHeader(getResource(PORTAL_UI_PAGE_SETION_TYPE),getResource(PORTAL_UI_PAGE_SETION_TYPE),colIndex);return header;}
PortalPageSectionsGridData.prototype.getCell=function(rowIndex,colIndex)
{var portalPageSection=this.m_portalPageSections[rowIndex];var sectionType=portalPageSection.getType();var txtValue;if(colIndex==0)
{var contentTypeInstId=portalPageSection.getContentTypeInstanceId();var portalContentType=this.m_contentTypeCache.getCoreInstanceObject(contentTypeInstId);txtValue=portalContentType.getName();}
else
{txtValue=portalPageSection.getTypeName();}
var gridCell=new GridCellText(txtValue,rowIndex,colIndex);return gridCell;}
PortalPageSectionsGridData.prototype.getPageSection=function(index)
{return this.m_portalPageSections[index];}
PortalPageSectionsGridData.prototype.setPageSection=function(index,val)
{this.m_portalPageSections[index]=val;}
PortalPageSectionsGridData.prototype.deletePageSection=function(index)
{this.m_portalPageSections=removeFromArray(this.m_portalPageSections,index);}
PortalPageSectionsGridData.prototype.addPageSection=function(pageSection)
{this.m_portalPageSections.push(pageSection);}
PortalPageSectionsGridData.prototype.getPortalPageSections=function()
{return this.m_portalPageSections;}
PortalPageSectionsGridData.prototype.comparePortalSectionOrder=function(pageSection1,pageSection2)
{var num1=pageSection1.getOrder();var num2=pageSection2.getOrder();return num1-num2;}
PortalPageSectionsGridData.prototype.sortPortalPageSections=function()
{this.m_portalPageSections.sort(this.comparePortalSectionOrder.bind(this));}
function PageTreeEditor(secure,windowManager)
{this.m_secure=secure;var settings=new CoreTreeEditorSettings();settings.m_newIcon=APP_URL+"/images/portal/page_tree/item_new.png"
settings.m_editIcon=APP_URL+"/images/portal/page_tree/item_edit.png";settings.m_deleteIcon=APP_URL+"/images/portal/page_tree/item_delete.png";settings.m_searchIcon=null;settings.m_refreshIcon=APP_URL+"/images/portal/page_tree/item_refresh.png";settings.m_itemIcon=APP_URL+"/images/portal/page_tree/item_small.png";settings.m_moveParentIcon=APP_URL+"/images/portal/page_tree/item_parent.png";settings.m_moveDownIcon=APP_URL+"/images/portal/page_tree/item_down.png";settings.m_moveUpIcon=APP_URL+"/images/portal/page_tree/item_up.png";settings.m_action="navigation.do";settings.m_maxDepth=4;settings.m_listItemName=getResource(PAGE_EDITOR_SINGLE_ITEM);settings.m_listItemsName=getResource(PAGE_EDITOR_MULTIPLE_ITEMS);this.CoreTreeEditor(settings,windowManager);this.m_debugName="PageTreeEditor";}
copyPrototype(PageTreeEditor,CoreTreeEditor);PageTreeEditor.prototype.getAjaxRequest=function()
{var request=CoreTreeEditor.prototype.getAjaxRequest.apply(this,arguments);if(this.m_secure=="1")
{request.addParam("SECURED_PAGES","1");}
else
{request.addParam("SECURED_PAGES","0");}
return request;}
PageTreeEditor.prototype.createToolbar=function()
{CoreTreeEditor.prototype.createToolbar.apply(this,arguments);this.m_previewBtn=this.m_toolbar.addIconButton(APP_URL+"/images/core/ui/toolbar/item_preview.png",getResource(PORTAL_UI_PREVIEW_PAGE));this.m_previewBtn.disable();}
PageTreeEditor.prototype.onToolbarButtonClick=function(objBtn)
{CoreTreeEditor.prototype.onToolbarButtonClick.apply(this,arguments);if(objBtn==this.m_previewBtn)
{this.onPreviewPage();}}
PageTreeEditor.prototype.getListCoreTreeItemsRequest=function()
{var request=CoreTreeEditor.prototype.getListCoreTreeItemsRequest.apply(this,arguments);request.addParam("securedPage",this.m_secure);return request;}
PageTreeEditor.prototype.getCoreTreeItemWindow=function(coreTreeItem,parentCoreTreeItemInstanceId)
{var objWin=new PageWindow(this,coreTreeItem,parentCoreTreeItemInstanceId);objWin.setType(this.m_windowType);return objWin;}
PageTreeEditor.prototype.onTreeSelectionChange=function(objTree)
{CoreTreeEditor.prototype.onTreeSelectionChange.apply(this,arguments);var objNode=this.m_tree.getSelectedNode();if(objNode!=null)
{this.m_toolbar.enableButton(this.m_previewBtn);}
else
{this.m_toolbar.disableButton(this.m_previewBtn);}}
PageTreeEditor.prototype.onPreviewPage=function()
{var objNode=this.m_tree.getSelectedNode();var pAlias=objNode.CORE_TREE_ITEM.getAlias();if(pAlias==null||pAlias.length==0)
{window.open(APP_URL+"/pi/"+DATA_LANGUAGE+"/"+objNode.CORE_TREE_ITEM.getInstanceId(),"PortalPreview");}
else
{var pAliases=pAlias.split(";");window.open(APP_URL+"/pa/"+DATA_LANGUAGE+"/"+pAliases[0],"PortalPreview");}}
function ImageListEditor(windowManager)
{var settings=new CoreListEditorSettings();settings.m_newIcon=APP_URL+"/images/portal/toolbar/image_new.png";settings.m_editIcon=APP_URL+"/images/portal/toolbar/image_edit.png";settings.m_deleteIcon=APP_URL+"/images/portal/toolbar/image_delete.png";settings.m_searchIcon=null;settings.m_refreshIcon=APP_URL+"/images/acquiro/editors/list_icons/item_refresh.png";settings.m_action="image.do";settings.m_sorted=true;settings.m_listItemName=getResource(PORTAL_UI_IMAGE);settings.m_listItemsName=getResource(PORTAL_UI_IMAGES);this.CoreListEditor(settings,windowManager);this.m_debugName="ImageListEditor";}
copyPrototype(ImageListEditor,CoreListEditor);function MailingListEditor(windowManager)
{var settings=new CoreListEditorSettings();settings.m_newIcon=APP_URL+"/images/acquiro/editors/list_icons/item_new.png";settings.m_editIcon=APP_URL+"/images/acquiro/editors/list_icons/item_edit.png";settings.m_deleteIcon=APP_URL+"/images/acquiro/editors/list_icons/item_delete.png";settings.m_searchIcon=null;settings.m_refreshIcon=APP_URL+"/images/acquiro/editors/list_icons/item_refresh.png";settings.m_action="mailinglist.do";settings.m_sorted=true;settings.m_listItemName=getResource(PORTAL_UI_MAILING_LIST);settings.m_listItemsName=getResource(PORTAL_UI_MAILING_LISTS);this.CoreListEditor(settings,windowManager);this.m_debugName="MailingListEditor";}
copyPrototype(MailingListEditor,CoreListEditor);MailingListEditor.prototype.createToolbar=function()
{CoreListEditor.prototype.createToolbar.apply(this,arguments);this.m_sendBtn=this.m_toolbar.addIconTextButton(APP_URL+"/images/acquiro/messaging/item_send.png",getResource(MESSAGING_LIST_SEND_MESSAGE),getResource(MESSAGING_LIST_SEND_MESSAGE_DESC));this.m_toolbar.disableButton(this.m_sendBtn);}
MailingListEditor.prototype.onListSelectionChange=function(objList)
{CoreListEditor.prototype.onListSelectionChange.apply(this,arguments);if(this.m_list.getSelectedItems().length>0)
{this.m_toolbar.enableButton(this.m_sendBtn);}
else
{this.m_toolbar.disableButton(this.m_sendBtn);}}
MailingListEditor.prototype.onToolbarButtonClick=function(objBtn)
{CoreListEditor.prototype.onToolbarButtonClick.apply(this,arguments);if(objBtn==this.m_sendBtn)
{this.onSendMessage();}}
MailingListEditor.prototype.onSendMessage=function(objBtn)
{this.m_sendDlg=new MailingListSendDialog(this.m_list.getSelectedItems()[0]);this.m_sendDlg.showDialog(this.onSendMessageDialog_Closed.bind(this));}
MailingListEditor.prototype.onSendMessageDialog_Closed=function(cancelled)
{this.m_sendDlg.deletePanel();this.m_sendDlg=null;}
function FileListEditor(windowManager)
{var settings=new CoreListEditorSettings();settings.m_newIcon=APP_URL+"/images/portal/toolbar/file_new.png";settings.m_editIcon=APP_URL+"/images/portal/toolbar/file_edit.png";settings.m_deleteIcon=APP_URL+"/images/portal/toolbar/file_delete.png";settings.m_searchIcon=null;settings.m_refreshIcon=APP_URL+"/images/acquiro/editors/list_icons/item_refresh.png";settings.m_action="portal_file.do";settings.m_sorted=true;settings.m_listItemName=getResource(PORTAL_UI_FILE);settings.m_listItemsName=getResource(PORTAL_UI_FILES);this.CoreListEditor(settings,windowManager);this.m_debugName="FileListEditor";}
copyPrototype(FileListEditor,CoreListEditor);function MailingListSendDialog(mailingList)
{this.ModalDialog();this.m_showCancel=true;this.m_showOk=false;this.m_mailingList=mailingList;}
copyPrototype(MailingListSendDialog,ModalDialog);MailingListSendDialog.prototype.showDialog=function(callback)
{var dialogLayout=new TableLayout();dialogLayout.setBackgroundColor("#F8F8F8");var lbl=new Label(getResource(PORTAL_UI_MAILING_LIST_SEND_DLG_1));lbl.setPadding(3,0,3,0);lbl.setBorder(0,0,0,1,"solid","#BDBDBD");dialogLayout.addRow("40");dialogLayout.addCell(dialogLayout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);lbl=new Label(getResource(PORTAL_UI_MAILING_LIST_SEND_DLG_2));lbl.setPadding(3,0,3,0);dialogLayout.addRow("20");dialogLayout.addCell(dialogLayout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);this.m_subject=new TextFieldCtrl("");dialogLayout.addRow("24");dialogLayout.addCell(dialogLayout.getRowCount()-1,this.m_subject,TABLE_LAYOUT_REMAINDER);lbl=new Label(getResource(PORTAL_UI_MAILING_LIST_SEND_DLG_3));lbl.setPadding(3,0,3,0);dialogLayout.addRow("20");dialogLayout.addCell(dialogLayout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);this.m_message=new TinyMCEEditor("");dialogLayout.addRow(TABLE_LAYOUT_REMAINDER);dialogLayout.addCell(dialogLayout.getRowCount()-1,this.m_message,TABLE_LAYOUT_REMAINDER);this.m_sendBtn=new Button(getResource(CORE_UI_SEND),null,null);this.m_sendBtn.addListener(this);this.m_sendBtn.disable();this.m_sendBtn.setMargin(0,5,0,0);this.m_toolbar.addCell(0,this.m_sendBtn,TABLE_LAYOUT_AUTO);var dlgArgs=new Array();dlgArgs[0]=getResource(PORTAL_UI_MAILING_LIST_SEND_DLG_4);dlgArgs[1]=dialogLayout;dlgArgs[2]=700;dlgArgs[3]=550;dlgArgs[4]=callback;ModalDialog.prototype.showDialog.apply(this,dlgArgs);}
MailingListSendDialog.prototype.onPanelChange=function(objPanel)
{if(trim(this.m_subject.getValue()).length>0&&trim(this.m_message.getValue()).length>0)
{this.m_sendBtn.enable();}
else
{this.m_sendBtn.disable();}}
MailingListSendDialog.prototype.onButtonClick=function(objBtn)
{ModalDialog.prototype.onButtonClick.apply(this,arguments);if(objBtn==this.m_sendBtn)
{var request=new AjaxRequest(APP_URL+"/mailinglist.do");request.addParam("action","sendMessage");request.addParam("coreListItemInstanceId",this.m_mailingList.getInstanceId());request.addParam("subject",this.m_subject.getValue());request.addParam("message",this.m_message.getValue());request.postRequest(this.onSendMessage_Response.bind(this));}}
MailingListSendDialog.prototype.onSendMessage_Response=function(response)
{this.hideDialog();msgDialog(PORTAL_UI_MAILING_LIST_SEND_DLG_5,PORTAL_UI_MAILING_LIST_SEND_DLG_5,null);}
function ContentTypeList()
{this.CoreInstanceObjectList();this.m_debugName="ContentTypeList";var cache=coreApp.getContentTypeCache();cache.addListener(this);cache.loadCacheData(false);}
copyPrototype(ContentTypeList,CoreInstanceObjectList);ContentTypeList.prototype.destroy=function()
{var cache=coreApp.getContentTypeCache();cache.removeListener(this);List.prototype.destroy.apply(this,arguments);}
function PortalInstanceEditor(updateUrl,instance,action,btnText,btnTooltip,saveMessage)
{this.TableLayout();this.m_controlHeight=false;this.setOverflowMode("visible");this.m_instance=instance;this.m_action=action;this.m_saveMessage=saveMessage;this.m_saveBtn=new Button(btnText,btnTooltip,null);this.m_saveBtn.setWidth(15+btnText.length*7);this.m_saveBtn.addListener(this);this.m_itemInstanceCtrl=new InstanceControl(this.m_instance);var objDoc=this.m_instance.getDocument();var internalFields=objDoc.getFieldsByOption(PORTAL_FIELD_INTERNAL_OPTION,"1");if(internalFields.length>0)
{this.m_itemInstanceCtrl.m_docCtrlOptions.m_hidden_fields=new Array();for(var i=0;i<internalFields.length;i++)
{this.m_itemInstanceCtrl.m_docCtrlOptions.m_hidden_fields.push(internalFields[i].getId());}}
this.m_itemInstanceCtrl.useScrollPanel(false);this.m_itemInstanceCtrl.createLayout(MODE_INSTANCE);this.m_itemInstanceCtrl.addListener(this);this.addRow(TABLE_LAYOUT_FLOW);this.addCell(0,this.m_itemInstanceCtrl,TABLE_LAYOUT_REMAINDER);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(1,new Panel(),"50%");this.addCell(1,this.m_saveBtn,TABLE_LAYOUT_AUTO);this.addCell(1,new Panel(),"50%");this.m_saved=false;}
copyPrototype(PortalInstanceEditor,TableLayout);PortalInstanceEditor.prototype.onButtonClick=function(objBtn)
{this.onSaveInstance();}
PortalInstanceEditor.prototype.prepareRequest=function()
{var request=new AjaxRequest(APP_URL+"/page.do");request.addParam("action",this.m_action);request.addParam("langCode",USER_LANGUAGE);this.m_instance.populateRequest(request);return request;}
PortalInstanceEditor.prototype.onSaveInstance=function()
{if(this.m_saved)
{alert(PORTAL_INSTANCE_EDITOR_ALREADY_SAVED);return;}
this.m_itemInstanceCtrl.updateInstance();var request=this.prepareRequest();request.postRequest(this.onSaveInstance_Response.bind(this));}
PortalInstanceEditor.prototype.onSaveInstance_Response=function(response)
{this.m_saved=true;alert(this.m_saveMessage);}
PortalInstanceEditor.prototype.onDocumentControlHeightChange=function(response)
{this.refresh();}
function UserContentEditor(updateUrl,portalUserContent,action)
{this.m_portalUserContent=portalUserContent;this.PortalInstanceEditor(updateUrl,this.m_portalUserContent.getItemInstance(),action,USER_CONTENT_EDITOR_BTN_TEXT,USER_CONTENT_EDITOR_BTN_TOOLTIP,USER_CONTENT_EDITOR_BTN_SUCCESS);}
copyPrototype(UserContentEditor,PortalInstanceEditor);UserContentEditor.prototype.prepareRequest=function()
{var request=PortalInstanceEditor.prototype.prepareRequest.apply(this,arguments);this.m_portalUserContent.populateRequest(request);request.addParam("userContentInstanceId",this.m_portalUserContent.getId());request.addParam("userContentItemInstanceId",this.m_portalUserContent.getItemInstance().getId());return request;}
UserContentEditor.prototype.onSaveInstance_Response=function(response)
{eval(response.getJavaScript());this.m_portalUserContent=portalUserContent;this.m_itemInstanceCtrl.setInstance(this.m_portalUserContent.getItemInstance());alert(this.m_saveMessage);}
function SubscriberEditor()
{this.TableLayout();this.m_controlHeight=false;}
copyPrototype(SubscriberEditor,TableLayout);SubscriberEditor.prototype.onCreate=function()
{this.m_saveBtn=new Button(USER_EDITOR_BTN_TEXT,USER_EDITOR_BTN_TOOLTIP,null);var btnWidth=15+USER_EDITOR_BTN_TEXT.length*7.5;this.m_saveBtn.setWidth(btnWidth);this.m_saveBtn.addListener(this);this.m_firstname=this.addField(USER_EDITOR_FNAME_LBL,"",false);this.m_lastname=this.addField(USER_EDITOR_LNAME_LBL,"",false);this.m_username=this.addField(USER_EDITOR_USERNAME_LBL,"",false);this.m_password=this.addField(USER_EDITOR_PASSWORD_LBL,"",true);this.m_passwordConf=this.addField(USER_EDITOR_PASSWORD_CONF_LBL,"",true);this.m_email=this.addField(USER_EDITOR_EMAIL_LBL,"",false);this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,new Panel(),300-btnWidth);this.addCell(this.getRowCount()-1,this.m_saveBtn,btnWidth);this.addCell(this.getRowCount()-1,new Panel(),TABLE_LAYOUT_REMAINDER);TableLayout.prototype.onCreate.apply(this,arguments);}
SubscriberEditor.prototype.addField=function(caption,tooltip,blnPwd)
{var lbl=new DocumentFieldLabel(caption,tooltip,true);this.addRow(TABLE_LAYOUT_FLOW);this.addCell(this.getRowCount()-1,lbl,"115");var textField=new TextFieldCtrl("");if(blnPwd)
{textField=new Password("");}
textField.setMargin(0,0,0,3);this.addCell(this.getRowCount()-1,textField,"200");this.addCell(this.getRowCount()-1,new Panel(),TABLE_LAYOUT_REMAINDER);return textField;}
SubscriberEditor.prototype.onButtonClick=function()
{var request=new AjaxRequest(APP_URL+"/page.do");request.addParam("action","subscribe");request.addParam("langCode",USER_LANGUAGE);request.addParam("username",this.m_username.getValue());request.addParam("password",this.m_password.getValue());request.addParam("passwordConf",this.m_passwordConf.getValue());request.addParam("email",this.m_email.getValue());request.addParam("fname",this.m_firstname.getValue());request.addParam("lname",this.m_lastname.getValue());request.postRequest(this.onSubscribe_Response.bind(this));}
SubscriberEditor.prototype.onSubscribe_Response=function(response)
{alert(USER_EDITOR_SUCCESS);}
function PortalSearchEditor(updateUrl,search,action,btnText,btnTooltip,saveMessage)
{this.TableLayout();this.m_search=search;this.m_action=action;this.m_saveMessage=saveMessage;this.m_searchBtn=new Button(btnText,btnTooltip,null);this.m_searchBtn.setWidth(15+btnText.length*7);this.m_searchBtn.addListener(this);this.m_searchControl=new SimpleSearchControl(this.m_search);var objDoc=this.m_search.getDocument();var internalFields=objDoc.getFieldsByOption(PORTAL_FIELD_INTERNAL_OPTION,"1");if(internalFields.length>0)
{this.m_searchControl.m_docCtrlOptions.m_hidden_fields=new Array();for(var i=0;i<internalFields.length;i++)
{this.m_searchControl.m_docCtrlOptions.m_hidden_fields.push(internalFields[i].getId());}}
this.m_searchControl.m_docCtrlOptions.m_hide_search_options=true;this.m_searchControl.m_docCtrlOptions.m_hide_multilingual_value=true;this.m_searchControl.createLayout();this.addRow(TABLE_LAYOUT_FLOW);this.addCell(0,this.m_searchControl,TABLE_LAYOUT_REMAINDER);this.addRow(TABLE_LAYOUT_FLOW);this.addCell(1,new Panel(),"50%");this.addCell(1,this.m_searchBtn,TABLE_LAYOUT_AUTO);this.addCell(1,new Panel(),"50%");}
copyPrototype(PortalSearchEditor,TableLayout);PortalSearchEditor.prototype.onButtonClick=function(objBtn)
{this.onSaveSearch();}
PortalSearchEditor.prototype.prepareRequest=function()
{var request=new AjaxRequest(APP_URL+"/page.do");request.addParam("action",this.m_action);request.addParam("langCode",USER_LANGUAGE);this.m_search.populateRequest(request);return request;}
PortalSearchEditor.prototype.onSaveSearch=function()
{this.m_searchControl.updateSearch();var request=this.prepareRequest();request.postRequest(this.onSaveSearch_Response.bind(this));}
PortalSearchEditor.prototype.onSaveSearch_Response=function(response)
{}
function ContentSearchEditor(updateUrl,contentSearch,pageInstanceId,contentTypeInstanceId,pageSectionInstanceId,action)
{this.m_contentSearch=contentSearch;this.m_contentTypeInstanceId=contentTypeInstanceId;this.m_pageInstanceId=pageInstanceId;this.m_pageSectionInstanceId=pageSectionInstanceId;this.PortalSearchEditor(updateUrl,this.m_contentSearch,action,SEARCH_EDITOR_BTN_TEXT,SEARCH_EDITOR_BTN_TOOLTIP,SEARCH_EDITOR_BTN_SUCCESS);}
copyPrototype(ContentSearchEditor,PortalSearchEditor);ContentSearchEditor.prototype.prepareRequest=function()
{var request=PortalSearchEditor.prototype.prepareRequest.apply(this,arguments);request.addParam("searchInstanceId",this.m_contentSearch.getId());request.addParam("contentTypeInstanceId",this.m_contentTypeInstanceId);request.addParam("pageSectionInstanceId",this.m_pageSectionInstanceId);return request;}
ContentSearchEditor.prototype.onSaveSearch_Response=function(response)
{window.location="page.do?action=viewPage&pageInstanceId="+this.m_pageInstanceId+"&subType=searchContent";}
function ItemEditor(updateUrl,itemInstance,contentTypeInstanceId,action)
{this.PortalInstanceEditor(updateUrl,itemInstance,action,USER_CONTENT_EDITOR_BTN_TEXT,USER_CONTENT_EDITOR_BTN_TOOLTIP,USER_CONTENT_EDITOR_BTN_SUCCESS);this.m_contentTypeInstanceId=contentTypeInstanceId;}
copyPrototype(ItemEditor,PortalInstanceEditor);ItemEditor.prototype.prepareRequest=function()
{var request=PortalInstanceEditor.prototype.prepareRequest.apply(this,arguments);request.addParam("itemInstanceId",this.m_instance.getId());request.addParam("contentTypeInstanceId",this.m_contentTypeInstanceId);return request;}
ItemEditor.prototype.onSaveInstance_Response=function(response)
{eval(response.getJavaScript());PortalInstanceEditor.prototype.onSaveInstance_Response.apply(this,arguments);this.m_instance.setId(newItemId);}
function ContactUsEditor(updateUrl,contactInstance,action)
{this.PortalInstanceEditor(updateUrl,contactInstance,action,CONTACT_US_EDITOR_BTN_TEXT,CONTACT_US_EDITOR_BTN_TOOLTIP,CONTACT_US_EDITOR_BTN_SUCCESS);this.m_contactInstance=contactInstance;}
copyPrototype(ContactUsEditor,PortalInstanceEditor);ContactUsEditor.prototype.prepareRequest=function()
{var request=PortalInstanceEditor.prototype.prepareRequest.apply(this,arguments);request.addParam("contactInstanceId",this.m_contactInstance.getId());return request;}
function PortalTabToolbar(portalTab)
{this.MainTabToolbar(portalTab);this.m_portalTab=portalTab;this.createControls();this.m_editProfileBtn=this.addIconButtonRight(APP_URL+"/images/core/ui/toolbar/user_edit.png","Edit your user profile.");this.addListener(this);}
copyPrototype(PortalTabToolbar,MainTabToolbar);PortalTabToolbar.prototype.onToolbarButtonClick=function(objBtn)
{if(objBtn==this.m_editProfileBtn)
{this.m_portalTab.onEditProfile();}
MainTabToolbar.prototype.onToolbarButtonClick.apply(this,arguments);}
function ContentTypeTabToolbar(contentTypeTab)
{this.MainTabToolbar(contentTypeTab);this.m_contentTypeTab=contentTypeTab;this.createControls();this.m_editProfileBtn=this.addIconButtonRight(APP_URL+"/images/core/ui/toolbar/user_edit.png","Edit your user profile.");this.addListener(this);}
copyPrototype(ContentTypeTabToolbar,MainTabToolbar);ContentTypeTabToolbar.prototype.postCreate=function()
{MainTabToolbar.prototype.postCreate.apply(this,arguments);this.disableAll();}
ContentTypeTabToolbar.prototype.onToolbarButtonClick=function(objBtn)
{MainTabToolbar.prototype.onToolbarButtonClick.apply(this,arguments);if(objBtn==this.m_addContentItemBtn)
{this.m_contentTypeTab.onNewContentTypeItem();}
else if(objBtn==this.m_editContentItemBtn)
{this.m_contentTypeTab.onEditContentTypeItem();}
else if(objBtn==this.m_deleteContentItemBtn)
{this.m_contentTypeTab.onDeleteContentTypeItem();}
else if(objBtn==this.m_editProfileBtn)
{this.m_portalTab.onEditProfile();}}
ContentTypeTabToolbar.prototype.enableAddContentTypeItemButtons=function()
{}
ContentTypeTabToolbar.prototype.enableContentTypeItemButtons=function()
{}
function ContentTypeToolbar(contentTypeTab,contentTypeList)
{this.Toolbar();this.m_contentTypeTab=contentTypeTab;this.m_contentTypeList=contentTypeList;this.m_contentTypeList.addListener(this);var showEditor=coreApp.isShowContentTypeEditor();if(showEditor)
{this.m_addContentTypeBtn=this.addIconButton(APP_URL+"/images/portal/toolbar/contenttype_new.png",getResource(PORTAL_UI_NEW_CONTENT_TYPE));this.m_openContentTypeBtn=this.addIconButton(APP_URL+"/images/portal/toolbar/contenttype_edit.png",getResource(PORTAL_UI_EDIT_CONTENT_TYPE));this.m_deleteContentTypeBtn=this.addIconButton(APP_URL+"/images/portal/toolbar/contenttype_delete.png",getResource(PORTAL_UI_DELETE_CONTENT_TYPE));}
else
{this.m_addContentTypeBtn=null;this.m_openContentTypeBtn=null;this.m_deleteContentTypeBtn=null;}
this.m_viewContentItemsBtn=this.addIconButton(APP_URL+"/images/portal/toolbar/contenttype_view.png",getResource(PORTAL_UI_VIEW_CONTENT_TYPE));this.m_searchContentItemsBtn=this.addIconButton(APP_URL+"/images/portal/toolbar/contenttype_search.png",getResource(PORTAL_UI_SEARCH_CONTENT_TYPE));this.addListener(this);}
copyPrototype(ContentTypeToolbar,Toolbar);ContentTypeToolbar.prototype.postCreate=function()
{Toolbar.prototype.postCreate.apply(this,arguments);this.disableAll();if(this.m_addContentTypeBtn!=null)
{this.enableButton(this.m_addContentTypeBtn);}}
ContentTypeToolbar.prototype.onToolbarButtonClick=function(objBtn)
{if(objBtn==this.m_addContentTypeBtn)
{this.m_contentTypeTab.onNewContentType();}
else if(objBtn==this.m_openContentTypeBtn)
{this.m_contentTypeTab.onEditContentType();}
else if(objBtn==this.m_deleteContentTypeBtn)
{this.m_contentTypeTab.onDeleteContentType();}
else if(objBtn==this.m_viewContentItemsBtn)
{this.m_contentTypeTab.onListContentTypeItems();}
else if(objBtn==this.m_searchContentItemsBtn)
{this.m_contentTypeTab.onGetSearchContentItems();}}
ContentTypeToolbar.prototype.onListSelectionChange=function(objList)
{var selection=this.m_contentTypeList.getSelectedItems();if(selection.length>0)
{var contentType=selection[0];this.enableAll();}
else
{this.disableAll();if(this.m_addContentTypeBtn!=null)
{this.enableButton(this.m_addContentTypeBtn);}}}
function NavigationTabToolbar(navigationTab)
{this.PortalTabToolbar(navigationTab);this.m_navigationTab=navigationTab;}
copyPrototype(NavigationTabToolbar,PortalTabToolbar);function ImageLibraryTabToolbar(imagesTab)
{this.PortalTabToolbar(imagesTab);this.m_imagesTab=imagesTab;}
copyPrototype(ImageLibraryTabToolbar,PortalTabToolbar);function MailingListTabToolbar(imagesTab)
{this.PortalTabToolbar(imagesTab);this.m_imagesTab=imagesTab;}
copyPrototype(MailingListTabToolbar,PortalTabToolbar);function FileLibraryTabToolbar(filesTab)
{this.PortalTabToolbar(filesTab);this.m_filesTab=filesTab;}
copyPrototype(FileLibraryTabToolbar,PortalTabToolbar);var WINDOW_TYPE_CONTENT_TYPE=++WINDOW_UNIQUE_TYPE;function ContentTypeWindow(portalContentType,template)
{this.m_portalContentType=portalContentType;this.m_template=template;var caption="";if(this.m_portalContentType!=null)
{caption=this.m_portalContentType.getName();}
this.CoreObjectWindow(caption,null,WINDOW_TYPE_CONTENT_TYPE);this.setCoreObject(this.m_portalContentType);}
copyPrototype(ContentTypeWindow,CoreObjectWindow);ContentTypeWindow.prototype.loadWindow=function()
{CoreObjectWindow.prototype.loadWindow.apply(this,arguments);if(this.m_portalContentType==null)
{var request=new AjaxRequest(APP_URL+"/content_type.do");request.addParam("action","newContentType");request.addParam("templateType",this.m_template);request.postRequest(this.onLoadContentType_Response.bind(this));}
else
{var request=new AjaxRequest(APP_URL+"/content_type.do");request.addParam("action","editContentType");request.addParam("contentTypeInstanceId",this.m_portalContentType.getInstanceId());request.postRequest(this.onLoadContentType_Response.bind(this));}}
ContentTypeWindow.prototype.onLoadContentType_Response=function(response)
{eval(response.getJavaScript());this.m_portalContentType=contentType;this.setCoreObject(this.m_portalContentType);this.m_contentTypeDocument=contentTypeDocument;this.m_contentTypeInstControl=new InstanceControl(this.m_portalContentType.getInstance());this.m_contentTypeInstControl.useScrollPanel(false);this.m_contentTypeInstControl.createLayout(MODE_INSTANCE);this.m_contentTypeInstControl.setPadding(3,3,3,3);this.addRow("35");this.addCell(this.getRowCount()-1,this.m_contentTypeInstControl,TABLE_LAYOUT_REMAINDER);var docToolbar=new DocumentControlToolbar();docToolbar.addDocumentControlButtons();docToolbar.setBorder(0,0,0,1,"solid",SKIN_FIELD_BORDER_COLOR);this.m_contentTypeDocumentControl=new DocumentControl(this.m_contentTypeDocument);this.m_contentTypeDocumentControl.setCanAddUserLists(false);this.m_contentTypeDocumentControl.setCanAddHTMLFields(true);this.m_contentTypeDocumentControl.createLayout(MODE_DOCUMENT);this.m_contentTypeDocumentControl.setToolbar(docToolbar);this.m_itemLayout=new InstanceLayoutEditor(this.m_contentTypeDocument,this.m_portalContentType.getItemLayout());this.m_listLayout=new InstanceLayoutEditor(this.m_contentTypeDocument,this.m_portalContentType.getListLayout());this.m_tabControl=new TabControl();this.m_tabControl.setUseSmallTabs(true);this.m_tabControl.setPadding(2,2,2,2);this.m_tabControl.addListener(this);this.m_fieldsLayout=new TableLayout();this.m_fieldsLayout.addRow(TABLE_LAYOUT_AUTO);this.m_fieldsLayout.addCell(this.m_fieldsLayout.getRowCount()-1,docToolbar,TABLE_LAYOUT_REMAINDER);this.m_fieldsLayout.addRow(TABLE_LAYOUT_REMAINDER);this.m_fieldsLayout.addCell(this.m_fieldsLayout.getRowCount()-1,this.m_contentTypeDocumentControl,TABLE_LAYOUT_REMAINDER);this.m_fieldsTab=new Tab(getResource(PORTAL_UI_CT_WIN_FIELDS),getResource(PORTAL_UI_CT_WIN_FIELDS_DESC),null);this.m_fieldsTab.setWidth(160);this.m_tabControl.addTab(this.m_fieldsTab,this.m_fieldsLayout);var layout=new TableLayout();layout.addRow(TABLE_LAYOUT_REMAINDER);layout.addCell(layout.getRowCount()-1,this.m_itemLayout,TABLE_LAYOUT_REMAINDER);this.m_itemLayoutTab=new Tab(getResource(PORTAL_UI_CT_WIN_ITEM_LAYOUT),getResource(PORTAL_UI_CT_WIN_ITEM_LAYOUT_DESC),null);this.m_itemLayoutTab.setWidth(120);this.m_tabControl.addTab(this.m_itemLayoutTab,layout);var layout=new TableLayout();layout.addRow(TABLE_LAYOUT_REMAINDER);layout.addCell(layout.getRowCount()-1,this.m_listLayout,TABLE_LAYOUT_REMAINDER);this.m_listLayoutTab=new Tab(getResource(PORTAL_UI_CT_WIN_LIST_LAYOUT),getResource(PORTAL_UI_CT_WIN_LIST_LAYOUT_DESC),null);this.m_listLayoutTab.setWidth(120);this.m_tabControl.addTab(this.m_listLayoutTab,layout);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_tabControl,TABLE_LAYOUT_REMAINDER);this.onLoaded(false);this.m_caption=this.m_portalContentType.getName();this.m_tooltip=getResource(PORTAL_UI_CONTENT_TYPE)+" - "+this.m_portalContentType.getName();this.m_windowManager.updateWindowCaption(this);this.m_contentTypeDocumentControl.checkToolbar();}
ContentTypeWindow.prototype.saveWindow=function()
{this.m_contentTypeInstControl.updateInstance();this.m_contentTypeDocumentControl.updateInstance();this.m_itemLayout.updateEditorLayout();this.m_listLayout.updateEditorLayout();this.m_portalContentType.setItemLayout(this.m_itemLayout.getLayouts());this.m_portalContentType.setListLayout(this.m_listLayout.getLayouts());var request=new AjaxRequest(APP_URL+"/content_type.do");request.addParam("contentTypeInstanceId",this.m_portalContentType.getId());request.addParam("contentTypeDocumentId",this.m_contentTypeDocument.getId());request.addParam("action","updateContentType");this.m_portalContentType.getInstance().populateRequest(request);this.m_contentTypeDocument.populateRequest(request);request.postRequest(this.onSaveContentType_Response.bind(this));}
ContentTypeWindow.prototype.onSaveContentType_Response=function(response)
{eval(response.getJavaScript());this.m_portalContentType=contentType;this.m_contentTypeDocument=contentTypeDocument;this.m_contentTypeInstControl.setInstance(this.m_portalContentType.getInstance());this.m_contentTypeDocumentControl.setDocument(this.m_contentTypeDocument);this.m_itemLayout.setLayout(this.m_portalContentType.getItemLayout())
this.m_listLayout.setLayout(this.m_portalContentType.getListLayout())
this.m_itemLayout.setDocument(this.m_contentTypeDocument);this.m_listLayout.setDocument(this.m_contentTypeDocument);this.m_portalContentType.setId(contentType.getId());var cache=coreApp.getContentTypeCache();cache.updateCoreInstanceObject(this.m_portalContentType);this.setCoreObject(this.m_portalContentType);this.m_caption=this.m_portalContentType.getName();this.m_tooltip=getResource(PORTAL_UI_CONTENT_TYPE)+" - "+this.m_portalContentType.getName();this.m_windowManager.updateWindowCaption(this);this.onSaved();}
ContentTypeWindow.prototype.canRefresh=function()
{if(this.m_portalContentType==null||this.m_portalContentType.isNewInstance())
{return false;}
return true;}
ContentTypeWindow.prototype.getPortalContentType=function()
{return this.m_portalContentType;}
ContentTypeWindow.prototype.onActiveTabChange=function(objTabCtrl)
{if(objTabCtrl==this.m_tabControl)
{if(this.m_tabControl.getActiveTab()==this.m_fieldsLayout)
{this.m_contentTypeDocumentControl.checkToolbar();}}}
var WINDOW_TYPE_CONTENT_TYPE_ITEMS=++WINDOW_UNIQUE_TYPE;function ContentTypeItemsWindow(portalContentType)
{this.m_contentTypeItemInstances=null;this.m_portalContentType=portalContentType;this.m_loaded=false;this.m_canRefresh=true;this.m_create=false;this.m_edit=false;this.m_instances=null;var caption=this.m_portalContentType.getName()+" - Items";this.CoreObjectWindow(caption,null,WINDOW_TYPE_CONTENT_TYPE_ITEMS);this.setCoreObject(this.m_portalContentType);}
copyPrototype(ContentTypeItemsWindow,CoreObjectWindow);ContentTypeItemsWindow.prototype.loadWindow=function()
{CoreObjectWindow.prototype.loadWindow.apply(this,arguments);if(this.m_instances==null)
{var request=new AjaxRequest(APP_URL+"/content_type.do");request.addParam("action","listContentTypeItems");request.addParam("contentTypeInstanceId",this.m_portalContentType.getInstanceId());request.postRequest(this.onListContentItems_Response.bind(this));}
else
{this.listContentItems(this.m_instances);}}
ContentTypeItemsWindow.prototype.setContentTypeItems=function(contentTypesItemsInstances)
{this.m_instances=contentTypesItemsInstances;}
ContentTypeItemsWindow.prototype.onListContentItems_Response=function(response)
{eval(response.getJavaScript());this.listContentItems(contentTypesItemsInstances);}
ContentTypeItemsWindow.prototype.listContentItems=function(contentTypesItemsInstances)
{this.m_toolbar=new Toolbar();this.m_toolbar.addListener(this);this.m_addBtn=this.m_toolbar.addIconButton(APP_URL+"/images/core/ui/toolbar/item_new.png",getResource(PORTAL_UI_NEW_CONTENT_ITEM));this.m_delBtn=this.m_toolbar.addIconButton(APP_URL+"/images/core/ui/toolbar/item_delete.png",getResource(PORTAL_UI_DELETE_CONTENT_ITEM));this.m_delBtn.disable();this.m_instances=contentTypesItemsInstances;this.m_instanceCtrl=null;if(this.m_instances.length>0)
{this.m_instancesGridData=new InstancesGridData(this.m_instances);this.m_instancesGrid=new Grid(GRID_MODE_PRELOAD);this.m_instancesGrid.setPageSize(10);this.m_instancesGrid.setGridData(this.m_instancesGridData);this.m_instancesGrid.addListener(this);}
else
{this.m_instancesGrid=new Label(getResource(PORTAL_UI_CIS_WIN_NONE));}
this.m_gridCcrollPanel=new ScrollPanel();this.m_gridCcrollPanel.setPanel(this.m_instancesGrid);this.m_gridCcrollPanel.setHeight(280);this.m_splitPanel=new SplitControl();this.m_splitPanel.setPanels(this.m_gridCcrollPanel,new Panel());this.addRow(TABLE_LAYOUT_AUTO);this.addCell(0,this.m_toolbar,TABLE_LAYOUT_REMAINDER);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(1,this.m_splitPanel,TABLE_LAYOUT_REMAINDER);this.onLoaded(true);}
ContentTypeItemsWindow.prototype.saveWindow=function()
{this.m_instanceCtrl.updateInstance();var request=new AjaxRequest(APP_URL+"/content_type.do");request.addParam("contentTypeInstanceId",this.m_portalContentType.getInstanceId());request.addParam("itemInstanceId",this.m_instance.getId());request.addParam("action","updateContentTypeItem");this.m_instance.populateRequest(request);request.postRequest(this.onSaveInstance_Response.bind(this));}
ContentTypeItemsWindow.prototype.onSaveInstance_Response=function(response)
{eval(response.getJavaScript());if(getType(this.m_instancesGrid)!="Grid")
{this.m_instance=itemInstance;this.m_instances.push(this.m_instance);this.m_instancesGridData=new InstancesGridData(this.m_instances);this.m_instancesGrid=new Grid(GRID_MODE_PRELOAD);this.m_instancesGrid.setPageSize(10);this.m_instancesGrid.setGridData(this.m_instancesGridData);this.m_instancesGrid.addListener(this);this.m_gridCcrollPanel.setPanel(this.m_instancesGrid);}
else
{if(this.m_instance.isNewInstance())
{this.m_instance=itemInstance;this.m_instances=this.m_instancesGridData.addInstance(this.m_instance);}
else
{this.m_instance=itemInstance;this.m_instancesGridData.replaceInstance(this.m_instance.getId(),this.m_instance);}}
this.m_instanceCtrl.setInstance(this.m_instance);this.m_instancesGrid.refresh();var rowIndex=this.m_instancesGridData.getInstanceIndex(this.m_instance.getId());this.m_instancesGrid.setSelectedRow(rowIndex,false);this.onSaved();if(this.m_create)
{this.onNewContentItem();}
else if(this.m_edit)
{this.onEditContentItem();}}
ContentTypeItemsWindow.prototype.setCanRefresh=function(canRefresh)
{this.m_canRefresh=canRefresh;}
ContentTypeItemsWindow.prototype.canRefresh=function()
{return this.m_canRefresh;}
ContentTypeItemsWindow.prototype.onGridRowClick=function(args)
{this.onEditContentItem();}
ContentTypeItemsWindow.prototype.onEditContentItem=function()
{if(this.hasChanged())
{var saveDialog=new ModalDialog();saveDialog.setShowCancel(true);saveDialog.showDialog(getResource(DLG_SAVE_CONFIRM),new Label(getResource(DLG_SAVE_CONFIRM_DESC)),400,120,this.onEditContentItem_Closed.bind(this));}
else
{this.onEditContentItem_Closed(true);}}
ContentTypeItemsWindow.prototype.onEditContentItem_Closed=function(cancelled)
{if(!cancelled)
{this.m_edit=true;this.saveWindow();return;}
this.clearHasChanged();this.m_edit=false;var rowIndex=this.m_instancesGrid.getSelectedRow();this.m_instance=this.m_instancesGridData.getInstance(rowIndex);if(this.m_instanceCtrl!=null)
{this.m_instanceCtrl.setInstance(this.m_instance);}
else
{this.m_instanceCtrl=new InstanceControl(this.m_instance);this.m_instanceCtrl.createLayout(MODE_INSTANCE);this.m_instanceCtrl.setPadding(2,2,2,2);this.m_splitPanel.setPanel2(this.m_instanceCtrl);}
this.m_delBtn.enable();}
ContentTypeItemsWindow.prototype.onToolbarButtonClick=function(objBtn)
{if(objBtn==this.m_addBtn)
{this.onNewContentItem();}
else if(objBtn==this.m_delBtn)
{this.onDeleteContentItem();}}
ContentTypeItemsWindow.prototype.onNewContentItem=function()
{if(this.hasChanged())
{var saveDialog=new ModalDialog();saveDialog.setShowCancel(true);saveDialog.showDialog(getResource(DLG_SAVE_CONFIRM),new Label(getResource(DLG_SAVE_CONFIRM_DESC)),400,120,this.onNewContentItem_Closed.bind(this));}
else
{this.onNewContentItem_Closed(true);}}
ContentTypeItemsWindow.prototype.onNewContentItem_Closed=function(cancelled)
{if(!cancelled)
{this.m_create=true;this.saveWindow();return;}
this.clearHasChanged();this.m_create=false;var request=new AjaxRequest(APP_URL+"/content_type.do");request.addParam("action","newContentTypeItem");request.addParam("contentTypeInstanceId",this.m_portalContentType.getInstanceId());request.postRequest(this.onNewContentItem_Response.bind(this));}
ContentTypeItemsWindow.prototype.onNewContentItem_Response=function(response)
{eval(response.getJavaScript());this.m_instance=itemInstance;if(getType(this.m_instancesGrid)=="Grid")
{this.m_instancesGrid.setSelectedRow(-1);}
if(this.m_instanceCtrl!=null)
{this.m_instanceCtrl.setInstance(this.m_instance);}
else
{this.m_instanceCtrl=new InstanceControl(this.m_instance);this.m_instanceCtrl.createLayout(MODE_INSTANCE);this.m_instanceCtrl.setPadding(2,2,2,2);this.m_splitPanel.setPanel2(this.m_instanceCtrl);}}
ContentTypeItemsWindow.prototype.onDeleteContentItem=function()
{this.m_delDialog=deleteDialog(PORTAL_UI_CIS_WIN_DELETE,this.onDeleteContentItem_Closed.bind(this));}
ContentTypeItemsWindow.prototype.onDeleteContentItem_Closed=function(cancelled)
{if(cancelled)
{return;}
var request=new AjaxRequest(APP_URL+"/content_type.do");request.addParam("action","deleteContentTypeItem");request.addParam("contentTypeInstanceId",this.m_portalContentType.getInstanceId());request.addParam("itemInstanceId",this.m_instance.getId());request.postRequest(this.onDeleteContentItem_Response.bind(this));}
ContentTypeItemsWindow.prototype.onDeleteContentItem_Response=function()
{var rowIndex=this.m_instancesGridData.getInstanceIndex(this.m_instance.getId());if(rowIndex>-1)
{this.m_instancesGridData.deleteInstance(this.m_instance.getId());this.m_instancesGrid.refresh();}
this.m_splitPanel.setPanel2(new Panel());this.m_instance=null;this.m_instanceCtrl=null;this.m_delBtn.disable();}
var WINDOW_TYPE_CONTENT_TYPE_ITEM=++WINDOW_UNIQUE_TYPE;function ContentTypeItemWindow(itemInstanceId,contentType)
{this.m_itemInstanceId=itemInstanceId;this.m_portalContentType=contentType;var caption=contentType.getName()+" "+getResource(PORTAL_UI_CI_WIN_ITEM);this.Window(caption,null,WINDOW_TYPE_CONTENT_TYPE_ITEM);}
copyPrototype(ContentTypeItemWindow,Window);ContentTypeItemWindow.prototype.loadWindow=function()
{Window.prototype.loadWindow.apply(this,arguments);var request=new AjaxRequest(APP_URL+"/content_type.do");if(this.m_itemInstanceId==null)
{request.addParam("action","newContentTypeItem");request.addParam("contentTypeInstanceId",this.m_portalContentType.getInstanceId());}
else
{request.addParam("action","editContentTypeItem");request.addParam("contentTypeInstanceId",this.m_portalContentType.getInstanceId());request.addParam("itemInstanceId",this.m_itemInstanceId);}
request.postRequest(this.onLoadContentTypeItem_Response.bind(this));}
ContentTypeItemWindow.prototype.onLoadContentTypeItem_Response=function(response)
{eval(response.getJavaScript());this.m_itemInstance=itemInstance;if(coreUser!=undefined)
{this.m_coreUser=coreUser;}
if(this.m_itemInstance.isNewInstance())
{this.onPanelChange(this);}
this.m_itemInstanceCtrl=new InstanceControl(this.m_itemInstance);this.m_itemInstanceCtrl.createLayout(MODE_INSTANCE);this.m_itemInstanceCtrl.setPadding(2,2,2,2);if(this.m_coreUser!=null)
{this.m_userInstanceCtrl=new InstanceControl(this.m_coreUser.getInstance());this.m_userInstanceCtrl.createLayout(MODE_INSTANCE);this.m_userInstanceCtrl.setPadding(2,2,2,2);this.m_userInstanceCtrl.setNotifyChanges(false);var tabCtrl=new TabControl();tabCtrl.setUseSmallTabs(true);var contentItemTab=new Tab(getResource(PORTAL_UI_CONTENT_ITEM),getResource(PORTAL_UI_CI_WIN_EDIT),null);contentItemTab.setWidth(120);tabCtrl.addTab(contentItemTab,this.m_itemInstanceCtrl);var userTab=new Tab(getResource(PORTAL_UI_CI_WIN_USER),getResource(PORTAL_UI_CI_WIN_USER_DESC),null);userTab.setWidth(120);tabCtrl.addTab(userTab,this.m_userInstanceCtrl);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(0,tabCtrl,TABLE_LAYOUT_REMAINDER);}
else
{this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(0,this.m_itemInstanceCtrl,TABLE_LAYOUT_REMAINDER);}
this.onLoaded();}
ContentTypeItemWindow.prototype.saveWindow=function()
{this.m_itemInstanceCtrl.updateInstance();var request=new AjaxRequest(APP_URL+"/content_type.do");request.addParam("action","updateContentTypeItem");request.addParam("contentTypeInstanceId",this.m_portalContentType.getInstanceId());request.addParam("itemInstanceId",this.m_itemInstance.getId());this.m_itemInstance.populateRequest(request);request.postRequest(this.onSaveContentTypeItem_Response.bind(this));}
ContentTypeItemWindow.prototype.onSaveContentTypeItem_Response=function(response)
{eval(response.getJavaScript());this.m_itemInstance=itemInstance;this.m_itemInstanceId=itemInstance.getId();this.m_itemInstanceCtrl.setInstance(itemInstance);this.onSaved();}
ContentTypeItemWindow.prototype.canRefresh=function()
{if(this.m_itemInstance==null||this.m_itemInstance.isNewInstance())
{return false;}
return true;}
function PageWindow(coreTreeItemEditor,coreTreeItem,parentCoreTreeItemInstanceId)
{this.CoreTreeEditorWindow(coreTreeItemEditor,coreTreeItem,parentCoreTreeItemInstanceId);this.m_portalPage=coreTreeItem;this.m_securedPage=this.m_coreTreeItemEditor.m_secure;this.m_deletedPageSectionIds=new Array();}
copyPrototype(PageWindow,CoreTreeEditorWindow);PageWindow.prototype.getNewCoreTreeItemRequest=function()
{var request=CoreTreeEditorWindow.prototype.getNewCoreTreeItemRequest.apply(this,arguments);request.addParam("securedPage",this.m_coreTreeItemEditor.m_secure);return request;}
PageWindow.prototype.createCoreTreeEditorWindowLayout=function()
{var windowLayout=CoreTreeEditorWindow.prototype.createCoreTreeEditorWindowLayout.apply(this,arguments);if(!coreApp.isShowContentTypeEditor())
{this.m_coreTreeItemInstCtrl.m_docCtrlOptions.m_hidden_fields=new Array();this.m_coreTreeItemInstCtrl.m_docCtrlOptions.m_hidden_fields.push(this.m_coreTreeItem.m_cannotDeleteFieldId);}
this.m_portalPage=this.m_coreTreeItem;this.m_tabCtrl=new TabControl();this.m_tabCtrl.setUseSmallTabs(true);var pageInfoTab=new Tab();this.m_pageInfoTab=new Tab("Page Information","Enter the page's basic information.",null);this.m_pageInfoTab.setWidth(150);var lbl=new Label("Page Id:"+this.m_portalPage.getInstanceId());lbl.setPadding(3,3,3,3);var layout=new TableLayout();layout.addRow(20);layout.addCell(layout.getRowCount()-1,lbl,TABLE_LAYOUT_REMAINDER);layout.addRow(TABLE_LAYOUT_REMAINDER);layout.addCell(layout.getRowCount()-1,windowLayout,TABLE_LAYOUT_REMAINDER);this.m_tabCtrl.addTab(this.m_pageInfoTab,layout);if(coreApp.isShowContentTypeEditor())
{this.m_structuredDataLayout=new TableLayout();this.m_pageSectionGridData=new PortalPageSectionsGridData(this.m_portalPage.getPortalPageSections());this.m_pageSectionGrid=new Grid(GRID_MODE_PRELOAD);this.m_pageSectionGrid.setGridData(this.m_pageSectionGridData);this.m_pageSectionGrid.addListener(this);this.m_pageSectionGrid.setMargin(2,2,2,2);this.m_toolbar=new Toolbar();this.m_toolbar.addListener(this);this.m_addSectionBtn=this.m_toolbar.addIconButton(APP_URL+"/images/core/ui/toolbar/add.png","Add a Content Section this page.");this.m_moveUpSectionBtn=this.m_toolbar.addIconButton(APP_URL+"/images/core/ui/toolbar/up.png","Move the selected Content Section up.");this.m_moveUpSectionBtn.disable();this.m_moveDownSectionBtn=this.m_toolbar.addIconButton(APP_URL+"/images/core/ui/toolbar/down.png","Move the selected Content Section down.");this.m_moveDownSectionBtn.disable();this.m_deleteSectionBtn=this.m_toolbar.addIconButton(APP_URL+"/images/core/ui/toolbar/delete.png","Dekete the selected Content Section.");this.m_deleteSectionBtn.disable();this.m_structuredDataLayout.addRow(TABLE_LAYOUT_AUTO);this.m_structuredDataLayout.addCell(0,this.m_toolbar,TABLE_LAYOUT_REMAINDER);this.m_structuredDataLayout.addRow(TABLE_LAYOUT_FLOW);this.m_structuredDataLayout.addCell(1,this.m_pageSectionGrid,TABLE_LAYOUT_REMAINDER);this.m_structuredDataScrollPanel=new ScrollPanel();this.m_structuredDataScrollPanel.setPanel(this.m_structuredDataLayout);this.m_structuredDataTab=new Tab("Page Structured Data","Select what structured data this page displays.",null);this.m_structuredDataTab.setWidth(150);this.m_tabCtrl.addTab(this.m_structuredDataTab,this.m_structuredDataScrollPanel);}
else
{this.m_structuredDataLayout=null;}
return this.m_tabCtrl;}
PageWindow.prototype.getUpdateCoreTreeItemRequest=function()
{var request=CoreTreeEditorWindow.prototype.getUpdateCoreTreeItemRequest.apply(this,arguments);if(this.m_structuredDataLayout!=null)
{var portalPageSections=this.m_pageSectionGridData.getPortalPageSections();var portalPageSectionIds="";for(var i=0;i<portalPageSections.length;i++)
{if(portalPageSectionIds.length>0)
{portalPageSectionIds+="|";}
portalPageSectionIds+=portalPageSections[i].getId();portalPageSections[i].getInstance().populateRequest(request);if(portalPageSections[i].getType()==PORTAL_PAGE_SECTION_TYPE_LIST||portalPageSections[i].getType()==PORTAL_PAGE_SECTION_TYPE_CALENDAR||portalPageSections[i].getType()==PORTAL_PAGE_SECTION_TYPE_SEARCH)
{portalPageSections[i].getContentQuery().populateRequest(request);}}
request.addParam("pageSectionIds",portalPageSectionIds);var deletedPageSectionIds="";for(var i=0;i<this.m_deletedPageSectionIds.length;i++)
{if(i>0)
{deletedPageSectionIds+="|";}
deletedPageSectionIds+=this.m_deletedPageSectionIds[i];}
request.addParam("deletedPageSectionIds",deletedPageSectionIds);}
return request;}
PageWindow.prototype.updateCoreTreeEditorWindowLayout=function()
{CoreTreeEditorWindow.prototype.updateCoreTreeEditorWindowLayout.apply(this,arguments);this.m_portalPage=this.m_coreTreeItem;if(this.m_structuredDataLayout!=null)
{var portalPageSections=this.m_portalPage.getPortalPageSections();for(var i=0;i<portalPageSections.length;i++)
{this.m_pageSectionGridData.setPageSection(i,portalPageSections[i]);}
this.m_deletedPageSectionIds=new Array();}}
PageWindow.prototype.canRefresh=function()
{if(this.m_portalPage==null||this.m_portalPage.isNewInstance())
{return false;}
return true;}
PageWindow.prototype.getPortalPage=function()
{return this.m_portalPage;}
PageWindow.prototype.onGridRowClick=function(args)
{this.checkUI();}
PageWindow.prototype.onGridRowDblClick=function(args)
{var instancesGrid=args[0];var rowIndex=args[1];var portalPageSections=this.m_pageSectionGridData.getPortalPageSections();var portalPageSection=portalPageSections[rowIndex];var contentTypeCache=coreApp.getContentTypeCache();var contentType=contentTypeCache.getCoreInstanceObject(portalPageSection.getContentTypeInstanceId());if(portalPageSection.getType()==PORTAL_PAGE_SECTION_TYPE_LIST||portalPageSection.getType()==PORTAL_PAGE_SECTION_TYPE_CALENDAR||portalPageSection.getType()==PORTAL_PAGE_SECTION_TYPE_SEARCH)
{var contentQuery=portalPageSection.getContentQuery();this.m_contentQueryDialog=new SearchDialog(contentType.getName(),contentQuery);this.m_contentQueryDialog.m_searchCtrl.m_docCtrlOptions.m_hide_fields_in_search=false;this.m_contentQueryDialog.m_searchCtrl.m_docCtrlOptions.m_show_sort_field=true;this.m_contentQueryDialog.m_searchCtrl.m_docCtrlOptions.m_hide_search_options=false;this.m_contentQueryDialog.showDialog(this.onContentQueryDialogClose.bind(this));}
else if(portalPageSection.getType()==PORTAL_PAGE_SECTION_TYPE_ITEM)
{var contentTypeItemWindow=new ContentTypeItemWindow(portalPageSection.getContentTypeIdentifier(),contentType);contentTypeItemWindow.addListener(this);this.m_windowManager.addWindow(contentTypeItemWindow);}}
PageWindow.prototype.onContentQueryDialogClose=function(cancelled)
{if(cancelled)
{return;}
if(this.m_contentQueryDialog.hasChanged())
{this.onPanelChange(this);}}
PageWindow.prototype.checkUI=function()
{if(this.m_structuredDataLayout==null)
{return;}
this.m_moveUpSectionBtn.disable();this.m_moveDownSectionBtn.disable();this.m_deleteSectionBtn.disable();var selectedRow=this.m_pageSectionGrid.getSelectedRow();if(selectedRow==-1)
{return;}
this.m_deleteSectionBtn.enable();if(selectedRow>0)
{this.m_moveUpSectionBtn.enable();}
if(selectedRow<this.m_pageSectionGrid.getRowCount()-1)
{this.m_moveDownSectionBtn.enable();}}
PageWindow.prototype.onToolbarButtonClick=function(objBtn)
{if(objBtn==this.m_moveUpSectionBtn)
{var selectedRow=this.m_pageSectionGrid.getSelectedRow();if(selectedRow==-1)
{return;}
var pageSection1=this.m_pageSectionGridData.getPageSection(selectedRow);var pageSection2=this.m_pageSectionGridData.getPageSection(selectedRow-1);var temp=pageSection1.getOrder();pageSection1.setOrder(pageSection2.getOrder());pageSection2.setOrder(temp);this.m_pageSectionGridData.sortPortalPageSections();this.m_pageSectionGrid.refresh();this.m_pageSectionGrid.setSelectedRow(selectedRow-1);return;}
else if(objBtn==this.m_moveDownSectionBtn)
{var selectedRow=this.m_pageSectionGrid.getSelectedRow();if(selectedRow==-1)
{return;}
var pageSection1=this.m_pageSectionGridData.getPageSection(selectedRow);var pageSection2=this.m_pageSectionGridData.getPageSection(selectedRow+1);var temp=pageSection1.getOrder();pageSection1.setOrder(pageSection2.getOrder());pageSection2.setOrder(temp);this.m_pageSectionGridData.sortPortalPageSections();this.m_pageSectionGrid.refresh();this.m_pageSectionGrid.setSelectedRow(selectedRow+1);return;}
else if(objBtn==this.m_deleteSectionBtn)
{this.onDeletePageSection();}
else if(objBtn==this.m_addSectionBtn)
{this.m_contentSectionWizard=new ContentSectionWizard(this.m_portalPage,this.onContentSectionWizard_Close.bind(this));this.m_contentSectionWizard.showWizard();}
Window.prototype.onButtonClick.apply(this,arguments);}
PageWindow.prototype.onContentSectionWizard_Close=function(cancelled)
{if(cancelled)
{return;}
var portalPageSection=this.m_contentSectionWizard.m_newPortalPageSection;portalPageSection.setOrder(this.m_pageSectionGrid.getRowCount());this.m_pageSectionGridData.addPageSection(portalPageSection);this.m_pageSectionGrid.refresh();this.onPanelChange(this);this.m_contentSectionWizard=null;}
PageWindow.prototype.onDeletePageSection=function(objBtn)
{var rowIndex=this.m_pageSectionGrid.getSelectedRow();var portalPageSection=this.m_pageSectionGridData.getPageSection(rowIndex);var msg="Are you sure you want to delete the selected page content?";if(portalPageSection.isUserContent())
{msg+="\r\n\r\n";msg+="If you delete this User Content page section, all the content created by the portal users will also be removed.";}
this.m_delDialog=new ModalDialog();this.m_delDialog.setShowCancel(true);this.m_delDialog.showDialog("Confirm Delete",new Label(msg),400,120,this.onDeletePageSection_Confirm.bind(this));}
PageWindow.prototype.onDeletePageSection_Confirm=function(cancelled)
{if(cancelled)
{return;}
var rowIndex=this.m_pageSectionGrid.getSelectedRow();var portalPageSection=this.m_pageSectionGridData.getPageSection(rowIndex);this.m_pageSectionGridData.deletePageSection(rowIndex);this.m_deletedPageSectionIds.push(portalPageSection.getInstanceId());this.m_pageSectionGrid.refresh();this.checkUI();this.onPanelChange(this);}
function ContentSectionWizardStep1()
{this.WizardStep(getResource(PORTAL_UI_CS_WIZ_S1_TITLE));this.setSize(600,400);}
copyPrototype(ContentSectionWizardStep1,WizardStep);ContentSectionWizardStep1.prototype.createStepLayout=function()
{WizardStep.prototype.createStepLayout.apply(this,arguments);var objLbl;this.m_singleItemRadio=new RadioButton("pageSectionType",PORTAL_PAGE_SECTION_TYPE_ITEM,getResource(PORTAL_UI_PAGE_SETION_TYPE_ITEM));this.m_singleItemRadio.addListener(this);objLbl=new Label(getResource(PORTAL_UI_PAGE_SETION_TYPE_ITEM_DESC));objLbl.setPadding(25,2,0,0);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,this.m_singleItemRadio,TABLE_LAYOUT_REMAINDER);this.addRow("25");this.addCell(this.getRowCount()-1,objLbl,TABLE_LAYOUT_REMAINDER);this.m_itemListRadio=new RadioButton("pageSectionType",PORTAL_PAGE_SECTION_TYPE_LIST,getResource(PORTAL_UI_PAGE_SETION_TYPE_LIST));this.m_itemListRadio.addListener(this);objLbl=new Label(getResource(PORTAL_UI_PAGE_SETION_TYPE_LIST_DESC));objLbl.setPadding(25,2,0,0);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,this.m_itemListRadio,TABLE_LAYOUT_REMAINDER);this.addRow("40");this.addCell(this.getRowCount()-1,objLbl,TABLE_LAYOUT_REMAINDER);this.m_calendarRadio=new RadioButton("pageSectionType",PORTAL_PAGE_SECTION_TYPE_CALENDAR,getResource(PORTAL_UI_PAGE_SETION_TYPE_CALENDAR));this.m_calendarRadio.addListener(this);objLbl=new Label(getResource(PORTAL_UI_PAGE_SETION_TYPE_CALENDAR_DESC));objLbl.setPadding(25,2,0,0);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,this.m_calendarRadio,TABLE_LAYOUT_REMAINDER);this.addRow("40");this.addCell(this.getRowCount()-1,objLbl,TABLE_LAYOUT_REMAINDER);this.m_itemSearchRadio=new RadioButton("pageSectionType",PORTAL_PAGE_SECTION_TYPE_CREATE_ITEM,getResource(PORTAL_UI_PAGE_SETION_TYPE_SEARCH));this.m_itemSearchRadio.addListener(this);objLbl=new Label(getResource(PORTAL_UI_PAGE_SETION_TYPE_SEARCH_DESC));objLbl.setPadding(25,2,0,0);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,this.m_itemSearchRadio,TABLE_LAYOUT_REMAINDER);this.addRow("40");this.addCell(this.getRowCount()-1,objLbl,TABLE_LAYOUT_REMAINDER);this.m_itemCreateRadio=new RadioButton("pageSectionType",PORTAL_PAGE_SECTION_TYPE_SEARCH,getResource(PORTAL_UI_PAGE_SETION_TYPE_USER_CONTENT));this.m_itemCreateRadio.addListener(this);objLbl=new Label(getResource(PORTAL_UI_PAGE_SETION_TYPE_USER_CONTENT_DESC));objLbl.setPadding(25,2,0,0);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,this.m_itemCreateRadio,TABLE_LAYOUT_REMAINDER);this.addRow("40");this.addCell(this.getRowCount()-1,objLbl,TABLE_LAYOUT_REMAINDER);if(this.m_wizard.m_portalPage.isSecured())
{this.m_itemCreateSecuredRadio=new RadioButton("pageSectionType",PORTAL_PAGE_SECTION_TYPE_SEARCH,getResource(PORTAL_UI_PAGE_SETION_TYPE_SECURED_CONTENT));this.m_itemCreateSecuredRadio.addListener(this);objLbl=new Label(getResource(PORTAL_UI_PAGE_SETION_TYPE_SECURED_CONTENT_DESC));objLbl.setPadding(25,2,0,0);this.addRow(TABLE_LAYOUT_AUTO);this.addCell(this.getRowCount()-1,this.m_itemCreateSecuredRadio,TABLE_LAYOUT_REMAINDER);this.addRow("40");this.addCell(this.getRowCount()-1,objLbl,TABLE_LAYOUT_REMAINDER);}
else
{this.m_itemCreateSecuredRadio=null;}}
ContentSectionWizardStep1.prototype.onRadioButtonClick=function()
{this.m_wizard.enableNext();}
ContentSectionWizardStep1.prototype.onShowStep=function()
{if(!this.m_singleItemRadio.isChecked()&&!this.m_itemListRadio.isChecked()&&!this.m_calendarRadio.isChecked()&&!this.m_itemSearchRadio.isChecked()&&!this.m_itemCreateRadio.isChecked()&&!(this.m_itemCreateSecuredRadio!=null&&this.m_itemCreateSecuredRadio.isChecked()))
{this.m_wizard.disableNext();}
else
{this.m_wizard.enableNext();}}
function ContentSectionWizardStep2()
{this.WizardStep(getResource(PORTAL_UI_CS_WIZ_S2_TITLE));this.setSize(600,400);this.m_selectedContentType=null;}
copyPrototype(ContentSectionWizardStep2,WizardStep);ContentSectionWizardStep2.prototype.createStepLayout=function()
{WizardStep.prototype.createStepLayout.apply(this,arguments);this.m_contentTypeList=new ContentTypeList();this.m_contentTypeList.addListener(this);this.m_contentTypeList.setMargin(2,2,2,2);this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_contentTypeList,TABLE_LAYOUT_REMAINDER);}
ContentSectionWizardStep2.prototype.onListSelectionChange=function()
{var selection=this.m_contentTypeList.getSelectedItems();if(selection.length==0)
{this.m_selectedContentType=null;}
else
{this.m_selectedContentType=selection[0];}
this.checkUI();}
ContentSectionWizardStep2.prototype.onShowStep=function()
{this.checkUI();}
ContentSectionWizardStep2.prototype.checkUI=function()
{this.m_wizard.disableNext();this.m_wizard.disableFinish();if(this.m_selectedContentType!=null)
{if(this.m_wizard.m_step1.m_singleItemRadio.isChecked()||this.m_wizard.m_step1.m_itemListRadio.isChecked()||this.m_wizard.m_step1.m_calendarRadio.isChecked())
{this.m_wizard.enableNext();}
else
{this.m_wizard.enableFinish();}}}
ContentSectionWizardStep2.prototype.onNext=function()
{if(this.m_wizard.m_step1.m_singleItemRadio.isChecked())
{this.m_wizard.onNextConfirm(this.m_wizard.m_step3);}
else if(this.m_wizard.m_step1.m_itemListRadio.isChecked()||this.m_wizard.m_step1.m_calendarRadio.isChecked())
{this.m_wizard.onNextConfirm(this.m_wizard.m_step4);}}
ContentSectionWizardStep2.prototype.onFinish=function()
{var pageSectionType=null;if(this.m_wizard.m_step1.m_itemSearchRadio.isChecked())
{pageSectionType=PORTAL_PAGE_SECTION_TYPE_SEARCH;}
else if(this.m_wizard.m_step1.m_itemCreateRadio.isChecked())
{pageSectionType=PORTAL_PAGE_SECTION_TYPE_CREATE_ITEM;}
else if(this.m_wizard.m_step1.m_itemCreateSecuredRadio.isChecked())
{pageSectionType=PORTAL_PAGE_SECTION_TYPE_USER_CONTENT;}
var portalContentType=this.m_wizard.m_step2.m_selectedContentType;var request=new AjaxRequest(APP_URL+"/navigation.do");request.addParam("action","newPageSection");request.addParam("pageInstanceId",this.m_wizard.m_portalPage.getInstanceId());request.addParam("pageSectionType",pageSectionType);request.addParam("pageSection_ContentTypeInstanceId",portalContentType.getInstanceId());request.postRequest(this.addPageSection_Response.bind(this));}
ContentSectionWizardStep2.prototype.addPageSection_Response=function(response)
{eval(response.getJavaScript());this.m_wizard.m_newPortalPageSection=portalPageSection;this.m_wizard.onFinishConfirm();}
function ContentSectionWizardStep3()
{this.WizardStep(getResource(PORTAL_UI_CS_WIZ_S2_TITLE));this.setSize(600,400);this.m_selectedContentItem=null;}
copyPrototype(ContentSectionWizardStep3,WizardStep);ContentSectionWizardStep3.prototype.createStepLayout=function()
{WizardStep.prototype.createStepLayout.apply(this,arguments);this.m_contentItemsGrid=new Label(getResource(PORTAL_UI_CS_WIZ_S3_LOADING));this.m_contentItemsGrid.setColor("gray");this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_contentItemsGrid,TABLE_LAYOUT_REMAINDER);}
ContentSectionWizardStep3.prototype.onShowStep=function()
{this.m_wizard.disableNext();this.m_wizard.disableFinish();var request=new AjaxRequest(APP_URL+"/content_type.do");request.addParam("action","listContentTypeItems");request.addParam("contentTypeInstanceId",this.m_wizard.m_step2.m_selectedContentType.getInstanceId());request.postRequest(this.onLoadContentTypeItems_Response.bind(this));}
ContentSectionWizardStep3.prototype.onLoadContentTypeItems_Response=function(response)
{eval(response.getJavaScript());this.m_contentTypeItemInstances=contentTypesItemsInstances;if(this.m_contentTypeItemInstances.length==0)
{this.m_contentItemsGrid=new Label(getResource(PORTAL_UI_CS_WIZ_S3_NONE));}
else
{this.m_itemsGridData=new InstancesGridData(this.m_contentTypeItemInstances);this.m_contentItemsGrid=new Grid(GRID_MODE_PRELOAD);this.m_contentItemsGrid.setPageSize(15);this.m_contentItemsGrid.setGridData(this.m_itemsGridData);this.m_contentItemsGrid.addListener(this);}
this.m_contentItemsGrid.setPadding(2,2,2,2);this.replaceCell(this.getRowCount()-1,0,this.m_contentItemsGrid);}
ContentSectionWizardStep3.prototype.onPrevious=function()
{this.m_selectedContentItem=null;this.m_wizard.onPreviousConfirm();}
ContentSectionWizardStep3.prototype.onFinish=function()
{var portalContentType=this.m_wizard.m_step2.m_selectedContentType;var request=new AjaxRequest(APP_URL+"/navigation.do");request.addParam("action","newPageSection");request.addParam("pageInstanceId",this.m_wizard.m_portalPage.getInstanceId());request.addParam("pageSectionType",PORTAL_PAGE_SECTION_TYPE_ITEM);request.addParam("pageSection_ContentTypeInstanceId",portalContentType.getInstanceId());request.postRequest(this.addPageSection_Item_Response.bind(this));}
ContentSectionWizardStep3.prototype.addPageSection_Item_Response=function(response)
{eval(response.getJavaScript());var portalPageSection=portalPageSection;portalPageSection.setContentTypeIdentifier(this.m_selectedContentItem.getId());this.m_wizard.m_newPortalPageSection=portalPageSection;this.m_wizard.onFinishConfirm();}
ContentSectionWizardStep3.prototype.onGridRowClick=function()
{var contentItemIndex=this.m_contentItemsGrid.getSelectedRow();if(contentItemIndex>-1)
{this.m_selectedContentItem=this.m_contentTypeItemInstances[contentItemIndex];this.m_wizard.enableFinish();}
else
{this.m_selectedContentItem=null;this.m_wizard.disableFinish();}}
function ContentSectionWizardStep4()
{this.WizardStep(getResource(PORTAL_UI_CS_WIZ_S4_TITLE));this.setSize(600,400);this.m_selectedContentItem=null;}
copyPrototype(ContentSectionWizardStep4,WizardStep);ContentSectionWizardStep4.prototype.createStepLayout=function()
{WizardStep.prototype.createStepLayout.apply(this,arguments);this.m_searchControl=new Label(getResource(PORTAL_UI_CS_WIZ_S4_LOADING));this.m_searchControl.setColor("gray");this.addRow(TABLE_LAYOUT_REMAINDER);this.addCell(this.getRowCount()-1,this.m_searchControl,TABLE_LAYOUT_REMAINDER);}
ContentSectionWizardStep4.prototype.onShowStep=function()
{this.m_wizard.disableNext();this.m_wizard.disableFinish();var pageSectionType=null;if(this.m_wizard.m_step1.m_itemListRadio.isChecked())
{pageSectionType=PORTAL_PAGE_SECTION_TYPE_LIST;}
else if(this.m_wizard.m_step1.m_calendarRadio.isChecked())
{pageSectionType=PORTAL_PAGE_SECTION_TYPE_CALENDAR;}
var portalContentType=this.m_wizard.m_step2.m_selectedContentType;var request=new AjaxRequest(APP_URL+"/navigation.do");request.addParam("action","newPageSection");request.addParam("pageInstanceId",this.m_wizard.m_portalPage.getId());request.addParam("pageSectionType",pageSectionType);request.addParam("pageSection_ContentTypeInstanceId",portalContentType.getId());request.postRequest(this.addPageSection_Query_Response.bind(this));}
ContentSectionWizardStep4.prototype.addPageSection_Query_Response=function(response)
{eval(response.getJavaScript());this.m_portalPageSection=portalPageSection;var contentQuery=this.m_portalPageSection.getContentQuery();this.m_searchControl=new SimpleSearchControl(contentQuery);if(this.m_wizard.m_step1.m_itemListRadio.isChecked())
{this.m_searchControl.m_docCtrlOptions.m_show_sort_field=true;}
this.m_searchControl.createLayout();var layout=new TableLayout();if(this.m_wizard.m_step1.m_itemListRadio.isChecked())
{this.m_alphabeticalListCk=new Checkbox("0","Alphabetical List");layout.addRow(TABLE_LAYOUT_FLOW);layout.addCell(layout.getRowCount()-1,this.m_alphabeticalListCk,TABLE_LAYOUT_REMAINDER);}
layout.addRow(TABLE_LAYOUT_FLOW);layout.addCell(layout.getRowCount()-1,this.m_searchControl,TABLE_LAYOUT_REMAINDER);this.replaceCell(this.getRowCount()-1,0,new ScrollPanel(layout));this.m_wizard.enableFinish();}
ContentSectionWizardStep4.prototype.onPrevious=function()
{this.m_selectedContentItem=null;this.m_wizard.onPreviousConfirm();}
ContentSectionWizardStep4.prototype.onFinish=function()
{this.m_searchControl.updateSearch();if(this.m_wizard.m_step1.m_itemListRadio.isChecked())
{if(this.m_alphabeticalListCk.getValue()=="1")
{this.m_portalPageSection.setOptionValue(PORTAL_PAGE_SECTION_LIST_OPTION_ALPHABETICAL,"1");}
else
{this.m_portalPageSection.setOptionValue(PORTAL_PAGE_SECTION_LIST_OPTION_ALPHABETICAL,"0");}}
this.m_wizard.m_newPortalPageSection=this.m_portalPageSection;this.m_wizard.onFinishConfirm();}
function ContentSectionWizard(portalPage,callback)
{this.Wizard(getResource(PORTAL_UI_CS_WIZ_TITLE),callback);this.m_portalPage=portalPage;this.m_newPortalPageSection=null;this.m_step1=new ContentSectionWizardStep1();this.m_step2=new ContentSectionWizardStep2();this.m_step3=new ContentSectionWizardStep3();this.m_step4=new ContentSectionWizardStep4();this.addStep(this.m_step1);this.addStep(this.m_step2);this.addStep(this.m_step3);this.addStep(this.m_step4);}
copyPrototype(ContentSectionWizard,Wizard);ContentSectionWizard.prototype.getPageSize=function()
{return this.m_pageSize;}
function PortalTab()
{this.MainTab();this.setUniqueId("MainTab");this.m_logoUrl=APP_URL+"/images/portal/logo_small.png";this.m_logoWidth=150;this.m_logoHeight=31;}
copyPrototype(PortalTab,MainTab);PortalTab.prototype.onEditProfile=function()
{var winIndex=this.m_windowManager.getCoreObjectWindowIndex(WINDOW_TYPE_USER_PROFILE,coreApp.getCoreUser().getId());if(winIndex>-1)
{var objWindow=this.m_windowManager.getWindow(winIndex);this.m_windowManager.setActiveWindow(objWindow);return;}
var userWindow=new UserProfileWindow(null);userWindow.addListener(this);this.m_windowManager.addWindow(userWindow);}
function ContentTypesTab()
{this.PortalTab();this.setUniqueId("ContentTypesTab");}
copyPrototype(ContentTypesTab,PortalTab);ContentTypesTab.prototype.initialize_toolbar=function()
{this.m_toolbar=new ContentTypeTabToolbar(this);this.m_toolbar.setUniqueId(this.getUniqueId()+"_Toolbar");}
ContentTypesTab.prototype.initialize_rightPane=function()
{PortalTab.prototype.initialize_rightPane.apply(this,arguments);this.m_windowManager=new CoreObjectWindowManager();this.m_windowManager.setBackgroundColor("#BECAC8");this.m_windowManager.setToolbar(this.m_toolbar);this.m_windowManager.addListener(this);this.m_rightPane=this.m_windowManager;}
ContentTypesTab.prototype.initialize_list=function()
{PortalTab.prototype.initialize_list.apply(this,arguments);this.addCacheToLoad(coreApp.getContentTypeCache());this.m_contentTypeList=new ContentTypeList();this.m_contentTypeList.addListener(this);this.m_contentTypeToolbar=new ContentTypeToolbar(this,this.m_contentTypeList);this.m_contentTypesLayout=this.createListToolbarLayout(this.m_contentTypeToolbar,this.m_contentTypeList);this.m_listPanel=new TabControl();this.m_listPanel.setUseSmallTabs(true);this.m_listPanelTab=new Tab(getResource(PORTAL_UI_CONTENT_TYPES),getResource(PORTAL_UI_CONTENT_TYPES_LIST),null);this.m_listPanelTab.setWidth(120);this.m_listPanel.addTab(this.m_listPanelTab,this.m_contentTypesLayout);}
ContentTypesTab.prototype.onNewContentType=function()
{var templates=new Array();templates.push("Blank");templates.push("Dog");this.m_contentTypeDlg=new RadioButtonSetDialog(templates);this.m_contentTypeDlg.showDialog("Select Template Type","Select the template type of the content type.",400,250,this.onNewContentType_Closed.bind(this));}
ContentTypesTab.prototype.onNewContentType_Closed=function(cancelled)
{if(cancelled)
{return;}
var contentTypeWindow=new ContentTypeWindow(null,this.m_contentTypeDlg.getValue());contentTypeWindow.addListener(this);this.m_windowManager.addWindow(contentTypeWindow);}
ContentTypesTab.prototype.onEditContentType=function()
{var selectedObjects=this.m_contentTypeList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("ContentTypesTab.prototype.onDeleteContentType: Invalid content type selection");}
var contentType=selectedObjects[0];var objWin=this.m_windowManager.getCoreObjectWindow(WINDOW_TYPE_CONTENT_TYPE,contentType.getId());if(objWin!=null)
{this.m_windowManager.setActiveWindow(objWin);return;}
objWin=new ContentTypeWindow(contentType,null);objWin.addListener(this);this.m_windowManager.addWindow(objWin);}
ContentTypesTab.prototype.onListContentTypeItems=function()
{var selectedObjects=this.m_contentTypeList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("ContentTypesTab.prototype.onDeleteContentType: Invalid content type selection");}
var contentType=selectedObjects[0];var objWin=this.m_windowManager.getCoreObjectWindow(WINDOW_TYPE_CONTENT_TYPE_ITEMS,contentType.getId());if(objWin!=null)
{this.m_windowManager.setActiveWindow(objWin);return;}
objWin=new ContentTypeItemsWindow(contentType);objWin.addListener(this);this.m_windowManager.addWindow(objWin);}
ContentTypesTab.prototype.onDeleteContentType=function()
{var selectedObjects=this.m_contentTypeList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("ContentTypesTab.prototype.onDeleteContentType: Invalid content type selection");}
var contentType=selectedObjects[0];this.m_delDialog=new ModalDialog();this.m_delDialog.setShowCancel(true);this.m_delDialog.showDialog(getResource(PORTAL_UI_CONFIRM_DELETE),new Label(getResource(PORTAL_UI_CONTENT_TYPE_DELETE)),400,120,this.onDeleteContentType_Confirm.bind(this));}
ContentTypesTab.prototype.onDeleteContentType_Confirm=function(cancelled)
{if(cancelled)
{return;}
var selectedObjects=this.m_contentTypeList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("ContentTypesTab.prototype.onDeleteContentType: Invalid content type selection");}
var contentType=selectedObjects[0];var request=new AjaxRequest(APP_URL+"/content_type.do");request.addParam("action","deleteContentType");request.addParam("contentTypeInstanceId",contentType.getInstanceId());request.postRequest(this.onDeleteContentType_Response.bind(this));}
ContentTypesTab.prototype.onDeleteContentType_Response=function(response)
{eval(response.getJavaScript());var cache=coreApp.getContentTypeCache();cache.removeCoreInstanceObject(contentTypeInstanceId);var winIndex=this.getContentTypeWindowIndex(contentTypeInstanceId);if(winIndex>-1)
{this.m_windowManager.removeWindow(winIndex);}}
ContentTypesTab.prototype.getContentTypeWindowIndex=function(contentTypeInstanceId)
{var wCount=this.m_windowManager.getWindowCount();var curWindow;var portalContentType;for(var i=0;i<wCount;i++)
{curWindow=this.m_windowManager.getWindow(i);if(curWindow.getType()!=WINDOW_TYPE_CONTENT_TYPE)
{continue;}
portalContentType=curWindow.getPortalContentType();if(portalContentType.getId()!=contentTypeInstanceId)
{continue;}
return i;}
return-1;}
ContentTypesTab.prototype.getContentTypeItemsWindowIndex=function(contentTypeInstanceId)
{var wCount=this.m_windowManager.getWindowCount();var curWindow;var portalContentType;for(var i=0;i<wCount;i++)
{curWindow=this.m_windowManager.getWindow(i);if(curWindow.getType()!=WINDOW_TYPE_CONTENT_TYPE_ITEMS)
{continue;}
portalContentType=curWindow.getPortalContentType();if(portalContentType.getId()!=contentTypeInstanceId)
{continue;}
return i;}
return-1;}
ContentTypesTab.prototype.onWindowActivate=function()
{this.checkUIControls();}
ContentTypesTab.prototype.onWindowChanged=function(objWindow)
{this.checkUIControls();}
ContentTypesTab.prototype.onWindowSaved=function()
{this.checkUIControls();}
ContentTypesTab.prototype.onWindowLoaded=function()
{this.checkUIControls();}
ContentTypesTab.prototype.onWindowLoaded=function()
{this.checkUIControls();}
ContentTypesTab.prototype.checkUIControls=function()
{if(!this.isCreated())
{return;}
this.m_toolbar.disableAll();var selectedObjects=this.m_contentTypeList.getSelectedItems();if(selectedObjects.length>0)
{this.m_toolbar.enableAddContentTypeItemButtons();}
var objWindow=this.m_windowManager.getActiveWindow();if(objWindow!=null)
{this.m_toolbar.enablePrint();if(objWindow.hasChanged())
{this.m_toolbar.enableSave();}
if(objWindow.canRefresh())
{this.m_toolbar.enableRefresh();}}}
ContentTypesTab.prototype.onListSelectionChange=function(objList)
{this.checkUIControls();}
ContentTypesTab.prototype.onContentTypeItemSelected=function(objList)
{this.checkUIControls();}
ContentTypesTab.prototype.onGetSearchContentItems=function(objList)
{var selectedObjects=this.m_contentTypeList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("ContentTypesTab.prototype.onGetSearchContentItems: Invalid content type selection");}
var contentType=selectedObjects[0];var request=new AjaxRequest(APP_URL+"/content_type.do");request.addParam("action","getSearchContentType");request.addParam("contentTypeInstanceId",contentType.getInstanceId());request.postRequest(this.onGetSearchContentItems_Response.bind(this));}
ContentTypesTab.prototype.onGetSearchContentItems_Response=function(response)
{eval(response.getJavaScript());var selectedObjects=this.m_contentTypeList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("ContentTypesTab.prototype.onGetSearchContentItems_Response: Invalid content type selection");}
var contentType=selectedObjects[0];this.m_searchDialog=new SearchDialog("Search - "+contentType.getName(),contentItemSearch)
this.m_searchDialog.showDialog(this.onGetSearchContentItems_DialogClose.bind(this));}
ContentTypesTab.prototype.onGetSearchContentItems_DialogClose=function(cancelled)
{if(cancelled)
{this.m_searchDialog=null;return;}
var selectedObjects=this.m_contentTypeList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("ContentTypesTab.prototype.onGetSearchContentItems_DialogClose: Invalid content type selection");}
var contentType=selectedObjects[0];var itemSearch=this.m_searchDialog.getSearch();var request=new AjaxRequest(APP_URL+"/content_type.do");request.addParam("action","searchContentType");request.addParam("contentTypeInstanceId",contentType.getInstanceId());request.addParam("itemSearchId",itemSearch.getId());itemSearch.populateRequest(request);request.postRequest(this.onSearchContentItem_Response.bind(this));this.m_searchDialog=null;}
ContentTypesTab.prototype.onSearchContentItem_Response=function(response)
{eval(response.getJavaScript());var selectedObjects=this.m_contentTypeList.getSelectedItems();if(selectedObjects.length==0)
{new CoreException("ContentTypesTab.prototype.onSearchContentItem_Response: Invalid content type selection");}
var contentType=selectedObjects[0];var contentTypeItemsWindow=new ContentTypeItemsWindow(contentType);contentTypeItemsWindow.setContentTypeItems(contentTypesItemsInstances);contentTypeItemsWindow.setCanRefresh(false);contentTypeItemsWindow.addListener(this);this.m_windowManager.addWindow(contentTypeItemsWindow);}
function NavigationTab()
{this.PortalTab();this.setUniqueId("NavigationTab");this.m_windowManager=new CoreObjectWindowManager();}
copyPrototype(NavigationTab,PortalTab);NavigationTab.prototype.initialize_toolbar=function()
{this.m_toolbar=new NavigationTabToolbar(this);this.m_toolbar.setUniqueId(this.getUniqueId()+"_Toolbar");}
NavigationTab.prototype.initialize_rightPane=function()
{PortalTab.prototype.initialize_rightPane.apply(this,arguments);this.m_windowManager.setBackgroundColor("#BECAC8");this.m_windowManager.setToolbar(this.m_toolbar);this.m_windowManager.addListener(this);this.m_rightPane=this.m_windowManager;}
NavigationTab.prototype.initialize_list=function()
{PortalTab.prototype.initialize_list.apply(this,arguments);this.addCacheToLoad(coreApp.getContentTypeCache());this.m_publicPagesLayout=new PageTreeEditor("0",this.m_windowManager);this.m_securedPagesLayout=new PageTreeEditor("1",this.m_windowManager);this.m_listPanel=new TabControl();this.m_listPanel.setUseSmallTabs(true);this.m_publicPagesTab=new Tab(getResource(PORTAL_UI_PUBLIC_PAGES),getResource(PORTAL_UI_PUBLIC_PAGES_DESC),null);this.m_publicPagesTab.setWidth(110);this.m_listPanel.addTab(this.m_publicPagesTab,this.m_publicPagesLayout);this.m_securedPagesTab=new Tab(getResource(PORTAL_UI_PRIVATE_PAGES),getResource(PORTAL_UI_PRIVATE_PAGES_DESC),null);this.m_securedPagesTab.setWidth(110);this.m_listPanel.addTab(this.m_securedPagesTab,this.m_securedPagesLayout);this.m_listPanel.setWidth(230);}
NavigationTab.prototype.onWindowActivate=function()
{this.checkUIControls();}
NavigationTab.prototype.onWindowChanged=function(objWindow)
{this.checkUIControls();}
NavigationTab.prototype.onWindowSaved=function()
{this.checkUIControls();}
NavigationTab.prototype.onWindowLoaded=function()
{this.checkUIControls();}
NavigationTab.prototype.checkUIControls=function()
{if(!this.isCreated())
{return;}
this.m_toolbar.disableAll();var objWindow=this.m_windowManager.getActiveWindow();if(objWindow!=null)
{this.m_toolbar.enablePrint();if(objWindow.hasChanged())
{this.m_toolbar.enableSave();}
if(objWindow.canRefresh())
{this.m_toolbar.enableRefresh();}}}
NavigationTab.prototype.onPageAdd_ContentItem=function()
{var objWindow=this.m_windowManager.getActiveWindow();var pageInstanceId=objWindow.getPortalPage().getId();var objWindow=this.m_windowManager.getActiveWindow();if(objWindow==null)
{return;}
var selection=this.m_contentTypeList.getSelectedItems();if(selection.length==0)
{return;}
var portalContentType=selection[0];var itemIndex=this.m_itemsGrid.getSelectedRow();var itemInstance=this.m_itemsGrid.getGridData().getInstance(itemIndex);objWindow.addPageSection_Item(portalContentType,itemInstance);}
NavigationTab.prototype.onPageAdd_ContentQuery=function()
{var objWindow=this.m_windowManager.getActiveWindow();var pageInstanceId=objWindow.getPortalPage().getId();var objWindow=this.m_windowManager.getActiveWindow();if(objWindow==null)
{return;}
var selection=this.m_contentTypeList.getSelectedItems();if(selection.length==0)
{return;}
var portalContentType=selection[0];objWindow.addPageSection_Query(portalContentType);}
NavigationTab.prototype.onPageAdd_CalendarQuery=function()
{var objWindow=this.m_windowManager.getActiveWindow();var pageInstanceId=objWindow.getPortalPage().getId();var objWindow=this.m_windowManager.getActiveWindow();if(objWindow==null)
{return;}
var selection=this.m_contentTypeList.getSelectedItems();if(selection.length==0)
{return;}
var portalContentType=selection[0];objWindow.addPageSection_Calendar(portalContentType);}
NavigationTab.prototype.onPageAdd_Search=function()
{var objWindow=this.m_windowManager.getActiveWindow();var pageInstanceId=objWindow.getPortalPage().getId();var objWindow=this.m_windowManager.getActiveWindow();if(objWindow==null)
{return;}
var selection=this.m_contentTypeList.getSelectedItems();if(selection.length==0)
{return;}
var portalContentType=selection[0];objWindow.addPageSection_Search(portalContentType);}
NavigationTab.prototype.onPageAdd_Subscribe=function()
{var objWindow=this.m_windowManager.getActiveWindow();var pageInstanceId=objWindow.getPortalPage().getId();var objWindow=this.m_windowManager.getActiveWindow();if(objWindow==null)
{return;}
objWindow.addPageSection_Subscribe();}
NavigationTab.prototype.onPageAdd_CreateItem=function()
{var objWindow=this.m_windowManager.getActiveWindow();var pageInstanceId=objWindow.getPortalPage().getId();var objWindow=this.m_windowManager.getActiveWindow();if(objWindow==null)
{return;}
var selection=this.m_contentTypeList.getSelectedItems();if(selection.length==0)
{return;}
var portalContentType=selection[0];objWindow.addPageSection_CreateItem(portalContentType);}
NavigationTab.prototype.onPageAdd_UserContent=function()
{var objWindow=this.m_windowManager.getActiveWindow();var pageInstanceId=objWindow.getPortalPage().getId();var objWindow=this.m_windowManager.getActiveWindow();if(objWindow==null)
{return;}
var selection=this.m_contentTypeList.getSelectedItems();if(selection.length==0)
{return;}
var portalContentType=selection[0];objWindow.addPageSection_UserContent(portalContentType);}
NavigationTab.prototype.isSecuredPages=function()
{return this.m_listPanel.getActiveTab()==this.m_securedPagesLayout;}
function ImageLibraryTab()
{this.PortalTab();this.setUniqueId("ImageLibraryTab");this.m_windowManager=new CoreObjectWindowManager();}
copyPrototype(ImageLibraryTab,PortalTab);ImageLibraryTab.prototype.initialize_toolbar=function()
{this.m_toolbar=new ImageLibraryTabToolbar(this);}
ImageLibraryTab.prototype.initialize_rightPane=function()
{PortalTab.prototype.initialize_rightPane.apply(this,arguments);this.m_windowManager.setBackgroundColor("#BECAC8");this.m_windowManager.setToolbar(this.m_toolbar);this.m_windowManager.addListener(this);this.m_rightPane=this.m_windowManager;}
ImageLibraryTab.prototype.initialize_list=function()
{PortalTab.prototype.initialize_list.apply(this,arguments);this.m_imagesList=new ImageListEditor(this.m_windowManager);this.m_imagesList.setWidth(265);this.m_listPanel=new TabControl();this.m_listPanel.setUseSmallTabs(true);this.m_imagesTab=new Tab(getResource(PORTAL_UI_IMAGES),getResource(PORTAL_UI_IMAGES_LIST),null);this.m_imagesTab.setWidth(110);this.m_listPanel.addTab(this.m_imagesTab,this.m_imagesList);this.m_listPanel.setWidth(140);}
ImageLibraryTab.prototype.onWindowActivate=function()
{this.checkUIControls();}
ImageLibraryTab.prototype.onWindowChanged=function(objWindow)
{this.checkUIControls();}
ImageLibraryTab.prototype.onWindowSaved=function()
{this.checkUIControls();}
ImageLibraryTab.prototype.onWindowLoaded=function()
{this.checkUIControls();}
ImageLibraryTab.prototype.checkUIControls=function()
{if(!this.isCreated())
{return;}
this.m_toolbar.disableAll();var objWindow=this.m_windowManager.getActiveWindow();if(objWindow!=null)
{this.m_toolbar.enablePrint();if(objWindow.hasChanged())
{this.m_toolbar.enableSave();}
if(objWindow.canRefresh())
{this.m_toolbar.enableRefresh();}}}
function MailingListsTab()
{this.PortalTab();this.setUniqueId("MailingListsTab");this.m_windowManager=new CoreObjectWindowManager();}
copyPrototype(MailingListsTab,PortalTab);MailingListsTab.prototype.initialize_toolbar=function()
{this.m_toolbar=new MailingListTabToolbar(this);}
MailingListsTab.prototype.initialize_rightPane=function()
{PortalTab.prototype.initialize_rightPane.apply(this,arguments);this.m_windowManager.setBackgroundColor("#BECAC8");this.m_windowManager.setToolbar(this.m_toolbar);this.m_windowManager.addListener(this);this.m_rightPane=this.m_windowManager;}
MailingListsTab.prototype.initialize_list=function()
{PortalTab.prototype.initialize_list.apply(this,arguments);this.m_mailingListsList=new MailingListEditor(this.m_windowManager);this.m_mailingListsList.setWidth(265);this.m_listPanel=new TabControl();this.m_listPanel.setUseSmallTabs(true);this.m_mailingListsTab=new Tab(getResource(PORTAL_UI_MAILING_LISTS),getResource(PORTAL_UI_MAILING_LISTS_DESC),null);this.m_mailingListsTab.setWidth(110);this.m_listPanel.addTab(this.m_mailingListsTab,this.m_mailingListsList);this.m_listPanel.setWidth(140);}
MailingListsTab.prototype.onWindowActivate=function()
{this.checkUIControls();}
MailingListsTab.prototype.onWindowChanged=function(objWindow)
{this.checkUIControls();}
MailingListsTab.prototype.onWindowSaved=function()
{this.checkUIControls();}
MailingListsTab.prototype.onWindowLoaded=function()
{this.checkUIControls();}
MailingListsTab.prototype.checkUIControls=function()
{if(!this.isCreated())
{return;}
this.m_toolbar.disableAll();var objWindow=this.m_windowManager.getActiveWindow();if(objWindow!=null)
{this.m_toolbar.enablePrint();if(objWindow.hasChanged())
{this.m_toolbar.enableSave();}
if(objWindow.canRefresh())
{this.m_toolbar.enableRefresh();}}}
function FileLibraryTab()
{this.PortalTab();this.setUniqueId("FileLibraryTab");this.m_windowManager=new CoreObjectWindowManager();}
copyPrototype(FileLibraryTab,PortalTab);FileLibraryTab.prototype.initialize_toolbar=function()
{this.m_toolbar=new FileLibraryTabToolbar(this);}
FileLibraryTab.prototype.initialize_rightPane=function()
{PortalTab.prototype.initialize_rightPane.apply(this,arguments);this.m_windowManager.setBackgroundColor("#BECAC8");this.m_windowManager.setToolbar(this.m_toolbar);this.m_windowManager.addListener(this);this.m_rightPane=this.m_windowManager;}
FileLibraryTab.prototype.initialize_list=function()
{PortalTab.prototype.initialize_list.apply(this,arguments);this.m_filesList=new FileListEditor(this.m_windowManager);this.m_filesList.setWidth(265);this.m_listPanel=new TabControl();this.m_listPanel.setUseSmallTabs(true);this.m_filesTab=new Tab(getResource(PORTAL_UI_FILES),getResource(PORTAL_UI_FILES_LIST),null);this.m_filesTab.setWidth(110);this.m_listPanel.addTab(this.m_filesTab,this.m_filesList);this.m_listPanel.setWidth(140);}
FileLibraryTab.prototype.onWindowActivate=function()
{this.checkUIControls();}
FileLibraryTab.prototype.onWindowChanged=function(objWindow)
{this.checkUIControls();}
FileLibraryTab.prototype.onWindowSaved=function()
{this.checkUIControls();}
FileLibraryTab.prototype.onWindowLoaded=function()
{this.checkUIControls();}
FileLibraryTab.prototype.checkUIControls=function()
{if(!this.isCreated())
{return;}
this.m_toolbar.disableAll();var objWindow=this.m_windowManager.getActiveWindow();if(objWindow!=null)
{this.m_toolbar.enablePrint();if(objWindow.hasChanged())
{this.m_toolbar.enableSave();}
if(objWindow.canRefresh())
{this.m_toolbar.enableRefresh();}}}
var CACHE_CONTENT_TYPES="contentTypes";ACCOUNT_PERMISSION_ACTION="portalaccountpermission.do";SECURITY_TAB_SHOW_GROUPS=false;function PortalApplication()
{this.CoreApplication();this.initializeCaches();this.m_coreUser=null;}
copyPrototype(PortalApplication,CoreApplication);PortalApplication.prototype.getInitializationRequests=function()
{var requests=CoreApplication.prototype.getInitializationRequests.apply(this,arguments);var request=new AjaxRequest(APP_URL+"/user.do");request.addParam("action","openProfile");requests.addRequest(request,this.onOpenProfile_Response.bind(this));return requests;}
PortalApplication.prototype.initializeUI=function(response)
{this.m_navigationTabLayout=new NavigationTab();this.m_navigationTab=new Tab(getResource(PORTAL_UI_PAGES),getResource(PORTAL_UI_PAGES_DESC),null);this.m_navigationTab.setWidth(130);this.m_contentTypeTabLayout=new ContentTypesTab();this.m_contentTypeTab=new Tab(getResource(PORTAL_UI_CONTENT_TYPES),getResource(PORTAL_UI_CONTENT_TYPES_DESC),null);this.m_contentTypeTab.setWidth(130);this.m_imageLibraryTabLayout=new ImageLibraryTab();this.m_imageLibraryTab=new Tab(getResource(PORTAL_UI_IMAGES),getResource(PORTAL_UI_IMAGES_DESC),null);this.m_imageLibraryTab.setWidth(130);this.m_fileLibraryTabLayout=new FileLibraryTab();this.m_fileLibraryTab=new Tab(getResource(PORTAL_UI_FILES),getResource(PORTAL_UI_FILES_DESC),null);this.m_fileLibraryTab.setWidth(130);this.m_mailingListTabLayout=new MailingListsTab();this.m_mailingListTab=new Tab(getResource(PORTAL_UI_MAILING_LISTS),getResource(PORTAL_UI_MAILING_LISTS_DESC),null);this.m_mailingListTab.setWidth(130);MESSAGING_ACTION="portal_messaging.do";this.m_messagingTabLayout=new MessagingTab();this.m_messagingTabLayout.m_logoUrl=APP_URL+"/images/portal/logo_small.png";this.m_messagingTabLayout.m_logoWidth=150;this.m_messagingTabLayout.m_logoHeight=31;this.m_messagingTab=new Tab(getResource(MESSAGING_TAB_TITLE),getResource(MESSAGING_TAB_DESC),null);this.m_messagingTab.setWidth(130);this.m_securityTab=null;if(coreApp.getCoreUser().isSecurityAdmin())
{this.m_securityTabLayout=new SecurityTab();this.m_securityTabLayout.m_showUserGroups=false;this.m_securityTab=new Tab(getResource(PORTAL_UI_SECURITY),getResource(PORTAL_UI_SECURITY_DESC),null);this.m_securityTab.setWidth(130);}
this.main_panel.addTab(this.m_navigationTab,this.m_navigationTabLayout);this.main_panel.addTab(this.m_contentTypeTab,this.m_contentTypeTabLayout);this.main_panel.addTab(this.m_imageLibraryTab,this.m_imageLibraryTabLayout);this.main_panel.addTab(this.m_fileLibraryTab,this.m_fileLibraryTabLayout);this.main_panel.addTab(this.m_mailingListTab,this.m_mailingListTabLayout);this.main_panel.addTab(this.m_messagingTab,this.m_messagingTabLayout);if(this.m_securityTab!=null)
{this.main_panel.addTab(this.m_securityTab,this.m_securityTabLayout);}
this.m_messageDiv=createDiv("",document.body);this.m_messageDiv.style.position="absolute";this.m_messageDiv.style.height="14px";this.m_messageDiv.style.width="200px";this.m_messageDiv.style.top="20px";this.m_messageDiv.style.left=this.getAppContainerWidth()-205+"px";this.m_messageDiv.style.textAlign="right";this.m_messageDiv.style.fontFamily="Segoe UI,Tahoma";this.m_messageDiv.style.fontSize="12px";this.m_messageDiv.innerHTML=this.m_coreUser.getFirstName()+" "+this.m_coreUser.getLastName()+" / ";this.m_logOutLink=createLink(getResource(PORTAL_UI_LOGOUT),APP_URL+"/login.do?action=logout",this.m_messageDiv);this.m_logOutLink.href="#nowhere";this.m_logOutLink.style.textDecoration="none";this.m_logOutLink.style.color="black";this.m_logOutLink.style.fontWeight="";this.m_logOutLink.onclick=this.onLogout.bind(this);CoreApplication.prototype.initializeUI.apply(this,arguments);var appLoadDiv=document.getElementById("AppLoading");appLoadDiv.parentNode.removeChild(appLoadDiv);}
PortalApplication.prototype.onOpenProfile_Response=function(response)
{eval(response.getJavaScript());this.m_accountName=accountName;this.setCoreUser(coreUser);coreUser.m_isSecurityAdmin=isSecurityAdmin;}
PortalApplication.prototype.setCoreUser=function(coreUser)
{this.m_coreUser=coreUser;DOCUMENT_DATE_FORMAT_USER=coreUser.getDateFormat();}
PortalApplication.prototype.getCoreUser=function(coreUser)
{return this.m_coreUser;}
PortalApplication.prototype.initializeCaches=function()
{CoreApplication.prototype.initializeCaches.apply(this,arguments);var contentTypeCache=new ContentTypeCache();this.m_cacheManager.addCache(CACHE_CONTENT_TYPES,contentTypeCache);}
PortalApplication.prototype.getContentTypeCache=function()
{return this.m_cacheManager.getCache(CACHE_CONTENT_TYPES);}
PortalApplication.prototype.getPublicPagesCache=function()
{return this.m_cacheManager.getCache(CACHE_PUBLIC_PAGES);}
PortalApplication.prototype.getSecuredPagesCache=function()
{return this.m_cacheManager.getCache(CACHE_SECURED_PAGES);}
PortalApplication.prototype.onLogout=function(event)
{if(!event&&window.event)
{event=window.event;}
cancelEvent(event);var request=new AjaxRequest(APP_URL+"/login.do");request.addParam("action","logout");request.postRequest(this.onLogout_Response.bind(this));return false;}
PortalApplication.prototype.onLogout_Response=function(response)
{window.onbeforeunload=null;window.location=APP_LOGIN_URL;}
PortalApplication.prototype.resize=function()
{CoreApplication.prototype.resize.apply(this,arguments);this.m_messageDiv.style.left=this.getAppContainerWidth()-205+"px";}
PortalApplication.prototype.isShowContentTypeEditor=function()
{return window.location.href.indexOf("ct=true")>-1;}
