function showCSS($out) { $css = ''; $bgcolor = Design::toWebColor($this->backgroundcolor); if (!empty($bgcolor)) { $css .= 'body { background-color: #' . $bgcolor->hexValue() . ' }' . "\n"; } $ccolor = Design::toWebColor($this->contentcolor); if (!empty($ccolor)) { $css .= '#content, #site_nav_local_views .current a { background-color: #'; $css .= $ccolor->hexValue() . '} ' . "\n"; } $sbcolor = Design::toWebColor($this->sidebarcolor); if (!empty($sbcolor)) { $css .= '#aside_primary { background-color: #' . $sbcolor->hexValue() . ' }' . "\n"; } $tcolor = Design::toWebColor($this->textcolor); if (!empty($tcolor)) { $css .= 'html body { color: #' . $tcolor->hexValue() . ' }' . "\n"; } $lcolor = Design::toWebColor($this->linkcolor); if (!empty($lcolor)) { $css .= 'a { color: #' . $lcolor->hexValue() . ' }' . "\n"; } if (!empty($this->backgroundimage) && $this->disposition & BACKGROUND_ON) { $repeat = $this->disposition & BACKGROUND_TILE ? 'background-repeat:repeat;' : 'background-repeat:no-repeat;'; $css .= 'body { background-image:url(' . Design::url($this->backgroundimage) . '); ' . $repeat . ' background-attachment:fixed; }' . "\n"; } if (0 != mb_strlen($css)) { $out->style($css); } }
/** * Shows the design settings form * * @param Design $design a working design to show * * @return nothing */ function showDesignForm($design) { $this->elementStart('form', array('method' => 'post', 'enctype' => 'multipart/form-data', 'id' => 'form_settings_design', 'class' => 'form_settings', 'action' => $this->submitaction)); $this->elementStart('fieldset'); $this->hidden('token', common_session_token()); $this->elementStart('fieldset', array('id' => 'settings_design_background-image')); // TRANS: Fieldset legend on profile design page. $this->element('legend', null, _('Change background image')); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->element('input', array('name' => 'MAX_FILE_SIZE', 'type' => 'hidden', 'id' => 'MAX_FILE_SIZE', 'value' => ImageFile::maxFileSizeInt())); $this->element('label', array('for' => 'design_background-image_file'), _('Upload file')); $this->element('input', array('name' => 'design_background-image_file', 'type' => 'file', 'id' => 'design_background-image_file')); // TRANS: Instructions for form on profile design page. $this->element('p', 'form_guide', _('You can upload your personal ' . 'background image. The maximum file size is 2MB.')); $this->elementEnd('li'); if (!empty($design->backgroundimage)) { $this->elementStart('li', array('id' => 'design_background-image_onoff')); $this->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->element('input', $attrs); $this->element('label', array('for' => 'design_background-image_on', 'class' => 'radio'), _m('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->element('input', $attrs); $this->element('label', array('for' => 'design_background-image_off', 'class' => 'radio'), _m('RADIO', 'Off')); // TRANS: Form guide for a set of radio buttons on the profile design page that will enable or disable // TRANS: use of the uploaded profile image. $this->element('p', 'form_guide', _('Turn background image on or off.')); $this->elementEnd('li'); $this->elementStart('li'); $this->checkbox('design_background-image_repeat', _('Tile background image'), $design->disposition & BACKGROUND_TILE ? true : false); $this->elementEnd('li'); } $this->elementEnd('ul'); $this->elementEnd('fieldset'); $this->elementStart('fieldset', array('id' => 'settings_design_color')); // TRANS: Fieldset legend on profile design page to change profile page colours. $this->element('legend', null, _('Change colours')); $this->elementStart('ul', 'form_data'); try { $bgcolor = new WebColor($design->backgroundcolor); $this->elementStart('li'); // TRANS: Label on profile design page for setting a profile page background colour. $this->element('label', array('for' => 'swatch-1'), _('Background')); $this->element('input', array('name' => 'design_background', 'type' => 'text', 'id' => 'swatch-1', 'class' => 'swatch', 'maxlength' => '7', 'size' => '7', 'value' => '')); $this->elementEnd('li'); $ccolor = new WebColor($design->contentcolor); $this->elementStart('li'); // TRANS: Label on profile design page for setting a profile page content colour. $this->element('label', array('for' => 'swatch-2'), _('Content')); $this->element('input', array('name' => 'design_content', 'type' => 'text', 'id' => 'swatch-2', 'class' => 'swatch', 'maxlength' => '7', 'size' => '7', 'value' => '')); $this->elementEnd('li'); $sbcolor = new WebColor($design->sidebarcolor); $this->elementStart('li'); // TRANS: Label on profile design page for setting a profile page sidebar colour. $this->element('label', array('for' => 'swatch-3'), _('Sidebar')); $this->element('input', array('name' => 'design_sidebar', 'type' => 'text', 'id' => 'swatch-3', 'class' => 'swatch', 'maxlength' => '7', 'size' => '7', 'value' => '')); $this->elementEnd('li'); $tcolor = new WebColor($design->textcolor); $this->elementStart('li'); // TRANS: Label on profile design page for setting a profile page text colour. $this->element('label', array('for' => 'swatch-4'), _('Text')); $this->element('input', array('name' => 'design_text', 'type' => 'text', 'id' => 'swatch-4', 'class' => 'swatch', 'maxlength' => '7', 'size' => '7', 'value' => '')); $this->elementEnd('li'); $lcolor = new WebColor($design->linkcolor); $this->elementStart('li'); // TRANS: Label on profile design page for setting a profile page links colour. $this->element('label', array('for' => 'swatch-5'), _('Links')); $this->element('input', array('name' => 'design_links', 'type' => 'text', 'id' => 'swatch-5', 'class' => 'swatch', 'maxlength' => '7', 'size' => '7', 'value' => '')); $this->elementEnd('li'); } catch (WebColorException $e) { common_log(LOG_ERR, 'Bad color values in design ID: ' . $design->id); } $this->elementEnd('ul'); $this->elementEnd('fieldset'); // TRANS: Button text on profile design page to immediately reset all colour settings to default. $this->submit('defaults', _('Use defaults'), 'submit form_action-default', 'defaults', _('Restore default designs')); $this->element('input', array('id' => 'settings_design_reset', 'type' => 'reset', 'value' => _m('BUTTON', 'Reset'), 'class' => 'submit form_action-primary', 'title' => _('Reset back to default'))); // TRANS: Button text on profile design page to save settings. $this->submit('save', _m('BUTTON', 'Save'), 'submit form_action-secondary', 'save', _('Save design')); $this->elementEnd('fieldset'); $this->elementEnd('form'); }
/** * 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 twitterUserArray($profile, $get_notice = false) { $twitter_user = array(); $twitter_user['id'] = intval($profile->id); $twitter_user['name'] = $profile->getBestName(); $twitter_user['screen_name'] = $profile->nickname; $twitter_user['location'] = $profile->location ? $profile->location : null; $twitter_user['description'] = $profile->bio ? $profile->bio : null; $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE); $twitter_user['profile_image_url'] = $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE); $twitter_user['url'] = $profile->homepage ? $profile->homepage : null; $twitter_user['protected'] = false; # not supported by StatusNet yet $twitter_user['followers_count'] = $profile->subscriberCount(); $design = null; $user = $profile->getUser(); // Note: some profiles don't have an associated user $defaultDesign = Design::siteDesign(); if (!empty($user)) { $design = $user->getDesign(); } if (empty($design)) { $design = $defaultDesign; } $color = Design::toWebColor(empty($design->backgroundcolor) ? $defaultDesign->backgroundcolor : $design->backgroundcolor); $twitter_user['profile_background_color'] = $color == null ? '' : '#' . $color->hexValue(); $color = Design::toWebColor(empty($design->textcolor) ? $defaultDesign->textcolor : $design->textcolor); $twitter_user['profile_text_color'] = $color == null ? '' : '#' . $color->hexValue(); $color = Design::toWebColor(empty($design->linkcolor) ? $defaultDesign->linkcolor : $design->linkcolor); $twitter_user['profile_link_color'] = $color == null ? '' : '#' . $color->hexValue(); $color = Design::toWebColor(empty($design->sidebarcolor) ? $defaultDesign->sidebarcolor : $design->sidebarcolor); $twitter_user['profile_sidebar_fill_color'] = $color == null ? '' : '#' . $color->hexValue(); $twitter_user['profile_sidebar_border_color'] = ''; $twitter_user['friends_count'] = $profile->subscriptionCount(); $twitter_user['created_at'] = $this->dateTwitter($profile->created); $twitter_user['favourites_count'] = $profile->faveCount(); // British spelling! $timezone = 'UTC'; if (!empty($user) && $user->timezone) { $timezone = $user->timezone; } $t = new DateTime(); $t->setTimezone(new DateTimeZone($timezone)); $twitter_user['utc_offset'] = $t->format('Z'); $twitter_user['time_zone'] = $timezone; $twitter_user['profile_background_image_url'] = empty($design->backgroundimage) ? '' : $design->disposition & BACKGROUND_ON ? Design::url($design->backgroundimage) : ''; $twitter_user['profile_background_tile'] = empty($design->disposition) ? '' : $design->disposition & BACKGROUND_TILE ? 'true' : 'false'; $twitter_user['statuses_count'] = $profile->noticeCount(); // Is the requesting user following this user? $twitter_user['following'] = false; $twitter_user['notifications'] = false; if (isset($this->auth_user)) { $twitter_user['following'] = $this->auth_user->isSubscribed($profile); // Notifications on? $sub = Subscription::pkeyGet(array('subscriber' => $this->auth_user->id, 'subscribed' => $profile->id)); if ($sub) { $twitter_user['notifications'] = $sub->jabber || $sub->sms; } } if ($get_notice) { $notice = $profile->getCurrentNotice(); if ($notice) { # don't get user! $twitter_user['status'] = $this->twitterStatusArray($notice, false); } } return $twitter_user; }
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'); }