Exemplo n.º 1
0
 /**
  * Returns class instance
  *
  * @return UAVATARS_BOL_Service
  */
 public static function getInstance()
 {
     if (null === self::$classInstance) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Exemplo n.º 2
0
 public function hasHistory($userId)
 {
     if (!$this->isActive()) {
         return null;
     }
     $avatar = UAVATARS_BOL_Service::getInstance()->findLastByUserId($userId);
     return $avatar !== null;
 }
Exemplo n.º 3
0
 public function initForNode(OW_Event $event)
 {
     $params = $event->getParams();
     $userId = $params["userId"];
     $node = $params["node"];
     $avatar = UAVATARS_BOL_Service::getInstance()->findLastByUserId($userId);
     if ($avatar === null) {
         return;
     }
     $staticUrl = OW::getPluginManager()->getPlugin('uavatars')->getStaticUrl();
     OW::getDocument()->addStyleSheet($staticUrl . 'style.css');
     OW::getDocument()->addScript($staticUrl . 'script.js');
     UAVATARS_CLASS_PhotoBridge::getInstance()->initPhotoFloatBox();
     $js = UTIL_JsGenerator::newInstance();
     $photoInfo = UAVATARS_CLASS_PhotoBridge::getInstance()->getPhotoInfo($avatar->photoId);
     if (!empty($photoInfo)) {
         $js->addScript('$("' . $node . '").addClass("ow_cursor_pointer");');
         $url = null;
         $photoData = null;
         if (!empty($photoInfo["dimension"])) {
             $photoData = array("mainUrl" => $photoInfo["previewUrl"], "main" => array($photoInfo["dimension"]["main"][0], $photoInfo["dimension"]["main"][1]));
             $js->addScript('var image = new Image(); image.src={$url};', array("url" => $photoInfo["previewUrl"]));
         } else {
             $url = $photoInfo["photoUrl"];
             $js->addScript('var image = new Image(); image.src={$url};', array("url" => $url));
         }
         $js->jQueryEvent($node, 'click', 'if ( $("' . $node . '").is(event.target) ) UAVATARS.setPhoto(event.data.photoId, event.data.photoData, image);', array('event'), array('photoId' => $avatar->photoId, "photoData" => $photoData));
         OW::getDocument()->addOnloadScript($js);
     }
 }
Exemplo n.º 4
0
 public function onItemRender(OW_Event $event)
 {
     $params = $event->getParams();
     $data = $event->getData();
     if ($params['action']['entityType'] != 'avatar-change') {
         return;
     }
     $userId = $params['action']['userId'];
     $avatarId = $params['action']['entityId'];
     $avatar = UAVATARS_BOL_Service::getInstance()->findLastByAvatarId($avatarId);
     if ($avatar === null) {
         return;
     }
     $staticUrl = OW::getPluginManager()->getPlugin('uavatars')->getStaticUrl();
     OW::getDocument()->addStyleSheet($staticUrl . 'style.css');
     OW::getDocument()->addScript($staticUrl . 'script.js');
     $avatars = UAVATARS_BOL_Service::getInstance()->findListAfterAvatarId($avatar->avatarId, 2);
     UAVATARS_CLASS_PhotoBridge::getInstance()->initPhotoFloatBox();
     $js = UTIL_JsGenerator::newInstance();
     if (count($avatars) == 1) {
         $avatarUrl = UAVATARS_BOL_Service::getInstance()->getAvatarUrl($avatars[0]);
         $imgUniqId = uniqid('uavatar_');
         $data['content'] = '<div class="ua-newsfeed-avatars-wrap">
             <a id="' . $imgUniqId . '" class="ua-newsfeed-avatar ua-newsfeed-current-avatar ow_border" href="javascript://">
                 <img src="' . $avatarUrl . '" />
             </a>
             </div>';
         $photoInfo = UAVATARS_CLASS_PhotoBridge::getInstance()->getPhotoInfo($avatars[0]->photoId);
         if (!empty($photoInfo)) {
             $photoData = null;
             if (!empty($photoInfo["dimension"])) {
                 $photoData = array("mainUrl" => $photoInfo["previewUrl"], "main" => array($photoInfo["dimension"]["main"][0], $photoInfo["dimension"]["main"][1]));
                 $js->addScript('var image = new Image(); image.src={$url};', array("url" => $photoInfo["previewUrl"]));
             } else {
                 $url = $photoInfo["photoUrl"];
                 $js->addScript('var image = new Image(); image.src={$url};', array("url" => $url));
             }
             $js->jQueryEvent('#' . $imgUniqId, 'click', 'UAVATARS.setPhoto(event.data.photoId, event.data.photoData, image);', array('event'), array('photoId' => $avatars[0]->photoId, "photoData" => $photoData));
         }
     } else {
         $currentAvatarUrl = UAVATARS_BOL_Service::getInstance()->getAvatarUrl($avatars[0]);
         $prevAvatarUrl = UAVATARS_BOL_Service::getInstance()->getAvatarUrl($avatars[1]);
         $currentUniqId = uniqid('uavatar_');
         $prevUniqId = uniqid('uavatar_');
         $data['content'] = '<div class="ua-newsfeed-avatars-wrap">
             <a id="' . $prevUniqId . '" class="ua-newsfeed-avatar ua-newsfeed-prev-avatar ow_border" href="javascript://">
                 <img src="' . $prevAvatarUrl . '" />
             </a>
             <a id="' . $currentUniqId . '" class="ua-newsfeed-avatar ua-newsfeed-current-avatar ow_border" href="javascript://">
                 <img src="' . $currentAvatarUrl . '" />
             </a>
             </div>';
         $photoInfo = UAVATARS_CLASS_PhotoBridge::getInstance()->getPhotoInfo($avatars[0]->photoId);
         if (!empty($photoInfo)) {
             $photoData = null;
             $url = null;
             if (!empty($photoInfo["dimension"])) {
                 $photoData = array("mainUrl" => $photoInfo["previewUrl"], "main" => array($photoInfo["dimension"]["main"][0], $photoInfo["dimension"]["main"][1]));
                 $js->addScript('var image = new Image(); image.src={$url};', array("url" => $photoInfo["previewUrl"]));
             } else {
                 $url = $photoInfo["photoUrl"];
                 $js->addScript('(new Image()).src={$url};', array("url" => $url));
             }
             $js->jQueryEvent('#' . $currentUniqId, 'click', 'UAVATARS.setPhoto(event.data.photoId, event.data.photoData, image);', array('event'), array('photoId' => $avatars[0]->photoId, "photoData" => $photoData));
         }
         $photoInfo = UAVATARS_CLASS_PhotoBridge::getInstance()->getPhotoInfo($avatars[1]->photoId);
         if (!empty($photoInfo)) {
             $url = null;
             $photoData = null;
             if (!empty($photoInfo["dimension"])) {
                 $photoData = array("mainUrl" => $photoInfo["previewUrl"], "main" => array($photoInfo["dimension"]["main"][0], $photoInfo["dimension"]["main"][1]));
                 $js->addScript('var image = new Image(); image.src={$url};', array("url" => $photoInfo["previewUrl"]));
             } else {
                 $js->addScript('var image = new Image(); image.src={$url};', array("url" => $photoInfo["photoUrl"]));
             }
             $js->jQueryEvent('#' . $prevUniqId, 'click', 'UAVATARS.setPhoto(event.data.photoId, event.data.photoData, image);', array('event'), array('photoId' => $avatars[1]->photoId, "photoData" => $photoData));
         }
     }
     OW::getDocument()->addOnloadScript($js);
     $event->setData($data);
 }
Exemplo n.º 5
0
 public function initForNode(OW_Event $event)
 {
     $params = $event->getParams();
     $userId = $params["userId"];
     $node = $params["node"];
     $avatar = UAVATARS_BOL_Service::getInstance()->findLastByUserId($userId);
     if ($avatar === null) {
         return;
     }
     $staticUrl = OW::getPluginManager()->getPlugin('uavatars')->getStaticUrl();
     OW::getDocument()->addStyleSheet($staticUrl . 'style.css');
     OW::getDocument()->addScript($staticUrl . 'script.js');
     UAVATARS_CLASS_PhotoBridge::getInstance()->initPhotoFloatBox();
     $js = UTIL_JsGenerator::newInstance();
     $js->addScript('$("' . $node . '").addClass("ow_cursor_pointer");');
     $js->jQueryEvent($node, 'click', 'if ( $("' . $node . '").is(event.target) ) UAVATARS.setPhoto(event.data.photoId);', array('event'), array('photoId' => $avatar->photoId));
     OW::getDocument()->addOnloadScript($js);
 }
Exemplo n.º 6
0
 public function onItemRender(OW_Event $event)
 {
     $params = $event->getParams();
     $data = $event->getData();
     if ($params['action']['entityType'] != 'avatar-change') {
         return;
     }
     $userId = $params['action']['userId'];
     $avatarId = $params['action']['entityId'];
     $avatar = UAVATARS_BOL_Service::getInstance()->findLastByAvatarId($avatarId);
     if ($avatar === null) {
         return;
     }
     $staticUrl = OW::getPluginManager()->getPlugin('uavatars')->getStaticUrl();
     OW::getDocument()->addStyleSheet($staticUrl . 'style.css');
     OW::getDocument()->addScript($staticUrl . 'script.js');
     $avatars = UAVATARS_BOL_Service::getInstance()->findByUserId($userId, array(0, 2));
     UAVATARS_CLASS_PhotoBridge::getInstance()->initPhotoFloatBox();
     $js = UTIL_JsGenerator::newInstance();
     if (count($avatars) == 1) {
         $avatarUrl = UAVATARS_BOL_Service::getInstance()->getAvatarUrl($avatars[0]);
         $imgUniqId = uniqid('uavatar_');
         $data['content'] = '<div class="ua-newsfeed-avatars-wrap">
             <a id="' . $imgUniqId . '" class="ua-newsfeed-avatar ua-newsfeed-current-avatar ow_border" href="javascript://">
                 <img src="' . $avatarUrl . '" />
             </a>
             </div>';
         if (UAVATARS_CLASS_PhotoBridge::getInstance()->isPhotoExists($avatars[0]->photoId)) {
             $js->jQueryEvent('#' . $imgUniqId, 'click', 'UAVATARS.setPhoto(event.data.photoId);', array('event'), array('photoId' => $avatars[0]->photoId));
         }
     } else {
         $currentAvatarUrl = UAVATARS_BOL_Service::getInstance()->getAvatarUrl($avatars[0]);
         $prevAvatarUrl = UAVATARS_BOL_Service::getInstance()->getAvatarUrl($avatars[1]);
         $currentUniqId = uniqid('uavatar_');
         $prevUniqId = uniqid('uavatar_');
         $data['content'] = '<div class="ua-newsfeed-avatars-wrap">
             <a id="' . $prevUniqId . '" class="ua-newsfeed-avatar ua-newsfeed-prev-avatar ow_border" href="javascript://">
                 <img src="' . $prevAvatarUrl . '" />
             </a>
             <a id="' . $currentUniqId . '" class="ua-newsfeed-avatar ua-newsfeed-current-avatar ow_border" href="javascript://">
                 <img src="' . $currentAvatarUrl . '" />
             </a>
             </div>';
         if (UAVATARS_CLASS_PhotoBridge::getInstance()->isPhotoExists($avatars[0]->photoId)) {
             $js->jQueryEvent('#' . $currentUniqId, 'click', 'UAVATARS.setPhoto(event.data.photoId);', array('event'), array('photoId' => $avatars[0]->photoId));
         }
         if (UAVATARS_CLASS_PhotoBridge::getInstance()->isPhotoExists($avatars[1]->photoId)) {
             $js->jQueryEvent('#' . $prevUniqId, 'click', 'UAVATARS.setPhoto(event.data.photoId);', array('event'), array('photoId' => $avatars[1]->photoId));
         }
     }
     OW::getDocument()->addOnloadScript($js);
     $event->setData($data);
 }