@EXT\Route(
"organize/tags",
name="claro_workspace_tag_organize",
options={"expose"=true}
)
@EXT\ParamConverter("currentUser", options={"authenticatedUser" = true})
@EXT\Template()

Display list of workspace tags
969475
public function organizeWorkspaceTagAction(User $currentUser)
    {
        $tagsHierarchy = $this->tagManager->getAllHierarchiesByUser($currentUser);
        $rootTags = $this->tagManager->getRootTags($currentUser);
        $hierarchy = array();

        foreach ($tagsHierarchy as $tagHierarchy) {

            if ($tagHierarchy->getLevel() === 1) {

                if (!isset($hierarchy[$tagHierarchy->getParent()->getId()]) ||
                    !is_array($hierarchy[$tagHierarchy->getParent()->getId()])) {

                    $hierarchy[$tagHierarchy->getParent()->getId()] = array();
                }
                $hierarchy[$tagHierarchy->getParent()->getId()][] = $tagHierarchy->getTag();
            }
        }

        return array(
            'hierarchy' => $hierarchy,
            'rootTags' => $rootTags
        );
    }
709144
public function listAction()
    {
        $params = $this->params();
        $page   = (int) $params->fromRoute( 'page' );
        $mode   = $params->fromRoute( 'mode' );
        $all    = $mode == 'all';
        $tags   = array_map(
            'rawurldecode',
            explode( '/', $params->fromRoute( 'tags' ) )
        );

        $paginator = $this->getServiceLocator()
                          ->get( 'Grid\Paragraph\Model\Paragraph\Model' )
                          ->getContentPaginatorByTags( $tags, $all );

        $this->paragraphLayout();

        return array(
            'paginator'         => $paginator,
            'page'              => $page,
            'mode'              => $mode,
            'tags'              => $tags,
        );
    }
246477
public function getTags() {
        return implode(",", array_keys(ArrayHelper::map($this->owner->getModelTags()->asArray()->all(), 'name', 'name')));
    }
614134
public function add_related_tags($tagnames) {
        $context = context_system::instance();
        $tagobjects = static::create_if_missing($this->tagcollid, $tagnames);

        $currenttags = static::get_item_tags('core', 'tag', $this->id);

        foreach ($tagobjects as $name => $tag) {
            foreach ($currenttags as $currenttag) {
                if ($currenttag->name === $name) {
                    continue 2;
                }
            }
            $this->add_instance('core', 'tag', $tag->id, $context, 0);
            $tag->add_instance('core', 'tag', $this->id, $context, 0);
            $currenttags[] = $tag;
        }
    }
180401
public function actionAssignTags()
    {
        foreach(explode(',',$_POST['Contact']['tags']) as $tag_value) {
            $tag = Tag::find()->where('status<>"deleted" AND name=:name AND type=:type', [':name' => $tag_value, ':type' => 'Contact'])->one();
            if(!isset($tag->id)) {
                $tag = new Tag;
                $tag->type = 'Contact';
                $tag->name = $tag_value;
                $tag->save();       
            }
            $tagList[] = $tag->id;
        }

        $this->getSearchCriteria();
        $this->dataProvider->pagination = false;

        $result = $this->dataProvider->query->select('id')->asArray()->all();

        foreach($result as $model) {
            foreach ($tagList as $tag_id) {
                $insert[] = '(' . $tag_id . ',' . $model['id'] . ',NOW(),NOW(),' . Yii::$app->user->identity->id . ',' . Yii::$app->user->identity->id . ')';
            }
        }
        // INSERT multiple rows at once
        \Yii::$app->db->createCommand("INSERT IGNORE INTO Contact_Tag (Tag_id, Contact_id, update_time, create_time, update_by, create_by) VALUES ".implode(',',$insert))->execute();
        return $this->redirect(['index']);
    }
1040717
public function findAdminChildrenFromTags(array $tags)
    {
        if (count($tags) === 0) {
            throw new \InvalidArgumentException('Array argument cannot be empty');
        }

        $index = 0;
        $eol = PHP_EOL;
        $tagsTest = '(';

        foreach ($tags as $tag) {
            $tagsTest .= $index > 0 ? '    OR ' : '    ';
            $tagsTest .= "p.id = {$tag}{$eol}";
            $index++;
        }
        $tagsTest .= "){$eol}";

        $dql = "
            SELECT DISTINCT t
            FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTag t
            WHERE t.user IS NULL
            AND EXISTS (
                SELECT h
                FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTagHierarchy h
                JOIN h.parent p
                WHERE h.user IS NULL
                AND h.tag = t
                AND {$tagsTest}
            )
            ORDER BY t.name
        ";
        $query = $this->_em->createQuery($dql);

        return $query->getResult();
    }
