Beispiel #1
0
 /**
  * Convert LiveDocx service return value from list methods to consistent PHP array
  *
  * @param  array $list
  * @return array
  * @since  LiveDocx 1.0 
  */
 protected function _backendListArrayToMultiAssocArray($list)
 {
     $this->logIn();
     $ret = array();
     if (isset($list->ArrayOfString)) {
         foreach ($list->ArrayOfString as $a) {
             if (is_array($a)) {
                 // 1 template only
                 $o = new \StdClass();
                 $o->string = $a;
             } else {
                 // 2 or more templates
                 $o = $a;
             }
             unset($a);
             if (isset($o->string)) {
                 $date1 = new Date($o->string[3], Date::RFC_1123);
                 $date2 = new Date($o->string[1], Date::RFC_1123);
                 $ret[] = array('filename' => $o->string[0], 'fileSize' => (int) $o->string[2], 'createTime' => (int) $date1->get(Date::TIMESTAMP), 'modifyTime' => (int) $date2->get(Date::TIMESTAMP));
             }
         }
     }
     return $ret;
 }
Beispiel #2
0
 /**
  * Decorator to format return value of list methods
  *
  * @param array $result
  * @return string
  */
 public static function listDecorator($result)
 {
     $ret = '';
     $date = new Date();
     if (count($result) > 0) {
         foreach ($result as $record) {
             $date->set($record['createTime']);
             $createTimeFormatted = $date->get(Date::RFC_1123);
             $date->set($record['modifyTime']);
             $modifyTimeFormatted = $date->get(Date::RFC_1123);
             $ret .= sprintf('         Filename  : %s%s', $record['filename'], PHP_EOL);
             $ret .= sprintf('         File Size : %d b%s', $record['fileSize'], PHP_EOL);
             $ret .= sprintf('     Creation Time : %d (%s)%s', $record['createTime'], $createTimeFormatted, PHP_EOL);
             $ret .= sprintf('Last Modified Time : %d (%s)%s', $record['modifyTime'], $modifyTimeFormatted, PHP_EOL);
             $ret .= PHP_EOL;
         }
     }
     unset($date);
     return $ret;
 }
Beispiel #3
0
 /**
  * Get posts matching the arguments
  *
  * If no date or url is given, most recent date will be used
  *
  * @param  string    $tag Optional filtering by tag
  * @param  Zend_Date $dt  Optional filtering by date
  * @param  string    $url Optional filtering by url
  * @throws Zend_Service_Delicious_Exception
  * @return Zend_Service_Delicious_PostList
  */
 public function getPosts($tag = null, Date $dt = null, $url = null)
 {
     $parms = array();
     if ($tag) {
         $parms['tag'] = $tag;
     }
     if ($url) {
         $parms['url'] = $url;
     }
     if ($dt) {
         $parms['dt'] = $dt->get('Y-m-d\\TH:i:s\\Z');
     }
     $response = $this->makeRequest(self::PATH_POSTS_GET, $parms);
     return $this->_parseXmlPostList($response);
 }
Beispiel #4
0
 public function testRespondsToValidConfirmationWithBodyContainingHubChallenge()
 {
     $this->_tableGateway->expects($this->any())->method('find')->with($this->equalTo('verifytokenkey'))->will($this->returnValue($this->_rowset));
     $t = new Date\Date();
     $rowdata = array('id' => 'verifytokenkey', 'verify_token' => hash('sha256', 'cba'), 'created_time' => $t->get(Date\Date::TIMESTAMP), 'lease_seconds' => 10000);
     $row = new \Zend\Db\Table\Row(array('data' => $rowdata));
     $this->_rowset->expects($this->any())->method('current')->will($this->returnValue($row));
     // require for the count call on the rowset in Model/Subscription
     $this->_rowset->expects($this->any())->method('count')->will($this->returnValue(1));
     $this->_tableGateway->expects($this->once())->method('update')->with($this->equalTo(array('id' => 'verifytokenkey', 'verify_token' => hash('sha256', 'cba'), 'created_time' => $t->get(Date\Date::TIMESTAMP), 'lease_seconds' => 1234567, 'subscription_state' => 'verified', 'expiration_time' => $t->add(1234567, Date\Date::SECOND)->get('yyyy-MM-dd HH:mm:ss'))), $this->equalTo('id = \'verifytokenkey\''));
     $this->_adapter->expects($this->once())->method('quoteInto')->with($this->equalTo('id = ?'), $this->equalTo('verifytokenkey'))->will($this->returnValue('id = \'verifytokenkey\''));
     $this->_callback->handle($this->_get);
     $this->assertTrue($this->_callback->getHttpResponse()->getBody() == 'abc');
 }
