예제 #1
0
 public function api_load_times()
 {
     /*Initialize the Mite API connector class*/
     $mite = new Mite\Mite(MITE_SUB, MITE_KEY);
     /*Get your own userID*/
     $userID = $mite->getMyself()->id;
     $stepper = array('a' => 0, 'u' => 0);
     /*Get all times which belong to me*/
     $e = $mite->getTimes(array(), array(), array(), array($userID), null, false, false, false, false, null, MITE_TIMES, false);
     for ($e->rewind(); $e->valid(); $e->next()) {
         $entry = $e->current();
         /*MAP ALL TIMES WITH WORKTIME*/
         if ($entry->minutes > 0) {
             $time = Time::find(array('conditions' => array('project_name = ? AND service_name = ? AND minutes = ? AND created = ?', $entry->project_name, $entry->service_name, $entry->minutes, strtotime($entry->date_at))));
             if (!$time) {
                 $save = Time::create(array('project_name' => $entry->project_name, 'service_name' => $entry->service_name, 'minutes' => $entry->minutes, 'created' => strtotime($entry->date_at)));
                 $stepper['a']++;
             } else {
                 $time->project_name = $entry->project_name;
                 $time->service_name = $entry->service_name;
                 $time->minutes = $entry->minutes;
                 $time->created = strtotime($entry->date_at);
                 $time->save();
                 $stepper['u']++;
             }
         }
         unset($entry);
     }
     /*Status*/
     echo "\t\t\t" . $stepper['a'] . " entries " . ($stepper['a'] > 1 ? 'have' : 'has') . " been added...\n";
     echo "\t\t\t" . $stepper['u'] . " entries " . ($stepper['u'] > 1 ? 'have' : 'has') . " been updated...\n";
 }
 public function testIsRTLEnabled()
 {
     $article = InstantArticle::create()->withCanonicalURL('http://wp.localtest.me/2016/04/12/stress-on-earth/')->enableAutomaticAdPlacement()->enableRTL()->withHeader(Header::create()->withTitle(H1::create()->appendText('Peace on <b>earth</b>'))->addAuthor(Author::create()->withName('bill'))->withPublishTime(Time::create(Time::PUBLISHED)->withDatetime(\DateTime::createFromFormat('j-M-Y G:i:s', '14-Aug-1984 19:30:00'))))->addChild(Paragraph::create()->appendText('Yes, peace is good for everybody!')->appendText(LineBreak::create())->appendText(' Man kind.'));
     $result = $article->render();
     $expected = '<!doctype html>' . '<html dir="rtl">' . '<head>' . '<link rel="canonical" href="http://wp.localtest.me/2016/04/12/stress-on-earth/"/>' . '<meta charset="utf-8"/>' . '<meta property="op:generator" content="facebook-instant-articles-sdk-php"/>' . '<meta property="op:generator:version" content="1.5.2"/>' . '<meta property="op:markup_version" content="v1.0"/>' . '</head>' . '<body>' . '<article>' . '<header>' . '<h1>Peace on &lt;b&gt;earth&lt;/b&gt;</h1>' . '<time class="op-published" datetime="1984-08-14T19:30:00+00:00">August 14th, 7:30pm</time>' . '<address>' . '<a>bill</a>' . '</address>' . '</header>' . '<p>Yes, peace is good for everybody!<br/> Man kind.</p>' . '</article>' . '</body>' . '</html>';
     $this->assertEquals($expected, $result);
 }
예제 #3
0
 public function testRenderModified()
 {
     $time = Time::create(Time::PUBLISHED)->withDatetime($this->timeDate);
     $expected = '<time class="op-published" datetime="1984-08-14T19:30:00+00:00">' . 'August 14th, 7:30pm' . '</time>';
     $rendered = $time->render();
     $this->assertEquals($expected, $rendered);
 }
