当前位置: 首页>>代码示例>>PHP>>正文


PHP FD::photo方法代码示例

本文整理汇总了PHP中FD::photo方法的典型用法代码示例。如果您正苦于以下问题:PHP FD::photo方法的具体用法?PHP FD::photo怎么用?PHP FD::photo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FD的用法示例。


在下文中一共展示了FD::photo方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: crop

 /**
  * Displays the dialog to allow user to crop avatar
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function crop()
 {
     // Require the user to be logged in
     FD::requireLogin();
     // Load up the ajax library
     $ajax = FD::ajax();
     // Get the unique object.
     $uid = JRequest::getInt('uid');
     $type = JRequest::getCmd('type');
     // Get photo id
     $id = JRequest::getInt('id');
     $table = FD::table('Photo');
     $table->load($id);
     $redirectUrl = JRequest::getVar('redirectUrl', '');
     // Load up the library
     $lib = FD::photo($table->uid, $table->type, $table);
     if (!$table->id) {
         return $this->deleted($lib);
     }
     // Check if the user is really allowed to upload avatar
     if (!$lib->canUseAvatar()) {
         return $ajax->reject();
     }
     $redirect = JRequest::getInt('redirect', 1);
     $theme = FD::themes();
     $theme->set('uid', $uid);
     $theme->set('type', $type);
     $theme->set('redirectUrl', $redirectUrl);
     $theme->set('photo', $lib->data);
     $theme->set('redirect', $redirect);
     $output = $theme->output('site/avatar/crop');
     return $ajax->resolve($output);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:41,代码来源:view.ajax.php

示例2: delete_photo

 public function delete_photo()
 {
     $user = JFactory::getUser($this->plugin->get('user')->id);
     $app = JFactory::getApplication();
     $id = $app->input->get('id', 0, 'INT');
     // Load the photo table
     $photo = FD::table('Photo');
     $photo->load($id);
     $lib = FD::photo($photo->uid, $photo->type, $photo);
     if (!$id && !$photo->id) {
         return false;
     }
     // Load the photo library
     // Test if the user is allowed to delete the photo
     if (!$lib->deleteable()) {
         return false;
     }
     // Try to delete the photo
     $state = $photo->delete();
     if (!$state) {
         return false;
     } else {
         return $state;
     }
 }
开发者ID:yalive,项目名称:com_api-plugins,代码行数:25,代码来源:album.php

示例3: photosSchema

 public function photosSchema($rows, $userid)
 {
     $lang = JFactory::getLanguage();
     $lang->load('com_easysocial', JPATH_ADMINISTRATOR, 'en-GB', true);
     $result = array();
     foreach ($rows as $ky => $row) {
         if (isset($row->id)) {
             $item = new PhotosSimpleSchema();
             $item->isowner = $row->uid == $userid ? true : false;
             $item->id = $row->id;
             $item->album_id = $row->album_id;
             $item->cover_id = $row->cover_id;
             $item->type = $row->type;
             $item->uid = $row->id;
             // for post comment photo id is required.
             $item->user_id = $row->user_id;
             $item->title = JText::_($row->title);
             $item->caption = JText::_($row->caption);
             $item->created = $row->created;
             $item->state = $row->state;
             $item->assigned_date = $row->assigned_date;
             $item->image_large = $row->image_large;
             $item->image_square = $row->image_square;
             $item->image_thumbnail = $row->image_thumbnail;
             $item->image_featured = $row->image_featured;
             $like = FD::photo();
             $like->data->id = $row->id;
             $data = $like->likes();
             $item->likes = $this->createlikeObj($data, $userid);
             $comobj = $like->comments();
             $comobj->stream_id = 1;
             $item->comment_element = $comobj->element . "." . $comobj->group . "." . $comobj->verb;
             $item->comments = $this->createCommentsObj($comobj);
             $result[] = $item;
         }
     }
     return $result;
 }
开发者ID:beingsane,项目名称:com_api-plugins,代码行数:38,代码来源:mappingHelper.php

示例4: moveToAnotherAlbum

 /**
  * Displays the move to album dialog
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function moveToAnotherAlbum()
 {
     $ajax = FD::ajax();
     // Get the current user.
     $my = FD::user();
     // Get photo
     $id = JRequest::getInt('id');
     $photo = FD::table('photo');
     $photo->load($id);
     // If photo id is invalid, reject this.
     if (!$photo->id || !$id) {
         return $ajax->reject();
     }
     // Load up the photo lib
     $lib = FD::photo($photo->uid, $photo->type, $photo);
     // Check if the user is really allowed to move the photo
     if (!$lib->canMovePhoto()) {
         return $ajax->reject();
     }
     // Get albums
     $model = FD::model('Albums');
     $albums = $model->getAlbums($my->id, SOCIAL_TYPE_USER, array('exclusion' => $photo->album_id, 'core' => false));
     // Get dialog
     $theme = FD::themes();
     $theme->set('albums', $albums);
     $theme->set('photo', $photo);
     $html = $theme->output('site/photos/dialog.move');
     return $ajax->resolve($html);
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:37,代码来源:view.ajax.php

示例5: uploadPhoto

 public function uploadPhoto($log_usr = 0, $type = null)
 {
     // Get current logged in user.
     $my = FD::user($log_usr);
     // Get user access
     $access = FD::access($my->id, SOCIAL_TYPE_USER);
     // Load up the photo library
     $lib = FD::photo($log_usr, $type);
     // Define uploader options
     $options = array('name' => 'file', 'maxsize' => $lib->getUploadFileSizeLimit());
     // Get uploaded file
     $file = FD::uploader($options)->getFile();
     // Load the iamge object
     $image = FD::image();
     $image->load($file['tmp_name'], $file['name']);
     // Detect if this is a really valid image file.
     if (!$image->isValid()) {
         return "invalid image";
     }
     // Load up the album's model.
     $albumsModel = FD::model('Albums');
     // Create the default album if necessary
     $album = $albumsModel->getDefaultAlbum($log_usr, $type, SOCIAL_ALBUM_STORY_ALBUM);
     // Bind photo data
     $photo = FD::table('Photo');
     $photo->uid = $log_usr;
     $photo->type = $type;
     $photo->user_id = $my->id;
     $photo->album_id = $album->id;
     $photo->title = $file['name'];
     $photo->caption = '';
     $photo->state = 1;
     $photo->ordering = 0;
     // Set the creation date alias
     $photo->assigned_date = FD::date()->toMySQL();
     // Trigger rules that should occur before a photo is stored
     $photo->beforeStore($file, $image);
     // Try to store the photo.
     $state = $photo->store();
     // Load the photos model
     $photosModel = FD::model('Photos');
     // Get the storage path for this photo
     $storage = FD::call('Photos', 'getStoragePath', array($album->id, $photo->id));
     // Get the photos library
     $photoLib = FD::get('Photos', $image);
     $paths = $photoLib->create($storage);
     // Create metadata about the photos
     if ($paths) {
         foreach ($paths as $type => $fileName) {
             $meta = FD::table('PhotoMeta');
             $meta->photo_id = $photo->id;
             $meta->group = SOCIAL_PHOTOS_META_PATH;
             $meta->property = $type;
             $meta->value = $storage . '/' . $fileName;
             $meta->store();
             // We need to store the photos dimension here
             list($width, $height, $imageType, $attr) = getimagesize(JPATH_ROOT . $storage . '/' . $fileName);
             // Set the photo dimensions
             $meta = FD::table('PhotoMeta');
             $meta->photo_id = $photo->id;
             $meta->group = SOCIAL_PHOTOS_META_WIDTH;
             $meta->property = $type;
             $meta->value = $width;
             $meta->store();
             $meta = FD::table('PhotoMeta');
             $meta->photo_id = $photo->id;
             $meta->group = SOCIAL_PHOTOS_META_HEIGHT;
             $meta->property = $type;
             $meta->value = $height;
             $meta->store();
         }
     }
     // After storing the photo, trigger rules that should occur after a photo is stored
     //$photo->afterStore( $file , $image );
     //$sphoto = new SocialPhotos($photo_obj->id);
     return $photo;
 }
开发者ID:bellodox,项目名称:com_api-plugins,代码行数:77,代码来源:share.php

示例6: editable

 /**
  * Determines if the user is allowed to edit this photo
  *
  * @deprecated  1.2
  * @since   1.0
  * @access  public
  * @param   int     The user to check against (optional)
  * @return  bool    True if success, false otherwise
  */
 public function editable($id = null)
 {
     $lib = FD::photo($this->uid, $this->type, $this);
     // Why shareable instead of editable?
     // Changing to editable for now
     // return $lib->shareable();
     return $lib->editable();
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:17,代码来源:photo.php

示例7: foreach

<div class="es-album-photos">

	<div class="es-photo-item-group no-transition" data-photo-item-group>

		<div class="es-media-item es-photo-item layout-item grid-sizer">
			<div><div></div></div>
		</div>

		<?php 
if (!empty($photos)) {
    ?>
			<?php 
    foreach ($photos as $photo) {
        ?>
				<?php 
        echo FD::photo($photo->uid, $photo->type, $photo)->renderItem($options['photoItem']);
        ?>
			<?php 
    }
    ?>
		<?php 
}
?>
	</div>

	<div class="no-photos-hint content-hint">
		<?php 
echo JText::_("COM_EASYSOCIAL_NO_PHOTOS_AVAILABLE");
?>
	</div>
开发者ID:knigherrant,项目名称:decopatio,代码行数:30,代码来源:photos.php

示例8: createAvatarFromFile

 /**
  * Allows caller to create an avatar by posted the $_FILE data
  *
  * @since   1.0
  * @access  public
  * @param   string
  * @return
  */
 public function createAvatarFromFile()
 {
     // Check for request forgeries
     FD::checkToken();
     // Only registered users should be allowed to upload photos
     FD::requireLogin();
     // Get the current view
     $view = $this->getCurrentView();
     $config = FD::config();
     // Get the unique item id
     $uid = JRequest::getInt('uid');
     $type = JRequest::getCmd('type');
     // Get current user.
     $my = FD::user();
     if (!$uid && !$type) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_PHOTOS_INVALID_ID_PROVIDED'), SOCIAL_MSG_ERROR);
         return $view->call('createAvatar');
     }
     // Load up the photo library
     $lib = FD::photo($uid, $type);
     // Set uploader options
     $options = array('name' => 'avatar_file', 'maxsize' => $lib->getUploadFileSizeLimit());
     // Get uploaded file
     $file = FD::uploader($options)->getFile();
     // If there was an error getting uploaded file, stop.
     if ($file instanceof SocialException) {
         $view->setMessage($file);
         return $view->call('createAvatar');
     }
     // Load the image
     $image = FD::image();
     $image->load($file['tmp_name'], $file['name']);
     // Check if there's a profile photos album that already exists.
     $albumModel = FD::model('Albums');
     // Retrieve the default album for this node.
     $album = $lib->getDefaultAlbum();
     $photo = FD::table('Photo');
     $photo->uid = $uid;
     $photo->type = $type;
     $photo->user_id = $my->id;
     $photo->album_id = $album->id;
     $photo->title = $file['name'];
     $photo->caption = '';
     $photo->ordering = 0;
     // Set the creation date alias
     $photo->assigned_date = FD::date()->toMySQL();
     // We need to set the photo state to "SOCIAL_PHOTOS_STATE_TMP"
     $photo->state = SOCIAL_PHOTOS_STATE_TMP;
     // Try to store the photo first
     $state = $photo->store();
     // Bind any exif data if there are any.
     // Only bind exif data for jpg files (if want to add tiff, then do add it here)
     if ($image->hasExifSupport()) {
         $photo->mapExif($file);
     }
     if (!$state) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_PHOTOS_ERROR_CREATING_IMAGE_FILES'), SOCIAL_MSG_ERROR);
         return $view->call('createAvatar');
     }
     // Push all the ordering of the photo down
     $photosModel = FD::model('photos');
     $photosModel->pushPhotosOrdering($album->id, $photo->id);
     // Render photos library
     $photoLib = FD::get('Photos', $image);
     $storage = $photoLib->getStoragePath($album->id, $photo->id);
     $paths = $photoLib->create($storage);
     // Create metadata about the photos
     foreach ($paths as $type => $fileName) {
         $meta = FD::table('PhotoMeta');
         $meta->photo_id = $photo->id;
         $meta->group = SOCIAL_PHOTOS_META_PATH;
         $meta->property = $type;
         $meta->value = $storage . '/' . $fileName;
         $meta->store();
     }
     // Retrieve the original photo again.
     $image = $photo->getImageObject('original');
     return $view->call('createAvatar', $photo);
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:87,代码来源:photos.php

