Beispiel #1
0
 public function testSetWhenUsesZendDateObject()
 {
     $entry = new Writer\Deleted();
     $entry->setWhen(new Date\Date('1234567890', Date\Date::TIMESTAMP));
     $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP);
     $this->assertTrue($myDate->equals($entry->getWhen()));
 }
Beispiel #2
0
 /**
  * Save subscription to RDMBS
  *
  * @param array $data
  * @return bool
  */
 public function setSubscription(array $data)
 {
     if (!isset($data['id'])) {
         throw new PubSubHubbub\Exception('ID must be set before attempting a save');
     }
     $result = $this->_db->select(array('id' => $data['id']));
     if ($result && 0 < count($result)) {
         $data['created_time'] = $result->current()->created_time;
         $now = new Date\Date();
         if (array_key_exists('lease_seconds', $data) && $data['lease_seconds']) {
             $data['expiration_time'] = $now->add($data['lease_seconds'], Date\Date::SECOND)->get('yyyy-MM-dd HH:mm:ss');
         }
         $this->_db->update($data, array('id' => $data['id']));
         return false;
     }
     $this->_db->insert($data);
     return true;
 }
Beispiel #3
0
 /**
  * Save subscription to RDMBS
  *
  * @param array $data
  * @return bool
  */
 public function setSubscription(array $data)
 {
     if (!isset($data['id'])) {
         throw new PubSubHubbub\Exception('ID must be set before attempting a save');
     }
     $result = $this->_db->find($data['id']);
     if ($result) {
         $data['created_time'] = $result->current()->created_time;
         $now = new Date\Date();
         if ($data['lease_seconds']) {
             $data['expiration_time'] = $now->add($data['lease_seconds'], Date\Date::SECOND)->get('yyyy-MM-dd HH:mm:ss');
         }
         $this->_db->update($data, $this->_db->getAdapter()->quoteInto('id = ?', $data['id']));
         return false;
     }
     $this->_db->insert($data);
     return true;
 }
Beispiel #4
0
 public function teardown()
 {
     Date\Date::setOptions($this->_options);
 }
Beispiel #5
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->toString('Y-m-d\\TH:i:s\\Z', 'php');
     }
     $response = $this->makeRequest(self::PATH_POSTS_GET, $parms);
     return $this->_parseXmlPostList($response);
 }
Beispiel #6
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 #7
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Date\Date;
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
/*
 * ALTERNATIVE: Specify username and password in constructor
 */
/*
$mailMerge = new MailMerge(
    array (
        'username' => DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME,
        'password' => DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD
    )
);
*/
$mailMerge->setLocalTemplate('template.doc');
$mailMerge->assign('customer_number', sprintf("#%'10s", rand(0, 1000000000)))->assign('invoice_number', sprintf("#%'10s", rand(0, 1000000000)))->assign('account_number', sprintf("#%'10s", rand(0, 1000000000)));
$billData = array('phone' => '+22 (0)333 444 555', 'date' => Date::now()->toString(Date::DATE_LONG), 'name' => 'James Henry Brown', 'service_phone' => '+22 (0)333 444 559', 'service_fax' => '+22 (0)333 444 558', 'month' => sprintf('%s %s', Date::now()->toString(Date::MONTH_NAME), Date::now()->toString(Date::YEAR)), 'monthly_fee' => '15.00', 'total_net' => '19.60', 'tax' => '19.00', 'tax_value' => '3.72', 'total' => '23.32');
$mailMerge->assign($billData);
$billConnections = array(array('connection_number' => '+11 (0)222 333 441', 'connection_duration' => '00:01:01', 'fee' => '1.15'), array('connection_number' => '+11 (0)222 333 442', 'connection_duration' => '00:01:02', 'fee' => '1.15'), array('connection_number' => '+11 (0)222 333 443', 'connection_duration' => '00:01:03', 'fee' => '1.15'), array('connection_number' => '+11 (0)222 333 444', 'connection_duration' => '00:01:04', 'fee' => '1.15'));
$mailMerge->assign('connection', $billConnections);
$mailMerge->createDocument();
$document = $mailMerge->retrieveDocument('pdf');
unset($mailMerge);
file_put_contents('document.pdf', $document);
Beispiel #8
0
 public function testSetLastBuildDateUsesZendDateObject()
 {
     $writer = new Writer\Feed();
     $writer->setLastBuildDate(new Date\Date('1234567890', Date\Date::TIMESTAMP));
     $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP);
     $this->assertTrue($myDate->equals($writer->getLastBuildDate()));
 }
