Exemple #1
0
 public static function getInstance()
 {
     if (null === self::$classInstance) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Exemple #2
0
 public function contentIndexing()
 {
     PHOTO_BOL_SearchService::getInstance()->contentIndexing();
 }
Exemple #3
0
 public function addSearchData(OW_Event $event)
 {
     $params = $event->getParams();
     if (empty($params['entityId']) || empty($params['entityType']) || empty($params['content'])) {
         return;
     }
     PHOTO_BOL_SearchService::getInstance()->addSearchData($params['entityId'], $params['entityType'], $params['content']);
 }
Exemple #4
0
 public function getFloatbox($params)
 {
     if (empty($params['photoId']) || !$params['photoId']) {
         throw new Redirect404Exception();
     }
     $photoId = (int) $params['photoId'];
     if (($photo = $this->photoService->findPhotoById($photoId)) === NULL) {
         return array('result' => 'error');
     }
     $event = new BASE_CLASS_EventCollector('photo.collectPhotoList');
     OW::getEventManager()->trigger($event);
     $data = array();
     $listTypes = array('list' => array_merge($event->getData(), array('latest', 'toprated', 'albumPhotos', 'userPhotos', 'featured', 'entityPhotos', 'most_discussed')), 'search' => array('hash', 'user', 'desc', 'all'));
     if (array_search($params['listType'], $listTypes['list']) === FALSE && array_search($params['listType'], $listTypes['search']) === FALSE) {
         $listType = 'latest';
     } else {
         $listType = $params['listType'];
     }
     switch ($listType) {
         case 'hash':
         case 'user':
         case 'desc':
         case 'all':
             $data['id'] = @$params['id'];
             $data['searchVal'] = $params['searchVal'];
             $listService = PHOTO_BOL_SearchService::getInstance();
             break;
         default:
             $event = new OW_Event('photo.getPhotoListService', array('listType' => $listType));
             OW::getEventManager()->trigger($event);
             $service = $event->getData();
             if (!empty($service)) {
                 $listService = $service;
             } else {
                 $listService = $this->photoService;
             }
             break;
     }
     $userId = OW::getUser()->getId();
     $resp = array('result' => TRUE);
     if (!empty($params['photos'])) {
         foreach (array_unique($params['photos']) as $photoId) {
             $resp['photos'][$photoId] = $this->prepareMarkup($photoId, $params['layout']);
             $resp['photos'][$photoId]['ownerId'] = $this->photoService->findPhotoOwner($photoId);
             $rateInfo = BOL_RateService::getInstance()->findRateInfoForEntityList('photo_rates', array($photoId));
             $userScore = BOL_RateService::getInstance()->findUserSocre($userId, 'photo_rates', array($photoId));
             $resp['photos'][$photoId]['rateInfo'] = $rateInfo[$photoId];
             $resp['photos'][$photoId]['userScore'] = $userScore[$photoId];
         }
     }
     if (!empty($params['loadPrevList']) || !empty($params['loadPrevPhoto'])) {
         $resp['prevList'] = $prevIdList = $listService->getPrevPhotoIdList($listType, $photo->id, $data);
         if (count($prevIdList) < PHOTO_BOL_PhotoService::ID_LIST_LIMIT) {
             $resp['prevCompleted'] = TRUE;
             $resp['firstList'] = $firstIdList = $listService->getFirstPhotoIdList($listType, $photo->id, $data);
         }
         if (!empty($params['loadPrevPhoto'])) {
             $prevId = !empty($prevIdList) ? min($prevIdList) : (!empty($firstIdList) ? min($firstIdList) : null);
             if ($prevId && !isset($resp['photos'][$prevId])) {
                 $resp['photos'][$prevId] = $this->prepareMarkup($prevId, $params['layout']);
                 $resp['photos'][$prevId]['ownerId'] = $this->photoService->findPhotoOwner($prevId);
                 $rateInfo = BOL_RateService::getInstance()->findRateInfoForEntityList('photo_rates', array($prevId));
                 $userScore = BOL_RateService::getInstance()->findUserSocre($userId, 'photo_rates', array($prevId));
                 $resp['photos'][$prevId]['rateInfo'] = $rateInfo[$prevId];
                 $resp['photos'][$prevId]['userScore'] = $userScore[$prevId];
             }
         }
     }
     if (!empty($params['loadNextList']) || !empty($params['loadNextPhoto'])) {
         $resp['nextList'] = $nextIdList = $listService->getNextPhotoIdList($listType, $photo->id, $data);
         if (count($nextIdList) < PHOTO_BOL_PhotoService::ID_LIST_LIMIT) {
             $resp['nextCompleted'] = TRUE;
             $resp['lastList'] = $lastIdList = $listService->getLastPhotoIdList($listType, $photo->id, $data);
         }
         if (!empty($params['loadNextPhoto'])) {
             $nextId = !empty($nextIdList) ? max($nextIdList) : (!empty($lastIdList) ? max($lastIdList) : null);
             if ($nextId && !isset($resp['photos'][$nextId])) {
                 $resp['photos'][$nextId] = $this->prepareMarkup($nextId, $params['layout']);
                 $resp['photos'][$nextId]['ownerId'] = $this->photoService->findPhotoOwner($nextId);
                 $rateInfo = BOL_RateService::getInstance()->findRateInfoForEntityList('photo_rates', array($nextId));
                 $userScore = BOL_RateService::getInstance()->findUserSocre($userId, 'photo_rates', array($nextId));
                 $resp['photos'][$nextId]['rateInfo'] = $rateInfo[$nextId];
                 $resp['photos'][$nextId]['userScore'] = $userScore[$nextId];
             }
         }
     }
     return $resp;
 }
Exemple #5
0
          KEY `entityTypeId` (`entityTypeId`,`entityId`),
          FULLTEXT KEY `content` (`content`)
        ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;
    ');
} catch (Exception $e) {
    Updater::getLogger()->addEntry(json_encode($e));
}
try {
    UPDATE_Autoload::getInstance()->addPackagePointer('PHOTO_BOL', $plugin->getBolDir());
    PHOTO_BOL_SearchService::getInstance()->addEntityType(PHOTO_BOL_SearchService::ENTITY_TYPE_ALBUM);
    PHOTO_BOL_SearchService::getInstance()->addEntityType(PHOTO_BOL_SearchService::ENTITY_TYPE_PHOTO);
} catch (Exception $e) {
    Updater::getLogger()->addEntry(json_encode($e));
}
try {
    $entityTypeId = PHOTO_BOL_SearchService::getInstance()->getEntityTypeId(PHOTO_BOL_SearchService::ENTITY_TYPE_PHOTO);
    Updater::getDbo()->query('INSERT INTO `' . PHOTO_BOL_SearchDataDao::getInstance()->getTableName() . '` (`entityTypeId`, `entityId`, `content`)
        SELECT ' . $entityTypeId . ', `id`, `description`
        FROM `' . PHOTO_BOL_PhotoDao::getInstance()->getTableName() . '`');
} catch (Exception $e) {
    Updater::getLogger()->addEntry(json_encode($e));
}
$config = Updater::getConfigService();
if (!$config->configExists('photo', 'photo_list_view_classic')) {
    $config->addConfig('photo', 'photo_list_view_classic', FALSE);
}
if (!$config->configExists('photo', 'album_list_view_classic')) {
    $config->addConfig('photo', 'album_list_view_classic', FALSE);
}
if (!$config->configExists('photo', 'photo_view_classic')) {
    $config->addConfig('photo', 'photo_view_classic', FALSE);