本文整理汇总了PHP中OW::getStorage方法的典型用法代码示例。如果您正苦于以下问题:PHP OW::getStorage方法的具体用法?PHP OW::getStorage怎么用?PHP OW::getStorage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OW
的用法示例。
在下文中一共展示了OW::getStorage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
}
}
}
示例2: addTemplate
public function addTemplate($fileName, $roleIds = null, $default = false)
{
$canvasWidth = self::CANVAS_WIDTH;
$canvasHeight = $this->config['cover_height'];
$coverImage = new UTIL_Image($fileName);
$imageHeight = $coverImage->getHeight();
$imageWidth = $coverImage->getWidth();
$css = array('width' => 'auto', 'height' => 'auto');
$tmp = $canvasWidth * $imageHeight / $imageWidth;
if ($tmp >= $canvasHeight) {
$css['width'] = '100%';
} else {
$css['height'] = '100%';
}
$template = new UHEADER_BOL_Template();
$extension = UTIL_File::getExtension($fileName);
$template->file = uniqid('template-') . '.' . $extension;
$template->default = $default;
$template->timeStamp = time();
$dimensions = array('height' => $imageHeight, 'width' => $imageWidth);
$template->setSettings(array('dimensions' => $dimensions, 'css' => $css, 'canvas' => array('width' => $canvasWidth, 'height' => $canvasHeight), 'position' => array('top' => 0, 'left' => 0)));
$this->service->saveTemplate($template);
if ($roleIds !== null) {
$this->service->saveRoleIdsForTemplateId($template->id, $roleIds);
}
$templatePath = $this->service->getTemplatePath($template);
OW::getStorage()->copyFile($fileName, $templatePath);
}
示例3: exportConfigs
private function exportConfigs(ZipArchive $za, $archiveDir)
{
$this->configs['avatarUrl'] = OW::getStorage()->getFileUrl(BOL_AvatarService::getInstance()->getAvatarsDir());
$tableName = OW::getDbo()->escapeString(str_replace(OW_DB_PREFIX, '%%TBL-PREFIX%%', BOL_ConfigDao::getInstance()->getTableName()));
$query = " SELECT `key`, `name`, `value`, `description` FROM " . BOL_ConfigDao::getInstance()->getTableName() . " WHERE name NOT IN ( 'maintenance', 'update_soft', 'site_installed', 'soft_build', 'soft_version' )\n AND `key` NOT IN ( 'dataimporter', 'dataexporter' ) ";
$sql = DATAEXPORTER_BOL_ExportService::getInstance()->exportTableToSql(OW_DB_PREFIX . 'base_config', false, false, true, $query);
$za->addFromString($archiveDir . '/configs.sql', $sql);
}
示例4: export
public function export($params)
{
/* @var $za ZipArchives */
$za = $params['zipArchive'];
$archiveDir = $params['archiveDir'];
$plugin = OW::getPluginManager()->getPlugin('groups');
$string = json_encode(array('dirUrl' => OW::getStorage()->getFileUrl($plugin->getUserFilesDir())));
$za->addFromString($archiveDir . '/' . 'config.txt', $string);
}
示例5: __construct
public function __construct($albumId, $photoId = NULL, $userId = NULL)
{
parent::__construct();
if (empty($userId)) {
$userId = OW::getUser()->getId();
}
if (empty($userId) || ($album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($albumId)) === null || ($album->userId != $userId || !OW::getUser()->isAuthorized('photo', 'view'))) {
$this->setVisible(FALSE);
return;
}
if ($photoId === NULL && !PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->isAlbumCoverExist($albumId)) {
$this->setVisible(FALSE);
return;
}
$storage = OW::getStorage();
if (empty($photoId)) {
if ($storage instanceof BASE_CLASS_FileStorage) {
$photoPath = PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->getAlbumCoverPathByAlbumId($albumId);
} else {
$photoPath = PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->getAlbumCoverUrlByAlbumId($albumId, true);
}
$info = getimagesize($photoPath);
if ($info['0'] < 330 || $info['1'] < 330) {
$this->assign('imgError', OW::getLanguage()->text('photo', 'to_small_cover_img'));
return;
}
$this->assign('coverUrl', PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->getAlbumCoverUrlByAlbumId($albumId, TRUE));
} else {
$photo = PHOTO_BOL_PhotoDao::getInstance()->findById($photoId);
$this->assign('coverUrl', PHOTO_BOL_PhotoDao::getInstance()->getPhotoUrl($photo->id, $photo->hash, FALSE));
if (!empty($photo->dimension)) {
$info = json_decode($photo->dimension, true);
if ($info[PHOTO_BOL_PhotoService::TYPE_ORIGINAL]['0'] < 330 || $info[PHOTO_BOL_PhotoService::TYPE_ORIGINAL]['1'] < 330) {
$this->assign('imgError', OW::getLanguage()->text('photo', 'to_small_cover_img'));
return;
}
} else {
if ($storage instanceof BASE_CLASS_FileStorage) {
$photoPath = PHOTO_BOL_PhotoDao::getInstance()->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_ORIGINAL);
} else {
$photoPath = PHOTO_BOL_PhotoDao::getInstance()->getPhotoUrl($photo->id, $photo->hash, FALSE);
}
$info = getimagesize($photoPath);
if ($info['0'] < 330 || $info['1'] < 330) {
$this->assign('imgError', OW::getLanguage()->text('photo', 'to_small_cover_img'));
return;
}
}
}
OW::getDocument()->addStyleSheet(OW::getPluginManager()->getPlugin('base')->getStaticCssUrl() . 'jquery.Jcrop.css');
OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'jquery.Jcrop.js');
$form = new PHOTO_CLASS_MakeAlbumCover();
$form->getElement('albumId')->setValue($albumId);
$form->getElement('photoId')->setValue($photoId);
$this->addForm($form);
}
示例6: onBeforeGroupDelete
public function onBeforeGroupDelete(OW_Event $event)
{
$params = $event->getParams();
$groupId = $params['groupId'];
$group = GROUPS_BOL_Service::getInstance()->findGroupById($groupId);
$fileName = GROUPS_BOL_Service::getInstance()->getGroupImagePath($group);
if ($fileName !== null) {
OW::getStorage()->removeFile($fileName);
}
}
示例7: getLocalPath
public static function getLocalPath($uri)
{
$userFilesUrl = OW::getStorage()->getFileUrl(OW_DIR_USERFILES);
$path = null;
if (stripos($uri, OW_URL_HOME) !== false) {
$path = str_replace(OW_URL_HOME, OW_DIR_ROOT, $uri);
$path = str_replace('/', DS, $path);
} else {
if (stripos($uri, $userFilesUrl) !== false) {
$path = str_replace($userFilesUrl, OW_DIR_USERFILES, $uri);
$path = str_replace('/', DS, $path);
}
}
return $path;
}
示例8: copy_resize_image
public function copy_resize_image($tmp_name, $slugimage, $idThumb, $extension, $width = null, $height = null)
{
if ($extension == null) {
$extension = '';
}
$storage = OW::getStorage();
$imagesDir = OW::getPluginManager()->getPlugin('spdownload')->getUserFilesDir();
$imageName = $slugimage . '_' . $idThumb . '.' . $extension;
$imagePath = $imagesDir . $imageName;
$pluginfilesDir = Ow::getPluginManager()->getPlugin('spdownload')->getPluginFilesDir();
$tmpImgPath = $slugimage . '_' . $idThumb . '.' . $extension;
$image = new UTIL_Image($tmp_name);
$image->resizeImage($width, $height)->saveImage($tmpImgPath);
//Copy file into storage folder
$storage->copyFile($tmpImgPath, $imagePath);
unlink($tmpImgPath);
}
示例9: prepareMarkup
private function prepareMarkup($photo, $layout = null)
{
$markup = array();
$photo->title = UTIL_HtmlTag::autoLink($photo->title);
$photo->url = OW::getStorage()->getFileUrl($this->themeService->getUserfileImagesDir() . $photo->getFilename());
$photo->addDatetime = UTIL_DateTime::formatSimpleDate($photo->addDatetime, true);
$markup['photo'] = $photo;
$action = new BASE_ContextAction();
$action->setKey('photo-moderate');
$context = new BASE_CMP_ContextAction();
$context->addAction($action);
$lang = OW::getLanguage();
$action = new BASE_ContextAction();
$action->setKey('delete');
$action->setParentKey('photo-moderate');
$action->setLabel($lang->text('base', 'delete'));
$action->setId('photo-delete');
$action->addAttribute('rel', $photo->id);
$context->addAction($action);
$markup['contextAction'] = $context->render();
$document = OW::getDocument();
$onloadScript = $document->getOnloadScript();
if (!empty($onloadScript)) {
$markup['onloadScript'] = $onloadScript;
}
$scriptFiles = $document->getScripts();
if (!empty($scriptFiles)) {
$markup['scriptFiles'] = $scriptFiles;
}
$css = $document->getStyleDeclarations();
if (!empty($css)) {
$markup['css'] = $css;
}
$cssFiles = $document->getStyleSheets();
if (!empty($cssFiles)) {
$markup['cssFiles'] = $cssFiles;
}
$meta = $document->getMeta();
if (!empty($meta)) {
$markup['meta'] = $meta;
}
return $markup;
}
示例10: removeFile
/**
* Removes file
*
* @param int $id
*/
public function removeFile($id)
{
$path = $this->getFilePath($id);
$storage = OW::getStorage();
if ($storage->fileExists($path)) {
$storage->removeFile($path);
}
}
示例11: addFromPhotos
public function addFromPhotos($query)
{
$photoId = $query['photoId'];
$groupId = $query['groupId'];
if (!GHEADER_CLASS_CreditsBridge::getInstance()->credits->isAvaliable(GHEADER_CLASS_Credits::ACTION_ADD)) {
$error = GHEADER_CLASS_CreditsBridge::getInstance()->credits->getErrorMessage(GHEADER_CLASS_Credits::ACTION_ADD);
throw new InvalidArgumentException($error);
}
$sourcePath = GHEADER_CLASS_PhotoBridge::getInstance()->pullPhoto($photoId);
if ($sourcePath === null) {
throw new InvalidArgumentException("The requested photo wasn't find");
}
$canvasWidth = $query['width'];
$canvasHeight = OW::getConfig()->getValue('gheader', 'cover_height');
$coverImage = new UTIL_Image($sourcePath);
$imageHeight = $coverImage->getHeight();
$imageWidth = $coverImage->getWidth();
$css = array('width' => 'auto', 'height' => 'auto');
$tmp = $canvasWidth * $imageHeight / $imageWidth;
if ($tmp >= $canvasHeight) {
$css['width'] = '100%';
} else {
$css['height'] = '100%';
}
$this->validateImage($coverImage, $canvasWidth, $canvasHeight);
$cover = $this->service->findCoverByGroupId($groupId, GHEADER_BOL_Cover::STATUS_TMP);
if ($cover === null) {
$cover = new GHEADER_BOL_Cover();
}
$extension = UTIL_File::getExtension($sourcePath);
$cover->file = uniqid('cover-' . $groupId . '-') . '.' . $extension;
$cover->groupId = $groupId;
$cover->status = GHEADER_BOL_Cover::STATUS_TMP;
$cover->timeStamp = time();
$dimensions = array('height' => $imageHeight, 'width' => $imageWidth);
$cover->setSettings(array('photoId' => $photoId, 'dimensions' => $dimensions, 'css' => $css, 'canvas' => array('width' => $canvasWidth, 'height' => $canvasHeight), 'position' => array('top' => 0, 'left' => 0)));
$this->service->saveCover($cover);
$coverPath = $this->service->getCoverPath($cover);
OW::getStorage()->copyFile($sourcePath, $coverPath);
@unlink($sourcePath);
$coverUrl = $this->service->getCoverUrl($cover);
return array('src' => $coverUrl, 'data' => $cover->getSettings());
}
示例12: removePhotoFile
/**
* Removes photo file
*
* @param int $id
* @param $hash
* @param string $type
*/
public function removePhotoFile($id, $hash, $type)
{
$path = $this->getPhotoPath($id, $hash, $type);
$storage = OW::getStorage();
if ($storage->fileExists($path)) {
$storage->removeFile($path);
}
}
示例13: moveTemporaryPhoto
public function moveTemporaryPhoto($tmpId, $albumId, $desc, $tag = NULL, $angle = 0, $uploadKey = null, $status = null)
{
$tmp = $this->photoTemporaryDao->findById($tmpId);
$album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($albumId);
if (!$tmp || !$album) {
return FALSE;
}
$previewTmp = $this->photoTemporaryDao->getTemporaryPhotoPath($tmp->id, 1);
$mainTmp = $this->photoTemporaryDao->getTemporaryPhotoPath($tmp->id, 2);
$originalTmp = $this->photoTemporaryDao->getTemporaryPhotoPath($tmp->id, 3);
$smallTmp = $this->photoTemporaryDao->getTemporaryPhotoPath($tmp->id, 4);
$fullscreenTmp = $this->photoTemporaryDao->getTemporaryPhotoPath($tmp->id, 5);
$privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $album->userId, 'action' => 'photo_view_album'));
$photoService = PHOTO_BOL_PhotoService::getInstance();
$photo = new PHOTO_BOL_Photo();
$photo->description = htmlspecialchars(trim($desc));
$photo->albumId = $albumId;
$photo->addDatetime = time();
$photo->status = empty($status) ? "approved" : $status;
$photo->hasFullsize = (int) $tmp->hasFullsize;
$photo->privacy = !empty($privacy) ? $privacy : 'everybody';
$photo->hash = uniqid();
$photo->uploadKey = empty($uploadKey) ? $photoService->getPhotoUploadKey($albumId) : $uploadKey;
PHOTO_BOL_PhotoDao::getInstance()->save($photo);
try {
$storage = OW::getStorage();
$dimension = array();
if ((int) $angle !== 0) {
$tmpImage = $tmp->hasFullsize ? (bool) OW::getConfig()->getValue('photo', 'store_fullsize') ? $originalTmp : $fullscreenTmp : $mainTmp;
$smallImg = new UTIL_Image($tmpImage);
$smallImg->resizeImage(PHOTO_BOL_PhotoService::DIM_SMALL_WIDTH, PHOTO_BOL_PhotoService::DIM_SMALL_HEIGHT, TRUE)->rotate($angle)->saveImage($smallTmp);
$storage->copyFile($smallTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_SMALL));
$dimension[PHOTO_BOL_PhotoService::TYPE_SMALL] = array($smallImg->getWidth(), $smallImg->getHeight());
$smallImg->destroy();
$previewImage = new UTIL_Image($tmpImage);
$previewImage->resizeImage(PHOTO_BOL_PhotoService::DIM_PREVIEW_WIDTH, PHOTO_BOL_PhotoService::DIM_PREVIEW_HEIGHT)->rotate($angle)->saveImage($previewTmp);
$storage->copyFile($previewTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_PREVIEW));
$dimension[PHOTO_BOL_PhotoService::TYPE_PREVIEW] = array($previewImage->getWidth(), $previewImage->getHeight());
$previewImage->destroy();
$main = new UTIL_Image($tmpImage);
$main->resizeImage(PHOTO_BOL_PhotoService::DIM_MAIN_WIDTH, PHOTO_BOL_PhotoService::DIM_MAIN_HEIGHT)->rotate($angle)->saveImage($mainTmp);
$storage->copyFile($mainTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_MAIN));
$dimension[PHOTO_BOL_PhotoService::TYPE_MAIN] = array($main->getWidth(), $main->getHeight());
$main->destroy();
$originalImage = new UTIL_Image($tmpImage);
$originalImage->resizeImage(PHOTO_BOL_PhotoService::DIM_ORIGINAL_WIDTH, PHOTO_BOL_PhotoService::DIM_ORIGINAL_HEIGHT)->rotate($angle)->saveImage($originalTmp);
$storage->copyFile($originalTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_ORIGINAL));
$dimension[PHOTO_BOL_PhotoService::TYPE_ORIGINAL] = array($originalImage->getWidth(), $originalImage->getHeight());
$originalImage->destroy();
if ($tmp->hasFullsize && (bool) OW::getConfig()->getValue('photo', 'store_fullsize')) {
$fullscreen = new UTIL_Image($tmpImage);
$fullscreen->resizeImage(PHOTO_BOL_PhotoService::DIM_FULLSCREEN_WIDTH, PHOTO_BOL_PhotoService::DIM_FULLSCREEN_HEIGHT)->rotate($angle)->saveImage($fullscreenTmp);
$storage->copyFile($fullscreenTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_FULLSCREEN));
$dimension[PHOTO_BOL_PhotoService::TYPE_FULLSCREEN] = array($fullscreen->getWidth(), $fullscreen->getHeight());
$fullscreen->destroy();
}
} else {
$storage->copyFile($smallTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_SMALL));
list($width, $height) = getimagesize($smallTmp);
$dimension[PHOTO_BOL_PhotoService::TYPE_SMALL] = array($width, $height);
$storage->copyFile($previewTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_PREVIEW));
list($width, $height) = getimagesize($previewTmp);
$dimension[PHOTO_BOL_PhotoService::TYPE_PREVIEW] = array($width, $height);
$storage->copyFile($mainTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_MAIN));
list($width, $height) = getimagesize($mainTmp);
$dimension[PHOTO_BOL_PhotoService::TYPE_MAIN] = array($width, $height);
$storage->copyFile($originalTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_ORIGINAL));
list($width, $height) = getimagesize($originalTmp);
$dimension[PHOTO_BOL_PhotoService::TYPE_ORIGINAL] = array($width, $height);
if ($tmp->hasFullsize && (bool) OW::getConfig()->getValue('photo', 'store_fullsize')) {
$storage->copyFile($fullscreenTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_FULLSCREEN));
list($width, $height) = getimagesize($fullscreenTmp);
$dimension[PHOTO_BOL_PhotoService::TYPE_FULLSCREEN] = array($width, $height);
}
}
$photo->setDimension(json_encode($dimension));
PHOTO_BOL_PhotoDao::getInstance()->save($photo);
if (mb_strlen($desc)) {
BOL_TagService::getInstance()->updateEntityTags($photo->id, 'photo', $photoService->descToHashtag($desc));
}
if (mb_strlen($tag)) {
BOL_TagService::getInstance()->updateEntityTags($photo->id, 'photo', explode(',', $tag));
}
OW::getEventManager()->trigger(new OW_Event('photo.onMoveTemporaryPhoto', array('tmpId' => $tmpId, 'albumId' => $albumId, 'photoId' => $photo->id)));
} catch (Exception $e) {
$photo = NULL;
}
return $photo;
}
示例14: getAvatarsUrlList
/**
* Returns list of users' avatars
*
* @param array $userIds
* @param int $size
* @return array
*/
public function getAvatarsUrlList(array $userIds, $size = 1)
{
if (empty($userIds)) {
return array();
}
$urlsList = array();
if (is_array($userIds)) {
$avatars = array();
$prefix = OW::getPluginManager()->getPlugin('base')->getUserFilesDir() . 'avatars' . DS . ($size == 1 ? self::AVATAR_PREFIX : self::AVATAR_BIG_PREFIX);
$defAvatarUrl = $this->getDefaultAvatarUrl($size);
$objList = $this->avatarDao->getAvatarsList($userIds);
foreach ($objList as $avatar) {
$avatars[$avatar->userId] = $avatar;
}
foreach ($userIds as $userId) {
if (array_key_exists($userId, $avatars)) {
$urlsList[$userId] = OW::getStorage()->getFileUrl($prefix . $userId . '_' . $avatars[$userId]->hash . '.jpg');
if ($avatars[$userId]->status != BOL_ContentService::STATUS_ACTIVE) {
$urlsList[$userId] = $defAvatarUrl;
}
} else {
$urlsList[$userId] = $defAvatarUrl;
}
}
}
return $urlsList;
}
示例15: deleteImageById
public function deleteImageById($id)
{
$image = $this->findById((int) $id);
$data = $image->getData();
$storage = OW::getStorage();
$storage->removeFile(OW::getPluginManager()->getPlugin('base')->getUserFilesDir() . $image->id . '-' . $data->name);
$this->deleteById($image->id);
}