public function apply($transformer, $instant_article, $node)
 {
     // Builds the slideshow
     $slideshow = Slideshow::create();
     $instant_article->addChild($slideshow);
     $gallery = $this->getProperty(self::PROPERTY_JETPACK_DATA_GALLERY, $node);
     if ($gallery && isset($gallery)) {
         foreach ($gallery as $gallery_image) {
             // Constructs Image if it contains URL
             if (!Type::isTextEmpty($gallery_image['src'])) {
                 $image = Image::create();
                 $image->withURL($gallery_image['src']);
                 // Constructs Caption element when present in the JSON
                 if (!Type::isTextEmpty($gallery_image['caption'])) {
                     $caption = Caption::create();
                     $caption->appendText($gallery_image['caption']);
                     $image->withCaption($caption);
                 }
                 $slideshow->addImage($image);
             }
         }
     }
     $transformer->transform($slideshow, $node);
     return $instant_article;
 }
 public function apply($transformer, $header, $node)
 {
     $page_url = $this->getProperty(self::PROPERTY_SPONSOR_PAGE_URL, $node);
     if ($page_url && !Type::isTextEmpty($page_url)) {
         $sponsor = Sponsor::create();
         $header->withSponsor($sponsor);
         $sponsor->withPageUrl($page_url);
     }
     return $header;
 }
 public function get($node)
 {
     $content = null;
     Type::enforce($node, 'DOMNode');
     $elements = self::findAll($node, $this->selector);
     if (!empty($elements) && $elements->item(0)) {
         $element = $elements->item(0);
         if ($this->attribute) {
             $content = $element->getAttribute($this->attribute);
         } else {
             $content = $element->textContent;
         }
     }
     if (!Type::isTextEmpty($content)) {
         return json_decode($content, true);
     }
     return null;
 }
示例#4
0
 /**
  * Overrides the Element::isValid().
  *
  * @see Element::isValid().
  * @return true for valid GeoTag that contains not empty script, false otherwise.
  */
 public function isValid()
 {
     return !Type::isTextEmpty($this->script);
 }
 public function get($node)
 {
     Type::enforce($node, 'DOMNode');
     $elements = self::findAll($node, $this->selector);
     if (!empty($elements) && $elements->item(0)) {
         $element = $elements->item(0);
         if ($this->attribute) {
             $result = $element->getAttribute($this->attribute);
         } else {
             $result = $element->textContent;
         }
         if (!Type::isTextEmpty($this->prefix)) {
             $result = $this->prefix . $result;
         }
         if (!Type::isTextEmpty($this->suffix)) {
             $result = $result . $this->suffix;
         }
         return $result;
     }
     return null;
 }
示例#6
0
 /**
  * Overrides the Element::isValid().
  *
  * @see Element::isValid().
  * @return true for valid Author that contains not empty name, false otherwise.
  */
 public function isValid()
 {
     return !Type::isTextEmpty($this->name);
 }
 public function testStringEmpty()
 {
     $this->assertTrue(Type::isTextEmpty(""));
     $this->assertTrue(Type::isTextEmpty("  "));
     $this->assertTrue(Type::isTextEmpty("\t\t"));
     $this->assertTrue(Type::isTextEmpty(" "));
     $this->assertTrue(Type::isTextEmpty("\n"));
 }
 public function isValid()
 {
     $header_valid = false;
     if ($this->getHeader()) {
         $header_valid = $this->getHeader()->isValid();
     }
     $items = $this->getChildren();
     $one_item_valid = false;
     if ($items) {
         foreach ($items as $item) {
             if ($item->isValid()) {
                 $one_item_valid = true;
                 break;
             }
         }
     }
     $footer_valid = true;
     if ($this->getFooter()) {
         $footer_valid = $this->getFooter()->isValid();
     }
     return $this->canonicalURL && !Type::isTextEmpty($this->canonicalURL) && $header_valid && $footer_valid && $one_item_valid;
 }
 /**
  * Overrides the Element::isValid().
  *
  * @see Element::isValid().
  * @return true for valid ListElement that contains at least one ListItem's valid, false otherwise.
  */
 public function isValid()
 {
     return !Type::isTextEmpty($this->page_url);
 }
示例#10
0
 /**
  * Overrides the Element::isValid().
  * @see Element::isValid().
  * @return true for valid Ad that contains valid src or html, false otherwise.
  */
 public function isValid()
 {
     return !Type::isTextEmpty($this->source) || $this->html;
 }
 /**
  * Overrides the Element::isValid().
  *
  * @see Element::isValid().
  * @return true for valid tag, false otherwise.
  */
 public function isValid()
 {
     $textContent = '';
     foreach ($this->textChildren as $content) {
         // Recursive check on TextContainer, if something inside is valid, this is valid.
         if (Type::is($content, TextContainer::getClassName()) && $content->isValid()) {
             return true;
             // If is string content, concat to check if it is not only a bunch of empty chars.
         } elseif (Type::is($content, Type::STRING)) {
             $textContent = $textContent . $content;
         }
     }
     return !Type::isTextEmpty($textContent);
 }
 /**
  * Overrides the Element::isValid().
  *
  * @see Element::isValid().
  * @return true for valid Interactive that contains valid source or html, false otherwise.
  */
 public function isValid()
 {
     return $this->html || !Type::isTextEmpty($this->source) && $this->height && $this->width;
 }