/**
  * Fetches tag identified with provided remote_id
  *
  * @static
  * @param string $remote_id
  * @return array
  */
 public static function fetchTagByRemoteID($remote_id)
 {
     $result = eZTagsObject::fetchByRemoteID($remote_id);
     if ($result instanceof eZTagsObject) {
         return array('result' => $result);
     } else {
         return array('result' => false);
     }
 }
 public function publishTagByRemoteID($tagRemoteID, $tagParentID, $tagKeyword)
 {
     $ezTagsObject = eZTagsObject::fetchByRemoteID($tagRemoteID);
     if (!$ezTagsObject instanceof eZTagsObject) {
         $ezTagsObject = new eZTagsObject(array('remote_id' => $tagRemoteID));
     }
     $ezTagsObject->setAttribute('parent_id', $tagParentID);
     // ParentID
     $ezTagsObject->setAttribute('keyword', $tagKeyword);
     // Keyword
     $ezTagsObject->store();
     return true;
 }
    public static function create($remoteID, $keyword, eZTagsObject $parentTag=null)
    {
        // Vérification de l'existance
        if ($remoteID)
        {
            $tag = eZTagsObject::fetchByRemoteID($remoteID);

            if ($tag)
            {
                if ($parentTag && $tag->attribute( 'parent_id' ) != $parentTag->attribute('id'))
                {
                    $tag->setAttribute('parent_id', $parentTag->attribute('id'));
                    $tag->updatePathString($parentTag);
                    $tag->updateDepth($parentTag);
                }

                return $tag;
            }
        }
        else
        {
            $tags = eZTagsObject::fetchList(array(
                'keyword' => array( 'like', trim( $keyword ) ),
                'parent_id' => $parentTag ? $parentTag->attribute('id') : 0,
            ));

            if (count($tags))
                return $tags[0];
        }

        $db = eZDB::instance();
        $db->begin();

        // Création du tag
        $tag = new eZTagsObject(array(
            'remote_id'   => $remoteID,
            'parent_id'   => $parentTag ? $parentTag->attribute( 'id' ) : null,
            'main_tag_id' => null,
            'keyword'     => $keyword,
            'depth'       => $parentTag ? $parentTag->attribute( 'depth' ) + 1 : 1
        ));

        $tag->store();

        // Mise a jour du path string
        $tag->setAttribute( 'path_string', ($parentTag ? $parentTag->attribute( 'path_string' ) : '/') . $tag->attribute( 'id' ) . '/' );
        $tag->store();
        $tag->updateModified();

        $db->commit();

        /* Extended Hook */
        if ( class_exists( 'ezpEvent', false ) )
            ezpEvent::getInstance()->filter( 'tag/add', array( 'tag' => $tag, 'parentTag' => $parentTag ) );

        return $tag;
    }
 /**
  * Fetches tag identified with provided remote ID
  *
  * @static
  *
  * @param string $remoteID
  * @param mixed $language
  *
  * @return array
  */
 public static function fetchTagByRemoteID($remoteID, $language = false)
 {
     if ($language) {
         if (!is_array($language)) {
             $language = array($language);
         }
         eZContentLanguage::setPrioritizedLanguages($language);
     }
     $result = eZTagsObject::fetchByRemoteID($remoteID);
     if ($language) {
         eZContentLanguage::clearPrioritizedLanguages();
     }
     if ($result instanceof eZTagsObject) {
         return array('result' => $result);
     }
     return array('result' => false);
 }