예제 #4
0
 public function testCompleteHeader()
 {
     date_default_timezone_set('UTC');
     $inline = '<script>alert("test & more test");</script>';
     $header = Header::create()->withTitle('Big Top Title')->withSubTitle('Smaller SubTitle')->withPublishTime(Time::create(Time::PUBLISHED)->withDatetime(\DateTime::createFromFormat('j-M-Y G:i:s', '14-Aug-1984 19:30:00')))->withModifyTime(Time::create(Time::MODIFIED)->withDatetime(\DateTime::createFromFormat('j-M-Y G:i:s', '10-Feb-2016 10:00:00')))->addAuthor(Author::create()->withName('Author One')->withDescription('Passionate coder and mountain biker'))->addAuthor(Author::create()->withName('Author Two')->withDescription('Weend surfer with heavy weight coding skils')->withURL('http://facebook.com/author'))->withKicker('Some kicker of this article')->withCover(Image::create()->withURL('https://jpeg.org/images/jpegls-home.jpg')->withCaption(Caption::create()->appendText('Some caption to the image')))->addAd(Ad::create()->withSource('http://foo.com'))->addAd(Ad::create()->withSource('http://foo.com')->withWidth(350)->withHeight(50)->enableDefaultForReuse())->addAd(Ad::create()->withWidth(300)->withHeight(250)->enableDefaultForReuse()->withHTML($inline));
     $expected = '<header>' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home.jpg"/>' . '<figcaption>Some caption to the image</figcaption>' . '</figure>' . '<h1>Big Top Title</h1>' . '<h2>Smaller SubTitle</h2>' . '<time class="op-published" datetime="1984-08-14T19:30:00+00:00">August 14th, 7:30pm</time>' . '<time class="op-modified" datetime="2016-02-10T10:00:00+00:00">February 10th, 10:00am</time>' . '<address>' . '<a>Author One</a>' . 'Passionate coder and mountain biker' . '</address>' . '<address>' . '<a href="http://facebook.com/author" rel="facebook">Author Two</a>' . 'Weend surfer with heavy weight coding skils' . '</address>' . '<h3 class="op-kicker">Some kicker of this article</h3>' . '<section class="op-ad-template">' . '<figure class="op-ad">' . '<iframe src="http://foo.com"></iframe>' . '</figure>' . '<figure class="op-ad op-ad-default">' . '<iframe src="http://foo.com" width="350" height="50"></iframe>' . '</figure>' . '<figure class="op-ad">' . '<iframe width="300" height="250">' . '<script>alert("test & more test");</script>' . '</iframe>' . '</figure>' . '</section>' . '</header>';
     $rendered = $header->render();
     $this->assertEquals($expected, $rendered);
 }
 public function testImport()
 {
     $prm = Primitive::time('test')->setSingle(true)->setMax(Time::create('00:12:00'))->setMin(Time::create('00:10:00'));
     $array = array(0 => array('test' => '00:12:01'), 1 => array('test' => '00:14:00'), 2 => array('test' => '00:09:59'), 3 => array('test' => '00:11:00'), 4 => array('test' => '00:10:00'), 5 => array('test' => '00:12:00'));
     $this->assertFalse($prm->import($array[0]));
     $this->assertFalse($prm->import($array[1]));
     $this->assertFalse($prm->import($array[2]));
     $this->assertTrue($prm->import($array[3]));
     $this->assertTrue($prm->import($array[4]));
     $this->assertTrue($prm->import($array[5]));
 }
예제 #6
0
 public static function stringToTimeList($string)
 {
     $list = array();
     $times = split("([,; \n]+)", $string);
     for ($i = 0, $size = count($times); $i < $size; ++$i) {
         $time = mb_ereg_replace('[^0-9:]', ':', $times[$i]);
         try {
             $list[] = Time::create($time);
         } catch (WrongArgumentException $e) {
             /* ignore */
         }
     }
     return $list;
 }
예제 #7
0
 public function api_add()
 {
     $save = Time::create(array('project_name' => 'Projektbezeichnung', 'service_name' => 'Geleisteter Service', 'minutes' => 0, 'created' => strtotime($_POST['date'])));
     return Time::last()->id;
 }
 /**
  * 
  * @return string
  */
 public function getExpireHTML()
 {
     if (!$this->owner->Secured) {
         return;
     }
     if ($this->owner instanceof Folder) {
         $ret = "N/A";
     } else {
         switch ($this->owner->ExpiryType) {
             case 'AtAFixedDate':
                 if ($expireDate = $this->owner->ExpireAtDate) {
                     $datetime = new SS_Datetime();
                     $datetime->setValue($expireDate);
                     $now = $today = date('Y-m-d H:i:s');
                     if ($expireDate > $now) {
                         $expire = _t("FileSecured.EmbargoedNotExpired", "Not expired, will expire ");
                     } else {
                         $expire = _t("FileSecured.EmbargoedExpired", "Expired ");
                     }
                     $time = Time::create();
                     $time->setValue($datetime->Time());
                     $date = Date::create();
                     $date->setValue($datetime->Date());
                     $ret = $expire . " at " . $time->Nice() . ", " . $date->Long();
                 } else {
                     $ret = _t("FileSecured.EmbargoedNoDateSetNotExpired", "No embargoing date/time is set, so treated as not expired");
                 }
                 break;
             default:
                 //case 'None':
                 $ret = "Not expired";
         }
     }
     return $ret;
 }
 /**
  * @return TestUser
  */
 private function spawnUser($options = array())
 {
     $options += array('id' => '77', 'credentials' => Credentials::create(), 'lastLogin' => Timestamp::create('2011-12-31'), 'registered' => Timestamp::create('2011-12-30'), 'strangeTime' => Time::create('01:23:45'), 'city' => null, 'firstOptional' => null, 'secondOptional' => null, 'url' => HttpUrl::create()->parse('https://www.github.com'), 'properties' => Hstore::make(array('a' => 'apple', 'b' => 'bananas')), 'ip' => IpAddress::create('127.0.0.1'));
     return $this->spawnObject(TestUser::create(), $options);
 }
 public function testIsValid()
 {
     $ia = InstantArticle::create()->withCanonicalURL('http://wp.localtest.me/2016/04/12/stress-on-earth/')->enableAutomaticAdPlacement()->withHeader(Header::create()->withTitle(H1::create()->appendText('Peace on <b>earth</b>'))->addAuthor(Author::create()->withName('bill'))->withPublishTime(Time::create(Time::PUBLISHED)->withDatetime(\DateTime::createFromFormat('j-M-Y G:i:s', '14-Aug-1984 19:30:00'))))->addChild(Paragraph::create()->appendText('Yes, peace is good for everybody!')->appendText(LineBreak::create())->appendText(' Man kind.'));
     $this->assertTrue($ia->isValid());
 }