ACC SHELL
<?php
// Author: Jakub Macek, CZ; Copyright: Poski.com s.r.o.; Code is 100% my work. Do not copy.
class HTML
{
public static function attributes($attrs)
{
if (is_array($attrs))
{
$temp = ' ';
foreach ($attrs as $k => $v)
if (is_int($k))
$temp .= htmlentities($v) . ' ';
else
$temp .= htmlentities($k) . '="' . htmlentities($v) . '" ';
$temp .= ' ';
$attrs = $temp;
}
return ' ' . trim($attrs) . ' ';
}
public static function e($string)
{
if (!isset($GLOBALS['HTML_e_table']))
$GLOBALS['HTML_e_table'] = array(
'¡' => '¡', '¢' => '¢', '£' => '£', '¤' => '¤', '¥' => '¥', '¦' => '¦',
'§' => '§', '¨' => '¨', '©' => '©', 'ª' => 'ª', '«' => '«', '¬' => '¬', '' => '­',
'®' => '®', '¯' => '¯', '°' => '°', '±' => '±', '²' => '²', '³' => '³', '´' => '´',
'µ' => 'µ', '¶' => '¶', '·' => '·', '¸' => '¸', '¹' => '¹', 'º' => 'º',
'»' => '»', '¼' => '¼', '½' => '½', '¾' => '¾', '¿' => '¿', '×' => '×',
'÷' => '÷', 'ƒ' => 'ƒ', '•' => '•', '…' => '…', '′' => '′', '″' => '″',
'‾' => '‾', '⁄' => '⁄', '℘' => '℘', 'ℑ' => 'ℑ', 'ℜ' => 'ℜ', '™' => '™',
'ℵ' => 'ℵ', '←' => '←', '↑' => '↑', '→' => '→', '↓' => '↓', '↔' => '↔',
'↵' => '↵', '⇐' => '⇐', '⇑' => '⇑', '⇒' => '⇒', '⇓' => '⇓', '⇔' => '⇔',
'∀' => '∀', '∂' => '∂', '∃' => '∃', '∅' => '∅', '∇' => '∇', '∈' => '∈',
'∉' => '∉', '∋' => '∋', '∏' => '∏', '∑' => '∑', '−' => '−', '∗' => '∗',
'√' => '√', '∝' => '∝', '∞' => '∞', '∠' => '∠', '∧' => '∧', '∨' => '∨', '∩' => '∩',
'∪' => '∪', '∫' => '∫', '∴' => '∴', '∼' => '∼', '≅' => '≅', '≈' => '≈',
'≠' => '≠', '≡' => '≡', '≤' => '≤', '≥' => '≥', '⊂' => '⊂', '⊃' => '⊃', '⊄' => '⊄',
'⊆' => '⊆', '⊇' => '⊇', '⊕' => '⊕', '⊗' => '⊗', '⊥' => '⊥', '⋅' => '⋅',
'◊' => '◊', '♠' => '♠', '♣' => '♣', '♥' => '♥', '♦' => '♦', '"' => '"',
'&' => '&', '<' => '<', '>' => '>', 'ˆ' => 'ˆ', '˜' => '˜', ' ' => ' ', ' ' => ' ',
' ' => ' ', '' => '‌', '' => '‍', '' => '‎', '' => '‏', '–' => '–',
'—' => '—', '‘' => '‘', '’' => '’', '‚' => '‚', '“' => '“', '”' => '”',
'„' => '„', '†' => '†', '‡' => '‡', '‰' => '‰', '‹' => '‹', '›' => '›',
'€' => '€');
return strtr($string, $GLOBALS['HTML_e_table']);
}
public static function pager($options)
{
require_once('third-party/PEAR/Pager.php');
$opts = array(
'perPage' => $options['page-size'],
'delta' => (isset($options['delta']) ? $options['delta'] : 5),
'mode' => (isset($options['mode']) ? $options['mode'] : 'Sliding'),
'currentPage' => $options['page'],
'urlVar' => (isset($options['key']) ? $options['key'] : 'page'),
'curPageLinkClassName' => 'selected',
'clearIfVoid' => true,
'useSessions' => false,
'excludeVars' => array('page.panel', 'page.viewstate', 'page_panel', 'page_viewstate', '_'),
'extraVars' => array(),
);
if (isset($options['page-count']))
$opts['totalItems'] = $options['page-count'] * $options['page-size'];
else
$opts['itemData'] = $options['pages'];
foreach (array('altFirst', 'altPrev', 'altNext', 'altLast', 'altPage', 'prevImg', 'nextImg', 'separator',
'spacesBeforeSeparator', 'spacesAfterSeparator', 'firstLinkTitle', 'prevLinkTitle', 'nextLinkTitle',
'lastLinkTitle', 'curPageSpanPre', 'curPageSpanPost', 'firstPagePre', 'firstPageText', 'firstPagePost',
'lastPagePre', 'lastPageText', 'lastPagePost') as $key)
if (($temp = __('pager-'.$key, '@core', false)) !== false)
$opts[$key] = $temp;
if (isset($options['url']))
{
$opts['append'] = false;
$opts['fileName'] = $options['url'];
}
if (page()->panel)
$opts['onclick'] = "return application.loadPanel(this.href, '".page()->panel."');";
if (page()->viewstate)
$opts['extraVars']['page.viewstate'] = page()->viewstate;
$result = Pager::factory($opts);
if (isset($options['url']))
{
$result->_path = '/';
$result->_url = '/';
$result->build();
}
$temp = $result->getPageSelectBox(array('autoSubmit' => true));
if (page()->panel)
$temp = preg_replace('~onchange="document\.location\.href=([^"]+)"~', 'onchange="return application.loadPanel(\1, \'' . page()->panel . '\')"', $temp);
$result->selectBox = $temp;
return $result;
}
// <script type="text/javascript"><!--//--><![CDATA[//><!--
// //--><!]]></script>
public static function js($type)
{
if ($type === 0)
return '<script type="text/javascript"><!--//--><![CDATA[//><!--' . "\n";
else if ($type === 1)
return "\n" . '//--><!]]></script>';
else if (is_string($type))
return self::js(0) . $type . self::js(1);
else
error('unknown argument type');
}
public static function tableFromArray($array, $columns = array())
{
reset($array);
if (!$columns)
{
$columns = current($array);
foreach ($columns as $k => $v)
$columns[$k] = $k;
}
$result = '<table>';
$result .= '<tr>';
foreach ($columns as $k => $v)
$result .= '<th>' . $v . '</th>';
$result .= '</tr>';
foreach ($array as $rowkey => $row)
{
$result .= '<tr>';
foreach ($columns as $k => $v)
$result .= '<td>' . $row[$k] . '</td>';
$result .= '</tr>';
}
$result .= '</table>';
return $result;
}
}
class HTMLElement
{
public $name = '';
public $attributes = array();
public $children = array();
public function __construct($name = '')
{
$this->name = $name;
}
public function attributeGet($key, $value = null)
{
return (isset($this->attributes[$key]) ? $this->attributes[$key] : $value);
}
public function attributeSet($key, $value)
{
if ($value === null)
unset($this->attributes[$key]);
else
$this->attributes[$key] = $value;
}
public function attributesToString()
{
$result = array();
foreach ($this->attributes as $k => $v)
$result[] = $k . '="' . HTML::e($v) . '"';
return implode(' ', $result);
}
public function isPaired()
{
return !in_array($this->name, array('img', 'hr'));
}
public function add($element)
{
$this->children[] = $element;
}
public function renderOpen()
{
$autoclose = '';
if (!$this->isPaired())
$autoclose = ' /';
return '<'.$this->name.' '.$this->attributesToString().$autoclose.'>';
}
public function renderClose()
{
if (!$this->isPaired())
return '';
return '</'.$this->name.'>';
}
public function render()
{
$result = '';
$result .= $this->renderOpen();
foreach ($this->children as $child)
$result .= $child->render();
$result .= $this->renderClose();
return $result;
}
}
class HTMLText
{
public $text = '';
public function __construct($text = '')
{
$this->text = $text;
}
public function render()
{
return $this->text;
}
}
?>
ACC SHELL 2018