107695
function _tag_open( &$parser, $tag, $attributes ) {
		$this->currentElement = strtoupper( $tag );

		switch( $this->currentElement ) {
			case 'INDEX':
				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
					$index = $this->addIndex( $attributes );
					xml_set_object( $parser,  $index );
				}
				break;
			case 'DATA':
				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
					$data = $this->addData( $attributes );
					xml_set_object( $parser, $data );
				}
				break;
			case 'DROP':
				$this->drop();
				break;
			case 'FIELD':
				// Add a field
				$fieldName = $attributes['NAME'];
				$fieldType = $attributes['TYPE'];
				$fieldSize = isset( $attributes['SIZE'] ) ? $attributes['SIZE'] : NULL;
				$fieldOpts = !empty( $attributes['OPTS'] ) ? $attributes['OPTS'] : NULL;

				$this->addField( $fieldName, $fieldType, $fieldSize, $fieldOpts );
				break;
			case 'KEY':
			case 'NOTNULL':
			case 'AUTOINCREMENT':
			case 'DEFDATE':
			case 'DEFTIMESTAMP':
			case 'UNSIGNED':
				// Add a field option
				$this->addFieldOpt( $this->current_field, $this->currentElement );
				break;
			case 'DEFAULT':
				// Add a field option to the table object

				// Work around ADOdb datadict issue that misinterprets empty strings.
				if( $attributes['VALUE'] == '' ) {
					$attributes['VALUE'] = " '' ";
				}

				$this->addFieldOpt( $this->current_field, $this->currentElement, $attributes['VALUE'] );
				break;
			case 'OPT':
			case 'CONSTRAINT':
				// Accept platform-specific options
				$this->currentPlatform = ( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) );
				break;
			default:
				// print_r( array( $tag, $attributes ) );
		}
	}
845733
public function indexAction()
    {
        $user = $this->userService->getCurrentUser();
        $workspacesArray = [];
        /** @var Workspace $workspace */
        foreach ($this->workspaceRepository->findAll() as $workspace) {

            // FIXME: This check should be implemented through a specialized Workspace Privilege or something similar
            if ($workspace->getOwner() !== null && $workspace->getOwner() !== $user) {
                continue;
            }

            $workspaceArray = [
                'name' => $workspace->getName(),
                'title' => $workspace->getTitle(),
                'description' => $workspace->getDescription(),
                'baseWorkspace' => $workspace->getBaseWorkspace()
            ];
            if ($user !== null) {
                $workspaceArray['readonly'] = !$this->userService->currentUserCanPublishToWorkspace($workspace);
            }
            $workspacesArray[] = $workspaceArray;
        }

        $this->view->assign('workspaces', $workspacesArray);
    }
183132
public function onWorkspaceActionMenuRender(WorkspaceAdditionalActionEvent $event)
    {
        $workspace = $event->getWorkspace();
        $url = $this->router->generate(
            'claro_tag_workspace_tag_form',
            array('workspace' => $workspace->getId())
        );

        $menu = $event->getMenu();
        $menu->addChild(
            $this->translator->trans('tag_action', array(), 'tag'),
            array('uri' => $url)
        )->setExtra('icon', 'fa fa-tags')
        ->setExtra('display', 'modal_form');

        return $menu;
    }
75391
public function listAnnouncementsAction()
    {
        $this->checkStaticTemplateIsIncluded();
        $this->checkSettings();

        $this->slotExtendedAssignMultiple([
            self::VIEW_VARIABLE_ASSOCIATION_ID => $this->settings[self::SETTINGS_ASSOCIATION_ID],
            self::VIEW_VARIABLE_FILTER => $this->getAnnouncementsFilter(),
        ], __CLASS__, __FUNCTION__);

        return $this->view->render();
    }
