static function fromUpload($param = 'upload') { switch ($_FILES[$param]['error']) { case UPLOAD_ERR_OK: // success, jump out break; case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: // TRANS: Exception thrown when too large a file is uploaded. // TRANS: %s is the maximum file size, for example "500b", "10kB" or "2MB". throw new Exception(sprintf(_('That file is too big. The maximum file size is %s.'), ImageFile::maxFileSize())); return; case UPLOAD_ERR_PARTIAL: @unlink($_FILES[$param]['tmp_name']); // TRANS: Exception thrown when uploading an image and that action could not be completed. throw new Exception(_('Partial upload.')); return; case UPLOAD_ERR_NO_FILE: // No file; probably just a non-AJAX submission. return; default: common_log(LOG_ERR, __METHOD__ . ": Unknown upload error " . $_FILES[$param]['error']); // TRANS: Exception thrown when uploading an image fails for an unknown reason. throw new Exception(_('System error uploading file.')); return; } $info = @getimagesize($_FILES[$param]['tmp_name']); if (!$info) { @unlink($_FILES[$param]['tmp_name']); // TRANS: Exception thrown when uploading a file as image that is not an image or is a corrupt file. throw new Exception(_('Not an image or corrupt file.')); return; } return new ImageFile(null, $_FILES[$param]['tmp_name']); }
static function fromUpload($param = 'upload') { switch ($_FILES[$param]['error']) { case UPLOAD_ERR_OK: // success, jump out break; case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: throw new Exception(sprintf(_('That file is too big. The maximum file size is %s.'), ImageFile::maxFileSize())); return; case UPLOAD_ERR_PARTIAL: @unlink($_FILES[$param]['tmp_name']); throw new Exception(_('Partial upload.')); return; case UPLOAD_ERR_NO_FILE: // No file; probably just a non-AJAX submission. return; default: common_log(LOG_ERR, __METHOD__ . ": Unknown upload error " . $_FILES[$param]['error']); throw new Exception(_('System error uploading file.')); return; } $info = @getimagesize($_FILES[$param]['tmp_name']); if (!$info) { @unlink($_FILES[$param]['tmp_name']); throw new Exception(_('Not an image or corrupt file.')); return; } return new ImageFile(null, $_FILES[$param]['tmp_name']); }
/** * Instructions for use * * @return instructions for use */ function getInstructions() { // TRANS: Instructions for group logo page. // TRANS: %s is the maximum file size for that site. return sprintf(_('You can upload a logo image for your group. The maximum file size is %s.'), ImageFile::maxFileSize()); }
/** * Instructions for use * * @return instructions for use */ function getInstructions() { return sprintf(_('You can upload a logo image for your group. The maximum file size is %s.'), ImageFile::maxFileSize()); }
/** * Instructions for use * * @return instructions for use */ function getInstructions() { return sprintf(_('You can upload your personal avatar. The maximum file size is %s.'), ImageFile::maxFileSize()); }
/** * Instructions for use * * @return instructions for use */ function getInstructions() { // TRANS: Instruction for avatar upload page. // TRANS: %s is the maximum file size, for example "500b", "10kB" or "2MB". return sprintf(_('You can upload your personal avatar. The maximum file size is %s.'), ImageFile::maxFileSize()); }
/** * Instructions for use * * @return instructions for use */ function getInstructions() { return sprintf(_('可以上传图片作为头像显示, 图片文件最大限制为 %s.'), ImageFile::maxFileSize()); }
/** * Data elements of the form * * @return void */ function formData() { $this->out->elementStart('fieldset', array('id' => 'settings_design_logo')); $this->out->element('legend', null, _('Change logo')); $this->out->elementStart('ul', 'form_data'); $this->li(); $this->input('logo', _('Site logo'), 'Logo for the site (full URL)'); $this->unli(); $this->out->elementEnd('ul'); $this->out->elementEnd('fieldset'); $this->out->elementStart('fieldset', array('id' => 'settings_design_theme')); $this->out->element('legend', null, _('Change theme')); $this->out->elementStart('ul', 'form_data'); $themes = Theme::listAvailable(); // XXX: listAvailable() can return an empty list if you // screw up your settings, so just in case: if (empty($themes)) { $themes = array('default', 'default'); } asort($themes); $themes = array_combine($themes, $themes); $this->li(); $this->out->dropdown('theme', _('Site theme'), $themes, _('Theme for the site.'), false, $this->value('theme')); $this->unli(); $this->out->elementEnd('ul'); $this->out->elementEnd('fieldset'); $design = $this->out->design; $this->out->elementStart('fieldset', array('id' => 'settings_design_background-image')); $this->out->element('legend', null, _('Change background image')); $this->out->elementStart('ul', 'form_data'); $this->li(); $this->out->element('label', array('for' => 'design_background-image_file'), _('Background')); $this->out->element('input', array('name' => 'design_background-image_file', 'type' => 'file', 'id' => 'design_background-image_file')); $this->out->element('p', 'form_guide', sprintf(_('You can upload a background image for the site. ' . 'The maximum file size is %1$s.'), ImageFile::maxFileSize())); $this->out->element('input', array('name' => 'MAX_FILE_SIZE', 'type' => 'hidden', 'id' => 'MAX_FILE_SIZE', 'value' => ImageFile::maxFileSizeInt())); $this->unli(); if (!empty($design->backgroundimage)) { $this->out->elementStart('li', array('id' => 'design_background-image_onoff')); $this->out->element('img', array('src' => Design::url($design->backgroundimage))); $attrs = array('name' => 'design_background-image_onoff', 'type' => 'radio', 'id' => 'design_background-image_on', 'class' => 'radio', 'value' => 'on'); if ($design->disposition & BACKGROUND_ON) { $attrs['checked'] = 'checked'; } $this->out->element('input', $attrs); $this->out->element('label', array('for' => 'design_background-image_on', 'class' => 'radio'), _('On')); $attrs = array('name' => 'design_background-image_onoff', 'type' => 'radio', 'id' => 'design_background-image_off', 'class' => 'radio', 'value' => 'off'); if ($design->disposition & BACKGROUND_OFF) { $attrs['checked'] = 'checked'; } $this->out->element('input', $attrs); $this->out->element('label', array('for' => 'design_background-image_off', 'class' => 'radio'), _('Off')); $this->out->element('p', 'form_guide', _('Turn background image on or off.')); $this->unli(); $this->li(); $this->out->checkbox('design_background-image_repeat', _('Tile background image'), $design->disposition & BACKGROUND_TILE ? true : false); $this->unli(); } $this->out->elementEnd('ul'); $this->out->elementEnd('fieldset'); $this->out->elementStart('fieldset', array('id' => 'settings_design_color')); $this->out->element('legend', null, _('Change colours')); $this->out->elementStart('ul', 'form_data'); try { $bgcolor = new WebColor($design->backgroundcolor); $this->li(); $this->out->element('label', array('for' => 'swatch-1'), _('Background')); $this->out->element('input', array('name' => 'design_background', 'type' => 'text', 'id' => 'swatch-1', 'class' => 'swatch', 'maxlength' => '7', 'size' => '7', 'value' => '')); $this->unli(); $ccolor = new WebColor($design->contentcolor); $this->li(); $this->out->element('label', array('for' => 'swatch-2'), _('Content')); $this->out->element('input', array('name' => 'design_content', 'type' => 'text', 'id' => 'swatch-2', 'class' => 'swatch', 'maxlength' => '7', 'size' => '7', 'value' => '')); $this->unli(); $sbcolor = new WebColor($design->sidebarcolor); $this->li(); $this->out->element('label', array('for' => 'swatch-3'), _('Sidebar')); $this->out->element('input', array('name' => 'design_sidebar', 'type' => 'text', 'id' => 'swatch-3', 'class' => 'swatch', 'maxlength' => '7', 'size' => '7', 'value' => '')); $this->unli(); $tcolor = new WebColor($design->textcolor); $this->li(); $this->out->element('label', array('for' => 'swatch-4'), _('Text')); $this->out->element('input', array('name' => 'design_text', 'type' => 'text', 'id' => 'swatch-4', 'class' => 'swatch', 'maxlength' => '7', 'size' => '7', 'value' => '')); $this->unli(); $lcolor = new WebColor($design->linkcolor); $this->li(); $this->out->element('label', array('for' => 'swatch-5'), _('Links')); $this->out->element('input', array('name' => 'design_links', 'type' => 'text', 'id' => 'swatch-5', 'class' => 'swatch', 'maxlength' => '7', 'size' => '7', 'value' => '')); $this->unli(); } catch (WebColorException $e) { common_log(LOG_ERR, 'Bad color values in site design: ' . $e->getMessage()); } $this->out->elementEnd('fieldset'); $this->out->elementEnd('ul'); }
function showBackground() { $design = $this->out->design; $this->out->elementStart('fieldset', array('id' => 'settings_design_background-image')); // TRANS: Fieldset legend for theme background image. $this->out->element('legend', null, _('Change background image')); $this->out->elementStart('ul', 'form_data'); $this->li(); $this->out->element('input', array('name' => 'MAX_FILE_SIZE', 'type' => 'hidden', 'id' => 'MAX_FILE_SIZE', 'value' => ImageFile::maxFileSizeInt())); $this->out->element('label', array('for' => 'design_background-image_file'), _('Background')); $this->out->element('input', array('name' => 'design_background-image_file', 'type' => 'file', 'id' => 'design_background-image_file')); $this->out->element('p', 'form_guide', sprintf(_('You can upload a background image for the site. ' . 'The maximum file size is %1$s.'), ImageFile::maxFileSize())); $this->unli(); if (!empty($design->backgroundimage)) { $this->out->elementStart('li', array('id' => 'design_background-image_onoff')); $this->out->element('img', array('src' => Design::url($design->backgroundimage))); $attrs = array('name' => 'design_background-image_onoff', 'type' => 'radio', 'id' => 'design_background-image_on', 'class' => 'radio', 'value' => 'on'); if ($design->disposition & BACKGROUND_ON) { $attrs['checked'] = 'checked'; } $this->out->element('input', $attrs); $this->out->element('label', array('for' => 'design_background-image_on', 'class' => 'radio'), _('On')); $attrs = array('name' => 'design_background-image_onoff', 'type' => 'radio', 'id' => 'design_background-image_off', 'class' => 'radio', 'value' => 'off'); if ($design->disposition & BACKGROUND_OFF) { $attrs['checked'] = 'checked'; } $this->out->element('input', $attrs); $this->out->element('label', array('for' => 'design_background-image_off', 'class' => 'radio'), _('Off')); // TRANS: Form guide for turning background image on or off on theme designer page. $this->out->element('p', 'form_guide', _('Turn background image on or off.')); $this->unli(); $this->li(); $this->out->checkbox('design_background-image_repeat', _('Tile background image'), $design->disposition & BACKGROUND_TILE ? true : false); $this->unli(); } $this->out->elementEnd('ul'); $this->out->elementEnd('fieldset'); }