当前位置: 首页>>代码示例>>PHP>>正文


PHP ct函数代码示例

本文整理汇总了PHP中ct函数的典型用法代码示例。如果您正苦于以下问题:PHP ct函数的具体用法?PHP ct怎么用?PHP ct使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ct函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getTickerColumns

 /**
  * @return an array of columns e.g. (type, title, args)
  */
 function getTickerColumns()
 {
     $columns = array();
     $columns[] = array('type' => 'number', 'title' => ct("Free delay"));
     $columns[] = array('type' => 'number', 'title' => ct("Premium delay"));
     return $columns;
 }
开发者ID:phpsource,项目名称:openclerk,代码行数:10,代码来源:StatisticsQueue.php

示例2: ct

function ct($n, $m)
{
    $ct = c::get($n, $m);
    if (!is_null($ct)) {
        return $ct;
    }
    if ($n === $m) {
        $ct = 0.0;
    } elseif ($n === 1 && $m === 0) {
        $ct = 2.0;
    } elseif ($m === 0) {
        $ct = (1 + ct($n - 1, 0)) * 2;
    } else {
        for ($i = $m + 1; $i != $n; ++$i) {
            $ct0 = c::get($n, $i);
            if (!is_null($ct0)) {
                break;
            }
        }
        for ($i -= 1; $i != $m; --$i) {
            $ct1 = 1 + $ct0 / 2 + ct($n, 0) / 2;
            c::set($n, $i, $ct1);
            $ct0 = $ct1;
        }
        $ct = 1 + ct($n, $m + 1) / 2 + ct($n, 0) / 2;
    }
    c::set($n, $m, $ct);
    return $ct;
}
开发者ID:BastinRobin,项目名称:CodeSprints,代码行数:29,代码来源:ct.php

示例3: getTickerColumns

 /**
  * @return an array of columns e.g. (type, title, args)
  */
 function getTickerColumns()
 {
     $columns = array();
     $columns[] = array('type' => 'number', 'title' => ct("1 min"), 'min' => 0, 'max' => 5);
     $columns[] = array('type' => 'number', 'title' => ct("5 min"), 'min' => 0, 'max' => 5);
     $columns[] = array('type' => 'number', 'title' => ct("15 min"), 'min' => 0, 'max' => 5);
     return $columns;
 }
开发者ID:phpsource,项目名称:openclerk,代码行数:11,代码来源:StatisticsSystemLoad.php

示例4: getData

 public function getData($days)
 {
     $columns = array();
     $key_column = array('type' => 'date', 'title' => ct("Date"));
     $report_type = $this->report_type;
     $report_table = $this->report_table;
     $report_ref_table = $this->report_ref_table;
     $report_reference = $this->report_reference;
     $key_prefix = $this->key_prefix;
     $key = $this->key;
     $actual_value_key = $this->actual_value_key;
     $q = db()->prepare("SELECT * FROM performance_reports WHERE report_type=? ORDER BY id DESC LIMIT 30");
     $q->execute(array($report_type));
     $reports = $q->fetchAll();
     if (!$reports) {
         return render_text($graph, "No report {$report_type} found.");
     }
     // construct an array of (date => )
     $data = array();
     $keys = array();
     $last_updated = false;
     foreach ($reports as $report) {
         // get all queries
         $q = db()->prepare("SELECT * FROM {$report_table} AS r " . ($report_ref_table ? "JOIN {$report_ref_table} AS q ON r.{$report_reference}=q.id " : "") . "WHERE report_id=?");
         $q->execute(array($report['id']));
         $date = date('Y-m-d H:i:s', strtotime($report['created_at']));
         $row = array();
         while ($query = $q->fetch()) {
             if (!isset($keys[$query[$key]])) {
                 $keys[$query[$key]] = count($keys);
                 $columns[] = array('type' => 'number', 'title' => $query[$key]);
             }
             if ($actual_value_key === null) {
                 if ($query[$key_prefix . '_count'] == 0) {
                     // prevent division by 0
                     $row[$keys[$query[$key]]] = graph_number_format(0);
                 } else {
                     $row[$keys[$query[$key]]] = graph_number_format($query[$key_prefix . '_time'] / $query[$key_prefix . '_count']);
                 }
             } else {
                 $row[$keys[$query[$key]]] = graph_number_format($query[$actual_value_key]);
             }
         }
         $data[$date] = $row;
         $last_updated = max($last_updated, strtotime($report['created_at']));
     }
     // fill in any missing rows, e.g. queries that may not have featured in certain reports
     foreach ($data as $date => $row) {
         foreach ($keys as $id) {
             if (!isset($row[$id])) {
                 $data[$date][$id] = 0;
             }
         }
     }
     return array('key' => $key_column, 'columns' => $columns, 'data' => $data, 'last_updated' => $last_updated);
 }