Beispiel #5
0
 /**
  * @ZF-10150
  */
 public function testChineseFullDates()
 {
     $date = new Date(array('year' => 2008, 'month' => 10, 'day' => 12));
     $this->assertEquals('2008年10月12日', $date->get(Date::DATE_LONG, 'zh'));
 }
Beispiel #6
0
 /**
  * Return a list of standard protocol/optional parameters for addition to
  * client's POST body that are specific to the current Hub Server URL
  *
  * @param  string $hubUrl
  * @param  mode $hubUrl
  * @return string
  */
 protected function _getRequestParameters($hubUrl, $mode)
 {
     if (!in_array($mode, array('subscribe', 'unsubscribe'))) {
         throw new Exception('Invalid mode specified: "' . $mode . '" which should have been "subscribe" or "unsubscribe"');
     }
     $params = array('hub.mode' => $mode, 'hub.topic' => $this->getTopicUrl());
     if ($this->getPreferredVerificationMode() == PubSubHubbub::VERIFICATION_MODE_SYNC) {
         $vmodes = array(PubSubHubbub::VERIFICATION_MODE_SYNC, PubSubHubbub::VERIFICATION_MODE_ASYNC);
     } else {
         $vmodes = array(PubSubHubbub::VERIFICATION_MODE_ASYNC, PubSubHubbub::VERIFICATION_MODE_SYNC);
     }
     $params['hub.verify'] = array();
     foreach ($vmodes as $vmode) {
         $params['hub.verify'][] = $vmode;
     }
     /**
      * Establish a persistent verify_token and attach key to callback
      * URL's path/querystring
      */
     $key = $this->_generateSubscriptionKey($params, $hubUrl);
     $token = $this->_generateVerifyToken();
     $params['hub.verify_token'] = $token;
     // Note: query string only usable with PuSH 0.2 Hubs
     if (!$this->_usePathParameter) {
         $params['hub.callback'] = $this->getCallbackUrl() . '?xhub.subscription=' . PubSubHubbub::urlencode($key);
     } else {
         $params['hub.callback'] = rtrim($this->getCallbackUrl(), '/') . '/' . PubSubHubbub::urlencode($key);
     }
     if ($mode == 'subscribe' && !is_null($this->getLeaseSeconds())) {
         $params['hub.lease_seconds'] = $this->getLeaseSeconds();
     }
     // hub.secret not currently supported
     $optParams = $this->getParameters();
     foreach ($optParams as $name => $value) {
         $params[$name] = $value;
     }
     // store subscription to storage
     $now = new Date\Date();
     $expires = null;
     if (isset($params['hub.lease_seconds'])) {
         $expires = $now->add($params['hub.lease_seconds'], Date\Date::SECOND)->get('yyyy-MM-dd HH:mm:ss');
     }
     $data = array('id' => $key, 'topic_url' => $params['hub.topic'], 'hub_url' => $hubUrl, 'created_time' => $now->get('yyyy-MM-dd HH:mm:ss'), 'lease_seconds' => $expires, 'verify_token' => hash('sha256', $params['hub.verify_token']), 'secret' => null, 'expiration_time' => $expires, 'subscription_state' => PubSubHubbub::SUBSCRIPTION_NOTVERIFIED);
     $this->getStorage()->setSubscription($data);
     return $this->_toByteValueOrderedString($this->_urlEncode($params));
 }
Beispiel #7
0
    /**
     * @ZF-7154
     */
    public function testZF7154()
    {
        $locale = new Locale('de_AT');

        $date = new Date(1577833200,$locale);
        $date2 = new Date(2006, Date::YEAR);
        $date->setTimeZone(date_default_timezone_get());

        $date->setYear(2000);
        $date->setMonth('Apr');
        $this->assertSame('2000-04-01T04:00:00+05:00', $date->get(Date::W3C));

        $date->setYear(2004);
        $date->setMonth('Februar');
        $this->assertSame('2004-02-01T04:00:00+05:00', $date->get(Date::W3C));
    }