Last active
May 15, 2018 04:23
-
-
Save webbingstudio/39df7a19df26889c45cb71f0ef156f57 to your computer and use it in GitHub Desktop.
a-blog cmsのエントリー位置リストの距離表示を最適化する校正オプション ref: https://qiita.com/webbingstudio@github/items/e8482ce9429350684656
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ACMS_User_Corrector | |
{ | |
/** | |
* distance | |
* 数値を距離に変換する | |
* | |
* @param string $txt - 校正オプションが適用されている文字列 | |
* @return string - 校正後の文字列 | |
*/ | |
public static function distance($txt, $args = array()) | |
{ | |
// 例 {var}[distance(2)] | |
// {var}は強制的に数値に変換される | |
// 1000未満の場合は単位がm | |
// 1000以上の場合は単位がkm | |
// 引数: 丸める小数点の位、指定なしの場合は1 | |
$round = isset($args[0]) ? (int)$args[0] : (int)1; | |
if ( (float)$txt >= 1000 ) { | |
return round( ( (float)$txt / 1000 ) , $round ) . 'km'; | |
} else { | |
return $txt . 'm'; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ACMS_User_Corrector | |
{ | |
// ここに校正オプションを書くと追加される | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{geo_distance}[distance] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment