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


PHP h2o类代码示例

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


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

示例1: spp_random_terms_func

function spp_random_terms_func($atts)
{
    extract(shortcode_atts(array('count' => 10), $atts));
    global $spp_settings;
    global $wpdb;
    // SELECT * FROM myTable WHERE RAND()<(SELECT ((30/COUNT(*))*10) FROM myTable) ORDER BY RAND() LIMIT 30;
    $sql = "SELECT `term` FROM `" . $wpdb->prefix . "spp` WHERE RAND()<(SELECT ((" . $count . "/COUNT(`term`))*10) FROM `" . $wpdb->prefix . "spp`) ORDER BY RAND() LIMIT " . $count . ";";
    $searchterms = $wpdb->get_results($sql);
    if (!empty($searchterms) && count($searchterms) > 100) {
        $terms = array();
        foreach ($searchterms as $term) {
            $terms[] = $term->term;
        }
    } else {
        $file = @file_get_contents(SPP_PATH . '/keywords.txt');
        if ($file) {
            $terms = explode("\n", $file);
            shuffle($terms);
            $terms = array_slice($terms, 0, $count);
        } else {
            $terms = array();
        }
    }
    $result = new h2o(SPP_PATH . "/templates/widget.html");
    return $result->render(array('terms' => $terms, 'settings' => $spp_settings));
}
开发者ID:gigikiri,项目名称:wpagczone,代码行数:26,代码来源:random-terms.php

示例2: renderEmail

 /**
  * Render template with variables for sending in an email
  *
  * @param $template
  * @param $page
  * @return string
  */
 static function renderEmail($template, $page)
 {
     // H2o object for rendering
     $h2o = new h2o(null, array('autoescape' => false));
     // Load template and render it
     $h2o->loadTemplate(__DIR__ . '/../views/' . $template);
     return $h2o->render(compact('page'));
 }
开发者ID:Outlaw11A,项目名称:SDP2015,代码行数:15,代码来源:Notification.php

示例3: renderException

 function renderException($data, $template = "")
 {
     if (DEBUG) {
         $template = "exception.html";
         $template_paths = array(dirname(__FILE__) . '/templates/');
         $h2o = new h2o($template, array('searchpath' => $template_paths, 'cache' => false));
         echo $h2o->render($data);
     } else {
     }
 }
开发者ID:JSilva,项目名称:BareBones,代码行数:10,代码来源:TemplateManager.php

示例4: render

 public function render($template, $vars)
 {
     $registry = Registry::getInstance();
     require_once join_path($registry->web_root, 'system/template/h2o.php');
     $path = join_path($registry->web_root, 'view/' . $template . '.html');
     if (!file_exists($path)) {
         trigger_error('Template: View ' . $path . ' not found!');
     }
     $vars = array_merge($vars, array('config' => $registry));
     $h2o = new h2o($path, array('cache' => 'apc', 'safeClass' => array('V7F\\Helpers\\Registry', 'V7F\\Template\\Template_Helpers')));
     echo $h2o->render($vars);
 }
开发者ID:hemantshekhawat,项目名称:Snippets,代码行数:12,代码来源:template.php

示例5: render

 public function render()
 {
     if (!isset($_COOKIE['lang'])) {
         $lang = 'fr';
     } else {
         $lang = $_COOKIE['lang'];
     }
     $h2o = new h2o($this->template, array('searchpath' => 'templates', 'php-i18n' => array('locale' => $lang, 'charset' => 'UTF-8', 'gettext_path' => '/usr/bin/', 'tmp_dir' => '/tmp/')));
     //$session = get_session();
     //$logged = $session->get_logged_user();
     $globals = array('lang' => $lang, 'IMG_URL' => IMG_URL);
     return $h2o->render(array_merge($globals, $this->datas));
 }
开发者ID:jouvent,项目名称:Genitura,代码行数:13,代码来源:response.php

示例6: spp_random_terms_func

