Ejemplo n.º 1
0
/**
 * Processes loading of this sample code through a web browser.
 */
function runWWWVersion()
{
    session_start();

    // Note that all calls to endHTML() below end script execution!

    global $_SESSION, $_GET;
    if (!isset($_SESSION['docsSampleSessionToken']) && !isset($_GET['token'])) {
        requestUserLogin('Please login to your Google Account.');
    } else {
        $client = getAuthSubHttpClient();
        $docs = new Zend_Gdata_Docs($client);

        // First we check for commands that can be submitted either though
        // POST or GET (they don't make any changes).
        if (!empty($_REQUEST['command'])) {
            switch ($_REQUEST['command']) {
                case 'retrieveAllDocuments':
                    startHTML();
                    retrieveAllDocuments($docs, true);
                    endHTML(true);
                case 'retrieveWPDocs':
                    startHTML();
                    retrieveWPDocs($docs, true);
                    endHTML(true);
                case 'retrieveSpreadsheets':
                    startHTML();
                    retrieveSpreadsheets($docs, true);
                    endHTML(true);
                case 'fullTextSearch':
                    startHTML();
                    fullTextSearch($docs, true, $_REQUEST['query']);
                    endHTML(true);
                    
            }
        }
    
        // Now we handle the potentially destructive commands, which have to
        // be submitted by POST only.
        if (!empty($_POST['command'])) {
            switch ($_POST['command']) {
                case 'uploadDocument':
                    startHTML();
                    uploadDocument($docs, true, 
                        $_FILES['uploadedFile']['name'], 
                        $_FILES['uploadedFile']['tmp_name']);
                    endHTML(true);
                case 'modifySubscription':
                    if ($_POST['mode'] == 'subscribe') {
                        startHTML();
                        endHTML(true);
                    } elseif ($_POST['mode'] == 'unsubscribe') {
                        startHTML();
                        endHTML(true);
                    } else {
                        header('HTTP/1.1 400 Bad Request');
                        startHTML();
                        echo "<h2>Invalid mode.</h2>\n";
                        echo "<p>Please check your request and try again.</p>";
                        endHTML(true);
                    }
            }
        }
    
        // Check for an invalid command. If so, display an error and exit.
        if (!empty($_REQUEST['command'])) {
            header('HTTP/1.1 400 Bad Request');
            startHTML();
            echo "<h2>Invalid command.</h2>\n";
            echo "<p>Please check your request and try again.</p>";
            endHTML(true);
        }
        // If a menu parameter is available, display a submenu.
    
        if (!empty($_REQUEST['menu'])) {
            switch ($_REQUEST['menu']) {
                case 'list':
                    startHTML();
                    displayListMenu();
                    endHTML();
                case 'query':
                    startHTML();
                    displayQueryMenu();
                    endHTML();
                case 'upload':
                    startHTML();
                    displayUploadMenu();
                    endHTML();
                case 'logout':
                    startHTML(false);
                    logout();
                    endHTML();
                default:
                    header('HTTP/1.1 400 Bad Request');
                    startHTML();
                    echo "<h2>Invalid menu selection.</h2>\n";
                    echo "<p>Please check your request and try again.</p>";
                    endHTML(true);
            }
        }
        // If we get this far, that means there's nothing to do. Display
        // the main menu.
        // If no command was issued and no menu was selected, display the
        // main menu.
        startHTML();
        displayMenu();
        endHTML();
    }
}
Ejemplo n.º 2
0
    $session = $client->getSession('Administrator', 'Administrator');
    $answer = $session->newRequest("Document.Query")->set('params', 'query', "SELECT * FROM Document WHERE ecm:fulltext = '" . $research . "'")->sendRequest();
    $documentsArray = $answer->getDocumentList();
    $value = sizeof($documentsArray);
    echo '<table>';
    echo '<tr><TH>uid</TH><TH>Path</TH>
		<TH>Type</TH><TH>State</TH><TH>Title</TH><TH>Download as PDF</TH>';
    for ($test = 0; $test < $value; $test++) {
        echo '<tr>';
        echo '<td> ' . current($documentsArray)->getUid() . '</td>';
        echo '<td> ' . current($documentsArray)->getPath() . '</td>';
        echo '<td> ' . current($documentsArray)->getType() . '</td>';
        echo '<td> ' . current($documentsArray)->getState() . '</td>';
        echo '<td> ' . current($documentsArray)->getTitle() . '</td>';
        echo '<td><form id="test" action="./B5bis.php" method="post" >';
        echo '<input type="hidden" name="data" value="' . current($documentsArray)->getPath() . '"/>';
        echo '<input type="submit" value="download"/>';
        echo '</form></td></tr>';
        next($documentsArray);
    }
    echo '</table>';
}
if (!isset($_POST['research']) or empty($_POST['research'])) {
    echo 'research is empty';
} else {
    fullTextSearch($_POST['research']);
}
?>
</body>
</html>