From 06f945f27840b53e57795dadbc38e76f7e11ab1c Mon Sep 17 00:00:00 2001 From: Horus3 Date: Mon, 24 Feb 2014 16:42:14 +0100 Subject: init --- zend/library/Zend/Gdata/Spreadsheets/CellEntry.php | 104 +++++ zend/library/Zend/Gdata/Spreadsheets/CellFeed.php | 158 ++++++++ zend/library/Zend/Gdata/Spreadsheets/CellQuery.php | 417 +++++++++++++++++++++ .../Zend/Gdata/Spreadsheets/DocumentQuery.php | 288 ++++++++++++++ .../Zend/Gdata/Spreadsheets/Extension/Cell.php | 201 ++++++++++ .../Zend/Gdata/Spreadsheets/Extension/ColCount.php | 59 +++ .../Zend/Gdata/Spreadsheets/Extension/Custom.php | 100 +++++ .../Zend/Gdata/Spreadsheets/Extension/RowCount.php | 60 +++ zend/library/Zend/Gdata/Spreadsheets/ListEntry.php | 208 ++++++++++ zend/library/Zend/Gdata/Spreadsheets/ListFeed.php | 64 ++++ zend/library/Zend/Gdata/Spreadsheets/ListQuery.php | 305 +++++++++++++++ .../Zend/Gdata/Spreadsheets/SpreadsheetEntry.php | 64 ++++ .../Zend/Gdata/Spreadsheets/SpreadsheetFeed.php | 64 ++++ .../Zend/Gdata/Spreadsheets/WorksheetEntry.php | 187 +++++++++ .../Zend/Gdata/Spreadsheets/WorksheetFeed.php | 64 ++++ 15 files changed, 2343 insertions(+) create mode 100644 zend/library/Zend/Gdata/Spreadsheets/CellEntry.php create mode 100644 zend/library/Zend/Gdata/Spreadsheets/CellFeed.php create mode 100644 zend/library/Zend/Gdata/Spreadsheets/CellQuery.php create mode 100644 zend/library/Zend/Gdata/Spreadsheets/DocumentQuery.php create mode 100644 zend/library/Zend/Gdata/Spreadsheets/Extension/Cell.php create mode 100644 zend/library/Zend/Gdata/Spreadsheets/Extension/ColCount.php create mode 100644 zend/library/Zend/Gdata/Spreadsheets/Extension/Custom.php create mode 100644 zend/library/Zend/Gdata/Spreadsheets/Extension/RowCount.php create mode 100644 zend/library/Zend/Gdata/Spreadsheets/ListEntry.php create mode 100644 zend/library/Zend/Gdata/Spreadsheets/ListFeed.php create mode 100644 zend/library/Zend/Gdata/Spreadsheets/ListQuery.php create mode 100644 zend/library/Zend/Gdata/Spreadsheets/SpreadsheetEntry.php create mode 100644 zend/library/Zend/Gdata/Spreadsheets/SpreadsheetFeed.php create mode 100644 zend/library/Zend/Gdata/Spreadsheets/WorksheetEntry.php create mode 100644 zend/library/Zend/Gdata/Spreadsheets/WorksheetFeed.php (limited to 'zend/library/Zend/Gdata/Spreadsheets') diff --git a/zend/library/Zend/Gdata/Spreadsheets/CellEntry.php b/zend/library/Zend/Gdata/Spreadsheets/CellEntry.php new file mode 100644 index 0000000..906ad71 --- /dev/null +++ b/zend/library/Zend/Gdata/Spreadsheets/CellEntry.php @@ -0,0 +1,104 @@ +registerAllNamespaces(Zend_Gdata_Spreadsheets::$namespaces); + parent::__construct($element); + } + + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_cell != null) { + $element->appendChild($this->_cell->getDOM($element->ownerDocument)); + } + return $element; + } + + protected function takeChildFromDOM($child) + { + $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; + switch ($absoluteNodeName) { + case $this->lookupNamespace('gs') . ':' . 'cell'; + $cell = new Zend_Gdata_Spreadsheets_Extension_Cell(); + $cell->transferFromDOM($child); + $this->_cell = $cell; + break; + default: + parent::takeChildFromDOM($child); + break; + } + } + + /** + * Gets the Cell element of this Cell Entry. + * @return Zend_Gdata_Spreadsheets_Extension_Cell + */ + public function getCell() + { + return $this->_cell; + } + + /** + * Sets the Cell element of this Cell Entry. + * @param Zend_Gdata_Spreadsheets_Extension_Cell $cell + * @return Zend_Gdata_Spreadsheets_CellEntry + */ + public function setCell($cell) + { + $this->_cell = $cell; + return $this; + } + +} diff --git a/zend/library/Zend/Gdata/Spreadsheets/CellFeed.php b/zend/library/Zend/Gdata/Spreadsheets/CellFeed.php new file mode 100644 index 0000000..8cc9a56 --- /dev/null +++ b/zend/library/Zend/Gdata/Spreadsheets/CellFeed.php @@ -0,0 +1,158 @@ +registerAllNamespaces(Zend_Gdata_Spreadsheets::$namespaces); + parent::__construct($element); + } + + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->rowCount != null) { + $element->appendChild($this->_rowCount->getDOM($element->ownerDocument)); + } + if ($this->colCount != null) { + $element->appendChild($this->_colCount->getDOM($element->ownerDocument)); + } + return $element; + } + + protected function takeChildFromDOM($child) + { + $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; + switch ($absoluteNodeName) { + case $this->lookupNamespace('gs') . ':' . 'rowCount'; + $rowCount = new Zend_Gdata_Spreadsheets_Extension_RowCount(); + $rowCount->transferFromDOM($child); + $this->_rowCount = $rowCount; + break; + case $this->lookupNamespace('gs') . ':' . 'colCount'; + $colCount = new Zend_Gdata_Spreadsheets_Extension_ColCount(); + $colCount->transferFromDOM($child); + $this->_colCount = $colCount; + break; + default: + parent::takeChildFromDOM($child); + break; + } + } + + /** + * Gets the row count for this feed. + * @return string The row count for the feed. + */ + public function getRowCount() + { + return $this->_rowCount; + } + + /** + * Gets the column count for this feed. + * @return string The column count for the feed. + */ + public function getColumnCount() + { + return $this->_colCount; + } + + /** + * Sets the row count for this feed. + * @param string $rowCount The new row count for the feed. + */ + public function setRowCount($rowCount) + { + $this->_rowCount = $rowCount; + return $this; + } + + /** + * Sets the column count for this feed. + * @param string $colCount The new column count for the feed. + */ + public function setColumnCount($colCount) + { + $this->_colCount = $colCount; + return $this; + } + +} diff --git a/zend/library/Zend/Gdata/Spreadsheets/CellQuery.php b/zend/library/Zend/Gdata/Spreadsheets/CellQuery.php new file mode 100644 index 0000000..1dafd7c --- /dev/null +++ b/zend/library/Zend/Gdata/Spreadsheets/CellQuery.php @@ -0,0 +1,417 @@ +_spreadsheetKey = $value; + return $this; + } + + /** + * Gets the spreadsheet key for this query. + * + * @return string spreadsheet key + */ + public function getSpreadsheetKey() + { + return $this->_spreadsheetKey; + } + + /** + * Sets the worksheet id for this query. + * + * @param string $value + * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface + */ + public function setWorksheetId($value) + { + $this->_worksheetId = $value; + return $this; + } + + /** + * Gets the worksheet id for this query. + * + * @return string worksheet id + */ + public function getWorksheetId() + { + return $this->_worksheetId; + } + + /** + * Sets the cell id for this query. + * + * @param string $value + * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface + */ + public function setCellId($value) + { + $this->_cellId = $value; + return $this; + } + + /** + * Gets the cell id for this query. + * + * @return string cell id + */ + public function getCellId() + { + return $this->_cellId; + } + + /** + * Sets the projection for this query. + * + * @param string $value + * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface + */ + public function setProjection($value) + { + $this->_projection = $value; + return $this; + } + + /** + * Sets the visibility for this query. + * + * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface + */ + public function setVisibility($value) + { + $this->_visibility = $value; + return $this; + } + + /** + * Gets the projection for this query. + * + * @return string projection + */ + public function getProjection() + { + return $this->_projection; + } + + /** + * Gets the visibility for this query. + * + * @return string visibility + */ + public function getVisibility() + { + return $this->_visibility; + } + + /** + * Sets the min-row attribute for this query. + * + * @param string $value + * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface + */ + public function setMinRow($value) + { + if ($value != null) { + $this->_params['min-row'] = $value; + } else { + unset($this->_params['min-row']); + } + return $this; + } + + /** + * Gets the min-row attribute for this query. + * + * @return string min-row + */ + public function getMinRow() + { + if (array_key_exists('min-row', $this->_params)) { + return $this->_params['min-row']; + } else { + return null; + } + } + + /** + * Sets the max-row attribute for this query. + * + * @param string $value + * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface + */ + public function setMaxRow($value) + { + if ($value != null) { + $this->_params['max-row'] = $value; + } else { + unset($this->_params['max-row']); + } + return $this; + } + + /** + * Gets the max-row attribute for this query. + * + * @return string max-row + */ + public function getMaxRow() + { + if (array_key_exists('max-row', $this->_params)) { + return $this->_params['max-row']; + } else { + return null; + } + } + + /** + * Sets the min-col attribute for this query. + * + * @param string $value + * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface + */ + public function setMinCol($value) + { + if ($value != null) { + $this->_params['min-col'] = $value; + } else { + unset($this->_params['min-col']); + } + return $this; + } + + /** + * Gets the min-col attribute for this query. + * + * @return string min-col + */ + public function getMinCol() + { + if (array_key_exists('min-col', $this->_params)) { + return $this->_params['min-col']; + } else { + return null; + } + } + + /** + * Sets the max-col attribute for this query. + * + * @param string $value + * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface + */ + public function setMaxCol($value) + { + if ($value != null) { + $this->_params['max-col'] = $value; + } else { + unset($this->_params['max-col']); + } + return $this; + } + + /** + * Gets the max-col attribute for this query. + * + * @return string max-col + */ + public function getMaxCol() + { + if (array_key_exists('max-col', $this->_params)) { + return $this->_params['max-col']; + } else { + return null; + } + } + + /** + * Sets the range attribute for this query. + * + * @param string $value + * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface + */ + public function setRange($value) + { + if ($value != null) { + $this->_params['range'] = $value; + } else { + unset($this->_params['range']); + } + return $this; + } + + /** + * Gets the range attribute for this query. + * + * @return string range + */ + public function getRange() + { + if (array_key_exists('range', $this->_params)) { + return $this->_params['range']; + } else { + return null; + } + } + + /** + * Sets the return-empty attribute for this query. + * + * @param mixed $value String or bool value for whether to return empty cells + * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface + */ + public function setReturnEmpty($value) + { + if (is_bool($value)) { + $this->_params['return-empty'] = ($value?'true':'false'); + } else if ($value != null) { + $this->_params['return-empty'] = $value; + } else { + unset($this->_params['return-empty']); + } + return $this; + } + + /** + * Gets the return-empty attribute for this query. + * + * @return string return-empty + */ + public function getReturnEmpty() + { + if (array_key_exists('return-empty', $this->_params)) { + return $this->_params['return-empty']; + } else { + return null; + } + } + + /** + * Gets the full query URL for this query. + * + * @return string url + */ + public function getQueryUrl() + { + if ($this->_url == null) { + $uri = $this->_defaultFeedUri; + + if ($this->_spreadsheetKey != null) { + $uri .= '/'.$this->_spreadsheetKey; + } else { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception('A spreadsheet key must be provided for cell queries.'); + } + + if ($this->_worksheetId != null) { + $uri .= '/'.$this->_worksheetId; + } else { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception('A worksheet id must be provided for cell queries.'); + } + + if ($this->_visibility != null) { + $uri .= '/'.$this->_visibility; + } else { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception('A visibility must be provided for cell queries.'); + } + + if ($this->_projection != null) { + $uri .= '/'.$this->_projection; + } else { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception('A projection must be provided for cell queries.'); + } + + if ($this->_cellId != null) { + $uri .= '/'.$this->_cellId; + } + } else { + $uri = $this->_url; + } + + $uri .= $this->getQueryString(); + return $uri; + } + + /** + * Gets the attribute query string for this query. + * + * @return string query string + */ + public function getQueryString() + { + return parent::getQueryString(); + } + +} diff --git a/zend/library/Zend/Gdata/Spreadsheets/DocumentQuery.php b/zend/library/Zend/Gdata/Spreadsheets/DocumentQuery.php new file mode 100644 index 0000000..f6abec3 --- /dev/null +++ b/zend/library/Zend/Gdata/Spreadsheets/DocumentQuery.php @@ -0,0 +1,288 @@ +_spreadsheetKey = $value; + return $this; + } + + /** + * Gets the spreadsheet key for this query. + * @return string spreadsheet key + */ + public function getSpreadsheetKey() + { + return $this->_spreadsheetKey; + } + + /** + * Sets the worksheet id for this query. + * @param string $value + * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface + */ + public function setWorksheetId($value) + { + $this->_worksheetId = $value; + return $this; + } + + /** + * Gets the worksheet id for this query. + * @return string worksheet id + */ + public function getWorksheetId() + { + return $this->_worksheetId; + } + + /** + * Sets the document type for this query. + * @param string $value spreadsheets or worksheets + * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface + */ + public function setDocumentType($value) + { + $this->_documentType = $value; + return $this; + } + + /** + * Gets the document type for this query. + * @return string document type + */ + public function getDocumentType() + { + return $this->_documentType; + } + + /** + * Sets the projection for this query. + * @param string $value + * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface + */ + public function setProjection($value) + { + $this->_projection = $value; + return $this; + } + + /** + * Sets the visibility for this query. + * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface + */ + public function setVisibility($value) + { + $this->_visibility = $value; + return $this; + } + + /** + * Gets the projection for this query. + * @return string projection + */ + public function getProjection() + { + return $this->_projection; + } + + /** + * Gets the visibility for this query. + * @return string visibility + */ + public function getVisibility() + { + return $this->_visibility; + } + + /** + * Sets the title attribute for this query. + * @param string $value + * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface + */ + public function setTitle($value) + { + if ($value != null) { + $this->_params['title'] = $value; + } else { + unset($this->_params['title']); + } + return $this; + } + + /** + * Sets the title-exact attribute for this query. + * @param string $value + * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface + */ + public function setTitleExact($value) + { + if ($value != null) { + $this->_params['title-exact'] = $value; + } else { + unset($this->_params['title-exact']); + } + return $this; + } + + /** + * Gets the title attribute for this query. + * @return string title + */ + public function getTitle() + { + if (array_key_exists('title', $this->_params)) { + return $this->_params['title']; + } else { + return null; + } + } + + /** + * Gets the title-exact attribute for this query. + * @return string title-exact + */ + public function getTitleExact() + { + if (array_key_exists('title-exact', $this->_params)) { + return $this->_params['title-exact']; + } else { + return null; + } + } + + private function appendVisibilityProjection() + { + $uri = ''; + + if ($this->_visibility != null) { + $uri .= '/'.$this->_visibility; + } else { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception('A visibility must be provided for document queries.'); + } + + if ($this->_projection != null) { + $uri .= '/'.$this->_projection; + } else { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception('A projection must be provided for document queries.'); + } + + return $uri; + } + + + /** + * Gets the full query URL for this query. + * @return string url + */ + public function getQueryUrl() + { + $uri = $this->_defaultFeedUri; + + if ($this->_documentType != null) { + $uri .= '/'.$this->_documentType; + } else { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception('A document type must be provided for document queries.'); + } + + if ($this->_documentType == 'spreadsheets') { + $uri .= $this->appendVisibilityProjection(); + if ($this->_spreadsheetKey != null) { + $uri .= '/'.$this->_spreadsheetKey; + } + } else if ($this->_documentType == 'worksheets') { + if ($this->_spreadsheetKey != null) { + $uri .= '/'.$this->_spreadsheetKey; + } else { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception('A spreadsheet key must be provided for worksheet document queries.'); + } + $uri .= $this->appendVisibilityProjection(); + if ($this->_worksheetId != null) { + $uri .= '/'.$this->_worksheetId; + } + } + + $uri .= $this->getQueryString(); + return $uri; + } + + /** + * Gets the attribute query string for this query. + * @return string query string + */ + public function getQueryString() + { + return parent::getQueryString(); + } + +} diff --git a/zend/library/Zend/Gdata/Spreadsheets/Extension/Cell.php b/zend/library/Zend/Gdata/Spreadsheets/Extension/Cell.php new file mode 100644 index 0000000..8ebad7d --- /dev/null +++ b/zend/library/Zend/Gdata/Spreadsheets/Extension/Cell.php @@ -0,0 +1,201 @@ +registerAllNamespaces(Zend_Gdata_Spreadsheets::$namespaces); + parent::__construct(); + $this->_text = $text; + $this->_row = $row; + $this->_col = $col; + $this->_inputValue = $inputValue; + $this->_numericValue = $numericValue; + } + + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + $element->setAttribute('row', $this->_row); + $element->setAttribute('col', $this->_col); + if ($this->_inputValue) $element->setAttribute('inputValue', $this->_inputValue); + if ($this->_numericValue) $element->setAttribute('numericValue', $this->_numericValue); + return $element; + } + + protected function takeAttributeFromDOM($attribute) + { + switch ($attribute->localName) { + case 'row': + $this->_row = $attribute->nodeValue; + break; + case 'col': + $this->_col = $attribute->nodeValue; + break; + case 'inputValue': + $this->_inputValue = $attribute->nodeValue; + break; + case 'numericValue': + $this->_numericValue = $attribute->nodeValue; + break; + default: + parent::takeAttributeFromDOM($attribute); + } + } + + /** + * Gets the row attribute of the Cell element. + * @return string Row of the Cell. + */ + public function getRow() + { + return $this->_row; + } + + /** + * Gets the column attribute of the Cell element. + * @return string Column of the Cell. + */ + public function getColumn() + { + return $this->_col; + } + + /** + * Gets the input value attribute of the Cell element. + * @return string Input value of the Cell. + */ + public function getInputValue() + { + return $this->_inputValue; + } + + /** + * Gets the numeric value attribute of the Cell element. + * @return string Numeric value of the Cell. + */ + public function getNumericValue() + { + return $this->_numericValue; + } + + /** + * Sets the row attribute of the Cell element. + * @param string $row New row of the Cell. + */ + public function setRow($row) + { + $this->_row = $row; + return $this; + } + + /** + * Sets the column attribute of the Cell element. + * @param string $col New column of the Cell. + */ + public function setColumn($col) + { + $this->_col = $col; + return $this; + } + + /** + * Sets the input value attribute of the Cell element. + * @param string $inputValue New input value of the Cell. + */ + public function setInputValue($inputValue) + { + $this->_inputValue = $inputValue; + return $this; + } + + /** + * Sets the numeric value attribute of the Cell element. + * @param string $numericValue New numeric value of the Cell. + */ + public function setNumericValue($numericValue) + { + $this->_numericValue = $numericValue; + } + +} diff --git a/zend/library/Zend/Gdata/Spreadsheets/Extension/ColCount.php b/zend/library/Zend/Gdata/Spreadsheets/Extension/ColCount.php new file mode 100644 index 0000000..80eb7dc --- /dev/null +++ b/zend/library/Zend/Gdata/Spreadsheets/Extension/ColCount.php @@ -0,0 +1,59 @@ +registerAllNamespaces(Zend_Gdata_Spreadsheets::$namespaces); + parent::__construct(); + $this->_text = $text; + } +} diff --git a/zend/library/Zend/Gdata/Spreadsheets/Extension/Custom.php b/zend/library/Zend/Gdata/Spreadsheets/Extension/Custom.php new file mode 100644 index 0000000..1a39066 --- /dev/null +++ b/zend/library/Zend/Gdata/Spreadsheets/Extension/Custom.php @@ -0,0 +1,100 @@ +registerAllNamespaces(Zend_Gdata_Spreadsheets::$namespaces); + parent::__construct(); + $this->_text = $value; + $this->_rootElement = $column; + } + + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + return $element; + } + + /** + * Transfers each child and attribute into member variables. + * This is called when XML is received over the wire and the data + * model needs to be built to represent this XML. + * + * @param DOMNode $node The DOMNode that represents this object's data + */ + public function transferFromDOM($node) + { + parent::transferFromDOM($node); + $this->_rootElement = $node->localName; + } + + /** + * Sets the column/tag name of the element. + * @param string $column The new column name. + */ + public function setColumnName($column) + { + $this->_rootElement = $column; + return $this; + } + + /** + * Gets the column name of the element + * @return string The column name. + */ + public function getColumnName() + { + return $this->_rootElement; + } + +} diff --git a/zend/library/Zend/Gdata/Spreadsheets/Extension/RowCount.php b/zend/library/Zend/Gdata/Spreadsheets/Extension/RowCount.php new file mode 100644 index 0000000..fa0a51d --- /dev/null +++ b/zend/library/Zend/Gdata/Spreadsheets/Extension/RowCount.php @@ -0,0 +1,60 @@ +registerAllNamespaces(Zend_Gdata_Spreadsheets::$namespaces); + parent::__construct(); + $this->_text = $text; + } + +} diff --git a/zend/library/Zend/Gdata/Spreadsheets/ListEntry.php b/zend/library/Zend/Gdata/Spreadsheets/ListEntry.php new file mode 100644 index 0000000..08cd367 --- /dev/null +++ b/zend/library/Zend/Gdata/Spreadsheets/ListEntry.php @@ -0,0 +1,208 @@ +registerAllNamespaces(Zend_Gdata_Spreadsheets::$namespaces); + parent::__construct($element); + } + + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if (!empty($this->_custom)) { + foreach ($this->_custom as $custom) { + $element->appendChild($custom->getDOM($element->ownerDocument)); + } + } + return $element; + } + + protected function takeChildFromDOM($child) + { + switch ($child->namespaceURI) { + case $this->lookupNamespace('gsx'); + $custom = new Zend_Gdata_Spreadsheets_Extension_Custom($child->localName); + $custom->transferFromDOM($child); + $this->addCustom($custom); + break; + default: + parent::takeChildFromDOM($child); + break; + } + } + + /** + * Gets the row elements contained by this list entry. + * @return array The custom row elements in this list entry + */ + public function getCustom() + { + return $this->_custom; + } + + /** + * Gets a single row element contained by this list entry using its name. + * @param string $name The name of a custom element to return. If null + * or not defined, an array containing all custom elements + * indexed by name will be returned. + * @return mixed If a name is specified, the + * Zend_Gdata_Spreadsheets_Extension_Custom element requested, + * is returned or null if not found. Otherwise, an array of all + * Zend_Gdata_Spreadsheets_Extension_Custom elements is returned + * indexed by name. + */ + public function getCustomByName($name = null) + { + if ($name === null) { + return $this->_customByName; + } else { + if (array_key_exists($name, $this->customByName)) { + return $this->_customByName[$name]; + } else { + return null; + } + } + } + + /** + * Sets the row elements contained by this list entry. If any + * custom row elements were previously stored, they will be overwritten. + * @param array $custom The custom row elements to be contained in this + * list entry. + * @return Zend_Gdata_Spreadsheets_ListEntry Provides a fluent interface. + */ + public function setCustom($custom) + { + $this->_custom = array(); + foreach ($custom as $c) { + $this->addCustom($c); + } + return $this; + } + + /** + * Add an individual custom row element to this list entry. + * @param Zend_Gdata_Spreadsheets_Extension_Custom $custom The custom + * element to be added. + * @return Zend_Gdata_Spreadsheets_ListEntry Provides a fluent interface. + */ + public function addCustom($custom) + { + $this->_custom[] = $custom; + $this->_customByName[$custom->getColumnName()] = $custom; + return $this; + } + + /** + * Remove an individual row element from this list entry by index. This + * will cause the array to be re-indexed. + * @param int $index The index of the custom element to be deleted. + * @return Zend_Gdata_Spreadsheets_ListEntry Provides a fluent interface. + * @throws Zend_Gdata_App_InvalidArgumentException + */ + public function removeCustom($index) + { + if (array_key_exists($index, $this->_custom)) { + $element = $this->_custom[$index]; + // Remove element + unset($this->_custom[$index]); + // Re-index the array + $this->_custom = array_values($this->_custom); + // Be sure to delete form both arrays! + $key = array_search($element, $this->_customByName); + unset($this->_customByName[$key]); + } else { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Element does not exist.'); + } + return $this; + } + + /** + * Remove an individual row element from this list entry by name. + * @param string $name The name of the custom element to be deleted. + * @return Zend_Gdata_Spreadsheets_ListEntry Provides a fluent interface. + * @throws Zend_Gdata_App_InvalidArgumentException + */ + public function removeCustomByName($name) + { + if (array_key_exists($name, $this->_customByName)) { + $element = $this->_customByName[$name]; + // Remove element + unset($this->_customByName[$name]); + // Be sure to delete from both arrays! + $key = array_search($element, $this->_custom); + unset($this->_custom[$key]); + } else { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Element does not exist.'); + } + return $this; + } + +} diff --git a/zend/library/Zend/Gdata/Spreadsheets/ListFeed.php b/zend/library/Zend/Gdata/Spreadsheets/ListFeed.php new file mode 100644 index 0000000..b2cb08b --- /dev/null +++ b/zend/library/Zend/Gdata/Spreadsheets/ListFeed.php @@ -0,0 +1,64 @@ +registerAllNamespaces(Zend_Gdata_Spreadsheets::$namespaces); + parent::__construct($element); + } + +} diff --git a/zend/library/Zend/Gdata/Spreadsheets/ListQuery.php b/zend/library/Zend/Gdata/Spreadsheets/ListQuery.php new file mode 100644 index 0000000..64ea3d3 --- /dev/null +++ b/zend/library/Zend/Gdata/Spreadsheets/ListQuery.php @@ -0,0 +1,305 @@ +_spreadsheetKey = $value; + return $this; + } + + /** + * Gets the spreadsheet key for the query. + * @return string spreadsheet key + */ + public function getSpreadsheetKey() + { + return $this->_spreadsheetKey; + } + + /** + * Sets the worksheet id for the query. + * @param string $value + * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface + */ + public function setWorksheetId($value) + { + $this->_worksheetId = $value; + return $this; + } + + /** + * Gets the worksheet id for the query. + * @return string worksheet id + */ + public function getWorksheetId() + { + return $this->_worksheetId; + } + + /** + * Sets the row id for the query. + * @param string $value row id + * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface + */ + public function setRowId($value) + { + $this->_rowId = $value; + return $this; + } + + /** + * Gets the row id for the query. + * @return string row id + */ + public function getRowId() + { + return $this->_rowId; + } + + /** + * Sets the projection for the query. + * @param string $value Projection + * @return Zend_Gdata_Spreadsheets_ListQuery Provides a fluent interface + */ + public function setProjection($value) + { + $this->_projection = $value; + return $this; + } + + /** + * Sets the visibility for this query. + * @param string $value visibility + * @return Zend_Gdata_Spreadsheets_ListQuery Provides a fluent interface + */ + public function setVisibility($value) + { + $this->_visibility = $value; + return $this; + } + + /** + * Gets the projection for this query. + * @return string projection + */ + public function getProjection() + { + return $this->_projection; + } + + /** + * Gets the visibility for this query. + * @return string visibility + */ + public function getVisibility() + { + return $this->_visibility; + } + + /** + * Sets the spreadsheet key for this query. + * @param string $value + * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface + */ + public function setSpreadsheetQuery($value) + { + if ($value != null) { + $this->_params['sq'] = $value; + } else { + unset($this->_params['sq']); + } + return $this; + } + + /** + * Gets the spreadsheet key for this query. + * @return string spreadsheet query + */ + public function getSpreadsheetQuery() + { + if (array_key_exists('sq', $this->_params)) { + return $this->_params['sq']; + } else { + return null; + } + } + + /** + * Sets the orderby attribute for this query. + * @param string $value + * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface + */ + public function setOrderBy($value) + { + if ($value != null) { + $this->_params['orderby'] = $value; + } else { + unset($this->_params['orderby']); + } + return $this; + } + + /** + * Gets the orderby attribute for this query. + * @return string orderby + */ + public function getOrderBy() + { + if (array_key_exists('orderby', $this->_params)) { + return $this->_params['orderby']; + } else { + return null; + } + } + + /** + * Sets the reverse attribute for this query. + * @param string $value + * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface + */ + public function setReverse($value) + { + if ($value != null) { + $this->_params['reverse'] = $value; + } else { + unset($this->_params['reverse']); + } + return $this; + } + + /** + * Gets the reverse attribute for this query. + * @return string reverse + */ + public function getReverse() + { + + + if (array_key_exists('reverse', $this->_params)) { + return $this->_params['reverse']; + } else { + return null; + } + } + + /** + * Gets the full query URL for this query. + * @return string url + */ + public function getQueryUrl() + { + + $uri = $this->_defaultFeedUri; + + if ($this->_spreadsheetKey != null) { + $uri .= '/'.$this->_spreadsheetKey; + } else { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception('A spreadsheet key must be provided for list queries.'); + } + + if ($this->_worksheetId != null) { + $uri .= '/'.$this->_worksheetId; + } else { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception('A worksheet id must be provided for list queries.'); + } + + if ($this->_visibility != null) { + $uri .= '/'.$this->_visibility; + } else { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception('A visibility must be provided for list queries.'); + } + + if ($this->_projection != null) { + $uri .= '/'.$this->_projection; + } else { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception('A projection must be provided for list queries.'); + } + + if ($this->_rowId != null) { + $uri .= '/'.$this->_rowId; + } + + $uri .= $this->getQueryString(); + return $uri; + } + + /** + * Gets the attribute query string for this query. + * @return string query string + */ + public function getQueryString() + { + return parent::getQueryString(); + } + +} diff --git a/zend/library/Zend/Gdata/Spreadsheets/SpreadsheetEntry.php b/zend/library/Zend/Gdata/Spreadsheets/SpreadsheetEntry.php new file mode 100644 index 0000000..ff3e21e --- /dev/null +++ b/zend/library/Zend/Gdata/Spreadsheets/SpreadsheetEntry.php @@ -0,0 +1,64 @@ +registerAllNamespaces(Zend_Gdata_Spreadsheets::$namespaces); + parent::__construct($element); + } + + /** + * Returns the worksheets in this spreadsheet + * + * @return Zend_Gdata_Spreadsheets_WorksheetFeed The worksheets + */ + public function getWorksheets() + { + $service = new Zend_Gdata_Spreadsheets($this->getHttpClient()); + return $service->getWorksheetFeed($this); + } + +} diff --git a/zend/library/Zend/Gdata/Spreadsheets/SpreadsheetFeed.php b/zend/library/Zend/Gdata/Spreadsheets/SpreadsheetFeed.php new file mode 100644 index 0000000..e47f9c9 --- /dev/null +++ b/zend/library/Zend/Gdata/Spreadsheets/SpreadsheetFeed.php @@ -0,0 +1,64 @@ +registerAllNamespaces(Zend_Gdata_Spreadsheets::$namespaces); + parent::__construct($element); + } + +} diff --git a/zend/library/Zend/Gdata/Spreadsheets/WorksheetEntry.php b/zend/library/Zend/Gdata/Spreadsheets/WorksheetEntry.php new file mode 100644 index 0000000..a7506de --- /dev/null +++ b/zend/library/Zend/Gdata/Spreadsheets/WorksheetEntry.php @@ -0,0 +1,187 @@ +registerAllNamespaces(Zend_Gdata_Spreadsheets::$namespaces); + parent::__construct($element); + } + + /** + * Retrieves a DOMElement which corresponds to this element and all + * child properties. This is used to build an entry back into a DOM + * and eventually XML text for sending to the server upon updates, or + * for application storage/persistence. + * + * @param DOMDocument $doc The DOMDocument used to construct DOMElements + * @return DOMElement The DOMElement representing this element and all + * child properties. + */ + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_rowCount != null) { + $element->appendChild($this->_rowCount->getDOM($element->ownerDocument)); + } + if ($this->_colCount != null) { + $element->appendChild($this->_colCount->getDOM($element->ownerDocument)); + } + return $element; + } + + /** + * Creates individual Entry objects of the appropriate type and + * stores them in the $_entry array based upon DOM data. + * + * @param DOMNode $child The DOMNode to process + */ + protected function takeChildFromDOM($child) + { + $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; + switch ($absoluteNodeName) { + case $this->lookupNamespace('gs') . ':' . 'rowCount'; + $rowCount = new Zend_Gdata_Spreadsheets_Extension_RowCount(); + $rowCount->transferFromDOM($child); + $this->_rowCount = $rowCount; + break; + case $this->lookupNamespace('gs') . ':' . 'colCount'; + $colCount = new Zend_Gdata_Spreadsheets_Extension_ColCount(); + $colCount->transferFromDOM($child); + $this->_colCount = $colCount; + break; + default: + parent::takeChildFromDOM($child); + break; + } + } + + + /** + * Gets the row count for this entry. + * + * @return string The row count for the entry. + */ + public function getRowCount() + { + return $this->_rowCount; + } + + /** + * Gets the column count for this entry. + * + * @return string The column count for the entry. + */ + public function getColumnCount() + { + return $this->_colCount; + } + + /** + * Sets the row count for this entry. + * + * @param string $rowCount The new row count for the entry. + */ + public function setRowCount($rowCount) + { + $this->_rowCount = $rowCount; + return $this; + } + + /** + * Sets the column count for this entry. + * + * @param string $colCount The new column count for the entry. + */ + public function setColumnCount($colCount) + { + $this->_colCount = $colCount; + return $this; + } + + /** + * Returns the content of all rows as an associative array + * + * @return array An array of rows. Each element of the array is an associative array of data + */ + public function getContentsAsRows() + { + $service = new Zend_Gdata_Spreadsheets($this->getHttpClient()); + return $service->getSpreadsheetListFeedContents($this); + } + + /** + * Returns the content of all cells as an associative array, indexed + * off the cell location (ie 'A1', 'D4', etc). Each element of + * the array is an associative array with a 'value' and a 'function'. + * Only non-empty cells are returned by default. 'range' is the + * value of the 'range' query parameter specified at: + * http://code.google.com/apis/spreadsheets/reference.html#cells_Parameters + * + * @param string $range The range of cells to retrieve + * @param boolean $empty Whether to retrieve empty cells + * @return array An associative array of cells + */ + public function getContentsAsCells($range = null, $empty = false) + { + $service = new Zend_Gdata_Spreadsheets($this->getHttpClient()); + return $service->getSpreadsheetCellFeedContents($this, $range, $empty); + } + +} diff --git a/zend/library/Zend/Gdata/Spreadsheets/WorksheetFeed.php b/zend/library/Zend/Gdata/Spreadsheets/WorksheetFeed.php new file mode 100644 index 0000000..f549e09 --- /dev/null +++ b/zend/library/Zend/Gdata/Spreadsheets/WorksheetFeed.php @@ -0,0 +1,64 @@ +registerAllNamespaces(Zend_Gdata_Spreadsheets::$namespaces); + parent::__construct($element); + } + + /** + * The classname for individual feed elements. + * + * @var string + */ + protected $_entryClassName = 'Zend_Gdata_Spreadsheets_WorksheetEntry'; + + /** + * The classname for the feed. + * + * @var string + */ + protected $_feedClassName = 'Zend_Gdata_Spreadsheets_WorksheetFeed'; + +} -- cgit v1.2.3