當前位置: 首頁>>代碼示例>>PHP>>正文


PHP LANG::l_方法代碼示例

本文整理匯總了PHP中LANG::l_方法的典型用法代碼示例。如果您正苦於以下問題:PHP LANG::l_方法的具體用法?PHP LANG::l_怎麽用?PHP LANG::l_使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在LANG的用法示例。


在下文中一共展示了LANG::l_方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: output

    /**
     * This function produces the html output for the homepage
     */
    function output()
    {
        //calculate operatorstring
        if ($this->operator_distance > 0) {
            $operator_string = "";
            arsort($this->operator);
            foreach ($this->operator as $a => $b) {
                $operator_string .= $a . " (" . round($b / $this->relation_distance * 100, 1) . " %), ";
            }
            if ($this->operator_distance < $this->relation_distance) {
                $operator_string .= LANG::l_('N/A') . " (" . round(($this->relation_distance - $this->operator_distance) / $this->relation_distance * 100, 1) . " %)";
            } else {
                //delete comma
                $operator_string = substr($operator_string, 0, strlen($operator_string) - 2);
            }
        } else {
            $operator_string = LANG::l_('N/A') . " (100 %)";
        }
        // calculate trafficmodes string
        $trafficmode_string = LANG::l_('Unknown');
        //default
        if ($this->trafficmode_distance > 0) {
            arsort($this->trafficmode);
            $trafficmode_string = "";
            $trafficmode_name = array("mixed" => LANG::l_('mixed traffic'), "passenger" => LANG::l_('passenger traffic'), "freight" => LANG::l_('freight traffic'));
            foreach ($this->trafficmode as $a => $b) {
                if (isset($trafficmode_name[$a])) {
                    $trafficmode_string .= $trafficmode_name[$a] . " (" . round($b / $this->relation_distance * 100, 1) . " %), ";
                } else {
                    $this->trafficmode_distance -= $b;
                    //remove from trafficmode_distance
                }
            }
            if ($this->trafficmode_distance < $this->relation_distance) {
                $trafficmode_string .= LANG::l_('N/A') . " (" . round(($this->relation_distance - $this->trafficmode_distance) / $this->relation_distance * 100, 1) . " %)";
            } else {
                //delete comma
                $trafficmode_string = substr($trafficmode_string, 0, strlen($trafficmode_string) - 2);
            }
        } else {
            $trafficmode_string = LANG::l_('N/A') . " (100 %)";
        }
        // calculate electrified distances
        if ($this->electrified_distance > 0) {
            arsort($this->electrified);
            $electrified_string = "";
            foreach ($this->electrified as $a => $b) {
                if ($a == "no") {
                    $electrified_string .= LANG::l_('not electrified') . " (" . round($b / $this->relation_distance * 100, 1) . " %), ";
                } else {
                    $volfre = explode(";", $a);
                    if ($volfre[0] == LANG::l_('N/A')) {
                        $voltage = LANG::l_('N/A');
                    } else {
                        $voltage = $volfre[0];
                    }
                    if ($volfre[1] == LANG::l_('N/A')) {
                        $frequency = LANG::l_('N/A');
                    } elseif ($volfre[1] == "0") {
                        $frequency = LANG::l_('DC');
                    } else {
                        $frequency = $volfre[1] . " Hz " . LANG::l_('AC');
                    }
                    if ($voltage == LANG::l_('N/A') && $frequency == LANG::l_('N/A')) {
                        $electrified_string .= LANG::l_('electrified with unknown voltage') . " (" . round($b / $this->relation_distance * 100, 1) . " %), ";
                    } else {
                        $electrified_string .= $voltage . " V / " . $frequency . " (" . round($b / $this->relation_distance * 100, 1) . " %), ";
                    }
                }
            }
            if ($this->electrified_distance < $this->relation_distance) {
                $electrified_string .= LANG::l_('N/A') . " (" . round(($this->relation_distance - $this->electrified_distance) / $this->relation_distance * 100, 1) . " %)";
            } else {
                //delete comma
                $electrified_string = substr($electrified_string, 0, strlen($electrified_string) - 2);
            }
        } else {
            $electrified_string = LANG::l_('N/A') . " (100 %)";
        }
        // calculate structures
        if ($this->building_distance > 0) {
            $building_string = "";
            if ($this->tunnel_distance > 0) {
                $building_string .= round($this->tunnel_distance, 1) . " km " . LANG::l_('in tunnels') . " (" . round($this->tunnel_distance / $this->relation_distance * 100, 1) . " %), ";
            }
            if ($this->bridge_distance > 0) {
                $building_string .= round($this->bridge_distance, 1) . " km " . LANG::l_('on bridges') . " (" . round($this->bridge_distance / $this->relation_distance * 100, 1) . " %), ";
            }
            if ($this->embankment_distance > 0) {
                $building_string .= round($this->embankment_distance, 1) . " km " . LANG::l_('on embankments') . " (" . round($this->embankment_distance / $this->relation_distance * 100, 1) . " %), ";
            }
            if ($this->cutting_distance > 0) {
                $building_string .= round($this->cutting_distance, 1) . " km " . LANG::l_('in cuttings') . " (" . round($this->cutting_distance / $this->relation_distance * 100, 1) . " %), ";
            }
            //check whether there is a ground level part
            if ($this->relation_distance != $this->building_distance) {
                $building_string .= round($this->relation_distance - $this->building_distance, 1) . " km " . LANG::l_('on ground level') . " (" . round(($this->relation_distance - $this->building_distance) / $this->relation_distance * 100, 1) . " %)";
//.........這裏部分代碼省略.........
開發者ID:bigbug21,項目名稱:OSMTrainRouteAnalysis,代碼行數:101,代碼來源:getData.php


注:本文中的LANG::l_方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。