827550
public static function update_tags($tags) {
        global $CFG, $PAGE, $DB;

        // Validate and normalize parameters.
        $tags = self::validate_parameters(self::update_tags_parameters(), array('tags' => $tags));

        $systemcontext = context_system::instance();
        $canmanage = has_capability('moodle/tag:manage', $systemcontext);
        $canedit = has_capability('moodle/tag:edit', $systemcontext);
        $warnings = array();

        if (empty($CFG->usetags)) {
            throw new moodle_exception('tagsaredisabled', 'tag');
        }

        $renderer = $PAGE->get_renderer('core');
        foreach ($tags['tags'] as $tag) {
            $tag = (array)$tag;
            if (array_key_exists('rawname', $tag)) {
                $tag['rawname'] = clean_param($tag['rawname'], PARAM_TAG);
                if (empty($tag['rawname'])) {
                    unset($tag['rawname']);
                }
            }
            if (!$canmanage) {
                // User without manage capability can not change any fields except for descriptions.
                $tag = array_intersect_key($tag, array('id' => 1,
                    'description' => 1, 'descriptionformat' => 1));
            }
            if (!$canedit) {
                // User without edit capability can not change description.
                $tag = array_diff_key($tag,
                        array('description' => 1, 'descriptionformat' => 1));
            }
            if (count($tag) <= 1) {
                $warnings[] = array(
                    'item' => $tag['id'],
                    'warningcode' => 'nothingtoupdate',
                    'message' => get_string('nothingtoupdate', 'core_tag')
                );
                continue;
            }
            if (!$tagobject = core_tag_tag::get($tag['id'], '*')) {
                $warnings[] = array(
                    'item' => $tag['id'],
                    'warningcode' => 'tagnotfound',
                    'message' => get_string('tagnotfound', 'error')
                );
                continue;
            }
            // First check if new tag name is allowed.
            if (!empty($tag['rawname']) && ($existing = core_tag_tag::get_by_name($tagobject->tagcollid, $tag['rawname']))) {
                if ($existing->id != $tag['id']) {
                    $warnings[] = array(
                        'item' => $tag['id'],
                        'warningcode' => 'namesalreadybeeingused',
                        'message' => get_string('namesalreadybeeingused', 'core_tag')
                    );
                    continue;
                }
            }
            if (array_key_exists('official', $tag)) {
                // Parameter 'official' deprecated and replaced with 'isstandard'.
                $tag['isstandard'] = $tag['official'] ? 1 : 0;
                unset($tag['official']);
            }
            if (isset($tag['flag'])) {
                if ($tag['flag']) {
                    $tagobject->flag();
                } else {
                    $tagobject->reset_flag();
                }
                unset($tag['flag']);
            }
            unset($tag['id']);
            if (count($tag)) {
                $tagobject->update($tag);
            }
        }
        return array('warnings' => $warnings);
    }
1282226
protected function _setViewParams( MW_View_Interface $view, array &$tags = array(), &$expire = null )
	{
		if( !isset( $this->_cache ) )
		{
			$context = $this->_getContext();
			$manager = MShop_Factory::createManager( $context, 'catalog' );

			/** client/html/catalog/filter/tree/startid
			 * The ID of the category node that should be the root of the displayed category tree
			 *
			 * If you want to display only a part of your category tree, you can
			 * configure the ID of the category node from which rendering the
			 * remaining sub-tree should start.
			 *
			 * In most cases you can set this value via the administration interface
			 * of the shop application. In that case you often can configure the
			 * start ID individually for each catalog filter.
			 *
			 * @param string Category ID
			 * @since 2014.03
			 * @category User
			 * @category Developer
			 * @see client/html/catalog/filter/tree/levels-always
			 * @see client/html/catalog/filter/tree/levels-only
			 */
			$startid = $view->config( 'client/html/catalog/filter/tree/startid', '' );
			$currentid = (string) $view->param( 'f-catalog-id', '' );

			/** @todo Make referenced domains configurable */
			$ref = array( 'text', 'media', 'attribute' );


			if( $currentid != '' )
			{
				$catItems = $manager->getPath( $currentid );

				if( $startid != '' )
				{
					foreach( $catItems as $key => $item )
					{
						if( $key == $startid ) {
							break;
						}
						unset( $catItems[$key] );
					}
				}

				if( ( $node = reset( $catItems ) ) === false )
				{
					$msg = sprintf( 'Category with ID "%1$s" not below ID "%2$s"', $currentid, $startid );
					throw new Client_Html_Exception( $msg );
				}
			}
			else if( $startid != '' )
			{
				$node = $manager->getItem( $startid );
				$catItems = array( $node->getId() => $node );
			}
			else
			{
				$node = $manager->getTree( null, array(), MW_Tree_Manager_Abstract::LEVEL_ONE );
				$catItems = array( $node->getId() => $node );
			}


			$search = $manager->createSearch();
			$expr = $search->compare( '==', 'catalog.parentid', array_keys( $catItems ) );
			$expr = $search->combine( '||', array( $expr, $search->compare( '==', 'catalog.id', $node->getId() ) ) );

			/** client/html/catalog/filter/tree/levels-always
			 * The number of levels in the category tree that should be always displayed
			 *
			 * Usually, only the root node and the first level of the category
			 * tree is shown in the frontend. Only if the user clicks on a
			 * node in the first level, the page reloads and the sub-nodes of
			 * the chosen category are rendered as well.
			 *
			 * Using this configuration option you can enforce the given number
			 * of levels to be always displayed. The root node uses level 0, the
			 * categories below level 1 and so on.
			 *
			 * In most cases you can set this value via the administration interface
			 * of the shop application. In that case you often can configure the
			 * levels individually for each catalog filter.
			 *
			 * @param integer Number of tree levels
			 * @since 2014.03
			 * @category User
			 * @category Developer
			 * @see client/html/catalog/filter/tree/startid
			 * @see client/html/catalog/filter/tree/levels-only
			 */
			if( ( $levels = $view->config( 'client/html/catalog/filter/tree/levels-always' ) ) != null ) {
				$expr = $search->combine( '||', array( $expr, $search->compare( '<=', 'catalog.level', $levels ) ) );
			}

			/** client/html/catalog/filter/tree/levels-only
			 * No more than this number of levels in the category tree should be displayed
			 *
			 * If the user clicks on a category node, the page reloads and the
			 * sub-nodes of the chosen category are rendered as well.
			 * Using this configuration option you can enforce that no more than
			 * the given number of levels will be displayed at all. The root
			 * node uses level 0, the categories below level 1 and so on.
			 *
			 * In most cases you can set this value via the administration interface
			 * of the shop application. In that case you often can configure the
			 * levels individually for each catalog filter.
			 *
			 * @param integer Number of tree levels
			 * @since 2014.03
			 * @category User
			 * @category Developer
			 * @see client/html/catalog/filter/tree/startid
			 * @see client/html/catalog/filter/tree/levels-always
			 */
			if( ( $levels = $view->config( 'client/html/catalog/filter/tree/levels-only' ) ) != null ) {
				$expr = $search->combine( '&&', array( $expr, $search->compare( '<=', 'catalog.level', $levels ) ) );
			}

			$search->setConditions( $expr );

			$id = ( $startid != '' ? $startid : null );
			$level = MW_Tree_Manager_Abstract::LEVEL_TREE;

			$view->treeCatalogPath = $catItems;
			$view->treeCatalogTree = $manager->getTree( $id, $ref, $level, $search );
			$view->treeCatalogIds = $this->_getCatalogIds( $view->treeCatalogTree, $catItems, $currentid );
			$view->treeFilterParams = $this->_getClientParams( $view->param(), array( 'f' ) );

			$this->_addMetaItemCatalog( $view->treeCatalogTree, $this->_expire, $this->_tags );

			$this->_cache = $view;
		}

		$expire = $this->_expires( $this->_expire, $expire );
		$tags = array_merge( $tags, $this->_tags );

		return $this->_cache;
	}
