X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Faction.php;h=55ee83bde6d5bc9d32ed89a76e80e773f094b083;hb=f1bfbece06d7db20fa144fe5ac8a2f6c589eff45;hp=e503975147085db7200db9575dcea0da54078456;hpb=6832a34216437cbacdc1e21f2cf8fa8f4e58ff63;p=quix0rs-gnu-social.git diff --git a/lib/action.php b/lib/action.php index e503975147..55ee83bde6 100644 --- a/lib/action.php +++ b/lib/action.php @@ -175,8 +175,9 @@ class Action extends HTMLOutputter // lawsuit $this->element('link', array('rel' => 'shortcut icon', 'href' => Theme::path('favicon.ico'))); } else { + // favicon.ico should be HTTPS if the rest of the page is $this->element('link', array('rel' => 'shortcut icon', - 'href' => common_path('favicon.ico'))); + 'href' => common_path('favicon.ico', StatusNet::isHTTPS()))); } if (common_config('site', 'mobile')) { @@ -314,7 +315,6 @@ class Action extends HTMLOutputter // lawsuit * * @return nothing */ - function showFeeds() { $feeds = $this->getFeeds(); @@ -398,7 +398,10 @@ class Action extends HTMLOutputter // lawsuit Event::handle('EndShowSiteNotice', array($this)); } if (common_logged_in()) { - $this->showNoticeForm(); + if (Event::handle('StartShowNoticeForm', array($this))) { + $this->showNoticeForm(); + Event::handle('EndShowNoticeForm', array($this)); + } } else { $this->showAnonymousMessage(); } @@ -423,11 +426,35 @@ class Action extends HTMLOutputter // lawsuit } $this->elementStart('a', array('class' => 'url home bookmark', 'href' => $url)); - if (common_config('site', 'logo') || file_exists(Theme::file('logo.png'))) { + + if (StatusNet::isHTTPS()) { + $logoUrl = common_config('site', 'ssllogo'); + if (empty($logoUrl)) { + // if logo is an uploaded file, try to fall back to HTTPS file URL + $httpUrl = common_config('site', 'logo'); + if (!empty($httpUrl)) { + $f = File::staticGet('url', $httpUrl); + if (!empty($f) && !empty($f->filename)) { + // this will handle the HTTPS case + $logoUrl = File::url($f->filename); + } + } + } + } else { + $logoUrl = common_config('site', 'logo'); + } + + if (empty($logoUrl) && file_exists(Theme::file('logo.png'))) { + // This should handle the HTTPS case internally + $logoUrl = Theme::path('logo.png'); + } + + if (!empty($logoUrl)) { $this->element('img', array('class' => 'logo photo', - 'src' => (common_config('site', 'logo')) ? common_config('site', 'logo') : Theme::path('logo.png'), + 'src' => $logoUrl, 'alt' => common_config('site', 'name'))); } + $this->text(' '); $this->element('span', array('class' => 'fn org'), common_config('site', 'name')); $this->elementEnd('a'); @@ -710,19 +737,18 @@ class Action extends HTMLOutputter // lawsuit * * @return nothing */ - function showAside() { $this->elementStart('div', array('id' => 'aside_primary', 'class' => 'aside')); - if (Event::handle('StartShowExportData', array($this))) { - $this->showExportData(); - Event::handle('EndShowExportData', array($this)); - } if (Event::handle('StartShowSections', array($this))) { $this->showSections(); Event::handle('EndShowSections', array($this)); } + if (Event::handle('StartShowExportData', array($this))) { + $this->showExportData(); + Event::handle('EndShowExportData', array($this)); + } $this->elementEnd('div'); } @@ -731,7 +757,6 @@ class Action extends HTMLOutputter // lawsuit * * @return void */ - function showExportData() { $feeds = $this->getFeeds(); @@ -807,6 +832,7 @@ class Action extends HTMLOutputter // lawsuit // TRANS: Secondary navigation menu option leading to contact information on the StatusNet site. _('Contact')); $this->menuItem(common_local_url('doc', array('title' => 'badge')), + // TRANS: Secondary navigation menu option. _('Badge')); Event::handle('EndSecondaryNav', array($this)); } @@ -840,6 +866,9 @@ class Action extends HTMLOutputter // lawsuit $this->elementStart('dd', null); if (common_config('site', 'broughtby')) { // TRANS: First sentence of the StatusNet site license. Used if 'broughtby' is set. + // TRANS: Text between [] is a link description, text between () is the link itself. + // TRANS: Make sure there is no whitespace between "]" and "(". + // TRANS: "%%site.broughtby%%" is the value of the variable site.broughtby $instr = _('**%%site.name%%** is a microblogging service brought to you by [%%site.broughtby%%](%%site.broughtbyurl%%).'); } else { // TRANS: First sentence of the StatusNet site license. Used if 'broughtby' is not set. @@ -847,6 +876,9 @@ class Action extends HTMLOutputter // lawsuit } $instr .= ' '; // TRANS: Second sentence of the StatusNet site license. Mentions the StatusNet source code license. + // TRANS: Make sure there is no whitespace between "]" and "(". + // TRANS: Text between [] is a link description, text between () is the link itself. + // TRANS: %s is the version of StatusNet that is being used. $instr .= sprintf(_('It runs the [StatusNet](http://status.net/) microblogging software, version %s, available under the [GNU Affero General Public License](http://www.fsf.org/licensing/licenses/agpl-3.0.html).'), STATUSNET_VERSION); $output = common_markup_to_html($instr); $this->raw($output); @@ -887,13 +919,32 @@ class Action extends HTMLOutputter // lawsuit case 'cc': // fall through default: $this->elementStart('p'); + + $image = common_config('license', 'image'); + $sslimage = common_config('license', 'sslimage'); + + if (StatusNet::isHTTPS()) { + if (!empty($sslimage)) { + $url = $sslimage; + } else if (preg_match('#^http://i.creativecommons.org/#', $image)) { + // CC support HTTPS on their images + $url = preg_replace('/^http/', 'https', $image); + } else { + // Better to show mixed content than no content + $url = $image; + } + } else { + $url = $image; + } + $this->element('img', array('id' => 'license_cc', - 'src' => common_config('license', 'image'), + 'src' => $url, 'alt' => common_config('license', 'title'), 'width' => '80', 'height' => '15')); $this->text(' '); - // TRANS: license message in footer. %1$s is the site name, %2$s is a link to the license URL, with a licence name set in configuration. + // TRANS: license message in footer. + // TRANS: %1$s is the site name, %2$s is a link to the license URL, with a licence name set in configuration. $notice = _('All %1$s content and data are available under the %2$s license.'); $link = "_hasEtag($etag, $if_none_match)) { - header('HTTP/1.1 304 Not Modified'); - // Better way to do this? - exit(0); + if ($if_none_match) { + // If this check fails, ignore the if-modified-since below. + $checked = true; + if ($this->_hasEtag($etag, $if_none_match)) { + header('HTTP/1.1 304 Not Modified'); + // Better way to do this? + exit(0); + } } } - if ($lm && array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) { + if (!$checked && $lm && array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) { $if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE']; $ims = strtotime($if_modified_since); if ($lm <= $ims) { @@ -1041,7 +1096,6 @@ class Action extends HTMLOutputter // lawsuit * * @return boolean is read only action? */ - function isCacheable() { return true; @@ -1055,7 +1109,6 @@ class Action extends HTMLOutputter // lawsuit * * @return boolean */ - function _hasEtag($etag, $if_none_match) { $etags = explode(',', $if_none_match); @@ -1095,7 +1148,6 @@ class Action extends HTMLOutputter // lawsuit * * @return integer integer value */ - function int($key, $defValue=null, $maxValue=null, $minValue=null) { $arg = strtolower($this->trimmed($key)); @@ -1123,7 +1175,6 @@ class Action extends HTMLOutputter // lawsuit * * @return nothing */ - function serverError($msg, $code=500) { $action = $this->trimmed('action'); @@ -1139,7 +1190,6 @@ class Action extends HTMLOutputter // lawsuit * * @return nothing */ - function clientError($msg, $code=400) { $action = $this->trimmed('action'); @@ -1152,7 +1202,6 @@ class Action extends HTMLOutputter // lawsuit * * @return string current URL */ - function selfUrl() { list($action, $args) = $this->returnToArgs(); @@ -1164,7 +1213,6 @@ class Action extends HTMLOutputter // lawsuit * * @return array two elements: action, other args */ - function returnToArgs() { $action = $this->trimmed('action'); @@ -1271,7 +1319,6 @@ class Action extends HTMLOutputter // lawsuit * * @return array Feed object to show in head and links */ - function getFeeds() { return null; @@ -1282,7 +1329,6 @@ class Action extends HTMLOutputter // lawsuit * * @return Design a design object to use */ - function getDesign() { return Design::siteDesign(); @@ -1296,7 +1342,6 @@ class Action extends HTMLOutputter // lawsuit * * @return void */ - // XXX: Finding this type of check with the same message about 50 times. // Possible to refactor? function checkSessionToken() @@ -1304,6 +1349,7 @@ class Action extends HTMLOutputter // lawsuit // CSRF protection $token = $this->trimmed('token'); if (empty($token) || $token != common_session_token()) { + // TRANS: Client error text when there is a problem with the session token. $this->clientError(_('There was a problem with your session token.')); } }