// Copyright 2003 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // p4wHtml: // Appends the requested html data to itself (which is basically // a StrBuf). This is used to build up html strings which can // be output by the p4wRequest to the browser. #include <p4wp4.h> #include <assert.h> #include "p4wStrBuf.h" #include "p4wHtml.h" #define CRLF "\r\n" p4wHtml & p4wHtml::httpHeader( int code ) { // // Generate the http header message using code *this << "HTTP/1.0 "; *this << code; *this << " OK" << CRLF; return *this; } p4wHtml & p4wHtml::authHeader() { // // Generate the http header message for the authorization // screen *this << "HTTP/1.0 401 Authenticate" << CRLF; *this << "WWW-Authenticate: Basic realm=\"P4Web\"" << CRLF; return *this; } p4wHtml & p4wHtml::serverId() { // // Generate the Server id string *this << "Server: P4Web/" << ID_REL << "/"; *this << ID_OS << "/" << ID_PATCH << CRLF; return *this; } p4wHtml & p4wHtml::CacheControl(int secs) { // // Generate the Cache-Control string *this << "Cache-Control: max-age=" << secs << CRLF; return *this; } p4wHtml & p4wHtml::contentType( const char *type, int endHeader, const char *charset ) { // // Generate the content-type message *this << "Content-Type: "; *this << type; if( charset ) *this << "; " << "charset=" << charset; *this << " " << CRLF; if( endHeader ) *this << CRLF; return *this; } p4wHtml & p4wHtml::setCookie( const char *name, const char *value, int clear, int endHeader, int sessionOnly ) { // // Generate a cookie *this << "Set-Cookie: "; *this << COOKIEPREFIX << name << "=" << value; if (clear) *this << "; expires=Fri, 1-Dec-1999 23:59:59 GMT; path=/"; else if (sessionOnly) *this << "; path=/"; else { char time_buffer[255 + 1]; // Do our own strftime time_buffer[0] = '\0'; StrBuf time_format; time_format.Append( "%a, %d %b %Y %H:%M:%S" ); time_t day7; if (!strcmp(name, "Defaults") || !strcmp(name, "JobsDefs") || !strcmp(name, "ChgsDefs") || !strcmp(name, "States") || !strcmp(name, "Filters")) day7 = time(0) + (604800 * 522); // add 10 years (in seconds) else day7 = time(0) + 604800; // add one week (in seconds) strftime( time_buffer, sizeof( time_buffer ), time_format.Text(), gmtime( &day7 ) ); *this << "; expires="; *this << time_buffer; *this << " GMT; path=/"; } *this << " " << CRLF; if( endHeader ) *this << CRLF; return *this; } p4wHtml & p4wHtml::contentLength( int len ) { // // Generate the content-length directive *this << "Content-Length: "; *this << len << CRLF; *this << CRLF; return *this; } p4wHtml & p4wHtml::location( const char *newLocation ) { // // Generate the location directive to remap // to a new url *this << "Content-Length: 0" << CRLF; *this << "location: "; *this << newLocation << CRLF << CRLF; return *this; } p4wHtml & p4wHtml::beginHeader( const char *charset ) { // // Start the Header section *this << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML"; *this << " 4.0 Transitional//EN\"" << crlf; *this << "\"http://www.w3.org/TR/REC-html40/loose.dtd\">" << crlf; *this << "<Html>" << crlf; *this << "<Head>" << crlf; if( charset ) *this << "\n<meta http-equiv=\"content-type\" content=\"text/html; charset=\"" << charset << "\" />\n"; return *this; } p4wHtml & p4wHtml::title( const char *str ) { // // Generate the title *this << "<Title>" << p4wStrBuf().EscapeHTML( StrRef(str) ).Text() << "</Title>" << crlf; return *this; } p4wHtml & p4wHtml::styleSheet(p4wRequest *fRequest, int bNoJS) { AllCommands ac = fRequest->GetCmd(); Options *opts = fRequest->GetOpts(); if ((*opts)[ 'f' ]) fRequest->ProcessCustomization(); StrBuf visitedColor; const StrPtr *pgc = fRequest->GetStateArg( "pgc" ); visitedColor.Set( (pgc && *pgc == "y") ? "#861C8B" : "#0000CC" ); // // Generate the javascript for popup menus if needed const StrPtr *thx = fRequest->GetStateArg( "thx" ); if (thx) bNoJS = 1; if (!bNoJS) { *this << "<script type=\"text/javascript\"><!--" << crlf; if (fRequest->GetJavascriptMode() == 2 && fRequest->GetBrowserVersion() < 7.0) // MSIE 6 is brain dead *this << "var selfil" << crlf; *this << "var finm" << crlf; *this << "var args" << crlf; *this << "var mShw = 0" << crlf; *this << "var m" << crlf; *this << "function hideMenu() {" << crlf; *this << " if (m)" << crlf; *this << " m.style.display='none'" << crlf; if (fRequest->GetJavascriptMode() == 2 && fRequest->GetBrowserVersion() < 7.0) // MSIE 6 is brain dead { *this << " if (selfil)" << crlf; *this << " selfil.style.display='';" << crlf; *this << " selfil = 0;" << crlf; } *this << "}" << crlf; *this << "function formFieldClear( field, text )" << crlf; *this << "{" << crlf; *this << " if (field.value == text) {" << crlf; *this << " field.value = '';" << crlf; *this << " field.style.color = '#000000';" << crlf; *this << " }" << crlf; *this << "}" << crlf; *this << "function formFieldRestore( field, text )" << crlf; *this << "{" << crlf; *this << " if (field.value == '') {" << crlf; *this << " field.value = text;" << crlf; *this << " field.style.color = '#A0A0A0';" << crlf; *this << " }" << crlf; *this << "}" << crlf; int bGenMenu; switch(p4wAllCommands::GetTab( ac )) { case TT_FILE: case TT_SUBMITTED: case TT_BRANCH: case TT_LABEL: case TT_JOB: bGenMenu = 1; break; default: bGenMenu = 0; break; } if (bGenMenu); { *this << "function hideDiv(divname) {" << crlf; *this << " d = document.getElementById(divname)" << crlf; *this << " if (d)" << crlf; *this << " d.style.display='none'" << crlf; *this << "}" << crlf; *this << "function showDiv(divname, divloc) {" << crlf; *this << " d = document.getElementById(divname)" << crlf; *this << " if (!d)" << crlf; *this << " return" << crlf; *this << " i = document.getElementById(divloc)" << crlf; *this << " if (!i)" << crlf; *this << " return" << crlf; *this << " var t = i.offsetTop" << crlf; *this << " var p = i.offsetParent" << crlf; *this << " var l = i.offsetLeft" << crlf; *this << " var w = i.offsetWidth" << crlf; *this << " while (p.tagName != 'BODY') {" << crlf; *this << " t = t + p.offsetTop" << crlf; *this << " l = l + p.offsetLeft" << crlf; *this << " p = p.offsetParent" << crlf; *this << " }" << crlf; *this << " d.style.top = t + i.offsetHeight + 10" << crlf; *this << " d.style.left = l+(w/2)" << crlf; *this << " d.style.display=''" << crlf; *this << "}" << crlf; *this << "function validateFilelogForm() {" << crlf; *this << " var n = document.forms.filelogForm.revs;" << crlf; *this << " for(var i=0; i < n.length; i++) {" << crlf; *this << " if (n[i].checked) {" << crlf; *this << " if (document.forms.filelogForm.rev2.value == n[i].value) {" << crlf; *this << " alert('You attempted to compare a file with itself."; *this << " Before choosing the \"Diff vs. Selected Revision\" option, you must select"; *this << " one of the other revisions by clicking its radio button.')" << crlf; *this << " return false;" << crlf; *this << " }" << crlf; *this << " return true;" << crlf; *this << " }" << crlf; *this << " }" << crlf; *this << " alert('Before choosing the \"Diff vs. Selected Revision\" option,"; *this << " you must select a revision by clicking its radio button.');" << crlf; *this << " return false;" << crlf; *this << "}" << crlf; *this << "function showMenu(filename, id, menu, show, arg) {" << crlf; *this << " if (m)" << crlf; *this << " m.style.display='none'" << crlf; *this << " m = document.getElementById('menu_'+menu)" << crlf; *this << " if (!m)" << crlf; *this << " return" << crlf; *this << " finm = filename" << crlf; *this << " if (mShw && arg == '')" << crlf; *this << " args = '&mu='+mShw" << crlf; *this << " else" << crlf; *this << " args = arg" << crlf; *this << " var n" << crlf; // this is the bitfield ctr *this << " var o" << crlf; // this is the 'other' id's controlled by n *this << " var i" << crlf; *this << " var j = -1" << crlf; *this << " while (j < 31) {" << crlf; *this << " n = o = 1 << ++j" << crlf; *this << " while (1) {" << crlf; *this << " i = document.getElementById('id_mu'+menu+o)" << crlf; *this << " if (i) {" << crlf; *this << " if (show & n)" << crlf; *this << " {" << crlf; *this << " i.style.display=''" << crlf; *this << " h = document.getElementById('id_mu'+menu+o+'h')" << crlf; *this << " if (h)" << crlf; *this << " h.style.display='none'" << crlf; *this << " }" << crlf; *this << " else" << crlf; *this << " {" << crlf; *this << " i.style.display='none'" << crlf; *this << " }" << crlf; *this << " if (n < 4)" << crlf; *this << " break;" << crlf; *this << " o++" << crlf; // go check for more controlled by bit n *this << " }" << crlf; *this << " else" << crlf; *this << " break" << crlf; *this << " }" << crlf; *this << " }" << crlf; *this << " i = document.getElementById('id_'+id)" << crlf; *this << " var t = i.offsetTop" << crlf; *this << " var p = i.offsetParent" << crlf; *this << " var l = i.offsetLeft" << crlf; *this << " while (p.tagName != 'BODY') {" << crlf; *this << " t = t + p.offsetTop" << crlf; *this << " l = l + p.offsetLeft" << crlf; *this << " p = p.offsetParent" << crlf; *this << " }" << crlf; *this << " m.style.top = t + i.offsetHeight + 1" << crlf; if (fRequest->GetJavascriptMode() == 2 && fRequest->GetBrowserVersion() < 7.0) // MSIE 6 is brain dead *this << " msie6hack(t + i.offsetHeight + 1)" << crlf; *this << " m.style.left = l - 8" << crlf; *this << " m.style.display=''" << crlf; *this << "}" << crlf; *this << "function setmushow(show) {" << crlf; *this << " mShw = show" << crlf; *this << "}" << crlf; *this << "function runcmd(cmd) {" << crlf; *this << " var url = finm + \"?ac=\" + cmd + args;" << crlf; *this << " window.location = url;" << crlf; *this << "}" << crlf; *this << "function runurl(url) {" << crlf; *this << " window.location = url;" << crlf; *this << "}" << crlf; *this << "function runuXc(url, cmd) {" << crlf; *this << " var newurl = url + finm + cmd;" << crlf; *this << " window.location = newurl;" << crlf; *this << "}" << crlf; *this << "function promptuXc(str, url, cmd) {" << crlf; *this << " var val=prompt(str, '')" << crlf; *this << " if (val!=null && val!='')" << crlf; *this << " {" << crlf; *this << " var newurl = url + val" << crlf; *this << " runuXc(newurl, cmd)" << crlf; *this << " }" << crlf; *this << "}" << crlf; if (fRequest->GetJavascriptMode() == 2 && fRequest->GetBrowserVersion() < 7.0) // MSIE 6 is brain dead { *this << "function msie6hack(mtop) {" << crlf; *this << " selfil = document.getElementById('selectFilter')" << crlf; *this << " if (selfil) {" << crlf; *this << " var t = selfil.offsetTop" << crlf; *this << " var p = selfil.offsetParent" << crlf; *this << " var l = selfil.offsetLeft" << crlf; *this << " while (p.tagName != 'BODY') {" << crlf; *this << " t = t + p.offsetTop" << crlf; *this << " l = l + p.offsetLeft" << crlf; *this << " p = p.offsetParent" << crlf; *this << " }" << crlf; *this << " if (mtop < (t + selfil.offsetHeight + 1))" << crlf; *this << " selfil.style.display='none';" << crlf; *this << " else" << crlf; *this << " selfil = 0;" << crlf; *this << " }" << crlf; *this << "}" << crlf; } if ((ac == AC_CHGLISTANNOTATE) || (ac == AC_CHGLISTFULLANNOTATE)) { *this << "function showPopup(id, menu, show, arg) {" << crlf; *this << " if (m)" << crlf; *this << " m.style.display='none'" << crlf; *this << " m = document.getElementById('menu_'+menu)" << crlf; *this << " if (!m)" << crlf; *this << " return" << crlf; *this << " args = arg" << crlf; *this << " var i" << crlf; *this << " i = document.getElementById('id_'+id)" << crlf; *this << " var t = i.offsetTop" << crlf; *this << " var p = i.offsetParent" << crlf; *this << " var l = i.offsetLeft" << crlf; *this << " while (p.tagName != 'BODY') {" << crlf; *this << " t = t + p.offsetTop" << crlf; *this << " l = l + p.offsetLeft" << crlf; *this << " p = p.offsetParent" << crlf; *this << " }" << crlf; *this << " m.style.top = t - 8" << crlf; *this << " m.style.left = l + i.offsetWidth" << crlf; *this << " m.style.display=''" << crlf; *this << "}" << crlf; } *this << "function showhi(id)" << crlf; *this << "{" << crlf; *this << " document.getElementById(id + 'p').style.display='none'" << crlf; *this << " document.getElementById(id + 'h').style.display=''" << crlf; *this << "}" << crlf; *this << "function hidehi(id)" << crlf; *this << "{" << crlf; *this << " document.getElementById(id + 'p').style.display=''" << crlf; *this << " document.getElementById(id + 'h').style.display='none'" << crlf; *this << "}" << crlf; *this << "function check4ESC(e) {" << crlf; *this << " if (m) {" << crlf; *this << " var kC = (window.event) ? event.keyCode : e.keyCode;" << crlf; *this << " var Esc = (window.event) ? 27 : e.DOM_VK_ESCAPE" << crlf; // MSIE : Firefox *this << " if (kC==Esc) {" << crlf; *this << " m.style.display='none'" << crlf; *this << " m = 0" << crlf; *this << " }" << crlf; *this << " }" << crlf; *this << " return true;" << crlf; *this << "}" << crlf; *this << "document.onkeyup = check4ESC;" << crlf; } if (ac == AC_DIFFWVC || ac == AC_DIFFCVH || ac == AC_DIFFWVH || ac == AC_DIFFRVW || ac == AC_DIFF2 || ac == AC_DIFF21 || ac == AC_DIFF22) { *this << "var nDif=0;" << crlf; *this << "var mDif=0;" << crlf; *this << "function set_mDif(i)" << crlf; *this << "{" << crlf; *this << " mDif = i;" << crlf; *this << "}" << crlf; *this << "function scrollto(id)" << crlf; *this << "{" << crlf; *this << " if (id)" << crlf; *this << " {" << crlf; *this << " id.className = 'np';" << crlf; *this << " var y = 0;" << crlf; *this << " while (id != null) {" << crlf; *this << " y += id.offsetTop;" << crlf; *this << " id = id.offsetParent;" << crlf; *this << " }" << crlf; *this << " window.scrollTo(0, y-5);" << crlf; *this << " }" << crlf; *this << "}" << crlf; *this << "function showchunk(chk)" << crlf; *this << "{" << crlf; *this << " var id = document.getElementById('an' + nDif);" << crlf; *this << " if (id)" << crlf; *this << " id.className = '';" << crlf; *this << " nDif = chk;" << crlf; *this << " id = document.getElementById('an' + nDif);" << crlf; *this << " scrollto(id);" << crlf; *this << " return false;" << crlf; *this << "}" << crlf; *this << "function check4np(e) {" << crlf; *this << " var id = document.getElementById('nextprev');" << crlf; *this << " if (!id || !id.checked)" << crlf; *this << " return true;" << crlf; *this << " var kC;" << crlf; *this << " if (window.event && !window.event.ctrlKey)" << crlf; *this << " kC = window.event.keyCode;" << crlf; *this << " else" << crlf; *this << " kC = e.which;" << crlf; *this << " if (kC==78 || kC==110) {" << crlf; *this << " id = document.getElementById('an' + nDif);" << crlf; *this << " if (id)" << crlf; *this << " id.className = '';" << crlf; *this << " if (nDif < 0)" << crlf; *this << " nDif = 0;" << crlf; *this << " else if (nDif >= mDif)" << crlf; *this << " nDif = 0;" << crlf; *this << " id = document.getElementById('an' + ++nDif);" << crlf; *this << " scrollto(id);" << crlf; *this << " return false;" << crlf; *this << " }" << crlf; *this << " else if (kC==80 || kC==112) {" << crlf; *this << " id = document.getElementById('an' + nDif);" << crlf; *this << " if (id)" << crlf; *this << " id.className = '';" << crlf; *this << " if (nDif <= 1)" << crlf; *this << " nDif = mDif+1;" << crlf; *this << " else if (nDif > mDif)" << crlf; *this << " nDif = mDif;" << crlf; *this << " id = document.getElementById('an' + --nDif);" << crlf; *this << " scrollto(id);" << crlf; *this << " return false;" << crlf; *this << " }" << crlf; *this << " return true;" << crlf; *this << "}" << crlf; *this << "document.onkeypress = check4np;" << crlf; } *this << "//--></script>" << crlf; } // // Generate the stylesheet using p4web's customized settings *this << " <Style type=\"text/css\"><!--" << crlf; // // Link/href styles *this << " A { text-decoration: none }" << crlf; *this << " A:link { text-decoration: none; color: #0000CC;"; *this << " font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 12px }" << crlf; *this << " A:visited { text-decoration: none; color: "; *this << visitedColor; *this << "; font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 12px }" << crlf; *this << " A:hover { text-decoration: underline; color: #0000CC;"; *this << " font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 12px }" << crlf; *this << " A.status:link { text-decoration: none; color: #"; const StrPtr *ptr = fRequest->GetCustText(); if (ptr && ptr->Length()) *this << ptr->Text(); else *this << "FFFFFF"; *this << "; font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 11px }" << crlf; *this << " A.status:visited { text-decoration: none; color: #"; ptr = fRequest->GetCustText(); if (ptr && ptr->Length()) *this << ptr->Text(); else *this << "FFFFFF"; *this << "; font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 11px }" << crlf; *this << " A.status:hover { text-decoration: underline; color: #"; ptr = fRequest->GetCustText(); if (ptr && ptr->Length()) *this << ptr->Text(); else *this << "FFFFFF"; *this << " font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 11px }" << crlf; *this << " A.nav_link:link { text-decoration: none; color: #0000CC;"; *this << " font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 11px }" << crlf; *this << " A.nav_link:visited { text-decoration: none; color: "; *this << visitedColor; *this << "; font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 11px }" << crlf; *this << " A.nav_link:hover { text-decoration: underline; color: #0000CC;"; *this << " font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 11px }" << crlf; *this << " A.tab:link { text-decoration: none; color: #000000;"; *this << " font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 11px; font-weight: bold }" << crlf; *this << " A.tab:visited { text-decoration: none; color: #000000;"; *this << " font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 11px; font-weight: bold }" << crlf; *this << " A.tab:hover { text-decoration: underline; color: #000000;"; *this << " font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 11px; font-weight: bold }" << crlf; *this << " A.path:link { text-decoration: none; color: #0000CC;"; *this << " font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 14px; font-weight: bold }" << crlf; *this << " A.path:visited { text-decoration: none; color: "; *this << visitedColor; *this << "; font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 14px; font-weight: bold }" << crlf; *this << " A.path:hover { text-decoration: underline; color: #0000CC;"; *this << " font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 14px; font-weight: bold }" << crlf; *this << " A.remote:link { text-decoration: none; color: #0000CC;"; *this << " font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 10px; font-weight: bold }" << crlf; *this << " A.remote:visited { text-decoration: none; color: "; *this << visitedColor; *this << "; font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 10px; font-weight: bold }" << crlf; *this << " A.remote:hover { text-decoration: underline; color: #0000CC;"; *this << " font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 10px; font-weight: bold }" << crlf; *this << " A.file:link { text-decoration: none; color: #0000CC;"; *this << " font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 12px; font-weight: bold }" << crlf; *this << " A.file:visited { text-decoration: none; color: "; *this << visitedColor; *this << "; font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 12px; font-weight: bold }" << crlf; *this << " A.file:hover { text-decoration: underline; color: #0000CC;"; *this << " font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 12px; font-weight: bold }" << crlf; *this << " A.bigger:link, A.bigger:visited { text-decoration: none"; *this << " color: #0000FF;"; *this << " font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 14px }" << crlf; *this << " A.fixed:link { text-decoration: none; color: #0000CC;"; *this << " font-family: monospace,verdana,arial,helvetica,sans-serif;"; *this << " font-size: 12px; font-weight: normal }"; *this << crlf; *this << " A.fixed:visited { text-decoration: none; color: "; *this << visitedColor; *this << "; font-family: monospace,verdana,arial,helvetica,sans-serif;"; *this << " font-size: 12px; font-weight: normal }"; *this << crlf; *this << " A.fixed:hover { text-decoration: underline; color: #0000CC;"; *this << " font-family: monospace,verdana,arial,helvetica,sans-serif;"; *this << " font-size: 12px; font-weight: normal }"; *this << crlf; // // Table styles *this << " TD { font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 12px; font-weight: normal; color: #000000 }"; *this << crlf; *this << " TH { font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 11px; font-weight: bold; color: #000000 }"; *this << crlf; *this << " TD.recent_activity { font-family: verdana,arial,helvetica,"; *this << "sans-serif; font-size: 11px; padding-left: 3px;"; *this << " padding-right: 3px; padding-top: 3px; padding-bottom: 3px }"; *this << crlf; // // List type styles *this << " UL.none { list-style-type: none }" << crlf; *this << " DT { font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 12px; font-weight: bold; color: #000000 }"; *this << crlf; *this << " DD { font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 12px; font-weight: normal; color: #000000 }"; *this << crlf; // Top Header *this << " table.fHeader { border: 0px; width: 100%; background: #"; ptr = fRequest->GetCustBackground(); if (ptr && ptr->Length()) *this << ptr->Text() << " }" << crlf; else *this << "115577 url(/headerBkgrndIcon?ac=20) repeat-x top left;}" << crlf; *this << " .logo {padding: 4px 15px 7px 7px; width: 114px;}" << crlf; // Tabs *this << " .tabsspr { background: #c4c3c3 url(/tabBackgroundIcon?ac=20) repeat-x top left;"; *this << " border-left: 1px solid #eeeeee; padding: 2px 0px 2px 0px; }" << crlf; *this << " .tabs { background: #c4c3c3 url(/tabBackgroundIcon?ac=20) repeat-x top left; border-right: "; if( fRequest->GetJavascriptMode() == 2 ) // IE? *this << "3"; else *this << "1"; *this << "px solid #7f7f7f; border-left: 1px solid #eeeeee; padding: 2px 0px 2px 0px; }" << crlf; *this << " td.tabs:hover," << crlf; *this << " .actab { background: #eeeeee url(/activeTabBackgroundIcon?ac=20) repeat-x top left; border-right: "; if( fRequest->GetJavascriptMode() == 2 ) // IE? *this << "3"; else *this << "1"; *this << "px solid #7f7f7f; border-left: 1px solid #eeeeee; padding: 2px 0px 2px 0px; }" << crlf; if( fRequest->GetJavascriptMode() == 2 && fRequest->GetBrowserVersion() < 7.0 ) // IE 6 or earlier? { *this << " .tabs a:hover { background: #eeeeee url(/activeTabBackgroundIcon?ac=20) repeat-x top left;"; *this << " border-left: 2px solid #eeeeee; padding: 2px 10px 2px 0px; }" << crlf; } *this << " .tabs a," << crlf; *this << " .actab a { padding: 1px 10px 1px 2px; }" << crlf; // Font styles *this << " .fSmall { font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 12px }" << crlf; *this << " .fSmaller { font-family: verdana,arial,helvetica,"; *this << "sans-serif; font-size: 10px }" << crlf; *this << " .fNormal { font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 14px }" << crlf; // // Set the default font for the page // *this << " BODY { font-family: verdana,arial,helvetica,sans-serif;"; // *this << " font-size: 14px }" << crlf; // // Spacing controls *this << " .doublespace { font-family: verdana,arial,helvetica,"; *this << "sans-serif; font-size: 14px; font-weight: normal;"; *this << " line-height: 180% }" << crlf; // // Customized styles *this << " .statusLabel { font-family: verdana,arial,helvetica,"; *this << "sans-serif; font-size: 10px; font-weight: bold; color: #"; ptr = fRequest->GetCustLabel(); if (ptr && ptr->Length()) *this << ptr->Text(); else *this << "FFCC66"; *this << "; padding: 4px 5px 0px 0px;}" << crlf; *this << " .statusPath { font-family: verdana,arial,helvetica,"; *this << "sans-serif; font-size: 10px; font-weight: bold; color: #"; ptr = fRequest->GetCustLabel(); if (ptr && ptr->Length()) *this << ptr->Text(); else *this << "FFCC66"; *this << "; padding: 0px 5px 0px 0px; }" << crlf; *this << " .pathField," << crlf; *this << " .connectionField," << crlf; *this << " .status { font-family: verdana,arial,helvetica,"; *this << "sans-serif; font-size: 11px; color: #"; ptr = fRequest->GetCustText(); if (ptr && ptr->Length()) *this << ptr->Text() << " }" << crlf; else *this << "FFFFFF }" << crlf; *this << " .pathField { padding: 0px 0px 5px 0px; white-space: nowrap; }" << crlf; *this << " .connectionField { padding: 4px 60px 0px 0px;}" << crlf; *this << " .tab { font-family: verdana,arial,helvetica,"; *this << "sans-serif; color: #000000; font-size: 11px;"; *this << " font-weight: bold }" << crlf; *this << " .version { font-family: verdana,arial,helvetica,"; *this << "sans-serif; font-size: 10px; color: #999999 }" << crlf; *this << " .remote { font-family: verdana,arial,helvetica,"; *this << "sans-serif; font-size: 10px; color: #996d02 }" << crlf; *this << " .title { font-family: verdana,arial,helvetica,"; *this << "sans-serif; font-size: 18px; font-weight: bold; color: #"; ptr = fRequest->GetCustTitle(); if (ptr && ptr->Length()) *this << ptr->Text(); else *this << "000000"; //"115577"; *this << " }" << crlf; *this << " .copyright { font-family: verdana,arial,helvetica,"; *this << "sans-serif; font-size: 11px; font-style: italic;"; *this << " color: #999999 }" << crlf; *this << " .path { font-family: verdana,arial,helvetica,"; *this << "sans-serif; font-size: 14px; font-weight: bold; vertical-align: top }" << crlf; *this << " .label { font-family: verdana,arial,helvetica,"; *this << "sans-serif; font-size: 12px; font-weight: bold;"; *this << " color: #000000 }" << crlf; *this << " .normal { font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 12px; font-weight: normal; color: #000000 }"; *this << crlf; *this << " .fixed { font-family: monospace,verdana,arial,helvetica,sans-serif;"; *this << " font-size: 12px; font-weight: normal; color: #000000 }"; *this << crlf; *this << " .subtitle { font-family: verdana,arial,helvetica,sans-serif;"; *this << " font-size: 14px; font-weight: bold; color: #000000;"; *this << " text-align: left }"; *this << crlf; *this << " .filestat { font-family: verdana,arial,helvetica,sans-serif;", *this << " font-size: 10px; color: #999999; }"; *this << crlf; *this << " .filestat A:link," << crlf; *this << " .filestat A:visited," << crlf; *this << " .filestat A:hover { text-decoration: none; }", *this << crlf; // *this << " .lineno { text-align: right; text-decoration: none; font-family: monospace;", // *this << " font-size: 10px; color: #999999; }"; // *this << crlf; *this << " .pre { text-decoration: none; font-family: monospace;", *this << " font-size: 12px; font-weight: normal; color: #000000 }"; *this << crlf; *this << " .pre A:link { text-decoration: none; font-family: monospace;", *this << " font-size: 12px; font-weight: normal; color: #000000 }"; *this << crlf; *this << " .pre A:visited { text-decoration: none; font-family: monospace;", *this << " font-size: 12px; font-weight: normal; color: #000000 }"; *this << crlf; *this << " .pre A:hover { text-decoration: none; font-family: monospace;", *this << " font-size: 12px; font-weight: normal; color: #000000 }"; *this << crlf; *this << " TR.b td {margin: 0; border-style: solid; border-width: 0px;", *this << " border-bottom: 1px solid #E8EAEC;}"; *this << crlf; // // CSS for per-file-menus, thumbnails and details *this << " .ttip { border-style: solid; border-color: #000000; border-width: 1px;", *this << " background-color: #FFFFF0; padding: 5; position: absolute;", *this << " font-family: arial,sans-serif; font-size: 12px; }"; *this << crlf; *this << " .mu { border-style: solid; border-color: #C0C0C0; border-width: 2px;", *this << " background-color: #E6E6E6; padding: 0; position: absolute; }"; *this << crlf; if (fRequest->GetJavascriptMode() == 2 && fRequest->GetBrowserVersion() < 7.0) // MSIE 6 { *this << " .mu a:hover { text-decoration: none; background-color: #008; color: #ffffff }"; *this << crlf; } else { *this << " .mu div:hover { background-color: #008; }"; *this << crlf; *this << " .mu div:hover a { text-decoration: none; color: #ffffff }"; *this << crlf; } *this << " .mu div {padding: 1 0 1 0;}"; *this << crlf; *this << " .mu div div {padding: 0;}"; *this << crlf; *this << " .muaro { background-image: url(/menuarrowIcon?ac=20);"; *this << " background-repeat: no-repeat; background-position: center left; }"; *this << crlf; *this << " .muaro A:hover { background-image: url(/menuarrowhoverIcon?ac=20);"; *this << " background-repeat: no-repeat; background-position: center left; text-decoration: none; }"; *this << crlf; #if 0 *this << " .filestatmuaro," << crlf; *this << " .filestatmuaro A:link," << crlf; *this << " .filestatmuaro A:visited { font-family: verdana,arial,helvetica,sans-serif;", *this << " font-size: 10px; color: #999999; background-image: url(/menuarrowIcon?ac=20);"; *this << " background-repeat: no-repeat; background-position: center right; }"; *this << crlf; *this << " .filestatmuaro A:hover { text-decoration: none; background-image: url(/menuarrowhoverIcon?ac=20);"; *this << " background-repeat: no-repeat; background-position: center right; text-decoration: none; }"; *this << crlf; #endif *this << " TD.thumbnail_pane { border-style: solid; border-width: 1px; "; *this << "border-color: #7F7F7F }"; *this << crlf; if (ac == AC_CONFIGURATION) { *this << " TD.radio_box { border-style: solid; border-width: 1px; "; *this << "border-color: #c5c5c5; padding: 5px;}"; *this << crlf; } *this << " TR.list_row td { padding: 1px 0px; }"; *this << crlf; *this << " TR.pathbr_row td { padding: 2px 0px;}"; *this << crlf; *this << " div.alt_row," << crlf; *this << " TR.alt_row { background: #f1f5fa;}"; *this << crlf; // *this << " div.alt_div { background: #f1f5fa; border-top: 1px solid #e8eaec; border-bottom: 1px solid #e8eaec; margin: -1px 0 -1px 0; }"; // *this << crlf; if (!bNoJS) { // // Menu styles *this << " div.menu { position: relative; cursor: default}"; *this << crlf; *this << " div.menu ul { visibility: hidden; position: absolute; top: -20px; left: 90%; margin: 0; padding: 0 }"; *this << crlf; *this << " div.menu:hover > ul { visibility: visible}"; *this << crlf; *this << " .menu ul li { display: list-item; list-style: url(/notselectedIcon?ac=20) none inside; padding: 0.2em 4 0 4; white-space: nowrap}"; *this << crlf; *this << " .menu ul li:hover { background-color: #008}"; *this << crlf; *this << " .menu ul li.divider { list-style: none outside; border-color: #7F7F7F; border-width: 1px 0px 0px 0px; border-style: solid; padding: 0 0 0 0; margin: 2px 0 0 0; line-height: 1px; height: 1px; }"; *this << crlf; *this << " .menu ul li.checkmark { list-style: url(/checkmarkIcon?ac=20) disc inside; }"; *this << crlf; *this << " .menu ul li.checkmark:hover { list-style: url(/checkmarkhighlightedIcon?ac=20) disc inside; }"; *this << crlf; *this << " .menu ul li.bullet { list-style: url(/bulletIcon?ac=20) disc inside; }"; *this << crlf; *this << " .menu ul li.bullet:hover { list-style: url(/bullethighlightedIcon?ac=20) disc inside; }"; *this << crlf; *this << " .menu ul li a:link,"; *this << crlf; *this << " .menu ul li a:visited { text-decoration: none; color: #0000CC; }"; *this << crlf; *this << " .menu ul li:hover a:link,"; *this << crlf; *this << " .menu ul li:hover a:visited { text-decoration: none; color: #ffffff; }"; *this << crlf; #if 0 *this << " .menu ul li ul { visibility: hidden; position: absolute; top: 20%; left: 90%; margin: 0; padding: 0 }"; *this << crlf; *this << " .menu ul li:hover ul { visibility: visible}"; *this << crlf; *this << " .menu ul li:hover ul li a,"; *this << crlf; *this << " .menu ul li:hover ul li a:visited { text-decoration: none; color: #0000CC; white-space: nowrap}"; *this << crlf; *this << " .menu ul li:hover ul li:hover a,"; *this << crlf; *this << " .menu ul li:hover ul li:hover a:visited { text-decoration: none; color: #ffffff; }"; *this << crlf; #endif // // Path browser thumbnail table const StrPtr *thw = fRequest->GetStateArg( "thw" ); if (thw && (ac == AC_FILESMATCHING || ac == AC_PATHBROWSER)) { const StrPtr *thz = fRequest->GetStateArg( "thz" ); const StrPtr *thb = fRequest->GetStateArg( "thb" ); int i; int extra = thb ? 2 : 0; StrNum nbr; if ( !thz ) nbr.Set(i = 162 + extra); else if ( *thz == "m" ) nbr.Set(i = 122 + extra); else if ( *thz == "s" ) nbr.Set(i = 82 + extra); *this << " DIV.thumb { background: #ffffff; width: "; *this << nbr.Text(); *this << "px; line-height: 1; float: left; margin: 5px; text-align: center; }"; *this << crlf; *this << " P.img { margin-top: 0; margin-bottom: 0; height: "; nbr.Set(i-2); *this << nbr.Text(); *this << "px; }"; *this << crlf; *this << " P.txt { margin-top: 5px; margin-bottom: 1px; }"; *this << crlf; *this << " IMG.minwidth { width: "; nbr.Set(fRequest->GetThumbnailCols() * (i+10)); *this << nbr.Text(); *this << "px; }"; *this << crlf; } } switch(ac) { case AC_BROWSEFILE: *this << " table.rev_history { width: 100%; border: 1px solid #7F7F7F; background: #ffffff;}"; *this << crlf; *this << " table.rev_history th {padding: 2px 8px; background: #EEEEEE; text-align: left;}"; *this << crlf; *this << " table.rev_history td {margin: 0; padding: 3px 8px; vertical-align: top;}"; *this << crlf; *this << " table.rev_history td.top_line {margin: 0; border-top: 1px solid #d1d5da; padding: 3px 8px; vertical-align: top;}"; *this << crlf; *this << " table.rev_history tr.top_row td {border-top: 1px solid #7F7F7F;}"; *this << crlf; *this << " table.rev_history tr.alt_row {background: #f1f5fa;}"; *this << crlf; break; case AC_DIFFWVC: case AC_DIFFCVH: case AC_DIFFWVH: case AC_DIFFRVW: case AC_DIFF2: case AC_DIFF21: case AC_DIFF22: if( fRequest->GetJavascriptMode() == 2) // MSIE makes Curier New too small to read *this << " table.f td{ font-family: courier,monospace,verdana,"; else // other borwsers can resize Courier New properly *this << " table.f td{ font-family: courier new,monospace,verdana,"; *this << "arial,helvetica,sans-serif; font-size: 80%; "; *this << "font-weight: normal; color: #000000 }" << crlf; *this << " th.diffpath{ font-family: verdana,arial,helvetica,sans-serif; font-size: 60%; "; *this << "font-weight: bold; color: #000000 }" << crlf; *this << " td.n { background-color: #E0E0E0; text-align: right; }" << crlf; *this << " td.r { background-color: #FFD0D0; color: #000000; text-align: right; }" << crlf; *this << " td.g { background-color: #C0FFC0; color: #000000; text-align: right; }" << crlf; *this << " td.b { background-color: #E0E0FF; color: #000000; text-align: right; }" << crlf; *this << " td.rx { background-color: #FFD0D0; color: #000000; }" << crlf; *this << " td.gx { background-color: #C0FFC0; color: #000000; }" << crlf; *this << " td.bx { background-color: #E0E0FF; color: #000000; }" << crlf; *this << " .cc { font-family: arial,helvetica,verdana,sans-serif; "; *this << "font-size: 8px; background-color: #FFFFFF; color: #FFFFFF; }" << crlf; *this << " .np { border-style: solid; border-color: #808080; border-width: 2px; }" << crlf; *this << " .np td { border-style: solid; border-color: #FFFFFF; border-width: 0px; }" << crlf; // this bit of silliness fixes a Safari refresh bug(!) *this << " .np td.raro{ background-color: #FFA6A6; }" << crlf; *this << " .np td.garo{ background-color: #80FF80; }" << crlf; *this << " .np td.baro{ background-color: #B3B2FF; }" << crlf; break; case AC_DIFF2DIRSOUTPUT: *this << " .l, table.f td{ background-color: #F5F5F5 }" << crlf; *this << " .r, table.f td.r { background-color: #FFD0D0; color: #000000; }" << crlf; *this << " .g, table.f td.g { background-color: #C0FFC0; color: #000000; }" << crlf; *this << " .d, table.f td.d { background-color: #E7E7E7; color: #000000; }" << crlf; *this << " .w, table.f td.w { background-color: #FFFFFF; color: #000000; }" << crlf; break; default: break; } int i = atoi(fRequest->GetShowHide().Text()); switch (ac) { case AC_PATHBROWSER: case AC_FILESMATCHING: if (i & SH_FILES) styleSheetShowHide(1); else styleSheetShowHide(0); break; case AC_SUBMITTEDCHANGELISTS: case AC_SUBMITTEDCHANGELISTSFILE: case AC_FIXSUBMITTED: if (i & SH_SUBMITTED) styleSheetShowHide(1); else styleSheetShowHide(0); break; case AC_BRANCHES: if (i & SH_BRANCHES) styleSheetShowHide(1); else styleSheetShowHide(0); break; case AC_LABELS: case AC_LABELSPATH: if (i & SH_LABELS) styleSheetShowHide(1); else styleSheetShowHide(0); break; case AC_CLIENTS: if (i & SH_CLIENTS) styleSheetShowHide(1); else styleSheetShowHide(0); break; case AC_USERS: if (i & SH_USERS) styleSheetShowHide(1); else styleSheetShowHide(0); break; case AC_JOBS: if (i & SH_JOBS) styleSheetShowHide(1); else styleSheetShowHide(0); break; default: switch(fRequest->GetLastReturnType()) { case AC_BROWSEFILE: styleSheetShowHide(0, 3, 1); break; default: break; } } i = atoi(fRequest->GetShowHide().Text()); if (i & SH_P4CMDS) styleSheetShowHide(1,0,0,9); else styleSheetShowHide(0,0,0,9); *this << " --></Style>" << crlf; return *this; } p4wHtml & p4wHtml::styleSheetShowHide(int hide, int extraSame, int extraOpps, int ctr) { int i; char buf[8]; if (!hide) { *this << " div#showhideBlock"; if (ctr) *this << ctr; *this << " { display: block; }" << crlf; *this << " div#hideBlockIcon"; if (ctr) *this << ctr; *this << " { display: inline; }" << crlf; *this << " div#showBlockIcon"; if (ctr) *this << ctr; *this << " { display: none; }" << crlf; for (i = 0; ++i <= extraSame; ) { sprintf(buf, "%d", i); *this << " div#showhideInline" << buf; if (ctr) *this << ctr; *this << " { display: inline; }" << crlf; } for (i = 0; ++i <= extraOpps; ) { sprintf(buf, "%d", i+extraSame); *this << " div#showhideInline" << buf; if (ctr) *this << ctr; *this << " { display: none; }" << crlf; } } else { *this << " div#showhideBlock"; if (ctr) *this << ctr; *this << " { display: none; }" << crlf; *this << " div#hideBlockIcon"; if (ctr) *this << ctr; *this << " { display: none; }" << crlf; *this << " div#showBlockIcon"; if (ctr) *this << ctr; *this << " { display: inline; }" << crlf; for (i = 0; ++i <= extraSame; ) { sprintf(buf, "%d", i); *this << " div#showhideInline" << buf; if (ctr) *this << ctr; *this << " { display: none; }" << crlf; } for (i = 0; ++i <= extraOpps; ) { sprintf(buf, "%d", i+extraSame); *this << " div#showhideInline" << buf; if (ctr) *this << ctr; *this << " { display: inline; }" << crlf; } } return *this; } p4wHtml & p4wHtml::base( const char *type, int isHTTPS ) { // // Generate the BASE directive *this << " <Base href=\""; if (isHTTPS && !strncmp(type, "http:", 5) ) { *this << "https"; *this << type +4; } else *this << type; if (*type != '/' && *(type + strlen(type) - 1) != '/') // hack for Firefox <base> handling *this << "/"; // gets cleaned up in p4wURL::ParseURL() *this << "\">" << crlf; return *this; } p4wHtml & p4wHtml::rssHeaderLink( const char *title, const char *href ) { // // Generate an RSS link in the header section *this << " <link rel=\"alternate\" type=\"application/rss+xml\" title=\""; *this << p4wStrBuf().EscapeHTML( StrRef(title) ).Text() << "\" href=\"" << href << "\">" << crlf; return *this; } p4wHtml & p4wHtml::endHeader( const char *faviconhttp, int isHTTPS ) { // // End the header section if (faviconhttp) { *this << "<link rel=\"shortcut icon\" href=\""; if (isHTTPS) *this << "https://"; else *this << "http://"; *this << faviconhttp; *this << "/favicon.ico\" type=\"image/x-icon\">" << crlf; } *this << "<meta name=\"viewport\" content=\"width=760, initial-scale=0.4, minimum-scale=0.4\" />" << crlf; *this << "</Head>" << crlf; return *this; } p4wHtml & p4wHtml::beginBody( const char *color, const char *link, const char *vlink, const char *leftmar, const char *topmar, const char *marwidth, const char *marheight, const char *jshandler, const char *jsaction ) { // // Start the body section of the page *this << "<Body"; if( color ) *this << " bgcolor=\"" << color << "\""; if( link ) *this << " link=\"" << link << "\""; if( vlink ) *this << " vlink=\"" << vlink << "\""; if( leftmar ) *this << " leftmargin=\"" << leftmar << "\""; if( topmar ) *this << " topmargin=\"" << topmar << "\""; if( marwidth ) *this << " marginwidth=\"" << marwidth << "\""; if( marheight ) *this << " marginheight=\"" << marheight << "\""; if ( jshandler && jsaction ) *this << " " << jshandler << "=\"" << jsaction << "\""; *this << ">"; *this << crlf; return *this; } p4wHtml & p4wHtml::endBody() { // // End the page *this << "</Body>" << crlf; *this << "</Html>" << crlf; return *this; } p4wHtml & p4wHtml::header( const char *txt ) { // // Generate an H1 header *this << "<h1>" << txt << "</h1>" << crlf; return *this; } p4wHtml & p4wHtml::comment( const char *txt ) { // // Write the text out as an html comment *this << "<!-- " << txt << " -->" << crlf; return *this; } p4wHtml & p4wHtml::paragraph() { // // Start new paragraph *this << "<p>" << crlf; return *this; } p4wHtml & p4wHtml::hline( const char *width, const char *size ) { // // horizontal line *this << "<hr"; if( width ) *this << " width=" << "\"" << width << "\""; if( size ) *this << " size=" << "\"" << size << "\""; *this << ">" << crlf; return *this; } p4wHtml & p4wHtml::linebreak() { // // Generate a line break *this << "<br>" << crlf; return *this; } p4wHtml & p4wHtml::beginNobreak() { // // Start a section where line breaks are prohibited *this << "<nobr>"; return *this; } p4wHtml & p4wHtml::endNobreak() { // // End a text section where line breaks were prohibited *this << "</nobr>"; *this << crlf; return *this; } p4wHtml & p4wHtml::label( const char *str, const char *labelID, const char *face, const char *size, const char *color ) { char *p = strstr((char *)str, "</a>"); if (!p) return text( str, face, size, color, labelID ); p = strstr((char *)str, "<a "); if (!p) return text( str, face, size, color, 0 ); char *q; int suppressCRLF = fSuppressCRLF; StrBuf beginning; beginning.Set(str); if (p != str && strncmp(str, "<img", 4)) { q = beginning.Text() + (p - str); *q = '\0'; beginning.SetLength(); fSuppressCRLF = 1; text( beginning.Text(), face, size, color, labelID ); fSuppressCRLF = suppressCRLF; beginning.Set(p); } for (q = p+4; p = strstr(q, "</a>"); ) q = p+4; if (*q) { p = beginning.Text() + (q - str); *p = '\0'; beginning.SetLength(); fSuppressCRLF = 1; } text( beginning.Text(), face, size, color, 0 ); if (*q) { fSuppressCRLF = suppressCRLF; text( q, face, size, color, labelID ); } return *this; } p4wHtml & p4wHtml::text( const char *str, const char *face, const char *size, const char *color, const char *labelID ) { // // Generate a text string with optional face, size & color if( face ) *this << "<" << face << ">"; if( size || color ) { *this << "<Font"; if( size ) *this << " size=\"" << size << "\""; if( color ) *this << " color=\"" << color << "\""; *this << ">"; if( !fSuppressCRLF ) *this << crlf; } if( labelID ) *this << "<label for=\"" << labelID << "\">"; *this << str; if( labelID ) *this << "</label>"; if( !fSuppressCRLF ) *this << crlf; if( size || color ) { *this << "</Font>"; if( !fSuppressCRLF ) *this << crlf; } if( face ) { *this << "</" << face << ">"; if( !fSuppressCRLF ) *this << crlf; } return *this; } p4wHtml & p4wHtml::beginLink( const char *url, const char *name, const char *cls, const char *mouseover, const char *title, const char *id, const char *jshandler, const char *jsaction ) { // // Generate a hyperlink *this << "<a"; if( url ) *this << " href=\"" << url << "\""; if( name ) *this << " name=\"" << name << "\""; if( cls ) *this << " class=\"" << cls << "\""; if( mouseover ) *this << " onmouseover=\"" << mouseover << "\""; if( title ) *this << " title=\"" << title << "\""; if( id ) *this << " id=\"" << id << "\""; if ( jshandler && jsaction ) *this << " " << jshandler << "=\"" << jsaction << "\""; *this << ">"; return *this; } p4wHtml & p4wHtml::endLink() { // // End the hyperlink directive *this << "</a>"; if( !fSuppressCRLF ) *this << crlf; return *this; } p4wHtml & p4wHtml::icon( const char *iconName, const char *height, const char *width, const char *alt, int suppressBorder, const char *vspace, const char *hspace, const char *align, const char *cls, const char *id ) { // // Construct the named icon using specified characteristics *this << "<img src=\""; *this << iconName << "\""; if (width) *this << " height=\"" << height << "\" width=\"" << width; else if (height) *this << " height=\"" << height; if( suppressBorder) *this << "\" border=\"0"; *this << "\" alt=\"" << alt; *this << "\" title=\"" << alt; if( vspace ) *this << "\" vspace=\"" << vspace; if( hspace ) *this << "\" hspace=\"" << hspace; if( align ) *this << "\" align=\"" << align; if( cls ) *this << "\" class=\"" << cls; if( id ) *this << "\" id=\"" << id; *this << "\">"; return *this; } p4wHtml & p4wHtml::beginUnformatted( const char *cls, const char *name ) { // // Start a section of unformatted text (<pre>) *this << "<pre"; if( cls ) *this << " class=\"" << cls << "\""; if( name ) *this << " name=\"" << name << "\""; *this << ">" << crlf; return *this; } p4wHtml & p4wHtml::endUnformatted() { // // End an unformatted text section (</pre>) *this << "</pre>" << crlf; return *this; } p4wHtml & p4wHtml::font( const char *size, const char *color, const char *cls ) { // // Generate a font command *this << "<font"; if( size ) *this << " size=\"" << size << "\""; if( color ) *this << " color=\"" << color << "\""; if( cls ) *this << " class=\"" << cls << "\""; *this << ">"; if( !fSuppressCRLF ) *this << crlf; return *this; } p4wHtml & p4wHtml::face( const char *type ) { // // Generate a command that changes the font face *this << "<" << type << ">" << crlf; return *this; } p4wHtml & p4wHtml::endFace( const char *type ) { // // Generate the command to end the font face *this << "</" << type << ">" << crlf; return *this; } p4wHtml & p4wHtml::endFont() { // // End a font directive *this << "</font>"; if( !fSuppressCRLF ) *this << crlf; return *this; } p4wHtml & p4wHtml::beginSpan( const char * cls, const char *style, const char *id ) { // // Begin a span directive *this << "<span"; if( cls ) *this << " class=\"" << cls << "\""; if( style ) *this << " style=\"" << style << "\""; if( id ) *this << " id=\"" << id << "\""; *this << ">"; return *this; } p4wHtml & p4wHtml::endSpan() { // // End a span directive *this << "</span>"; return *this; } p4wHtml & p4wHtml::beginDiv( const char * id, const char * cls, const char *style ) { // // Begin a div directive *this << "<div"; if( id ) *this << " id=\"" << id << "\""; if( cls ) *this << " class=\"" << cls << "\""; if( style ) *this << " style=\"" << style << "\""; *this << ">"; return *this; } p4wHtml & p4wHtml::endDiv() { // // End a div directive *this << "</div>"; return *this; } p4wHtml & p4wHtml::beginBlockquote() { // // Begin a blockquote directive *this << "<blockquote>"; return *this; } p4wHtml & p4wHtml::endBlockquote() { // // End a blockquote directive *this << "</blockquote>"; return *this; } p4wHtml & p4wHtml::beginDList() { // // Start a definition list *this << "<dl>" << crlf; return *this; } p4wHtml & p4wHtml::endDList() { // // End a definition list *this << "</dl>" << crlf; return *this; } p4wHtml & p4wHtml::dListTag() { // // Generate the definition list tag *this << "<dt>" << crlf; return *this; } p4wHtml & p4wHtml::dListVal() { // // Generate the definition list value *this << "<dd>" << crlf; return *this; } p4wHtml & p4wHtml::beginUList( const char *cls ) { // // Start an unordered list *this << "<ul"; if( cls ) *this << " class=" << cls; *this << ">" << crlf; return *this; } p4wHtml & p4wHtml::endUList() { // // End a definition list *this << "</ul>" << crlf; return *this; } p4wHtml & p4wHtml::listVal() { // // Generate a list value *this << "<li>" << crlf; return *this; } p4wHtml & p4wHtml::endListVal() { // // End a list value *this << "</li>" << crlf; return *this; } p4wHtml & p4wHtml::beginOList() { // // Start an ordered list *this << "<ol>" << crlf; return *this; } p4wHtml & p4wHtml::endOList() { // // End an ordered list *this << "</ol>" << crlf; return *this; } p4wHtml & p4wHtml::beginTable( const char *border, const char *width, const char *pad, const char *spacing, const char *bgcolor, const char *cls ) { // // Generate a table directive with optional border, width, // cellpadding & cellspacing *this << "<Table"; if( border ) *this << " Border=\"" << border << "\""; if( width ) *this << " Width=\"" << width << "\""; if( pad ) *this << " Cellpadding=\"" << pad << "\""; if( spacing ) *this << " Cellspacing=\"" << spacing << "\""; if( bgcolor ) *this << " Bgcolor=\"" << bgcolor << "\""; if( cls ) *this << " class=\"" << cls << "\""; *this << ">" << crlf; return *this; } p4wHtml & p4wHtml::endTable() { // // End the html table *this << "</Table>" << crlf; return *this; } p4wHtml & p4wHtml::beginTRow( const char *valign, const char *align, const char *bgcolor, const char *cls ) { // // Begin table row *this << "<tr"; if( valign ) *this << " valign=\"" << valign << "\""; if( align ) *this << " align=\"" << align << "\""; if( bgcolor ) *this << " bgcolor=\"" << bgcolor << "\""; if( cls ) *this << " class=\"" << cls << "\""; *this << ">" << crlf; return *this; } p4wHtml & p4wHtml::endTRow() { // // End table row *this << "</tr>" << crlf; return *this; } p4wHtml & p4wHtml::beginCol( const char *valign, const char *align, const char *colspan, const char *rowspan, const char *bgcolor, const char *width, const char *height, int nowrap, const char *cls, const char *style ) { // // Start a column of a table with optional valign, align, // colspan, rowspan, bgcolor & nowrap parameters *this << "<td"; if( valign ) *this << " valign=\"" << valign << "\""; if( align ) *this << " align=\"" << align << "\""; if( colspan ) *this << " colspan=\"" << colspan << "\""; if( rowspan ) *this << " rowspan=\"" << rowspan << "\""; if( bgcolor ) *this << " bgcolor=\"" << bgcolor << "\""; if( width ) *this << " width=\"" << width << "\""; if( height ) *this << " height=\"" << height << "\""; if( nowrap ) *this << " nowrap"; if( cls ) *this << " class=\"" << cls << "\""; if( style ) *this << " style=\"" << style << "\""; *this << ">" << crlf; return *this; } p4wHtml & p4wHtml::endCol() { // // End a column of an html table *this << "</td>" << crlf; return *this; } p4wHtml & p4wHtml::beginColHead( const char *valign, const char *align, const char *colspan, const char *rowspan, const char *bgcolor, const char *width, const char *height, int nowrap, const char *cls, const char *style ) { // // Start a column head (th) of a table with optional valign, align, // colspan, rowspan, bgcolor & nowrap parameters *this << "<th"; if( valign ) *this << " valign=\"" << valign << "\""; if( align ) *this << " align=\"" << align << "\""; if( colspan ) *this << " colspan=\"" << colspan << "\""; if( rowspan ) *this << " rowspan=\"" << rowspan << "\""; if( bgcolor ) *this << " bgcolor=\"" << bgcolor << "\""; if( width ) *this << " width=\"" << width << "\""; if( height ) *this << " height=\"" << height << "\""; if( nowrap ) *this << " nowrap"; if( cls ) *this << " class=\"" << cls << "\""; if( style ) *this << " style=\"" << style << "\""; *this << ">" << crlf; return *this; } p4wHtml & p4wHtml::endColHead() { // // End a column head (th) of an html table *this << "</th>" << crlf; return *this; } p4wHtml & p4wHtml::beginForm( const char *action, const char *name ) { // // Generate the form directive using p4web's usual settings *this << "<Form"; if( action ) { *this << " method=\"POST\" "; *this << "enctype=\"application/x-www-form-urlencoded\" "; *this << "action=\"" << action << "\""; } if( name ) *this << " name=\"" << name << "\""; *this << ">" << crlf; return *this; } p4wHtml & p4wHtml::endForm() { // // End the form *this << "</Form>" << crlf; return *this; } p4wHtml & p4wHtml::textField( const char *name, const char *value, int size, char *id, const char *onClick, const char *onFocus, const char *onBlur, const char *autocomplete ) { // // Generate a text input field inputField( "text", name, value, 0, size, id, onClick, onFocus, onBlur, autocomplete ); return *this; } p4wHtml & p4wHtml::checkbox( const char *name, const char *value, int checked, char *onClick, char *id ) { // // Generate a checkbox input field inputField( "checkbox", name, value, checked, 0, id ? id : (char *)name, onClick ); return *this; } p4wHtml & p4wHtml::checkboxselectall( const char *formName, const char *fieldName, int checked ) { *this << "<script language=javascript>" << crlf; *this << "document.write(\"<td colspan='3'>\")" << crlf; *this << "function CA(isO,noHL){" << crlf; *this << "for (var i=0;i<" << formName << ".elements.length;i++)" << crlf; *this << "{" << crlf; *this << "var e=" << formName << ".elements[i];" << crlf; if (fieldName) *this << "if ((e.name != 'allbox') && (e.name == '" << fieldName << "') && (e.type=='checkbox'))" << crlf; else *this << "if ((e.name != 'allbox') && (e.name != 'ByPath') && (e.type=='checkbox'))" << crlf; *this << "{" << crlf; *this << "if (isO != 1)" << crlf; *this << "{" << crlf; *this << "e.checked=" << formName << ".allbox.checked;" << crlf; *this << "}" << crlf; *this << "else" << crlf; *this << "{" << crlf; *this << "}" << crlf; *this << "}" << crlf; *this << "}" << crlf; *this << "}" << crlf; if (checked) *this << "document.write(\"<input name='allbox' id='allbox' type='checkbox' value='checked' checked onClick='CA(0);' title='Select or de-select all files'>\")" << crlf; else *this << "document.write(\"<input name='allbox' id='allbox' type='checkbox' value='checked' onClick='CA(0);' title='Select or de-select all files'>\")" << crlf; *this << "document.write(\" <label for='allbox'>select all files</label>\")" << crlf; *this << "document.write(\"</td></tr><tr><td><img src='/clearpixelIcon?ac=20' height='2' width='1' border='0' alt='' title=''></td>\")" << crlf; *this << "</script>" << crlf; return *this; } p4wHtml & p4wHtml::radio( const char *name, const char *value, int checked, char *onClick, char *id ) { // // Generate a radio input field inputField( "radio", name, value, checked, 0, id ? id : (char *)value, onClick ); return *this; } p4wHtml & p4wHtml::button( const char *name, const char *value ) { // // Generate a button inputField( "submit", name, value ); return *this; } p4wHtml & p4wHtml::reset( const char *value ) { // // Generate a reset button inputField( "reset", NULL, value ); return *this; } p4wHtml & p4wHtml::hiddenField( const char *name, const char *value ) { // // Generate a hidden field with a string value inputField( "hidden", name, value ); return *this; } p4wHtml & p4wHtml::hiddenField( const char *name, int value ) { // // Generate a hidden field with an integer value *this << "<Input type=hidden"; if( name ) *this << " name=\"" << name << "\""; if( value ) *this << " value=\"" << value << "\""; *this << ">" << crlf; return *this; } p4wHtml & p4wHtml::passwdField( const char *name, const char *value, int size ) { // // Generate a password input field inputField( "password", name, value, 0, size, 0,0,0,0, "off" ); return *this; } void p4wHtml::inputField( const char *type, const char *name, const char *value, int checked, int size, char *id, const char *onClick, const char *onFocus, const char *onBlur, const char *autocomplete ) { // // Generate an input field of specified type *this << "<Input type=" << type; if( name ) *this << " name=\"" << name << "\""; if( value ) *this << " value=\"" << value << "\""; if( size ) *this << " size=\"" << size << "\""; if( checked ) *this << " checked"; if( id ) *this << " id=\"" << id << "\""; if( onClick ) *this << " onClick=\"" << onClick << "\""; if( onFocus ) *this << " onFocus=\"" << onFocus << "\""; if( onBlur ) *this << " onBlur=\"" << onBlur << "\""; if( autocomplete ) *this << " autocomplete=\"" << autocomplete << "\""; *this << ">" << crlf; } p4wHtml & p4wHtml::beginTextbox( const char *name, int rows, int cols, const char *onClick ) { // // Generate a text box *this << "<TextArea name=\"" << name << "\""; *this << " rows=\"" << rows << "\""; *this << " cols=\"" << cols << "\""; if( onClick ) *this << " onClick=\"" << onClick << "\""; *this << ">" << crlf;; return *this; } p4wHtml & p4wHtml::endTextbox() { // // End a text area *this << "</TextArea>" << crlf; return *this; } p4wHtml & p4wHtml::beginSelect( const char *name, int size, int multiple, const char *onChange, const char *onFocus, const char *id ) { // // Begin a select box *this << "<Select name=\"" << name << "\""; if( size ) *this << " size =\"" << size << "\""; if( multiple ) *this << " multiple"; if( onChange ) *this << " onChange=\"" << onChange << "\""; if( onFocus ) *this << " onFocus=\"" << onFocus << "\""; if( id ) *this << " id =\"" << id << "\""; *this << ">" << crlf; return *this; } p4wHtml & p4wHtml::selectOpt( int selected, const char *value ) { // // Generate an option of a select box *this << "<Option"; if( selected ) *this << " selected"; if( value ) *this << " value=" << value; *this << ">" << crlf; return *this; } p4wHtml & p4wHtml::endSelect() { // // End the select box *this << "</Select>" << crlf; return *this; } p4wHtml & p4wHtml::beginLogin(char *actionURL) { // // Begin the login form beginForm(actionURL, "l"); beginTable(0, 0, "5", "0"); beginTRow(); beginCol(); *this << "User name:"; endCol(); beginCol(); textField("u", 0, 25, "user", 0, 0, 0, "off"); *this << crlf << "<script language=\"JavaScript\" type=\"text/javascript\">" << crlf; *this << "if(document.getElementById) document.getElementById('user').focus();" << crlf; *this << "</script>" << crlf; endCol(); endTRow(); beginTRow(); beginCol(); *this << "Password: "; endCol(); beginCol(); passwdField("p", 0, 25); endCol(); endTRow(); return *this; } p4wHtml & p4wHtml::endLogin(char *orgurl) { // // End the login form beginTRow(); beginCol(); endCol(); beginCol(); button("Submit", "Log In"); endCol(); endTRow(); StrBuf ck4logout; ck4logout << "?ac=" << AC_LOGOUT; if (!strstr(orgurl, ck4logout.Text())) { ck4logout.Clear(); ck4logout << "?ac=" << AC_USERPSWD; if (!strstr(orgurl, ck4logout.Text())) { ck4logout.Clear(); ck4logout << "?ac=" << AC_NONE; if (!strstr(orgurl, ck4logout.Text())) hiddenField("orgurl", p4wStrBuf().EscapeHTML( StrRef(orgurl) ).Text()); } } endTable(); endForm(); return *this; } // There is NO beginJSActionsLink() function! p4wHtml & p4wHtml::endJSActionsLink(int iconSz, int bUseIcon) { *this << -1; *this << ",\\\"\\\")' id='id_a1' title ='Menu'><nobr>"; if (bUseIcon) { *this << "<img src='p4Icon?ac=20' height='"; *this << iconSz; *this << "' width='"; *this << iconSz; *this << "' border='0' alt='' align=absmiddle title=''>"; } else *this << "Actions"; *this << "<img src='/clearpixelIcon?ac=20' height='25' width='2' border='0' alt='' align=absmiddle title=''>"; *this << "<img src='/menuarrowtoolbarIcon?ac=20' height='"; *this << iconSz; *this << "' width='"; *this << 15 * iconSz/25; *this << "' border='0' alt='' align=absmiddle title=''>"; *this << "</nobr></a></td>"; *this << "<td valign='middle' align='right' width='3'>"; *this << "<img src='/grayPixelIcon?ac=20' height='18' width='1' border='0' alt='' title='' vspace='0' hspace='0'>"; *this << "\")" << crlf; return *this; } p4wHtml & p4wHtml::RenderPathMenu() { fSepNeeded = 0; beginDiv("menu_path", "mu", "display:none"); *this << crlf; beginTable(0, "10"); // wrap menu in a table so MSIE won't make the menu 100% wide beginTRow(); beginCol(0,0,0,0,0,0,0,1); *this << crlf; if( fRequest->GetViewMode() == VM_WORKSPACE ) RenderMenuItem("path", AC_PATHBROWSER, "Display Tree View", PM_PATHBROWSER, "/workspacetree17Icon"); else RenderMenuItem("path", AC_PATHBROWSER, "Display Tree View", PM_PATHBROWSER, "/depottree17Icon"); RenderMenuItem("path", AC_DIFF2DIRS, "Diff Two Folders...", PM_DIFF2DIRS); if (!fRequest->GetBrowseMode()) { fSepNeeded = 1; RenderMenuItem("path", AC_PATHBROWSER, 0, PM_SYNCFRM+2); RenderMenuItem("path", AC_SYNCCMD, "Sync to Head Revisions", PM_SYNCFRM+1, "/runsync17Icon"); RenderMenuItem("path", AC_SYNCFRM, "Sync... ", PM_SYNCFRM); RenderMenuItem("path", AC_REMOVEFRM, "Remove from Workspace...", PM_REMOVEFRM); fSepNeeded = 1; RenderMenuItem("path", AC_PATHBROWSER, 0, PM_EDITFRM+1); RenderMenuItem("path", AC_EDITFRM, "Open for Edit...", PM_EDITFRM); RenderMenuItem("path", AC_ADDFRM, "Open for Add...", PM_ADDFRM); RenderMenuItem("path", AC_DELETEFRM, "Open for Delete...", PM_DELETEFRM); RenderMenuItem("path", AC_REVERTCMD, "Revert Unchanged Files", PM_REVERTFRM+1, "/runrevert17Icon"); RenderMenuItem("path", AC_REVERTFRM, "Revert...", PM_REVERTFRM); fSepNeeded = 1; RenderMenuItem("path", AC_PATHBROWSER, 0, PM_INTEGRATEFRM+1); RenderMenuItem("path", AC_INTEGRATEFRM, "Integrate...", PM_INTEGRATEFRM); RenderMenuItem("path", AC_RESOLVEFRM, "Resolve...", PM_RESOLVEFRM, "/runresolve17Icon"); RenderMenuItem("path", AC_FILETYPEFRM, "Change Filetype...", PM_FILETYPEFRM); RenderMenuItem("path", AC_LOCKFRM, "Lock... ", PM_LOCKFRM, "/runlockIcon"); RenderMenuItem("path", AC_UNLOCKFRM, "Unlock... ", PM_UNLOCKFRM, "/rununlockIcon"); } endCol(); endTRow(); endTable(); endDiv(); *this << crlf; return *this; } p4wHtml & p4wHtml::RenderFileMenu(int show) { if (!show) return *this; fSepNeeded = 0; beginDiv("menu_file", "mu", "display:none"); *this << crlf; beginTable(0, "10"); // wrap menu in a table so MSIE won't make the menu 100% wide beginTRow(); beginCol(0,0,0,0,0,0,0,1); *this << crlf; if(show & FM_BROWSEFILE) RenderMenuItem("file", AC_BROWSEFILE, "Revision History", FM_BROWSEFILE, "/showfilelog17Icon"); fSepNeeded = 1; RenderMenuItem("file", AC_BROWSEFILE, 0, FM_MIMECONTENT+1); if(show & FM_WORKSPACEFILEPATH) RenderMenuItem("file", AC_WORKSPACEFILEPATH, "Open Workspace File in Browser", FM_WORKSPACEFILEPATH); if(show & FM_MIMECONTENT) RenderMenuItem("file", AC_MIMECONTENT, "Open Head Rev in Browser", FM_MIMECONTENT); fSepNeeded = 1; if(show & FM_SYNCFILEFRM) RenderMenuItem("file", AC_BROWSEFILE, 0, FM_SYNCFILEFRM+1); if(show & FM_SYNCCMD) RenderMenuItem("file", AC_SYNCCMD, "Sync to Head Revision", FM_SYNCCMD, "/runsync17Icon"); if(show & FM_SYNCFILEFRM) RenderMenuItem("file", AC_SYNCFILEFRM, "Sync... ", FM_SYNCFILEFRM); if(show & FM_REMOVEFILEFRM) RenderMenuItem("file", AC_REMOVEFILEFRM, "Remove from Workspace", FM_REMOVEFILEFRM); fSepNeeded = 1; if(show & FM_EDITFILE) RenderMenuItem("file", AC_BROWSEFILE, 0, FM_EDITFILE+4); if(show & FM_EDITFILE) RenderMenuItem("file", AC_EDITFILE, "Open for Edit in Default Changelist", FM_EDITFILE, "/runedit17Icon"); if(show & FM_EDITFILE) RenderMenuItem("file", AC_EDITFILEFRM, "Open for Edit...", FM_EDITFILE+1); fSepNeeded = 1; if(show & FM_ADDFILEFRM) RenderMenuItem("file", AC_BROWSEFILE, 0, FM_ADDFILEFRM+2); if(show & FM_ADDFILEFRM) RenderMenuItem("file", AC_ADDFILE, "Open for Add in Default Changelist", FM_ADDFILEFRM+1, "/runadd17Icon"); if(show & FM_ADDFILEFRM) RenderMenuItem("file", AC_ADDFILEFRM, "Open for Add...", FM_ADDFILEFRM); if(show & FM_EDITFILE) RenderMenuItem("file", AC_DELETEFILE, "Open for Delete in Default Changelist", FM_EDITFILE+2, "/rundelete17Icon"); if(show & FM_EDITFILE) RenderMenuItem("file", AC_DELETEFILEFRM, "Open for Delete...", FM_EDITFILE+3); fSepNeeded = 1; if(show & FM_REVERTCONFIRM) RenderMenuItem("file", AC_BROWSEFILE, 0, FM_REVERTCONFIRM+2); if(show & FM_REVERTCONFIRM) RenderMenuItem("file", AC_REVERTUNCHANGEDFILEFRM, "Revert if Unchanged", FM_REVERTCONFIRM+1, "/runrevert17Icon"); if(show & FM_REVERTCONFIRM) RenderMenuItem("file", AC_REVERTCONFIRM, "Revert... ", FM_REVERTCONFIRM); fSepNeeded = 1; if(show & FM_FILETEXTLOCAL) RenderMenuItem("file", AC_BROWSEFILE, 0, FM_FILETEXTLOCAL+1); if(show & FM_FILETEXTLOCAL) RenderMenuItem("file", AC_FILETEXTLOCAL, "View Workspace File Text", FM_FILETEXTLOCAL); if(show & FM_FILETEXTDEPOT) RenderMenuItem("file", AC_FILETEXTDEPOT, "View Head Revision Text", FM_FILETEXTDEPOT, "/showtext17Icon"); if(show & FM_FILETEXTDEPOT) RenderMenuItem("file", AC_GENERALANNOTATE, "View Annotated File Text", FM_FILETEXTDEPOT+1); int fstatRun = 1; const StrPtr *pb = fRequest->GetStateArg( "pb" ); if (pb) { switch(atoi(pb->Text())) { case 56: case 58: case 59: case 60: fstatRun = 0; } } fSepNeeded = 1; if (fRequest->GetLastReturnType() == AC_PATHBROWSER) { if (show & FM_DIFF21 && fstatRun) RenderMenuItem("file", AC_BROWSEFILE, 0, FM_DIFF21+1); else if (show & FM_DIFFWVH) RenderMenuItem("file", AC_BROWSEFILE, 0, FM_DIFFWVH+1); } else if(show & FM_DIFF_WVC_CVH) RenderMenuItem("file", AC_BROWSEFILE, 0, FM_DIFF_WVC_CVH+1); if(show & FM_DIFF_WVC_CVH) RenderMenuItem("file", AC_DIFFWVC, "Diff Synced Rev vs. Workspace File ", FM_DIFF_WVC_CVH); if(show & FM_DIFFWVH) RenderMenuItem("file", AC_DIFFWVH, "Diff Head Rev vs. Workspace File ", FM_DIFFWVH); if (fRequest->GetLastReturnType() == AC_PATHBROWSER) if(show & FM_DIFF21) RenderMenuItem("file", AC_DIFF21, "Diff Previous Rev vs. Head Rev", FM_DIFF21, "/rundiffprev17Icon"); if(show & FM_DIFF_WVC_CVH) RenderMenuItem("file", AC_DIFFCVH, "Diff Synced Rev vs. Head Rev", FM_DIFF_WVC_CVH+1); if(show & FM_MIMECONTENT) RenderMenuItem("file", AC_DIFF2FILES,"Diff Two Depot Files... ", FM_MIMECONTENT+2); fSepNeeded = 1; if(show & FM_LAUNCHEDITOR) RenderMenuItem("file", AC_BROWSEFILE, 0, FM_LAUNCHEDITOR+1); if(show & FM_LAUNCHEDITOR) RenderMenuItem("file", AC_LAUNCHEDITOR, "Edit Workspace File in Default Editor", FM_LAUNCHEDITOR, "/launchedit17Icon"); if(show & FM_EDITTEXTLOCAL) RenderMenuItem("file", AC_EDITTEXTLOCAL, "Edit Workspace File in P4Web", FM_EDITTEXTLOCAL); fSepNeeded = 1; if(show & FM_INTEGRATEFILEFRM) RenderMenuItem("file", AC_BROWSEFILE, 0, FM_INTEGRATEFILEFRM+1); if(show & FM_INTEGRATEFILEFRM) RenderMenuItem("file", AC_INTEGRATEFILEFRM, "Integrate...", FM_INTEGRATEFILEFRM); if(show & FM_RESOLVEFILEFRM) RenderMenuItem("file", AC_RESOLVEFILEFRM, "Resolve...", FM_RESOLVEFILEFRM, "/runresolve17Icon"); if(show & FM_FILETYPEFILEFRM) RenderMenuItem("file", AC_FILETYPEFILEFRM, "Change Filetype...", FM_FILETYPEFILEFRM); if(show & FM_LOCKFILEFRM) RenderMenuItem("file", AC_LOCKFILEFRM, "Lock ", FM_LOCKFILEFRM, "/runlockIcon"); if(show & FM_UNLOCKFILEFRM) RenderMenuItem("file", AC_UNLOCKFILEFRM, "Unlock ", FM_UNLOCKFILEFRM, "/rununlockIcon"); fSepNeeded = 1; if(show & FM_UPLOADTOLOCAL) RenderMenuItem("file", AC_BROWSEFILE, 0, FM_UPLOADTOLOCAL+2); if(show & FM_UPLOADTOLOCAL) RenderMenuItem("file", AC_DOWNLOADTOLOCAL, "Download File from Workspace", FM_UPLOADTOLOCAL+1); if(show & FM_UPLOADTOLOCAL) RenderMenuItem("file", AC_UPLOADTOLOCAL, "Upload File to Workspace", FM_UPLOADTOLOCAL); endCol(); endTRow(); endTable(); endDiv(); *this << crlf; return *this; } p4wHtml & p4wHtml::RenderRevHistMenu() { fSepNeeded = 0; beginDiv("menu_revhist", "mu", "display:none"); *this << crlf; beginTable(0, "10"); // wrap menu in a table so MSIE won't make the menu 100% wide beginTRow(); beginCol(0,0,0,0,0,0,0,1); *this << crlf; RenderMenuItem("revhist", AC_MIMECONTENT, "Open Revision in Browser ", RH_MIMECONTENT); RenderMenuItem("revhist", AC_FILETEXTDEPOT, "View Revision Text", RH_FILETEXTDEPOT, "/showtext17Icon"); fSepNeeded = 1; RenderMenuItem("revhist", AC_NONE, 0, RH_SEPARATOR); RenderMenuItem("revhist", AC_DIFF21, "Diff vs. Previous Revision", RH_DIFF21, "/rundiffprev17Icon"); RenderMenuItem("revhist", AC_DIFFSVR, "Diff vs. Selected Revision", RH_DIFFSVR, 0, "filelogForm", "validateFilelogForm"); RenderMenuItem("revhist", AC_DIFFRVW, "Diff vs. Workspace File", RH_DIFFRVW); fSepNeeded = 1; RenderMenuItem("revhist", AC_SYNCREV, 0, RH_SEPARATOR2); RenderMenuItem("revhist", AC_SYNCREV, "Sync to this Revision", RH_SYNCREV); endCol(); endTRow(); endTable(); endDiv(); *this << crlf; return *this; } p4wHtml & p4wHtml::beginUrlMenu(p4wRequest *request, char *divname) { fRequest = request; fSepNeeded = 0; beginDiv(divname, "mu", "display:none"); *this << crlf; beginTable(0, "10"); // wrap menu in a table so MSIE won't make the menu 100% wide beginTRow(); beginCol(0,0,0,0,0,0,0,1); *this << crlf; return *this; } p4wHtml & p4wHtml::endUrlMenu() { endCol(); endTRow(); endTable(); endDiv(); *this << crlf; return *this; } p4wHtml & p4wHtml::renderUrlMenuItem(char *muName, int divctr, AllCommands ac, char *url, char *name, int adddots, const char* myicon, int myiBig, int buXc) { #ifdef _DEBUG assert(fRequest); #endif if( ( !fRequest || fRequest->GetBrowseMode() || fRequest->GetBITBRev().Length() ) && !p4wAllCommands::CanBrowse( ac ) ) return *this; char *p; StrBuf id; int i = 1 << divctr; id << "id_mu" << muName << i; StrBuf iconUrlp; StrBuf iconUrlh; StrBuf temp; p4wURL urlMaker; int h = myiBig ? 12 : 17; int w = myiBig ? 21 : 8; if (myicon) temp << id << "p"; urlMaker.ConstructIcon( iconUrlp, myicon ? myicon : "/clearpixelIcon", 12, 8, "", 1, "top", myicon ? temp.Text() : 0 ); if (myicon) { StrBuf highlighted; highlighted << myicon; p = strstr(highlighted.Text(), "Icon"); if (p) { *p = '\0'; highlighted.SetLength(); highlighted << "highlightedIcon"; } temp.Clear(); temp << id << "h"; urlMaker.ConstructIcon( iconUrlh, highlighted.Text(), 12, 8, "", 1, "top", temp.Text() ); } if (fSepNeeded) { StrBuf grayIcon; urlMaker.ConstructURL( grayIcon, "/grayPixelIcon", AC_ICON, NULL ); icon( grayIcon.Text(), "1", "100%", "", 1, "2", "0" ); linebreak(); fSepNeeded = 0; } if (myicon) { *this << "<div id=\"" << id.Text() << "\" style=\"display:none\" onMouseOver=\"showhi('"; *this << id.Text() << "')\" onMouseOut=\"hidehi('" << id.Text() << "')\">"; } else beginDiv(id.Text(), 0, "display:none"); if (*url == '\"') url++; if (*(url + strlen(url) - 1) == '\"') *(url + strlen(url) - 1) = '\0'; StrBuf newURL; if (strchr(url, '\\')) { newURL.Alloc(3 * strlen(url)); char *p = newURL.Text(); char *q = url; while(*q) { if (*q == '\\') { strcpy(p, "\\\\"); p += 2; q++; } else *p++ = *q++; } *p = '\0'; newURL.SetLength(); url = newURL.Text(); } const StrPtr *X = fRequest->GetStateArg("X"); int hideicons = (!fRequest->IsMac() || (X && strchr(X->Text(), 'I'))) ? 0 : 1; // 0->show, 1->hide StrBuf muUrl; if (buXc) { if (buXc == 1) { p = strchr(url, '@'); if (p) { p = strchr(++p, '@'); if (p) { *++p = '/'; *++p = '\0'; p = strchr(++p, '?'); } } } else p = NULL; muUrl << "javascript:runuXc('" << url << "','"; if (p) muUrl << p; muUrl << "')"; } else muUrl << "javascript:runurl('" << url << "')"; beginLink(muUrl.Text()); if (!hideicons || !myiBig) { *this << iconUrlp; if (myicon) *this << iconUrlh; } *this << "<nobr>" << name; if (adddots) *this << "..."; if (fRequest->GetJavascriptMode() == 2 && fRequest->GetBrowserVersion() < 7.0) // MSIE 6 { StrBuf clearIcon; urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); icon( clearIcon.Text(), "17", "100%", "", 1 ); } *this << "</nobr>"; endLink(); linebreak(); endDiv(); *this << crlf; return *this; } void p4wHtml::renderPromptMenuItem(char *muName, char *promptstr, char *urlin, AllCommands cmd, char *name, int divctr ) { #ifdef _DEBUG assert(fRequest); #endif if( ( !fRequest || fRequest->GetBrowseMode() || fRequest->GetBITBRev().Length() ) && !p4wAllCommands::CanBrowse( cmd ) ) return; StrBuf url; StrBuf iconUrl; StrBuf temp; p4wURL urlMaker; StrBuf id; id << "id_mu" << muName << divctr; char *myicon = NULL; if (myicon) temp << id << "p"; urlMaker.ConstructIcon( iconUrl, myicon ? myicon : "/clearpixelIcon", 12, 8, "", 1, "top", myicon ? temp.Text() : 0 ); beginDiv(id.Text(), 0, "display:none"); // const StrPtr *X = fRequest->GetStateArg("X"); // int hideicons = (!fRequest->IsMac() || (X && strchr(X->Text(), 'I'))) ? 0 : 1; // 0->show, 1->hide url << "javascript:promptuXc('" << promptstr << "','" << urlin << "','?ac=" << (int)cmd << "')"; beginLink(url.Text()); // if (!hideicons) *this << iconUrl; *this << "<nobr>" << name; if (fRequest->GetJavascriptMode() == 2 && fRequest->GetBrowserVersion() < 7.0) // MSIE 6 { StrBuf clearIcon; urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); icon( clearIcon.Text(), "17", "100%", "", 1 ); } *this << "</nobr>"; endLink(); linebreak(); endDiv(); } void p4wHtml::RenderMenuItem(char *muName, AllCommands cmd, char *name, int divctr, char *myicon, char *submit, char *validate) { #ifdef _DEBUG assert(fRequest); #endif if( ( !fRequest || fRequest->GetBrowseMode() || fRequest->GetBITBRev().Length() ) && !p4wAllCommands::CanBrowse( cmd ) ) return; StrBuf url; StrBuf iconUrlp; StrBuf iconUrlh; StrBuf temp; p4wURL urlMaker; char *p; StrBuf id; id << "id_mu" << muName << divctr; if (myicon) temp << id << "p"; urlMaker.ConstructIcon( iconUrlp, myicon ? myicon : "/clearpixelIcon", 17, 21, "", 1, "top", myicon ? temp.Text() : 0 ); if (myicon) { StrBuf highlighted; highlighted << myicon; p = strstr(highlighted.Text(), "Icon"); if (p) { *p = '\0'; highlighted.SetLength(); highlighted << "highlightedIcon"; } temp.Clear(); temp << id << "h"; urlMaker.ConstructIcon( iconUrlh, highlighted.Text(), 17, 21, "", 1, "top", temp.Text() ); } if (myicon) { *this << "<div id=\"" << id.Text() << "\" style=\"display:none\" onMouseOver=\"showhi('"; *this << id.Text() << "')\" onMouseOut=\"hidehi('" << id.Text() << "')\">"; } else beginDiv(id.Text(), 0, "display:none"); if (fSepNeeded) { StrBuf grayIcon; urlMaker.ConstructURL( grayIcon, "/grayPixelIcon", AC_ICON, NULL ); icon( grayIcon.Text(), "1", "100%", "", 1, "2", "0" ); linebreak(); fSepNeeded = 0; } if (name) { const StrPtr *X = fRequest->GetStateArg("X"); int hideicons = (!fRequest->IsMac() || (X && strchr(X->Text(), 'I'))) ? 0 : 1; // 0->show, 1->hide if (validate && submit) url << "javascript:if (" << validate << "()) document." << submit << ".submit();"; else if (submit) url << "javascript:document." << submit << ".submit();"; else url << "javascript:runcmd(" << (int)cmd << ")"; beginLink(url.Text()); if (!hideicons) { *this << iconUrlp; if (myicon) *this << iconUrlh; } *this << "<nobr>" << name; if (fRequest->GetJavascriptMode() == 2 && fRequest->GetBrowserVersion() < 7.0) // MSIE 6 { StrBuf clearIcon; urlMaker.ConstructURL( clearIcon, "/clearpixelIcon", AC_ICON, NULL ); icon( clearIcon.Text(), "17", "100%", "", 1 ); } *this << "</nobr>"; endLink(); linebreak(); } endDiv(); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 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. |
||
//guest/perforce_software/p4web/util/p4wHtml.cpp | |||||
#2 | 10416 | Lester Cheung | Using HTTPS for favicon when option -ss (HTTPS mode) is used. | ||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |