public function initFromXmlNode(DomElement $node, $itemTagName)
 {
     $this->clear();
     $itemsNodes = $node->getElementsByTagName($itemTagName);
     foreach ($itemsNodes as $itemNode) {
         $this->addItem($itemNode->textContent);
     }
 }
 /**
  * Tests GadgetHtmlRenderer->addHeadTags()
  */
 public function testAddHeadTags()
 {
     ob_start();
     $this->GadgetHtmlRenderer->renderGadget($this->gadget, $this->view);
     ob_end_clean();
     $this->GadgetHtmlRenderer->addHeadTags($this->domElement, $this->domDocument);
     $tmpNodeList = $this->domElement->getElementsByTagName("style");
     $tmpNodeList = $this->domElement->getElementsByTagName("script");
     $script = '';
     foreach ($this->GadgetHtmlRenderer->gadget->features as $feature) {
         $script .= $this->gadgetContext->getRegistry()->getFeatureContent($feature, $this->gadgetContext, true);
     }
     foreach ($tmpNodeList as $tmpNode) {
         $this->assertEquals('text/javascript', $tmpNode->getAttribute('type'));
         $nodeValue = substr($tmpNode->nodeValue, 0, strpos($tmpNode->nodeValue, 'gadgets.config.init('));
         $this->assertEquals(trim($script), trim($nodeValue));
     }
 }
 /**
  * Tests GadgetHtmlRenderer->addHeadTags()
  */
 public function testAddHeadTags()
 {
     ob_start();
     $this->gadgetHtmlRenderer->renderGadget($this->gadget, $this->view);
     ob_end_clean();
     $this->gadgetHtmlRenderer->addHeadTags($this->domElement, $this->domDocument);
     // TODO: currently we just test the script part
     $tmpNodeList = $this->domElement->getElementsByTagName("script");
     $scripts = $this->gadgetHtmlRenderer->getJavaScripts();
     $idx = 0;
     foreach ($tmpNodeList as $tmpNode) {
         $script = $scripts[$idx++];
         if ($script['type'] == 'inline') {
             $this->assertEquals('text/javascript', $tmpNode->getAttribute('type'));
             $this->assertEquals(trim($script['content']), trim($tmpNode->nodeValue));
         } else {
             $this->assertEquals($script['content'], $tmpNode->getAttribute('src'));
         }
     }
 }
 /**
  * 
  * @param \DomElement $outputContainer
  * @return boolean
  */
 private function isPassedNoMessagesOutput(\DomElement $outputContainer)
 {
     $statusElements = $outputContainer->getElementsByTagName('status');
     if ($statusElements->length === 0) {
         return false;
     }
     $statusElement = $statusElements->item(0);
     if (!$statusElement->hasAttribute('value')) {
         return false;
     }
     return $statusElements->item(0)->getAttribute('value') == 'passed';
 }
Beispiel #5
0
 /**
  * @param DomElement $match
  * @return array
  */
 private function getLinkDumpArrayItem($match)
 {
     $url = $match->getElementsByTagName('a')->item(0)->getAttribute('href');
     return ['name' => trim($match->nodeValue), 'url' => $url];
 }
 function __construct(DomElement $span)
 {
     if (strpos($span->getAttribute('class'), 'modconflict') !== false) {
         $this->conflict = true;
     }
     foreach ($span->childNodes as $child) {
         $text = $child->textContent;
         if (strpos($text, '(moderation-rejected-auto)') !== false) {
             $this->rejected_auto = true;
         }
         if (strpos($text, '(moderation-rejected-batch)') !== false) {
             $this->rejected_batch = true;
         }
         $matches = null;
         if (preg_match('/\\(moderation-whois-link: ([^)]*)\\)/', $text, $matches)) {
             $this->ip = $matches[1];
         }
     }
     $links = $span->getElementsByTagName('a');
     foreach ($links as $link) {
         if (strpos($link->getAttribute('class'), 'mw-userlink') !== false) {
             $text = $link->textContent;
             # This is
             # 1) either the user who made an edit,
             # 2) or the moderator who rejected it.
             # Let's check the text BEFORE this link for
             # the presence of 'moderation-rejected-by'.
             if (strpos($link->previousSibling->textContent, "moderation-rejected-by") !== false) {
                 $this->rejected_by_user = $text;
             } else {
                 $this->user = $text;
             }
             continue;
         }
         $href = $link->getAttribute('href');
         switch ($link->nodeValue) {
             case '(moderation-show)':
                 $this->showLink = $href;
                 break;
             case '(moderation-approve)':
                 $this->approveLink = $href;
                 break;
             case '(moderation-approveall)':
                 $this->approveAllLink = $href;
                 break;
             case '(moderation-reject)':
                 $this->rejectLink = $href;
                 break;
             case '(moderation-rejectall)':
                 $this->rejectAllLink = $href;
                 break;
             case '(moderation-merge)':
                 $this->mergeLink = $href;
                 break;
             case '(moderation-merged-link)':
                 $this->mergedDiffLink = $href;
             case '(moderation-block)':
                 $this->blockLink = $href;
                 break;
             case '(moderation-unblock)':
                 $this->unblockLink = $href;
                 break;
             default:
                 $this->title = $link->textContent;
         }
     }
     $matches = null;
     preg_match('/modid=([0-9]+)/', $this->showLink, $matches);
     $this->id = $matches[1];
 }
Beispiel #7
0
 private function parseServerList(DomElement $elem)
 {
     foreach ($elem->getElementsByTagName('server') as $s) {
         $url = $s->getAttribute('url');
         $server = ExternalServer::newFromUrlString($url);
         if ($server == null) {
             return;
         }
         $this->servers[] = $server;
     }
 }