Exemple #1
0
function printZipper($zipper, $token)
{
    $string = '<pre>';
    $generator = new HTMLPurifier_Generator(HTMLPurifier_Config::createDefault(), new HTMLPurifier_Context());
    foreach ($zipper->front as $i => $t) {
        $string .= printToken($generator, $t, $i, false);
    }
    if ($token !== NULL) {
        $string .= printToken($generator, $token, "", true);
    }
    for ($i = count($zipper->back) - 1; $i >= 0; $i--) {
        $string .= printToken($generator, $zipper->back[$i], $i, false);
    }
    $string .= '</pre>';
    echo $string;
}
/**
 * Renders the page's HTML.
 *
 * @param Zend_OAuth_Token $token (optional) The user's current OAuth token.
 * @param array $feeds (optional) An array of Zend_Gdata_Feed to print
 *     information for.
 * @return void
 */
function renderHTML($token = null, $feeds = null)
{
    ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8 />
<link href="style.css" type="text/css" rel="stylesheet"/>
</head>
<body>
  <?php 
    if (!isset($_SESSION['ACCESS_TOKEN'])) {
        ?>
    <button onclick="location.href='<?php 
        echo "{$APP_URL}?action=request_token";
        ?>
';">Grant Access to this app!</button>
  <?php 
    } else {
        ?>
    <div id="token_info">
      <span style="float:left;"><img src="http://code.google.com/apis/accounts/images/oauth_icon.png"></span>
      <div id="token"><?php 
        printToken($token);
        ?>
</div>
    </div>
    <div id="logout"><a href="<?php 
        echo "{$APP_URL}?action=logout";
        ?>
">Logout</a></div>
    <div style="clear:both;">
      <div id="doclist">
        <h4>First 100 documents from the <a href="http://code.google.com/apis/documents/" target="_new">Documents List Data API</a>:</h4>
        <div class="feed"><?php 
        printFeed($feeds[0]);
        ?>
</div>
      </div>
      <div id="spreadsheets">
        <h4>First 100 spreadsheets from the <a href="http://code.google.com/apis/spreadsheets/" target="_new">Spreadsheets Data API</a>:</h4>
        <div class="feed"><?php 
        printFeed($feeds[1]);
        ?>
</div>
      </div>
    </div>
  <?php 
    }
    ?>
</body>
</html>
<?php 
}