diff -r 877f952ae2bd -r 6b6c2214f778 web/lib/Zend/Mobile/Push/Message/Mpns/Tile.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Mobile/Push/Message/Mpns/Tile.php Thu Mar 21 19:52:38 2013 +0100 @@ -0,0 +1,365 @@ +_backgroundImage; + } + + /** + * Set Background Image + * + * @param string $bgImg + * @return Zend_Mobile_Push_Message_Mpns_Tile + * @throws Zend_Mobile_Push_Message_Exception + */ + public function setBackgroundImage($bgImg) + { + if (!is_string($bgImg)) { + throw new Zend_Mobile_Push_Message_Exception('$bgImg must be a string'); + } + $this->_backgroundImage = $bgImg; + return $this; + } + + /** + * Get Count + * + * @return int + */ + public function getCount() + { + return $this->_count; + } + + /** + * Set Count + * + * @param int $count + * @return Zend_Mobile_Push_Message_Mpns_Tile + * @throws Zend_Mobile_Push_Message_Exception + */ + public function setCount($count) + { + if (!is_numeric($count)) { + throw new Zend_Mobile_Push_Message_Exception('$count is not numeric'); + } + $this->_count = (int) $count; + return $this; + } + + /** + * Get Title + * + * @return string + */ + public function getTitle() + { + return $this->_title; + } + + /** + * Set Title + * + * @param string $title + * @return Zend_Mobile_Push_Message_Mpns_Tile + * @throws Zend_Mobile_Push_Message_Exception + */ + public function setTitle($title) + { + if (!is_string($title)) { + throw new Zend_Mobile_Push_Message_Exception('$title must be a string'); + } + $this->_title = $title; + return $this; + } + + /** + * Get Back Background Image + * + * @return string + */ + public function getBackBackgroundImage() + { + return $this->_backBackgroundImage; + } + + /** + * Set Back Background Image + * + * @param string $bgImg + * @return Zend_Mobile_Push_Message_Mpns_Tile + * @throws Zend_Mobile_Push_Message_Exception + */ + public function setBackBackgroundImage($bgImg) + { + if (!is_string($bgImg)) { + throw new Zend_Mobile_Push_Message_Exception('$bgImg must be a string'); + } + $this->_backBackgroundImage = $bgImg; + return $this; + } + + /** + * Get Back Title + * + * @return string + */ + public function getBackTitle() + { + return $this->_backTitle; + } + + /** + * Set Back Title + * + * @param string $title + * @return Zend_Mobile_Push_Message_Mpns_Tile + * @throws Zend_Mobile_Push_Message_Exception + */ + public function setBackTitle($title) + { + if (!is_string($title)) { + throw new Zend_Mobile_Push_Message_Exception('$title must be a string'); + } + $this->_backTitle = $title; + return $this; + } + + /** + * Get Back Content + * + * @return string + */ + public function getBackContent() + { + return $this->_backContent; + } + + /** + * Set Back Content + * + * @param string $content + * @return Zend_Mobile_Push_Message_Mpns_Tile + * @throws Zend_Mobile_Push_Message_Exception + */ + public function setBackContent($content) + { + if (!is_string($content)) { + throw new Zend_Mobile_Push_Message_Exception('$content must be a string'); + } + $this->_backContent = $content; + } + + /** + * Get Tile Id + * + * @return string + */ + public function getTileId() + { + return $this->_tileId; + } + + /** + * Set Tile Id + * + * @param string $tileId + * @return Zend_Mobile_Push_Message_Mpns_Tile + * @throws Zend_Mobile_Push_Message_Exception + */ + public function setTileId($tileId) + { + if (!is_string($tileId)) { + throw new Zend_Mobile_Push_Message_Exception('$tileId is not a string'); + } + $this->_tileId = $tileId; + return $this; + } + + /** + * Get Delay + * + * @return int + */ + public function getDelay() + { + if (!$this->_delay) { + return self::DELAY_IMMEDIATE; + } + return $this->_delay; + } + + /** + * Set Delay + * + * @param int $delay + * @return Zend_Mobile_Push_Message_Mpns_Tile + * @throws Zend_Mobile_Push_Message_Exception + */ + public function setDelay($delay) + { + if (!in_array($delay, array( + self::DELAY_IMMEDIATE, + self::DELAY_450S, + self::DELAY_900S + ))) { + throw new Zend_Mobile_Push_Message_Exception('$delay must be one of the DELAY_* constants'); + } + $this->_delay = $delay; + return $this; + } + + /** + * Get Notification Type + * + * @return string + */ + public static function getNotificationType() + { + return 'token'; + } + + /** + * Get XML Payload + * + * @return string + */ + public function getXmlPayload() + { + $ret = '' + . '' + . '_tileId) ? ' Id="' . htmlspecialchars($this->_tileId) . '"' : '') . '>' + . '' . htmlspecialchars($this->_backgroundImage) . '' + . '' . (int) $this->_count . '' + . '' . htmlspecialchars($this->_title) . ''; + + if ($this->_backBackgroundImage) { + $ret .= '' . htmlspecialchars($this->_backBackgroundImage) . ''; + } + if ($this->_backTitle) { + $ret .= '' . htmlspecialchars($this->_backTitle) . ''; + } + if ($this->_backContent) { + $ret .= '' . htmlspecialchars($this->_backContent) . ''; + } + + $ret .= '' + . ''; + return $ret; + } + + /** + * Validate proper mpns message + * + * @return boolean + */ + public function validate() + { + if (!isset($this->_token) || strlen($this->_token) === 0) { + return false; + } + if (empty($this->_backgroundImage)) { + return false; + } + if (empty($this->_title)) { + return false; + } + return parent::validate(); + } +}