本文整理汇总了PHP中PHOTO_BOL_PhotoService类的典型用法代码示例。如果您正苦于以下问题:PHP PHOTO_BOL_PhotoService类的具体用法?PHP PHOTO_BOL_PhotoService怎么用?PHP PHOTO_BOL_PhotoService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHOTO_BOL_PhotoService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($listType, $count, $exclude = null, $albumId = null)
{
parent::__construct();
$this->photoService = PHOTO_BOL_PhotoService::getInstance();
$this->photoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance();
$checkPrivacy = !OW::getUser()->isAuthorized('photo');
if ($albumId) {
$photos = $this->photoService->getAlbumPhotos($albumId, 1, $count, $exclude);
} else {
$photos = $this->photoService->findPhotoList($listType, 1, $count, $checkPrivacy, $exclude);
}
$this->assign('photos', $photos);
foreach ($photos as $photo) {
array_push($exclude, $photo['id']);
}
if ($albumId) {
$loadMore = $this->photoAlbumService->countAlbumPhotos($albumId, $exclude);
} else {
$loadMore = $this->photoService->countPhotos($listType, $checkPrivacy, $exclude);
}
if (!$loadMore) {
$script = "OWM.trigger('photo.hide_load_more', {});";
OW::getDocument()->addOnloadScript($script);
}
}
示例2: getInstance
/**
* Returns class instance
*
* @return PHOTO_BOL_PhotoService
*/
public static function getInstance()
{
if (null === self::$classInstance) {
self::$classInstance = new self();
}
return self::$classInstance;
}
示例3: import
public function import($params)
{
$importDir = $params['importDir'];
$txtFile = $importDir . 'configs.txt';
// import configs
if (file_exists($txtFile)) {
$string = file_get_contents($txtFile);
$configs = json_decode($string, true);
}
if (!$configs) {
return;
}
$photoService = PHOTO_BOL_PhotoService::getInstance();
$types = array('main', 'preview', 'original');
$photoDir = $photoService->getPhotoUploadDir();
$page = 1;
while (true) {
$photos = $photoService->findPhotoList('latest', $page, 10);
$page++;
if (empty($photos)) {
break;
}
foreach ($photos as $photo) {
foreach ($types as $type) {
$path = $photoService->getPhotoPath($photo['id'], $photo['hash'], $type);
$photoName = str_replace($photoDir, '', $path);
$content = file_get_contents($configs['url'] . '/' . $photoName);
if (mb_strlen($content)) {
OW::getStorage()->fileSetContent($path, $content);
}
}
}
}
}
示例4: albumsDeleteProcess
public function albumsDeleteProcess()
{
$config = OW::getConfig();
// check if uninstall is in progress
if (!$config->getValue('photo', 'uninstall_inprogress')) {
return;
}
// check if cron queue is not busy
if ($config->getValue('photo', 'uninstall_cron_busy')) {
return;
}
$config->saveConfig('photo', 'uninstall_cron_busy', 1);
$albumService = PHOTO_BOL_PhotoAlbumService::getInstance();
try {
$albumService->deleteAlbums(self::ALBUMS_DELETE_LIMIT);
} catch (Exception $e) {
OW::getLogger()->addEntry(json_encode($e));
}
$config->saveConfig('photo', 'uninstall_cron_busy', 0);
if (!$albumService->countAlbums()) {
BOL_PluginService::getInstance()->uninstall('photo');
$config->saveConfig('photo', 'uninstall_inprogress', 0);
PHOTO_BOL_PhotoService::getInstance()->setMaintenanceMode(false);
}
}
示例5: findPhotoList
/**
* Returns photo list
*
* @param string $type
* @param int $page
* @param int $limit
* @return array of PHOTO_BOL_Photo
*/
public function findPhotoList($type, $page, $limit, $checkPrivacy = true)
{
if ($type == 'toprated') {
$first = ($page - 1) * $limit;
$topRatedList = BOL_RateService::getInstance()->findMostRatedEntityList('photo_rates', $first, $limit);
if (!$topRatedList) {
return array();
}
$photoArr = $this->advancedphotoDao->findPhotoInfoListByIdList(array_keys($topRatedList));
$photos = array();
foreach ($photoArr as $key => $photo) {
$photos[$key] = $photo;
$photos[$key]['score'] = $topRatedList[$photo['id']]['avgScore'];
$photos[$key]['rates'] = $topRatedList[$photo['id']]['ratesCount'];
}
usort($photos, array('PHOTO_BOL_PhotoService', 'sortArrayItemByDesc'));
} else {
$photos = $this->advancedphotoDao->getPhotoList($type, $page, $limit, $checkPrivacy);
}
if ($photos) {
foreach ($photos as $key => $photo) {
$photos[$key]['url'] = $this->photoService->getPhotoPreviewUrl($photo['id']);
}
}
return $photos;
}
示例6: __construct
public function __construct($photoId)
{
parent::__construct();
$photoEditForm = new PHOTO_CLASS_EditForm($photoId);
$this->addForm($photoEditForm);
$photo = PHOTO_BOL_PhotoService::getInstance()->findPhotoById($photoId);
$photoEditForm->getElement('id')->setValue($photoId);
$photoEditForm->getElement('description')->setValue($photo->description);
}
示例7: export
public function export($params)
{
$photoService = PHOTO_BOL_PhotoService::getInstance();
$url = OW::getStorage()->getFileUrl($photoService->getPhotoUploadDir());
/* @var $za ZipArchives */
$za = $params['zipArchive'];
$archiveDir = $params['archiveDir'];
$string = json_encode(array('url' => $url));
$za->addFromString($archiveDir . '/' . 'configs.txt', $string);
}
示例8: __construct
public function __construct($userId)
{
$photos = PHOTO_BOL_PhotoService::getInstance()->findPhotoList('latest', 1, 2);
if (empty($photos)) {
$this->setVisible(false);
return;
}
$items = array();
foreach ($photos as $item) {
$items[] = array('src' => $item['url']);
}
parent::__construct($items, 'Photos');
}
示例9: __construct
public function __construct($albumId = NULL, $albumName = NULL, $albumDescription = null, $url = NULL)
{
if (!OW::getUser()->isAuthorized('photo', 'upload')) {
$this->setVisible(FALSE);
return;
}
$userId = OW::getUser()->getId();
$document = OW::getDocument();
PHOTO_BOL_PhotoTemporaryService::getInstance()->deleteUserTemporaryPhotos($userId);
$plugin = OW::getPluginManager()->getPlugin('photo');
$document->addStyleSheet($plugin->getStaticCssUrl() . 'photo_upload.css');
$document->addScript($plugin->getStaticJsUrl() . 'jQueryRotate.min.js');
$document->addScript($plugin->getStaticJsUrl() . 'codemirror.min.js');
$document->addScript($plugin->getStaticJsUrl() . 'upload.js');
$document->addScriptDeclarationBeforeIncludes(UTIL_JsGenerator::composeJsString(';window.ajaxPhotoUploadParams = {};
Object.defineProperties(ajaxPhotoUploadParams, {
actionUrl: {
value: {$url},
writable: false,
enumerable: true
},
maxFileSize: {
value: {$size},
writable: false,
enumerable: true
},
deleteAction: {
value: {$deleteAction},
writable: false,
enumerable: true
}
});', array('url' => OW::getRouter()->urlForRoute('photo.ajax_upload'), 'size' => PHOTO_BOL_PhotoService::getInstance()->getMaxUploadFileSize(), 'deleteAction' => OW::getRouter()->urlForRoute('photo.ajax_upload_delete'))));
$document->addOnloadScript(';window.ajaxPhotoUploader.init();');
$this->addForm(new PHOTO_CLASS_AjaxUploadForm('user', $userId, $albumId, $albumName, $albumDescription, $url));
$newsfeedAlbum = PHOTO_BOL_PhotoAlbumService::getInstance()->getNewsfeedAlbum($userId);
$this->assign('albumNameList', PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumNameListByUserId($userId, !empty($newsfeedAlbum) ? array($newsfeedAlbum->id) : array()));
$language = OW::getLanguage();
$language->addKeyForJs('photo', 'not_all_photos_uploaded');
$language->addKeyForJs('photo', 'size_limit');
$language->addKeyForJs('photo', 'type_error');
$language->addKeyForJs('photo', 'dnd_support');
$language->addKeyForJs('photo', 'dnd_not_support');
$language->addKeyForJs('photo', 'drop_here');
$language->addKeyForJs('photo', 'please_wait');
$language->addKeyForJs('photo', 'create_album');
$language->addKeyForJs('photo', 'album_name');
$language->addKeyForJs('photo', 'album_desc');
$language->addKeyForJs('photo', 'describe_photo');
$language->addKeyForJs('photo', 'photo_upload_error');
}
示例10: onInfoRender
public function onInfoRender(OW_Event $event)
{
$language = OW::getLanguage();
$params = $event->getParams();
if ($params["entityType"] != HINT_BOL_Service::ENTITY_TYPE_USER) {
return;
}
$userId = $params["entityId"];
if ($params["key"] != "photo-count") {
return;
}
$count = PHOTO_BOL_PhotoService::getInstance()->countUserPhotos($userId);
$url = OW::getRouter()->urlForRoute("photo_user_albums", array("user" => BOL_UserService::getInstance()->getUserName($userId)));
$event->setData($language->text("hint", "info_photo_count", array("count" => $count, "url" => $url)));
}
示例11: getFloatbox
public function getFloatbox()
{
if (empty($_POST['photoId']) || !$_POST['photoId']) {
throw new Redirect404Exception();
}
$photoId = (int) $_POST['photoId'];
$service = PHOTO_BOL_PhotoService::getInstance();
$photo = $service->findPhotoById($photoId);
if (!$photo) {
exit(json_encode(array('result' => 'error')));
}
// is moderator
$moderatorMode = OW::getUser()->isAuthorized('photo');
$userId = OW::getUser()->getId();
$resp['result'] = "success";
if ($_POST['current'] == "true") {
$resp['current'] = $this->prepareMarkup($photoId);
$contentOwner = $this->photoService->findPhotoOwner($photoId);
$ownerMode = $contentOwner == $userId;
$resp['current']['authorized'] = $ownerMode || $moderatorMode || OW::getUser()->isAuthorized('photo', 'view');
}
if ($_POST['prev'] == "true") {
$prevPhoto = $service->getPreviousPhoto($photo->albumId, $photo->id);
if ($prevPhoto) {
$resp['prev'] = $this->prepareMarkup($prevPhoto['dto']->id);
$resp['prev']['prev'] = $service->getPreviousPhotoId($photo->albumId, $prevPhoto['dto']->id);
$resp['prev']['next'] = $photo->id;
$resp['current']['prev'] = $prevPhoto['dto']->id;
$contentOwner = $this->photoService->findPhotoOwner($prevPhoto['dto']->id);
$ownerMode = $contentOwner == $userId;
$resp['prev']['authorized'] = $ownerMode || $moderatorMode || OW::getUser()->isAuthorized('photo', 'view');
}
}
if ($_POST['next'] == "true") {
$nextPhoto = $service->getNextPhoto($photo->albumId, $photo->id);
if ($nextPhoto) {
$resp['next'] = $this->prepareMarkup($nextPhoto['dto']->id);
$resp['next']['prev'] = $photo->id;
$resp['next']['next'] = $service->getNextPhotoId($photo->albumId, $nextPhoto['dto']->id);
$resp['current']['next'] = $nextPhoto['dto']->id;
$contentOwner = $this->photoService->findPhotoOwner($nextPhoto['dto']->id);
$ownerMode = $contentOwner == $userId;
$resp['next']['authorized'] = $ownerMode || $moderatorMode || OW::getUser()->isAuthorized('photo', 'view');
}
}
exit(json_encode($resp));
}
示例12: findIndexedData
public function findIndexedData($searchVal, array $entityTypes = array(), $limit = PHOTO_BOL_SearchService::SEARCH_LIMIT)
{
$condition = PHOTO_BOL_PhotoService::getInstance()->getQueryCondition('searchByDesc', array('photo' => 'p', 'album' => 'a'));
$sql = 'SELECT `index`.*
FROM `' . $this->getTableName() . '` AS `index`
INNER JOIN `' . PHOTO_BOL_PhotoDao::getInstance()->getTableName() . '` AS `p` ON(`index`.`entityId` = `p`.`id`)
INNER JOIN `' . PHOTO_BOL_PhotoAlbumDao::getInstance()->getTableName() . '` AS `a` ON(`a`.`id` = `p`.`albumId`)
' . $condition['join'] . '
WHERE MATCH(`index`.`' . self::CONTENT . '`) AGAINST(:val IN BOOLEAN MODE) AND `p`.`privacy` = :everybody AND `p`.`status` = :status AND ' . $condition['where'];
if (count($entityTypes) !== 0) {
$sql .= ' AND `index`.`' . self::ENTITY_TYPE_ID . '` IN (SELECT `entity`.`id`
FROM `' . PHOTO_BOL_SearchEntityTypeDao::getInstance()->getTableName() . '` AS `entity`
WHERE `entity`.`' . PHOTO_BOL_SearchEntityTypeDao::ENTITY_TYPE . '` IN( ' . $this->dbo->mergeInClause($entityTypes) . '))';
}
$sql .= ' LIMIT :limit';
return $this->dbo->queryForObjectList($sql, $this->getDtoClassName(), array_merge($condition['params'], array('val' => $searchVal, 'limit' => (int) $limit, 'everybody' => PHOTO_BOL_PhotoDao::PRIVACY_EVERYBODY, 'status' => 'approved')));
}
示例13: __construct
public function __construct($photoId = NULL)
{
parent::__construct('photo-edit-form');
$this->setAjax(TRUE);
$this->setAction(OW::getRouter()->urlFor('PHOTO_CTRL_Photo', 'ajaxUpdatePhoto'));
$this->bindJsFunction('success', 'function( data )
{
OW.trigger("photo.afterPhotoEdit", data);
}');
$photo = PHOTO_BOL_PhotoService::getInstance()->findPhotoById($photoId);
$album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($photo->albumId);
$photoIdField = new HiddenField('photoId');
$photoIdField->setRequired(TRUE);
$photoIdField->setValue($photo->id);
$photoIdField->addValidator(new PHOTO_CLASS_PhotoOwnerValidator());
$this->addElement($photoIdField);
$albumField = new TextField('album');
$albumField->setId('ajax-upload-album');
$albumField->setRequired();
$albumField->setValue($album->name);
$albumField->setLabel(OW::getLanguage()->text('photo', 'create_album'));
$albumField->addAttribute('class', 'ow_dropdown_btn ow_inputready ow_cursor_pointer');
$albumField->addAttribute('autocomplete', 'off');
$albumField->addAttribute('readonly');
$this->addElement($albumField);
$albumNameField = new TextField('album-name');
$albumNameField->setRequired();
$albumNameField->setValue($album->name);
$albumNameField->addValidator(new PHOTO_CLASS_AlbumNameValidator(FALSE, NULL, $album->name));
$albumNameField->setHasInvitation(TRUE);
$albumNameField->setInvitation(OW::getLanguage()->text('photo', 'album_name'));
$albumNameField->addAttribute('class', 'ow_smallmargin invitation');
$this->addElement($albumNameField);
$desc = new Textarea('description');
$desc->setHasInvitation(TRUE);
$desc->setInvitation(OW::getLanguage()->text('photo', 'album_desc'));
$this->addElement($desc);
$photoDesc = new PHOTO_CLASS_HashtagFormElement('photo-desc');
$photoDesc->setValue($photo->description);
$photoDesc->setLabel(OW::getLanguage()->text('photo', 'album_desc'));
$this->addElement($photoDesc);
$submit = new Submit('edit');
$submit->setValue(OW::getLanguage()->text('photo', 'btn_edit'));
$this->addElement($submit);
}
示例14: findUserPhotos
public function findUserPhotos($userId, $start, $offset)
{
$photoService = PHOTO_BOL_PhotoService::getInstance();
$photoDao = PHOTO_BOL_PhotoDao::getInstance();
$albumDao = PHOTO_BOL_PhotoAlbumDao::getInstance();
$query = 'SELECT p.* FROM ' . $photoDao->getTableName() . ' AS p
INNER JOIN ' . $albumDao->getTableName() . ' AS a ON p.albumId=a.id
WHERE a.userId=:u AND p.status = "approved" ORDER BY p.addDatetime DESC
LIMIT :start, :offset';
$list = OW::getDbo()->queryForList($query, array('u' => $userId, 'start' => $start, 'offset' => $offset));
$out = array();
foreach ($list as $photo) {
$id = $photo['id'];
$out[$id] = array('id' => $id, 'thumb' => $photoService->getPhotoPreviewUrl($id), 'url' => $photoService->getPhotoUrl($id), 'path' => $photoService->getPhotoPath($id), 'description' => $photo['description'], 'permalink' => OW::getRouter()->urlForRoute('view_photo', array('id' => $id)));
$out[$id]['oembed'] = json_encode(array('type' => 'photo', 'url' => $out[$id]['url'], 'href' => $out[$id]['permalink'], 'description' => $out[$id]['description']));
}
return $out;
}
示例15: __construct
/**
* Class constructor
*/
public function __construct($photoId)
{
parent::__construct('photo-edit-form');
$this->setAjax(true);
$this->setAction(OW::getRouter()->urlFor('PHOTO_CTRL_Photo', 'ajaxUpdatePhoto'));
$language = OW::getLanguage();
$photo = PHOTO_BOL_PhotoService::getInstance()->findPhotoById($photoId);
$album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($photo->albumId);
$userId = OW::getUser()->getId();
// photo id field
$photoIdField = new HiddenField('id');
$photoIdField->setRequired(true);
$this->addElement($photoIdField);
// photo album Field
$albumField = new SuggestField('album');
$responderUrl = OW::getRouter()->urlFor('PHOTO_CTRL_Upload', 'suggestAlbum', array('userId' => $userId));
$albumField->setResponderUrl($responderUrl);
if ($album) {
$albumField->setValue($album->name);
}
$albumField->setRequired(true);
$albumField->setLabel($language->text('photo', 'album'));
$this->addElement($albumField);
// description Field
$descField = new WysiwygTextarea('description', null, false);
$descField->setId("photo-desc-area");
$this->addElement($descField->setLabel($language->text('photo', 'description')));
$tags = array();
$entityTags = BOL_TagService::getInstance()->findEntityTags($photo->id, 'photo');
if ($entityTags) {
$tags = array();
foreach ($entityTags as $entityTag) {
$tags[] = $entityTag->label;
}
$tagsField = new TagsInputField('tags');
$tagsField->setValue($tags);
} else {
$tagsField = new TagsInputField('tags');
}
$this->addElement($tagsField->setLabel($language->text('photo', 'tags')));
$submit = new Submit('edit');
$submit->setValue($language->text('photo', 'btn_edit'));
$this->addElement($submit);
}