Beispiel #9
0
 /**
  * Check if the given date fits the given format
  *
  * @param  string $value  Date to check
  * @return boolean False when date does not fit the format
  */
 private function _checkFormat($value)
 {
     try {
         $parsed = \Zend\Locale\Format::getDate($value, array('date_format' => $this->_format, 'format_type' => 'iso', 'fix_date' => false));
         if (isset($parsed['year']) and (strpos(strtoupper($this->_format), 'YY') !== false and strpos(strtoupper($this->_format), 'YYYY') === false)) {
             $parsed['year'] = ZendDate\Date::getFullYear($parsed['year']);
         }
     } catch (\Exception $e) {
         // Date can not be parsed
         return false;
     }
     if ((strpos($this->_format, 'Y') !== false or strpos($this->_format, 'y') !== false) and !isset($parsed['year'])) {
         // Year expected but not found
         return false;
     }
     if (strpos($this->_format, 'M') !== false and !isset($parsed['month'])) {
         // Month expected but not found
         return false;
     }
     if (strpos($this->_format, 'd') !== false and !isset($parsed['day'])) {
         // Day expected but not found
         return false;
     }
     if ((strpos($this->_format, 'H') !== false or strpos($this->_format, 'h') !== false) and !isset($parsed['hour'])) {
         // Hour expected but not found
         return false;
     }
     if (strpos($this->_format, 'm') !== false and !isset($parsed['minute'])) {
         // Minute expected but not found
         return false;
     }
     if (strpos($this->_format, 's') !== false and !isset($parsed['second'])) {
         // Second expected  but not found
         return false;
     }
     // Date fits the format
     return true;
 }
Beispiel #10
0
 /**
  * ZF-6457
  */
 public function testArrayVerification()
 {
     $date = new Date\Date();
     $array = $date->toArray();
     $this->assertTrue($this->_validator->isValid($array), "array expected to be valid");
 }
Beispiel #11
0
 /**
  * Convert the DateTime into an AMF Date
  *
  * @param  DateTime|\Zend\Date\Date $data
  * @return Zend\AMF\Parser\AMF0\Serializer
  */
 public function writeDate($data)
 {
     if ($data instanceof \DateTime) {
         $dateString = $data->format('U');
     } elseif ($data instanceof Date\Date) {
         $dateString = $data->toString('U');
     } else {
         throw new AMF\Exception('Invalid date specified; must be a DateTime or Zend_Date object');
     }
     $dateString *= 1000;
     // Make the conversion and remove milliseconds.
     $this->_stream->writeDouble($dateString);
     // Flash does not respect timezone but requires it.
     $this->_stream->writeInt(0);
     return $this;
 }
