本文整理汇总了PHP中h2o类的典型用法代码示例。如果您正苦于以下问题:PHP h2o类的具体用法?PHP h2o怎么用?PHP h2o使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了h2o类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: h2o
<?php
require 'h2o/h2o.php';
$h2o = new h2o('templates/friends.html');
$user = $_COOKIE['email'];
$hash = $_COOKIE['crypt'];
if (crypt($user, $hash) == $hash) {
} else {
header("Location:logout.php");
}
$data = array('error' => '', 'email' => $user);
#$data['email']=$user
require 'config.php';
require 'connect.php';
$ret = mysql_query("SELECT email from incoming where destination='{$user}'");
if (mysql_error($conn)) {
$data['error'] = mysql_error($conn);
echo $h2o->render(compact('data'));
return;
}
while ($row = mysql_fetch_assoc($ret)) {
$json[] = $row;
}
$ret = mysql_query("SELECT DISTINCT email2 as email from connections where email1='{$user}' and email2<>'{$user}'");
while ($row = mysql_fetch_assoc($ret)) {
$json1[] = $row;
}
$ret = mysql_query("SELECT email FROM users WHERE email NOT IN ( SELECT email2 FROM connections WHERE email1='{$user}') and email<>'{$user}'") or die(mysql_error());
while ($row = mysql_fetch_assoc($ret)) {
$json2[] = $row;
}
开发者ID:kharepratyush,项目名称:basic-twitter-prototype,代码行数:31,代码来源:friend.php
示例17: 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
示例18: build_permalink_for
return $before;
}
}
h2o::addFilter('firstword');
function build_permalink_for($term, $url_rewrites_index)
{
global $spp_settings;
$rule = $spp_settings->url_rewrites[$url_rewrites_index];
$term = CoreFilters::hyphenize($term);
$term = str_replace('-', $rule['separator'], $term);
$array_of_term = explode($rule['separator'], $term);
$first_word = isset($array_of_term[0]) ? $array_of_term[0] : $term;
$permalink = $rule['permalink'];
$permalink = str_replace('{{ first_word }}', $first_word, $permalink);
$permalink = str_replace('{{ random }}', substr(md5($term), 1, 7), $permalink);
$permalink = str_replace('{{ term }}', $term, $permalink);
$permalink = home_url($permalink);
return $permalink;
}
h2o::addFilter('build_permalink_for');
h2o::addFilter('base64_encode');
function spp_is_bot()
{
$crawlers = array('aspseek', 'abachobot', 'accoona', 'acoirobot', 'adsbot', 'alexa', 'alta vista', 'altavista', 'ask jeeves', 'baidu', 'bing', 'crawler', 'croccrawler', 'dumbot', 'estyle', 'exabot', 'fast-enterprise', 'fast-webcrawler', 'francis', 'geonabot', 'gigabot', 'google', 'googlebot', 'heise', 'heritrix', 'ibm', 'iccrawler', 'idbot', 'ichiro', 'lycos', 'mediapartners-google', 'msn', 'msrbot', 'majestic-12', 'metager', 'ng-search', 'nutch', 'omniexplorer', 'psbot', 'rambler', 'seosearch', 'scooter', 'scrubby', 'seekport', 'sensis', 'seoma', 'snappy', 'steeler', 'synoo', 'telekom', 'turnitinbot', 'voyager', 'wisenut', 'yacy', 'yahoo');
foreach ($crawlers as $c) {
if (stripos($_SERVER['HTTP_USER_AGENT'], $c) !== false) {
return true;
}
}
return false;
}
开发者ID:jjpango,项目名称:JJTeam,代码行数:31,代码来源:permalink.php
示例19: templize
function templize($source)
{
$output = array();
$inline_re = '/^\\s*trans\\s+("(?:[^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'(?:[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')\\s*/';
$block_re = "/^\\s*blocktrans(?:\\s+|\$)/";
$endblock_re = "/^\\s*endblocktrans\$/";
$plural_re = "/^\\s*plural\$/";
$var_re = '{
_\\(
(
"[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | # Double Quote string
\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' # Single Quote String
)
\\)
}x';
$lexer = new H2o_Lexer(h2o::getOptions());
$tokenstream = $lexer->tokenize($source);
$in_block = false;
$is_plural = false;
$singulars = array();
$plurals = array();
while ($t = $tokenstream->next()) {
if ($in_block) {
if ($t->type == 'block' && $t->content == 'endblocktrans') {
if ($is_plural) {
$output[] = sprintf(" ngettext('%s', '%s', \$count)", join('', $singulars), join('', $plurals));
} else {
$output[] = sprintf(" gettext('%s')", join('', $singulars));
}
$singulars = $plurals = array();
$in_block = $is_plural = false;
} elseif ($t->type == 'block' && $t->content == 'plural') {
$is_plural = true;
} elseif ($t->type == 'text') {
if ($is_plural) {
$plurals[] = addslashes($t->content);
} else {
$singulars[] = addslashes($t->content);
}
} elseif ($t->type == 'variable') {
@(list($var, $filters) = explode('|', $t->content));
if ($is_plural) {
$plurals[] = sprintf("%%(%s)", $var);
} else {
$singulars[] = sprintf("%%(%s)", $var);
}
} elseif ($t->type == 'block') {
throw new Exception('No block tag is allowed in translation block');
}
} else {
if ($t->type == 'block') {
if (preg_match($inline_re, $t->content, $matches)) {
$output[] = sprintf(" gettext(%s)", $matches[1]);
} elseif (preg_match($block_re, $t->content, $matches)) {
$in_block = true;
}
} elseif ($t->type == 'variable') {
if (preg_match($var_re, $t->content, $matches)) {
$output[] = sprintf(" gettext(%s)", $matches[1]);
}
}
}
}
$result = str_replace("\r", '', implode(";\n", $output));
if ($result) {
return "\n" . $result . ";\n";
}
}
开发者ID:hbasria,项目名称:pjango,代码行数:68,代码来源:i18n.php
示例20: 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
注:本文中的h2o类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论