本文整理汇总了PHP中CUrlHelper::avatarURI方法的典型用法代码示例。如果您正苦于以下问题:PHP CUrlHelper::avatarURI方法的具体用法?PHP CUrlHelper::avatarURI怎么用?PHP CUrlHelper::avatarURI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUrlHelper
的用法示例。
在下文中一共展示了CUrlHelper::avatarURI方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLargeAvatar
/**
* Get large avatar use for cropping
* @return string
*/
public function getLargeAvatar()
{
$config = CFactory::getConfig();
$largeAvatar = $config->getString('imagefolder') . '/avatar/profile-' . JFile::getName($this->avatar);
if (JFile::exists(JPATH_ROOT . '/' . $largeAvatar)) {
return CUrlHelper::avatarURI($largeAvatar) . '?' . md5(time());
/* adding random param to prevent browser caching */
} else {
return $this->getAvatar();
}
}
示例2: getAvatar
public function getAvatar()
{
// Get the avatar path. Some maintance/cleaning work: We no longer store
// the default avatar in db. If the default avatar is found, we reset it
// to empty. In next release, we'll rewrite this portion accordingly.
// We allow the default avatar to be template specific.
if ($this->avatar == 'components/com_community/assets/user.png') {
$this->avatar = '';
$this->store();
}
CFactory::load('helpers', 'url');
$avatar = CUrlHelper::avatarURI($this->avatar, 'user.png');
return $avatar;
}
示例3: getAvatar
public function getAvatar()
{
// Get the avatar path. Some maintance/cleaning work: We no longer store
// the default avatar in db. If the default avatar is found, we reset it
// to empty. In next release, we'll rewrite this portion accordingly.
// We allow the default avatar to be template specific.
$profileModel = CFactory::getModel('Profile');
$gender = $profileModel->getGender($this->userid);
if (empty($gender)) {
$gender = 'Male';
}
if ($this->avatar == 'components/com_community/assets/user-' . JText::_($gender) . '.png') {
$this->avatar = '';
$this->store();
}
$avatar = CUrlHelper::avatarURI($this->avatar, 'user-' . JText::_($gender) . '.png');
return $avatar;
}
示例4: changeAvatar
//.........这里部分代码省略.........
/**
* Generate activity stream
* @todo Should we use CApiActivities::add
*/
// do not have to generate a stream if the user is not the user itself (eg admin change user avatar)
if (CUserPoints::assignPoint('profile.avatar.upload') && $my->id == CFactory::getUser()->id) {
$act = new stdClass();
$act->cmd = 'profile.avatar.upload';
$act->actor = $userid;
$act->target = 0;
$act->title = '';
$act->content = '';
$act->access = $my->_cparams->get("privacyPhotoView", 0);
$act->app = 'profile.avatar.upload';
/* Profile app */
$act->cid = isset($photo->id) && $photo->id ? $photo->id : 0;
$act->verb = 'upload';
/* We uploaded new avatar - NOT change avatar */
$act->params = $params;
$params->set('photo_id', $photo->id);
$params->set('album_id', $photo->albumid);
$act->comment_id = CActivities::COMMENT_SELF;
$act->comment_type = 'profile.avatar.upload';
$act->like_id = CActivities::LIKE_SELF;
$act->like_type = 'profile.avatar.upload';
}
break;
case 'group':
CUserPoints::assignPoint('group.avatar.upload');
/**
* Generate activity stream
* @todo Should we use CApiActivities::add
*/
$act = new stdClass();
$act->cmd = 'groups.avatar.upload';
$act->actor = $userid;
$act->target = 0;
$act->title = '';
$act->content = '';
$act->app = 'groups.avatar.upload';
/* Groups app */
$act->cid = $id;
$act->groupid = $id;
$act->verb = 'update';
/* We do update */
$params->set('photo_id', $photo->id);
$params->set('album_id', $photo->albumid);
$act->comment_id = CActivities::COMMENT_SELF;
$act->comment_type = 'groups.avatar.upload';
$act->like_id = CActivities::LIKE_SELF;
$act->like_type = 'groups.avatar.upload';
break;
case 'event':
//CUserPoints::assignPoint('events.avatar.upload'); @disabled since 4.0
/**
* Generate activity stream
* @todo Should we use CApiActivities::add
*/
$act = new stdClass();
$act->cmd = 'events.avatar.upload';
$act->actor = $userid;
$act->target = 0;
$act->title = '';
$act->content = '';
$act->app = 'events.avatar.upload';
/* Events app */
$act->cid = $id;
$act->eventid = $id;
$act->verb = 'update';
/* We do update */
$act->comment_id = CActivities::COMMENT_SELF;
$act->comment_type = 'events.avatar.upload';
$act->like_id = CActivities::LIKE_SELF;
$act->like_type = 'events.avatar.upload';
break;
}
//we only generate stream if the uploader is the user himself, not admin or anyone else
if (isset($act) && $my->id == $id || $type != 'profile') {
// $return = CApiActivities::add($act);
/**
* use internal Stream instead use for 3rd part API
*/
$return = CActivityStream::add($act, $params->toString());
//add the reference to the activity so that we can do something when someone update the avatar
if ($type == 'profile') {
// overwrite the params because some of the param might be updated through $my object above
$cTableParams = $my->_cparams;
} else {
$cTableParams = new JRegistry($cTable->params);
}
$cTableParams->set('avatar_activity_id', $return->id);
$cTable->params = $cTableParams->toString();
$cTable->store();
}
if (method_exists($cTable, 'getLargeAvatar')) {
$this->_showUploadError(false, $cTable->getLargeAvatar(), CUrlHelper::avatarURI($thumbnail, 'user_thumb.png'));
} else {
$this->_showUploadError(false, $cTable->getAvatar(), CUrlHelper::avatarURI($thumbnail, 'user_thumb.png'));
}
}
示例5: getThumbAvatar
/**
* @deprecated Since 2.0
*/
public function getThumbAvatar($id, $thumb)
{
$thumb = CUrlHelper::avatarURI($thumb, 'event_thumb.png');
return $thumb;
}
示例6: getThumbAvatar
/**
* Return full uri path of the thumbnail
*/
public function getThumbAvatar()
{
if ($this->thumb == 'components/com_community/assets/event_thumb.png') {
$this->thumb = '';
$this->store();
}
CFactory::load('helpers', 'url');
$thumb = CUrlHelper::avatarURI($this->thumb, 'event_thumb.png');
return $thumb;
}
示例7: getThumbAvatar
public function getThumbAvatar()
{
if ($this->thumb == 'components/com_community/assets/group_thumb.jpg') {
$this->thumb = '';
$this->store();
}
// For group avatars that are stored in a remote location, we should return the proper path.
if ($this->storage != 'file' && !empty($this->thumb)) {
$storage = CStorage::getStorage($this->storage);
return $storage->getURI($this->thumb);
}
$thumb = CUrlHelper::avatarURI($this->thumb, 'group_thumb.png');
return $thumb;
}
示例8: getThumbAvatar
/**
* @deprecated Since 2.0
*/
function getThumbAvatar($id, $thumb)
{
CFactory::load('helpers', 'url');
$thumb = CUrlHelper::avatarURI($thumb, 'event_thumb.png');
return $thumb;
}
示例9: getThumbAvatar
/**
* Return path to thumb image
*/
public function getThumbAvatar()
{
// @rule: Check if the current user's watermark matches the current system's watermark.
$multiprofile =& JTable::getInstance('MultiProfile', 'CTable');
$match = $multiprofile->isHashMatched($this->_profile_id, $this->_watermark_hash);
if (!$match) {
// @rule: Since the admin may have changed the watermark for the specific user profile type, we need to also update
// the user's watermark as well.
CFactory::load('helpers', 'image');
$hashName = CImageHelper::getHashName($this->id . time());
$multiprofile->updateUserAvatar($this, $hashName);
$multiprofile->updateUserThumb($this, $hashName);
}
if (JString::stristr($this->_thumb, 'default_thumb.jpg')) {
$this->_thumb = '';
}
// For user avatars that are stored in a remote location, we should return the proper path.
// @rule: For default avatars and watermark avatars we don't want to alter the url behavior.
// as it should be stored locally.
if ($this->_storage != 'file' && !empty($this->_thumb) && JString::stristr($this->_thumb, 'images/watermarks') === false) {
$storage = CStorage::getStorage($this->_storage);
return $storage->getURI($this->_thumb);
}
CFactory::load('helpers', 'url');
$thumb = CUrlHelper::avatarURI($this->_thumb, 'user_thumb.png');
return $thumb;
}
示例10: getThumbAvatar
public function getThumbAvatar($obj)
{
// For group avatars that are stored in a remote location, we should return the proper path.
if ($obj->storage != 'file' && !empty($obj->thumb)) {
$storage = CStorage::getStorage($obj->storage);
return $storage->getURI($obj->thumb);
}
$thumb = CUrlHelper::avatarURI($obj->thumb, 'group_thumb.png');
return $thumb;
}
示例11: changeAvatar
public function changeAvatar()
{
$objResponse = new JAXResponse();
$type = JRequest::getVar('type');
$id = JRequest::getVar('id');
$filter = JFilterInput::getInstance();
$type = $filter->clean($type, 'string');
$id = $filter->clean($id, 'integer');
$cTable =& JTable::getInstance(ucfirst($type), 'CTable');
$cTable->load($id);
$my = CFactory::getUser();
$config = CFactory::getConfig();
CFactory::load('helpers', 'image');
$file = JRequest::getVar('filedata', '', 'FILES', 'array');
//check if file is allwoed
if (!CImageHelper::isValidType($file['type'])) {
$this->_showUploadError(true, JText::_('COM_COMMUNITY_IMAGE_FILE_NOT_SUPPORTED'));
return;
}
//check upload file size
$uploadlimit = (double) $config->get('maxuploadsize');
$uploadlimit = $uploadlimit * 1024 * 1024;
if (filesize($file['tmp_name']) > $uploadlimit && $uploadlimit != 0) {
$this->_showUploadError(true, JText::_('COM_COMMUNITY_VIDEOS_IMAGE_FILE_SIZE_EXCEEDED'));
return;
}
//start image processing
$imageMaxWidth = 160;
// Get a hash for the file name.
$fileName = JUtility::getHash($file['tmp_name'] . time());
$hashFileName = JString::substr($fileName, 0, 24);
$avatarFolder = $type != 'profile' && $type != '' ? $type . DS : '';
//avatar store path
$storage = JPATH_ROOT . DS . $config->getString('imagefolder') . DS . 'avatar' . DS . $avatarFolder;
$storageImage = $storage . DS . $hashFileName . CImageHelper::getExtension($file['type']);
$image = $config->getString('imagefolder') . '/avatar/' . $avatarFolder . $hashFileName . CImageHelper::getExtension($file['type']);
//avatar thumbnail path
$storageThumbnail = $storage . DS . 'thumb_' . $hashFileName . CImageHelper::getExtension($file['type']);
$thumbnail = $config->getString('imagefolder') . '/avatar/' . $avatarFolder . 'thumb_' . $hashFileName . CImageHelper::getExtension($file['type']);
// Generate full image
if (!CImageHelper::resizeProportional($file['tmp_name'], $storageImage, $file['type'], $imageMaxWidth)) {
$this->_showUploadError(true, JText::sprintf('COM_COMMUNITY_ERROR_MOVING_UPLOADED_FILE', $storageImage));
return;
}
// Generate thumbnail
if (!CImageHelper::createThumb($file['tmp_name'], $storageThumbnail, $file['type'])) {
$this->_showUploadError(true, JText::sprintf('COM_COMMUNITY_ERROR_MOVING_UPLOADED_FILE', $storageImage));
return;
}
$cTable->setImage($image, 'avatar');
$cTable->setImage($thumbnail, 'thumb');
$this->_showUploadError(false, $cTable->getAvatar(), CUrlHelper::avatarURI($thumbnail, 'user_thumb.png'));
}
示例12: getThumbAvatar
/**
* Return path to thumb image
*/
public function getThumbAvatar()
{
// @rule: Check if the current user's watermark matches the current system's watermark.
$multiprofile = JTable::getInstance('MultiProfile', 'CTable');
$match = $multiprofile->isHashMatched($this->_profile_id, $this->_watermark_hash);
if (!$match) {
// @rule: Since the admin may have changed the watermark for the specific user profile type, we need to also update
// the user's watermark as well.
//CFactory::load( 'helpers' , 'image' );
$hashName = CImageHelper::getHashName($this->id . time());
$multiprofile->updateUserAvatar($this, $hashName);
$multiprofile->updateUserThumb($this, $hashName);
}
if (JString::stristr($this->_thumb, 'default_thumb.jpg')) {
$this->_thumb = '';
}
// For user avatars that are stored in a remote location, we should return the proper path.
// @rule: For default avatars and watermark avatars we don't want to alter the url behavior.
// as it should be stored locally.
if ($this->_storage != 'file' && !empty($this->_thumb) && JString::stristr($this->_thumb, 'images/watermarks') === false) {
$storage = CStorage::getStorage($this->_storage);
return $storage->getURI($this->_thumb);
}
if ($this->_thumb && file_exists(JPATH_ROOT . '/' . $this->_thumb)) {
return JUri::root() . $this->_thumb;
}
$gender = $this->_getGender('male');
if (!strlen($gender)) {
$gender = 'undefined';
}
$td_path = "default-{$gender}-avatar";
if (file_exists(COMMUNITY_PATH_ASSETS . $td_path . '.png')) {
return JUri::root() . str_replace(JPATH_ROOT, '', COMMUNITY_PATH_ASSETS) . "{$td_path}.png";
}
if (file_exists(COMMUNITY_PATH_ASSETS . $td_path . '.jpg')) {
return JUri::root() . str_replace(JPATH_ROOT, '', COMMUNITY_PATH_ASSETS) . "{$td_path}.jpg";
}
if ($gender == 'undefined') {
$gender = 'male';
}
$thumb = CUrlHelper::avatarURI($this->_thumb, 'user-' . ucfirst($gender) . '-thumb.png');
return $thumb;
}