public function indexAction()
 {
     $content = new Content();
     $slug = $this->_getParam('slug');
     if ($slug == '\\d+') {
         $content = new Content();
         $this->view->contents = $content->getFrontContent('treports');
         $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
         $client = Zend_Gdata_ClientLogin::getHttpClient($this->_config->webservice->google->username, $this->_config->webservice->google->password, $service);
         $docs = new Zend_Gdata_Docs($client);
         $docsQuery = new Zend_Gdata_Docs_Query();
         $docsQuery->setQuery('title:Treasure Annual Report');
         $feed = $docs->getDocumentListFeed($docsQuery);
         $documents = array();
         foreach ($feed->entries as $entry) {
             $title = $entry->title;
             foreach ($entry->link as $link) {
                 if ($link->getRel() === 'alternate') {
                     $altlink = $link->getHref();
                 }
             }
             $documents[] = array('title' => $title, 'altlink' => $altlink, 'updated' => $entry->updated, 'type' => $entry->content->type, 'published' => $entry->published);
         }
         $this->view->documents = $documents;
     } else {
         $this->view->contents = $content->getContent('treports', $this->_getParam('slug'));
     }
 }
Exemple #2
0
 /**
  * Save PHPExcel to file
  *
  * @param	string		$pFileName
  * @throws	Exception
  */
 public function save($pFilename = null)
 {
     parent::save($pFilename);
     $googleDocsClient = Zend_Gdata_ClientLogin::getHttpClient($this->_username, $this->_password, Zend_Gdata_Docs::AUTH_SERVICE_NAME);
     $googleDocsService = new Zend_Gdata_Docs($googleDocsClient);
     $googleDocsService->uploadFile($pFilename, basename($pFilename), null, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);
     @unlink($pFilename);
 }
 /** Render documents on the index page
  */
 public function indexAction()
 {
     $content = new Content();
     $this->view->contents = $content->getFrontContent('publications');
     $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
     $client = Zend_Gdata_ClientLogin::getHttpClient($this->_helper->config->webservice->google->username, $this->_config->webservice->google->password, $service);
     $docs = new Zend_Gdata_Docs($client);
     $feed = $docs->getDocumentListFeed();
     $documents = array();
     foreach ($feed->entries as $entry) {
         $title = $entry->title;
         foreach ($entry->link as $link) {
             if ($link->getRel() === 'alternate') {
                 $altlink = $link->getHref();
             }
         }
         $documents[] = array('title' => $title, 'altlink' => $altlink, 'updated' => $entry->updated, 'type' => $entry->content->type, 'published' => $entry->published);
     }
     $this->view->documents = $documents;
 }
 function testUploadGdocAction()
 {
     $this->disableLayout();
     $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
     $client = Zend_Gdata_ClientLogin::getHttpClient("*****@*****.**", "W1sedsuk0l", $service);
     $docs = new Zend_Gdata_Docs($client);
     $file = "D:auditor\\data\filesauditor\\mastermanagement\\WebSSO_Activity_Plan_08082554__3_.xls";
     chmod($file, 0755);
     $newDocumentEntry = $docs->uploadFile($file, "2_Masrter_Management_100811__4__3.pdf", null, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);
     $this->render('blank', null, true);
     // Find the URL of the HTML view of this document.
     $alternateLink = '';
     foreach ($newDocumentEntry->link as $link) {
         if ($link->getRel() === 'alternate') {
             $alternateLink = $link->getHref();
         }
     }
     // Make the title link to the document on docs.google.com.
     echo "<a href=\"{$alternateLink}\">\n";
 }
 public function export($formName, $options = null)
 {
     $this->setOptions($options);
     // Security Check
     if (!$this->isAuthorized()) {
         $this->assertSecurityErrorMessage();
         return;
     }
     // Headers
     $this->echoHeaders('Content-Type: text/html; charset=UTF-8');
     if (!CFDBCheckZendFramework::checkIncludeZend()) {
         return;
     }
     Zend_Loader::loadClass('Zend_Gdata');
     Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
     //Zend_Loader::loadClass('Zend_Gdata_Spreadsheets');
     Zend_Loader::loadClass('Zend_Gdata_App_AuthException');
     Zend_Loader::loadClass('Zend_Http_Client');
     Zend_Loader::loadClass('Zend_Gdata_Docs');
     $guser = $options['guser'];
     $gpwd = $options['gpwd'];
     try {
         $client = Zend_Gdata_ClientLogin::getHttpClient($guser, $gpwd, Zend_Gdata_Docs::AUTH_SERVICE_NAME);
         //Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME
     } catch (Zend_Gdata_App_AuthException $ae) {
         CFDBDie::wp_die("<p>Login failed for: '{$guser}' </p><p>Error: " . $ae->getMessage() . '</p>', __('Login Failed', 'contact-form-7-to-database-extension'), array('response' => 200, 'back_link' => true));
     }
     try {
         // Generate CSV file contents into buffer
         $exporter = new ExportToCsvUtf8();
         $exporter->setOptions($options);
         $exporter->setCommonOptions();
         $exporter->setUseBom(false);
         ob_start();
         $exporter->echoCsv($formName);
         $csvFileContents = ob_get_contents();
         ob_end_clean();
         // Put the contents in a tmp file because Google upload API only reads from a file
         $tmpfname = tempnam(sys_get_temp_dir(), "{$formName}.csv");
         $handle = fopen($tmpfname, 'w');
         fwrite($handle, $csvFileContents);
         fclose($handle);
         // Upload the tmp file to Google Docs
         $docs = new Zend_Gdata_Docs($client);
         $newDocumentEntry = $docs->uploadFile($tmpfname, $formName, 'text/csv');
         unlink($tmpfname);
         // delete tmp file
         // Get the URL of the new Google doc
         $alternateLink = '';
         foreach ($newDocumentEntry->link as $link) {
             if ($link->getRel() === 'alternate') {
                 $alternateLink = $link->getHref();
                 break;
             }
         }
         //header("Location: $alternateLink");
         //$title = $newDocumentEntry->title;
         $title = __('New Google Spreadsheet', 'contact-form-7-to-database-extension');
         $output = utf8_encode("{$title}: <a target=\"_blank\" href=\"{$alternateLink}\">") . $formName . utf8_encode('</a>');
         CFDBDie::wp_die($output, $title, array('response' => 200, 'back_link' => true));
     } catch (Exception $ex) {
         CFDBDie::wp_die($ex->getMessage() . '<pre>' . $ex->getTraceAsString() . '</pre>', __('Error', 'contact-form-7-to-database-extension'), array('back_link' => true));
     }
 }
