<?php
 class baseField { var $Conf = array(); function init() { $Fields = dirname(__FILE__).'/'; if(file_exists($Fields)) { foreach(scandir($Fields) as $z) { if($z=='.' OR $z=='..') continue; $v = $Fields.$z; if(is_dir($v)) { foreach(scandir($v) as $f) { if($f=='.' OR $f=='..') continue; $v = $Fields.$z.'/'.$f; if(is_file($v) AND substr($v,-3)=='php') { require_once($v); } } } } } } function getFieldClass($t) { $c = $t.'Field'; if(class_exists($c)) { $F = new $c; } else { $F = new textField; } $F->Mizu = $this->Mizu; return $F; } function getType($tpl,$field=false) { switch(substr($field,0,3)) { case 'txt' : $type = 'html'; break; case 'fil' : $type = 'file'; break; case 'lis' : $type = 'files'; break; } if($tpl['attr'] AND $tpl['attr']['type']) { $type = $tpl['attr']['type']; } switch($type) { case 'htmleditor' : $R = 'html'; break; case 'fileselect' : $R = 'file'; break; case 'listselect' : case 'filelist' : case 'filelistselect' : $R = 'files'; break; default : $R = $type; break; } return $R; } function getFieldConf($tpl,$field) { $F = $this->getFieldClass($this->getType($tpl,$field)); return $F->Conf; } function getIcon($tpl,$field) { $F = $this->getFieldClass($this->getType($tpl,$field)); if($F->Conf['icon']) { $R = $F->Conf['icon']; } else { $R = 'edit.png'; } return $R; } function getEditElement($field,$name,$value,$addConf=false,$cnt=false,$allREl=array()) { $attr = $addConf['attr']; $R = array(); $R['name'] = $name; $R['value'] = $value; $R['conf']['cnt'] = $cnt; $R['fieldLabel']= $this->Mizu->getElementName($attr,$field); $ElConf = $this->Mizu->getElementConfFromNameStr($name); $ElConf['field'] = $field; $R['ElConf'] = $ElConf; $t = $this->getType($addConf,$field); $F = $this->getFieldClass($t); $allREl = $F->editAllREl($allREl,$addConf,$R); $R = $F->edit($addConf,$R); if(is_array($addConf)) { $R['addConf'] = $addConf; } if(!$R['addConf']) $R['addConf'] = array(); if(!$R['addConf']['attr']) $R['addConf']['attr'] = array(); if($attr['filter']) { $tmp = explode(',',$attr['filter']); foreach($tmp as $k => $v) { $ftypes.=$this->Mizu->_File->Types[$v].'|'; } $ftypes = substr($ftypes,0,-1); $R['filter'] = $ftypes; } if($attr['height']) { $R['height'] = (int)$attr['height']; } if($attr['width']) { $R['width'] = (int)$attr['width']; } if($addConf) { $R['cls'] = 'from-'.$addConf['attr']['fromTpl']; } $allREl[] = $R; return $allREl; } function setAction() { return true; } function saveAction() { return true; } function editAction($v) { return $v; } function editAllREl($allREl,$addConf,$R) { return $allREl; } function edit($addConf,$R) { return array_merge($R,$this->Conf); } function getSetValue($v) { return $v; } function getGetValue($v) { return strip_tags(strtr($v,array("\n"=>' ',"\r"=>' '))); } } ?>