Esempio n. 1
0
 /**
  * Get first url pic
  *
  * Get the first url pic of a document,
  * if none is found, returns the default
  * url pic for a given resource checking if
  * it is Series, MultimediaObject of type
  * video or audio
  *
  * @param Series|MultimediaObject $object   Object to get the url (using $object->getPics())
  * @param boolean                 $absolute Returns absolute path
  * @param boolean                 $hd       Returns pic in HD
  *
  * @return string
  */
 public function getFirstUrlPic($object, $absolute = false, $hd = true)
 {
     $pics = $object->getPics();
     if (0 === count($pics)) {
         return $this->getDefaultUrlPicForObject($object, $absolute, $hd);
     } else {
         foreach ($pics as $pic) {
             if ($picUrl = $pic->getUrl()) {
                 break;
             }
         }
     }
     if ($absolute) {
         return $this->getAbsoluteUrlPic($picUrl);
     }
     return $picUrl;
 }
Esempio n. 2
0
 public function testPicsInSeries()
 {
     $url = realpath(__DIR__ . '/../Resources') . DIRECTORY_SEPARATOR . 'logo.png';
     $pic = new Pic();
     $pic->setUrl($url);
     $series = new Series();
     $pic1 = new Pic();
     $pic2 = new Pic();
     $this->assertEquals(0, count($series->getPics()));
     $series->addPic($pic);
     $this->assertEquals(1, count($series->getPics()));
     $this->assertTrue($series->containsPic($pic));
     $series->removePic($pic);
     $this->assertEquals(0, count($series->getPics()));
     $this->assertFalse($series->containsPic($pic));
     $picWithoutUrl = new Pic();
     $series->addPic($picWithoutUrl);
     $series->addPic($pic);
     $this->assertEquals(2, count($series->getPics()));
     $this->assertEquals($url, $series->getFirstUrlPic());
 }