Exemplo n.º 1
0
if (WorkbenchConfig::get()->value("checkSSL") && !usingSslEndToEnd()) {
    print "<div style='font-size: 8pt; color: orange;'>WARNING: Unsecure connection detected</div>";
}
if (WorkbenchContext::isEstablished() && WorkbenchContext::get()->isRequestStartTimeSet() && WorkbenchConfig::get()->value("displayRequestTime")) {
    $requestProcessingTime = WorkbenchContext::get()->getRequestProcessingTime();
    workbenchLog(LOG_INFO, "RequestProcessingMetrics", array("measure.request.service" => $requestProcessingTime . "sec", "source" => basename($_SERVER['SCRIPT_NAME'])));
    printf("Requested in %01.3f sec<BR/>", $requestProcessingTime);
}
print "Jason's Workbench " . ($GLOBALS["WORKBENCH_VERSION"] != "trunk" ? $GLOBALS["WORKBENCH_VERSION"] : "") . "<br/>\n";
?>
</div>

</body>

<script type="text/javascript" src="<?php 
echo getPathToStaticResource('/script/wz_tooltip.js');
?>
"></script>

<?php 
if (isset($_REQUEST["footerScripts"])) {
    foreach ($_REQUEST["footerScripts"] as $script) {
        print $script . "\n";
    }
}
?>

</html>

<?php 
$peak = memory_get_peak_usage();
Exemplo n.º 2
0
function displayBulkApiOptions($action, $forceDoAsync, $recommendDoAsync = false)
{
    //Hard Delete option
    if (WorkbenchContext::get()->isApiVersionAtLeast(19.0) && $action == 'Confirm Delete') {
        print "<p><label><input type='checkbox' id='doHardDelete' name='doHardDelete' onClick=\"" . "if (this.checked && " . ($forceDoAsync ? "false" : "true") . ") {" . "    document.getElementById('doAsync').checked = true;" . "    document.getElementById('asyncDeleteObjectSelection').style.display = 'inline';" . "    document.getElementById('unsupportedBulkConfigList').style.display = 'inline';" . "}\"/> " . "Permanently hard delete records</label>" . "&nbsp;<img onmouseover=\"Tip('When specified, the deleted records are not stored in the Recycle Bin. " . "Instead, the records become immediately eligible for deletion, don\\'t count toward the storage space used " . "by your organization, and may improve performance. The Administrative permission for this operation, " . "\\'Bulk API Hard Delete\\', is disabled by default and must be enabled by an administrator. " . "A Salesforce user license is required for hard delete. Hard Delete is only available via Bulk API.')\" " . "align='absmiddle' src='" . getPathToStaticResource('/images/help16.png') . "'/>" . "</p>";
    }
    //Async Options
    if (WorkbenchContext::get()->isApiVersionAtLeast(17.0) && in_array($action, array('Confirm Insert', 'Confirm Update', 'Confirm Upsert')) || WorkbenchContext::get()->isApiVersionAtLeast(18.0) && $action == 'Confirm Delete') {
        if ($forceDoAsync) {
            print "<input name='doAsync' type='hidden' value='true'/>";
        } else {
            print "<p><label><input id='doAsync' name='doAsync' type='checkbox' " . ($recommendDoAsync ? "checked='checked' " : "") . "onClick=\"" . "var doHardDelete = document.getElementById('doHardDelete');" . "var asyncDeleteObjectSelection = document.getElementById('asyncDeleteObjectSelection');" . "var unsupportedBulkConfigList = document.getElementById('unsupportedBulkConfigList');" . "if (this.checked) {" . "     if (asyncDeleteObjectSelection != null) asyncDeleteObjectSelection.style.display = 'inline';" . "     if (unsupportedBulkConfigList != null) unsupportedBulkConfigList.style.display = 'inline';" . "} else {" . "     if (doHardDelete != null) doHardDelete.checked = false;" . "     if (asyncDeleteObjectSelection != null) asyncDeleteObjectSelection.style.display = 'none';" . "     if (unsupportedBulkConfigList != null) unsupportedBulkConfigList.style.display = 'none';" . "}\"/> " . "Process records asynchronously via Bulk API</label>" . "&nbsp;<img onmouseover=\"Tip('Processing records asynchronously is recommended for large data loads. " . "The data will be uploaded to Salesforce via the Bulk API in batches and processed when server resources are available. " . "After batches have completed, results can be downloaded. Batch size and concurrency options are available in Settings.')\" " . "align='absmiddle' src='" . getPathToStaticResource('/images/help16.png') . "'/>" . "</p>";
        }
        // object selection for Bulk API Delete
        if ($action == 'Confirm Delete') {
            print "<div id='asyncDeleteObjectSelection' style='display: " . ($forceDoAsync || $recommendDoAsync ? "inline" : "none; margin-left: 3em;") . "'>Object Type: ";
            printObjectSelection(WorkbenchContext::get()->getDefaultObject());
            print "</div>";
        }
        // all configs not supported by Bulk API
        $bulkUnsupportedConfigs = array("mruHeader_updateMru", "allOrNoneHeader_allOrNone", "emailHeader_triggerAutoResponseEmail", "emailHeader_triggertriggerUserEmail", "emailHeader_triggerOtherEmail", "allowFieldTruncationHeader_allowFieldTruncation", "UserTerritoryDeleteHeader_transferToUserId");
        // find this user's settings that are in the unsupported config list
        $bulkUnsupportedSettings = array();
        foreach ($bulkUnsupportedConfigs as $c) {
            if (WorkbenchConfig::get()->overridden($c)) {
                $bulkUnsupportedSettings[] = $c;
            }
        }
        // print out a warning if any settings were found
        if (count($bulkUnsupportedSettings) > 0) {
            print "<div id='unsupportedBulkConfigList' style='display: " . ($forceDoAsync || $recommendDoAsync ? "inline" : "none") . "; color: orange;'>" . "<p " . ($forceDoAsync ? "" : "style='margin-left: 3em;'") . ">" . "<img src='" . getPathToStaticResource('/images/warning24.png') . "' /> " . "The following settings are not supported by the Bulk API and will be ignored:" . "<ul " . ($forceDoAsync ? "" : "style='margin-left: 5em;'") . ">";
            foreach ($bulkUnsupportedSettings as $s) {
                print "<li>" . WorkbenchConfig::get()->label($s) . "</li>";
            }
            print "</ul>" . "</p>" . "</div>";
        }
    }
}
Exemplo n.º 3
0
<?php

require_once 'session.php';
require_once 'shared.php';
require_once 'put.php';
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Language" content="UTF-8" />
        <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
        <link rel="stylesheet" href="<?php 
echo getPathToStaticResource('/style/master.css');
?>
" type="text/css" />
        <link rel="Shortcut Icon" type="image/png" href="<?php 
echo getPathToStaticResource('/images/bluecube-16x16.png');
?>
" />
        <title>Workbench - CSV Preview</title>
    </head>
<body>

<?php 
if (isset($_SESSION['csv_array'])) {
    displayCsvArray($_SESSION['csv_array']);
} else {
    displayError("No CSV has been uploaded, or it is no longer active");
}
include_once 'footer.php';
options:</p>

<form id='deployForm' name='deployForm' method='POST'
    action=''
    enctype='multipart/form-data'><input type='file' name='deployFile'
    size='44' />
    <?php 
        print getCsrfFormTag();
        ?>
    <input type='hidden' name='MAX_FILE_SIZE' value='<?php 
        print WorkbenchConfig::get()->value("maxFileSize");
        ?>
' />
    <img onmouseover="Tip('Choose a ZIP file containing a project manifest, a file named package.xml, and a set of directories that contain the components to deploy.  See Salesforce.com Metadata API Developers guide more information about working with ZIP files for deployment.')"
     align='absmiddle' src='<?php 
        echo getPathToStaticResource('/images/help16.png');
        ?>
' />
<p />
    <?php 
        printDeployOptions(defaultDeployOptions());
        ?>
