diff -r 877f952ae2bd -r 6b6c2214f778 web/lib/Zend/Mobile/Push/Message/Mpns/Toast.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Mobile/Push/Message/Mpns/Toast.php Thu Mar 21 19:52:38 2013 +0100 @@ -0,0 +1,225 @@ +_title; + } + + /** + * Set Title + * + * @param string $title + * @return Zend_Mobile_Push_Message_Mpns_Toast + * @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 Message + * + * @return string + */ + public function getMessage() + { + return $this->_msg; + } + + /** + * Set Message + * + * @param string $msg + * @return Zend_Mobile_Push_Message_Mpns_Toast + * @throws Zend_Mobile_Push_Message_Exception + */ + public function setMessage($msg) + { + if (!is_string($msg)) { + throw new Zend_Mobile_Push_Message_Exception('$msg must be a string'); + } + $this->_msg = $msg; + return $this; + } + + /** + * Get Params + * + * @return string + */ + public function getParams() + { + return $this->_params; + } + + /** + * Set Params + * + * @param string $params + * @return Zend_Mobile_Push_Message_Mpns_Toast + * @throws Zend_Mobile_Push_Message_Exception + */ + public function setParams($params) + { + if (!is_string($params)) { + throw new Zend_Mobile_Push_Message_Exception('$params must be a string'); + } + $this->_params = $params; + 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_Toast + * @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 'toast'; + } + + /** + * Get XML Payload + * + * @return string + */ + public function getXmlPayload() + { + $ret = '' + . '' + . '' + . '' . htmlspecialchars($this->_title) . '' + . '' . htmlspecialchars($this->_msg) . ''; + if (!empty($this->_params)) { + $ret .= '' . htmlspecialchars($this->_params) . ''; + } + $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->_title)) { + return false; + } + if (empty($this->_msg)) { + return false; + } + return parent::validate(); + } +}