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


PHP h2o::addTag方法代码示例

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


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

示例1: should_be_able_to_register_tag_using_alias

 public function should_be_able_to_register_tag_using_alias()
 {
     h2o::addTag(array('sample' => 'Sample_Tag', 's' => 'Sample_Tag'));
     expects(h2o::$tags)->should_contain('Sample_Tag');
     expects(isset(h2o::$tags['s']))->should_be_true();
     unset(h2o::$tags['sample'], h2o::$tags['s']);
     h2o::addTag(array('sample', 's' => 'Sample_Tag'));
     expects(h2o::$tags)->should_contain('Sample_Tag');
     expects(isset(h2o::$tags['s']))->should_be_true();
     unset(h2o::$tags['sample'], h2o::$tags['s']);
 }
开发者ID:tonjoo,项目名称:tiga-framework,代码行数:11,代码来源:h2o_spec.php

示例2: render

<?php

class Site_Tag extends Tag
{
    function render($context, $stream)
    {
        $stream->write('This is my site');
    }
}
h2o::addTag('site');
开发者ID:paudebau,项目名称:h2o-php,代码行数:10,代码来源:site_tags.php

示例3: render

        }
        return $images;
    }
    function render($context, $stream)
    {
        $cache = h2o_cache($context->options);
        $term = $context->resolve(':term');
        $hack = $context->resolve(':hack');
        $url = $this->get_api_url($term, $hack);
        $feed = @$this->fetch($context, $url);
        $feed = @$this->filter($feed);
        $context->set("images", $feed);
        $context->set("is_single_image", $this->is_single_image());
    }
    function fix_json($j)
    {
        $j = trim($j);
        $j = ltrim($j, '(');
        $j = rtrim($j, ')');
        $a = preg_split('#(?<!\\\\)\\"#', $j);
        for ($i = 0; $i < count($a); $i += 2) {
            $s = $a[$i];
            $s = preg_replace('#([^\\s\\[\\]\\{\\}\\:\\,]+):#', '"\\1":', $s);
            $a[$i] = $s;
        }
        $j = implode('"', $a);
        return $j;
    }
}
h2o::addTag('image');
开发者ID:gigikiri,项目名称:wpagczone,代码行数:30,代码来源:image.php

示例4: render

        }
        return $filtered_feed;
    }
    function render($context, $stream)
    {
        $cache = h2o_cache($context->options);
        $term = $context->resolve(':term');
        $hack = $context->resolve(':hack');
        $url = $this->get_api_url($term, $hack);
        $feed = @$this->fetch($context, $url)->xpath('//channel/item');
        $feed = @$this->filter($feed);
        $context->set("api", $feed);
        $context->set("api_url", $url);
    }
}
h2o::addTag('api');
function filter_bad_words($content)
{
    global $spp_settings;
    $bad_words = explode(',', $spp_settings->bad_words);
    foreach ($bad_words as $word) {
        // mulai ubah konten
        $content = str_ireplace($word . ' ', '', $content);
        $content = str_ireplace(' ' . $word . ' ', '', $content);
        $content = str_ireplace(' ' . $word, '', $content);
        $content = str_ireplace($word, '.', $content);
        $content = str_ireplace($word, ',', $content);
        $content = str_ireplace($word, '-', $content);
    }
    return $content;
}
开发者ID:jensonbetrail,项目名称:wordpress,代码行数:31,代码来源:api.php

示例5: TemplateSyntaxError

    {
        if (!empty($argstring) && !preg_match($this->syntax, $argstring)) {
            throw TemplateSyntaxError('Please specify time to live value for this cache block');
        }
        $this->body = $parser->parse('endcache');
        $this->uid = md5($parser->filename . $pos);
        $this->ttl = (int) $argstring;
        $options = $parser->options;
        if ($this->ttl) {
            $options['cache_ttl'] = $this->ttl;
        }
        if (!$options['cache']) {
            $options['cache'] = 'file';
        }
        $this->cache = h2o_cache($options);
    }
    function render($context, $stream)
    {
        if ($output = $this->cache->read($this->uid)) {
            $stream->write($output);
            return;
        }
        $output = new StreamWriter();
        $this->body->render($context, $output);
        $output = $output->close();
        $this->cache->write($this->uid, $output);
        $stream->write($output);
    }
}
h2o::addTag('cache');
开发者ID:nielsvm,项目名称:lxc-containers,代码行数:30,代码来源:cache.php

示例6: call_user_func_array

                        if (method_exists($obj, $attribute)) {
                            $obj = call_user_func_array(array($obj, $attribute), array());
                        } else {
                            if (method_exists($obj, "get_" . $attribute)) {
                                $obj = call_user_func_array(array($obj, "get_" . $attribute), array());
                            } else {
                                if (method_exists($obj, "is_" . $attribute)) {
                                    $obj = call_user_func_array(array($obj, "is_" . $attribute), array());
                                } else {
                                    $obj = null;
                                }
                            }
                        }
                    }
                } else {
                    $obj = null;
                    break;
                }
            }
        }
    }
    return $obj;
}
h2o::addTag(array("sqlvalue"));
h2o::addTag(array("sparqlvalue"));
h2o::addTag(array("tplnotice"));
h2o::addFilter(array('pmb_StringFilters'));
h2o::addFilter(array('pmb_DateFilters'));
H2o::addLookup("messagesLookup");
H2o::addLookup("globalLookup");
H2o::addLookup("recursive_lookup");
开发者ID:noble82,项目名称:proyectos-ULS,代码行数:31,代码来源:pmb_h2o.inc.php

示例7: TemplateSyntaxError

<?php

