ACC SHELL

Path : /srv/www/vhosts/alfa-com/engine/
File Upload :
Current File : /srv/www/vhosts/alfa-com/engine/HTML.php

<?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(
				'¡' => '&iexcl;', '¢' => '&cent;', '£' => '&pound;', '¤' => '&curren;', '¥' => '&yen;', '¦' => '&brvbar;',
				'§' => '&sect;', '¨' => '&uml;', '©' => '&copy;', 'ª' => '&ordf;', '«' => '&laquo;', '¬' => '&not;', '­' => '&shy;',
				'®' => '&reg;', '¯' => '&macr;', '°' => '&deg;', '±' => '&plusmn;', '²' => '&sup2;', '³' => '&sup3;', '´' => '&acute;',
				'µ' => '&micro;', '¶' => '&para;', '·' => '&middot;', '¸' => '&cedil;', '¹' => '&sup1;', 'º' => '&ordm;',
				'»' => '&raquo;', '¼' => '&frac14;', '½' => '&frac12;', '¾' => '&frac34;', '¿' => '&iquest;', '×' => '&times;',
				'÷' => '&divide;', 'ƒ' => '&fnof;', '•' => '&bull;', '…' => '&hellip;', '′' => '&prime;', '″' => '&Prime;',
				'‾' => '&oline;', '⁄' => '&frasl;', '℘' => '&weierp;', 'ℑ' => '&image;', 'ℜ' => '&real;', '™' => '&trade;',
				'ℵ' => '&alefsym;', '←' => '&larr;', '↑' => '&uarr;', '→' => '&rarr;', '↓' => '&darr;', '↔' => '&harr;',
				'↵' => '&crarr;', '⇐' => '&lArr;', '⇑' => '&uArr;', '⇒' => '&rArr;', '⇓' => '&dArr;', '⇔' => '&hArr;',
				'∀' => '&forall;', '∂' => '&part;', '∃' => '&exist;', '∅' => '&empty;', '∇' => '&nabla;', '∈' => '&isin;',
				'∉' => '&notin;', '∋' => '&ni;', '∏' => '&prod;', '∑' => '&sum;', '−' => '&minus;', '∗' => '&lowast;',
				'√' => '&radic;', '∝' => '&prop;', '∞' => '&infin;', '∠' => '&ang;', '∧' => '&and;', '∨' => '&or;', '∩' => '&cap;',
				'∪' => '&cup;', '∫' => '&int;', '∴' => '&there4;', '∼' => '&sim;', '≅' => '&cong;', '≈' => '&asymp;',
				'≠' => '&ne;', '≡' => '&equiv;', '≤' => '&le;', '≥' => '&ge;', '⊂' => '&sub;', '⊃' => '&sup;', '⊄' => '&nsub;',
				'⊆' => '&sube;', '⊇' => '&supe;', '⊕' => '&oplus;', '⊗' => '&otimes;', '⊥' => '&perp;', '⋅' => '&sdot;',
				'◊' => '&loz;', '♠' => '&spades;', '♣' => '&clubs;', '♥' => '&hearts;', '♦' => '&diams;', '"' => '&quot;',
				'&' => '&amp;', '<' => '&lt;', '>' => '&gt;', 'ˆ' => '&circ;', '˜' => '&tilde;', ' ' => '&ensp;', ' ' => '&emsp;',
				' ' => '&thinsp;', '‌' => '&zwnj;', '‍' => '&zwj;', '‎' => '&lrm;', '‏' => '&rlm;', '–' => '&ndash;',
				'—' => '&mdash;', '‘' => '&lsquo;', '’' => '&rsquo;', '‚' => '&sbquo;', '“' => '&ldquo;', '”' => '&rdquo;',
				'„' => '&bdquo;', '†' => '&dagger;', '‡' => '&Dagger;', '‰' => '&permil;', '‹' => '&lsaquo;', '›' => '&rsaquo;',
				'€' => '&euro;');
			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