<?php require_once "api.php"; require_once "config.php"; $res = mysql_connect($db_host . ":" . $db_port, $db_user, $db_pass); mysql_select_db($db_name, $res); $sh = new SpreadSheet($res, "1", $db_prefix); $r = $sh->getCell("B2")->getStyle(); echo "<pre>"; print_r($r); echo "</pre>"; echo "<br>"; /* $r = $sh->setValue("B1", 1); $r = $sh->setValue("B2", "=B1+1"); $r = $sh->setValue("B3", "=B2+1"); $r = $sh->setValue("B4", "=B3+1"); $r = $sh->setValue("B5", "=B4+1"); echo $sh->getValue("B1").": ".$sh->getCalculatedValue("B1")."<br>"; echo $sh->getValue("B2").": ".$sh->getCalculatedValue("B2")."<br>"; echo $sh->getValue("B3").": ".$sh->getCalculatedValue("B3")."<br>"; echo $sh->getValue("B4").": ".$sh->getCalculatedValue("B4")."<br>"; echo $sh->getValue("B5").": ".$sh->getCalculatedValue("B5")."<br>"; */
$entry = $this->gdClient->updateRow($this->listFeed->entries[0], $newRowArray); if ($entry instanceof Zend_Gdata_Spreadsheets_ListEntry) { echo "Success!\n"; $response = $entry->save(); } } /** * stringToArray * * @param string $rowData * @return array */ public function stringToArray($rowData) { $arr = array(); foreach ($rowData as $row) { $temp = explode('=', $row); $arr[$temp[0]] = $temp[1]; } return $arr; } } /** * Returns a HTTP client object with the appropriate headers for communicating * with Google using AuthSub authentication. * * Uses the $_SESSION['sessionToken'] to store the AuthSub session token after * it is obtained. The single use token supplied in the URL when redirected * after the user succesfully authenticated to Google is retrieved from the * $_GET['token'] variable. *
{ $this->group = static::getGroup(); // обращается к статичному методу дочернего класса } public static function create() { return new static(); // создаёт обьект доченего класса } static function getGroup() { return "default"; } } class User extends DomainObject { } class Document extends DomainObject { static function getGroup() { return "document"; } } class SpreadSheet extends Document { } var_dump(User::create()); var_dump(Document::create()); var_dump(SpreadSheet::create());
{ private $group; public function __construct() { $this->group = static::getGroup(); } public static function create() { return new static(); } static function getGroup() { return "default"; } } class User extends DomainObject { } class Document extends DomainObject { static function getGroup() { return "document"; } } class SpreadSheet extends Document { } print_r(User::create()); print_r(SpreadSheet::create());
/** sets cell text * @param text * cell text * @return * true or false */ public function setValue($text) { $this->value = $text; if (strlen($text) > 1 && $text[0] == '=') { $expr = $text; $expr = $this->replaceAreas($expr); $this->parsed = $expr; $triggers = $this->getTriggers($expr); } else { $this->parsed = $this->value; $triggers = array(); } $this->process_triggers($triggers); SpreadSheet::$processed = array(); return $this->calculate(); }
<?php require_once "api.php"; require_once "config.php"; $res = mysql_connect($db_host . ":" . $db_port, $db_user, $db_pass); mysql_select_db($db_name, $res); $sh = new SpreadSheet($res, "1", $db_prefix); $r = $sh->getCell("B2")->getStyle(); echo "<pre>"; print_r($r); echo "</pre>"; echo "<br>"; /*comments started here */ $r = $sh->setValue("B1", 1); $r = $sh->setValue("B2", "=B1+1"); $r = $sh->setValue("B3", "=B2+1"); $r = $sh->setValue("B4", "=B3+1"); $r = $sh->setValue("B5", "=B4+1"); echo $sh->getValue("B1") . ": " . $sh->getCalculatedValue("B1") . "<br>"; echo $sh->getValue("B2") . ": " . $sh->getCalculatedValue("B2") . "<br>"; echo $sh->getValue("B3") . ": " . $sh->getCalculatedValue("B3") . "<br>"; echo $sh->getValue("B4") . ": " . $sh->getCalculatedValue("B4") . "<br>"; echo $sh->getValue("B5") . ": " . $sh->getCalculatedValue("B5") . "<br>";