$tempDirectory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . md5(rand(1, 10000) . __FILE__);
if (is_dir($tempDirectory)) {
    recursiveRemoveDirectory($tempDirectory);
}
$logger->log(sprintf('Making temporary directory %s.', $tempDirectory), Logger::INFO);
mkdir($tempDirectory);
// -----------------------------------------------------------------------------
// Generate temporary documents
$tempFilenames = array();
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$mailMerge->setLocalTemplate('template.docx');
for ($iteration = 1; $iteration <= $iterations; $iteration++) {
    $tempFilename = sprintf('%s%s%010s.pdf', $tempDirectory, DIRECTORY_SEPARATOR, $iteration);
    $tempFilenames[] = $tempFilename;
    $mailMerge->assign('software', randomString())->assign('licensee', randomString())->assign('company', randomString())->assign('date', Date::now()->toString(Date::DATE_LONG))->assign('time', Date::now()->toString(Date::TIME_LONG))->assign('city', randomString())->assign('country', randomString());
    $mailMerge->createDocument();
    file_put_contents($tempFilename, $mailMerge->retrieveDocument('pdf'));
    $logger->log(sprintf('Generating temporary document %s.', $tempFilename), Logger::INFO);
}
unset($mailMerge);
// -----------------------------------------------------------------------------
// Concatenate temporary documents and write output document
$outputFilename = __DIR__ . DIRECTORY_SEPARATOR . 'document-concat.pdf';
$logger->log('Concatenating temporary documents...', Logger::INFO);
if (true === concatenatePdfFilenames($tempFilenames, $outputFilename, $processor)) {
    $logger->log(sprintf('...DONE. Saved output document as %s.', basename($outputFilename)), Logger::INFO);
} else {
    $logger->log(sprintf('...ERROR.'), Logger::ERR);
}
// -----------------------------------------------------------------------------
Beispiel #13
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Date\Date;
use Zend\Service\LiveDocx\MailMerge;
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$mailMerge->setLocalTemplate('template.docx');
$mailMerge->setFieldValue('software', 'Magic Graphical Compression Suite v1.9')->setFieldValue('licensee', 'Henry Döner-Meyer')->setFieldValue('company', 'Megasoft Co-operation')->setFieldValue('date', Date::now()->toString(Date::DATE_LONG))->setFieldValue('time', Date::now()->toString(Date::TIME_LONG))->setFieldValue('city', 'Bremen')->setFieldValue('country', 'Germany');
$mailMerge->createDocument();
// Get all metafiles
$metaFiles = $mailMerge->getAllMetafiles();
// Get just metafiles in specified range
//$metaFiles = $mailMerge->getMetafiles(1, 2);    // fromPage, toPage
foreach ($metaFiles as $pageNumber => $metaFileData) {
    $filename = sprintf('document-page-%d.wmf', $pageNumber);
    file_put_contents($filename, $metaFileData);
}
unset($mailMerge);
    /**
     * Defined by Zend_Filter_Interface
     *
     * Normalizes the given input
     *
     * @param  string $value Value to normalized
     * @return string|array The normalized value
     */
    public function filter($value)
    {
        if (is_array($value)) {
            $date = new Date($value, $this->_options['locale']);
            return $date->toString($this->_options['date_format']);
        } else if ($this->_options['precision'] === 0) {
            return Format::toInteger($value, $this->_options);
        } else if ($this->_options['precision'] === null) {
            return Format::toFloat($value, $this->_options);
        }

        return Format::toNumber($value, $this->_options);
    }
Beispiel #15
0
 /**
  * Get the entry's date of modification
  *
  * @return string
  */
 public function getDateModified()
 {
     if (array_key_exists('datemodified', $this->_data)) {
         return $this->_data['datemodified'];
     }
     $dateModified = null;
     $date = null;
     if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && $this->getType() !== Reader\Reader::TYPE_RSS_090) {
         $dateModified = $this->_xpath->evaluate('string(' . $this->_xpathQueryRss . '/pubDate)');
         if ($dateModified) {
             $dateModifiedParsed = strtotime($dateModified);
             if ($dateModifiedParsed) {
                 $date = new Date\Date($dateModifiedParsed);
             } else {
                 $dateStandards = array(Date\Date::RSS, Date\Date::RFC_822, Date\Date::RFC_2822, Date\Date::DATES);
                 $date = new Date\Date();
                 foreach ($dateStandards as $standard) {
                     try {
                         $date->set($dateModified, $standard);
                         break;
                     } catch (Date\Exception $e) {
                         if ($standard == Date\Date::DATES) {
                             require_once 'Zend/Feed/Exception.php';
                             throw new Exception('Could not load date due to unrecognised' . ' format (should follow RFC 822 or 2822):' . $e->getMessage(), 0, $e);
                         }
                     }
                 }
             }
         }
     }
     if (!$date) {
         $date = $this->getExtension('DublinCore')->getDate();
     }
     if (!$date) {
         $date = $this->getExtension('Atom')->getDateModified();
     }
     if (!$date) {
         $date = null;
     }
     $this->_data['datemodified'] = $date;
     return $this->_data['datemodified'];
 }
Beispiel #16
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Date\Date;
use Zend\Service\LiveDocx\MailMerge;
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$mailMerge->setLocalTemplate('template.docx');
$mailMerge->assign('software', 'Magic Graphical Compression Suite v1.9')->assign('licensee', 'Henry Döner-Meyer')->assign('company', 'Co-Operation')->assign('date', Date::now()->toString(Date::DATE_LONG))->assign('time', Date::now()->toString(Date::TIME_LONG))->assign('city', 'Berlin')->assign('country', 'Germany');
/**
 * ALTERNATIVE: Concatenating PDF files locally - basic
 * 
 * You can also assign multiple sets of data. In this case, each set of data
 * will populate the template and the resulting document (one per set of data)
 * will be appended to the previous document. Thus, in this example, we create
 * two documents that are concatenated into one PDF file.
 * 
 * NOTE: In the case that you wish to generate several thousand documents that
 *       are concatenated into one PDF, please take a look at the sample
 *       application 'generate-document-pdftk.php' in this directory.
 */
