/** * Generates Open Graph protocol information, and puts it into HTML */ protected function og_generation() { /** * Automatic generation of some information */ $Config = Config::instance(); if (!$Config->core['og_support']) { return; } $og =& $this->og_data; if (!isset($og['title']) || empty($og['title'])) { $this->og('title', $this->Title); } if ((!isset($og['description']) || empty($og['description'])) && $this->Description) { $this->og('description', $this->Description); } if (!isset($og['url']) || empty($og['url'])) { $this->og('url', HOME ? $Config->base_url() : ($this->canonical_url ?: $Config->base_url() . '/' . $Config->server['relative_address'])); } if (!isset($og['site_name']) || empty($og['site_name'])) { $this->og('site_name', get_core_ml_text('name')); } if (!isset($og['type']) || empty($og['type'])) { $this->og('type', 'website'); } if ($Config->core['multilingual']) { $L = Language::instance(); if (!isset($og['locale']) || empty($og['locale'])) { $this->og('locale', $L->clang . '_' . strtoupper($L->cregion)); } if ((!isset($og['locale:alternate']) || empty($og['locale:alternate'])) && count($Config->core['active_languages']) > 1) { foreach ($Config->core['active_languages'] as $lang) { if ($lang != $L->clanguage) { $this->og('locale:alternate', $L->get('clang', $lang) . '_' . strtoupper($L->get('cregion', $lang))); } } } } $prefix = 'og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#'; switch (explode('.', $this->og_type, 2)[0]) { case 'article': $prefix .= ' article: http://ogp.me/ns/article#'; break; case 'blog': $prefix .= ' blog: http://ogp.me/ns/blog#'; break; case 'book': $prefix .= ' book: http://ogp.me/ns/book#'; break; case 'profile': $prefix .= ' profile: http://ogp.me/ns/profile#'; break; case 'video': $prefix .= ' video: http://ogp.me/ns/video#'; break; case 'website': $prefix .= ' website: http://ogp.me/ns/website#'; break; } $this->Head = $this->Head . implode('', $og); if (!$this->no_head) { $this->Head = h::head($this->Head, ['prefix' => $prefix . $this->head_prefix]); } }
<?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) {