-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from effone/module-htgen
Hypertext Generator
- Loading branch information
Showing
6 changed files
with
223 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,5 @@ Thumbs.db | |
# Generic git files | ||
*.orig | ||
|
||
# Package Helpers | ||
# Files not part of software | ||
app/vault |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 . '>'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.