/*
$fieldValues = array (
    // set 1
    array (
        'software' => 'Magic Graphical Compression Suite v2.5',
        'licensee' => 'Henry Döner-Meyer',
        'company'  => 'Megasoft Co-Operation',
        'date'     => Date::now()->toString(Date::DATE_LONG),
        'time'     => Date::now()->toString(Date::TIME_LONG),
        'city'     => 'Berlin',
 /**
  * Get modification date (Unencoded Text)
  * @group ZFR002
  */
 public function testGetsDateModifiedFromAtom10()
 {
     $entry = Reader\Reader::importString(file_get_contents($this->_feedSamplePath . '/datemodified/atom10.xml'));
     $edate = new Date\Date();
     $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601);
     $this->assertTrue($edate->equals($entry->getDateModified()));
 }
Beispiel #18
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 #19
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 #20
0
 /**
  *
  *
  * @return Date\Date|null
  */
 public function getDate()
 {
     if (array_key_exists('date', $this->_data)) {
         return $this->_data['date'];
     }
     $d = null;
     $date = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc11:date)');
     if (!$date) {
         $date = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc10:date)');
     }
     if ($date) {
         $d = new Date\Date();
         $d->set($date, Date\Date::ISO_8601);
     }
     $this->_data['date'] = $d;
     return $this->_data['date'];
 }
Beispiel #21
0
 public function mktime($hour, $minute, $second, $month, $day, $year, $dst = -1, $gmt = false)
 {
     return parent::mktime($hour, $minute, $second, $month, $day, $year, $dst, $gmt);
 }
Beispiel #22
0
 /**
  * Returns the calculated month
  *
  * @param  string                          $calc    Calculation to make
  * @param  string|integer|array|\Zend\Date\Date  $month   Month to calculate with, if null the actual month is taken
  * @param  string|\Zend\Locale\Locale              $locale  Locale for parsing input
  * @return integer|\Zend\Date\Date  new time
  * @throws \Zend\Date\Exception
  */
 private function _month($calc, $month, $locale)
 {
     if ($month === null) {
         throw new Exception\InvalidArgumentException('parameter $month must be set, null is not allowed');
     }
     if ($locale === null) {
         $locale = $this->getLocale();
     }
     if ($month instanceof Date) {
         // extract month from object
         $found = $month->toString(self::MONTH_SHORT, 'iso', $locale);
     } else {
         if (is_numeric($month)) {
             $found = $month;
         } else {
             if (is_array($month)) {
                 if (isset($month['month']) === true) {
                     $month = $month['month'];
                 } else {
                     throw new Exception\InvalidArgumentException("no month given in array");
                 }
             } else {
                 $monthlist = Cldr::getList($locale, 'month');
                 $monthlist2 = Cldr::getList($locale, 'month', array('gregorian', 'format', 'abbreviated'));
                 $monthlist = array_merge($monthlist, $monthlist2);
                 $found = 0;
                 $cnt = 0;
                 foreach ($monthlist as $key => $value) {
                     if (strtoupper($value) == strtoupper($month)) {
                         $found = $key % 12 + 1;
                         break;
                     }
                     ++$cnt;
                 }
                 if ($found == 0) {
                     foreach ($monthlist2 as $key => $value) {
                         if (strtoupper(iconv_substr($value, 0, 1, 'UTF-8')) == strtoupper($month)) {
                             $found = $key + 1;
                             break;
                         }
                         ++$cnt;
                     }
                 }
                 if ($found == 0) {
                     throw new Exception\InvalidArgumentException("unknown month name ({$month})");
                 }
             }
         }
     }
     $return = $this->_calcdetail($calc, $found, self::MONTH_SHORT, $locale);
     if ($calc != 'cmp') {
         return $this;
     }
     return $return;
 }
Beispiel #23
0
 public function _getTime($sync = null)
 {
     return parent::_getTime($sync);
 }
Beispiel #24
0
 /**
  * @issue ZF-7908
  */
 public function testGetsDateModifiedFromRss20_UnrecognisedGmtFormat()
 {
     $feed = Reader\Reader::importString(file_get_contents($this->_feedSamplePath . '/datemodified/plain/rss20-zf-7908.xml'));
     $entry = $feed->current();
     //$this->assertEquals('Sunday 11 January 2009 09 55 59 +0000', $entry->getDateModified()->toString('EEEE dd MMMM YYYY HH mm ss ZZZ'));
     $edate = new Date\Date();
     $edate->set('Sun, 11 Jan 2009 09:55:59 GMT', Date\Date::RSS);
     $this->assertTrue($edate->equals($entry->getDateModified()));
 }
