forked from GNUsocial/gnu-social
Move common_avatar_* functions to Avatar
Moved the common_avatar_* functions to the Avatar class. Typically either as methods on the object or as static methods. Replaced all the uses of the functions in other modules.
This commit is contained in:
parent
d3ff8bfec6
commit
343cd6f205
@ -90,9 +90,9 @@ class AvatarbynicknameAction extends Action
|
||||
$url = $avatar->url;
|
||||
} else {
|
||||
if ($size == 'original') {
|
||||
$url = common_default_avatar(AVATAR_PROFILE_SIZE);
|
||||
$url = Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
||||
} else {
|
||||
$url = common_default_avatar($size+0);
|
||||
$url = Avatar::defaultImage($size+0);
|
||||
}
|
||||
}
|
||||
common_redirect($url, 302);
|
||||
|
@ -200,7 +200,7 @@ class AvatarsettingsAction extends AccountSettingsAction
|
||||
'class' => 'avatar_view'));
|
||||
$this->element('h2', null, _("Original"));
|
||||
$this->elementStart('div', array('id'=>'avatar_original_view'));
|
||||
$this->element('img', array('src' => common_avatar_url($this->filedata['filename']),
|
||||
$this->element('img', array('src' => Avatar::url($this->filedata['filename']),
|
||||
'width' => $this->filedata['width'],
|
||||
'height' => $this->filedata['height'],
|
||||
'alt' => $user->nickname));
|
||||
@ -212,7 +212,7 @@ class AvatarsettingsAction extends AccountSettingsAction
|
||||
'class' => 'avatar_view'));
|
||||
$this->element('h2', null, _("Preview"));
|
||||
$this->elementStart('div', array('id'=>'avatar_preview_view'));
|
||||
$this->element('img', array('src' => common_avatar_url($this->filedata['filename']),
|
||||
$this->element('img', array('src' => Avatar::url($this->filedata['filename']),
|
||||
'width' => AVATAR_PROFILE_SIZE,
|
||||
'height' => AVATAR_PROFILE_SIZE,
|
||||
'alt' => $user->nickname));
|
||||
@ -281,12 +281,12 @@ class AvatarsettingsAction extends AccountSettingsAction
|
||||
|
||||
$cur = common_current_user();
|
||||
|
||||
$filename = common_avatar_filename($cur->id,
|
||||
$filename = Avatar::filename($cur->id,
|
||||
image_type_to_extension($imagefile->type),
|
||||
null,
|
||||
'tmp'.common_timestamp());
|
||||
|
||||
$filepath = common_avatar_path($filename);
|
||||
$filepath = Avatar::path($filename);
|
||||
|
||||
move_uploaded_file($imagefile->filepath, $filepath);
|
||||
|
||||
|
@ -263,7 +263,7 @@ class GrouplogoAction extends Action
|
||||
'class' => 'avatar_view'));
|
||||
$this->element('h2', null, _("Original"));
|
||||
$this->elementStart('div', array('id'=>'avatar_original_view'));
|
||||
$this->element('img', array('src' => common_avatar_url($this->filedata['filename']),
|
||||
$this->element('img', array('src' => Avatar::url($this->filedata['filename']),
|
||||
'width' => $this->filedata['width'],
|
||||
'height' => $this->filedata['height'],
|
||||
'alt' => $this->group->nickname));
|
||||
@ -275,7 +275,7 @@ class GrouplogoAction extends Action
|
||||
'class' => 'avatar_view'));
|
||||
$this->element('h2', null, _("Preview"));
|
||||
$this->elementStart('div', array('id'=>'avatar_preview_view'));
|
||||
$this->element('img', array('src' => common_avatar_url($this->filedata['filename']),
|
||||
$this->element('img', array('src' => Avatar::url($this->filedata['filename']),
|
||||
'width' => AVATAR_PROFILE_SIZE,
|
||||
'height' => AVATAR_PROFILE_SIZE,
|
||||
'alt' => $this->group->nickname));
|
||||
@ -343,12 +343,12 @@ class GrouplogoAction extends Action
|
||||
return;
|
||||
}
|
||||
|
||||
$filename = common_avatar_filename($this->group->id,
|
||||
$filename = Avatar::filename($this->group->id,
|
||||
image_type_to_extension($imagefile->type),
|
||||
null,
|
||||
'group-temp-'.common_timestamp());
|
||||
|
||||
$filepath = common_avatar_path($filename);
|
||||
$filepath = Avatar::path($filename);
|
||||
|
||||
move_uploaded_file($imagefile->filepath, $filepath);
|
||||
|
||||
|
@ -166,7 +166,7 @@ class NoticesearchAction extends SearchAction
|
||||
$avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
|
||||
$this->elementStart('a', array('href' => $profile->profileurl,
|
||||
'class' => 'url'));
|
||||
$this->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE),
|
||||
$this->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE),
|
||||
'class' => 'avatar photo',
|
||||
'width' => AVATAR_STREAM_SIZE,
|
||||
'height' => AVATAR_STREAM_SIZE,
|
||||
|
@ -242,7 +242,7 @@ class ShowstreamAction extends Action
|
||||
$this->elementStart('dl', 'entity_depiction');
|
||||
$this->element('dt', null, _('Photo'));
|
||||
$this->elementStart('dd');
|
||||
$this->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_PROFILE_SIZE),
|
||||
$this->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE),
|
||||
'class' => 'photo avatar',
|
||||
'width' => AVATAR_PROFILE_SIZE,
|
||||
'height' => AVATAR_PROFILE_SIZE,
|
||||
|
@ -80,7 +80,7 @@ class TagotherAction extends Action
|
||||
$this->elementStart('dl', 'entity_depiction');
|
||||
$this->element('dt', null, _('Photo'));
|
||||
$this->elementStart('dd');
|
||||
$this->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_PROFILE_SIZE),
|
||||
$this->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE),
|
||||
'class' => 'photo avatar',
|
||||
'width' => AVATAR_PROFILE_SIZE,
|
||||
'height' => AVATAR_PROFILE_SIZE,
|
||||
|
@ -250,8 +250,8 @@ class TwittersettingsAction extends ConnectSettingsAction
|
||||
$avatar = $other->getAvatar(AVATAR_MINI_SIZE);
|
||||
|
||||
$avatar_url = ($avatar) ?
|
||||
common_avatar_display_url($avatar) :
|
||||
common_default_avatar(AVATAR_MINI_SIZE);
|
||||
$avatar->displayUrl() :
|
||||
Avatar::defaultImage(AVATAR_MINI_SIZE);
|
||||
|
||||
$this->element('img', array('src' => $avatar_url,
|
||||
'width' => AVATAR_MINI_SIZE,
|
||||
|
@ -4,18 +4,18 @@
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Avatar extends Memcached_DataObject
|
||||
class Avatar extends Memcached_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
/* the code below is auto generated do not remove the above tag */
|
||||
|
||||
public $__table = 'avatar'; // table name
|
||||
public $profile_id; // int(4) primary_key not_null
|
||||
public $original; // tinyint(1)
|
||||
public $original; // tinyint(1)
|
||||
public $width; // int(4) primary_key not_null
|
||||
public $height; // int(4) primary_key not_null
|
||||
public $mediatype; // varchar(32) not_null
|
||||
public $filename; // varchar(255)
|
||||
public $filename; // varchar(255)
|
||||
public $url; // varchar(255) unique_key
|
||||
public $created; // datetime() not_null
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
@ -33,13 +33,51 @@ class Avatar extends Memcached_DataObject
|
||||
{
|
||||
$filename = $this->filename;
|
||||
if (parent::delete()) {
|
||||
@unlink(common_avatar_path($filename));
|
||||
@unlink(Avatar::path($filename));
|
||||
}
|
||||
}
|
||||
|
||||
function &pkeyGet($kv)
|
||||
|
||||
function &pkeyGet($kv)
|
||||
{
|
||||
return Memcached_DataObject::pkeyGet('Avatar', $kv);
|
||||
}
|
||||
|
||||
// where should the avatar go for this user?
|
||||
|
||||
static function filename($id, $extension, $size=null, $extra=null)
|
||||
{
|
||||
if ($size) {
|
||||
return $id . '-' . $size . (($extra) ? ('-' . $extra) : '') . $extension;
|
||||
} else {
|
||||
return $id . '-original' . (($extra) ? ('-' . $extra) : '') . $extension;
|
||||
}
|
||||
}
|
||||
|
||||
static function path($filename)
|
||||
{
|
||||
return INSTALLDIR . '/avatar/' . $filename;
|
||||
}
|
||||
|
||||
static function url($filename)
|
||||
{
|
||||
return common_path('avatar/'.$filename);
|
||||
}
|
||||
|
||||
function displayUrl()
|
||||
{
|
||||
$server = common_config('avatar', 'server');
|
||||
if ($server) {
|
||||
return 'http://'.$server.'/'.$this->filename;
|
||||
} else {
|
||||
return $this->url;
|
||||
}
|
||||
}
|
||||
|
||||
static function defaultAvatar($size)
|
||||
{
|
||||
static $sizenames = array(AVATAR_PROFILE_SIZE => 'profile',
|
||||
AVATAR_STREAM_SIZE => 'stream',
|
||||
AVATAR_MINI_SIZE => 'mini');
|
||||
return theme_path('default-avatar-'.$sizenames[$size].'.png');
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ class Profile extends Memcached_DataObject
|
||||
|
||||
function setOriginal($filename)
|
||||
{
|
||||
$imagefile = new ImageFile($this->id, common_avatar_path($filename));
|
||||
$imagefile = new ImageFile($this->id, Avatar::path($filename));
|
||||
|
||||
$avatar = new Avatar();
|
||||
$avatar->profile_id = $this->id;
|
||||
@ -80,22 +80,22 @@ class Profile extends Memcached_DataObject
|
||||
$avatar->mediatype = image_type_to_mime_type($imagefile->type);
|
||||
$avatar->filename = $filename;
|
||||
$avatar->original = true;
|
||||
$avatar->url = common_avatar_url($filename);
|
||||
$avatar->url = Avatar::url($filename);
|
||||
$avatar->created = DB_DataObject_Cast::dateTime(); # current time
|
||||
|
||||
# XXX: start a transaction here
|
||||
|
||||
if (!$this->delete_avatars() || !$avatar->insert()) {
|
||||
@unlink(common_avatar_path($filename));
|
||||
@unlink(Avatar::path($filename));
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
|
||||
# We don't do a scaled one if original is our scaled size
|
||||
if (!($avatar->width == $size && $avatar->height == $size)) {
|
||||
|
||||
|
||||
$scaled_filename = $imagefile->resize($size);
|
||||
|
||||
|
||||
//$scaled = DB_DataObject::factory('avatar');
|
||||
$scaled = new Avatar();
|
||||
$scaled->profile_id = $this->id;
|
||||
@ -104,7 +104,7 @@ class Profile extends Memcached_DataObject
|
||||
$scaled->original = false;
|
||||
$scaled->mediatype = image_type_to_mime_type($imagefile->type);
|
||||
$scaled->filename = $scaled_filename;
|
||||
$scaled->url = common_avatar_url($scaled_filename);
|
||||
$scaled->url = Avatar::url($scaled_filename);
|
||||
$scaled->created = DB_DataObject_Cast::dateTime(); # current time
|
||||
|
||||
if (!$scaled->insert()) {
|
||||
@ -194,4 +194,13 @@ class Profile extends Memcached_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
function avatarUrl($size=AVATAR_PROFILE_SIZE)
|
||||
{
|
||||
$avatar = $this->getAvatar($size);
|
||||
if ($avatar) {
|
||||
return $avatar->displayUrl();
|
||||
} else {
|
||||
return Avatar::defaultImage($size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,13 +90,13 @@ class User_group extends Memcached_DataObject
|
||||
|
||||
function setOriginal($filename)
|
||||
{
|
||||
$imagefile = new ImageFile($this->id, common_avatar_path($filename));
|
||||
$imagefile = new ImageFile($this->id, Avatar::path($filename));
|
||||
|
||||
$orig = clone($this);
|
||||
$this->original_logo = common_avatar_url($filename);
|
||||
$this->homepage_logo = common_avatar_url($imagefile->resize(AVATAR_PROFILE_SIZE));
|
||||
$this->stream_logo = common_avatar_url($imagefile->resize(AVATAR_STREAM_SIZE));
|
||||
$this->mini_logo = common_avatar_url($imagefile->resize(AVATAR_MINI_SIZE));
|
||||
$this->original_logo = Avatar::url($filename);
|
||||
$this->homepage_logo = Avatar::url($imagefile->resize(AVATAR_PROFILE_SIZE));
|
||||
$this->stream_logo = Avatar::url($imagefile->resize(AVATAR_STREAM_SIZE));
|
||||
$this->mini_logo = Avatar::url($imagefile->resize(AVATAR_MINI_SIZE));
|
||||
common_debug(common_log_objstring($this));
|
||||
return $this->update($orig);
|
||||
}
|
||||
|
@ -153,12 +153,12 @@ class ImageFile
|
||||
|
||||
imagecopyresampled($image_dest, $image_src, 0, 0, $x, $y, $size, $size, $w, $h);
|
||||
|
||||
$outname = common_avatar_filename($this->id,
|
||||
$outname = Avatar::filename($this->id,
|
||||
image_type_to_extension($this->type),
|
||||
$size,
|
||||
common_timestamp());
|
||||
|
||||
$outpath = common_avatar_path($outname);
|
||||
$outpath = Avatar::path($outname);
|
||||
|
||||
switch ($this->type) {
|
||||
case IMAGETYPE_GIF:
|
||||
|
@ -178,7 +178,7 @@ function jabber_format_entry($profile, $notice)
|
||||
$entry .= "<link href='" . htmlspecialchars($profile->profileurl) . "'/>\n";
|
||||
$entry .= "<link rel='self' type='application/rss+xml' href='" . $self_url . "'/>\n";
|
||||
$entry .= "<author><name>" . $profile->nickname . "</name></author>\n";
|
||||
$entry .= "<icon>" . common_profile_avatar_url($profile, AVATAR_PROFILE_SIZE) . "</icon>\n";
|
||||
$entry .= "<icon>" . $profile->avatarUrl(AVATAR_PROFILE_SIZE) . "</icon>\n";
|
||||
$entry .= "</source>\n";
|
||||
$entry .= "<title>" . htmlspecialchars($msg) . "</title>\n";
|
||||
$entry .= "<summary>" . htmlspecialchars($msg) . "</summary>\n";
|
||||
|
@ -183,8 +183,8 @@ class MailboxAction extends PersonalAction
|
||||
'class' => 'url'));
|
||||
$avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
|
||||
$this->element('img', array('src' => ($avatar) ?
|
||||
common_avatar_display_url($avatar) :
|
||||
common_default_avatar(AVATAR_STREAM_SIZE),
|
||||
$avatar->displayUrl() :
|
||||
Avatar::defaultImage(AVATAR_STREAM_SIZE),
|
||||
'class' => 'photo avatar',
|
||||
'width' => AVATAR_STREAM_SIZE,
|
||||
'height' => AVATAR_STREAM_SIZE,
|
||||
|
@ -285,8 +285,8 @@ class NoticeListItem extends Widget
|
||||
$avatar = $this->profile->getAvatar($avatar_size);
|
||||
|
||||
$this->out->element('img', array('src' => ($avatar) ?
|
||||
common_avatar_display_url($avatar) :
|
||||
common_default_avatar($avatar_size),
|
||||
$avatar->displayUrl() :
|
||||
Avatar::defaultImage($avatar_size),
|
||||
'class' => 'avatar photo',
|
||||
'width' => $avatar_size,
|
||||
'height' => $avatar_size,
|
||||
|
@ -82,7 +82,7 @@ class NoticeSection extends Section
|
||||
$profile->nickname,
|
||||
'href' => $profile->profileurl,
|
||||
'class' => 'url'));
|
||||
$this->out->element('img', array('src' => (($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_MINI_SIZE)),
|
||||
$this->out->element('img', array('src' => (($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_MINI_SIZE)),
|
||||
'width' => AVATAR_MINI_SIZE,
|
||||
'height' => AVATAR_MINI_SIZE,
|
||||
'class' => 'avatar photo',
|
||||
|
@ -97,7 +97,7 @@ class ProfileList extends Widget
|
||||
$avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
|
||||
$this->out->elementStart('a', array('href' => $this->profile->profileurl,
|
||||
'class' => 'url'));
|
||||
$this->out->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE),
|
||||
$this->out->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE),
|
||||
'class' => 'photo avatar',
|
||||
'width' => AVATAR_STREAM_SIZE,
|
||||
'height' => AVATAR_STREAM_SIZE,
|
||||
|
@ -74,7 +74,7 @@ class ProfileMiniList extends ProfileList
|
||||
'rel' => 'contact member',
|
||||
'class' => 'url'));
|
||||
$avatar = $this->profile->getAvatar(AVATAR_MINI_SIZE);
|
||||
$this->out->element('img', array('src' => (($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_MINI_SIZE)),
|
||||
$this->out->element('img', array('src' => (($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_MINI_SIZE)),
|
||||
'width' => AVATAR_MINI_SIZE,
|
||||
'height' => AVATAR_MINI_SIZE,
|
||||
'class' => 'avatar photo',
|
||||
|
@ -86,7 +86,7 @@ class ProfileSection extends Section
|
||||
'rel' => 'contact member',
|
||||
'class' => 'url'));
|
||||
$avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
|
||||
$this->out->element('img', array('src' => (($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_MINI_SIZE)),
|
||||
$this->out->element('img', array('src' => (($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_MINI_SIZE)),
|
||||
'width' => AVATAR_MINI_SIZE,
|
||||
'height' => AVATAR_MINI_SIZE,
|
||||
'class' => 'avatar photo',
|
||||
|
@ -199,7 +199,7 @@ class Rss10Action extends Action
|
||||
$this->element('dc:date', null, common_date_w3dtf($notice->created));
|
||||
$this->element('dc:creator', null, ($profile->fullname) ? $profile->fullname : $profile->nickname);
|
||||
$this->element('sioc:has_creator', array('rdf:resource' => $creator_uri));
|
||||
$this->element('laconica:postIcon', array('rdf:resource' => common_profile_avatar_url($profile)));
|
||||
$this->element('laconica:postIcon', array('rdf:resource' => $profile->avatarUrl()));
|
||||
$this->element('cc:licence', array('rdf:resource' => common_config('license', 'url')));
|
||||
$this->elementEnd('item');
|
||||
$this->creators[$creator_uri] = $profile;
|
||||
@ -216,7 +216,7 @@ class Rss10Action extends Action
|
||||
$this->element('foaf:name', null, $profile->fullname);
|
||||
}
|
||||
$this->element('sioc:id', null, $id);
|
||||
$avatar = common_profile_avatar_url($profile);
|
||||
$avatar = $profile->avatarUrl();
|
||||
$this->element('sioc:avatar', array('rdf:resource' => $avatar));
|
||||
$this->elementEnd('sioc:User');
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class TwitterapiAction extends Action
|
||||
|
||||
$avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
|
||||
|
||||
$twitter_user['profile_image_url'] = ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE);
|
||||
$twitter_user['profile_image_url'] = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE);
|
||||
$twitter_user['protected'] = 'false'; # not supported by Laconica yet
|
||||
$twitter_user['url'] = ($profile->homepage) ? $profile->homepage : null;
|
||||
|
||||
|
78
lib/util.php
78
lib/util.php
@ -395,15 +395,15 @@ function common_render_text($text)
|
||||
function common_replace_urls_callback($text, $callback) {
|
||||
// Start off with a regex
|
||||
preg_match_all('#(?:(?:(?:https?|ftps?|mms|rtsp|gopher|news|nntp|telnet|wais|file|prospero|webcal|xmpp|irc)://|(?:mailto|aim|tel):)[^.\s]+\.[^\s]+|(?:[^.\s/]+\.)+(?:museum|travel|[a-z]{2,4})(?:[:/][^\s]*)?)#i', $text, $matches);
|
||||
|
||||
|
||||
// Then clean up what the regex left behind
|
||||
$offset = 0;
|
||||
foreach($matches[0] as $url) {
|
||||
$url = htmlspecialchars_decode($url);
|
||||
|
||||
|
||||
// Make sure we didn't pick up an email address
|
||||
if (preg_match('#^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$#i', $url)) continue;
|
||||
|
||||
|
||||
// Remove trailing punctuation
|
||||
$url = rtrim($url, '.?!,;:\'"`');
|
||||
|
||||
@ -422,48 +422,48 @@ function common_replace_urls_callback($text, $callback) {
|
||||
|
||||
// Remove trailing punctuation again (in case there were some inside parens)
|
||||
$url = rtrim($url, '.?!,;:\'"`');
|
||||
|
||||
|
||||
// Make sure we didn't capture part of the next sentence
|
||||
preg_match('#((?:[^.\s/]+\.)+)(museum|travel|[a-z]{2,4})#i', $url, $url_parts);
|
||||
|
||||
|
||||
// Were the parts capitalized any?
|
||||
$last_part = (mb_strtolower($url_parts[2]) !== $url_parts[2]) ? true:false;
|
||||
$prev_part = (mb_strtolower($url_parts[1]) !== $url_parts[1]) ? true:false;
|
||||
|
||||
|
||||
// If the first part wasn't cap'd but the last part was, we captured too much
|
||||
if ((!$prev_part && $last_part)) {
|
||||
$url = substr_replace($url, '', mb_strpos($url, '.'.$url_parts[2], 0));
|
||||
}
|
||||
|
||||
|
||||
// Capture the new TLD
|
||||
preg_match('#((?:[^.\s/]+\.)+)(museum|travel|[a-z]{2,4})#i', $url, $url_parts);
|
||||
|
||||
|
||||
$tlds = array('ac', 'ad', 'ae', 'aero', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', 'arpa', 'as', 'asia', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'biz', 'bj', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cat', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'com', 'coop', 'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'edu', 'ee', 'eg', 'er', 'es', 'et', 'eu', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gov', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'info', 'int', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jobs', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mil', 'mk', 'ml', 'mm', 'mn', 'mo', 'mobi', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'museum', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'name', 'nc', 'ne', 'net', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'org', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'pro', 'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tel', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'travel', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'yu', 'za', 'zm', 'zw');
|
||||
|
||||
if (!in_array($url_parts[2], $tlds)) continue;
|
||||
|
||||
|
||||
// Call user specified func
|
||||
$modified_url = $callback($url);
|
||||
|
||||
|
||||
// Replace it!
|
||||
$start = mb_strpos($text, $url, $offset);
|
||||
$text = mb_substr($text, 0, $start).$modified_url.mb_substr($text, $start + mb_strlen($url), mb_strlen($text));
|
||||
$offset = $start + mb_strlen($modified_url);
|
||||
}
|
||||
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
function common_linkify($url) {
|
||||
$display = $url;
|
||||
$url = (!preg_match('#^([a-z]+://|(mailto|aim|tel):)#i', $url)) ? 'http://'.$url:$url;
|
||||
|
||||
|
||||
if ($longurl = common_longurl($url)) {
|
||||
$longurl = htmlentities($longurl, ENT_QUOTES, 'UTF-8');
|
||||
$title = "title=\"$longurl\"";
|
||||
}
|
||||
else $title = '';
|
||||
|
||||
|
||||
return "<a href=\"$url\" $title class=\"extlink\">$display</a>";
|
||||
}
|
||||
|
||||
@ -653,48 +653,6 @@ function common_relative_profile($sender, $nickname, $dt=null)
|
||||
return null;
|
||||
}
|
||||
|
||||
// where should the avatar go for this user?
|
||||
|
||||
function common_avatar_filename($id, $extension, $size=null, $extra=null)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if ($size) {
|
||||
return $id . '-' . $size . (($extra) ? ('-' . $extra) : '') . $extension;
|
||||
} else {
|
||||
return $id . '-original' . (($extra) ? ('-' . $extra) : '') . $extension;
|
||||
}
|
||||
}
|
||||
|
||||
function common_avatar_path($filename)
|
||||
{
|
||||
global $config;
|
||||
return INSTALLDIR . '/avatar/' . $filename;
|
||||
}
|
||||
|
||||
function common_avatar_url($filename)
|
||||
{
|
||||
return common_path('avatar/'.$filename);
|
||||
}
|
||||
|
||||
function common_avatar_display_url($avatar)
|
||||
{
|
||||
$server = common_config('avatar', 'server');
|
||||
if ($server) {
|
||||
return 'http://'.$server.'/'.$avatar->filename;
|
||||
} else {
|
||||
return $avatar->url;
|
||||
}
|
||||
}
|
||||
|
||||
function common_default_avatar($size)
|
||||
{
|
||||
static $sizenames = array(AVATAR_PROFILE_SIZE => 'profile',
|
||||
AVATAR_STREAM_SIZE => 'stream',
|
||||
AVATAR_MINI_SIZE => 'mini');
|
||||
return theme_path('default-avatar-'.$sizenames[$size].'.png');
|
||||
}
|
||||
|
||||
function common_local_url($action, $args=null, $fragment=null)
|
||||
{
|
||||
$url = null;
|
||||
@ -1511,16 +1469,6 @@ function common_markup_to_html($c)
|
||||
return Markdown($c);
|
||||
}
|
||||
|
||||
function common_profile_avatar_url($profile, $size=AVATAR_PROFILE_SIZE)
|
||||
{
|
||||
$avatar = $profile->getAvatar($size);
|
||||
if ($avatar) {
|
||||
return common_avatar_display_url($avatar);
|
||||
} else {
|
||||
return common_default_avatar($size);
|
||||
}
|
||||
}
|
||||
|
||||
function common_profile_uri($profile)
|
||||
{
|
||||
if (!$profile) {
|
||||
|
@ -74,7 +74,7 @@ class EnjitQueueHandler extends QueueHandler
|
||||
$atom .= "<link href='" . $profile->profileurl . "'/>\n";
|
||||
$atom .= "<link rel='self' type='application/rss+xml' href='" . common_local_url('userrss', array('nickname' => $profile->nickname)) . "'/>\n";
|
||||
$atom .= "<author><name>" . $profile->nickname . "</name></author>\n";
|
||||
$atom .= "<icon>" . common_profile_avatar_url($profile, AVATAR_PROFILE_SIZE) . "</icon>\n";
|
||||
$atom .= "<icon>" . $profile->avatarUrl(AVATAR_PROFILE_SIZE) . "</icon>\n";
|
||||
$atom .= "</source>\n";
|
||||
$atom .= "<title>" . htmlspecialchars($msg) . "</title>\n";
|
||||
$atom .= "<summary>" . htmlspecialchars($msg) . "</summary>\n";
|
||||
|
Loading…
Reference in New Issue
Block a user