function spp_random_terms_func($atts)
{
    extract(shortcode_atts(array('count' => 10), $atts));
    global $spp_settings;
    global $wpdb;
    // SELECT * FROM myTable WHERE RAND()<(SELECT ((30/COUNT(*))*10) FROM myTable) ORDER BY RAND() LIMIT 30;
    $sql = "SELECT `term` FROM `" . $wpdb->prefix . "spp` WHERE RAND()<(SELECT ((" . $count . "/COUNT(`term`))*10) FROM `" . $wpdb->prefix . "spp`) ORDER BY RAND() LIMIT " . $count . ";";
    $searchterms = $wpdb->get_results($sql);
    if (!empty($searchterms)) {
        $result = new h2o(SPP_PATH . "/templates/widget.html");
        return $result->render(array('terms' => $searchterms, 'settings' => $spp_settings));
    } else {
        return false;
    }
}
开发者ID:gigikiri,项目名称:curlwp,代码行数:15,代码来源:random-terms.php

示例7: __construct

 function __construct($file = '', $options = array())
 {
     # Init a environment
     $this->options = $this->getOptions($options);
     $loader = $this->options['loader'];
     if (!$loader) {
         return true;
     }
     if (is_object($loader)) {
         $this->loader = $loader;
         $this->loader->setOptions($this->options);
     } else {
         $loaderClass = "H2o_{$loader}_Loader";
         if (!class_exists($loaderClass)) {
             throw new Exception('Invalid template loader');
         }
         if (isset($options['searchpath'])) {
             $this->searchpath = realpath($options['searchpath']) . DS;
         } else {
             $this->searchpath = dirname(realpath($file)) . DS;
         }
         $this->loader = new $loaderClass($this->searchpath, $this->options);
     }
     if (isset($options['i18n'])) {
         $i18n_options = array();
         if (is_array($options['i18n'])) {
             $i18n_options = $options['i18n'];
         }
         h2o::load('i18n');
         $this->i18n = new H2o_I18n($this->searchpath, $i18n_options);
     }
     $this->loader->runtime = $this;
     $this->nodelist = $this->loadTemplate($file);
 }
开发者ID:bouchra012,项目名称:PMB,代码行数:34,代码来源:h2o.php

示例8: __construct

 function __construct($file = null, $options = array())
 {
     # Init a environment
     $this->options = $this->getOptions($options);
     $loader = $this->options['loader'];
     if (!$loader) {
         return true;
     }
     if (is_object($loader)) {
         $this->loader = $loader;
         $this->loader->setOptions($this->options);
     } else {
         $loader = __NAMESPACE__ . '\\' . "H2o_{$loader}_Loader";
         if (!class_exists($loader)) {
             throw new \Exception('Invalid template loader');
         }
         if (isset($options['searchpath'])) {
             $this->searchpath = realpath($options['searchpath']) . DS;
         } elseif ($file) {
             $this->searchpath = dirname(realpath($file)) . DS;
         } else {
             $this->searchpath = getcwd() . DS;
         }
         $this->loader = new $loader($this->searchpath, $this->options);
     }
     $this->loader->runtime = $this;
     if (isset($options['i18n'])) {
         h2o::load('i18n');
         $this->i18n = new H2o_I18n($this->searchpath, $options['i18n']);
     }
     if ($file) {
         $this->nodelist = $this->loadTemplate($file);
     }
 }
开发者ID:hemantshekhawat,项目名称:Snippets,代码行数:34,代码来源:h2o.php

示例9: renderPage

function renderPage($template)
{
    $content = '';
    foreach ($template as $key => $value) {
        // try to mitigate directory traversal and remote inclusion
        if (preg_match('/[^a-zA-Z0-9\\.]/', $template[$key]['name'])) {
            die;
        }
        $_file = TEMPLATES_DIR . str_replace('.', '/', $template[$key]['name']) . '.html';
        // render the content template
        $page = new h2o($_file);
        $content .= $page->render($template[$key]['vars']);
        unset($page);
    }
    // place templates into the context of the main page
    $index = new h2o(TEMPLATES_DIR . 'index.html');
    echo $index->render(array('content' => $content, 'user' => $_SESSION['user']));
    exit;
}
开发者ID:nesicus,项目名称:mephit,代码行数:19,代码来源:site.lib.php

示例10: 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

示例11: filter_bad_words

        $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;
}
h2o::addFilter('filter_bad_words');
function remove_repeating_chars($object)
{
    return preg_replace("/[^a-zA-Z0-9\\s.?!\\/]/", "", $object);
}
h2o::addFilter('remove_repeating_chars');
开发者ID:jensonbetrail,项目名称:wordpress,代码行数:30,代码来源:api.php

