diff options
-rw-r--r-- | actions/avatarsettings.php | 190 | ||||
-rw-r--r-- | actions/facebookhome.php | 5 | ||||
-rw-r--r-- | actions/remotesubscribe.php | 16 | ||||
-rw-r--r-- | actions/showstream.php | 2 | ||||
-rw-r--r-- | lib/facebookaction.php | 5 | ||||
-rw-r--r-- | lib/imagefile.php | 10 | ||||
-rw-r--r-- | lib/tagcloudsection.php | 2 | ||||
-rw-r--r-- | theme/base/css/display.css | 16 | ||||
-rw-r--r-- | theme/identica/css/display.css | 13 |
9 files changed, 222 insertions, 37 deletions
diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php index 2c7af9b7a..1db35237e 100644 --- a/actions/avatarsettings.php +++ b/actions/avatarsettings.php @@ -50,6 +50,10 @@ require_once INSTALLDIR.'/lib/accountsettingsaction.php'; class AvatarsettingsAction extends AccountSettingsAction { + var $mode = null; + var $imagefile = null; + var $filename = null; + /** * Title of the page * @@ -69,7 +73,7 @@ class AvatarsettingsAction extends AccountSettingsAction function getInstructions() { - return _('Set your personal avatar.'); + return _('You can upload your personal avatar.'); } /** @@ -82,6 +86,15 @@ class AvatarsettingsAction extends AccountSettingsAction function showContent() { + if ($this->mode == 'crop') { + $this->showCropForm(); + } else { + $this->showUploadForm(); + } + } + + function showUploadForm() + { $user = common_current_user(); $profile = $user->getProfile(); @@ -132,16 +145,6 @@ class AvatarsettingsAction extends AccountSettingsAction 'height' => AVATAR_PROFILE_SIZE, 'alt' => $user->nickname)); $this->elementEnd('div'); - - foreach (array('avatar_crop_x', 'avatar_crop_y', - 'avatar_crop_w', 'avatar_crop_h') as $crop_info) { - $this->element('input', array('name' => $crop_info, - 'type' => 'hidden', - 'id' => $crop_info)); - } - $this->submit('crop', _('Crop')); - - $this->elementEnd('li'); } $this->elementStart('li', array ('id' => 'settings_attach')); @@ -166,6 +169,69 @@ class AvatarsettingsAction extends AccountSettingsAction } + function showCropForm() + { + $user = common_current_user(); + + $profile = $user->getProfile(); + + if (!$profile) { + common_log_db_error($user, 'SELECT', __FILE__); + $this->serverError(_('User without matching profile')); + return; + } + + $original = $profile->getOriginalAvatar(); + + $this->elementStart('form', array('method' => 'post', + 'id' => 'form_settings_avatar', + 'class' => 'form_settings', + 'action' => + common_local_url('avatarsettings'))); + $this->elementStart('fieldset'); + $this->element('legend', null, _('Avatar settings')); + $this->hidden('token', common_session_token()); + + $this->elementStart('ul', 'form_data'); + + $this->elementStart('li', + array('id' => 'avatar_original', + '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']), + 'width' => $this->filedata['width'], + 'height' => $this->filedata['height'], + 'alt' => $user->nickname)); + $this->elementEnd('div'); + $this->elementEnd('li'); + + $this->elementStart('li', + array('id' => 'avatar_preview', + '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']), + 'width' => AVATAR_PROFILE_SIZE, + 'height' => AVATAR_PROFILE_SIZE, + 'alt' => $user->nickname)); + $this->elementEnd('div'); + + foreach (array('avatar_crop_x', 'avatar_crop_y', + 'avatar_crop_w', 'avatar_crop_h') as $crop_info) { + $this->element('input', array('name' => $crop_info, + 'type' => 'hidden', + 'id' => $crop_info)); + } + $this->submit('crop', _('Crop')); + + $this->elementEnd('li'); + $this->elementEnd('ul'); + $this->elementEnd('fieldset'); + $this->elementEnd('form'); + + } + /** * Handle a post * @@ -212,17 +278,31 @@ class AvatarsettingsAction extends AccountSettingsAction return; } - $user = common_current_user(); + $cur = common_current_user(); - $profile = $user->getProfile(); + $filename = common_avatar_filename($cur->id, + image_type_to_extension($imagefile->type), + null, + 'tmp'.common_timestamp()); - if ($profile->setOriginal($imagefile->filename)) { - $this->showForm(_('Avatar updated.'), true); - } else { - $this->showForm(_('Failed updating avatar.')); - } + $filepath = common_avatar_path($filename); - $imagefile->unlink(); + move_uploaded_file($imagefile->filename, $filepath); + + $filedata = array('filename' => $filename, + 'filepath' => $filepath, + 'width' => $imagefile->width, + 'height' => $imagefile->height, + 'type' => $imagefile->type); + + $_SESSION['FILEDATA'] = $filedata; + + $this->filedata = $filedata; + + $this->mode = 'crop'; + + $this->showForm(_('Pick a square area of the image to be your avatar'), + true); } /** @@ -242,7 +322,77 @@ class AvatarsettingsAction extends AccountSettingsAction $w = $this->arg('avatar_crop_w'); $h = $this->arg('avatar_crop_h'); - if ($profile->crop_avatars($x, $y, $w, $h)) { + $filedata = $_SESSION['FILEDATA']; + + if (!$filedata) { + $this->serverError(_('Lost our file data.')); + return; + } + + $filepath = common_avatar_path($filedata['filename']); + + if (!file_exists($filepath)) { + $this->serverError(_('Lost our file.')); + return; + } + + switch ($filedata['type']) { + case IMAGETYPE_GIF: + $image_src = imagecreatefromgif($filepath); + break; + case IMAGETYPE_JPEG: + $image_src = imagecreatefromjpeg($filepath); + break; + case IMAGETYPE_PNG: + $image_src = imagecreatefrompng($filepath); + break; + default: + $this->serverError(_('Unknown file type')); + return; + } + + common_debug("W = $w, H = $h, X = $x, Y = $y"); + + $image_dest = imagecreatetruecolor($w, $h); + + $background = imagecolorallocate($image_dest, 0, 0, 0); + ImageColorTransparent($image_dest, $background); + imagealphablending($image_dest, false); + + imagecopyresized($image_dest, $image_src, 0, 0, $x, $y, $w, $h, $w, $h); + + $cur = common_current_user(); + + $filename = common_avatar_filename($cur->id, + image_type_to_extension($filedata['type']), + null, + common_timestamp()); + + $filepath = common_avatar_path($filename); + + switch ($filedata['type']) { + case IMAGETYPE_GIF: + imagegif($image_dest, $filepath); + break; + case IMAGETYPE_JPEG: + imagejpeg($image_dest, $filepath); + break; + case IMAGETYPE_PNG: + imagepng($image_dest, $filepath); + break; + default: + $this->serverError(_('Unknown file type')); + return; + } + + $user = common_current_user(); + + $profile = $cur->getProfile(); + + if ($profile->setOriginal($filepath)) { + @unlink(common_avatar_path($filedata['filename'])); + unset($_SESSION['FILEDATA']); + $this->mode = 'upload'; $this->showForm(_('Avatar updated.'), true); } else { $this->showForm(_('Failed updating avatar.')); diff --git a/actions/facebookhome.php b/actions/facebookhome.php index ea56ec071..b05e51b91 100644 --- a/actions/facebookhome.php +++ b/actions/facebookhome.php @@ -91,6 +91,9 @@ class FacebookhomeAction extends FacebookAction function login() { + + $this->showStylesheets(); + $nickname = common_canonical_nickname($this->trimmed('nickname')); $password = $this->arg('password'); @@ -185,6 +188,8 @@ class FacebookhomeAction extends FacebookAction function getUpdatePermission() { + $this->showStylesheets(); + $this->elementStart('div', array('class' => 'content')); $instructions = sprintf(_('If you would like the %s app to automatically update ' . diff --git a/actions/remotesubscribe.php b/actions/remotesubscribe.php index 3c8346fbe..f727a63b8 100644 --- a/actions/remotesubscribe.php +++ b/actions/remotesubscribe.php @@ -92,14 +92,26 @@ class RemotesubscribeAction extends Action { # id = remotesubscribe conflicts with the # button on profile page - $this->elementStart('form', array('id' => 'remsub', 'method' => 'post', - 'action' => common_local_url('remotesubscribe'))); + $this->elementStart('form', array('id' => 'form_remote_subscribe', + 'method' => 'post', + 'class' => 'form_settings', + 'action' => common_local_url('remotesubscribe'))); + $this->elementStart('fieldset'); + $this->element('legend', 'Subscribe to a remote user'); $this->hidden('token', common_session_token()); + + $this->elementStart('ul', 'form_data'); + $this->elementStart('li'); $this->input('nickname', _('User nickname'), $this->nickname, _('Nickname of the user you want to follow')); + $this->elementEnd('li'); + $this->elementStart('li'); $this->input('profile_url', _('Profile URL'), $this->profile_url, _('URL of your profile on another compatible microblogging service')); + $this->elementEnd('li'); + $this->elementEnd('ul'); $this->submit('submit', _('Subscribe')); + $this->elementEnd('fieldset'); $this->elementEnd('form'); } diff --git a/actions/showstream.php b/actions/showstream.php index 157ccdd0c..2fd56ad2e 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -367,7 +367,7 @@ class ShowstreamAction extends Action $url = common_local_url('remotesubscribe', array('nickname' => $this->profile->nickname)); $this->element('a', array('href' => $url, - 'id' => 'entity_subscribe_remote'), + 'class' => 'entity_remote_subscribe'), _('Subscribe')); } diff --git a/lib/facebookaction.php b/lib/facebookaction.php index 528b58154..a20e618d3 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -73,9 +73,7 @@ class FacebookAction extends Action function prepare($argarray) { parent::prepare($argarray); - - common_debug("Facebookaction::prepare"); - + $this->facebook = getFacebook(); $this->fbuid = $this->facebook->require_login(); @@ -261,7 +259,6 @@ class FacebookAction extends Action function showInstructions() { - global $xw; $this->elementStart('dl', array('class' => 'system_notice')); $this->element('dt', null, 'Page Notice'); diff --git a/lib/imagefile.php b/lib/imagefile.php index f15a72c76..7f1db892c 100644 --- a/lib/imagefile.php +++ b/lib/imagefile.php @@ -48,12 +48,17 @@ if (!defined('LACONICA')) { class ImageFile { var $filename = null; + var $barename = null; var $type = null; + var $height = null; + var $width = null; - function __construct($filename=null, $type=null) + function __construct($filename=null, $type=null, $width=null, $height=null) { $this->filename = $filename; $this->type = $type; + $this->width = $type; + $this->height = $type; } static function fromUpload($param='upload') @@ -83,6 +88,9 @@ class ImageFile return; } + $imagefile->width = $info[0]; + $imagefile->height = $info[1]; + switch ($info[2]) { case IMAGETYPE_GIF: case IMAGETYPE_JPEG: diff --git a/lib/tagcloudsection.php b/lib/tagcloudsection.php index 178dd88ca..ff2aca6d6 100644 --- a/lib/tagcloudsection.php +++ b/lib/tagcloudsection.php @@ -76,7 +76,7 @@ class TagCloudSection extends Section $this->out->elementStart('ul', 'tags xoxo tag-cloud'); foreach ($tw as $tag => $weight) { - $this->showTag($tag, $weight, $weight/$sum); + $this->showTag($tag, $weight, ($sum == 0) ? 0 : $weight/$sum); } $this->out->elementEnd('ul'); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index d5532a5c9..b4f3ffd54 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -144,7 +144,8 @@ font-weight:bold; #form_settings_avatar legend, #newgroup legend, #editgroup legend, -#form_tag_user legend { +#form_tag_user legend, +#form_remote_subscribe legend { display:none; } @@ -586,7 +587,8 @@ cursor:pointer; width:100%; } .entity_actions a, -#entity_nudge p { +#entity_nudge p, +.entity_remote_subscribe { text-decoration:none; font-weight:bold; display:block; @@ -606,6 +608,16 @@ padding-left:20px; padding:4px 4px 4px 23px; } +.entity_remote_subscribe { +padding:4px; +border-width:2px; +border-style:solid; +border-radius:4px; +-moz-border-radius:4px; +-webkit-border-radius:4px; +} + + .entity_tags ul { list-style-type:none; } diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index 17e2aee9e..f61d063b6 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -26,7 +26,8 @@ display:none; input, textarea, select, option { font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; } -input, textarea, select { +input, textarea, select, +.entity_remote_subscribe { border-color:#aaa; } @@ -34,7 +35,8 @@ border-color:#aaa; input.submit, #form_notice.warning #notice_text-count, #nav_register a, -.form_settings .form_note { +.form_settings .form_note, +.entity_remote_subscribe { background-color:#A9BF4F; } @@ -43,7 +45,8 @@ input:focus, textarea:focus, select:focus, border-color:#A9BF4F; } input.submit, -#nav_register a { +#nav_register a, +.entity_remote_subscribe { color:#fff; } @@ -74,9 +77,7 @@ background-color:#fcfcfc; background-color:#fcfffc; } -#aside_primary, -#entity_subscribe a, -#TB_window input.submit { +#aside_primary { background-color:#CEE1E9; } |