h2o::addTag('lorem');
class Lorem_Tag extends H2o_Node
{
    private $common = true;
    private $syntax = '/^(\\d+)?(?:\\s+(p|w))?(?:\\s?(random))?$/i';
    var $hint = "{% lorem [count] [format] [random]%}";
    function __construct($argstring, $parser, $position = 0)
    {
        if (!preg_match($this->syntax, trim($argstring), $match)) {
            throw new TemplateSyntaxError($this->hint);
        }
        @(list(, $count, $mode, $random) = $match);
        $this->count = $count ? $count : 1;
        $this->mode = $mode ? $mode : 'p';
        $this->common = !$random;
    }
    function render($context, $stream)
    {
        $output = '';
        switch ($this->mode) {
            case 'w':
                $output = lorem_words($this->count);
                break;
            case 'p':
                $output = "<p>" . join("</p>\n<p>", lorem_paragraphs($this->count, $this->common)) . '</p>';
                break;
        }
        $stream->write($output);
    }
开发者ID:herlambang,项目名称:h2o-php,代码行数:31,代码来源:design.php

示例8: render

<?php

# For compatibility with Django.
class Admin_media_prefix_Tag extends H2o_Node
{
    function render($context, $stream)
    {
        $stream->write("/media/");
    }
}
h2o::addTag('admin_media_prefix');
开发者ID:nielsvm,项目名称:lxc-containers,代码行数:11,代码来源:adminmedia.php

示例9: stripcslashes

<?php

h2o::addTag('trans');
h2o::addTag('blocktrans');
h2o::addLookup(array('H2o_I18n', 'gettext'));
class Trans_Tag extends H2o_Node
{
    var $text = null;
    function __construct($argstring, $parser, $position = 0)
    {
        $this->args = H2o_Parser::parseArguments($argstring);
        $this->text = stripcslashes(substr($argstring, 1, -1));
    }
    function render($context, $stream)
    {
        $argPrefix = substr($this->args[0], 0, 1);
        if ($argPrefix == ':') {
            $message = $context->resolve($this->args[0]);
        } else {
            $message = $this->text;
            $message = str_replace("'", '', $message);
            $message = str_replace('"', '', $message);
        }
        if ($message) {
            $stream->write(pjango_gettext($message));
        }
    }
}
class Blocktrans_Tag extends H2o_Node
{
    private $singular, $plural;
开发者ID:hbasria,项目名称:pjango,代码行数:31,代码来源:i18n.php

示例10: __construct

    }
    function __construct($argstring, $parser, $pos = 0)
    {
        list($this->term, $this->hack) = explode(' ', $argstring);
    }
    function get_api_url($term = 'hello world', $hack = "")
    {
        $term .= " " . $hack;
        $term = urlencode($term);
        return "http://www.bing.com/search?q={$term}&format=rss";
    }
    function fetch($context, $url)
    {
        $this->url = $url;
        $feed = @file_get_contents($this->url);
        $feed = @simplexml_load_string($feed);
        return $feed;
    }
    function render($context, $stream)
    {
        $cache = h2o_cache($context->options);
        $term = $context->resolve(':term');
        $hack = 'site:youtube.com';
        $url = $this->get_api_url($term, $hack);
        $feed = @$this->fetch($context, $url)->xpath('//channel/item');
        $context->set("videos", $feed);
        $context->set("is_single_video", $this->is_single_video());
    }
}
h2o::addTag('video');
开发者ID:gigikir,项目名称:adebe,代码行数:30,代码来源:video.php

示例11: explode

<?php

h2o::addTag('gravatar');
class Gravatar_Tag extends H2o_Node
{
    private $email;
    private $img_size;
    function __construct($argstring, $parser, $pos = 0)
    {
        if (!empty($argstring)) {
            $args = explode(" ", trim($argstring));
            $this->email = strtolower($args[0]);
            $this->img_size = $args[1] ? $args[1] : 80;
            if (is_numeric($this->email)) {
                $this->img_size = $this->email;
                $this->email = '';
            }
            /*
             * TODO Fix to manage custom default image
             */
        } else {
            $this->img_size = 80;
        }
    }
    function render($context, $stream)
    {
        $context->push();
        if (substr($this->email, 0, 1) == ":") {
            $this->email = $context->resolve($this->email);
        }
        $output = '<img src="http://www.gravatar.com/avatar/' . (!empty($this->email) ? md5($this->email) . '.jpg' : '') . '?s=' . $this->img_size . '" alt="gravatar-image"/>';
开发者ID:jouvent,项目名称:Genitura,代码行数:31,代码来源:gravatar.php

示例12: __construct

            $context->set($this->struct_name, 0);
        }
    }
}
class Sparqlvalue_Tag extends H2o_Node
{
    private $struct_name;
    private $endpoint;
    function __construct($argstring, $parser, $position)
    {
        $params = explode(" ", $argstring);
        $this->struct_name = $params[0];
        $this->endpoint = $params[1];
        $this->sparql_query = $parser->parse('endsparqlvalue');
    }
    function render($context, $stream)
    {
        global $dbh;
        global $class_path;
        $query_stream = new StreamWriter();
        $this->sparql_query->render($context, $query_stream);
        $query = $query_stream->close();
        require_once "{$class_path}/rdf/arc2/ARC2.php";
        $config = array('remote_store_endpoint' => $this->endpoint, 'remote_store_timeout' => 10);
        $store = ARC2::getRemoteStore($config);
        $context->set($this->struct_name, $store->query($query, 'rows'));
    }
}
h2o::addTag(array("sqlvalue"));
h2o::addTag(array("sparqlvalue"));
h2o::addFilter(array('pmb_StringFilters'));
开发者ID:bouchra012,项目名称:PMB,代码行数:31,代码来源:pmb_h2o.inc.php


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