Exemple #1
0
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;
}
Exemple #2
0
 *
 *  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;
Exemple #3
0
 *
 *  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);
Exemple #4
0
<?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');
Exemple #5
0
 *  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) {
            /* */
        }
Exemple #6
0
 *  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');
Exemple #7
0
 *  (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);
    }
Exemple #8
0
 *  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) {
Exemple #9
0
<?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) {
Exemple #10
0
 *  (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;
    }
Exemple #11
0
 *  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');
Exemple #12
0
<?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()
    {
Exemple #13
0
<?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()
    {
Exemple #14
0
    {
        $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'];
    }
Exemple #15
0
 *
 *  Project	Horn Framework <http://horn.lupusmic.org>
 *  \author		Lupus Michaelis <*****@*****.**>
 *  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');
Exemple #16
0
 *
 *  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\escaper;

use horn\lib as h;
h\import('lib/object');
h\import('lib/collection');
h\import('lib/string');
abstract class base extends h\object_public implements h\escaper
{
    protected $_charset;
    public function __construct(h\string $charset)
    {
        $this->_charset = clone $charset;
        parent::__construct();
    }
}
class generic extends base
{
    protected $_map;
    public function __construct(h\string $charset)
    {
        $this->_map = h\collection();
Exemple #17
0
 *  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/tag');
h\import('lib/mustache/processor');
h\import('lib/escaper/html');
interface escaper
{
    function do_escape($string);
}
// XXX
h\import('lib/render');
class html_escaper extends h\render\html_escaper_helper implements escaper
{
    public function do_escape($any)
    {
        return $this->a($any);
    }
}
class null_escaper extends h\object_public implements escaper
{
    public function do_escape($any)
    {
        return $any;
    }
}
function parse($template)
Exemple #18
0
 *  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\object;

use horn\lib as h;
h\import('lib/exception');
/** Ensure homogenic access to properties.
 *
 *  This is the base class for advanced object handling.
 *
 *	\warning	Don't inherit directly from it. Use classes object_public (for world
 *				instanciable object), and object_protected or object_private (for self
 *				instanciable object only). In fact, change function scope when inheriting
 *				isn't allowed. But I maybe need to do some stuff at construct time. So the
 *				flavored object need.
 *
 *	When defining a new class, you can declare public attributes. Accessors will not be
 *	called on it because of their accessibility to world. In fact, __set and __get are
 *	called only when the accessed attribute doesnt exist or isn't in scope
 *	(public/private awareness).
 *
Exemple #19
0
 *
 *  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/where');
class query extends h\object_public
{
    protected $_table;
    protected $_where;
    private $_inplace = false;
    public function __construct($inplace = null)
    {
        parent::__construct();
        $this->_inplace = $inplace;
    }
    protected function q()
    {
        return $this->_inplace ? $this : clone $this;
    }
    public function where($operand)
Exemple #20
0
 *
 *  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/regex');
h\import('lib/controller');
h\import('lib/time/date_time');
h\import('lib/string');
h\import('apps/models/account');
h\import('apps/views/account');
class account_controller extends h\crud_controller
{
    public function __construct(h\component\context $context)
    {
        parent::__construct($context, new account_resource($this));
    }
}
class accounts_controller extends h\crud_controller
{
    public function __construct(h\component\context $context)
    {
        parent::__construct($context, new accounts_resource($this));
    }
}
class account_resource extends h\resource
Exemple #21
0
<?php

namespace tests;

use horn\lib as h;
use horn\lib\test as t;
h\import('lib/regex');
h\import('lib/test');
class test_suite_regex extends t\suite
{
    public function __construct($message = 'Regex')
    {
        parent::__construct($message);
        $this->providers[] = function () {
            return null;
        };
    }
    protected function _test_match()
    {
        $messages = array('Regex search');
        $expected_exception = null;
        foreach (array(array('.*', 'This is up to 3verything <3 !!!11', true), array('^This', 'This is up to 3verything <3 !!!11', true), array('^This$', 'This is up to 3verything <3 !!!11', false)) as $target) {
            $callback = function () use($target) {
                list($re, $subject, $expected_exit) = $target;
                $re = h\regex($re);
                $subject = h\string($subject);
                $result = $re->do_execute($subject);
                return $expected_exit === $result->is_match();
            };
            $this->add_test($callback, $messages, $expected_exception);
        }
Exemple #22
0
 *  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\http;

use horn\lib as h;
h\import('lib/object');
h\import('lib/string');
h\import('lib/exception');
h\import('lib/http/message');
const POST = 'POST';
const GET = 'GET';
const PUT = 'PUT';
const DELETE = 'DELETE';
const OPTIONS = 'OPTIONS';
class request_uri extends h\object_public
{
    public $path;
    public $search;
    public function _to_string()
    {
        $string = $this->path->_to_string();
        if ($this->search->count()) {
            $string->append(h\string('?'));
            $string->append($this->search->_to_string());
Exemple #23
0
 *  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\component;

use horn\lib as h;
h\import('lib/component');
class http_cache extends base
{
    public function do_touch(context $ctx)
    {
        @($ctx->out = null);
    }
    protected function do_before(context $ctx)
    {
        $ctx->out->head['Cache-Control'] = 'no-cache';
        return true;
    }
    protected function do_after(context $ctx)
    {
    }
}
Exemple #24
0
 *
 *  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/regex');
h\import('lib/db/connect');
h\import('lib/time/date_time');
h\import('apps/models/blog');
h\import('apps/views/blog');
h\import('apps/views/page_html');
class story_controller extends h\crud_controller
{
    public function __construct(h\component\context $context)
    {
        parent::__construct($context, new story_resource($this));
    }
}
class stories_controller extends h\crud_controller
{
    public function __construct(h\component\context $context)
    {
        parent::__construct($context, new stories_resource($this));
    }
}
class story_resource extends h\resource
Exemple #25
0
 *  (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/object');
h\import('lib/regex/escaper');
class expression extends h\object\public_
{
    const default_delemeter = '`';
    protected $_pattern;
    protected $_delimiter;
    private $escaper;
    public function __construct(h\string $pattern, h\string $delimiter = null)
    {
        $this->_delimiter = is_null($delimiter) ? h\string(static::default_delemeter) : $delimiter;
        $this->_pattern = new h\string();
        parent::__construct();
        $this->_pattern = $pattern;
        $this->escaper = new escaper(h\string($pattern->charset));
    }
    protected function _clone()
Exemple #26
0
<?php

namespace horn\lib\http;

use horn\lib as h;
h\import('lib/collection');
h\import('lib/http/url');
class message extends h\object_public
{
    public $head;
    public $body;
    public function __construct()
    {
        $this->head = new head();
        $this->body = new body();
        parent::__construct();
    }
}
class request extends message
{
    public $method;
    protected $_uri;
    public $version;
    public $body;
    public function __construct()
    {
        $this->_uri = new h\uri\path();
        parent::__construct();
    }
}
class response extends message
Exemple #27
0
 *  (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 tests;

use horn\lib as h;
use horn\lib\test as t;
h\import('lib/sql/database');
class test_suite_sql extends t\suite_object
{
    public function __construct()
    {
        parent::__construct('Database');
        $dbcon = new \mysqli('localhost', 'test', 'test', 'test');
        $this->providers[] = function () use($dbcon) {
            // I know, this is unsecure
            $forge = new h\sql\forge($dbcon);
            return $forge;
        };
    }
    protected function _test_select_from()
    {
        $db = $this->target;
Exemple #28
0
 *  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/object');
abstract class absolute extends h\object_public
{
    public function __construct()
    {
        $this->_scheme = new h\uri\scheme();
        $this->_scheme_specific_part = new h\uri\scheme_specific_part();
        parent::__construct();
    }
    protected abstract function is_scheme_supported(h\string $scheme);
    public function _to_string()
    {
        $literal = h\string::format('%s:%s', $this->scheme, $this->scheme_specific_part);
        return $literal;
    }
    protected function _set_scheme(h\string $scheme)
Exemple #29
0
 *  (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/object');
h\import('lib/uri');
class path extends h\object\wrapper
{
    protected function is_supported(h\object\base $impl)
    {
        return parent::is_supported($impl) && ($impl instanceof h\uri\absolute_path || $impl instanceof h\uri\net_path || $impl instanceof h\uri\empty_path || $impl instanceof h\uri\hierarchical_part);
    }
    public function _to_string()
    {
        return $this->_call('_to_string', array());
    }
}
class net_path extends h\object\public_
{
    protected $_authority;
    protected $_path;
Exemple #30
0
 *  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\user;

use horn\lib as h;
h\import('lib/collection');
h\import('lib/string');
h\import('lib/render/html');
h\import('lib/render/rss');
class account_html_renderer extends h\object_public
{
    protected $_canvas;
    public function __construct(\domelement $canvas)
    {
        $this->_canvas = $canvas;
        parent::__construct();
    }
    public function entry(account $account, $mode)
    {
        if ($mode == 'show') {
            return $this->entry_show($account);
        } elseif ($mode == 'edit') {
            return $this->entry_edit($account);
        } elseif ($mode == 'delete') {