Beispiel #25
0
 /**
  * Get the entry modification date
  *
  * @return string
  */
 public function getDateModified()
 {
     if (array_key_exists('datemodified', $this->_data)) {
         return $this->_data['datemodified'];
     }
     $date = null;
     if ($this->_getAtomType() === Reader\Reader::TYPE_ATOM_03) {
         $dateModified = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:modified)');
     } else {
         $dateModified = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:updated)');
     }
     if ($dateModified) {
         $date = new Date\Date();
         $date->set($dateModified, Date\Date::ISO_8601);
     }
     $this->_data['datemodified'] = $date;
     return $this->_data['datemodified'];
 }
Beispiel #26
0
 public function testZendDateSerializedToAmf0Date()
 {
     $date = new Date\Date('October 23, 1978', null, 'en_US');
     $date->set('4:20:00', Date\Date::TIMES);
     $newBody = new Value\MessageBody('/1/onResult', null, $date);
     $this->_response->setObjectEncoding(0x0);
     $this->_response->addAmfBody($newBody);
     $this->_response->finalize();
     $testResponse = $this->_response->getResponse();
     // Load the expected response.
     $mockResponse = file_get_contents(__DIR__ . '/TestAsset/Response/dateAmf0Response.bin');
     // Check that the response matches the expected serialized value
     $this->assertEquals($mockResponse, $testResponse);
 }
Beispiel #27
0
 /**
  * Get update base
  *
  * @return Date\Date|null
  */
 public function getUpdateBase()
 {
     $updateBase = $this->_getData('updateBase');
     $date = null;
     if ($updateBase) {
         $date = new Date\Date();
         $date->set($updateBase, Date\Date::W3C);
     }
     return $date;
 }
Beispiel #28
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Date\Date;
use Zend\Service\LiveDocx\MailMerge;
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$mailMerge->setLocalTemplate('template.docx');
$mailMerge->assign('software', 'Magic Graphical Compression Suite v1.9')->assign('licensee', 'Daï Lemaitre')->assign('company', 'Megasoft Co-operation')->assign('date', Date::now()->toString(Date::DATE_LONG))->assign('time', Date::now()->toString(Date::TIME_LONG))->assign('city', 'Lyon')->assign('country', 'France');
$mailMerge->createDocument();
// Get all bitmaps
$bitmaps = $mailMerge->getAllBitmaps(100, 'png');
// zoomFactor, format
// Get just bitmaps in specified range
//$bitmaps = $mailMerge->getBitmaps(2, 2, 100, 'png');   // fromPage, toPage, zoomFactor, format
foreach ($bitmaps as $pageNumber => $bitmapData) {
    $filename = sprintf('document-page-%d.png', $pageNumber);
    file_put_contents($filename, $bitmapData);
}
unset($mailMerge);
Beispiel #29
0
 /**
  * Get the feed lastBuild date
  *
  * @return Date\Date
  */
 public function getLastBuildDate()
 {
     if (array_key_exists('lastBuildDate', $this->_data)) {
         return $this->_data['lastBuildDate'];
     }
     $lastBuildDate = null;
     $date = null;
     if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && $this->getType() !== Reader\Reader::TYPE_RSS_090) {
         $lastBuildDate = $this->_xpath->evaluate('string(/rss/channel/lastBuildDate)');
         if ($lastBuildDate) {
             $lastBuildDateParsed = strtotime($lastBuildDate);
             if ($lastBuildDateParsed) {
                 $date = new Date\Date($lastBuildDateParsed);
             } else {
                 $dateStandards = array(Date\Date::RSS, Date\Date::RFC_822, Date\Date::RFC_2822, Date\Date::DATES);
                 $date = new Date\Date();
                 foreach ($dateStandards as $standard) {
                     try {
                         $date->set($lastBuildDate, $standard);
                         break;
                     } catch (Date\Exception $e) {
                         if ($standard == Date\Date::DATES) {
                             throw new Exception('Could not load date due to unrecognised' . ' format (should follow RFC 822 or 2822):' . $e->getMessage(), 0, $e);
                         }
                     }
                 }
             }
         }
     }
     if (!$date) {
         $date = null;
     }
     $this->_data['lastBuildDate'] = $date;
     return $this->_data['lastBuildDate'];
 }
Beispiel #30
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));
 }