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


PHP Feed::get_field方法代码示例

本文整理汇总了PHP中Feed::get_field方法的典型用法代码示例。如果您正苦于以下问题:PHP Feed::get_field方法的具体用法?PHP Feed::get_field怎么用?PHP Feed::get_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Feed的用法示例。


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

示例1: feed_controller

function feed_controller()
{
    global $mysqli, $redis, $session, $route, $feed_settings;
    $result = false;
    require_once "Modules/feed/feed_model.php";
    $feed = new Feed($mysqli, $redis, $feed_settings);
    if ($route->format == 'html') {
        if ($route->action == "list" && $session['write']) {
            $result = view("Modules/feed/Views/feedlist_view.php", array());
        } else {
            if ($route->action == "api" && $session['write']) {
                $result = view("Modules/feed/Views/feedapi_view.php", array());
            }
        }
    } else {
        if ($route->format == 'json') {
            // Public actions available on public feeds.
            if ($route->action == "list") {
                if ($session['read']) {
                    if (!isset($_GET['userid']) || isset($_GET['userid']) && $_GET['userid'] == $session['userid']) {
                        $result = $feed->get_user_feeds($session['userid']);
                    } else {
                        if (isset($_GET['userid']) && $_GET['userid'] != $session['userid']) {
                            $result = $feed->get_user_public_feeds(get('userid'));
                        }
                    }
                } else {
                    if (isset($_GET['userid'])) {
                        $result = $feed->get_user_public_feeds(get('userid'));
                    }
                }
            } elseif ($route->action == "create" && $session['write']) {
                $result = $feed->create($session['userid'], get('tag'), get('name'), get('datatype'), get('engine'), json_decode(get('options')));
            } elseif ($route->action == "updatesize" && $session['write']) {
                $result = $feed->update_user_feeds_size($session['userid']);
            } elseif ($route->action == "buffersize" && $session['write']) {
                $result = $feed->get_buffer_size();
                // To "fetch" multiple feed values in a single request
                // http://emoncms.org/feed/fetch.json?ids=123,567,890
            } elseif ($route->action == "fetch" && $session['read']) {
                $feedids = (array) explode(",", get('ids'));
                for ($i = 0; $i < count($feedids); $i++) {
                    $feedid = (int) $feedids[$i];
                    if ($feed->exist($feedid)) {
                        // if the feed exists
                        $result[$i] = $feed->get_value($feedid);
                        // null is a valid response
                    } else {
                        $result[$i] = false;
                    }
                    // false means feed not found
                }
            } else {
                $feedid = (int) get('id');
                // Actions that operate on a single existing feed that all use the feedid to select:
                // First we load the meta data for the feed that we want
                if ($feed->exist($feedid)) {
                    $f = $feed->get($feedid);
                    // if public or belongs to user
                    if ($f['public'] || $session['userid'] > 0 && $f['userid'] == $session['userid'] && $session['read']) {
                        if ($route->action == "timevalue") {
                            $result = $feed->get_timevalue($feedid);
                        } else {
                            if ($route->action == 'data') {
                                $skipmissing = 1;
                                $limitinterval = 1;
                                if (isset($_GET['skipmissing']) && $_GET['skipmissing'] == 0) {
                                    $skipmissing = 0;
                                }
                                if (isset($_GET['limitinterval']) && $_GET['limitinterval'] == 0) {
                                    $limitinterval = 0;
                                }
                                $result = $feed->get_data($feedid, get('start'), get('end'), get('interval'), $skipmissing, $limitinterval);
                            } else {
                                if ($route->action == "value") {
                                    $result = $feed->get_value($feedid);
                                } else {
                                    if ($route->action == "get") {
                                        $result = $feed->get_field($feedid, get('field'));
                                    } else {
                                        if ($route->action == "aget") {
                                            $result = $feed->get($feedid);
                                        } else {
                                            if ($route->action == 'histogram') {
                                                $result = $feed->histogram_get_power_vs_kwh($feedid, get('start'), get('end'));
                                            } else {
                                                if ($route->action == 'kwhatpower') {
                                                    $result = $feed->histogram_get_kwhd_atpower($feedid, get('min'), get('max'));
                                                } else {
                                                    if ($route->action == 'kwhatpowers') {
                                                        $result = $feed->histogram_get_kwhd_atpowers($feedid, get('points'));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
//.........这里部分代码省略.........
开发者ID:ashokbasnet,项目名称:emoncms,代码行数:101,代码来源:feed_controller.php

示例2: vis_controller

function vis_controller()
{
    global $mysqli, $redis, $session, $route, $user, $feed_settings;
    $result = false;
    require "Modules/feed/feed_model.php";
    $feed = new Feed($mysqli, $redis, $feed_settings);
    require "Modules/vis/multigraph_model.php";
    $multigraph = new Multigraph($mysqli);
    $visdir = "vis/visualisations/";
    require "Modules/vis/vis_object.php";
    $write_apikey = "";
    $read_apikey = "";
    if ($session['read']) {
        $read_apikey = $user->get_apikey_read($session['userid']);
    }
    if ($session['write']) {
        $write_apikey = $user->get_apikey_write($session['userid']);
    }
    if ($route->format == 'html') {
        if ($route->action == 'list' && $session['write']) {
            $multigraphs = $multigraph->getlist($session['userid']);
            $feedlist = $feed->get_user_feeds($session['userid']);
            $result = view("Modules/vis/Views/vis_main_view.php", array('user' => $user->get($session['userid']), 'feedlist' => $feedlist, 'apikey' => $read_apikey, 'visualisations' => $visualisations, 'multigraphs' => $multigraphs));
        } else {
            if ($route->action == "auto") {
                $feedid = intval(get('feedid'));
                $datatype = $feed->get_field($feedid, 'datatype');
                if ($datatype == 0) {
                    $result = "Feed type or authentication not valid";
                }
                if ($datatype == 1) {
                    $route->action = 'graph';
                }
                if ($datatype == 2) {
                    $route->action = 'bargraph';
                }
                if ($datatype == 3) {
                    $route->action = 'histgraph';
                }
            }
        }
        while ($vis = current($visualisations)) {
            $viskey = key($visualisations);
            // If the visualisation has a set property called action
            // then override the visualisation key and use the set action instead
            if (isset($vis['action'])) {
                $viskey = $vis['action'];
            }
            if ($route->action == $viskey) {
                $array = array();
                $array['valid'] = true;
                if (isset($vis['options'])) {
                    foreach ($vis['options'] as $option) {
                        $key = $option[0];
                        $type = $option[2];
                        if (isset($option[3])) {
                            $default = $option[3];
                        } else {
                            $default = "";
                        }
                        if ($type == 0 || $type == 1 || $type == 2 || $type == 3) {
                            $feedid = (int) get($key);
                            if ($feedid) {
                                $f = $feed->get($feedid);
                                $array[$key] = $feedid;
                                $array[$key . 'name'] = $f['name'];
                                if ($f['userid'] != $session['userid']) {
                                    $array['valid'] = false;
                                }
                                if ($f['public']) {
                                    $array['valid'] = true;
                                }
                            } else {
                                $array['valid'] = false;
                            }
                        } else {
                            if ($type == 4) {
                                // Boolean not used at the moment
                                if (get($key) == true || get($key) == false) {
                                    $array[$key] = get($key);
                                } else {
                                    $array[$key] = $default;
                                }
                            } else {
                                if ($type == 5) {
                                    $array[$key] = preg_replace('/[^\\p{L}_\\p{N}\\s£$€¥]/u', '', get($key)) ? get($key) : $default;
                                } else {
                                    if ($type == 6) {
                                        $array[$key] = str_replace(',', '.', floatval(get($key) ? get($key) : $default));
                                    } else {
                                        if ($type == 7) {
                                            $array[$key] = intval(get($key) ? get($key) : $default);
                                        } else {
                                            if ($type == 8) {
                                                $mid = (int) get($key);
                                                if ($mid) {
                                                    $f = $multigraph->get($mid, $session['userid']);
                                                    $array[$key] = intval($mid ? $mid : $default);
                                                    if (!isset($f['feedlist'])) {
                                                        $array['valid'] = false;
//.........这里部分代码省略.........
开发者ID:jpsingleton,项目名称:emoncms,代码行数:101,代码来源:vis_controller.php

示例3: vis_controller

function vis_controller()
{
    global $mysqli, $redis, $session, $route, $user, $feed_settings;
    $result = false;
    require "Modules/feed/feed_model.php";
    $feed = new Feed($mysqli, $redis, $feed_settings);
    require "Modules/vis/multigraph_model.php";
    $multigraph = new Multigraph($mysqli);
    $visdir = "vis/visualisations/";
    require "Modules/vis/vis_object.php";
    $write_apikey = "";
    $read_apikey = "";
    if ($session['read']) {
        $read_apikey = $user->get_apikey_read($session['userid']);
    }
    if ($session['write']) {
        $write_apikey = $user->get_apikey_write($session['userid']);
    }
    if ($route->format == 'html') {
        if ($route->action == 'list' && $session['write']) {
            $multigraphs = $multigraph->getlist($session['userid']);
            $feedlist = $feed->get_user_feeds($session['userid']);
            $result = view("Modules/vis/vis_main_view.php", array('user' => $user->get($session['userid']), 'feedlist' => $feedlist, 'apikey' => $read_apikey, 'visualisations' => $visualisations, 'multigraphs' => $multigraphs));
        }
        // Auto - automatically selects visualisation based on datatype
        // and is used primarily for quick checking feeds from the feeds page.
        if ($route->action == "auto") {
            $feedid = intval(get('feedid'));
            $datatype = $feed->get_field($feedid, 'datatype');
            if ($datatype == 0) {
                $result = "Feed type or authentication not valid";
            }
            if ($datatype == 1) {
                $route->action = 'rawdata';
            }
            if ($datatype == 2) {
                $route->action = 'bargraph';
            }
            if ($datatype == 3) {
                $route->action = 'histgraph';
            }
        }
        while ($vis = current($visualisations)) {
            $viskey = key($visualisations);
            // If the visualisation has a set property called action
            // then override the visualisation key and use the set action instead
            if (isset($vis['action'])) {
                $viskey = $vis['action'];
            }
            if ($route->action == $viskey) {
                $array = array();
                $array['valid'] = true;
                if (isset($vis['options'])) {
                    foreach ($vis['options'] as $option) {
                        $key = $option[0];
                        $type = $option[1];
                        if (isset($option[2])) {
                            $default = $option[2];
                        } else {
                            $default = "";
                        }
                        if ($type == 0 || $type == 1 || $type == 2 || $type == 3) {
                            $feedid = (int) get($key);
                            if ($feedid) {
                                $f = $feed->get($feedid);
                                $array[$key] = $feedid;
                                $array[$key . 'name'] = $f['name'];
                                if ($f['userid'] != $session['userid']) {
                                    $array['valid'] = false;
                                }
                                if ($f['public']) {
                                    $array['valid'] = true;
                                }
                            } else {
                                $array['valid'] = false;
                            }
                        }
                        // Boolean not used at the moment
                        if ($type == 4) {
                            if (get($key) == true || get($key) == false) {
                                $array[$key] = get($key);
                            } else {
                                $array[$key] = $default;
                            }
                        }
                        if ($type == 5) {
                            $array[$key] = preg_replace('/[^\\w\\s£$€¥]/', '', get($key)) ? get($key) : $default;
                        }
                        if ($type == 6) {
                            $array[$key] = str_replace(',', '.', floatval(get($key) ? get($key) : $default));
                        }
                        if ($type == 7) {
                            $array[$key] = intval(get($key) ? get($key) : $default);
                        }
                        # we need to either urlescape the colour, or just scrub out invalid chars. I'm doing the second, since
                        # we can be fairly confident that colours are eiter a hex or a simple word (e.g. "blue" or such)
                        if ($key == "colour") {
                            $array[$key] = preg_replace('/[^\\dA-Za-z]/', '', $array[$key]);
                        }
                    }
//.........这里部分代码省略.........
开发者ID:UbiCollab,项目名称:PersuasiveCommunities,代码行数:101,代码来源:vis_controller.php

示例4: feed_controller

function feed_controller()
{
    global $mysqli, $redis, $session, $route, $feed_settings;
    $result = false;
    include "Modules/feed/feed_model.php";
    $feed = new Feed($mysqli, $redis, $feed_settings);
    if ($route->format == 'html') {
        if ($route->action == "list" && $session['write']) {
            $result = view("Modules/feed/Views/feedlist_view.php", array());
        }
        if ($route->action == "api" && $session['write']) {
            $result = view("Modules/feed/Views/feedapi_view.php", array());
        }
    }
    if ($route->format == 'json') {
        // Public actions available on public feeds.
        if ($route->action == "list") {
            if (!isset($_GET['userid']) && $session['read']) {
                $result = $feed->get_user_feeds($session['userid']);
            }
            if (isset($_GET['userid']) && $session['read'] && $_GET['userid'] == $session['userid']) {
                $result = $feed->get_user_feeds($session['userid']);
            }
            if (isset($_GET['userid']) && $session['read'] && $_GET['userid'] != $session['userid']) {
                $result = $feed->get_user_public_feeds(get('userid'));
            }
            if (isset($_GET['userid']) && !$session['read']) {
                $result = $feed->get_user_public_feeds(get('userid'));
            }
        } elseif ($route->action == "getid" && $session['read']) {
            $result = $feed->get_id($session['userid'], get('name'));
        } elseif ($route->action == "create" && $session['write']) {
            $result = $feed->create($session['userid'], get('name'), get('datatype'), get('engine'), json_decode(get('options')));
        } elseif ($route->action == "updatesize" && $session['write']) {
            $result = $feed->update_user_feeds_size($session['userid']);
            // To "fetch" multiple feed values in a single request
            // http://emoncms.org/feed/fetch.json?ids=123,567,890
        } elseif ($route->action == "fetch" && $session['read']) {
            $feedids = (array) explode(",", get('ids'));
            for ($i = 0; $i < count($feedids); $i++) {
                $feedid = (int) $feedids[$i];
                if ($feed->exist($feedid)) {
                    $result[$i] = (double) $feed->get_value($feedid);
                } else {
                    $result[$i] = "";
                }
            }
        } else {
            $feedid = (int) get('id');
            // Actions that operate on a single existing feed that all use the feedid to select:
            // First we load the meta data for the feed that we want
            if ($feed->exist($feedid)) {
                $f = $feed->get($feedid);
                // if public or belongs to user
                if ($f['public'] || $session['userid'] > 0 && $f['userid'] == $session['userid'] && $session['read']) {
                    if ($route->action == "value") {
                        $result = $feed->get_value($feedid);
                    }
                    if ($route->action == "timevalue") {
                        $result = $feed->get_timevalue_seconds($feedid);
                    }
                    if ($route->action == "get") {
                        $result = $feed->get_field($feedid, get('field'));
                    }
                    // '/[^\w\s-]/'
                    if ($route->action == "aget") {
                        $result = $feed->get($feedid);
                    }
                    if ($route->action == 'histogram') {
                        $result = $feed->histogram_get_power_vs_kwh($feedid, get('start'), get('end'));
                    }
                    if ($route->action == 'kwhatpower') {
                        $result = $feed->histogram_get_kwhd_atpower($feedid, get('min'), get('max'));
                    }
                    if ($route->action == 'kwhatpowers') {
                        $result = $feed->histogram_get_kwhd_atpowers($feedid, get('points'));
                    }
                    if ($route->action == 'data') {
                        $result = $feed->get_data($feedid, get('start'), get('end'), get('dp'));
                    }
                    if ($route->action == 'average') {
                        $result = $feed->get_average($feedid, get('start'), get('end'), get('interval'));
                    }
                    if ($route->action == 'history') {
                        $result = $feed->get_history($feedid, get('start'), get('end'), get('interval'));
                    }
                }
                // write session required
                if (isset($session['write']) && $session['write'] && $session['userid'] > 0 && $f['userid'] == $session['userid']) {
                    // Storage engine agnostic
                    if ($route->action == 'set') {
                        $result = $feed->set_feed_fields($feedid, get('fields'));
                    }
                    if ($route->action == "insert") {
                        $result = $feed->insert_data($feedid, time(), get("time"), get("value"));
                    }
                    if ($route->action == "update") {
                        $result = $feed->update_data($feedid, time(), get("time"), get('value'));
                    }
                    if ($route->action == "delete") {
//.........这里部分代码省略.........
开发者ID:barriquello,项目名称:simon,代码行数:101,代码来源:feed_controller.php

示例5: vis_controller

function vis_controller()
{
    global $mysqli, $redis, $session, $route, $user, $settings;
    $result = false;
    require "Modules/feed/feed_model.php";
    $feed = new Feed($mysqli, $redis, $settings);
    require "Modules/vis/multigraph_model.php";
    $multigraph = new Multigraph($mysqli);
    $visdir = "vis/visualisations/";
    /*
      1 - realtime
      2 - daily
      3 - histogram
      4 - boolean (not used uncomment line 122)
      5 - text
      6 - float value
      7 - int value
    */
    $visualisations = array('realtime' => array('options' => array(array('feedid', 1))), 'rawdata' => array('options' => array(array('feedid', 1), array('fill', 7, 0), array('units', 5, 'W'), array('colour', 5, 'EDC240'))), 'bargraph' => array('options' => array(array('feedid', 2), array('colour', 5, 'EDC240'))), 'timestoredaily' => array('options' => array(array('feedid', 1), array('units', 5, 'kWh'))), 'smoothie' => array('options' => array(array('feedid', 1), array('ufac', 6))), 'histgraph' => array('options' => array(array('feedid', 3), array('barwidth', 7, 50), array('start', 7, 0), array('end', 7, 0))), 'zoom' => array('options' => array(array('power', 1), array('kwhd', 2), array('currency', 5, '&pound;'), array('currency_after_val', 7, 0), array('pricekwh', 6, 0.14))), 'stacked' => array('options' => array(array('bottom', 2), array('top', 2))), 'stackedsolar' => array('options' => array(array('solar', 2), array('consumption', 2))), 'threshold' => array('options' => array(array('feedid', 3), array('thresholdA', 6, 500), array('thresholdB', 6, 2500))), 'simplezoom' => array('options' => array(array('power', 1), array('kwhd', 2))), 'orderbars' => array('options' => array(array('feedid', 2))), 'orderthreshold' => array('options' => array(array('feedid', 3), array('power', 1), array('thresholdA', 6, 500), array('thresholdB', 6, 2500))), 'editrealtime' => array('options' => array(array('feedid', 1))), 'editdaily' => array('options' => array(array('feedid', 2))), 'multigraph' => array('action' => 'multigraph', 'options' => array(array('mid', 7))), 'compare' => array('action' => 'compare', 'options' => array(array('powerx', 1), array('powery', 1))));
    $write_apikey = "";
    $read_apikey = "";
    if ($session['read']) {
        $read_apikey = $user->get_apikey_read($session['userid']);
    }
    if ($session['write']) {
        $write_apikey = $user->get_apikey_write($session['userid']);
    }
    if ($route->format == 'html') {
        if ($route->action == 'list' && $session['write']) {
            $multigraphs = $multigraph->getlist($session['userid']);
            $feedlist = $feed->get_user_feeds($session['userid']);
            $result = view("Modules/vis/vis_main_view.php", array('user' => $user->get($session['userid']), 'feedlist' => $feedlist, 'apikey' => $read_apikey, 'visualisations' => $visualisations, 'multigraphs' => $multigraphs));
        }
        // Auto - automatically selects visualisation based on datatype
        // and is used primarily for quick checking feeds from the feeds page.
        if ($route->action == "auto") {
            $feedid = intval(get('feedid'));
            $datatype = $feed->get_field($feedid, 'datatype');
            if ($datatype == 0) {
                $result = "Feed type or authentication not valid";
            }
            if ($datatype == 1) {
                $route->action = 'rawdata';
            }
            if ($datatype == 2) {
                $route->action = 'bargraph';
            }
            if ($datatype == 3) {
                $route->action = 'histgraph';
            }
        }
        while ($vis = current($visualisations)) {
            $viskey = key($visualisations);
            // If the visualisation has a set property called action
            // then override the visualisation key and use the set action instead
            if (isset($vis['action'])) {
                $viskey = $vis['action'];
            }
            if ($route->action == $viskey) {
                $array = array();
                $array['valid'] = true;
                if (isset($vis['options'])) {
                    foreach ($vis['options'] as $option) {
                        $key = $option[0];
                        $type = $option[1];
                        if (isset($option[2])) {
                            $default = $option[2];
                        } else {
                            $default = "";
                        }
                        if ($type == 1 || $type == 2 || $type == 3) {
                            $feedid = (int) get($key);
                            if ($feedid) {
                                $f = $feed->get($feedid);
                                $array[$key] = $feedid;
                                $array[$key . 'name'] = $f['name'];
                                if ($f['userid'] != $session['userid'] || $f['datatype'] != $type) {
                                    $array['valid'] = false;
                                }
                                if ($f['public'] && $f['datatype'] == $type) {
                                    $array['valid'] = true;
                                }
                            } else {
                                $array['valid'] = false;
                            }
                        }
                        // Boolean not used at the moment
                        if ($type == 4) {
                            if (get($key) == true || get($key) == false) {
                                $array[$key] = get($key);
                            } else {
                                $array[$key] = $default;
                            }
                        }
                        if ($type == 5) {
                            $array[$key] = preg_replace('/[^\\w\\s£$€¥]/', '', get($key)) ? get($key) : $default;
                        }
                        if ($type == 6) {
                            $array[$key] = str_replace(',', '.', floatval(get($key) ? get($key) : $default));
                        }
//.........这里部分代码省略.........
开发者ID:kenpi2b,项目名称:pkg-emoncms,代码行数:101,代码来源:vis_controller.php


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