Example #1
0
 /**
  * Returns class instance
  *
  * @return UTAGS_BOL_Service
  */
 public static function getInstance()
 {
     if (null === self::$classInstance) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Example #2
0
 public function __construct()
 {
     parent::__construct();
     $this->uniqId = uniqid("ut-");
     $this->userId = OW::getUser()->getId();
     $this->assign("uniqId", $this->uniqId);
     $this->data = UTAGS_BOL_Service::getInstance()->getSuggestEntries($this->userId, null, "photo");
     $event = new OW_Event(UTAGS_BOL_Service::EVENT_ON_INPUT_INIT, array("input" => $this, "userId" => $this->userId, "context" => "photo"));
     OW::getEventManager()->trigger($event);
 }
Example #3
0
 private function deleteTags($params)
 {
     $photoId = $params["photoId"];
     $tagIds = $params["tagIds"];
     $clonnedPhoto = false;
     foreach ($tagIds as $tagId) {
         $tag = $this->service->findTagById($tagId);
         if ($tag->copyPhotoId == $photoId) {
             $clonnedPhoto = true;
         }
         $this->service->deleteTagById($tagId);
     }
     return array("list" => $this->renderTagList($photoId), "customList" => UTAGS_CLASS_PhotoBridge::getInstance()->getTagCloudHtml($photoId), "clearCache" => true, "close" => $clonnedPhoto, "refresh" => $clonnedPhoto);
 }
Example #4
0
 public function __construct($tags)
 {
     parent::__construct();
     $avatarService = BOL_AvatarService::getInstance();
     $tplTags = array();
     foreach ($tags as $tag) {
         /*@var $tag UTAGS_BOL_Tag */
         if ($tag->entityType != "user") {
             continue;
         }
         $avatarData = $avatarService->getDataForUserAvatars(array($tag->entityId, $tag->userId), true, true, true, false);
         $userAvatarData = $avatarData[$tag->entityId];
         $taggerAvatarData = $avatarData[$tag->userId];
         $tplTags[] = array("avatar" => $userAvatarData, "taggerAvatar" => $taggerAvatarData, "userId" => $tag->entityId, "taggerId" => $tag->userId, "id" => $tag->id, "delete" => UTAGS_BOL_Service::getInstance()->isCurrentUserCanDelete($tag));
     }
     $this->assign("tags", $tplTags);
 }
Example #5
0
    public function onItemRender(OW_Event $event)
    {
        $params = $event->getParams();
        if (!in_array($params['entityType'], array(self::TYPE_TAG_ME, self::TYPE_TAG_MY_PHOTO))) {
            return;
        }
        $tagId = intval($params['entityId']);
        $tag = UTAGS_BOL_Service::getInstance()->findTagById($tagId);
        $photoId = empty($tag->copyPhotoId) ? $tag->photoId : $tag->copyPhotoId;
        if ($tag === null) {
            return;
        }
        UTAGS_CLASS_PhotoBridge::getInstance()->initPhotoFloatBox();
        $data = $event->getData();
        $data['url'] = 'javascript://';
        $data["contentImage"] = UTAGS_CLASS_PhotoBridge::getInstance()->getPreviewSrc($photoId);
        $uniqId = $params['key'];
        $js = UTIL_JsGenerator::newInstance();
        $js->addScript('UTAGS_Require();');
        $js->addScript('var busy = false; $("#' . $uniqId . '").click(function( e ) {
            if ( !$(e.target).is("a") ) {
                if (busy) return false;
                busy = true;
                UTAGS_Require(function( app ) {
                    busy = false;
                    app.PhotoLauncher.setPhoto({$photoId});
                    
                    app._afterPhotoActivate = function( photo ) {
                        if ( photo.fetched )
                            photo.showTags({$tagIds});
                        else
                            photo.afterFetch = function() {
                                photo.showTags({$tagIds});
                                photo.afterFetch = null;
                            };

                        app._afterPhotoActivate = null;
                    };
                });
            }
        });;', array("photoId" => $tag->photoId, "tagIds" => array((int) $tag->id)));
        OW::getDocument()->addOnloadScript($js->generateJs());
        $event->setData($data);
    }
Example #6
0
 public function onTagRemove(OW_Event $event)
 {
     $params = $event->getParams();
     $tagId = $params['tagId'];
     $tag = UTAGS_BOL_Service::getInstance()->findTagById($tagId);
     if ($tag === null) {
         return;
     }
     $activityParams = array('entityType' => UTAGS_CLASS_PhotoBridge::FEED_ENTITY_TYPE, 'entityId' => $tag->photoId, 'activityId' => $tag->id);
     if ($tag->entityType == UTAGS_BOL_Service::ENTITY_TYPE_CUSTOM) {
         $activityParams["activityType"] = self::TYPE_TEXT_TAG;
     }
     if ($tag->entityType == UTAGS_BOL_Service::ENTITY_TYPE_USER) {
         $activityParams["activityType"] = self::TYPE_USER_TAG;
     }
     OW::getEventManager()->trigger(new OW_Event('feed.delete_activity', $activityParams));
 }
Example #7
0
 public function afterPhotoDelete(OW_Event $event)
 {
     $params = $event->getParams();
     $photoId = $params["photoId"];
     $service = UTAGS_BOL_Service::getInstance();
     $copyTags = $service->findTagsByCopyPhotoId($photoId);
     foreach ($copyTags as $tag) {
         $tag->copyPhotoId = null;
         $service->saveTag($tag);
     }
     $service->deleteByPhotoId($photoId);
 }
Example #8
0
 public function beforeTagDelete(OW_Event $event)
 {
     $params = $event->getParams();
     $tagId = $params['tagId'];
     $tag = UTAGS_BOL_Service::getInstance()->findTagById($tagId);
     if (empty($tagId) || $tag->entityType != UTAGS_BOL_Service::ENTITY_TYPE_CUSTOM) {
         return;
     }
     BOL_EntityTagDao::getInstance()->deleteById($tag->entityId);
 }