开发者ID:phpsource,项目名称:openclerk,代码行数:56,代码来源:AdminMetrics.php

示例5: getTickerColumns

 /**
  * @return an array of columns e.g. (type, title, args)
  */
 function getTickerColumns()
 {
     $args = array(':pair' => get_currency_abbr($this->currency1) . "/" . get_currency_abbr($this->currency2));
     $columns = array();
     if ($this->onlyhasLastTrade()) {
         // hack fix because TheMoneyConverter and Coinbase only have last_trade
         $columns[] = array('type' => 'number', 'title' => ct(":pair"), 'args' => $args);
     } else {
         $columns[] = array('type' => 'number', 'title' => ct(":pair Bid"), 'args' => $args);
         $columns[] = array('type' => 'number', 'title' => ct(":pair Ask"), 'args' => $args);
     }
     return $columns;
 }
开发者ID:phpsource,项目名称:openclerk,代码行数:16,代码来源:Ticker.php

示例6: getData

 public function getData($days)
 {
     $columns = array();
     $key_column = array('type' => 'string', 'title' => ct("Key"));
     $columns[] = array('type' => 'string', 'title' => ct("Title"), 'heading' => true);
     $columns[] = array('type' => 'string align-right', 'title' => ct("Total"));
     $columns[] = array('type' => 'string align-right', 'title' => ct("Last week"));
     $columns[] = array('type' => 'string align-right', 'title' => ct("Last day"));
     $columns[] = array('type' => 'string align-right', 'title' => ct("Last hour"));
     $last_updated = time();
     $summary = array('user_properties' => array('title' => ct('Users'), 'extra' => array('is_disabled=1' => ct('Disabled'))), 'addresses' => array('title' => ct('Addresses')), 'jobs' => array('title' => ct('Jobs'), 'extra' => array('is_executed=0' => ct('Pending'))), 'outstanding_premiums' => array('title' => ct('Premiums'), 'extra' => array('is_paid=1' => ct('Paid'))), 'uncaught_exceptions' => array('title' => ct('Uncaught exceptions')), 'ticker' => array('title' => ct('Ticker instances')));
     $result = array();
     foreach ($summary as $key => $data) {
         $row = array();
         $row[0] = $data['title'];
         if (isset($data['extra'])) {
             foreach ($data['extra'] as $extra_key => $extra_title) {
                 $row[0] .= " ({$extra_title})";
             }
         }
         $parts = array('1', 'created_at >= date_sub(now(), interval 7 day)', 'created_at >= date_sub(now(), interval 1 day)', 'created_at >= date_sub(now(), interval 1 hour)');
         foreach ($parts as $query) {
             $q = db()->prepare("SELECT COUNT(*) AS c FROM {$key} WHERE {$query}");
             $q->execute();
             $c = $q->fetch();
             $row[] = number_format($c['c']);
             if (isset($data['extra'])) {
                 foreach ($data['extra'] as $extra_key => $extra_title) {
                     $q = db()->prepare("SELECT COUNT(*) AS c FROM {$key} WHERE {$query} AND {$extra_key}");
                     $q->execute();
                     $c = $q->fetch();
                     $row[count($row) - 1] .= " (" . number_format($c['c']) . ")";
                 }
             }
         }
         $result[$key] = $row;
     }
     $row = array(ct("Unused premium addresses"));
     $q = db()->prepare("SELECT currency, COUNT(*) AS c FROM premium_addresses WHERE is_used=0 GROUP BY currency");
     $q->execute();
     while ($c = $q->fetch()) {
         $row[] = number_format($c['c']) . " (" . get_currency_abbr($c['currency']) . ")";
     }
     $result['unused_premium_addresses'] = $row;
     return array('key' => $key_column, 'columns' => $columns, 'data' => $result, 'last_updated' => $last_updated);
 }