223398
function favorites_tags( $page = 1, $count = 50)
	{
		$params = array();
		$params['count'] = $count;
		$params['page'] = $page;
		return $this->oauth->get( 'favorites/tags', $params );
	}
1205161
public function UpdateTags()
    {
        $siteTree = DataObject::getSchema()->tableName(SiteTree::class);
        $taxonomy = DataObject::getSchema()->tableName(TaxonomyTerm::class);

        $tags = TaxonomyTerm::get()
            ->innerJoin('BasePage_Terms', sprintf('"%s"."ID"="BasePage_Terms"."TaxonomyTermID"', $taxonomy))
            ->innerJoin(
                $siteTree,
                sprintf(
                    '"%s"."ID" = "BasePage_Terms"."BasePageID" AND "%s"."ParentID" = \'%d\'',
                    $siteTree,
                    $siteTree,
                    $this->ID
                )
            )
            ->sort('Name');

        return $tags;
    }
854688
public function list_tags()
    {
        if (!$this->is_loggedin) {
            return false;
        }

        $response = $this->exec_curl('/api/s/' . $this->site . '/rest/tag');

        return $this->process_response($response);
    }
103004
public function getTaggedObjects(
        User $user = null,
        $withPlatform = false,
        $class = null,
        $search = '',
        $strictSearch = false,
        $orderedBy = 'name',
        $order = 'ASC',
        $withPager = false,
        $page = 1,
        $max = 50
    )
    {
        $objects = empty($search) ?
            $this->taggedObjectRepo->findAllTaggedObjects(
                $user,
                $withPlatform,
                $class,
                $orderedBy,
                $order
            ) :
            $this->taggedObjectRepo->findSearchedTaggedObjects(
                $search,
                $user,
                $withPlatform,
                $class,
                $orderedBy,
                $order,
                $strictSearch
            );

        return $withPager ?
            $this->pagerFactory->createPagerFromArray($objects, $page, $max) :
            $objects;
    }
1025936
public function listAction()
    {
        $this->routeParam()->mapPageTo($this->queryService);
        $collection = $this->queryService->findUsedTags();

        return $this->viewModelFactory()->createFor($collection);
    }