/** * @param array $tags */ public function setTags(array $tags) { foreach ($tags as $tag) { $tag = new Tag($tag); $this->tags[$tag->getName()] = $tag; } }
public function __toString() { if (isset($this->pointer)) { $tag_name = Tag::getName($this->tag); return isset($this->symbol_table) ? "[" . $tag_name . ", " . $this->symbol_table->get($this->pointer) . "]" : "[" . $tag_name . ", " . $this->pointer . "]"; } return "[" . $this->tag . "]"; }
public function renderTagHead(Tag $tag) { $res = '## [' . $tag->getName() . ']'; if ($tag->getDate()) { $res .= ' - ' . $tag->getDate(); } return $res . "\n"; }
public function __construct(AbstractObject $parent, $summary = '', Tag $tag = null) { parent::__construct($parent); $this->summary = $summary; $this->operationid = uniqid('', true); //@todo getSwagger()->title -> Do some complex construction? if ($tag) { $this->tags[] = $tag->getName(); } }
/** * Should the given tags be kept together, or kept apart? * * @param Tag $first * @param Tag $second * * @return bool */ public static function shouldBeTogether(Tag $first, Tag $second) { $firstName = $first->getName(); $secondName = $second->getName(); if ($firstName === $secondName) { return true; } foreach (self::$groups as $group) { if (in_array($firstName, $group, true) && in_array($secondName, $group, true)) { return true; } } return false; }
public function testCreate() { $tag = new Tag('a'); $this->assertSame("a", $tag->getName()); $this->assertSame("<a></a>", $tag->render()); $tag->href = "TEST"; $this->assertSame('<a href="TEST"></a>', $tag->render()); $img = new Tag('img'); $this->assertSame('<img>', $img->render()); $tag->addChild($img); $this->assertSame('<a href="TEST"><img></a>', $tag->render()); $img->src = "http://github.com/"; $this->assertSame('<a href="TEST"><img src="http://github.com/"></a>', $tag->render()); $tag->addText('Click me'); $this->assertSame('<a href="TEST"><img src="http://github.com/">Click me</a>', $tag->render()); $tag->addText('<some text>'); $this->assertSame('<a href="TEST"><img src="http://github.com/">Click me<some text></a>', $tag->render()); // getText - text at wrong index $this->assertSame(NULL, $tag->getText()); // getText - text at index 0 $tag->setText('<some text>'); $this->assertSame('<some text>', $tag->getText()); }
/** * Adds tag. * @param Tag $tag * @param boolean $prependNotes default is append * @return Tag the added tag */ public function addTag(Tag $tag, $prependNotes = false) { return $this->findTag($tag->getName())->setDate($tag->getDate())->addNotes($tag->getNotes(), $prependNotes); }
/** * Helper function to add a tag to a tree. * * @param Tag $tag - the Tag to add * @param TreeNode $parent - the current parent node * @return TreeNode - the new parent node * @author Karthik Viswanathan */ private function addTag($tag, $parent) { if ($tag->isClosing()) { // if there is some discrepency on what the tag closes, // just move up the tree until a similar opening tag is found // if no similar opening tag can be found, assume that // the parent tag is still unclosed $findParent = $parent; while ($findParent != null && $findParent->getValue()->getName() != $tag->getName()) { $findParent = $findParent->getParent(); if ($findParent->getValue() != 'root') { break; } } if ($findParent != null) { return $findParent->getParent(); } return $parent; } $node = $this->appendToTree($tag, $parent); $tag->setNode($node); $this->populateTagArray($tag); // self closed means the parent is still unclosed if ($tag->isSelfClosed()) { return $parent; } return $node; }
public function assignTagToCve(Cve &$cve, Tag &$tag) { if ($cve == null || $cve->getId() == -1 || $tag == null) { Utils::log(LOG_DEBUG, "Exception", __FILE__, __LINE__); throw new Exception("Cve object is not valid or Cve.id is not set"); } # Check if the tag name is valid if ($tag->getName() == "") { $tag->setName(Constants::$NA); } $tagId = $this->getTagIdByName($tag->getName()); if ($tagId == -1) { $this->getPakiti()->getDao("Tag")->create($tag); } else { $tag->setId($tagId); } Utils::log(LOG_DEBUG, "Assinging the tag to the cve [cveId=" . $cve->getId() . ",tag=" . $tag->getName() . "]", __FILE__, __LINE__); # Check if the already assigned $isAssigned = $this->getPakiti()->getManager("DbManager")->queryToSingleValue("select 1 from CveTag where\n \t \t\tcveId=" . $this->getPakiti()->getManager("DbManager")->escape($cve->getId()) . " and\n \t \t\ttagId=" . $this->getPakiti()->getManager("DbManager")->escape($tag->getId())); if ($isAssigned != null) { throw new Exception($cve->getName() . " is already associated with " . $tag->getName() . " tag!"); } else { # Association between cve and cveTag doesn't exist, so create it $this->getPakiti()->getManager("DbManager")->query("\n \t\tinsert into CveTag set\n \t\t\tcveId=" . $this->getPakiti()->getManager("DbManager")->escape($cve->getId()) . ",\n \t \t\ttagId=" . $this->getPakiti()->getManager("DbManager")->escape($tag->getId()) . ",\n \t \t\t`reason`='" . $this->getPakiti()->getManager("DbManager")->escape($tag->getReason()) . "'"); } }
public function update(Tag &$tag) { $this->db->query("update Tag set\n \tname='" . $this->db->escape($tag->getName()) . "',\n \tdescription='" . $this->db->escape($tag->getName()) . "',\n \tenabled=" . $this->db->escape($tag->getEnabled()) . "\n where id=" . $tag->getId()); }
public function set(Tag $tag) { $this->setName($tag->getName()); $this->setDate($tag->getDate()); $this->setNotes($tag->getNotes()); }