开发者ID:phpsource,项目名称:openclerk,代码行数:46,代码来源:AdminStatistics.php

示例7: getData

 public function getData($days)
 {
     $key_column = array('type' => 'string', 'title' => get_exchange_name($this->exchange));
     $columns = array();
     $columns[] = array('type' => 'string', 'title' => ct("Price"), 'heading' => true);
     $columns[] = array('type' => 'string', 'title' => ct("Value"));
     $data = array();
     $q = db()->prepare("SELECT * FROM ticker_recent WHERE exchange=:exchange AND currency1=:currency1 AND currency2=:currency2");
     $q->execute(array('exchange' => $this->exchange, 'currency1' => $this->currency1, 'currency2' => $this->currency2));
     if ($ticker = $q->fetch()) {
         $last_updated = $ticker['created_at'];
         $data[] = array('Bid', currency_format($this->currency1, $ticker['bid'], 4));
         $data[] = array('Ask', currency_format($this->currency1, $ticker['ask'], 4));
     } else {
         throw new GraphException(t("No recent rates found for :exchange :pair", $this->getTitleArgs()));
     }
     return array('key' => $key_column, 'columns' => $columns, 'data' => $data, 'last_updated' => $last_updated, 'no_header' => true);
 }
开发者ID:phpsource,项目名称:openclerk,代码行数:18,代码来源:ExchangePair.php

示例8: getData

 /**
  * We need to transpose the returned data, both data and columns.
  */
 public function getData($days)
 {
     $original = parent::getData($days);
     $columns = array();
     $columns[] = array('type' => 'string', 'title' => ct("Total :currency"), 'args' => array(':currency' => get_currency_abbr($this->currency)), 'heading' => true);
     $data = array();
     $total = 0;
     foreach ($original['data'] as $key => $row) {
         foreach ($row as $i => $value) {
             $data[] = array($original['columns'][$i]['title'], currency_format($this->currency, $value, 4));
             $total += $value;
         }
     }
     // 'Total BTC' column
     $columns[] = array('type' => 'string', 'title' => currency_format($this->currency, $total, 4));
     // save for later
     $this->total = $total;
     return array('key' => $original['key'], 'columns' => $columns, 'data' => $data, 'last_updated' => $original['last_updated']);
 }
开发者ID:phpsource,项目名称:openclerk,代码行数:22,代码来源:CompositionTable.php

示例9: print_report