示例9: addPhotoAlbum

 public function addPhotoAlbum($log_usr = 0, $album_id)
 {
     $my = FD::user();
     // Load up the configuration
     $config = FD::config();
     // Load the album table
     $album = FD::table('Album');
     $album->load($album_id);
     // Check if the album id provided is valid
     if (!$album->id || !$album->id) {
         return "album not valid";
     }
     // Get the uid and the type
     $uid = $album->uid;
     $type = $album->type;
     // Load the photo library
     $lib = FD::photo($uid, $type);
     // Set uploader options
     $options = array('name' => 'file', 'maxsize' => $lib->getUploadFileSizeLimit());
     // Get uploaded file
     $file = FD::uploader($options)->getFile();
     // If there was an error getting uploaded file, stop.
     if ($file instanceof SocialException) {
         return false;
     }
     // Load the image object
     $image = FD::image();
     $image->load($file['tmp_name'], $file['name']);
     // Detect if this is a really valid image file.
     if (!$image->isValid()) {
         return false;
     }
     // Bind the photo data now
     $photo = FD::table('Photo');
     $photo->uid = $uid;
     $photo->type = $type;
     $photo->user_id = $album->uid;
     $photo->album_id = $album->id;
     $photo->title = $file['name'];
     $photo->caption = '';
     $photo->ordering = 0;
     $photo->state = SOCIAL_STATE_PUBLISHED;
     // Set the creation date alias
     $photo->assigned_date = FD::date()->toMySQL();
     // Cleanup photo title.
     $photo->cleanupTitle();
     // Trigger rules that should occur before a photo is stored
     $photo->beforeStore($file, $image);
     // Try to store the photo.
     $state = $photo->store();
     if (!$state) {
         return false;
     }
     // If album doesn't have a cover, set the current photo as the cover.
     //~ if (!$album->hasCover()) {
     //~ $album->cover_id    = $photo->id;
     //~
     //~ // Store the album
     //~ $album->store();
     //~ }
     // Get the photos library
     $photoLib = FD::get('Photos', $image);
     // Get the storage path for this photo
     $storageContainer = FD::cleanPath($config->get('photos.storage.container'));
     $storage = $photoLib->getStoragePath($album->id, $photo->id);
     $paths = $photoLib->create($storage);
     // We need to calculate the total size used in each photo (including all the variants)
     $totalSize = 0;
     // Create metadata about the photos
     if ($paths) {
         foreach ($paths as $type => $fileName) {
             $meta = FD::table('PhotoMeta');
             $meta->photo_id = $photo->id;
             $meta->group = SOCIAL_PHOTOS_META_PATH;
             $meta->property = $type;
             // do not store the container path as this path might changed from time to time
             $tmpStorage = str_replace('/' . $storageContainer . '/', '/', $storage);
             $meta->value = $tmpStorage . '/' . $fileName;
             $meta->store();
             // We need to store the photos dimension here
             list($width, $height, $imageType, $attr) = getimagesize(JPATH_ROOT . $storage . '/' . $fileName);
             // Set the photo size
             $totalSize += filesize(JPATH_ROOT . $storage . '/' . $fileName);
             // Set the photo dimensions
             $meta = FD::table('PhotoMeta');
             $meta->photo_id = $photo->id;
             $meta->group = SOCIAL_PHOTOS_META_WIDTH;
             $meta->property = $type;
             $meta->value = $width;
             $meta->store();
             $meta = FD::table('PhotoMeta');
             $meta->photo_id = $photo->id;
             $meta->group = SOCIAL_PHOTOS_META_HEIGHT;
             $meta->property = $type;
             $meta->value = $height;
             $meta->store();
         }
     }
     // Set the total photo size
     $photo->total_size = $totalSize;
//.........这里部分代码省略.........
开发者ID:yalive,项目名称:com_api-plugins,代码行数:101,代码来源:uploadHelper.php

示例10: download

 /**
  * Allows use to download a photo from the site.
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function download()
 {
     // Check if photos is enabled
     $this->checkFeature();
     // Load up info object
     $info = FD::info();
     // Get the id of the photo
     $id = JRequest::getInt('id');
     $photo = FD::table('Photo');
     $photo->load($id);
     // Id provided must be valid
     if (!$id || !$photo->id) {
         $this->setMessage(JText::_('COM_EASYSOCIAL_PHOTOS_INVALID_PHOTO_ID_PROVIDED'), SOCIAL_MSG_ERROR);
         $info->set($this->getMessage());
         return $this->redirect(FRoute::albums(array(), false));
     }
     // Load up photo library
     $lib = FD::photo($photo->uid, $photo->type, $photo);
     if (!$lib->downloadable()) {
         return $this->restricted($lib);
     }
     // Let's try to download the file now
     $photo->download();
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:32,代码来源:view.html.php

示例11: remove

 /**
  * Allows caller to remove a photo
  *
  * @since	1.2
  * @access	public
  */
 public function remove()
 {
     // Check for request forgeries
     FD::checkToken();
     // Only logged in users allowed
     FD::requireLogin();
     // Get the current view
     $view = $this->getCurrentView();
     $uid = JRequest::getInt('uid');
     $type = JRequest::getCmd('type');
     if (!$uid && !$type) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_PHOTOS_INVALID_ID_PROVIDED'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Get the cover object
     $cover = FD::table('Cover');
     $state = $cover->load(array('uid' => $uid, 'type' => $type));
     if (!$state) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_PHOTOS_INVALID_ID_PROVIDED'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Load up the photo library
     $lib = FD::photo($uid, $type, $cover->photo_id);
     if (!$lib->canDeleteCover()) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_PHOTOS_NO_PERMISSION_TO_DELETE_COVER'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Delete the cover.
     $cover->delete();
     return $view->call(__FUNCTION__);
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:37,代码来源:cover.php

示例12: loadMore

 /**
  * Method to allow caller to load more photos in an album.
  *
  * @since	1.2.11
  * @access	public
  * @param	string
  * @return
  */
 public function loadMore($photos = array(), $nextStart = 0)
 {
     $ajax = FD::ajax();
     if ($this->hasErrors()) {
         return $ajax->reject($this->getMessage());
     }
     // Get the current logged in user.
     $my = FD::user();
     // Get layout
     $layout = JRequest::getCmd('layout', 'item');
     $options = array('viewer' => $my->id, 'layout' => $layout, 'showResponse' => false, 'showTags' => false);
     if ($layout == "dialog") {
         $options['showForm'] = false;
         $options['showInfo'] = false;
         $options['showStats'] = false;
         $options['showToolbar'] = false;
     }
     $htmls = array();
     foreach ($photos as $photo) {
         $lib = FD::photo($photo->uid, $photo->type, $photo);
         $htmls[] = $lib->renderItem($options);
     }
     return $ajax->resolve($htmls, $nextStart);
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:32,代码来源:view.ajax.php

示例13: upload

 /**
  * Post process after the photo is uploaded on the site
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function upload($photo = null, $paths = array())
 {
     $json = FD::json();
     // If there was an error uploading the photo, throw proper error message
     if ($this->hasErrors()) {
         $json->send($this->getMessage());
     }
     // Get the current logged in user
     $my = FD::user();
     // Get the layout to display
     $layout = JRequest::getCmd('layout', 'item');
     $options = array('viewer' => $my->id, 'layout' => $layout, 'showResponse' => false, 'showTags' => false);
     // Load up the photo library
     $lib = FD::photo($photo->uid, $photo->type, $photo);
     $output = $lib->renderItem($options);
     $response = new stdClass();
     $response->data = $photo->export();
     $response->html = $output;
     $json->send($response);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:28,代码来源:view.json.php


注:本文中的FD::photo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。