Lines Matching refs:tag

11  * Helper part of the tag plugin, allows to query and print tags
17 * @var string namespace tag links point to
30 * @deprecated 2022-08-31 Not used/filled any more by tag plugin
70 'desc' => 'returns the tag links of a given page',
76 'desc' => 'generates tag links for given words',
86 'tag (required)' => 'string'
168 foreach ($tags as $tag) {
169 $links[] = $this->tagLink($tag);
175 * Returns the link for one given tag
177 * @param string $tag the tag the link shall point to
179 * @param bool $dynamic if the link class shall be changed if no pages with the specified tag exist
182 public function tagLink($tag, $title = '', $dynamic = false) {
184 $svtag = $tag;
185 $tagTitle = str_replace('_', ' ', noNS($tag));
189 $tag = $resolver->resolveId($tag);
190 $exists = page_exists($tag);
193 resolve_pageid($this->namespace, $tag, $exists);
197 $url = wl($tag);
200 $heading = p_get_first_heading($tag, false);
216 $url = wl($tag, ['do'=>'showtag', 'tag'=>$svtag]);
224 'tooltip' => hsc($tag),
228 return '<a href="'.$link['href'].'" class="'.$link['class'].'" title="'.$link['tooltip'].'" rel="tag">'
234 * Returns a list of pages with a certain tag; very similar to ft_backlinks()
238 * @param string $tagquery The tag string that shall be searched e.g. 'tag +tag -tag'
246 $tagquery = $INPUT->str('tag');
336 * Refine found pages with tags (+tag: AND, -tag: (AND) NOT)
339 * @param string $tagquery The list of tags in the form "tag +tag2 -tag3". The tags will be cleaned.
367 * $tag => int count
389 foreach ($tags as $tag) {
390 if (!isset($indexedPagesWithTags[$tag])) continue;
393 $pages = array_unique($indexedPagesWithTags[$tag]);
403 $tagOccurrences[$tag] = count($pages);
406 $tagOccurrences[$tag] = 0;
410 $tagOccurrences[$tag]++;
414 $tagOccurrences[$tag] = 0;
418 $tagOccurrences[$tag]++ ;
425 if ($tagOccurrences[$tag] == 0) {
426 unset($tagOccurrences[$tag]);
447 * Returns pages from index matching the tag query
449 * @param array $queryTags the tags to filter e.g. ['tag'(OR), '+tag'(AND), '-tag'(NOT)]
456 foreach ($queryTags as $i => $tag) {
457 if ($tag[0] == '+' || $tag[0] == '-') {
458 $cleanTags[$i] = substr($tag, 1);
460 $cleanTags[$i] = $tag;
466 // use all pages as basis if the first tag isn't an "or"-tag or if there are no tags given
472 $tag = $cleanTags[$i];
473 if (!is_array($pages[$tag])) {
474 $pages[$tag] = [];
478 $result = array_intersect($result, $pages[$tag]);
480 $result = array_diff($result, $pages[$tag]);
482 $result = array_unique(array_merge($result, $pages[$tag]));
494 * @param string $tags tag string, if containing spaces use quotes e.g. "tag with spaces", will be replaced by underscores
528 * callback: Cleans a tag using cleanID while preserving a possible prefix of + or -, and replace placeholders
530 * @param string $tag
533 protected function cleanTag($tag) {
534 $prefix = substr($tag, 0, 1);
535 $tag = $this->replacePlaceholders($tag);
537 return $prefix.cleanID($tag);
539 return cleanID($tag);
546 * @param string $tag
549 protected function replacePlaceholders($tag) {
582 return str_replace(array_keys($replace), array_values($replace), $tag);
662 * @param string $tag1 tag being searched
663 * @param string $tag2 tag from index
674 * @param string[] $queryTags tags we are looking ['tag', '+tag', '-tag']
679 foreach($queryTags as $tag) {
680 if ($tag[0] == "+" and !in_array(substr($tag, 1), $pageTags)) {
683 if ($tag[0] == "-" and in_array(substr($tag, 1), $pageTags)) {
686 if (in_array($tag, $pageTags)) {
731 * Returns pages from index matching the tag query
733 * @param array $queryTags the tags to filter e.g. ['tag'(OR), '+tag'(AND), '-tag'(NOT)]