function print_report()
{
    $OUTPUT = clean_html(financialStatements::incomestmnt($_POST));
    switch ($_POST["key"]) {
        case ct("Print"):
            require "../tmpl-print.php";
            break;
        case ct("Save"):
            db_conn("core");
            $sql = "INSERT INTO save_income_stmnt (output, gendate, div) VALUES ('" . base64_encode($OUTPUT) . "', current_date, '" . USER_DIV . "')";
            $svincRslt = db_exec($sql) or errDie("Unable to save the balance sheet to Cubit.");
            return "<li class='err'>Income statement has been successfully saved to Cubit.</li>\n\t\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=25%>\n\t\t\t\t<tr><th>Quick Links</th></tr>\n\t\t\t\t<tr class=datacell><td align=center><a target=_blank href='../core/acc-new2.php'>Add account (New Window)</a></td></tr>\n\t\t\t\t<tr class=datacell><td align=center><a href='index-reports.php'>Financials</a></td></tr>\n\t\t\t\t<tr class=datacell><td align=center><a href='index-reports-stmnt.php'>Current Year Financial Statements</a></td></tr>\n\t\t\t\t<tr class=datacell><td align=center><a href='../main.php'>Main Menu</td></tr>\n\t\t\t</table>";
            break;
        case ct("Export to Spreadsheet"):
            require_lib("xls");
            StreamXLS("income_statement", $OUTPUT);
            break;
    }
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:19,代码来源:income-stmnt.php

示例10: getData

 public function getData($days)
 {
     $key_column = array('type' => 'string', 'title' => ct("Currency"));
     $columns = array();
     // get data
     // TODO could probably cache this
     $q = db()->prepare("SELECT SUM(balance) AS balance, exchange, MAX(created_at) AS created_at FROM balances WHERE user_id=? AND is_recent=1 AND currency=? GROUP BY exchange");
     $q->execute(array($this->getUser(), $this->currency));
     $balances = $q->fetchAll();
     // need to also get address balances
     $summary_balances = get_all_summary_instances($this->getUser());
     // get additional balances
     $data = array();
     if (isset($summary_balances['blockchain' . $this->currency]) && $summary_balances['blockchain' . $this->currency]['balance'] != 0) {
         $balances[] = array("balance" => $summary_balances['blockchain' . $this->currency]['balance'], "exchange" => "blockchain", "created_at" => $summary_balances['blockchain' . $this->currency]['created_at']);
     }
     if (isset($summary_balances['offsets' . $this->currency]) && $summary_balances['offsets' . $this->currency]['balance'] != 0) {
         $balances[] = array("balance" => $summary_balances['offsets' . $this->currency]['balance'], "exchange" => "offsets", "created_at" => $summary_balances['offsets' . $this->currency]['created_at']);
     }
     // sort by balance
     usort($balances, array($this, 'sort_by_balance_desc'));
     $last_updated = find_latest_created_at($balances);
     // apply demo_scale and calculate total summary
     $data = array();
     $total = 0;
     foreach ($balances as $b) {
         if ($b['balance'] != 0) {
             $columns[] = array('type' => 'number', 'title' => get_exchange_name($b['exchange']));
             $data[] = demo_scale($b['balance']);
             $total += demo_scale($b['balance']);
         }
     }
     // return a more helpful message if there is no data
     if (!$data) {
         throw new NoDataGraphException_AddAccountsAddresses();
     }
     // sort data by balance
     $data = array(get_currency_abbr($this->currency) => $data);
     return array('key' => $key_column, 'columns' => $columns, 'data' => $data, 'last_updated' => $last_updated);
 }
开发者ID:phpsource,项目名称:openclerk,代码行数:40,代码来源:CompositionPie.php

示例11: getData

 public function getData($days)
 {
     $key_column = array('type' => 'string', 'title' => ct("Currency"));
     $columns = array();
     // get all balances
     $balances = get_all_summary_instances($this->getUser());
     $last_updated = find_latest_created_at($balances, "total");
     // and convert them using the most recent rates
     $rates = get_all_recent_rates();
     // create data
     // TODO refactor this into generic any-currency balances
     $data = array();
     if (isset($balances['totalbtc']) && $balances['totalbtc']['balance'] != 0) {
         $columns[] = array('type' => 'number', 'title' => get_currency_abbr('btc'));
         $data[] = graph_number_format(demo_scale($balances['totalbtc']['balance']));
     }
     foreach (get_all_currencies() as $cur) {
         // if the key is a currency, use the same currency colour across all graphs (#293)
         $color = array_search($cur, get_all_currencies());
         if ($cur == 'btc') {
             continue;
         }
         if (!is_fiat_currency($cur) && isset($balances['total' . $cur]) && $balances['total' . $cur]['balance'] != 0 && isset($rates['btc' . $cur])) {
             $columns[] = array('type' => 'number', 'title' => get_currency_abbr($cur), 'color' => $color);
             $data[] = graph_number_format(demo_scale($balances['total' . $cur]['balance'] * $rates['btc' . $cur]['bid']));
         }
         if (is_fiat_currency($cur) && isset($balances['total' . $cur]) && $balances['total' . $cur]['balance'] != 0 && isset($rates[$cur . 'btc']) && $rates[$cur . 'btc']['ask']) {
             $columns[] = array('type' => 'number', 'title' => get_currency_abbr($cur), 'color' => $color);
             $data[] = graph_number_format(demo_scale($balances['total' . $cur]['balance'] / $rates[$cur . 'btc']['ask']));
         }
     }
     // display a helpful message if there's no data
     if (!$data) {
         throw new NoDataGraphException_AddAccountsAddresses();
     }
     // sort data by balance
     arsort($data);
     $data = array(get_currency_abbr('btc') => $data);
     return array('key' => $key_column, 'columns' => $columns, 'data' => $data, 'last_updated' => $last_updated);
 }
开发者ID:phpsource,项目名称:openclerk,代码行数:40,代码来源:EquivalentPieBTC.php

示例12: getData

 public function getData($days)
 {
     $key_column = array('type' => 'string', 'title' => ct("Currency"));
     $columns = array();
     $columns[] = array('type' => 'string', 'title' => ct("Currency"), 'heading' => true);
     $columns[] = array('type' => 'string', 'title' => ct("Total"));
     // a table of each currency
     // get all balances
     $balances = get_all_summary_instances($this->getUser());
     $summaries = get_all_summary_currencies($this->getUser());
     $currencies = get_all_currencies();
     $last_updated = find_latest_created_at($balances, "total");
     // create data
     $data = array();
     foreach ($currencies as $c) {
         if (isset($summaries[$c])) {
             $balance = isset($balances['total' . $c]) ? $balances['total' . $c]['balance'] : 0;
             $data[] = array("<span title=\"" . htmlspecialchars(get_currency_name($c)) . "\">" . get_currency_abbr($c) . "</span>", currency_format($c, demo_scale($balance), 4));
         }
     }
     return array('key' => $key_column, 'columns' => $columns, 'data' => $data, 'last_updated' => $last_updated, 'add_more_currencies' => true, 'no_header' => true);
 }
开发者ID:phpsource,项目名称:openclerk,代码行数:22,代码来源:BalancesTable.php

示例13: getData

 public function getData($days)
 {
     $key_column = array('type' => 'string', 'title' => ct("Currency"));
     $columns = array();
     $columns[] = array('type' => 'string', 'title' => ct("Exchange"), 'heading' => true);
     $columns[] = array('type' => 'string', 'title' => ct("Converted fiat"));
     // a table of each crypto2xxx value
     // get all balances
     $currencies = get_crypto_conversion_summary_types($this->getUser());
     $last_updated = false;
     // create data
     $data = array();
     foreach ($currencies as $key => $c) {
         $q = db()->prepare("SELECT * FROM summary_instances WHERE user_id=? AND summary_type=? AND is_recent=1");
         $q->execute(array($this->getUser(), "crypto2" . $key));
         if ($balance = $q->fetch()) {
             $data[] = array($c['short_title'], currency_format($c['currency'], demo_scale($balance['balance']), 4));
             $last_updated = max($last_updated, strtotime($balance['created_at']));
         }
     }
     return array('key' => $key_column, 'columns' => $columns, 'data' => $data, 'last_updated' => $last_updated, 'add_more_currencies' => true, 'no_header' => true);
 }
开发者ID:phpsource,项目名称:openclerk,代码行数:22,代码来源:CryptoConvertedTable.php

示例14: getData

 public function getData($days)
 {
     $columns = array();
     $key_column = array('type' => 'string', 'title' => ct("Key"));
     $columns[] = array('type' => 'string', 'title' => ct("Exchange"), 'heading' => true);
     $columns[] = array('type' => 'string', 'title' => ct("Price"));
     $columns[] = array('type' => 'string', 'title' => ct("Volume"));
     $q = db()->prepare("SELECT * FROM ticker_recent WHERE currency1=? AND currency2=? ORDER BY volume DESC");
     $q->execute(array($this->currency1, $this->currency2));
     $tickers = $q->fetchAll();
     $q = db()->prepare("SELECT * FROM average_market_count WHERE currency1=? AND currency2=?");
     $q->execute(array($this->currency1, $this->currency2));
     $market_count = $q->fetch();
     $average = false;
     foreach ($tickers as $ticker) {
         if ($ticker['exchange'] == 'average') {
             $average = $ticker;
         }
     }
     if (!$average) {
         throw new RenderGraphException(t("Could not find any average data"));
     }
     $volume_currency = $average['currency2'];
     // generate the table of data
     $data = array();
     foreach ($tickers as $ticker) {
         if ($ticker['exchange'] == "average") {
             continue;
         }
         if ($ticker['volume'] == 0) {
             continue;
         }
         $id = $ticker['exchange'] . "_" . $ticker['currency1'] . $ticker['currency2'] . "_daily";
         $data[$ticker['exchange']] = array("<a href=\"" . htmlspecialchars(url_for('historical', array('id' => $id, 'days' => 180))) . "\">" . get_exchange_name($ticker['exchange']) . "</a>", $this->average_currency_format_html($ticker['last_trade'], $ticker['last_trade']), currency_format($volume_currency, $ticker['volume'], 0) . " (" . ($average['volume'] == 0 ? "-" : number_format($ticker['volume'] * 100 / $average['volume']) . "%") . ")");
     }
     $last_updated = $average['created_at'];
     return array('key' => $key_column, 'columns' => $columns, 'data' => $data, 'last_updated' => $last_updated, 'h1' => get_currency_abbr($average['currency1']) . "/" . get_currency_abbr($average['currency2']) . ": " . currency_format($average['currency1'], $average['last_trade']), 'h2' => "(" . number_format($average['volume']) . " " . get_currency_abbr($volume_currency) . " total volume)");
 }
开发者ID:phpsource,项目名称:openclerk,代码行数:38,代码来源:AverageMarketData.php

示例15: getData

 public function getData($days)
 {
     $columns = array();
     $key_column = array('type' => 'date', 'title' => ct("Date"));
     $columns = $this->getTickerColumns();
     // TODO extra_days_necessary
     $extra_days = 10;
     $sources = $this->getTickerSources($days, $extra_days);
     $args = $this->getTickerArgs();
     $data = array();
     $last_updated = false;
     foreach ($sources as $source) {
         $q = db()->prepare($source['query']);
         $q->execute($args);
         while ($ticker = $q->fetch()) {
             $data_key = date($this->isDaily() ? 'Y-m-d' : 'Y-m-d H:i:s', strtotime($ticker[$source['key']]));
             $data[$data_key] = $this->getTickerData($ticker);
             $last_updated = max($last_updated, strtotime($ticker['created_at']));
         }
     }
     // sort by key, but we only want values
     uksort($data, 'cmp_time_reverse');
     return array('key' => $key_column, 'columns' => $columns, 'data' => $data, 'last_updated' => $last_updated);
 }
开发者ID:phpsource,项目名称:openclerk,代码行数:24,代码来源:AbstractTicker.php


注:本文中的ct函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。