示例12: spp

function spp($term = "", $template = 'default.html', $hack = "")
{
    global $spp_settings;
    $result = new h2o(SPP_PATH . "/templates/{$template}", array('safeClass' => array('SimpleXMLElement', 'stdClass')));
    return $result->render(array('term' => $term, 'hack' => $hack, 'settings' => $spp_settings));
}
开发者ID:gigikiri,项目名称:curlwp,代码行数:6,代码来源:stupidpie.php

示例13: userify

<?php

class TimelineFilters extends FilterCollection
{
    static function userify($user, $timelineid, $suffix = null)
    {
        if (!$user['deleted']) {
            return sprintf('<span class="a" onclick="showUserInfo(%d, null, {source: \'timeline\', timeline_id: %d})">%s %s</span>', $user['id'], $timelineid, $user['name'], $user['surname']) . $suffix;
        } else {
            return $user['name'] . " " . $user['surname'] . $suffix;
        }
    }
    static function user_adjectify($user, $timelineid)
    {
        $is_comment = array_key_exists('commenter_id', $user);
        if ($is_comment) {
            $suffix = "'s";
        } else {
            $suffix = null;
        }
        if (!$is_comment || $user['id'] != $user['commenter_id']) {
            return TimelineFilters::userify($user, $timelineid, $suffix);
        } else {
            return $user['adj'];
        }
    }
}
h2o::addFilter(array('TimelineFilters'));
开发者ID:vad,项目名称:taolin,代码行数:28,代码来源:filters.php

示例14: print_r

<?php

print_r(memory_get_usage());
include '../h2o.php';
h2o::load('i18n');
//// Set language to German
//$i18n = new H2o_I18n(dirname(__FILE__).DS, array(
//    'gettext_path' => dirname(__FILE__).DS.'bin/gettext/bin/'
//));
//$i18n->setLocale('fr');
//
//$i18n->extract();
//$i18n->compile();
////
// Choose domain
//extract_translations(
//   realpath('trans.tpl'), array('tpl', 'html'), dirname(__FILE__).DS.'bin/gettext/bin/'
//);
//
//compile_translations(
//   realpath('trans.tpl'), null, dirname(__FILE__).DS.'bin/gettext/bin/'
//);
$template = new H2o('trans.tpl', array('cache' => false, 'cache_dir' => dirname(__FILE__)));
$time_start = microtime(true);
for ($i = 0; $i < 10; $i++) {
    $r = $template->render(array('users' => array(array('username' => 'peter', 'tasks' => array('school', 'writing'), 'user_id' => 1), array('username' => 'anton', 'tasks' => array('go shopping'), 'user_id' => 2), array('username' => 'john doe', 'tasks' => array('write report', 'call tony', 'meeting with arron'), 'user_id' => 3), array('username' => 'foobar', 'tasks' => array(), 'user_id' => 4))));
}
echo $r;
echo "in " . (microtime(true) - $time_start) . " seconds\n<br/>";
开发者ID:paudebau,项目名称:h2o-php,代码行数:29,代码来源:index.php

示例15: str_replace

    return str_replace($search, '', $term);
}
if (function_exists('wpunique_synonymize')) {
    h2o::addFilter('wpunique_synonymize');
}
h2o::addFilter('host');
function host($string)
{
    $host = parse_url($string);
    return $host['host'];
}
function spp_shortcode($atts)
{
    extract(shortcode_atts(array('term' => 'hello world', 'template' => 'default.html', 'hack' => ''), $atts));
    return spp($term, $template, $hack);
}
add_shortcode('spp', 'spp_shortcode');
function get_video_id($url)
{
    $parts = parse_url($url);
    if ($parts === false) {
        return false;
    } else {
        parse_str($parts['query'], $params);
        return $params['v'];
    }
}
h2o::addFilter('get_video_id');
if (!class_exists('h2o_parser')) {
    require SPP_PATH . '/templates/h2o/h2o/parser.php';
}
开发者ID:jensonbetrail,项目名称:wordpress,代码行数:31,代码来源:h2o-config.php


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