Skip to content

Commit

Permalink
Merge pull request #8 from effone/module-htgen
Browse files Browse the repository at this point in the history
Hypertext Generator
  • Loading branch information
effone authored Aug 17, 2018
2 parents 7235752 + 61a3afc commit 65c6f5b
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 161 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ Thumbs.db
# Generic git files
*.orig

# Package Helpers
# Files not part of software
app/vault
4 changes: 2 additions & 2 deletions app/core/class/di.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DI
* @param $abstract
* @param null $concrete
*/
public function push($abstract, $concrete = null)
public function set($abstract, $concrete = null)
{
if ($concrete === null) {
$concrete = $abstract;
Expand All @@ -40,7 +40,7 @@ public function push($abstract, $concrete = null)
* @return mixed|null|object
* @throws Exception
*/
public function pull($abstract, $values = [])
public function get($abstract, $values = [])
{
// if we don't have it, just register it
if (!isset($this->instances[$abstract])) {
Expand Down
65 changes: 65 additions & 0 deletions app/core/class/htgen.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
/**
* Elyzin - PHP based free forum software
*
* @since 0.1.0
* @version 0.1.0
* @package Model : User
* @author Elyzin Devs <[email protected]>
* @source https://github.com/elyzin/elyzin Base repository
* @link http://elyz.in
* @copyright 2018 Elyzin
* @license MIT
*
* @todo Namespace
* @todo Interface, Form elements, Markdown Parser
*/

class HTGen
{
protected $void_tags = ['area', 'base', 'br', 'col', 'hr', 'img', 'input', 'link', 'meta', 'param', 'command', 'keygen', 'source']; // HTML5 Compliant Void Tags

public function __construct()
{
}

/**
* HTML Element Generator (all pre-structured elements depend on this method)
*
* @param string $tag
* @param string $content
* @param array $arg
* @param boolean $multiline
* @param boolean $xhtml
* @return string
*/
public function elem($tag = 'br', $content = '', $arg = array(), $multiline = true, $xhtml = false)
{
$decl = "";
if (!empty($arg)) { // && !in_array($tag, ['br','hr']))
$decl = array();
foreach ($arg as $attrib => $value) {
if (is_array($value)) $value = implode(', ', $value);
if (is_numeric($attrib)) {
$attrib = $value;
$value = '';
}
$value = (!$value) ? '' : '="' . $value . '"';
$decl[] = $attrib . $value;
}
$decl = empty($decl) ? '' : ' ' . implode(' ', $decl);
}
if (in_array($tag, $this->void_tags)) {
$multiline = false; // Force oneline for void tags
$startclose = $content = '';
$endopen = $xhtml ? ' /' : ''; // XHTML compatibility, false by default
} else {
$startclose = '>';
$endopen = '</' . $tag;
}

$eol = $multiline ? PHP_EOL : '';
return '
<' . $tag . $decl . $startclose . $content . $eol . $endopen . '>';
}
}
1 change: 0 additions & 1 deletion app/core/class/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,6 @@ public function out(int $pagegen = 0)
$this->mustext['all'][] = 'nav';
$varhr['name'] = conf('basename');
$varhr['caption'] = $this->caption;
$varhr['project_name'] = isset($_SESSION['project']['name']) ? $_SESSION['project']['name'] : $this->lang('base', ['project_na']);
$varhr['navigation'] = $this->buildNav();

// Generate the visible header
Expand Down
Loading

0 comments on commit 65c6f5b

Please sign in to comment.