public function gdata_insert_row() { ProjectConfiguration::registerZend(); Zend_Loader::loadClass('Zend_Gdata_AuthSub'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); Zend_Loader::loadClass('Zend_Gdata_Spreadsheets'); Zend_Loader::loadClass('Zend_Gdata_Docs'); $username = "******"; $password = "******"; //Chave do arquivo $key = "0Ak_oCZQf3sTidEJnZGQ4MHdhS0R1NUlSeG1ORkpnalE"; //Carregando o serviço do arquivo $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME; $client = Zend_Gdata_ClientLogin::getHttpClient($username, $password, $service); $spreadSheetService = new Zend_Gdata_Spreadsheets($client); //Pegando as planilhas do arquivo $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); $query->setSpreadsheetKey($key); $feed = $spreadSheetService->getWorksheetFeed($query); //Escolhendo a planilha correta foreach ($feed->entries as $entry) { if ($entry->getTitle() == 'Disponiveis') { $worksheetId = basename($entry->getId()); } } //Configura variaveis da nova linha na planilha $assoc = $this->getAssociado(); $matricula = $this->isTitular() ? $assoc->getMatricula() : $assoc->getTitular()->getMatricula(); $dependenteId = $this->isDependente() ? $assoc->getId() : '0'; //Monta array para o serviço do arquivo $rowData = array("data" => $this->getDateTimeObject('created_at')->format('Y-m-d'), "matricula" => $matricula, "nome" => $assoc->getNome(), "dependenteid" => $dependenteId, "encaminhaid" => $this->getId()); //Insere na Planilha $insertedListEntry = $spreadSheetService->insertRow($rowData, $key, $worksheetId); }
public function getRows() { $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); $query->setSpreadsheetKey($this->spreadsheetId); $feed = $this->spreadsheetService->getWorksheetFeed($query); return $feed->entries[0]->getContentsAsRows(); }
public function changeWorksheet($name) { $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); $query->setSpreadsheetKey($this->currKey); $feed = $this->gdClient->getWorksheetFeed($query); $index = $this->getIndexOf($name, $feed); $currWkshtId = split('/', $feed->entries[$index]->id->text); $this->currWkshtId = $currWkshtId[8]; }
public function promptForWorksheet() { $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); $query->setSpreadsheetKey($this->currKey); $feed = $this->gdClient->getWorksheetFeed($query); $this->printFeed($feed); $input = getInput("\nSelection"); $currWkshtId = split('/', $feed->entries[$input]->id->text); $this->currWkshtId = $currWkshtId[8]; }
* @return void */ public function __construct($email, $password) { try { $client = Zend_Gdata_ClientLogin::getHttpClient($email, $password, Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME); } catch (Zend_Gdata_App_AuthException $ae) { exit("Error: " . $ae->getMessage() . "\nCredentials provided were email: [{$email}] and password [{$password}].\n"); } $this->gdClient = new Zend_Gdata_Spreadsheets($client); $this->currKey = '1xCULJMNvPsDm95Nnqy2l7hjUwKlz5_SiutyeozKswFY';
public function postUpdate($values) { //clear cache #@exec("rm /var/frontend/web/cache/".str_replace("http://", "", $this->Asset->retriveUrl2())); set_time_limit(0); error_reporting(E_ALL); ini_set('display_errors', '1'); $clientLibraryPath = sfConfig::get('sf_lib_dir') . '/vendor/ZendGdata-1.11.11/library'; $oldPath = set_include_path($clientLibraryPath); // load Zend Gdata libraries require_once sfConfig::get('sf_lib_dir') . '/vendor/ZendGdata-1.11.11/library/Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata_Spreadsheets'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); // set credentials for ClientLogin authentication $user = "******"; $pass = "******"; //die($this->getSpreadsheetId()."<br>".$this->getWorksheetId()); try { // connect to API $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME; $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); $service = new Zend_Gdata_Spreadsheets($client); // get worksheet entry $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); $query->setSpreadsheetKey($this->getSpreadsheetId()); $query->setWorksheetId($this->getWorksheetId()); $wsEntry = $service->getWorksheetEntry($query); $title = new Zend_Gdata_App_Extension_Title($this->getQuestion()); $wsEntry->setTitle($title); // update entry $entryResult = $service->updateEntry($wsEntry, $wsEntry->getLink('edit')->getHref()); echo 'The ID of the updated worksheet entry is: ' . $entryResult->id; } catch (Exception $e) { die('ERROR: ' . $e->getMessage()); } }
public function resizeWorksheet($newRowCount, $newColumnCount) { $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); $query->setSpreadsheetKey($this->currKey); $query->setWorksheetId($this->currWkshtId); $currentWorksheet = $this->gdClient->getWorksheetEntry($query); $currentWorksheet = $currentWorksheet->setRowCount(new Zend_Gdata_Spreadsheets_Extension_RowCount($newRowCount)); $currentWorksheet = $currentWorksheet->setColumnCount(new Zend_Gdata_Spreadsheets_Extension_ColCount($newColumnCount)); $currentWorksheet->save(); $this->getRowAndColumnCount(); print "Worksheet has been resized to $this->rowCount rows and $this->columnCount columns.\n"; return true; }
function getSpreadsheetId() { try { // connect to API $httpClient = $accessToken->getHttpClient($oauthOptions); $client = new Zend_Gdata_Docs($httpClient, "leopizzo991"); ///$token = new Zend_Oauth_Token_Access(); $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME; //$client = Zend_Gdata_ClientLogin::getHttpClient("leopizzodb", "l30p1z04d", $service); $service = new Zend_Gdata_Spreadsheets($client); // get list of available spreadsheets $feed = $service->getSpreadsheetFeed(); } catch (Exception $e) { die('ERROR: ' . $e->getMessage()); } foreach ($feed->entries as $entry) { $spreadsheetURL = $entry->id; } $spreadsheetKey = basename($spreadsheetURL); $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); $query->setSpreadsheetKey($spreadsheetKey); $feed = $service->getWorksheetFeed($query); //echo "Spreadsheet Key: <strong>$spreadsheetKey</strong> <br>"; foreach ($feed as $entry) { $sName = $entry->title->text; echo "ID of sheet {$sName} is: <strong>" . basename($entry->id) . "</strong><br>"; } }
function check_ipn() { global $wpdb, $purchase_log, $wpsc_cart; $wpcb_atos = get_option('wpcb_atos'); $wpcb_general = get_option('wpcb_general'); $wpcb_dev = get_option('wpcb_dev'); $purch_log_email = get_option('purch_log_email'); if (!$purch_log_email) { $purch_log_email = get_bloginfo('admin_email'); } // Automatic Response ATOS : if ($_GET['ipn'] == 'atos') { if (array_key_exists('mode_demo', $wpcb_dev) && $wpcb_dev['mode_demo']) { // Ce Kit de demo a du vous etre envoyé par la banque $pathfile = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/cgi-bin/demo/pathfile"; $path_bin_response = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/cgi-bin/demo/response"; $logfile = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/cgi-bin/demo/logfile.txt"; } else { $pathfile = $wpcb_atos['pathfile']; $path_bin_response = $wpcb_atos['path_bin_response']; $logfile = $wpcb_atos['logfile']; } // Initialisation du chemin du fichier de log : if (isset($_POST['DATA'])) { $data = escapeshellcmd($_POST['DATA']); $message = "message={$data}"; $pathfile = "pathfile=" . $pathfile; if (isset($_POST['sandbox'])) { $result = $_POST['sandbox']; } else { $result = exec("{$path_bin_response} {$pathfile} {$message}"); } $tableau = explode("!", $result); $response = array('code' => $tableau[1], 'error' => $tableau[2], 'merchantid' => $tableau[3], 'merchantcountry' => $tableau[4], 'amount' => $tableau[5], 'transactionid' => $tableau[6], 'paymentmeans' => $tableau[7], 'transmissiondate' => $tableau[8], 'paymenttime' => $tableau[9], 'paymentdate' => $tableau[10], 'responsecode' => $tableau[11], 'paymentcertificate' => $tableau[12], 'authorisationid' => $tableau[13], 'currencycode' => $tableau[14], 'cardnumber' => $tableau[15], 'cvvflag' => $tableau[16], 'cvvresponsecode' => $tableau[17], 'bankresponsecode' => $tableau[18], 'complementarycode' => $tableau[19], 'complementaryinfo' => $tableau[20], 'returncontext' => $tableau[21], 'caddie' => $tableau[22], 'receiptcomplement' => $tableau[23], 'merchantlanguage' => $tableau[24], 'language' => $tableau[25], 'customerid' => $tableau[26], 'orderid' => $tableau[27], 'customeremail' => $tableau[28], 'customeripaddress' => $tableau[29], 'captureday' => $tableau[30], 'capturemode' => $tableau[31], 'data' => $tableau[32]); //Session id used by wp ecommerce : $sessionid = $response['orderid']; // A venir : Ajout dans un google spreadsheet qui a toutes les entêtes précédentes (requis Zend) // A coler dans la page admin pour tester if (WP_ZEND_FRAMEWORK) { $GoogleConnection = true; $SpreadSheetConnection = true; try { $client = Zend_Gdata_ClientLogin::getHttpClient($wpcb_general['googleemail'], $wpcb_general['googlepassword']); } catch (Zend_Gdata_App_AuthException $ae) { echo $ae->exception(); $GoogleConnection = false; } if ($GoogleConnection) { // Test $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME; $client = Zend_Gdata_ClientLogin::getHttpClient($wpcb_general['googleemail'], $wpcb_general['googlepassword'], $service); // On va chercher le numéro de la feuille : $query_worksheet = new Zend_Gdata_Spreadsheets_DocumentQuery(); // todo pour pas de client ici ? $query_worksheet->setSpreadsheetKey($wpcb_general['spreadsheetKey']); $spreadsheetService = new Zend_Gdata_Spreadsheets($client); try { $feed = $spreadsheetService->getWorksheetFeed($query_worksheet); } catch (Zend_Gdata_App_HttpException $ae) { echo $ae->exception(); $SpreadSheetConnection = false; } if ($SpreadSheetConnection) { // Tout bon on ajoute : foreach ($feed->entries as $entry) { if ($entry->title->text == 'CB') { $worksheetId_CB = basename($entry->id); } elseif ($entry->title->text == 'Paypal') { $worksheetId_Paypal = basename($entry->id); } } $spreadsheetService = new Zend_Gdata_Spreadsheets($client); // Insert row in google spreadsheet : $insertedListEntry = $spreadsheetService->insertRow($response, $wpcb_general['spreadsheetKey'], $worksheetId_CB); } else { wp_mail($purch_log_email, 'Email envoyé depuis le auto_response', 'Mauvais Numero de Spreadsheet dans les options du plugin wpcb'); } } else { if (WP_DEBUG) { wp_mail($purch_log_email, 'Email envoyé depuis le auto_response', 'Mauvais login/mot de pass google dans les options du plugin wpcb'); } } } else { wp_mail($purch_log_email, 'Email envoyé depuis le auto_response', 'Installer Zend pour ajouter automatiquement les ventes à google drive !'); } // analyse du code retour if (isset($_POST['sandbox'])) { $message = "-----------SANDBOX-------------------------\n"; foreach ($response as $k => $v) { $message .= $k . " = " . $v . "\n"; } $message .= "-------------------------------------------\n"; if ($logfile) { $fp = fopen($logfile, "a"); fwrite($fp, $message); fclose($fp); } echo $message; wp_mail($purch_log_email, 'Email pour vous dire qu\'un paiement SANDBOX est arrivé !', $message); } else { //Vrai achat ! if ($response['code'] == "" && $response['error'] == "") { $message = "erreur appel response\n executable response non trouve {$path_bin_response}\n Session Id : {$sessionid}"; if ($logfile) { $fp = fopen($logfile, "a"); // Ouverture du fichier de log en append fwrite($fp, $message); fclose($fp); } if (WP_DEBUG) { wp_mail($purch_log_email, 'Email envoyé depuis le auto_response car il y a une erreur avec un paiement Atos', $message); } $wpdb->query("UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `processed`= '5' WHERE `sessionid`=" . $sessionid); $wpsc_cart->empty_cart(); } elseif ($response['code'] != 0) { $message = " API call error.\n Error message : {$error}\n Session Id : {$sessionid}"; if ($logfile) { // Ouverture du fichier de log en append $fp = fopen($logfile, "a"); fwrite($fp, $message); fclose($fp); } if (WP_DEBUG) { wp_mail($purch_log_email, 'Email envoyé depuis le auto_response car il y a une erreur avec un paiement Atos', $message); } $wpdb->query("UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `processed`= '5' WHERE `sessionid`=" . $sessionid); $wpsc_cart->empty_cart(); } else { // Ok, Sauvegarde dans la base de donnée du shop. if ($response_code == 00) { $message = "-----------SALES----------------------------\n"; foreach ($response as $k => $v) { $message .= $k . " = " . $v . "\n"; } $message .= "-------------------------------------------\n"; if ($logfile) { $fp = fopen($logfile, "a"); fwrite($fp, $message); fclose($fp); } if (WP_DEBUG) { wp_mail($purch_log_email, 'Email pour vous dire qu\'un paiement est arrivé !', $message); } $wpdb->query("UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `processed`= '3' WHERE `sessionid`=" . $sessionid); $purchase_log = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= " . $sessionid . " LIMIT 1", ARRAY_A); // Ne pas enlever car global ! $wpsc_cart->empty_cart(); // Peut-être faut-il ici decrease stock ??? // redirect -> transaction_results($sessionid, false); // false -> no echo ! // The cart is emptied in this function a condition d'avoir la global $wpsc_cart ! } } } // Fin du vrai achat } else { if (WP_DEBUG) { wp_mail($purch_log_email, 'Qqn a accéder à cette page sans utiliser le module de CB', 'Rien de grave, c\'est peut-etre un robot google !'); } } } elseif ($_GET['ipn'] == 'systempaycyberplus') { $message = ''; foreach ($_POST as $key => $value) { $message .= $key . '->' . $value . "\n"; } mail($purch_log_email, 'ipn systempay cyberplus', $message); $wpcb_systempaycyberplus = get_option('wpcb_systempaycyberplus'); $control = Check_Signature(uncharm($_POST), $wpcb_systempaycyberplus['certificat']); if ($control == 'true') { $sessionid = $_POST['vads_order_id']; if ($_POST['vads_result'] == "00") { switch ($_POST['vads_auth_mode']) { case "FULL": $wpdb->query("UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `processed`= '3' WHERE `sessionid`=" . $sessionid); $purchase_log = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= " . $sessionid . " LIMIT 1", ARRAY_A); // Ne pas enlever car global ! $wpsc_cart->empty_cart(); // Peut-être faut-il ici decrease stock ??? // redirect -> transaction_results($sessionid, false); break; case "MARK": break; } } else { //failed $wpdb->query("UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `processed`= '5' WHERE `sessionid`=" . $sessionid); $wpsc_cart->empty_cart(); //http://matale.fr/?cbListener=systempay_cyberplus&mode=test } } else { mail($purch_log_email, 'ipn systempay cyberplus signature non valide', $message); } if ($transauthorised == false) { } } elseif ($_GET['ipn'] == 'paypal') { $wpcb_paypal = get_option('wpcb_paypal'); // Initialisation du chemin du fichier de log : error_reporting(E_ALL ^ E_NOTICE); $header = ""; $emailtext = ""; // Read the post from PayPal and add 'cmd' $req = 'cmd=_notify-validate'; if (function_exists('get_magic_quotes_gpc')) { $get_magic_quotes_exits = true; } foreach ($_POST as $key => $value) { // Handle escape characters, which depends on setting of magic quotes if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) { $value = urlencode(stripslashes($value)); } else { $value = urlencode($value); } $req .= "&{$key}={$value}"; } // Post back to PayPal to validate $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; if ($wpcb_paypal['sandbox_paypal']) { $fp = fsockopen('ssl://sandbox.paypal.com', 443, $errno, $errstr, 30); } else { $fp = fsockopen('ssl://www.paypal.com', 443, $errno, $errstr, 30); } // Process validation from PayPal if (!$fp) { // HTTP ERROR } else { // NO HTTP ERROR fputs($fp, $header . $req); while (!feof($fp)) { $res = fgets($fp, 1024); if (strcmp($res, "VERIFIED") == 0) { if ($_POST['payment_status'] == 'Completed') { if (WP_DEBUG) { wp_mail($purch_log_email, "IPN Completed Payement", $req); } $sessionid = $_POST['item_number']; $wpdb->query("UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `processed`= '3' WHERE `sessionid`=" . $sessionid); $purchase_log = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= " . $sessionid . " LIMIT 1", ARRAY_A); transaction_results($sessionid, false); // false -> no echo ! } //End if completed } elseif (strcmp($res, "INVALID") == 0) { // If 'INVALID', send an email. TODO: Log for manual investigation. if (WP_DEBUG) { wp_mail($purch_log_email, "Live-INVALID IPN", $req); } $wpdb->query("UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `processed`= '5' WHERE `sessionid`=" . $sessionid); } } fclose($fp); } } // fin du ipn=paypal }
private function getWorksheetId($ss_id = FALSE, $ws = FALSE) { if ($this->worksheet_id) { return $this->worksheet_id; } $ss_id = $ss_id ? $ss_id : $this->spreadsheet_id; $ws = $ws ? $ws : $this->worksheet; $wk_id = FALSE; if ($ss_id and $ws) { $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); $query->setSpreadsheetKey($ss_id); $feed = $this->client->getWorksheetFeed($query); foreach ($feed->entries as $entry) { if ($entry->title->text == $ws) { $wk_id = explode("/", $entry->id->text); $wk_id = array_pop($wk_id); $this->worksheet_id = $wk_id; break; } } } return $wk_id; }
private function getWorksheetId($ss_id, $ws = FALSE) { $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); $query->setSpreadsheetKey($ss_id); $feed = $this->client->getWorksheetFeed($query); foreach ($feed->entries as $entry) { if ($entry->title->text == $ws) { return array_pop(explode("/", $entry->id->text)); } } return FALSE; }
function process($destination) { if (!$this->configured) { $this->redirect(array('action' => 'config')); } $this->destination = $destination; $gdata_start = microtime(true); $client = new Zend_Gdata_SpreadSheets($this->gdata_client); $feed = $client->getSpreadsheetFeed(); $search = $this->destination; $spreadsheetKey = null; foreach ($feed->entries as $index => $entry) { if ($entry->title->text == $search) { $id = explode('/', $entry->id->text); $spreadsheetKey = end($id); } } if ($spreadsheetKey === null) { die('見つからないよ。'); } $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); $query->setSpreadsheetKey($spreadsheetKey); $feed = $client->getWorksheetFeed($query); $tables = array(); foreach ($feed->entries as $entry) { $worksheetName = $entry->title->text; if ($worksheetName == '表紙') { continue; } $worksheetId = end(explode('/', $entry->id->text)); $query = new Zend_Gdata_Spreadsheets_CellQuery(); $query->setSpreadsheetKey($spreadsheetKey); $query->setWorksheetId($worksheetId); $cellFeed = $client->getCellFeed($query); $table = array(); foreach ($cellFeed->entries as $cellEntry) { $text = $cellEntry->cell->text; $row = $cellEntry->cell->row; $col = $cellEntry->cell->col; if ($row < 3) { continue; } $table[$row][$col] = $text; } if (empty($table[3][2])) { continue; } foreach ($table as $index => $row) { if (empty($row[2])) { unset($table[$index]); } } if (empty($table)) { continue; } $tables[$worksheetName] = $table; } $this->set('gdata_elapsed_time', microtime(true) - $gdata_start); $database_start = microtime(true); App::import('Model', 'ConnectionManager'); $db =& ConnectionManager::getDataSource('default'); $result = $db->query('SET FOREIGN_KEY_CHECKS=0'); $this->_incrementSuccess($result); $this->set('countTables', count($tables)); foreach ($tables as $name => $table) { $result = $db->query("DROP TABLE IF EXISTS `{$name}`"); $this->_incrementSuccess($result); $sql = 'CREATE TABLE IF NOT EXISTS `' . trim($name) . "` (\n"; $fieldDefs = $foreignKeys = $indexColmuns = array(); $records = array(); foreach ($table as $index => $row) { $fieldDef = '`' . $row[2] . '` '; $fieldDef .= $this->_getType($row[3]); $fieldDef .= $this->_getNull($row[4], $this->_getType($row[3])); if (isset($row[5])) { $fieldDef .= $this->_getDefault($row[5]); } if (!empty($row[6])) { $fieldDef .= $this->_getOthers($row[6]); } if (!empty($row[7])) { $fieldDef .= $this->_getComment($row[7]); } if (!empty($row[1])) { $colmun_index = strtolower(trim($row[1])); if ($colmun_index == 'primary') { $fieldDef .= 'PRIMARY KEY '; } elseif ($colmun_index == 'unique') { $fieldDef .= ' UNIQUE '; } elseif ($colmun_index == 'index') { $indexColmuns[] = $row[2]; } elseif ($colmun_index == 'foreign') { $parts = explode('_', $row[2]); array_pop($parts); array_push($parts, Inflector::pluralize(array_pop($parts))); $ref = implode('_', $parts); if (strpos($ref, '.') === false) { $ref .= '.id'; } $foreignKeys[$row[2]] = $ref; } elseif (preg_match('/foreign\\((.+?)\\)/', $colmun_index, $matche)) { $ref = $matche[1]; if (strpos($ref, '.') === false) { $ref .= '.id'; } $foreignKeys[$row[2]] = $ref; } } $fieldDefs[$index] = $fieldDef; if (isset($row[9])) { $records[$row[2]] = $this->_getRecordRow($row); } } $sql .= implode(",\n", $fieldDefs); if (!empty($foreignKeys)) { $sql .= ",\n"; foreach ($foreignKeys as $from => $to) { list($toTable, $toField) = explode('.', $to); $foreignKeys[$from] = "FOREIGN KEY ({$from}) REFERENCES {$toTable}({$toField})"; } $sql .= implode(",\n", $foreignKeys); } if (!empty($indexColmuns)) { $sql .= ",\n"; foreach ($indexColmuns as $i => $colmun) { $indexColmuns[$i] = " INDEX (`{$colmun}`) "; } $sql .= implode(",\n", $indexColmuns); } $sql .= ") ENGINE=InnoDB DEFAULT CHARSET=utf8"; $result = $db->query($sql); $this->_incrementSuccess($result); $this->_incrementCreateTableSuccess($result); if (!empty($records)) { $fields = array_keys($records); $recordsDef = array(); foreach ($records as $field => $values) { foreach ($values as $index => $value) { $recordsDef[$index][array_search($field, $fields)] = $value; } } foreach ($recordsDef as $index => $values) { $recordsDef[$index] = '(' . implode(', ', $recordsDef[$index]) . ')'; } $db->insertMulti(trim($name), $fields, $recordsDef); } } $result = $db->query('SET FOREIGN_KEY_CHECKS=1'); $this->_incrementSuccess($result); $this->set('database_elapsed_time', microtime(true) - $database_start); $this->set('countSuccessTables', $this->_countSuccessTables); $this->set('countSuccessQueries', $this->_countSuccessQueries); $this->set('countQueries', $this->_countQueries); }
/** * Retourne une liste des feuilles d'un SpreadSheet suivant son titre passé en paramètre * @param String titre du spreedsheat * @return la liste des worksheets */ public function getWorkSheetsListByTitleValue($title) { $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); $query->setSpreadsheetKey($this->explodeId($this->getSpreadSheetByTitleValue($title)->getId())); return $this->service->getWorksheetFeed($query); }
Zend_Loader::loadClass('Zend_Http_Client'); // Set your Google Docs credentials here $user = '******'; $pass = '******'; $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME; $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); $spreadsheetService = new Zend_Gdata_Spreadsheets($client); $feed = $spreadsheetService->getSpreadsheetFeed(); // This is not the url displayed when logged in to Goolge Docs, because // that would just make sense. Oh, no - instead it has to be abstracted // away in the object. This is the feed url. $sheetName = "Sheet1"; foreach ($feed->entries as $entry) { if ($entry->title->text == $sheetName) { $spreadsheetURL = $entry->id; echo "SpreadsheetURL is: {$spreadsheetURL} <br /> \n"; break; } } $spreadsheetKey = basename($spreadsheetURL); $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); $query->setSpreadsheetKey($spreadsheetKey); $feed = $spreadsheetService->getWorksheetFeed($query); echo "Spreadsheet Key : {$spreadsheetKey} <br/> \n"; foreach ($feed->entries as $entry) { echo "ID of sheet {$entry->title->text} is " . basename($entry->id) . " <br/> \n"; } //$worksheetId = "Sheet1"; $worksheetId = basename($entry->id); // Ensure to use all lower case for column (header) names and escape sequences for spaces. $spreadsheetService->insertRow(array('header1' => 'Blargity', 'header2' => '9001'), $spreadsheetKey, $worksheetId);
private function getRowId($service, $spreadsheetKey) { $worksheetname = 'RAW'; $documentQuery = new Zend_Gdata_Spreadsheets_DocumentQuery(); $documentQuery->setSpreadsheetKey($spreadsheetKey); $spreadsheetFeed = $service->getWorksheetFeed($documentQuery); $i = 0; foreach ($spreadsheetFeed->entries as $worksheetEntry) { $worksheetId = split('/', $spreadsheetFeed->entries[$i]->id->text); if ($worksheetEntry->title->text === $worksheetname) { $worksheetId = $worksheetId[8]; break; } $i++; } return $worksheetId; }
public function testGetWorksheetEntry() { $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); $query->setSpreadsheetKey($this->sprKey); $query->setWorksheetId($this->wksId); $entry = $this->gdata->getWorksheetEntry($query); $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_WorksheetEntry); $entry = $this->gdata->getWorksheetEntry($query->getQueryUrl()); $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_WorksheetEntry); }
private function getRowId($service) { $worksheetname = "RAW"; $documentQuery = new Zend_Gdata_Spreadsheets_DocumentQuery(); $documentQuery->setSpreadsheetKey(opConfig::get('op_kintai_spkey')); $spreadsheetFeed = $service->getWorksheetFeed($documentQuery); $i = 0; foreach ($spreadsheetFeed->entries as $worksheetEntry) { $worksheetIds = split('/', $spreadsheetFeed->entries[$i]->id->text); if ($worksheetEntry->title->text === $worksheetname) { $worksheetId = $worksheetIds[8]; break; } $i++; } return $worksheetId; }