// Copyright 1999 (c) by Perforce Software, Inc. All rights reserved. // // p4wUsersPane: // The users pane. #include <p4wp4.h> #include "p4wStrBuf.h" #include "p4wHtml.h" #include "p4wPane.h" #include "p4wUsersPane.h" p4wUsersPane::p4wUsersPane(p4wView & ParentView, p4wRequest & Request) : p4wPane(ParentView, Request), fRowCtr(0) { } p4wUsersPane::~p4wUsersPane() { } // ------------------------------------- // Render functions. // void p4wUsersPane::Begin() { // // Begin the pane. p4wHtml htm; p4wURL urlMaker; StrBuf clearIcon; StrBuf grayIcon; // // Construct whitespace spacer & line underneathe title urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); urlMaker.ConstructURL( grayIcon, "/grayPixelIcon", AC_ICON, NULL ); htm.comment( "BEGIN USERS PANE" ); if (fRequest.GetScreenChunks() & SCRN_TITLE) { // Output the title htm.beginTRow(); htm.beginCol(); htm.beginSpan( "title" ); htm << "Users:"; htm.endSpan(); htm.endCol(); htm.endTRow(); // // Generate line underneath the title htm.beginTRow(); htm.beginCol( "top" ); htm.icon( grayIcon.Text(), "1", "100%", "", 1, "0", "0" ); htm.endCol(); htm.endTRow(); } fRequest << htm; htm.Clear(); // // Generate the users filter form if (fRequest.GetScreenChunks() & SCRN_FILTER) doForm(); // // Start the table htm.beginTRow(); htm.beginCol(); htm.icon( clearIcon.Text(), "6", "1", "", 1 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.beginTable( "0", "100%", "0", "1", "#7F7F7F" ); htm.beginTRow( NULL, NULL, "#FFFFFF" ); htm.beginCol(); htm.beginTable( "0", "100%", "0", "0", "#FFFFFF" ); // // Generate table headings htm.beginTRow( NULL, NULL, "#EEEEEE" ); htm.beginColHead(); htm.icon( clearIcon.Text(), "18", "5", "", 1 ); htm.endColHead(); htm.beginColHead( NULL, "left" ); htm << "Name"; htm.endColHead(); if (!SEC_DONT_SHOW_EMAIL_ADDR || fRequest.isLocalRequest()) { htm.beginColHead(); htm.icon( clearIcon.Text(), "0", "12", "", 1 ); htm.endColHead(); htm.beginColHead( NULL, "left" ); htm << "E-mail"; htm.endColHead(); } htm.beginColHead(); htm.icon( clearIcon.Text(), "0", "12", "", 1 ); htm.endColHead(); htm.beginColHead( NULL, "left" ); htm << "Updated"; htm.endColHead(); htm.beginColHead(); htm.icon( clearIcon.Text(), "0", "12", "", 1 ); htm.endColHead(); htm.beginColHead( NULL, "left" ); htm << "Accessed"; htm.endColHead(); htm.beginColHead(); htm.icon( clearIcon.Text(), "0", "12", "", 1 ); htm.endColHead(); htm.beginColHead( NULL, "left" ); htm << "Full name"; htm.endColHead(); htm.endTRow(); htm.beginTRow(); htm.beginCol( "top", NULL, "12", NULL, NULL, NULL, "5" ); htm.icon( grayIcon.Text(), "1", "100%", "", 1, "0", "0" ); htm.endCol(); htm.endTRow(); fRequest << htm; const StrPtr *unm = fRequest.GetDynArg( "unm", HE_None ); if (unm) fUnm << unm->Text(); const StrPtr *udu = fRequest.GetDynArg( "udu" ); if (udu) fUdu << udu->Text(); const StrPtr *uda = fRequest.GetDynArg( "uda" ); if (uda) fUda << uda->Text(); } void p4wUsersPane::Render(StrDict * varList) { // // Build the user URL StrPtr * user = varList->GetVar("User"); if (fUnm.Length()) { if (!user || !strstr(user->Text(), fUnm.Text())) return; } if (fUdu.Length()) { char *p; StrBuf date; date << p4wStrBuf().Expand(StrRef("%Update@*Y/*m/*d%"), *varList, Unicode() ); switch(*(p = fUdu.Text())) { case '_': if (strncmp(date.Text(), p+1, strlen(p+1)) != 0) return; break; case '-': if (fUdu.Length() == 11 ) { if (strcmp(date.Text(), p+1) >= 0) { return; } } else if (strcmp(date.Text(), p+1) > 0) { return; } break; default: if (fUdu.Length() == 10 ) { if (strcmp(date.Text(), p) < 0) { return; } } else if (strncmp(date.Text(), p, strlen(p)) < 0) { return; } break; } } if (fUda.Length()) { char *p; StrBuf date; date << p4wStrBuf().Expand(StrRef("%Access@*Y/*m/*d%"), *varList, Unicode() ); switch(*(p = fUda.Text())) { case '_': if (strncmp(date.Text(), p+1, strlen(p+1)) != 0) return; break; case '-': if (fUda.Length() == 11 ) { if (strcmp(date.Text(), p+1) >= 0) { return; } } else if (strcmp(date.Text(), p+1) > 0) { return; } break; default: if (fUda.Length() == 10 ) { if (strcmp(date.Text(), p) < 0) { return; } } else if (strncmp(date.Text(), p, strlen(p)) < 0) { return; } break; } } StrBuf userURL; StrBuf newBase; p4wURL urlMaker; p4wHtml htm(1); StrBuf clearIcon; // // Construct the vertical spacing icon urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); // // Construct the user url fRequest.UseNewBase( newBase, NULL, "path", NULL ); if( strcmp( user->Text(), fRequest.GetUser().Text() ) != 0 ) { newBase << user; } urlMaker.ConstructURL( userURL, newBase.Text(), AC_USERVIEW, NULL, fRequest.GetUnicode() ); // // If page content limit in bytes has been exceeded, don't // generate this entry if( PageLimitExceeded() ) return; htm.beginTRow( "top", 0, 0, (fRowCtr & 0x01) ? "list_row alt_row" : "list_row" ); htm.beginCol(); htm.endCol(); // // User name htm.beginCol(); htm.beginLink( userURL.Text() ); htm.text( p4wStrBuf().EscapeHTML(*user, Unicode()).Text() ); htm.endLink(); htm.endCol(); // // E-mail if (!SEC_DONT_SHOW_EMAIL_ADDR || fRequest.isLocalRequest()) { htm.beginCol(); htm.endCol(); htm.beginCol(); htm.beginLink( p4wStrBuf().Expand(StrRef("mailTo:%Email%"), *varList, Unicode() ).Text() ); htm.text( p4wStrBuf().Expand(StrRef("%Email%"), *varList, Unicode() ).Text() ); htm.endLink(); htm.endCol(); } // // Update date htm.beginCol(); htm.endCol(); htm.beginCol(); htm.text( p4wStrBuf().Expand(StrRef("%Update@*Y/*m/*d% "), *varList, Unicode() ).Text() ); htm.endCol(); // // Access date htm.beginCol(); htm.endCol(); htm.beginCol(); htm.text( p4wStrBuf().Expand(StrRef("%Access@*Y/*m/*d% "), *varList, Unicode() ).Text() ); htm.endCol(); // // Full name htm.beginCol(); htm.endCol(); htm.beginCol(0,0,0,0,0,0,0,1); htm.text( p4wStrBuf().Expand(StrRef("%FullName% "), *varList, Unicode() ).Text() ); htm.endCol(); htm.endTRow(); // // Vertical space between rows htm.beginTRow( 0, 0, 0, (fRowCtr++ & 0x01) ? "alt_row b" : "b" ); htm.beginCol( 0, 0, "100%" ); htm.icon( clearIcon.Text(), "3", "1", "", 1 ); htm.endCol(); htm.endTRow(); fRequest << htm; } void p4wUsersPane::End() { // // End the "Users" list. p4wHtml htm; if( !fRowCtr ) { p4wURL urlMaker; StrBuf clearIcon; urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); htm.beginTRow(); htm.beginCol(); htm.endCol(); htm.beginCol( NULL, NULL, "4" ); htm.text( "No users found." ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(); htm.icon( clearIcon.Text(), "5", "0", "", 1 ); htm.endCol(); htm.endTRow(); } htm.endTable(); htm.endCol(); htm.endTRow(); htm.endTable(); htm.endCol(); htm.endTRow(); htm.comment( "END USERS PANE" ); fRequest << htm; } void p4wUsersPane::doForm() { // // Generate the users filter form p4wHtml htm; p4wURL urlMaker; StrBuf actionURL; StrBuf path; StrBuf clearIcon; char *p; const StrPtr *unm = fRequest.GetDynArg( "unm", HE_Page ); const StrPtr *udu = fRequest.GetDynArg( "udu", HE_Page ); const StrPtr *uda = fRequest.GetDynArg( "uda", HE_Page ); // // Used to generate some whitespace urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); // // Some browsers will truncate the path from the BASE // if the path does not end in a forward slash. So if // we're in workspace mode, use the full path as a precaution. if( fRequest.GetViewMode() == VM_WORKSPACE ) fRequest.UseNewBase( path, NULL, "path", fRequest.GetPath().Text() ); else path << fRequest.GetURL(); fRequest.ConstructSafeURL( actionURL, path.Text(), AC_USERSPROCESSOR, NULL ); htm.beginTRow(); htm.beginCol(); fRequest << htm; htm.Clear(); StrBuf filtermsg; doFilterMessage(&filtermsg); fRequest.doShowHideBlock(SH_USERS, "user filter", "User Filter", filtermsg.Text()); htm.endCol(); htm.endTRow(); // // Start a DIV for showing/hiding the filter htm.beginTRow(); htm.beginCol(); htm << "<script language=javascript>" << crlf; htm << "document.write(\"<div id='showhideBlock'>\")" << crlf; htm << "</script>" << crlf; htm.beginTable(0, "100%", "0", "0"); // // Start the tables with the form htm.beginTRow(); htm.beginCol(); if( fRequest.GetJavascriptMode() != 2) htm.icon( clearIcon.Text(), "5", "1", "", 1 ); htm.beginForm( actionURL.Text() ); htm.beginTable( "0", "100%", "2", "0", "#FFFFFF" ); // // Top row of filter htm.beginTRow(); htm.beginCol(0,0,0,"100%"); htm.icon( clearIcon.Text(), "1", "14", "", 1 ); htm.endCol(); htm.beginCol(0,0,0,0,0,0,0,1); htm.label("User name contains:", "unm"); htm.endCol(); htm.beginCol(); htm.textField("unm", unm && unm->Length() ? unm->Text() : 0, 0, "unm"); htm.endCol(); htm.beginCol(); htm.icon( clearIcon.Text(), "1", "50", "", 1 ); htm.endCol(); htm.beginCol(); htm.text("Updated:"); htm.endCol(); htm.beginCol(0,0,0,0,0,0,0,1); htm.radio("Updated", "on", udu && *(udu->Text()) == '_', 0, "uon"); htm.label("on ", "uon"); htm.radio("Updated", "before", udu && *(udu->Text()) == '-', 0, "ub4"); htm.label("before ", "ub4"); htm.radio("Updated", "after", !udu || (*(udu->Text()) != '_' && *(udu->Text()) != '-'), 0, "uaf"); htm.label("after ", "uaf"); htm.endCol(); htm.beginCol(); if (udu && udu->Length()) { p = udu->Text(); if (*p == '-' || *p == '_') p++; } else p = NULL; htm.textField("udu", p ? p : 0, 0, "udu", 0, "formFieldClear(this, 'yyyy/mm/dd')", "formFieldRestore(this, 'yyyy/mm/dd')"); if (!p) { htm << "<script language=\"JavaScript\" type=\"text/javascript\">" << crlf; htm << "d = document.getElementById('udu');;" << crlf; htm << "if (d) { d.value = 'yyyy/mm/dd'; d.style.color = '#A0A0A0'; }" << crlf; htm << "</script>" << crlf; } htm.endCol(); htm.beginCol(0,0,0,0,0,"100%"); htm.endCol(); htm.endTRow(); // // 2nd row of filter htm.beginTRow(); htm.beginCol(0,0, "3"); htm.endCol(); htm.beginCol(); htm.text("Accessed:"); htm.endCol(); htm.beginCol(0,0,0,0,0,0,0,1); htm.radio("Accessed", "on", uda && *(uda->Text()) == '_', 0, "aon"); htm.label("on ", "aon"); htm.radio("Accessed", "before", uda && *(uda->Text()) == '-', 0, "ab4"); htm.label("before ", "ab4"); htm.radio("Accessed", "after", !uda || (*(uda->Text()) != '_' && *(uda->Text()) != '-'), 0, "aft"); htm.label("after ", "aft"); htm.endCol(); htm.beginCol(); if (uda && uda->Length()) { p = uda->Text(); if (*p == '-' || *p == '_') p++; } else p = NULL; htm.textField("uda", p ? p : 0, 0, "uda", 0, "formFieldClear(this, 'yyyy/mm/dd')", "formFieldRestore(this, 'yyyy/mm/dd')"); if (!p) { htm << "<script language=\"JavaScript\" type=\"text/javascript\">" << crlf; htm << "d = document.getElementById('uda');;" << crlf; htm << "if (d) { d.value = 'yyyy/mm/dd'; d.style.color = '#A0A0A0'; }" << crlf; htm << "</script>" << crlf; } htm.endCol(); htm.endTRow(); // // Filter button htm.beginTRow(); htm.beginCol(); htm.icon( clearIcon.Text(), "5", "1", "", 1 ); htm.endCol(); htm.endTRow(); htm.beginTRow(); htm.beginCol(0,0,"100%",0,0,0,0,1); htm.button( "Show", "Filter" ); // // Clear button htm.button( "Clear", "Reset Defaults" ); htm.endCol(); htm.endTRow(); htm.endTable(); StrBuf grayIcon; urlMaker.ConstructURL( grayIcon, "/grayPixelIcon", AC_ICON, NULL ); htm.icon( clearIcon.Text(), "10", "100%", "", 1, "0", "0" ); htm.icon( grayIcon.Text(), "1", "100%", "", 1, "0", "0" ); htm.endCol(); htm.endTRow(); htm.endCol(); htm.endTRow(); htm.endTable(); htm << "<script language=javascript>" << crlf; htm << "document.write(\"</div>\")" << crlf; htm << "</script>" << crlf; fRequest << htm; } void p4wUsersPane::doFilterMessage(StrBuf *msg) { char *p; const StrPtr *unm = fRequest.GetDynArg( "unm", HE_Page ); const StrPtr *udu = fRequest.GetDynArg( "udu", HE_Page ); const StrPtr *uda = fRequest.GetDynArg( "uda", HE_Page ); if (unm) *msg << "(Name contains: "" << unm->Text() << """; if (udu) { if (*(msg->Text())) *msg << "; Updated "; else *msg << "(Updated "; switch(*(udu->Text())) { case '-': if (udu->Length() < 11) *msg << "on or"; *msg << " before"; p = udu->Text()+1; break; case '_': if (udu->Length() < 11) *msg << "in"; else *msg << "on"; p = udu->Text()+1; break; default: if (udu->Length() < 10) *msg << "in or"; *msg << " after"; p = udu->Text(); break; } *msg << ": " << p; } if (uda) { if (*(msg->Text())) *msg << "; Accessed "; else *msg << "(Accessed "; switch(*(uda->Text())) { case '-': if (uda->Length() < 11) *msg << "on or"; *msg << " before"; p = uda->Text()+1; break; case '_': if (uda->Length() < 11) *msg << "in"; else *msg << "on"; p = uda->Text()+1; break; default: if (uda->Length() < 10) *msg << "in or"; *msg << " after"; p = uda->Text(); break; } *msg << ": " << p; } if (*(msg->Text())) *msg << ")"; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 12234 | Matt Attaway |
Rejigger P4Web project in preparation for official sunsetting The bin directory contains the last official builds of P4Web from the Perforce download site. P4Web is soon to be completely sunsetted; these builds are here for folks who don't want to build their own. To better handle the archived builds the source code has been moved into a separate src directory. |
||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |