本文整理汇总了PHP中horn\lib\import函数的典型用法代码示例。如果您正苦于以下问题:PHP import函数的具体用法?PHP import怎么用?PHP import使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了import函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
function build(h\configuration $configuration, context $ctx)
{
$component = null;
// We build the onion from core to skin
$components = h\c($configuration['components'])->reverse();
foreach ($components as $layer) {
h\import('lib/component/' . $layer);
$component_class = "\\horn\\lib\\component\\{$layer}";
$component = new $component_class($configuration, $component);
$component->do_touch($ctx);
}
return $component;
}
示例2: __construct
*
* Horn Framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero Public License for more details.
*
* You should have received a copy of the GNU Affero Public License
* along with Horn Framework. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace horn\lib\sql;
use horn\lib as h;
h\import('lib/object');
h\import('lib/collection');
h\import('lib/sql/query');
class select extends query
{
protected $_fields;
protected $_criteria;
public function __construct(h\collection $fields = null)
{
$this->_fields = h\collection();
$this->_criteria = h\collection();
parent::__construct();
$this->fields = $fields;
}
public function values($fields)
{
$q = $this->q();
$q->values[] = $fields;
示例3: get_all
*
* Horn Framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero Public License for more details.
*
* You should have received a copy of the GNU Affero Public License
* along with Horn Framework. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace horn\apps\blog;
use horn\lib as h;
h\import('lib/collection');
h\import('lib/string');
h\import('lib/model');
class account_data extends h\model_data
{
const name = 'account';
public function get_all()
{
$db = $this->model->services->get('db');
$rows = $db->query(h\string('select * from accounts'));
return $this->create_accounts_from_select($rows);
}
public function get_by_name(h\string $name)
{
$db = $this->model->services->get('db');
$sql = h\string::format('select * from accounts where name = %s', $db->escape($name));
$rows = $db->query($sql);
$accounts = $this->create_accounts_from_select($rows);
示例4: __construct
<?php
namespace horn\lib\markup;
use horn\lib as h;
h\import('lib/object');
h\import('lib/string');
h\import('lib/collection');
h\import('lib/markup/rss');
class rss extends xml
{
protected $_document;
protected function __construct(\domdocument $dom)
{
parent::__construct($dom);
$this->_initialize();
}
public static function create()
{
$document = new \domdocument('1.0', 'UTF-8');
$rss = new static($document);
return $rss;
}
protected function _to_string()
{
return $this->document->saveXML();
}
protected function _initialize()
{
$doc = $this->document;
$root = $doc->createElementNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'rdf:RDF');
示例5: do_feed
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Horn Framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero Public License for more details.
*
* You should have received a copy of the GNU Affero Public License
* along with Horn Framework. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace horn\lib\uri;
use horn\lib as h;
h\import('lib/inet/url');
class port_factory extends h\uri\specific_factory
{
public function do_feed(h\string $meat)
{
if ($meat->length() < 1) {
return null;
}
if (h\string(':')->is_equal($meat[0])) {
$meat->behead(1);
} else {
return null;
}
for ($end_port = 0; \is_numeric((string) $meat[$end_port]); ++$end_port) {
/* */
}
示例6: __construct
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Horn Framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero Public License for more details.
*
* You should have received a copy of the GNU Affero Public License
* along with Horn Framework. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace horn\lib\regex;
use horn\lib as h;
h\import('lib/escaper');
class escaper extends h\object\public_ implements h\escaper
{
public function __construct(h\string $charset)
{
parent::__construct();
}
public function do_escape(h\string $subject)
{
$escaped = clone $subject;
$escaped->scalar = preg_quote($escaped->scalar);
return $escaped;
}
public function do_unescape(h\string $subject)
{
throw $this->_exception('Unescape is not supported');
示例7: __construct
* (at your option) any later version.
*
* Horn Framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero Public License for more details.
*
* You should have received a copy of the GNU Affero Public License
* along with Horn Framework. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace horn\lib\mustache;
use horn\lib as h;
h\import('lib/object');
h\import('lib/mustache/parser');
class processor extends h\object_public
{
protected $_escaper;
protected $_parser;
public function __construct(parser $parser, escaper $escaper)
{
$this->_parser = $parser;
$this->_escaper = $escaper;
parent::__construct();
}
public function do_process(h\string $template, $context)
{
$parsed = $this->parser->do_parse($template);
return $this->render_template($parsed, $context);
}
示例8: __construct
* Horn Framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero Public License for more details.
*
* You should have received a copy of the GNU Affero Public License
* along with Horn Framework. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace horn\lib\inet;
use horn\lib as h;
h\import('lib/object');
h\import('lib/inet/url');
h\import('lib/regex');
h\import('lib/regex-defs');
abstract class inet extends h\object_protected
{
protected $_raw;
protected $_netmask;
protected $_words;
const ERR_UNKNOWN_VERSION = "Unknown IP version [%d].";
const ERR_BAD_IP = "Bad address IP [%s].";
protected function __construct()
{
parent::__construct();
$this->_words = new collection();
}
static function new_(h\string $literal, $version = inet_4::version)
{
if ($version == inet_4::version) {
示例9: __construct
<?php
namespace tests;
use horn\lib as h;
use horn\lib\test as t;
h\import('lib/test');
//h\import('lib/date');
h\import('lib/time');
class test_suite_time extends t\suite_object
{
public function __construct($message = 'Time')
{
parent::__construct($message);
//$this->providers[] = function () { return new h\time ; };
$this->providers[] = function () {
return h\today();
};
$this->providers[] = function () {
return h\tomorrow();
};
$this->providers[] = function () {
return h\yesterday();
};
}
protected function _test_today()
{
$messages = array('Testing today');
$suite = $this;
$o = $this->target;
$callback = function () use($o, $suite) {
示例10: __construct
* (at your option) any later version.
*
* Horn Framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero Public License for more details.
*
* You should have received a copy of the GNU Affero Public License
* along with Horn Framework. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace horn\lib\sql;
use horn\lib as h;
h\import('lib/object');
h\import('lib/collection');
class where extends h\object_public
{
protected $_stack;
public function __construct($operand)
{
$this->_stack = h\collection();
parent::__construct();
$this->stack[] = $operand;
}
public function equals($operand)
{
$this->stack[] = '=';
$this->stack[] = $operand;
return $this;
}
示例11:
* Horn Framework is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Horn Framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero Public License for more details.
*
* You should have received a copy of the GNU Affero Public License
* along with Horn Framework. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* Before you mess URI, please read http://www.w3.org/TR/uri-clarification/
http://www.ietf.org/rfc/rfc3986.txt
*/
namespace horn\lib;
use horn\lib as h;
h\import('lib/string');
h\import('lib/collection');
h\import('lib/regex');
h\import('lib/regex-defs');
h\import('lib/uri/factory');
h\import('lib/uri/absolute');
h\import('lib/uri/scheme');
h\import('lib/uri/scheme_specific_part');
h\import('lib/uri/port');
h\import('lib/uri/query');
示例12: __construct
<?php
namespace horn\lib\test;
use horn\lib as h;
h\import('lib/object');
h\import('lib/string');
h\import('lib/collection');
h\import('lib/callback');
/** Test management.
* This class provides a way to handle test running. The test is actually done in a
* case object.
*/
class context extends h\object_public
{
const CAPTION = 'Unamed test case.';
public $success = null;
public $message = self::CAPTION;
public $on_true = 'Ok';
public $on_false = 'Ko';
public $expected_exception = array();
protected $_callback;
protected $_caught_exception = null;
public function __construct(h\callback $callback, $expected_exception = false)
{
parent::__construct();
$this->callback = $callback;
$expected_exception and $this->expected_exception = $expected_exception;
}
public function __invoke()
{
示例13: __construct
<?php
namespace tests;
use horn\lib as h;
use horn\lib\test as t;
h\import('lib/uri/path');
class test_suite_path extends t\suite
{
public function __construct($message = 'Path')
{
parent::__construct($message);
$this->providers[] = function () {
null;
};
}
protected function _test_create_http_uri()
{
$messages = array('Path');
$expected_exception = null;
$callback = function () {
$path = new h\uri\path();
$path->set_impl(new h\uri\net_path());
$path->authority->host->set_impl(new h\inet\host());
$path->path->set_impl(new h\uri\empty_path());
return h\string('//')->is_equal($path->_to_string());
};
$this->add_test($callback, $messages, $expected_exception);
}
protected function _test_create_http_uri_localhost()
{
示例14: do_render
{
$this->_configuration = $configuration;
parent::__construct();
}
public abstract function do_render(h\component\context $context);
}
class json extends base
{
public function do_render(h\component\context $context)
{
return json_encode(array('status' => $context->error_handling['status'], 'results' => $context->results, 'errors' => $context->error_handling['messages']));
}
}
h\import('lib/render/escaper');
h\import('lib/render/html');
h\import('lib/render/strategy');
class html extends base
{
protected $_strategy;
public function __construct(h\configuration $configuration)
{
parent::__construct($configuration);
$this->init_strategy();
}
private function init_strategy()
{
//$this->configuration['template']['path'];
$this->_strategy = new php_include_strategy();
$this->strategy->escaper = new h\render\html_escaper_helper(h\string('UTF-8'));
$this->strategy->path = $this->configuration['template']['path'];
}
示例15:
*
* Project Horn Framework <http://horn.lupusmic.org>
* \author Lupus Michaelis <mickael@lupusmic.org>
* Copyright 2009, Lupus Michaelis
* License AGPL <http://www.fsf.org/licensing/licenses/agpl-3.0.html>
*/
/*
* This file is part of Horn Framework.
*
* Horn Framework is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Horn Framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero Public License for more details.
*
* You should have received a copy of the GNU Affero Public License
* along with Horn Framework. If not, see <http://www.gnu.org/licenses/>.
*
*/
/** \package horn\lib\tests
*/
namespace horn\lib\test;
use horn\lib as h;
h\import('lib/test/suite');
h\import('lib/test/context');