[dev] One function to rules them all

This commit is contained in:
Shnoulle (Denis Chenu) 2017-04-21 00:48:41 +02:00
parent 1f31150932
commit cec634f99d
2 changed files with 27 additions and 24 deletions

View File

@ -107,14 +107,24 @@ class QvitterAction extends ApiAction
} else {
$attachmentroot = common_path('attachment/', StatusNet::isHTTPS());
}
$avatarconfig=common_config('avatar');
if($avatarconfig['server']) {
if(StatusNet::isHTTPS() ){
$avatarroot ='https://'.$avatarconfig['server'].$avatarconfig['path'];
} elseif(!StatusNet::isHTTPS()) {
$avatarroot ='http://'.$avatarconfig['server'].$avatarconfig['path'];
}
} else {
$attachmentroot = common_path('attachment/', StatusNet::isHTTPS());
}
$instanceurl = common_path('', StatusNet::isHTTPS());
$favicon_path = QvitterPlugin::settings("favicon_path");
$favicon_path = QvitterPlugin::settings("favicon_path");
// user's browser's language setting
$user_browser_language = 'en'; // use english if we can't find the browser language
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$user_browser_language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
}
// user's browser's language setting
$user_browser_language = 'en'; // use english if we can't find the browser language
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$user_browser_language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
}
common_set_returnto(''); // forget this
@ -379,15 +389,16 @@ class QvitterAction extends ApiAction
window.customWelcomeText = <?php print json_encode(QvitterPlugin::settings("customwelcometext")); ?>;
window.urlShortenerAPIURL = '<?php print QvitterPlugin::settings("urlshortenerapiurl"); ?>';
window.urlShortenerSignature = '<?php print QvitterPlugin::settings("urlshortenersignature"); ?>';
window.urlshortenerFormat = '<?php print QvitterPlugin::settings("urlshortenerformat"); ?>';
window.urlshortenerFormat = '<?php print QvitterPlugin::settings("urlshortenerformat"); ?>';
window.commonSessionToken = '<?php print common_session_token(); ?>';
window.siteMaxThumbnailSize = <?php print common_config('thumbnail', 'maxsize'); ?>;
window.siteAttachmentURLBase = '<?php print $attachmentroot; ?>';
window.siteAvatarURLBase = '<?php print $avatarroot; ?>';
window.siteEmail = '<?php print common_config('site', 'email'); ?>';
window.siteLicenseTitle = '<?php print common_config('license', 'title'); ?>';
window.siteLicenseURL = '<?php print common_config('license', 'url'); ?>';
window.customTermsOfUse = <?php print json_encode(QvitterPlugin::settings("customtermsofuse")); ?>;
window.siteLocalOnlyDefaultPath = <?php print (common_config('public', 'localonly') ? 'true' : 'false'); ?>;
window.siteLocalOnlyDefaultPath = <?php print (common_config('public', 'localonly') ? 'true' : 'false'); ?>;
<?php
// Get all topics in Qvitter's namespace in Profile_prefs

View File

@ -726,17 +726,13 @@ function updateAllQueetsTimes() {
· · · · · · · · · */
function isLocalURL(url) {
if(url.substring(0,window.siteInstanceURL.length) == window.siteInstanceURL) {
if(url.substring(0,window.siteInstanceURL.length) == window.siteInstanceURL // site url
|| url.substring(0,window.siteAttachmentURLBase.length) == window.siteAttachmentURLBase // attachment url
|| url.substring(0,window.siteAvatarURLBase.length) == window.siteAvatarURLBase // avatar url
) {
return true;
}
else {
if(url.substring(0,window.siteAttachmentURLBase.length) == window.siteAttachmentURLBase) {
return true;
}
else {
return false;
}
}
return false;
}
@ -1052,14 +1048,10 @@ function userArrayCacheGetUserNicknameById(id) {
· · · · · · · · · */
function detectLocalOrExternalUserObject(userObject) {
var dataProfileImageUrlWithoutProtocol = removeProtocolFromUrl(userObject.profile_image_url);
var siteInstanceURLWithoutProtocol = removeProtocolFromUrl(window.siteInstanceURL);
if(dataProfileImageUrlWithoutProtocol.substring(0,siteInstanceURLWithoutProtocol.length) == siteInstanceURLWithoutProtocol
|| dataProfileImageUrlWithoutProtocol.substring(0,window.avatarServer.length) == window.avatarServer
){
if(isLocalURL(userObject.profile_image_url) ) {
return 'local';
}
else {
} else {
return 'external';
}
}