示例#1
0
文件: Photo.php 项目: freyr/gallery
 /**
  * @param array $tags
  */
 public function setTags(array $tags)
 {
     foreach ($tags as $tag) {
         $tag = new Tag($tag);
         $this->tags[$tag->getName()] = $tag;
     }
 }
示例#2
0
文件: Token.php 项目: quack/quack
 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 . "]";
 }
示例#3
0
 public function renderTagHead(Tag $tag)
 {
     $res = '## [' . $tag->getName() . ']';
     if ($tag->getDate()) {
         $res .= ' - ' . $tag->getDate();
     }
     return $res . "\n";
 }
示例#4
0
 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();
     }
 }
示例#5
0
 /**
  * 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;
 }
示例#6
0
 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&lt;some text&gt;</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());
 }
示例#7
0
 /**
  * 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);
 }
示例#8
0
文件: PQLite.php 项目: iface91/iface
 /**
  * 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;
 }
示例#9
0
 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()) . "'");
     }
 }
示例#10
0
 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());
 }
示例#11
0
文件: Tag.php 项目: hiqdev/chkipper
 public function set(Tag $tag)
 {
     $this->setName($tag->getName());
     $this->setDate($tag->getDate());
     $this->setNotes($tag->getNotes());
 }