Exemple #6
0
/**
 * Upload the specified document
 *
 * @param Zend_Gdata_Docs $docs The service object to use for communicating
 *     with the Google Documents server.
 * @param boolean $html True if output should be formatted for display in a
 *     web browser.
 * @param string $originalFileName The name of the file to be uploaded. The
 *     mime type of the file is determined from the extension on this file
 *     name. For example, test.csv is uploaded as a comma seperated volume
 *     and converted into a spreadsheet.
 * @param string $temporaryFileLocation (optional) The file in which the
 *     data for the document is stored. This is used when the file has been
 *     uploaded from the client's machine to the server and is stored in
 *     a temporary file which does not have an extension. If this parameter
 *     is null, the file is read from the originalFileName.
 */
function uploadDocument($docs, $html, $originalFileName,
                        $temporaryFileLocation) {
  $fileToUpload = $originalFileName;
  if ($temporaryFileLocation) {
    $fileToUpload = $temporaryFileLocation;
  }

  // Upload the file and convert it into a Google Document. The original
  // file name is used as the title of the document and the mime type
  // is determined based on the extension on the original file name.
  $newDocumentEntry = $docs->uploadFile($fileToUpload, $originalFileName,
      null, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);

  echo "New Document Title: ";

  if ($html) {
      // Find the URL of the HTML view of this document.
      $alternateLink = '';
      foreach ($newDocumentEntry->link as $link) {
          if ($link->getRel() === 'alternate') {
              $alternateLink = $link->getHref();
          }
      }
      // Make the title link to the document on docs.google.com.
      echo "<a href=\"$alternateLink\">\n";
  }
  echo $newDocumentEntry->title."\n";
  if ($html) {echo "</a>\n";}
}
    case 'logout':
        logout($APP_URL);
        break;
    case 'request_token':
        $_SESSION['REQUEST_TOKEN'] = serialize($consumer->fetchRequestToken(implode(' ', $scopes), $APP_URL . '?action=access_token'));
        $consumer->authorizeRequestToken();
        break;
    case 'access_token':
        $_SESSION['ACCESS_TOKEN'] = serialize($consumer->fetchAccessToken());
        header('Location: ' . $APP_URL);
        break;
    default:
        if (isset($_SESSION['ACCESS_TOKEN'])) {
            $accessToken = unserialize($_SESSION['ACCESS_TOKEN']);
            $httpClient = $accessToken->getHttpClient($consumer->getOauthOptions());
            $docsService = new Zend_Gdata_Docs($httpClient, $APP_NAME);
            $spreadsheetsService = new Zend_Gdata_Spreadsheets($httpClient, $APP_NAME);
            // Retrieve user's list of Google Docs and spreadsheet list.
            $docsFeed = $docsService->getDocumentListFeed();
            $spreadsheetFeed = $spreadsheetsService->getSpreadsheetFeed('http://spreadsheets.google.com/feeds/spreadsheets/private/full?max-results=100');
            renderHTML($accessToken, array($docsFeed, $spreadsheetFeed));
        } else {
            renderHTML();
        }
}
/**
 * Returns a the base URL of the current running web app.
 *
 * @return string
 */
function getAppURL()
Exemple #8
0
        header('Location: ' . $redirect);
    }
}
$request_token = @$_REQUEST['openid_ext2_request_token'];
if ($request_token) {
    $data = array();
    $httpClient = new Zend_Gdata_HttpClient();
    $access_token = getAccessToken($request_token);
    // Query the Documents API ===================================================
    $feedUri = 'http://docs.google.com/feeds/documents/private/full';
    $params = array('max-results' => 50, 'strict' => 'true');
    $req = OAuthRequest::from_consumer_and_token($consumer, $access_token, 'GET', $feedUri, $params);
    $req->sign_request($sig_method, $consumer, $access_token);
    // Note: the Authorization header changes with each request
    $httpClient->setHeaders($req->to_header());
    $docsService = new Zend_Gdata_Docs($httpClient);
    $query = $feedUri . '?' . implode_assoc('=', '&', $params);
    $feed = $docsService->getDocumentListFeed($query);
    $data['docs']['html'] = listEntries($feed);
    $data['docs']['xml'] = $feed->saveXML();
    // ===========================================================================
    // Query the Spreadsheets API ================================================
    $feedUri = 'http://spreadsheets.google.com/feeds/spreadsheets/private/full';
    $params = array('max-results' => 50);
    $req = OAuthRequest::from_consumer_and_token($consumer, $access_token, 'GET', $feedUri, $params);
    $req->sign_request($sig_method, $consumer, $access_token);
    // Note: the Authorization header changes with each request
    $httpClient->setHeaders($req->to_header());
    $spreadsheetsService = new Zend_Gdata_Spreadsheets($httpClient);
    $query = $feedUri . '?' . implode_assoc('=', '&', $params);
    $feed = $spreadsheetsService->getSpreadsheetFeed($query);