* @copyright: Copyright (c) 2010, Bunzia Alexander * @version: 1.0 * @license: http://www.gnu.org/copyleft/gpl.html GNU/GPL * @package: HiLO CMS */ class htmlControl { static function orderBy($key) { return ' '; } } class tableHtml { private $header = array(); private $content = array(); private $footer = array(); private $rows = array(); private $cols = array(); private $cols_keys = array(); private $count_rows = 0; private $cols_link = false; private $result = ''; function __constract($type) { global $MAIN_PAGE; } public function loadCss($file) { global $MAIN_PAGE; $MAIN_PAGE -> set_css($file); } public function loadJs($file) { global $MAIN_PAGE; $MAIN_PAGE -> set_js($file); } /** * Задаём один заголовок таблицы * */ public function cols($title,$key,$html=false) { if ( false===$this -> cols_link ) { $this -> cols_link = sizeof($this -> header); // делаем ссылку на заголовок $this -> header[]=array('cols'=> true); } $this -> cols[]=array('title'=>$title,'html'=>$html,'cols'=>sizeof($key)); $this -> cols_keys = array_merge($this -> cols_keys,$key); return true; } public function addPanel( $content ) { $this -> rows[]=array('panel'=>true, 'html'=>$content); return true; } public function row( $row ) { if ( false===$this -> data_link ) { $this -> data_link = sizeof($this -> rows); // делаем ссылку на заголовок } $result = ''; foreach( $this -> cols_keys as $k ) { if ( false===isset($row[$k]) ) { throw new Exception('Ошибка: не найден ключ '.$k); } $result .= ''.$row[$k].''; } $this -> rows[]=array('row'=>true,'html'=>$result.''); return true; } public function rows( $rows,$filter = array() ) { /* foreach( $rows as $row ) { $this -> rows[]=array('html'=>$row); } return true;*/ } public function addBlock( $content ) { return '
'.$content.'
'; } public function show( ) { $result= ''; for($i=0;$i rows);$i++) { if( $this -> rows[$i]['cols']===true ) { $result.=''; for($j=0;$j cols);$j++) { $cols = ($this -> cols[$j]['cols'] ==1) ? '' : 'colspan="'.$this -> cols[$j]['cols'].'"'; $result.=''; } $result.=''; } elseif( $this -> rows[$i]['row']===true) { if( $i==$this -> data_link ) { $result.=''; } $result.=$this -> rows[$i]; } $result.=''; } $result.= '
'.$this -> cols[$j]['html'].' '.$this -> cols[$j]['title'].'
'; return $result; } } /** * Класс генерации контрола ввода текста * */ class inputHtml { private $attributes = array(); private $check = array(); public function __construct($v = '') { $this -> attributes['name'] = $v; return $this; } public function setName($v) { if ( empty($v) ) { throw new Exception('Ошибка: нужно задать поле "name" для контрола input!'); } $this -> attributes['name'] = $v; return $this; } public function setValue($v) { $this -> attributes['value'] = $v; return $this; } public function setCheck($user_func) { /*$this -> attributes['value'] = $v; return $this;*/ } public function setCheckNum($min,$max) { $this -> check['num'] = '#[0-9]{'.$min.','.$max.'}#'; return $this; } public function show() { return ''; } } /** * Класс генерации сложных html объектов * */ class html_control { /** * JS календарь * * */ static function calendar($edit_name,$format='%d.%m.%Y'){ global $TMPL,$MAIN_PAGE; include_once(MAIN_SOURCE_PATH.'/ext/jscalendar/calendar.php'); $calendar = new DHTML_Calendar(MAIN_SOURCE_URL.'/ext/jscalendar/', 'en', 'calendar-win2k-2', false); $MAIN_PAGE -> set_js( $calendar->calendar_lib_path . $calendar->calendar_file); $MAIN_PAGE -> set_js( $calendar->calendar_lib_path . $calendar->calendar_lang_file); $MAIN_PAGE -> set_js( $calendar->calendar_lib_path . $calendar->calendar_setup_file); $MAIN_PAGE -> set_css( $calendar->calendar_lib_path . $calendar->calendar_theme_file); return 'указать '; } /** * функция загрузки html редактора * * @var: str $name название редактора, по совместительству имя файла в директории /inc/editors * @return: object объект-прослойка предоставляющий стандартный интерфейс для работы с редактором */ static function editor($name,$path='') { if ( empty($path) ){ $path = MAIN_SOURCE_PATH.'/inc/editors'; } // название редактора if ( empty($name) ){ sys_error(ERROR_500,E_HTML_EDIT_EMPTY); } // существование класса if ( !file_exists($path."/class.$name.php") ){ sys_error(ERROR_500, sprintf(E_HTML_EDIT_NOTFOUND,$name) ); } include_once($path."/class.$name.php"); // название класса должно совпадать с его именем $e = new $name; return $e; } } // --- класс для построения простых выпадающих списков class select_box{ private $selected_id = "0"; // --- выбраный индекс private $block_id = array();// --- ветки которые блокируются private $options = array(); private $select_box = ''; private $empty_record_flag = true; private $empty_record_num = 0; private $empty_record_value = '---'; private $multi_select = false; // --- данная ветка выводится в списке не будет public function set_block_id( $id ){ if ( empty($id) ){ return false; } array_push($this -> block_id, $id ); false; } public function block_id( $id ){ return $this -> set_block_id($id); } public function selected_id( $id ){ if ( empty($id) ){ return false; } if ( is_array($id) ){ $this -> multi_select = true; $this -> selected_id = $id; }else{ $this -> selected_id = (string)$id; } return false; } public function opt_open($value){ $this -> select_box .=' '; } public function opt_close(){ $this -> select_box .=' '; } public function set($key,$value){ if ( $this -> multi_select ){ $selected = ( in_array($key,$this -> selected_id) ) ? 'selected' : ''; }else{ $selected = ($key==$this -> selected_id) ? 'selected' : ''; } $disabled = ( in_array($key,$this -> block_id) ) ? 'disabled' : ''; $this -> select_box .='