<p />
<input type='submit' name='stageForDeployment' value='Next' /></form>
    <?php 
    }
}
include_once 'footer.php';
exit;
function deserializeDeployOptions($request)
{
Exemplo n.º 5
0
                       value="Delete"/>

                <span id="waitingIndicator">
                    <img src="<?php 
echo getPathToStaticResource('/images/wait16trans.gif');
?>
"/>
                    Processing...
                </span>
            </div>
        </form>
    </div>
</div>

<div id="streamContainer">
    <div><span id="status"></span><span id="pollIndicator">&bull;</span></div>
    <div id="streamBody"></div>
</div>

<script type="text/javascript">

</script>


<?php 
if ($c->isEnabled()) {
    addFooterScript("<script type='text/javascript' src='" . 'static-unversioned/script/dojo/dojo/dojo.js' . "'></script>");
    addFooterScript("<script type='text/javascript' src='" . getPathToStaticResource('/script/streamingClient.js') . "'></script>");
    addFooterScript("<script type='text/javascript'>var wbStreaming = " . $c->getStreamingConfig() . ";</script>");
}
require_once "footer.php";
function futureAjax($asyncId)
{
    ?>

<div id="async-container-<?php 
    echo $asyncId;
    ?>
"></div>

<script type='text/javascript' src='<?php 
    echo getPathToStaticResource('/script/getElementsByClassName.js');
    ?>
'></script>

<script type="text/javascript">
    <!--

    var WorkbenchFuture<?php 
    echo $asyncId;
    ?>
 = new function() {
        // Get the HTTP Object
        this.getHTTPObject = function() {
            if (window.ActiveXObject) {
                return new ActiveXObject("Microsoft.XMLHTTP");
            } else if (window.XMLHttpRequest) {
                return new XMLHttpRequest();
            } else {
                alert("Your browser does not support AJAX.");
                return null;
            }
        };

        this.getFuture = function() {
            this.disableWhileAsyncLoading(true);
            var container = document.getElementById('async-container-<?php 
    echo $asyncId;
    ?>
');
            container.innerHTML = "<img src='<?php 
    echo getPathToStaticResource('/images/wait16trans.gif');
    ?>
'/>&nbsp; Loading...";
            this.getFutureInternal(container, 0);
        };

        this.getFutureInternal = function(container, totalTimeWaiting) {
            var ajax = this.getHTTPObject();
            if (ajax != null) {
                var longPollTimeout = 10;
                ajax.open("GET", "future_get.php?async_id=<?php 
    echo $asyncId;
    ?>
&wait_for=" + longPollTimeout, true);
                ajax.send(null);
                ajax.onreadystatechange = function () {
                    if (ajax.readyState == 4) {
                        if (ajax.status == 200) {
                            container.innerHTML = ajax.responseText;
                            var evalables = getElementsByClassName("evalable", "script", container);
                            for (i in evalables) {
                                eval(evalables[i].innerHTML)
                            }
                        } else if (ajax.status == 202) {
                            // 202 means that long poll ended, but still waiting for result
                            container.innerHTML += ".";
                            if (totalTimeWaiting > (<?php 
    echo WorkbenchConfig::get()->value('asyncTimeoutSeconds');
    ?>
)) {
                                container.innerHTML = "<span style='color:red;'>Timed out waiting for asynchronous job to complete</span>";
                            } else {
                                WorkbenchFuture<?php 
    echo $asyncId;
    ?>
.getFutureInternal(container, totalTimeWaiting + longPollTimeout);
                                return;
                            }
                        } else if (ajax.status == 404) {
                            container.innerHTML = "<span style='color:red;'>Unknown Asynchronous Job</span>";
                        } else if (ajax.status == 503) {
                            container.innerHTML = "<span style='color:red;'>Service was temporarily interrupted or is unavailable. Please try again in a moment.</span>";
                        } else {
                            container.innerHTML = "<span style='color:red;'>Unknown Asynchronous State</span>";
                        }
                        WorkbenchFuture<?php 
    echo $asyncId;
    ?>
.disableWhileAsyncLoading(false);
                    }
                };
            } else {
                container.innerHTML = "Unknown error loading content";
            }
        };

        this.disableWhileAsyncLoading = function(isAllowed) {
            var disableWhileAsyncLoadingElements = getElementsByClassName("disableWhileAsyncLoading");

            for (i in disableWhileAsyncLoadingElements) {
                disableWhileAsyncLoadingElements[i].disabled = isAllowed;
            }
        };
    };

    WorkbenchFuture<?php 
    echo $asyncId;
    ?>
.getFuture();

    //-->
</script>

<?php 
}
Exemplo n.º 7
0
 $operation = isset($_REQUEST['op']) ? htmlspecialchars($_REQUEST['op']) : (isset($asyncResults->checkOnly) ? "D" : "R");
 $results = $operation == "D" ? WorkbenchContext::get()->getMetadataConnection()->checkDeployStatus($asyncProcessId, $debugInfo) : WorkbenchContext::get()->getMetadataConnection()->checkRetrieveStatus($asyncProcessId, $debugInfo);
 $zipLink = null;
 if (isset($results->zipFile) || isset($results->retrieveResult->zipFile)) {
     if (isset($results->zipFile)) {
         $_SESSION['retrievedZips'][$asyncResults->id] = $results->zipFile;
         unset($results->zipFile);
     } else {
         if (isset($results->retrieveResult->zipFile)) {
             $_SESSION['retrievedZips'][$asyncResults->id] = $results->retrieveResult->zipFile;
             unset($results->retrieveResult->zipFile);
         }
     }
     displayInfo("Retrieve result ZIP file is ready for download.");
     print "<p/>";
     $zipLink = " | <a id='zipLink' href='?asyncProcessId={$asyncResults->id}&downloadZip' onclick='undownloadedZip=false;' style='text-decoration:none;'>" . "<span style='text-decoration:underline;'>Download ZIP File</span> <img src='" . getPathToStaticResource('/images/downloadIconCompleted.gif') . "' border='0'/>" . "</a></p>";
 }
 $tree = new ExpandableTree("metadataStatusResultsTree", ExpandableTree::processResults($results));
 $tree->setForceCollapse(true);
 $tree->setAdditionalMenus($zipLink);
 $tree->setContainsIds(true);
 $tree->setContainsDates(true);
 $tree->printTree();
 if (isset($debugInfo["DebuggingInfo"]->debugLog)) {
     print "<p>&nbsp;</p><h3>Debug Logs</h3>";
     print "<pre>" . addLinksToIds(htmlspecialchars($debugInfo["DebuggingInfo"]->debugLog, ENT_QUOTES)) . '</pre>';
 }
 // if metadata changes were deployed, clear the cache because describe results will probably be different
 if ($operation == "D") {
     WorkbenchContext::get()->clearCache();
 }
Exemplo n.º 8
0
 public static function getClearCacheMenu()
 {
     return " | <a href='?clearCache' style='text-decoration:none;'>" . "<span style='text-decoration:underline;'>Clear Cache</span> <img src='" . getPathToStaticResource('/images/sweep.png') . "' border='0' align='top'/>" . "</a>";
 }
Exemplo n.º 9
0
function displayInfo($infos)
{
    print "<div class='displayInfo'>\n";
    print "<img src='" . getPathToStaticResource('/images/info24.png') . "' width='24' height='24' align='middle' border='0' alt='info:' /> <p/>";
    if (is_array($infos)) {
        $infoString = "";
        foreach ($infos as $info) {
            $infoString .= "<p>" . htmlspecialchars($info) . "</p>";
        }
        print $infoString;
    } else {
        print htmlspecialchars($infos);
    }
    print "</div>\n";
}
Exemplo n.º 10
0
function displaySearchResult($records, $searchTimeElapsed)
{
    //Check if records were returned
    if ($records) {
        if (WorkbenchConfig::get()->value("areTablesSortable")) {
            addFooterScript("<script type='text/javascript' src='" . getPathToStaticResource('/script/sortable.js') . "></script>");
        }
        try {
            print "<a name='sr'></a><div style='clear: both;'><br/><h2>Search Results</h2>\n";
            print "<p>Returned " . count($records) . " total record";
            if (count($records) !== 1) {
                print 's';
            }
            print " in ";
            printf("%01.3f", $searchTimeElapsed);
            print " seconds:</p>";
            $searchResultArray = array();
            foreach ($records as $record) {
                $recordObject = new Sobject($record->record);
                $searchResultArray[$recordObject->type][] = $recordObject;
            }
            foreach ($searchResultArray as $recordSetName => $records) {
                echo "<h3>{$recordSetName}</h3>";
                print "<table id='" . $recordSetName . "_results' class='" . getTableClass() . "'>\n";
                //Print the header row on screen
                $record0 = $records[0];
                print "<tr><th></th>";
                //If the user queried for the Salesforce ID, this special method is nessisary
                //to export it from the nested SOAP message. This will always be displayed
                //in the first column regardless of search order
                if (isset($record0->Id)) {
                    print "<th>Id</th>";
                }
                if ($record0->fields) {
                    foreach ($record0->fields->children() as $field) {
                        print "<th>";
                        print htmlspecialchars($field->getName(), ENT_QUOTES);
                        print "</th>";
                    }
                } else {
                    print "</td></tr>";
                }
                print "</tr>\n";
                //Print the remaining rows in the body
                $rowNum = 1;
                foreach ($records as $record) {
                    print "<tr><td>{$rowNum}</td>";
                    $rowNum++;
                    //Another check if there are ID columns in the body
                    if (isset($record->Id)) {
                        print "<td>" . addLinksToIds($record->Id) . "</td>";
                    }
                    //Print the non-ID fields
                    if (isset($record->fields)) {
                        foreach ($record->fields as $datum) {
                            print "<td>";
                            if ($datum) {
                                print localizeDateTimes(addLinksToIds(htmlspecialchars($datum, ENT_QUOTES)));
                            } else {
                                print "&nbsp;";
                            }
                            print "</td>";
                        }
                        print "</tr>\n";
                    } else {
                        print "</td></tr>\n";
                    }
                }
                print "</table>&nbsp;<p/>";
            }
            print "</div>\n";
        } catch (Exception $e) {
            $errors = null;
            $errors = $e->getMessage();
            print "<p />";
            displayError($errors, false, true);
        }
    } else {
        print "<p><a name='sr'>&nbsp;</a></p>";
        displayError("Sorry, no records returned.");
    }
    include_once 'footer.php';
}
Exemplo n.º 11
0
function displayQueryForm($queryRequest)
{
    registerShortcut("Ctrl+Alt+W", "addFilterRow(document.getElementById('numFilters').value++);" . "toggleFieldDisabled();");
    if ($queryRequest->getObject()) {
        $describeSObjectResult = WorkbenchContext::get()->describeSObjects($queryRequest->getObject());
        $fieldValuesToLabels = array();
        foreach ($describeSObjectResult->fields as $field) {
            $fieldValuesToLabels[$field->name] = $field->name;
        }
    } else {
        displayInfo('First choose an object to use the SOQL builder wizard.');
    }
    print "<script type='text/javascript'>\n";
    print "var field_type_array = new Array();\n";
    if (isset($describeSObjectResult)) {
        foreach ($describeSObjectResult->fields as $fields => $field) {
            print " field_type_array[\"{$field->name}\"]=[\"{$field->type}\"];\n";
        }
    }
    $ops = array('=' => '=', '!=' => '&ne;', '<' => '&lt;', '<=' => '&le;', '>' => '&gt;', '>=' => '&ge;', 'starts' => 'starts with', 'ends' => 'ends with', 'contains' => 'contains', 'IN' => 'in', 'NOT IN' => 'not in', 'INCLUDES' => 'includes', 'EXCLUDES' => 'excludes');
    print "var compOper_array = new Array();\n";
    foreach ($ops as $opValue => $opLabel) {
        print " compOper_array[\"{$opValue}\"]=[\"{$opLabel}\"];\n";
    }
    print "</script>\n";
    print "<script src='" . getPathToStaticResource('/script/query.js') . "' type='text/javascript'></script>\n";
    print "<form method='POST' id='query_form' name='query_form' action='query.php'>\n";
    print "<input type='hidden' name='justUpdate' value='0' />";
    print "<input type='hidden' id='numFilters' name='numFilters' value='" . count($queryRequest->getFilters()) . "' />";
    print "<p class='instructions'>Choose the object, fields, and critera to build a SOQL query below:</p>\n";
    print "<table border='0' style='width: 100%;'>\n";
    print "<tr><td valign='top' width='1'>Object:";
    printObjectSelection($queryRequest->getObject(), 'QB_object_sel', "16", "onChange='updateObject();'", "queryable");
    print "<p/>Fields:<select id='QB_field_sel' name='QB_field_sel[]' multiple='mutliple' size='4' style='width: 16em;' onChange='buildQuery();'>\n";
    if (isset($describeSObjectResult)) {
        print " <option value='count()'";
        if ($queryRequest->getFields() != null) {
            //check to make sure something is selected; otherwise warnings will display
            foreach ($queryRequest->getFields() as $selectedField) {
                if ('count()' == $selectedField) {
                    print " selected='selected' ";
                }
            }
        }
        print ">count()</option>\n";
        //print ">$field->name</option>\n";
        foreach ($describeSObjectResult->fields as $fields => $field) {
            print " <option value='{$field->name}'";
            if ($queryRequest->getFields() != null) {
                //check to make sure something is selected; otherwise warnings will display
                foreach ($queryRequest->getFields() as $selectedField) {
                    if ($field->name == $selectedField) {
                        print " selected='selected' ";
                    }
                }
            }
            print ">{$field->name}</option>\n";
        }
    }
    print "</select></td>\n";
    print "<td valign='top'>";
    print "<table border='0' align='right' style='width:100%'>\n";
    print "<tr><td valign='top' colspan=2>View as:<br/>" . "<label><input type='radio' id='export_action_screen' name='export_action' value='screen' ";
    if ($queryRequest->getExportTo() == 'screen') {
        print "checked='true'";
    }
    print " onClick='toggleMatrixSortSelectors(true);'>List</label>&nbsp;";
    print "<label><input type='radio' id='export_action_matrix' name='export_action' value='matrix' ";
    if ($queryRequest->getExportTo() == 'matrix') {
        print "checked='true'";
    }
    print " onClick='toggleMatrixSortSelectors(true);'>Matrix</label>";
    if (WorkbenchConfig::get()->value("allowQueryCsvExport")) {
        print "<label><input type='radio' id='export_action_csv' name='export_action' value='csv' ";
        if ($queryRequest->getExportTo() == 'csv') {
            print "checked='true'";
        }
        print " onClick='toggleMatrixSortSelectors(true);'>CSV</label>&nbsp;";
    }
    print "<label><input type='radio' id='export_action_async_csv' name='export_action' value='async_CSV' ";
    if ($queryRequest->getExportTo() == 'async_CSV') {
        print "checked='true'";
    }
    print " onClick='toggleMatrixSortSelectors(true);'>Bulk CSV</label>&nbsp;";
    print "<label><input type='radio' id='export_action_async_xml' name='export_action' value='async_XML' ";
    if ($queryRequest->getExportTo() == 'async_XML') {
        print "checked='true'";
    }
    print " onClick='toggleMatrixSortSelectors(true);'>Bulk XML</label>&nbsp;";
    print "<td valign='top' colspan=2>Deleted and archived records:<br/>" . "<label><input type='radio' name='query_action' value='Query' ";
    if ($queryRequest->getQueryAction() == 'Query') {
        print "checked='true'";
    }
    print " >Exclude</label>&nbsp;";
    print "<label><input type='radio' name='query_action' value='QueryAll' ";
    if ($queryRequest->getQueryAction() == 'QueryAll') {
        print "checked='true'";
    }
    print " >Include</label></td></tr></table>\n";
    print "<table id='QB_right_sub_table' border='0' align='right' style='width:100%'>\n";
    print "<tr id='matrix_selection_headers' style='display: none;'><td><br/>Columns:</td> <td><br/>Rows:</td> <td>&nbsp;</td></tr>\n";
    print "<tr id='matrix_selection_row' style='display: none;'><td><select id='matrix_cols' name='matrix_cols' style='width: 15em;' onChange='toggleFieldDisabled();buildQuery();' onkeyup='toggleFieldDisabled();buildQuery();'>";
    if (isset($fieldValuesToLabels)) {
        printSelectOptions(array_merge(array("" => ""), $fieldValuesToLabels), $queryRequest->getMatrixCols());
    }
    print "</select></td> <td><select id='matrix_rows' name='matrix_rows' style='width: 15em;' onChange='toggleFieldDisabled();buildQuery();' onkeyup='toggleFieldDisabled();buildQuery();'>";
    if (isset($fieldValuesToLabels)) {
        printSelectOptions(array_merge(array("" => ""), $fieldValuesToLabels), $queryRequest->getMatrixRows());
    }
    print "</select></td> <td><img onmouseover=\"Tip('Matrix view groups records into columns and rows of common field values.')\" align='absmiddle' src='" . getPathToStaticResource('/images/help16.png') . "'/></td></tr>\n";
    print "<tr id='sort_selection_headers'><td colspan='2'><br/>Sort results by:</td> <td><br/>Max Records:</td></tr>\n";
    print "<tr id='sort_selection_row'>";
    print "<td colspan='2'><select id='QB_orderby_field' name='QB_orderby_field' style='width: 16em;' onChange='buildQuery();'>\n";
    print "<option value=''></option>\n";
    if (isset($describeSObjectResult)) {
        foreach ($describeSObjectResult->fields as $fields => $field) {
            print " <option value='{$field->name}'";
            if ($queryRequest->getOrderByField() != null && $field->name == $queryRequest->getOrderByField()) {
                print " selected='selected' ";
            }
            print ">{$field->name}</option>\n";
        }
    }
    print "</select>\n";
    $qBOrderbySortOptions = array('ASC' => 'A to Z', 'DESC' => 'Z to A');
    print "<select id='QB_orderby_sort' name='QB_orderby_sort' style='width: 6em;' onChange='buildQuery();' onkeyup='buildQuery();'>\n";
    foreach ($qBOrderbySortOptions as $opKey => $op) {
        print "<option value='{$opKey}'";
        if (isset($_POST['QB_orderby_sort']) && $opKey == $_POST['QB_orderby_sort']) {
            print " selected='selected' ";
        }
        print ">{$op}</option>\n";
    }
    print "</select>\n";
    $qBNullsOptions = array('FIRST' => 'Nulls First', 'LAST' => 'Nulls Last');
    print "<select id='QB_nulls' name='QB_nulls' style='width: 10em;' onChange='buildQuery();' onkeyup='buildQuery();'>\n";
    foreach ($qBNullsOptions as $opKey => $op) {
        print "<option value='{$opKey}'";
        if ($queryRequest->getOrderByNulls() != null && $opKey == $queryRequest->getOrderByNulls()) {
            print " selected='selected' ";
        }
        print ">{$op}</option>\n";
    }
    print "</select></td>\n";
    print "<td><input type='text' id='QB_limit_txt' size='10' name='QB_limit_txt' value='" . htmlspecialchars($queryRequest->getLimit() != null ? $queryRequest->getLimit() : null, ENT_QUOTES) . "' onkeyup='buildQuery();' /></td>\n";
    print "</tr>\n";
    print "</table>\n";
    print "</td></tr>\n";
    $filterRowNum = 0;
    foreach ($queryRequest->getFilters() as $filter) {
        print "<script>addFilterRow(" . $filterRowNum++ . ", " . "\"" . $filter->getField() . "\", " . "\"" . $filter->getCompOper() . "\", " . "\"" . htmlspecialchars($filter->getValue(), ENT_QUOTES) . "\"" . ");</script>";
    }
    print "<tr><td valign='top' colspan=5><br/>Enter or modify a SOQL query below:\n" . "<br/><textarea id='soql_query_textarea' type='text' name='soql_query' rows='" . WorkbenchConfig::get()->value("textareaRows") . "' style='width: 99%; overflow: auto; font-family: monospace, courier;'>" . htmlspecialchars($queryRequest->getSoqlQuery(), ENT_QUOTES) . "</textarea>\n" . "</td></tr>\n";
    print "<tr><td colspan=1><input type='submit' name='querySubmit' class='disableWhileAsyncLoading' value='Query' onclick='return parentChildRelationshipQueryBlocker();' /></td>";
    print "<td colspan=4 align='right'>";
    print "&nbsp;&nbsp;" . "<img onmouseover=\"Tip('Where did saved queries go? They have been replaced with bookmarkable and shareable queries! Just run a query and bookmark the URL to save or copy and paste to share.')\" align='absmiddle' src='" . getPathToStaticResource('/images/help16.png') . "'/>";
    print "</td></tr></table><p/>\n";
    print "<script>toggleFieldDisabled();toggleMatrixSortSelectors(false);</script>";
}
Exemplo n.º 12
0
function displayQueryForm($queryRequest)
{
    registerShortcut("Ctrl+Alt+W", "addFilterRow(document.getElementById('numFilters').value++);" . "toggleFieldDisabled();");
    if ($queryRequest->getObject()) {
        $describeSObjectResult = WorkbenchContext::get()->describeSObjects($queryRequest->getObject());
        $fieldValuesToLabels = array();
        foreach ($describeSObjectResult->fields as $field) {
            $fieldValuesToLabels[$field->name] = $field->name;
        }
    } else {
        displayInfo('First choose an object to use the SOQL builder wizard.');
    }
    print "<script>\n";
    print "var field_type_array = new Array();\n";
    if (isset($describeSObjectResult)) {
        foreach ($describeSObjectResult->fields as $fields => $field) {
            print " field_type_array[\"{$field->name}\"]=[\"{$field->type}\"];\n";
        }
    }
    $ops = array('=' => '=', '!=' => '&ne;', '<' => '&lt;', '<=' => '&le;', '>' => '&gt;', '>=' => '&ge;', 'starts' => 'starts with', 'ends' => 'ends with', 'contains' => 'contains', 'IN' => 'in', 'NOT IN' => 'not in', 'INCLUDES' => 'includes', 'EXCLUDES' => 'excludes');
    print "var compOper_array = new Array();\n";
    foreach ($ops as $opValue => $opLabel) {
        print " compOper_array[\"{$opValue}\"]=[\"{$opLabel}\"];\n";
    }
    print <<<QUERY_BUILDER_SCRIPT

function parentChildRelationshipQueryBlocker() {
    var soql = document.getElementById('soql_query_textarea').value.toUpperCase();
    
    if (soql.indexOf('(SELECT') != -1 && soql.indexOf('IN (SELECT') == -1 && document.getElementById('export_action_csv').checked) {
        return confirm ("Export of parent-to-child relationship queries to CSV are not yet supported by Workbench and may give unexpected results. Are you sure you wish to continue?");
    }
    
}

function doesQueryHaveName() {
    var saveQr = document.getElementById('saveQr');
    if (saveQr.value == null || saveQr.value.length == 0) {
        alert('Query must have a name to save.');
        return false;
    }    
    
    return true;
}


function toggleFieldDisabled() {
    var QB_field_sel = document.getElementById('QB_field_sel');

    if (document.getElementById('QB_object_sel').value) {
        QB_field_sel.disabled = false;
    } else {
        QB_field_sel.disabled = true;
    }


    var isFieldSelected = false;
    for (var i = 0; i < QB_field_sel.options.length; i++)
        if (QB_field_sel.options[i].selected)
            isFieldSelected = true;
            
    if (isFieldSelected || (document.getElementById('matrix_rows').value != '' && document.getElementById('matrix_cols').value != '')) {
            document.getElementById('QB_orderby_field').disabled = false;
            document.getElementById('QB_orderby_sort').disabled = false;
            document.getElementById('QB_nulls').disabled = false;
            document.getElementById('QB_limit_txt').disabled = false;
            
            document.getElementById('QB_filter_field_0').disabled = false;
            if (document.getElementById('QB_filter_field_0').value) {
                document.getElementById('QB_filter_value_0').disabled = false;
                document.getElementById('QB_filter_compOper_0').disabled = false;
            } else {
                document.getElementById('QB_filter_value_0').disabled = true;
                document.getElementById('QB_filter_compOper_0').disabled = true;
            }
    } else {
            document.getElementById('QB_filter_field_0').disabled = true;
            document.getElementById('QB_filter_compOper_0').disabled = true;
            document.getElementById('QB_filter_value_0').disabled = true;
            document.getElementById('QB_orderby_field').disabled = true;
            document.getElementById('QB_orderby_sort').disabled = true;
            document.getElementById('QB_nulls').disabled = true;
            document.getElementById('QB_limit_txt').disabled = true;
    }

    var allPreviousRowsUsed = true;
    for (var r = 1; r < document.getElementById('numFilters').value; r++) {
        var lastRow = r-1;
        var thisRow = r;
        
        if (isFieldSelected && allPreviousRowsUsed && document.getElementById('QB_filter_field_' + lastRow).value && document.getElementById('QB_filter_compOper_' + lastRow).value && document.getElementById('QB_filter_value_' + lastRow).value) {
            document.getElementById('QB_filter_field_' + thisRow).disabled = false;
            if (document.getElementById('QB_filter_field_' + thisRow).value) {
                document.getElementById('QB_filter_value_' + thisRow).disabled = false;
                document.getElementById('QB_filter_compOper_' + thisRow).disabled = false;
            } else {
                document.getElementById('QB_filter_value_' + thisRow).disabled = true;
                document.getElementById('QB_filter_compOper_' + thisRow).disabled = true;
            }
        } else {
            allPreviousRowsUsed = false;
            document.getElementById('QB_filter_field_' + thisRow).disabled = true;
            document.getElementById('QB_filter_compOper_' + thisRow).disabled = true;
            document.getElementById('QB_filter_value_' + thisRow).disabled = true;
        }
    }
}

function updateObject() {
  document.query_form.justUpdate.value = 1;
  document.query_form.submit();
}

function exportActionIs(type) {
    var exportActions = document.getElementById('query_form')['export_action'];
    for (var i = 0; i < exportActions.length; i++) {
        if (exportActions[i].checked && exportActions[i].value == type) {
            return true;
        }
    }
    return false;
}

function arrayContains(haystack, needle) {
    for (i in haystack) {
        if (haystack[i] == needle) {
            return true;
        }
    }
    
    return false;
}

function buildQuery() {
    toggleFieldDisabled();
    var QB_object_sel = document.getElementById('QB_object_sel').value;
    var QB_field_sel = document.getElementById('QB_field_sel');
    QB_fields_selected = new Array();
    for (var i = 0; i < QB_field_sel.options.length; i++) {
        if (QB_field_sel.options[i].selected) {
            QB_fields_selected.push(QB_field_sel.options[i].value);
        }
    }
    
    if (exportActionIs('matrix')) {
        var matrix_cols = document.getElementById('matrix_cols');
        var matrix_rows = document.getElementById('matrix_rows');
        
        if (matrix_cols.value != '' && matrix_rows.value != '') {
            if (!arrayContains(QB_fields_selected, matrix_cols.value)) QB_fields_selected.push(matrix_cols.value);
            if (!arrayContains(QB_fields_selected, matrix_rows.value)) QB_fields_selected.push(matrix_rows.value);
        }
    }

    var soql_select = '';
    if (QB_fields_selected.toString().indexOf('count()') != -1 && QB_fields_selected.length > 1) {
        alert('Warning: Choosing count() with other fields will result in a malformed query. Unselect either count() or the other fields to continue.');
    } else    if (QB_fields_selected.length > 0) {
        var soql_select = 'SELECT ' + QB_fields_selected + ' FROM ' + QB_object_sel;
    }

    soql_where = '';
    for (var f = 0; f < document.getElementById('numFilters').value; f++) {
    
        var QB_filter_field = document.getElementById('QB_filter_field_' + f).value;
        var QB_filter_compOper = document.getElementById('QB_filter_compOper_' + f).value;
        var QB_filter_value = document.getElementById('QB_filter_value_' + f).value;
        
        var soql_where_logicOper = '';
        if (f > 0) {
            soql_where_logicOper = ' AND ';
        }    
        
        if (QB_filter_field && QB_filter_compOper && QB_filter_value) {
            if (QB_filter_compOper == 'starts') {
                QB_filter_compOper = 'LIKE'
                QB_filter_value = QB_filter_value + '%';
            } else if (QB_filter_compOper == 'ends') {
                QB_filter_compOper = 'LIKE'
                QB_filter_value = '%' + QB_filter_value;
            } else if (QB_filter_compOper == 'contains') {
                QB_filter_compOper = 'LIKE'
                QB_filter_value = '%' + QB_filter_value + '%';
            }
            
            
            if (QB_filter_compOper == 'IN' || 
                QB_filter_compOper == 'NOT IN' ||
                QB_filter_compOper == 'INCLUDES' || 
                QB_filter_compOper == 'EXCLUDES') {
                    QB_filter_value_q = '(' + QB_filter_value + ')';
            } else if ((QB_filter_value == 'null') ||
                (field_type_array[QB_filter_field] == "datetime") ||
                (field_type_array[QB_filter_field] == "date") ||
                (field_type_array[QB_filter_field] == "currency") ||
                (field_type_array[QB_filter_field] == "percent") ||
                (field_type_array[QB_filter_field] == "double") ||
                (field_type_array[QB_filter_field] == "int") ||
                (field_type_array[QB_filter_field] == "boolean")) {
                    QB_filter_value_q = QB_filter_value;
            } else {
                QB_filter_value_q = '\\'' + QB_filter_value + '\\'';
            }

            soql_where += soql_where_logicOper + QB_filter_field + ' ' + QB_filter_compOper + ' ' + QB_filter_value_q;
        } else {
            break;
        }
    }
    soql_where = soql_where != '' ? ' WHERE ' + soql_where : '';

    var QB_orderby_field = document.getElementById('QB_orderby_field').value;
    var QB_orderby_sort = document.getElementById('QB_orderby_sort').value;
    var QB_nulls = document.getElementById('QB_nulls').value;
    if (QB_orderby_field) {
        var soql_orderby = ' ORDER BY ' + QB_orderby_field + ' ' + QB_orderby_sort;
        if (QB_nulls)
            soql_orderby = soql_orderby + ' NULLS ' + QB_nulls;
    } else
        var soql_orderby = '';


    var QB_limit_txt = document.getElementById('QB_limit_txt').value;
    if (QB_limit_txt)
        var soql_limit = ' LIMIT ' + QB_limit_txt;
    else
        var soql_limit = '';

    if (soql_select)
        document.getElementById('soql_query_textarea').value = soql_select + soql_where + soql_orderby + soql_limit ;

}


function addFilterRow(filterRowNum, defaultField, defaultCompOper, defaultValue) {
    //build the row inner html
    var row = filterRowNum == 0 ? "<br/>Filter results by:<br/>" : "" ;
    row +=     "<select id='QB_filter_field_" + filterRowNum + "' name='QB_filter_field_" + filterRowNum + "' style='width: 16em;' onChange='buildQuery();' onkeyup='buildQuery();'>" +
            "<option value=''></option>";
    
    for (var field in field_type_array) {
        row += "<option value='" + field + "'";
        if (defaultField == field) row += " selected='selected' ";
        row += "'>" + field + "</option>";
    }     
    
    row += "</select>&nbsp;" +
            "" +
            "<select id='QB_filter_compOper_" + filterRowNum + "' name='QB_filter_compOper_" + filterRowNum + "' style='width: 6em;' onChange='buildQuery();' onkeyup='buildQuery();'>";

    for (var opKey in compOper_array) {
        row += "<option value='" + opKey + "'";
        if (defaultCompOper == opKey) row += " selected='selected' ";
        row += ">" + compOper_array[opKey] + "</option>";
    } 
    
    defaultValue = defaultValue != null ? defaultValue : "";
    row +=  "</select>&nbsp;" +
            "<input type='text' id='QB_filter_value_" + filterRowNum + "' size='31' name='QB_filter_value_" + filterRowNum + "' value='" + defaultValue + "' onkeyup='buildQuery();' />";
            

    //add to the DOM
    var newFilterCell = document.createElement('td');
    newFilterCell.setAttribute('colSpan','4');
    newFilterCell.setAttribute('vAlign','top');
    newFilterCell.setAttribute('nowrap','true');
    newFilterCell.innerHTML = row;

    var newPlusCell = document.createElement('td');
    newPlusCell.setAttribute('id','filter_plus_cell_' + filterRowNum);
    newPlusCell.setAttribute('vAlign','bottom');
    newPlusCell.innerHTML = "<img id='filter_plus_button' src='" + getPathToStaticResource('/images/plus_icon.jpg') + "' onclick='addFilterRow(document.getElementById(\\"numFilters\\").value++);toggleFieldDisabled();' onmouseover='this.style.cursor=\\"pointer\\";'  style='padding-top: 4px;'/>";
    
    var newFilterRow = document.createElement('tr');
    newFilterRow.setAttribute('id','filter_row_' + filterRowNum);
    newFilterRow.appendChild(newFilterCell);
    newFilterRow.appendChild(newPlusCell);
    
    document.getElementById('QB_right_sub_table').getElementsByTagName("TBODY").item(0).appendChild(newFilterRow);
    
    if (filterRowNum > 0) {
        var filter_plus_button = document.getElementById('filter_plus_button');
        filter_plus_button.parentNode.removeChild(filter_plus_button);
    }
    
    //expand the field list so it looks right
    document.getElementById('QB_field_sel').size += 2;
}

function toggleMatrixSortSelectors(hasChanged) {
    if (exportActionIs('matrix')) {
        document.getElementById('matrix_selection_headers').style.display = '';
        document.getElementById('matrix_selection_row').style.display = '';
        document.getElementById('QB_field_sel').size += 4;
        
        if(hasChanged) buildQuery();
    } else if (document.getElementById('matrix_selection_headers').style.display == '') {
        document.getElementById('matrix_selection_headers').style.display = 'none';
        document.getElementById('matrix_selection_row').style.display = 'none';
        document.getElementById('QB_field_sel').size -= 4;
        
        if(hasChanged) buildQuery();
    }
    
    //don't do anything if moving from screen to csv
}

</script>
QUERY_BUILDER_SCRIPT;
    if (WorkbenchConfig::get()->value("autoJumpToResults")) {
        print "<form method='POST' id='query_form' name='query_form' action='#qr'>\n";
    } else {
        print "<form method='POST' id='query_form' name='query_form' action=''>\n";
    }
    print "<input type='hidden' name='justUpdate' value='0' />";
    print "<input type='hidden' id='numFilters' name='numFilters' value='" . count($queryRequest->getFilters()) . "' />";
    print "<p class='instructions'>Choose the object, fields, and critera to build a SOQL query below:</p>\n";
    print "<table border='0' style='width: 100%;'>\n";
    print "<tr><td valign='top' width='1'>Object:";
    printObjectSelection($queryRequest->getObject(), 'QB_object_sel', "16", "onChange='updateObject();'", "queryable");
    print "<p/>Fields:<select id='QB_field_sel' name='QB_field_sel[]' multiple='mutliple' size='4' style='width: 16em;' onChange='buildQuery();'>\n";
    if (isset($describeSObjectResult)) {
        print " <option value='count()'";
        if ($queryRequest->getFields() != null) {
            //check to make sure something is selected; otherwise warnings will display
            foreach ($queryRequest->getFields() as $selectedField) {
                if ('count()' == $selectedField) {
                    print " selected='selected' ";
                }
            }
        }
        print ">count()</option>\n";
        //print ">$field->name</option>\n";
        foreach ($describeSObjectResult->fields as $fields => $field) {
            print " <option value='{$field->name}'";
            if ($queryRequest->getFields() != null) {
                //check to make sure something is selected; otherwise warnings will display
                foreach ($queryRequest->getFields() as $selectedField) {
                    if ($field->name == $selectedField) {
                        print " selected='selected' ";
                    }
                }
            }
            print ">{$field->name}</option>\n";
        }
    }
    print "</select></td>\n";
    print "<td valign='top'>";
    print "<table border='0' align='right' style='width:100%'>\n";
    print "<tr><td valign='top' colspan=2>View as:<br/>" . "<label><input type='radio' id='export_action_screen' name='export_action' value='screen' ";
    if ($queryRequest->getExportTo() == 'screen') {
        print "checked='true'";
    }
    print " onClick='toggleMatrixSortSelectors(true);'>List</label>&nbsp;";
    print "<label><input type='radio' id='export_action_matrix' name='export_action' value='matrix' ";
    if ($queryRequest->getExportTo() == 'matrix') {
        print "checked='true'";
    }
    print " onClick='toggleMatrixSortSelectors(true);'>Matrix</label>";
    if (WorkbenchConfig::get()->value("allowQueryCsvExport")) {
        print "<label><input type='radio' id='export_action_csv' name='export_action' value='csv' ";
        if ($queryRequest->getExportTo() == 'csv') {
            print "checked='true'";
        }
        print " onClick='toggleMatrixSortSelectors(true);'>CSV</label>&nbsp;";
    }
    print "<label><input type='radio' id='export_action_async_csv' name='export_action' value='async_CSV' ";
    if ($queryRequest->getExportTo() == 'async_CSV') {
        print "checked='true'";
    }
    print " onClick='toggleMatrixSortSelectors(true);'>Bulk CSV</label>&nbsp;";
    print "<label><input type='radio' id='export_action_async_xml' name='export_action' value='async_XML' ";
    if ($queryRequest->getExportTo() == 'async_XML') {
        print "checked='true'";
    }
    print " onClick='toggleMatrixSortSelectors(true);'>Bulk XML</label>&nbsp;";
    print "<td valign='top' colspan=2>Deleted and archived records:<br/>" . "<label><input type='radio' name='query_action' value='Query' ";
    if ($queryRequest->getQueryAction() == 'Query') {
        print "checked='true'";
    }
    print " >Exclude</label>&nbsp;";
    print "<label><input type='radio' name='query_action' value='QueryAll' ";
    if ($queryRequest->getQueryAction() == 'QueryAll') {
        print "checked='true'";
    }
    print " >Include</label></td></tr></table>\n";
    print "<table id='QB_right_sub_table' border='0' align='right' style='width:100%'>\n";
    print "<tr id='matrix_selection_headers' style='display: none;'><td><br/>Columns:</td> <td><br/>Rows:</td> <td>&nbsp;</td></tr>\n";
    print "<tr id='matrix_selection_row' style='display: none;'><td><select id='matrix_cols' name='matrix_cols' style='width: 15em;' onChange='toggleFieldDisabled();buildQuery();' onkeyup='toggleFieldDisabled();buildQuery();'>";
    if (isset($fieldValuesToLabels)) {
        printSelectOptions(array_merge(array("" => ""), $fieldValuesToLabels), $queryRequest->getMatrixCols());
    }
    print "</select></td> <td><select id='matrix_rows' name='matrix_rows' style='width: 15em;' onChange='toggleFieldDisabled();buildQuery();' onkeyup='toggleFieldDisabled();buildQuery();'>";
    if (isset($fieldValuesToLabels)) {
        printSelectOptions(array_merge(array("" => ""), $fieldValuesToLabels), $queryRequest->getMatrixRows());
    }
    print "</select></td> <td><img onmouseover=\"Tip('Matrix view groups records into columns and rows of common field values.')\" align='absmiddle' src='" . getPathToStaticResource('/images/help16.png') . "'/></td></tr>\n";
    print "<tr id='sort_selection_headers'><td colspan='2'><br/>Sort results by:</td> <td><br/>Max Records:</td></tr>\n";
    print "<tr id='sort_selection_row'>";
    print "<td colspan='2'><select id='QB_orderby_field' name='QB_orderby_field' style='width: 16em;' onChange='buildQuery();'>\n";
    print "<option value=''></option>\n";
    if (isset($describeSObjectResult)) {
        foreach ($describeSObjectResult->fields as $fields => $field) {
            print " <option value='{$field->name}'";
            if ($queryRequest->getOrderByField() != null && $field->name == $queryRequest->getOrderByField()) {
                print " selected='selected' ";
            }
            print ">{$field->name}</option>\n";
        }
    }
    print "</select>\n";
    $qBOrderbySortOptions = array('ASC' => 'A to Z', 'DESC' => 'Z to A');
    print "<select id='QB_orderby_sort' name='QB_orderby_sort' style='width: 6em;' onChange='buildQuery();' onkeyup='buildQuery();'>\n";
    foreach ($qBOrderbySortOptions as $opKey => $op) {
        print "<option value='{$opKey}'";
        if (isset($_POST['QB_orderby_sort']) && $opKey == $_POST['QB_orderby_sort']) {
            print " selected='selected' ";
        }
        print ">{$op}</option>\n";
    }
    print "</select>\n";
    $qBNullsOptions = array('FIRST' => 'Nulls First', 'LAST' => 'Nulls Last');
    print "<select id='QB_nulls' name='QB_nulls' style='width: 10em;' onChange='buildQuery();' onkeyup='buildQuery();'>\n";
    foreach ($qBNullsOptions as $opKey => $op) {
        print "<option value='{$opKey}'";
        if ($queryRequest->getOrderByNulls() != null && $opKey == $queryRequest->getOrderByNulls()) {
            print " selected='selected' ";
        }
        print ">{$op}</option>\n";
    }
    print "</select></td>\n";
    print "<td><input type='text' id='QB_limit_txt' size='10' name='QB_limit_txt' value='" . htmlspecialchars($queryRequest->getLimit() != null ? $queryRequest->getLimit() : null, ENT_QUOTES) . "' onkeyup='buildQuery();' /></td>\n";
    print "</tr>\n";
    print "</table>\n";
    print "</td></tr>\n";
    $filterRowNum = 0;
    foreach ($queryRequest->getFilters() as $filter) {
        print "<script>addFilterRow(" . $filterRowNum++ . ", " . "\"" . $filter->getField() . "\", " . "\"" . $filter->getCompOper() . "\", " . "\"" . htmlspecialchars($filter->getValue(), ENT_QUOTES) . "\"" . ");</script>";
    }
    print "<tr><td valign='top' colspan=5><br/>Enter or modify a SOQL query below:\n" . "<br/><textarea id='soql_query_textarea' type='text' name='soql_query' rows='" . WorkbenchConfig::get()->value("textareaRows") . "' style='width: 99%; overflow: auto; font-family: monospace, courier;'>" . htmlspecialchars($queryRequest->getSoqlQuery(), ENT_QUOTES) . "</textarea>\n" . "</td></tr>\n";
    print "<tr><td colspan=1><input type='submit' name='querySubmit' class='disableWhileAsyncLoading' value='Query' onclick='return parentChildRelationshipQueryBlocker();' />\n" . "<input type='reset' value='Reset' class='disableWhileAsyncLoading' />\n" . "</td>";
    //save and retrieve named queries
    print "<td colspan=4 align='right'>";
    print "&nbsp;Run: " . "<select name='getQr' style='width: 10em;' onChange='document.query_form.submit();' class='disableWhileAsyncLoading'>" . "<option value='' selected='selected'></option>";
    if (isset($_SESSION['savedQueryRequests'])) {
        foreach ($_SESSION['savedQueryRequests'] as $qrName => $qr) {
            if ($qrName != null) {
                print "<option value='{$qrName}'>{$qrName}</option>";
            }
        }
    }
    print "</select>";
    print "&nbsp;&nbsp;Save as: <input type='text' id='saveQr' name='saveQr' value='" . htmlspecialchars($queryRequest->getName(), ENT_QUOTES) . "' style='width: 10em;'/>\n";
    print "<input type='submit' name='doSaveQr' value='Save' class='disableWhileAsyncLoading' onclick='return doesQueryHaveName();' />\n";
    print "<input type='submit' name='clearAllQr' value='Clear All' class='disableWhileAsyncLoading' onclick='return confirm(\"Are you sure you would like to clear all saved queries?\");'/>\n";
    print "&nbsp;&nbsp;" . "<img onmouseover=\"Tip('Save a query with a name and run it at a later time during your session. Note, if a query is already saved with the same name, the previous one will be overwritten.')\" align='absmiddle' src='" . getPathToStaticResource('/images/help16.png') . "'/>";
    print "</td></tr></table><p/>\n";
    print "<script>toggleFieldDisabled();toggleMatrixSortSelectors(false);</script>";
}
Exemplo n.º 13
0
?>


<div id='mainBlock'>

<div id='navMenu' style="clear: both;">
    <span class="preload1"></span>
    <span class="preload2"></span>
    <ul id="nav">
    <?php 
foreach ($GLOBALS["MENUS"] as $menu => $pages) {
    if (isReadOnlyMode() && $menu == "Data") {
        //special-case for Data menu, since all read-only
        continue;
    }
    $menuLabel = $menu == "WORKBENCH" ? "&nbsp;<img src='" . getPathToStaticResource('/images/workbench-3-cubed-white-small.png') . "'/>" : strtolower($menu);
    print "<li class='top'><a class='top_link'><span class='down'>" . $menuLabel . "</span></a>\n" . "<ul class='sub'>";
    foreach ($pages as $href => $page) {
        if (!$page->onNavBar || !isLoggedIn() && $page->requiresSfdcSession || isLoggedIn() && $page->title == 'Login' || !$page->isReadOnly && isReadOnlyMode()) {
            continue;
        }
        print "<li><a href='{$href}' onmouseover=\"Tip('{$page->desc}')\" target=\"" . $page->window . "\">{$page->title}</a></li>\n";
    }
    print "</ul></li>";
    if (!isLoggedIn() || !termsOk()) {
        break;
    }
    //only show first "Workbench" menu in these cases
}
?>
    </ul>
Exemplo n.º 14
0
?>
                </select>
            </p>
        </div>

        <div class="loginType_std loginType_oauth loginType_adv">
            <?php 
if ($c->getTermsFile()) {
    ?>
            <div style="margin-left: 95px;">
                <input type="checkbox" id="termsAccepted" name="termsAccepted"/>
                <label for="termsAccepted"><a href="terms.php" target="_blank">I agree to the terms of service</a></label>
            </div>
            <?php 
}
?>

            <p>
                <div style="text-align: right;">
                    <input type="submit" id="loginBtn" name="uiLogin" value="Login">
                </div>
            </p>
        </div>
    </form>
</div>
    
<?php 
addFooterScript("<script type='text/javascript' src='" . getPathToStaticResource('/script/login.js') . "'></script>");
addFooterScript("<script type='text/javascript'>wbLoginConfig=" . $c->getJsConfig() . "</script>");
addFooterScript("<script type='text/javascript'>WorkbenchLogin.initializeForm('" . htmlspecialchars($c->getLoginType()) . "');</script>");
require_once "footer.php";
Exemplo n.º 15
0
 function displayQueryResults($records, $queryTimeElapsed, QueryRequest $queryRequest)
 {
     if (is_numeric($records)) {
         $countString = "Query would return {$records} record";
         $countString .= $records == 1 ? "." : "s.";
         displayInfo($countString);
         return;
     }
     if (!$records) {
         displayWarning("Sorry, no records returned.");
         return;
     }
     if (WorkbenchConfig::get()->value("areTablesSortable")) {
         addFooterScript("<script type='text/javascript' src='" . getPathToStaticResource('/script/sortable.js') . "></script>");
     }
     print "<a name='qr'></a><div style='clear: both;'><br/><h2>Query Results</h2>\n";
     if (isset($this->queryLocator)) {
         preg_match("/-(\\d+)/", $this->queryLocator, $lastRecord);
         $rowOffset = $lastRecord[1];
     } else {
         $rowOffset = 0;
     }
     $minRowNum = $rowOffset + 1;
     $maxRowNum = $rowOffset + count($records);
     print "<p>Returned records {$minRowNum} - {$maxRowNum} of " . $this->totalQuerySize . " total record" . ($this->totalQuerySize !== 1 ? "s" : "") . " in " . sprintf("%01.3f", $queryTimeElapsed) . " seconds:</p>\n";
     if (!WorkbenchConfig::get()->value("autoRunQueryMore") && $this->nextQueryLocator) {
         print "<p><input type='hidden' name='queryLocator' value='" . $this->nextQueryLocator . "' /></p>\n";
         print "<p><input type='submit' name='queryMore' id='queryMoreButtonTop' value='More...' /></p>\n";
     }
     print addLinksToIds($queryRequest->getExportTo() == 'matrix' ? $this->createQueryResultsMatrix($records, $queryRequest->getMatrixCols(), $queryRequest->getMatrixRows()) : $this->createQueryResultTable($records, $minRowNum));
     if (!WorkbenchConfig::get()->value("autoRunQueryMore") && $this->nextQueryLocator) {
         print "<p><input type='hidden' name='queryLocator' value='" . $this->nextQueryLocator . "' /></p>\n";
         print "<p><input type='submit' name='queryMore' id='queryMoreButtonBottom' value='More...' /></p>";
     }
     print "</form></div>\n";
 }
Exemplo n.º 16
0
        displayWarning("Unknown object type");
    }
    WorkbenchContext::get()->setDefaultObject($specifiedType);
}
?>

<p class='instructions'>Choose an object to describe:</p>

<form name='describeForm' method='POST' action='describe.php'>
    <?php 
printObjectSelection(WorkbenchContext::get()->getDefaultObject(), 'default_object', 30, "onChange=\"document.getElementById('loadingMessage').style.visibility='visible'; document.describeForm.submit();\"");
?>

    <span id='loadingMessage' style='visibility:hidden; color:#888;'>
        &nbsp;&nbsp;<img src='<?php 
print getPathToStaticResource('/images/wait16trans.gif');
?>
' align='absmiddle'/> Loading...
    </span>

</form>
<br/>

<?php 
if (WorkbenchContext::get()->getDefaultObject()) {
    $describeSObjectResult = WorkbenchContext::get()->describeSObjects(WorkbenchContext::get()->getDefaultObject());
    $alwaysArrayChildren = array("recordTypeInfos", "childRelationships");
    foreach ($alwaysArrayChildren as $child) {
        if (isset($describeSObjectResult->{$child}) && !is_array($describeSObjectResult->{$child})) {
            $describeSObjectResult->{$child} = array($describeSObjectResult->{$child});
        }
Exemplo n.º 17
0
    print "<tr>" . "<td class='dataLabel'>API Processing</td><td class='dataValue'>" . $jobInfo->getApiActiveProcessingTime() . " ms</td>" . "<td class='dataLabel'>Apex Processing</td><td class='dataValue'>" . $jobInfo->getApexProcessingTime() . " ms</td>" . "<td class='dataLabel'>Total Processing</td><td class='dataValue'>" . $jobInfo->getTotalProcessingTime() . " ms</td>" . "</tr>";
}
print "<tr>" . "<td class='dataLabel'>Created</td><td class='dataValue'>" . localizeDateTimes($jobInfo->getCreatedDate(), $timeOnlyFormat) . "</td>" . "<td class='dataLabel'>Last Modified</td><td class='dataValue'>" . localizeDateTimes($jobInfo->getSystemModstamp(), $timeOnlyFormat) . "</td>" . "<td class='dataLabel'>Retries</td><td class='dataValue'>" . $jobInfo->getNumberRetries() . "</td>" . "</tr>";
print "</table>";
print "<p>&nbsp;</p>";
if (count($batchInfos) > 0) {
    print "<h3>Batches</h3>";
    print "<table cellpadding='4' width='100%' class='lightlyBoxed'>";
    print "<tr>" . "<th>&nbsp;</th>" . "<th>Id</th>" . "<th>Status</th>" . "<th>Processed</th>" . (WorkbenchContext::get()->isApiVersionAtLeast(19.0) ? "<th>Failed</th>" : "") . "<th>Created</th>" . "<th>Last Modified</th>" . "</tr>";
    foreach ($batchInfos as $batchInfo) {
        print "<tr><td class='dataValue'>";
        if ($batchInfo->getState() == "Completed" || $batchInfo->getState() == "Failed") {
            $batchResultList = array(null);
            // default to an array of one null
            if ($jobInfo->getOpertion() == 'query' && $batchInfo->getState() == "Completed") {
                $batchResultList = $asyncConnection->getBatchResultList($jobInfo->getId(), $batchInfo->getId());
            }
            foreach ($batchResultList as $resultId) {
                print "<a href='downloadAsyncBatch.php?op=result&jobId=" . $jobInfo->getId() . "&batchId=" . $batchInfo->getId() . "&resultId=" . $resultId . "'>" . "<img src='" . getPathToStaticResource('/images/downloadIcon' . $batchInfo->getState() . '.gif') . "' border='0' onmouseover=\"Tip('Download " . $batchInfo->getState() . " Batch Results')\"/>" . "</a><br/>";
            }
        } else {
            print "&nbsp;";
        }
        print "</td>";
        $processingTimeDetails = "API Processing: " . $batchInfo->getApiActiveProcessingTime() . " ms<br/>" . "Apex Processing: " . $batchInfo->getApexProcessingTime() . " ms<br/>" . "Total Processing: " . $batchInfo->getTotalProcessingTime() . " ms<br/>";
        print "<td class='dataValue'>" . (WorkbenchContext::get()->isApiVersionAtLeast(19.0) ? "<a href='downloadAsyncBatch.php?op=request&jobId=" . $jobInfo->getId() . "&batchId=" . $batchInfo->getId() . "' onmouseover=\"Tip('Download Batch Request')\"/>" . $batchInfo->getId() . "</a>" : $batchInfo->getId()) . "</td>" . "<td class='dataValue'>" . $batchInfo->getState() . ($batchInfo->getStateMessage() != "" ? ": " . $batchInfo->getStateMessage() : "") . "</td>" . (WorkbenchContext::get()->isApiVersionAtLeast(19.0) ? "<td class='dataValue pseudoLink' style='cursor: default' onmouseover=\"Tip('{$processingTimeDetails}')\"/>" : "<td class='dataValue'>") . $batchInfo->getNumberRecordsProcessed() . ($batchInfo->getNumberRecordsProcessed() == "1" ? " record" : " records") . "</td>" . (WorkbenchContext::get()->isApiVersionAtLeast(19.0) ? "<td class='dataValue'>" . $batchInfo->getNumberRecordsFailed() . ($batchInfo->getNumberRecordsFailed() == "1" ? " record" : " records") . "</td>" : "") . "<td class='dataValue'>" . localizeDateTimes($batchInfo->getCreatedDate(), $timeOnlyFormat) . "</td>" . "<td class='dataValue'>" . localizeDateTimes($batchInfo->getSystemModstamp(), $timeOnlyFormat) . "</td>";
        print "</tr>";
    }
    print "</table>";
}
include_once 'footer.php';