Ejemplo n.º 1
0
 /**
  * Open Graph protocol support
  *
  * Provides automatic addition of <html prefix="og: http://ogp.me/ns#">, and is used for simplification of Open Graph protocol support
  *
  * @param string			$property		Property name, but without <i>og:</i> prefix. For example, <i>title</i>
  * @param string|string[]	$content		Content, may be an array
  * @param string			$custom_prefix	If prefix should differ from <i>og:</i>, for example, <i>article:</i> - specify it here
  *
  * @return Page
  */
 function og($property, $content, $custom_prefix = 'og:')
 {
     if (!$property || !($content || $content === 0)) {
         return $this;
     }
     if (!Config::instance()->core['og_support']) {
         return $this;
     }
     if (is_array($content)) {
         foreach ($content as $c) {
             $this->og($property, $c, $custom_prefix);
         }
         return $this;
     }
     if (!isset($this->og_data[$property])) {
         $this->og_data[$property] = '';
     }
     if ($property == 'type') {
         $this->og_type = $content;
     }
     $this->og_data[$property] .= h::meta(['property' => $custom_prefix . $property, 'content' => $content]);
     return $this;
 }
Ejemplo n.º 2
0
<?php

require "lib.htmlgen.php";
h::set_variable("table_data", array("foo" => "bar", "hello" => "world", "123" => "456", "abc" => "xyz"));
h::set_indent_pattern("  ");
h::html(function () {
    h::head(function () {
        h::meta(array("charset" => "UTF-8"));
        h::link(array("rel" => "stylesheet", "type" => "text/css", "href" => "global.css"));
    });
    h::body(function () {
        h::div(array("id" => "wrapper"), function () {
            h::h1("Hello, World", array("class" => "title"));
            h::comment("navigation");
            h::ul(array("class" => "links"), function () {
                foreach (array(1, 2, 3) as $x) {
                    h::li(function () use($x) {
                        h::a("Link {$x}", "#{$x}");
                    });
                }
            });
            h::comment("let's see some text");
            h::p("Lorem ipsum dolor sit amet, consectetur adipisicing elit...");
            h::comment("now for a table");
            h::table(function () {
                $table_data = h::get_variable('table_data', array());
                h::tr(array("class" => "header"), function () {
                    h::th("key");
                    h::th("value");
                });
                foreach ($table_data as $k => $v) {