fixup default avatar urls by using common function

darcs-hash:20080521155448-84dde-0e71fe5dccea49162911f80c65cd1e2a46043b14.gz
This commit is contained in:
Evan Prodromou 2008-05-21 11:54:48 -04:00
parent 12a58d87e8
commit 9933e1e341
6 changed files with 17 additions and 11 deletions

View File

@ -174,7 +174,7 @@ class ShowstreamAction extends StreamAction {
'href' => $subs->profileurl, 'href' => $subs->profileurl,
'class' => 'subscription')); 'class' => 'subscription'));
$avatar = $subs->getAvatar(AVATAR_MINI_SIZE); $avatar = $subs->getAvatar(AVATAR_MINI_SIZE);
common_element('img', array('src' => (($avatar) ? $avatar->url : $config['avatar']['default']['mini']), common_element('img', array('src' => (($avatar) ? $avatar->url : common_default_avatar(AVATAR_MINI_SIZE),
'width' => AVATAR_MINI_SIZE, 'width' => AVATAR_MINI_SIZE,
'height' => AVATAR_MINI_SIZE, 'height' => AVATAR_MINI_SIZE,
'class' => 'avatar mini', 'class' => 'avatar mini',

View File

@ -69,7 +69,7 @@ class SubscribedAction extends Action {
'href' => $subs->profileurl, 'href' => $subs->profileurl,
'class' => 'subscription')); 'class' => 'subscription'));
$avatar = $subs->getAvatar(AVATAR_STREAM_SIZE); $avatar = $subs->getAvatar(AVATAR_STREAM_SIZE);
common_element('img', array('src' => (($avatar) ? $avatar->url : $config['avatar']['default']['stream']), common_element('img', array('src' => (($avatar) ? $avatar->url : common_default_avatar(AVATAR_STREAM_SIZE)),
'width' => AVATAR_STREAM_SIZE, 'width' => AVATAR_STREAM_SIZE,
'height' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE,
'class' => 'avatar stream', 'class' => 'avatar stream',

View File

@ -68,7 +68,7 @@ class SubscriptionsAction extends Action {
common_element('img', common_element('img',
array('src' => array('src' =>
(($avatar) ? $avatar->url : (($avatar) ? $avatar->url :
$config['avatar']['default']['stream']), common_default_avatar(AVATAR_STREAM_SIZE)),
'width' => AVATAR_STREAM_SIZE, 'width' => AVATAR_STREAM_SIZE,
'height' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE,
'class' => 'avatar stream', 'class' => 'avatar stream',

View File

@ -45,13 +45,11 @@ $config =
'image' => 'http://i.creativecommons.org/l/by/3.0/88x31.png'), 'image' => 'http://i.creativecommons.org/l/by/3.0/88x31.png'),
'avatar' => 'avatar' =>
array('directory' => INSTALLDIR . '/avatar', array('directory' => INSTALLDIR . '/avatar',
'path' => '/avatar')); 'path' => '/avatar',
'default' =>
# these depend on defaults above array('profile' => 'theme/default/image/default-avatar-profile.png',
$config['avatar']['default'] = 'stream' => 'theme/default/image/default-avatar-stream.png',
array('profile' => "http://".$config['site']['server'].$config['site']['path'].'/'.'theme/default/image/default-avatar-profile.png', 'mini' => 'theme/default/image/default-avatar-mini.png')));
'stream' => "http://".$config['site']['server'].$config['site']['path'].'/'.'theme/default/image/default-avatar-stream.png',
'mini' => "http://".$config['site']['server'].$config['site']['path'].'/'.'theme/default/image/default-avatar-mini.png');
$config['db'] = &PEAR::getStaticProperty('DB_DataObject','options'); $config['db'] = &PEAR::getStaticProperty('DB_DataObject','options');

View File

@ -35,7 +35,7 @@ class StreamAction extends Action {
'id' => 'notice-' . $notice->id)); 'id' => 'notice-' . $notice->id));
$avatar = $profile->getAvatar(AVATAR_STREAM_SIZE); $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
common_element_start('a', array('href' => $profile->profileurl)); common_element_start('a', array('href' => $profile->profileurl));
common_element('img', array('src' => ($avatar) ? $avatar->url : $config['avatar']['default']['stream'], common_element('img', array('src' => ($avatar) ? $avatar->url : common_default_avatar(AVATAR_STREAM_SIZE),
'class' => 'avatar stream', 'class' => 'avatar stream',
'width' => AVATAR_STREAM_SIZE, 'width' => AVATAR_STREAM_SIZE,
'height' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE,

View File

@ -368,6 +368,14 @@ function common_avatar_url($filename) {
return "http://".$config['site']['server'].$config['avatar']['path'].'/'.$filename; return "http://".$config['site']['server'].$config['avatar']['path'].'/'.$filename;
} }
function common_default_avatar($size) {
static $sizenames = array(AVATAR_PROFILE_SIZE => 'profile',
AVATAR_STREAM_SIZE => 'stream',
AVATAR_MINI_SIZE => 'mini');
global $config;
return "http://".$config['site']['server'].$config['avatar']['path'].'/'.$config['avatar']['default'][$sizenames[$size]];
}
function common_local_url($action, $args=NULL) { function common_local_url($action, $args=NULL) {
global $config; global $config;
/* XXX: pretty URLs */ /* XXX: pretty URLs */