Merge remote-tracking branch 'friendica/develop' into develop
This commit is contained in:
commit
054f43a332
|
@ -1686,20 +1686,16 @@ use \Friendica\Core\Config;
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($r[0]['body'] != "") {
|
if ($r[0]['body'] != "") {
|
||||||
if (!intval(get_config('system','old_share'))) {
|
if (strpos($r[0]['body'], "[/share]") !== false) {
|
||||||
if (strpos($r[0]['body'], "[/share]") !== false) {
|
$pos = strpos($r[0]['body'], "[share");
|
||||||
$pos = strpos($r[0]['body'], "[share");
|
$post = substr($r[0]['body'], $pos);
|
||||||
$post = substr($r[0]['body'], $pos);
|
} else {
|
||||||
} else {
|
$post = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
|
||||||
$post = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
|
|
||||||
|
|
||||||
$post .= $r[0]['body'];
|
|
||||||
$post .= "[/share]";
|
|
||||||
}
|
|
||||||
$_REQUEST['body'] = $post;
|
|
||||||
} else
|
|
||||||
$_REQUEST['body'] = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8')."[url=".$r[0]['reply_url']."]".$r[0]['reply_author']."[/url] \n".$r[0]['body'];
|
|
||||||
|
|
||||||
|
$post .= $r[0]['body'];
|
||||||
|
$post .= "[/share]";
|
||||||
|
}
|
||||||
|
$_REQUEST['body'] = $post;
|
||||||
$_REQUEST['profile_uid'] = api_user();
|
$_REQUEST['profile_uid'] = api_user();
|
||||||
$_REQUEST['type'] = 'wall';
|
$_REQUEST['type'] = 'wall';
|
||||||
$_REQUEST['api_source'] = true;
|
$_REQUEST['api_source'] = true;
|
||||||
|
|
|
@ -649,9 +649,7 @@ function admin_page_site_post(App $a) {
|
||||||
$diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False);
|
$diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False);
|
||||||
$ssl_policy = ((x($_POST,'ssl_policy')) ? intval($_POST['ssl_policy']) : 0);
|
$ssl_policy = ((x($_POST,'ssl_policy')) ? intval($_POST['ssl_policy']) : 0);
|
||||||
$force_ssl = ((x($_POST,'force_ssl')) ? True : False);
|
$force_ssl = ((x($_POST,'force_ssl')) ? True : False);
|
||||||
$old_share = ((x($_POST,'old_share')) ? True : False);
|
|
||||||
$hide_help = ((x($_POST,'hide_help')) ? True : False);
|
$hide_help = ((x($_POST,'hide_help')) ? True : False);
|
||||||
$suppress_language = ((x($_POST,'suppress_language')) ? True : False);
|
|
||||||
$suppress_tags = ((x($_POST,'suppress_tags')) ? True : False);
|
$suppress_tags = ((x($_POST,'suppress_tags')) ? True : False);
|
||||||
$use_fulltext_engine = ((x($_POST,'use_fulltext_engine')) ? True : False);
|
$use_fulltext_engine = ((x($_POST,'use_fulltext_engine')) ? True : False);
|
||||||
$itemcache = ((x($_POST,'itemcache')) ? notags(trim($_POST['itemcache'])) : '');
|
$itemcache = ((x($_POST,'itemcache')) ? notags(trim($_POST['itemcache'])) : '');
|
||||||
|
@ -734,7 +732,6 @@ function admin_page_site_post(App $a) {
|
||||||
set_config('config','sitename',$sitename);
|
set_config('config','sitename',$sitename);
|
||||||
set_config('config','hostname',$hostname);
|
set_config('config','hostname',$hostname);
|
||||||
set_config('config','sender_email', $sender_email);
|
set_config('config','sender_email', $sender_email);
|
||||||
set_config('system','suppress_language',$suppress_language);
|
|
||||||
set_config('system','suppress_tags',$suppress_tags);
|
set_config('system','suppress_tags',$suppress_tags);
|
||||||
set_config('system','shortcut_icon',$shortcut_icon);
|
set_config('system','shortcut_icon',$shortcut_icon);
|
||||||
set_config('system','touch_icon',$touch_icon);
|
set_config('system','touch_icon',$touch_icon);
|
||||||
|
@ -805,7 +802,6 @@ function admin_page_site_post(App $a) {
|
||||||
set_config('config','private_addons', $private_addons);
|
set_config('config','private_addons', $private_addons);
|
||||||
|
|
||||||
set_config('system','force_ssl', $force_ssl);
|
set_config('system','force_ssl', $force_ssl);
|
||||||
set_config('system','old_share', $old_share);
|
|
||||||
set_config('system','hide_help', $hide_help);
|
set_config('system','hide_help', $hide_help);
|
||||||
set_config('system','use_fulltext_engine', $use_fulltext_engine);
|
set_config('system','use_fulltext_engine', $use_fulltext_engine);
|
||||||
set_config('system','itemcache', $itemcache);
|
set_config('system','itemcache', $itemcache);
|
||||||
|
@ -996,7 +992,6 @@ function admin_page_site(App $a) {
|
||||||
'$theme_mobile' => array('theme_mobile', t("Mobile system theme"), get_config('system','mobile-theme'), t("Theme for mobile devices"), $theme_choices_mobile),
|
'$theme_mobile' => array('theme_mobile', t("Mobile system theme"), get_config('system','mobile-theme'), t("Theme for mobile devices"), $theme_choices_mobile),
|
||||||
'$ssl_policy' => array('ssl_policy', t("SSL link policy"), (string) intval(get_config('system','ssl_policy')), t("Determines whether generated links should be forced to use SSL"), $ssl_choices),
|
'$ssl_policy' => array('ssl_policy', t("SSL link policy"), (string) intval(get_config('system','ssl_policy')), t("Determines whether generated links should be forced to use SSL"), $ssl_choices),
|
||||||
'$force_ssl' => array('force_ssl', t("Force SSL"), get_config('system','force_ssl'), t("Force all Non-SSL requests to SSL - Attention: on some systems it could lead to endless loops.")),
|
'$force_ssl' => array('force_ssl', t("Force SSL"), get_config('system','force_ssl'), t("Force all Non-SSL requests to SSL - Attention: on some systems it could lead to endless loops.")),
|
||||||
'$old_share' => array('old_share', t("Old style 'Share'"), get_config('system','old_share'), t("Deactivates the bbcode element 'share' for repeating items.")),
|
|
||||||
'$hide_help' => array('hide_help', t("Hide help entry from navigation menu"), get_config('system','hide_help'), t("Hides the menu entry for the Help pages from the navigation menu. You can still access it calling /help directly.")),
|
'$hide_help' => array('hide_help', t("Hide help entry from navigation menu"), get_config('system','hide_help'), t("Hides the menu entry for the Help pages from the navigation menu. You can still access it calling /help directly.")),
|
||||||
'$singleuser' => array('singleuser', t("Single user instance"), get_config('system','singleuser'), t("Make this instance multi-user or single-user for the named user"), $user_names),
|
'$singleuser' => array('singleuser', t("Single user instance"), get_config('system','singleuser'), t("Make this instance multi-user or single-user for the named user"), $user_names),
|
||||||
'$maximagesize' => array('maximagesize', t("Maximum image size"), get_config('system','maximagesize'), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")),
|
'$maximagesize' => array('maximagesize', t("Maximum image size"), get_config('system','maximagesize'), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")),
|
||||||
|
@ -1052,7 +1047,6 @@ function admin_page_site(App $a) {
|
||||||
'$nodeinfo' => array('nodeinfo', t("Publish server information"), get_config('system','nodeinfo'), t("If enabled, general server and usage data will be published. The data contains the name and version of the server, number of users with public profiles, number of posts and the activated protocols and connectors. See <a href='http://the-federation.info/'>the-federation.info</a> for details.")),
|
'$nodeinfo' => array('nodeinfo', t("Publish server information"), get_config('system','nodeinfo'), t("If enabled, general server and usage data will be published. The data contains the name and version of the server, number of users with public profiles, number of posts and the activated protocols and connectors. See <a href='http://the-federation.info/'>the-federation.info</a> for details.")),
|
||||||
|
|
||||||
'$use_fulltext_engine' => array('use_fulltext_engine', t("Use MySQL full text engine"), get_config('system','use_fulltext_engine'), t("Activates the full text engine. Speeds up search - but can only search for four and more characters.")),
|
'$use_fulltext_engine' => array('use_fulltext_engine', t("Use MySQL full text engine"), get_config('system','use_fulltext_engine'), t("Activates the full text engine. Speeds up search - but can only search for four and more characters.")),
|
||||||
'$suppress_language' => array('suppress_language', t("Suppress Language"), get_config('system','suppress_language'), t("Suppress language information in meta information about a posting.")),
|
|
||||||
'$suppress_tags' => array('suppress_tags', t("Suppress Tags"), get_config('system','suppress_tags'), t("Suppress showing a list of hashtags at the end of the posting.")),
|
'$suppress_tags' => array('suppress_tags', t("Suppress Tags"), get_config('system','suppress_tags'), t("Suppress showing a list of hashtags at the end of the posting.")),
|
||||||
'$itemcache' => array('itemcache', t("Path to item cache"), get_config('system','itemcache'), t("The item caches buffers generated bbcode and external images.")),
|
'$itemcache' => array('itemcache', t("Path to item cache"), get_config('system','itemcache'), t("The item caches buffers generated bbcode and external images.")),
|
||||||
'$itemcache_duration' => array('itemcache_duration', t("Cache duration in seconds"), get_config('system','itemcache_duration'), t("How long should the cache files be hold? Default value is 86400 seconds (One day). To disable the item cache, set the value to -1.")),
|
'$itemcache_duration' => array('itemcache_duration', t("Cache duration in seconds"), get_config('system','itemcache_duration'), t("How long should the cache files be hold? Default value is 86400 seconds (One day). To disable the item cache, set the value to -1.")),
|
||||||
|
|
|
@ -15,28 +15,18 @@ function share_init(App $a) {
|
||||||
if(! dbm::is_result($r) || ($r[0]['private'] == 1))
|
if(! dbm::is_result($r) || ($r[0]['private'] == 1))
|
||||||
killme();
|
killme();
|
||||||
|
|
||||||
if (!intval(get_config('system','old_share'))) {
|
if (strpos($r[0]['body'], "[/share]") !== false) {
|
||||||
if (strpos($r[0]['body'], "[/share]") !== false) {
|
$pos = strpos($r[0]['body'], "[share");
|
||||||
$pos = strpos($r[0]['body'], "[share");
|
$o = substr($r[0]['body'], $pos);
|
||||||
$o = substr($r[0]['body'], $pos);
|
|
||||||
} else {
|
|
||||||
$o = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
|
|
||||||
|
|
||||||
if($r[0]['title'])
|
|
||||||
$o .= '[b]'.$r[0]['title'].'[/b]'."\n";
|
|
||||||
$o .= $r[0]['body'];
|
|
||||||
$o.= "[/share]";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$o = '';
|
$o = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
|
||||||
|
|
||||||
$o .= "\xE2\x99\xb2" . ' [url=' . $r[0]['author-link'] . ']' . $r[0]['author-name'] . '[/url]' . "\n";
|
|
||||||
if($r[0]['title'])
|
if($r[0]['title'])
|
||||||
$o .= '[b]' . $r[0]['title'] . '[/b]' . "\n";
|
$o .= '[b]'.$r[0]['title'].'[/b]'."\n";
|
||||||
$o .= $r[0]['body'] . "\n" ;
|
$o .= $r[0]['body'];
|
||||||
|
$o.= "[/share]";
|
||||||
$o .= (($r[0]['plink']) ? '[url=' . $r[0]['plink'] . ']' . t('link') . '[/url]' . "\n" : '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $o;
|
echo $o;
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,32 +287,6 @@ class Item extends BaseObject {
|
||||||
|
|
||||||
localize_item($item);
|
localize_item($item);
|
||||||
|
|
||||||
if ($item["postopts"] and !get_config("system", "suppress_language")) {
|
|
||||||
//$langdata = explode(";", $item["postopts"]);
|
|
||||||
//$langstr = substr($langdata[0], 5)." (".round($langdata[1]*100, 1)."%)";
|
|
||||||
$langstr = "";
|
|
||||||
if (substr($item["postopts"], 0, 5) == "lang=") {
|
|
||||||
$postopts = substr($item["postopts"], 5);
|
|
||||||
|
|
||||||
$languages = explode(":", $postopts);
|
|
||||||
|
|
||||||
if (sizeof($languages) == 1) {
|
|
||||||
$languages = array();
|
|
||||||
$languages[] = $postopts;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($languages as $language) {
|
|
||||||
$langdata = explode(";", $language);
|
|
||||||
if ($langstr != "") {
|
|
||||||
$langstr .= ", ";
|
|
||||||
}
|
|
||||||
|
|
||||||
//$langstr .= $langdata[0]." (".round($langdata[1]*100, 1)."%)";
|
|
||||||
$langstr .= round($langdata[1]*100, 1)."% ".$langdata[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$body = prepare_body($item,true);
|
$body = prepare_body($item,true);
|
||||||
|
|
||||||
list($categories, $folders) = get_cats_and_terms($item);
|
list($categories, $folders) = get_cats_and_terms($item);
|
||||||
|
@ -420,7 +394,6 @@ class Item extends BaseObject {
|
||||||
'previewing' => ($conv->is_preview() ? ' preview ' : ''),
|
'previewing' => ($conv->is_preview() ? ' preview ' : ''),
|
||||||
'wait' => t('Please wait'),
|
'wait' => t('Please wait'),
|
||||||
'thread_level' => $thread_level,
|
'thread_level' => $thread_level,
|
||||||
'postopts' => $langstr,
|
|
||||||
'edited' => $edited,
|
'edited' => $edited,
|
||||||
'network' => $item["item_network"],
|
'network' => $item["item_network"],
|
||||||
'network_name' => network_to_name($item['item_network'], $profile_link),
|
'network_name' => network_to_name($item['item_network'], $profile_link),
|
||||||
|
|
|
@ -56,7 +56,6 @@
|
||||||
{{include file="field_select.tpl" field=$theme_mobile}}
|
{{include file="field_select.tpl" field=$theme_mobile}}
|
||||||
{{include file="field_select.tpl" field=$ssl_policy}}
|
{{include file="field_select.tpl" field=$ssl_policy}}
|
||||||
{{if $ssl_policy.2 == 1}}{{include file="field_checkbox.tpl" field=$force_ssl}}{{/if}}
|
{{if $ssl_policy.2 == 1}}{{include file="field_checkbox.tpl" field=$force_ssl}}{{/if}}
|
||||||
{{include file="field_checkbox.tpl" field=$old_share}}
|
|
||||||
{{include file="field_checkbox.tpl" field=$hide_help}}
|
{{include file="field_checkbox.tpl" field=$hide_help}}
|
||||||
{{include file="field_select.tpl" field=$singleuser}}
|
{{include file="field_select.tpl" field=$singleuser}}
|
||||||
<div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div>
|
<div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div>
|
||||||
|
@ -132,7 +131,6 @@
|
||||||
{{include file="field_input.tpl" field=$lockpath}}
|
{{include file="field_input.tpl" field=$lockpath}}
|
||||||
{{include file="field_input.tpl" field=$temppath}}
|
{{include file="field_input.tpl" field=$temppath}}
|
||||||
{{include file="field_input.tpl" field=$basepath}}
|
{{include file="field_input.tpl" field=$basepath}}
|
||||||
{{include file="field_checkbox.tpl" field=$suppress_language}}
|
|
||||||
{{include file="field_checkbox.tpl" field=$suppress_tags}}
|
{{include file="field_checkbox.tpl" field=$suppress_tags}}
|
||||||
{{include file="field_checkbox.tpl" field=$nodeinfo}}
|
{{include file="field_checkbox.tpl" field=$nodeinfo}}
|
||||||
{{include file="field_input.tpl" field=$embedly}}
|
{{include file="field_input.tpl" field=$embedly}}
|
||||||
|
|
|
@ -1,292 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class colors {
|
|
||||||
|
|
||||||
/* Convert hexdec color string to rgb(a) string */
|
|
||||||
|
|
||||||
function hex2rgba($color, $opacity = false) {
|
|
||||||
|
|
||||||
$default = 'rgb(0,0,0)';
|
|
||||||
|
|
||||||
//Return default if no color provided
|
|
||||||
if(empty($color))
|
|
||||||
return $default;
|
|
||||||
|
|
||||||
//Sanitize $color if "#" is provided
|
|
||||||
if ($color[0] == '#' ) {
|
|
||||||
$color = substr( $color, 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
//Check if color has 6 or 3 characters and get values
|
|
||||||
if (strlen($color) == 6) {
|
|
||||||
$hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
|
|
||||||
} elseif ( strlen( $color ) == 3 ) {
|
|
||||||
$hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] );
|
|
||||||
} else {
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Convert hexadec to rgb
|
|
||||||
$rgb = array_map('hexdec', $hex);
|
|
||||||
|
|
||||||
//Check if opacity is set(rgba or rgb)
|
|
||||||
if($opacity){
|
|
||||||
if(abs($opacity) > 1)
|
|
||||||
$opacity = 1.0;
|
|
||||||
$output = 'rgba('.implode(",",$rgb).','.$opacity.')';
|
|
||||||
} else {
|
|
||||||
$output = 'rgb('.implode(",",$rgb).')';
|
|
||||||
}
|
|
||||||
|
|
||||||
//Return rgb(a) color string
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
function hex2rgb( $colour ) {
|
|
||||||
if ( $colour[0] == '#' ) {
|
|
||||||
$colour = substr( $colour, 1 );
|
|
||||||
}
|
|
||||||
if ( strlen( $colour ) == 6 ) {
|
|
||||||
list( $r, $g, $b ) = array( $colour[0] . $colour[1], $colour[2] . $colour[3], $colour[4] . $colour[5] );
|
|
||||||
} elseif ( strlen( $colour ) == 3 ) {
|
|
||||||
list( $r, $g, $b ) = array( $colour[0] . $colour[0], $colour[1] . $colour[1], $colour[2] . $colour[2] );
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$r = hexdec( $r );
|
|
||||||
$g = hexdec( $g );
|
|
||||||
$b = hexdec( $b );
|
|
||||||
return array( 'red' => $r, 'green' => $g, 'blue' => $b );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function rgbToHsl( $r, $g, $b ) {
|
|
||||||
$oldR = $r;
|
|
||||||
$oldG = $g;
|
|
||||||
$oldB = $b;
|
|
||||||
$r /= 255;
|
|
||||||
$g /= 255;
|
|
||||||
$b /= 255;
|
|
||||||
$max = max( $r, $g, $b );
|
|
||||||
$min = min( $r, $g, $b );
|
|
||||||
$h;
|
|
||||||
$s;
|
|
||||||
$l = ( $max + $min ) / 2;
|
|
||||||
$d = $max - $min;
|
|
||||||
|
|
||||||
if( $d == 0 ){
|
|
||||||
$h = $s = 0; // achromatic
|
|
||||||
} else {
|
|
||||||
$s = $d / ( 1 - abs( 2 * $l - 1 ) );
|
|
||||||
switch( $max ){
|
|
||||||
case $r:
|
|
||||||
$h = 60 * fmod( ( ( $g - $b ) / $d ), 6 );
|
|
||||||
if ($b > $g) {
|
|
||||||
$h += 360;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case $g:
|
|
||||||
$h = 60 * ( ( $b - $r ) / $d + 2 );
|
|
||||||
break;
|
|
||||||
case $b:
|
|
||||||
$h = 60 * ( ( $r - $g ) / $d + 4 );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return array( round( $h, 2 ), round( $s, 2 ), round( $l, 2 ) );
|
|
||||||
}
|
|
||||||
function hslToRgb( $h, $s, $l ){
|
|
||||||
$r = "";
|
|
||||||
$g = "";
|
|
||||||
$b = "";
|
|
||||||
|
|
||||||
$c = ( 1 - abs( 2 * $l - 1 ) ) * $s;
|
|
||||||
$x = $c * ( 1 - abs( fmod( ( $h / 60 ), 2 ) - 1 ) );
|
|
||||||
$m = $l - ( $c / 2 );
|
|
||||||
if ( $h < 60 ) {
|
|
||||||
$r = $c;
|
|
||||||
$g = $x;
|
|
||||||
$b = 0;
|
|
||||||
} else if ( $h < 120 ) {
|
|
||||||
$r = $x;
|
|
||||||
$g = $c;
|
|
||||||
$b = 0;
|
|
||||||
} else if ( $h < 180 ) {
|
|
||||||
$r = 0;
|
|
||||||
$g = $c;
|
|
||||||
$b = $x;
|
|
||||||
} else if ( $h < 240 ) {
|
|
||||||
$r = 0;
|
|
||||||
$g = $x;
|
|
||||||
$b = $c;
|
|
||||||
} else if ( $h < 300 ) {
|
|
||||||
$r = $x;
|
|
||||||
$g = 0;
|
|
||||||
$b = $c;
|
|
||||||
} else {
|
|
||||||
$r = $c;
|
|
||||||
$g = 0;
|
|
||||||
$b = $x;
|
|
||||||
}
|
|
||||||
|
|
||||||
$r = ( $r + $m ) * 255;
|
|
||||||
$g = ( $g + $m ) * 255;
|
|
||||||
$b = ( $b + $m ) * 255;
|
|
||||||
|
|
||||||
return array( floor( $r ), floor( $g ), floor( $b ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Som more example code - this needs to be deletet if we don't need it in
|
|
||||||
* the future
|
|
||||||
*/
|
|
||||||
|
|
||||||
function HTMLToRGB($htmlCode)
|
|
||||||
{
|
|
||||||
if($htmlCode[0] == '#')
|
|
||||||
$htmlCode = substr($htmlCode, 1);
|
|
||||||
|
|
||||||
if (strlen($htmlCode) == 3)
|
|
||||||
{
|
|
||||||
$htmlCode = $htmlCode[0] . $htmlCode[0] . $htmlCode[1] . $htmlCode[1] . $htmlCode[2] . $htmlCode[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
$r = hexdec($htmlCode[0] . $htmlCode[1]);
|
|
||||||
$g = hexdec($htmlCode[2] . $htmlCode[3]);
|
|
||||||
$b = hexdec($htmlCode[4] . $htmlCode[5]);
|
|
||||||
|
|
||||||
return $b + ($g << 0x8) + ($r << 0x10);
|
|
||||||
}
|
|
||||||
|
|
||||||
function RGBToHTML($RGB)
|
|
||||||
{
|
|
||||||
$r = 0xFF & ($RGB >> 0x10);
|
|
||||||
$g = 0xFF & ($RGB >> 0x8);
|
|
||||||
$b = 0xFF & $RGB;
|
|
||||||
|
|
||||||
$r = dechex($r);
|
|
||||||
$g = dechex($g);
|
|
||||||
$b = dechex($b);
|
|
||||||
|
|
||||||
return "#" . str_pad($r, 2, "0", STR_PAD_LEFT) . str_pad($g, 2, "0", STR_PAD_LEFT) . str_pad($b, 2, "0", STR_PAD_LEFT);
|
|
||||||
}
|
|
||||||
|
|
||||||
function ChangeLuminosity($RGB, $LuminosityPercent)
|
|
||||||
{
|
|
||||||
$HSL = RGBToHSL($RGB);
|
|
||||||
$NewHSL = (int)(((float)$LuminosityPercent / 100) * 255) + (0xFFFF00 & $HSL);
|
|
||||||
return HSLToRGB($NewHSL);
|
|
||||||
}
|
|
||||||
|
|
||||||
function RGBToHSL($RGB)
|
|
||||||
{
|
|
||||||
$r = 0xFF & ($RGB >> 0x10);
|
|
||||||
$g = 0xFF & ($RGB >> 0x8);
|
|
||||||
$b = 0xFF & $RGB;
|
|
||||||
|
|
||||||
$r = ((float)$r) / 255.0;
|
|
||||||
$g = ((float)$g) / 255.0;
|
|
||||||
$b = ((float)$b) / 255.0;
|
|
||||||
|
|
||||||
$maxC = max($r, $g, $b);
|
|
||||||
$minC = min($r, $g, $b);
|
|
||||||
|
|
||||||
$l = ($maxC + $minC) / 2.0;
|
|
||||||
|
|
||||||
if($maxC == $minC)
|
|
||||||
{
|
|
||||||
$s = 0;
|
|
||||||
$h = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if($l < .5)
|
|
||||||
{
|
|
||||||
$s = ($maxC - $minC) / ($maxC + $minC);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$s = ($maxC - $minC) / (2.0 - $maxC - $minC);
|
|
||||||
}
|
|
||||||
if($r == $maxC)
|
|
||||||
$h = ($g - $b) / ($maxC - $minC);
|
|
||||||
if($g == $maxC)
|
|
||||||
$h = 2.0 + ($b - $r) / ($maxC - $minC);
|
|
||||||
if($b == $maxC)
|
|
||||||
$h = 4.0 + ($r - $g) / ($maxC - $minC);
|
|
||||||
|
|
||||||
$h = $h / 6.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$h = (int)round(255.0 * $h);
|
|
||||||
$s = (int)round(255.0 * $s);
|
|
||||||
$l = (int)round(255.0 * $l);
|
|
||||||
|
|
||||||
$HSL = $l + ($s << 0x8) + ($h << 0x10);
|
|
||||||
return $HSL;
|
|
||||||
}
|
|
||||||
|
|
||||||
function HSLToRGB($HSL)
|
|
||||||
{
|
|
||||||
$h = 0xFF & ($HSL >> 0x10);
|
|
||||||
$s = 0xFF & ($HSL >> 0x8);
|
|
||||||
$l = 0xFF & $HSL;
|
|
||||||
|
|
||||||
$h = ((float)$h) / 255.0;
|
|
||||||
$s = ((float)$s) / 255.0;
|
|
||||||
$l = ((float)$l) / 255.0;
|
|
||||||
|
|
||||||
if($s == 0)
|
|
||||||
{
|
|
||||||
$r = $l;
|
|
||||||
$g = $l;
|
|
||||||
$b = $l;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if($l < .5)
|
|
||||||
{
|
|
||||||
$t2 = $l * (1.0 + $s);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$t2 = ($l + $s) - ($l * $s);
|
|
||||||
}
|
|
||||||
$t1 = 2.0 * $l - $t2;
|
|
||||||
|
|
||||||
$rt3 = $h + 1.0/3.0;
|
|
||||||
$gt3 = $h;
|
|
||||||
$bt3 = $h - 1.0/3.0;
|
|
||||||
|
|
||||||
if($rt3 < 0) $rt3 += 1.0;
|
|
||||||
if($rt3 > 1) $rt3 -= 1.0;
|
|
||||||
if($gt3 < 0) $gt3 += 1.0;
|
|
||||||
if($gt3 > 1) $gt3 -= 1.0;
|
|
||||||
if($bt3 < 0) $bt3 += 1.0;
|
|
||||||
if($bt3 > 1) $bt3 -= 1.0;
|
|
||||||
|
|
||||||
if(6.0 * $rt3 < 1) $r = $t1 + ($t2 - $t1) * 6.0 * $rt3;
|
|
||||||
elseif(2.0 * $rt3 < 1) $r = $t2;
|
|
||||||
elseif(3.0 * $rt3 < 2) $r = $t1 + ($t2 - $t1) * ((2.0/3.0) - $rt3) * 6.0;
|
|
||||||
else $r = $t1;
|
|
||||||
|
|
||||||
if(6.0 * $gt3 < 1) $g = $t1 + ($t2 - $t1) * 6.0 * $gt3;
|
|
||||||
elseif(2.0 * $gt3 < 1) $g = $t2;
|
|
||||||
elseif(3.0 * $gt3 < 2) $g = $t1 + ($t2 - $t1) * ((2.0/3.0) - $gt3) * 6.0;
|
|
||||||
else $g = $t1;
|
|
||||||
|
|
||||||
if(6.0 * $bt3 < 1) $b = $t1 + ($t2 - $t1) * 6.0 * $bt3;
|
|
||||||
elseif(2.0 * $bt3 < 1) $b = $t2;
|
|
||||||
elseif(3.0 * $bt3 < 2) $b = $t1 + ($t2 - $t1) * ((2.0/3.0) - $bt3) * 6.0;
|
|
||||||
else $b = $t1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$r = (int)round(255.0 * $r);
|
|
||||||
$g = (int)round(255.0 * $g);
|
|
||||||
$b = (int)round(255.0 * $b);
|
|
||||||
|
|
||||||
$RGB = $b + ($g << 0x8) + ($r << 0x10);
|
|
||||||
return $RGB;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user