本文整理汇总了PHP中PHOTO_BOL_PhotoService::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP PHOTO_BOL_PhotoService::getInstance方法的具体用法?PHP PHOTO_BOL_PhotoService::getInstance怎么用?PHP PHOTO_BOL_PhotoService::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHOTO_BOL_PhotoService
的用法示例。
在下文中一共展示了PHOTO_BOL_PhotoService::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMenu
/**
* Returns menu component
*
* @return BASE_CMP_ContentMenu
*/
private function getMenu()
{
$language = OW::getLanguage();
$validLists = array('photo', 'album', 'tagged');
$classes = array('', '', 'ow_ic_tag');
$urls = array(OW::getRouter()->urlForRoute('photo_list_index'), OW::getRouter()->urlForRoute('photo_list_albums'), '');
$titles = array($language->text('advancedphoto', 'photos'), $language->text('advancedphoto', 'albums'), $language->text('photo', 'menu_tagged'));
if ($user = OW::getUser()->getUserObject()) {
$validLists[3] = "myalbum";
$classes[3] = "";
$urls[3] = OW::getRouter()->urlForRoute('photo_user_albums', array('user' => $user->username));
$titles[3] = $language->text('advancedphoto', 'my_albums');
}
$checkPrivacy = PHOTO_BOL_PhotoService::getInstance()->countPhotos('featured');
if (!PHOTO_BOL_PhotoService::getInstance()->countPhotos('featured', $checkPrivacy)) {
array_shift($validLists);
array_shift($classes);
}
$menuItems = array();
$order = 0;
foreach ($validLists as $type) {
$item = new BASE_MenuItem();
$item->setLabel($titles[$order]);
$item->setUrl($urls[$order] != '' ? $urls[$order] : OW::getRouter()->urlForRoute('view_photo_list', array('listType' => $type)));
$item->setKey($type);
$item->setIconClass($classes[$order]);
$item->setOrder($order);
array_push($menuItems, $item);
$order++;
}
$menu = new BASE_CMP_ContentMenu($menuItems);
return $menu;
}
示例2: 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);
}
}
}
}
}
示例3: __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);
}
}
示例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: __construct
/**
* Class constructor
*/
public function __construct()
{
parent::__construct();
$this->photoService = PHOTO_BOL_PhotoService::getInstance();
$this->photoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance();
$this->ajaxResponder = OW::getRouter()->urlFor('GPHOTOVIEWER_CTRL_Index', 'ajaxResponder');
}
示例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: 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')));
}
示例12: __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);
}
示例13: 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;
}
示例14: __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);
}
示例15: getMenuItems
public function getMenuItems(array $keys, $uniqId)
{
$lang = OW::getLanguage();
$menuItems = array();
$photoService = PHOTO_BOL_PhotoService::getInstance();
if (in_array('latest', $keys)) {
$count = $photoService->countPhotos('latest');
$menuItems['latest'] = array('label' => $lang->text('photo', 'menu_latest'), 'id' => 'photo-cmp-menu-latest-' . $uniqId, 'contId' => 'photo-cmp-latest-' . $uniqId, 'active' => true, 'visibility' => $count > $this->visiblePhotoCount ? true : false);
}
if (in_array('featured', $keys)) {
$count = $photoService->countPhotos('featured');
$menuItems['featured'] = array('label' => $lang->text('photo', 'menu_featured'), 'id' => 'photo-cmp-menu-featured-' . $uniqId, 'contId' => 'photo-cmp-featured-' . $uniqId, 'active' => false, 'visibility' => $count > $this->visiblePhotoCount ? true : false);
}
if (in_array('toprated', $keys)) {
$count = $photoService->countPhotos('toprated');
$menuItems['toprated'] = array('label' => $lang->text('photo', 'menu_toprated'), 'id' => 'photo-cmp-menu-toprated-' . $uniqId, 'contId' => 'photo-cmp-toprated-' . $uniqId, 'active' => false, 'visibility' => $count > $this->visiblePhotoCount ? true : false);
}
return $menuItems;
}