<?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,$conf=array()) { $c = $t.'Field'; if(class_exists($c)) { $F = new $c; } else { $F = new textField; } $F->Mizu = $this->Mizu; if($conf) { $F->Conf = $conf; } 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(method_exists($F, 'getFieldIcon')) { $R = $F->getFieldIcon($tpl,$field); } else if($F->Conf['icon']) { $R = $F->Conf['icon']; } else { $R = 'pencil'; } 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-item from-'.$addConf['attr']['fromTpl']; if($addConf['attr']['adv']) { $R['cls'].= ' adv-item '; $this->hadAdvancedFields = true; } else { $R['cls'].= ' base-item '; } } $R['value'] = $this->Mizu->_Helper->checkEncodingDBproblems($R['value']); $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"=>' '))); } } 